dolibarr 25.0.0-alpha
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
5 * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2016 Francis Appels <francis.appels@yahoo.com>
7 * Copyright (C) 2021 Noé Cendrier <noe.cendrier@altairis.fr>
8 * Copyright (C) 2021-2026 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2022-2025 Charlene Benke <charlene@patas-monkey.com>
10 * Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
11 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33// Load Dolibarr environment
34require '../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
36require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
37require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
43require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
44if (isModEnabled('project')) {
45 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
47}
48
58// Load translation files required by the page
59$langs->loadLangs(array('products', 'stocks', 'companies', 'categories'));
60
61$action = GETPOST('action', 'aZ09');
62$cancel = GETPOST('cancel', 'alpha');
63$confirm = GETPOST('confirm');
64$backtopage = GETPOST('backtopage', 'alpha');
65$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
66
67$projectid = GETPOSTINT('projectid');
68
69$id = GETPOSTINT('id');
70$socid = GETPOSTINT('socid');
71$ref = GETPOST('ref', 'alpha');
72
73// Load variable for pagination
74$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
75$sortfield = GETPOST('sortfield', 'aZ09comma');
76$sortorder = GETPOST('sortorder', 'aZ09comma');
77if (!$sortfield) {
78 $sortfield = "p.ref";
79}
80if (!$sortorder) {
81 $sortorder = "DESC";
82}
83
84// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
85$hookmanager->initHooks(array('warehousecard', 'stocklist', 'globalcard'));
86
87// Security check
88$result=restrictedArea($user, 'stock', $id, 'entrepot&stock');
89
90$usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_supplier_prices') : $user->hasRight('product', 'read');
91
92$object = new Entrepot($db);
93$extrafields = new ExtraFields($db);
94
95// fetch optionals attributes and labels
96$extrafields->fetch_name_optionals_label($object->table_element);
97
98// Load object
99if ($id > 0 || !empty($ref)) {
100 $ret = $object->fetch($id, $ref);
101 if ($ret <= 0) {
102 setEventMessages($object->error, $object->errors, 'errors');
103 $action = '';
104 }
105}
106
107$usercanread = $user->hasRight('stock', 'lire');
108$usercancreate = $user->hasRight('stock', 'creer');
109$usercandelete = $user->hasRight('stock', 'supprimer');
110$permissiontoeditextra = $usercancreate;
111if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
112 // For action 'update_extras', is there a specific permission set for the attribute to update
113 $permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
114}
115
116
117/*
118 * Actions
119 */
120
121$error = 0;
122
123$parameters = array('context' => 'warehousecard', 'id' => $id, 'ref' => $ref);
124$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
125if ($reshook < 0) {
126 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
127}
128if (empty($reshook)) {
129 $backurlforlist = DOL_URL_ROOT.'/product/stock/list.php';
130
131 if (empty($backtopage) || ($cancel && empty($id))) {
132 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
133 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
134 $backtopage = $backurlforlist;
135 } else {
136 $backtopage = DOL_URL_ROOT.'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
137 }
138 }
139 }
140
141 if ($cancel) {
142 if (!empty($backtopageforcancel)) {
143 header("Location: ".$backtopageforcancel);
144 exit;
145 } elseif (!empty($backtopage)) {
146 header("Location: ".$backtopage);
147 exit;
148 }
149 $action = '';
150 }
151
152 // Ajout entrepot
153 if ($action == 'add' && $user->hasRight('stock', 'creer')) {
154 $object->ref = (string) GETPOST("ref", "alpha");
155 $object->fk_parent = GETPOSTINT("fk_parent");
156 $object->fk_project = GETPOSTINT('projectid');
157 $object->label = (string) GETPOST("libelle", "alpha");
158 $object->description = (string) GETPOST("desc", "alpha");
159 $object->statut = GETPOSTINT("statut");
160 $object->lieu = (string) GETPOST("lieu", "alpha");
161 $object->address = (string) GETPOST("address", "alpha");
162 $object->zip = (string) GETPOST("zipcode", "alpha");
163 $object->town = (string) GETPOST("town", "alpha");
164 $object->country_id = GETPOSTINT("country_id");
165 $object->phone = (string) GETPOST("phone", "alpha");
166 $object->fax = (string) GETPOST("fax", "alpha");
167
168 if (!empty($object->label)) {
169 // Fill array 'array_options' with data from add form
170 $ret = $extrafields->setOptionalsFromPost(null, $object);
171 if ($ret < 0) {
172 $error++;
173 $action = 'create';
174 }
175
176 if (!$error) {
177 $id = $object->create($user);
178 if ($id > 0) {
179 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
180
181 $categories = GETPOST('categories', 'array:int');
182 $object->setCategories($categories);
183 if (!empty($backtopage)) {
184 $backtopage = str_replace("__ID__", (string) $id, $backtopage);
185 header("Location: ".$backtopage);
186 exit;
187 } else {
188 header("Location: card.php?id=".urlencode((string) ($id)));
189 exit;
190 }
191 } else {
192 $action = 'create';
193 setEventMessages($object->error, $object->errors, 'errors');
194 }
195 }
196 } else {
197 setEventMessages($langs->trans("ErrorWarehouseRefRequired"), null, 'errors');
198 $action = "create"; // Force retour sur page creation
199 }
200 }
201
202 // Delete warehouse
203 if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('stock', 'supprimer')) {
204 $object->fetch(GETPOSTINT('id'));
205 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
206 $result = $object->delete($user);
207 if ($result > 0) {
208 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
209 header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1');
210 exit;
211 } else {
212 setEventMessages($object->error, $object->errors, 'errors');
213 $action = '';
214 }
215 }
216
217 // Update warehouse
218 if ($action == 'update' && !$cancel && $user->hasRight('stock', 'creer')) {
219 if ($object->fetch($id)) {
220 $object->label = GETPOST("libelle");
221 $object->fk_parent = GETPOSTINT("fk_parent");
222 $object->fk_project = GETPOSTINT('projectid');
223 $object->description = GETPOST("desc", 'restricthtml');
224 $object->statut = GETPOSTINT("statut");
225 $object->lieu = GETPOST("lieu");
226 $object->address = GETPOST("address");
227 $object->zip = GETPOST("zipcode");
228 $object->town = GETPOST("town");
229 $object->country_id = GETPOSTINT("country_id");
230 $object->phone = GETPOST("phone");
231 $object->fax = GETPOST("fax");
232
233 // Fill array 'array_options' with data from add form
234 $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
235 if ($ret < 0) {
236 $error++;
237 }
238
239 if (!$error) {
240 $ret = $object->update($id, $user);
241 if ($ret < 0) {
242 $error++;
243 }
244 }
245
246 if ($error) {
247 $action = 'edit';
248 setEventMessages($object->error, $object->errors, 'errors');
249 } else {
250 $categories = GETPOST('categories', 'array:int');
251 $object->setCategories($categories);
252 $action = '';
253 }
254 } else {
255 $action = 'edit';
256 setEventMessages($object->error, $object->errors, 'errors');
257 }
258 } elseif ($action == 'update_extras' && $permissiontoeditextra) {
259 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
260
261 $attribute_name = GETPOST('attribute', 'aZ09');
262
263 // Fill array 'array_options' with data from update form
264 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
265 if ($ret < 0) {
266 $error++;
267 }
268
269 if (!$error) {
270 $result = $object->updateExtraField($attribute_name, 'PRODUCT_MODIFY');
271 if ($result < 0) {
272 setEventMessages($object->error, $object->errors, 'errors');
273 $error++;
274 }
275 }
276
277 if ($error) {
278 $action = 'edit_extras';
279 }
280 } elseif ($action == 'classin' && $usercancreate) {
281 // Link to a project
282 $object->setProject(GETPOSTINT('projectid'));
283 }
284
285 if ($cancel == $langs->trans("Cancel")) {
286 $action = '';
287 }
288
289 // Actions when printing a doc from card
290 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
291
292 // Actions to build doc
293 $upload_dir = $conf->stock->dir_output;
294 $permissiontoadd = $user->hasRight('stock', 'creer');
295 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
296}
297
298
299/*
300 * View
301 */
302
303$productstatic = new Product($db);
304$form = new Form($db);
305$formproduct = new FormProduct($db);
306$formcompany = new FormCompany($db);
307$formfile = new FormFile($db);
308$formproject = null;
309if (isModEnabled('project')) {
310 $formproject = new FormProjets($db);
311}
312
313$title = $langs->trans("WarehouseCard");
314if ($action == 'create') {
315 $title = $langs->trans("NewWarehouse");
316}
317
318$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
319llxHeader("", $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-stock_card');
320
321
322if ($action == 'create') {
323 print load_fiche_titre($langs->trans("NewWarehouse"), '', 'stock');
324
325 dol_set_focus('input[name="libelle"]');
326
327 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
328 print '<input type="hidden" name="token" value="'.newToken().'">';
329 print '<input type="hidden" name="action" value="add">';
330 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
331
332 print dol_get_fiche_head();
333
334 print '<table class="border centpercent">';
335
336 // Ref
337 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td><input class="width200" name="libelle" value=""></td></tr>';
338
339 print '<tr><td>'.$langs->trans("LocationSummary").'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu : '').'"></td></tr>';
340
341 // Parent entrepot
342 print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
343 print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses((GETPOSTISSET('fk_parent') ? GETPOSTINT('fk_parent') : 'ifone'), 'fk_parent', '', 1);
344 print '</td></tr>';
345
346 // Project
347 if (isModEnabled('project') && $formproject !== null) {
348 $langs->load('projects');
349 print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
350 print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
351 print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$socid.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$socid).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
352 print '</td></tr>';
353 }
354
355 // Description
356 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
357 // Editeur wysiwyg
358 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
359 $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%');
360 $doleditor->Create();
361 print '</td></tr>';
362
363 print '<tr><td>'.$langs->trans('Address').'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
364 print(!empty($object->address) ? $object->address : '');
365 print '</textarea></td></tr>';
366
367 // Zip / Town
368 print '<tr><td>'.$langs->trans('Zip').'</td><td>';
369 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip : ''), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
370 print '</td></tr>';
371 print '<tr><td>'.$langs->trans('Town').'</td><td>';
372 print $formcompany->select_ziptown((!empty($object->town) ? $object->town : ''), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
373 print '</td></tr>';
374
375 // Country
376 print '<tr><td>'.$langs->trans('Country').'</td><td>';
377 print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
378 print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id');
379 if ($user->admin) {
380 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
381 }
382 print '</td></tr>';
383
384 // Phone / Fax
385 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td><td>';
386 print $form->showPhoneInput($object->phone, 'phone', $object->country_id, 'object_phoning', 'maxwidth150 widthcentpercentminusx');
387 print '</td></tr>';
388 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td>';
389 print '<td>';
390 print $form->showPhoneInput($object->fax, 'fax', $object->country_id, 'object_phoning_fax', 'maxwidth150 widthcentpercentminusx');
391 print '</td></tr>';
392
393 // Warehouse usage
394 if (getDolGlobalInt("MAIN_FEATURES_LEVEL")) {
395 // TODO
396 }
397
398 // Status
399 print '<tr><td>'.$langs->trans("Status").'</td><td>';
400 print '<select id="warehousestatus" name="statut" class="flat minwidth100">';
401 foreach ($object->labelStatus as $key => $value) {
402 if ($key == 1) {
403 print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
404 } else {
405 print '<option value="'.$key.'">'.$langs->trans($value).'</option>';
406 }
407 }
408 print '</select>';
409 print ajax_combobox('warehousestatus');
410 print '</td></tr>';
411
412 // Other attributes
413 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
414
415 if (isModEnabled('category')) {
416 // Categories
417 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
418 print $form->selectCategories(Categorie::TYPE_WAREHOUSE, 'categories', $object);
419 print "</td></tr>";
420 }
421 print '</table>';
422
423 print dol_get_fiche_end();
424
425 print $form->buttonsSaveCancel("Create");
426
427 print '</form>';
428} else {
429 $id = GETPOSTINT("id");
430 if ($id > 0 || $ref) {
431 $object = new Entrepot($db);
432 $result = $object->fetch($id, $ref);
433 if ($result <= 0) {
434 print 'No record found';
435 exit;
436 }
437
438 // View mode
439 if ($action != 'edit' && $action != 're-edit') {
440 $head = stock_prepare_head($object);
441
442 print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock');
443
444 $formconfirm = '';
445
446 // Confirm delete warehouse
447 if ($action == 'delete') {
448 $formquestion = array(
449 array('type' => 'other', 'name' => 'info', 'label' => img_warning('').$langs->trans("WarningThisWIllAlsoDeleteStock"), 'morecss' => 'warning')
450 );
451 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", $formquestion, 0, 2);
452 }
453
454 // Call Hook formConfirm
455 $parameters = array('context' => 'warehousecard', 'formConfirm' => $formconfirm);
456 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
457 if (empty($reshook)) {
458 $formconfirm .= $hookmanager->resPrint;
459 } elseif ($reshook > 0) {
460 $formconfirm = $hookmanager->resPrint;
461 }
462
463 // Print form confirm
464 print $formconfirm;
465
466 // Warehouse card
467 $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
468
469 $morehtmlref = '<div class="refidno">';
470 $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
471
472 // Project
473 if (isModEnabled('project') && $formproject !== null) {
474 $langs->load("projects");
475 $morehtmlref .= '<br>'.img_picto('', 'project', 'class="pictofixedwidth"').' '.$langs->trans('Project').' ';
476 if ($usercancreate) {
477 if ($action != 'classify') {
478 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
479 }
480 if ($action == 'classify') {
481 $projectid = $object->fk_project;
482 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
483 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
484 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
485 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
486 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
487 $morehtmlref .= '</form>';
488 } else {
489 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, ($socid > 0 ? $socid : -1), (string) $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
490 }
491 } else {
492 if (!empty($object->fk_project)) {
493 $proj = new Project($db);
494 $proj->fetch($object->fk_project);
495 $morehtmlref .= ' : '.$proj->getNomUrl(1);
496 if ($proj->title) {
497 $morehtmlref .= ' - '.$proj->title;
498 }
499 } else {
500 $morehtmlref .= '';
501 }
502 }
503 }
504 $morehtmlref .= '</div>';
505
506 $shownav = 1;
507 if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
508 $shownav = 0;
509 }
510
511 dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref);
512
513 print '<div class="fichecenter">';
514 print '<div class="fichehalfleft">';
515 print '<div class="underbanner clearboth"></div>';
516
517 print '<table class="border centpercent tableforfield">';
518
519 // Parent entrepot
520 $parentwarehouse = new Entrepot($db);
521 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
522 print '<tr><td>'.$langs->trans("ParentWarehouse").'</td><td>';
523 print $parentwarehouse->getNomUrl(3);
524 print '</td></tr>';
525 }
526
527 print '<tr>';
528
529 // Description
530 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'.dol_htmlentitiesbr($object->description).'</td></tr>';
531
532 // Warehouse usage
533 if (getDolGlobalInt("STOCK_USE_WAREHOUSE_USAGE")) {
534 $labelusagestring = $object->fields['warehouse_usage']['arrayofkeyval'][empty($object->warehouse_usage) ? 1 : $object->warehouse_usage];
535 $labelusage = $labelusagestring ? $langs->trans($labelusagestring) : 'Unknown';
536 print '<td class="titlefield tdtop">'.$langs->trans("WarehouseUsage").'</td><td>'.dol_htmlentitiesbr($labelusage).'</td></tr>';
537 }
538
539 $calcproductsunique = $object->nb_different_products();
540 $calcproducts = $object->nb_products();
541
542 // Total nb of different products
543 print '<tr><td>'.$langs->trans("NumberOfDifferentProducts").'</td><td>';
544 print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb'];
545 print "</td></tr>";
546
547 // Nb of products
548 print '<tr><td>'.$langs->trans("NumberOfProducts").'</td><td>';
549 $valtoshow = price2num($calcproducts['nb'], 'MS');
550 print empty($valtoshow) ? '0' : $valtoshow;
551 print "</td></tr>";
552
553 print '</table>';
554
555 print '</div>';
556 print '<div class="fichehalfright">';
557 print '<div class="underbanner clearboth"></div>';
558
559 print '<table class="border centpercent tableforfield">';
560
561 // Value
562 if ($usercancreadsupplierprice) {
563 print '<tr><td class="titlefield">'.$langs->trans("EstimatedStockValueShort").'</td><td>';
564 print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency);
565 print "</td></tr>";
566 }
567
568 // Last movement
569 if ($user->hasRight('stock', 'mouvement', 'lire')) {
570 $sql = "SELECT max(m.datem) as datem";
571 $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
572 $sql .= " WHERE m.fk_entrepot = ".((int) $object->id);
573 $lastmovementdate = 0;
574 $resqlbis = $db->query($sql);
575 if ($resqlbis) {
576 $obj = $db->fetch_object($resqlbis);
577 $lastmovementdate = $db->jdate($obj->datem);
578 } else {
579 dol_print_error($db);
580 }
581 print '<tr><td>'.$langs->trans("LastMovement").'</td><td>';
582 if ($lastmovementdate) {
583 print dol_print_date($lastmovementdate, 'dayhour');
584 print ' &nbsp; &nbsp; ';
585 print img_picto($langs->trans('LastMovement'), 'movement', 'class="pictofixedwidth"');
586 print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id.'">'.$langs->trans("FullList").'</a>';
587 } else {
588 print $langs->trans("None");
589 }
590 print "</td></tr>";
591 }
592
593 // Other attributes
594 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
595
596 // Categories
597 if (isModEnabled('category')) {
598 print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
599 print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
600 print "</td></tr>";
601 }
602
603 print "</table>";
604
605 print '</div>';
606 print '</div>';
607
608 print '<div class="clearboth"></div>';
609
610 print dol_get_fiche_end();
611
612
613 /*
614 * Action bar
615 */
616 print "<div class=\"tabsAction\">\n";
617
618 $parameters = array('context' => 'warehousecard');
619 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
620 if (empty($reshook)) {
621 if (empty($action) || $action == 'classin') {
622 if ($user->hasRight('stock', 'creer')) {
623 print '<a class="butAction" href="card.php?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
624 } else {
625 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Modify").'</a>';
626 }
627
628 if ($user->hasRight('stock', 'supprimer')) {
629 print dolGetButtonAction($langs->trans("Delete"), $langs->trans("Delete"), 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', true, array('attr' => array('class' => 'reposition')))."\n";
630 } else {
631 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete").'</a>';
632 }
633 }
634 }
635
636 print "</div>";
637
638 // Show list of products into warehouse
639
640 $totalarray = array();
641 $totalarray['val'] = array();
642 $totalarray['pos'] = array();
643 $totalarray['type'] = array();
644 $totalarray['nbfield'] = 0;
645
646 // TODO Create $arrayfields with all fields to show
647
648 print load_fiche_titre($langs->trans("Stock"), '', 'stock');
649
650 print '<div class="div-table-responsive">';
651 print '<table class="noborder centpercent liste">';
652 print '<tr class="liste_titre">';
653 $parameters = array('context' => 'warehousecard', 'totalarray' => &$totalarray);
654 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
655 print $hookmanager->resPrint;
656
657 print_liste_field_titre("Products", "", "p.ref", "", "&id=".$object->id, "", $sortfield, $sortorder);
658 print_liste_field_titre("Label", "", "p.label", "", "&id=".$object->id, "", $sortfield, $sortorder);
659 print_liste_field_titre("NumberOfUnit", "", "ps.reel", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
660 $totalarray['nbfield'] += 3;
661 $totalarray['pos'][$totalarray['nbfield']] = 'totalunit';
662 $totalarray['type'][$totalarray['nbfield']] = 'stock';
663
664 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
665 print_liste_field_titre("Unit", "", "p.fk_unit", "", "&id=".$object->id, 'align="left"', $sortfield, $sortorder);
666 $totalarray['nbfield']++;
667 $totalarray['pos'][$totalarray['nbfield']] = 'units';
668 $totalarray['type'][$totalarray['nbfield']] = 'string';
669 }
670 if ($usercancreadsupplierprice) {
671 print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
672 $totalarray['nbfield']++;
673
674 print_liste_field_titre("EstimatedStockValueShort", "", "svalue", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
675 $totalarray['nbfield']++;
676 $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue';
677 $totalarray['type'][$totalarray['nbfield']] = '';
678 }
679
680 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
681 print_liste_field_titre("SellPriceMin", "", "p.price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
682 $totalarray['nbfield']++;
683 }
684 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
685 print_liste_field_titre("EstimatedStockValueSellShort", "", "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
686 $totalarray['nbfield']++;
687 $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell';
688 $totalarray['type'][$totalarray['nbfield']] = '';
689 }
690 if ($user->hasRight('stock', 'mouvement', 'creer')) {
692 $totalarray['nbfield']++;
693 }
694 if ($user->hasRight('stock', 'creer')) {
696 $totalarray['nbfield']++;
697 }
698 // Hook fields
699 $parameters = array('context' => 'warehousecard', 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
700 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
701 print $hookmanager->resPrint;
702 print "</tr>\n";
703
704 $totalunit = 0;
705 $totalvalue = $totalvaluesell = 0;
706
707 //For MultiCompany PMP per entity
708 $separatedPMP = false;
709 if (getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED') && getDolGlobalString('MULTICOMPANY_PMP_PER_ENTITY_ENABLED')) {
710 $separatedPMP = true;
711 }
712
713 $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.price, p.price_ttc, p.entity,";
714 $sql .= "p.tosell, p.tobuy,";
715 $sql .= "p.accountancy_code_sell,";
716 $sql .= "p.accountancy_code_sell_intra,";
717 $sql .= "p.accountancy_code_sell_export,";
718 $sql .= "p.accountancy_code_buy,";
719 $sql .= "p.accountancy_code_buy_intra,";
720 $sql .= "p.accountancy_code_buy_export,";
721 $sql .= 'p.barcode,';
722 if ($separatedPMP) {
723 // COALESCE: a product may have no row yet in llx_product_perentity (rows are created
724 // on the first stock movement), so fall back on the global p.pmp like Product::fetch()
725 // does, instead of showing an empty AWP.
726 $sql .= " COALESCE(pa.pmp, p.pmp) as ppmp,";
727 } else {
728 $sql .= " p.pmp as ppmp,";
729 }
730 $sql .= " ps.reel as value";
731 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
732 $sql .= ",fk_unit";
733 }
734 // svalue is the sort key of the "estimated value" column, so it must use the same AWP
735 // as ppmp above (the displayed value is recomputed in PHP from ppmp).
736 if ($separatedPMP) {
737 $sql .= ", (ps.reel * COALESCE(pa.pmp, p.pmp)) as svalue";
738 } else {
739 $sql .= ", (ps.reel * p.pmp) as svalue";
740 }
741 // Add fields from hooks
742 $parameters = array('context' => 'warehousecard');
743 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
744 if ($reshook > 0) { //Note that $sql is replaced if reshook > 0
745 $sql = "";
746 }
747 $sql .= $hookmanager->resPrint;
748 $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
749
750 if ($separatedPMP) {
751 // LEFT JOIN (not an inner join): a product with no llx_product_perentity row must
752 // still be listed in the warehouse content, falling back on the global p.pmp.
753 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = ".((int) $conf->entity);
754 }
755 $parameters = array('context' => 'warehousecard');
756 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook
757 if ($reshook > 0) { //Note that $sql is replaced if reshook > 0
758 $sql = "";
759 }
760 $sql .= $hookmanager->resPrint;
761
762 $sql .= " WHERE ps.fk_product = p.rowid";
763 $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse)
764 $sql .= " AND ps.fk_entrepot = ".((int) $object->id);
765
766 $parameters = array('context' => 'warehousecard');
767 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
768 if ($reshook > 0) { //Note that $sql is replaced if reshook > 0
769 $sql = "";
770 }
771 $sql .= $hookmanager->resPrint;
772
773 $sql .= $db->order($sortfield, $sortorder);
774
775 dol_syslog('List products', LOG_DEBUG);
776 $resql = $db->query($sql);
777 if ($resql) {
778 $num = $db->num_rows($resql);
779 $i = 0;
780 $units = 0;
781 $sameunits = true;
782
783 while ($i < $num) {
784 $objp = $db->fetch_object($resql);
785
786 // Multilangs
787 if (getDolGlobalInt('MAIN_MULTILANGS')) { // si l'option est active
788 $sql = "SELECT label";
789 $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
790 $sql .= " WHERE fk_product = ".((int) $objp->rowid);
791 $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
792 $sql .= " LIMIT 1";
793
794 $result = $db->query($sql);
795 if ($result) {
796 $objtp = $db->fetch_object($result);
797 if (isset($objtp->label) && $objtp->label != '') {
798 $objp->produit = $objtp->label;
799 }
800 }
801 }
802
803 //print '<td>'.dol_print_date($objp->datem).'</td>';
804 print '<tr class="oddeven">';
805
806 $productstatic->id = $objp->rowid;
807 $productstatic->ref = $objp->ref;
808 $productstatic->label = $objp->produit;
809 $productstatic->type = $objp->type;
810 $productstatic->entity = $objp->entity;
811 $productstatic->status_batch = $objp->tobatch;
812 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
813 $productstatic->fk_unit = $objp->fk_unit;
814 }
815 $productstatic->status = $objp->tosell;
816 $productstatic->status_buy = $objp->tobuy;
817 $productstatic->barcode = $objp->barcode;
818 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
819 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
820 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
821 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
822 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
823 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
824
825 // Ref
826 print "<td>";
827 print $productstatic->getNomUrl(1, 'stock', 16);
828 print '</td>';
829
830 // Label
831 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).'">'.dol_escape_htmltag($objp->produit).'</td>';
832
833 // Value
834 print '<td class="right">';
835 $valtoshow = price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function
836 print empty($valtoshow) ? '0' : $valtoshow;
837 print '</td>';
838 $totalunit += $objp->value;
839
840 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
841 // Units
842 print '<td align="left">';
843 if (is_null($productstatic->fk_unit)) {
844 $productstatic->fk_unit = 1;
845 }
846 print $productstatic->getLabelOfUnit('long', $langs);
847 print '</td>';
848 }
849 if ($usercancreadsupplierprice) {
850 // Price buy PMP
851 print '<td class="right nowraponall">'.price(price2num($objp->ppmp, 'MU')).'</td>';
852
853 // Total PMP
854 print '<td class="right amount nowraponall">'.price(price2num($objp->ppmp * $objp->value, 'MT')).'</td>';
855 $totalvalue += price2num($objp->ppmp * $objp->value, 'MT');
856 }
857 $pricemin = 0;
858 // Price sell min
859 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
860 $pricemin = $objp->price;
861 print '<td class="right">';
862 print price(price2num($pricemin, 'MU'), 1);
863 print '</td>';
864 // Total sell min
865 print '<td class="right">';
866 print price(price2num($pricemin * $objp->value, 'MT'), 1);
867 print '</td>';
868 }
869 $totalvaluesell += price2num($pricemin * $objp->value, 'MT');
870
871 // Link to transfer
872 if ($user->hasRight('stock', 'mouvement', 'creer')) {
873 print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=transfer&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">';
874 print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
875 print $langs->trans("TransferStock");
876 print "</a></td>";
877 }
878
879 // Link to stock
880 if ($user->hasRight('stock', 'creer')) {
881 print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=correction&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">';
882 print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
883 print $langs->trans("CorrectStock");
884 print "</a></td>";
885 }
886
887 $parameters = array('context' => 'warehousecard', 'obj' => $objp, 'totalarray' => &$totalarray);
888 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
889 print $hookmanager->resPrint;
890
891 print "</tr>";
892
893 // Define $unit and $sameunits
894 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
895 if ($i == 0) {
896 $units = $productstatic->fk_unit;
897 } elseif ($productstatic->fk_unit != $units) {
898 $sameunits = false;
899 }
900 }
901
902 $i++;
903 }
904 $db->free($resql);
905
906 $totalarray['val']['totalunit'] = $totalunit;
907 $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT');
908 $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT');
909 $totalarray['val']['units'] = $productstatic->getLabelOfUnit('long', $langs);
910
911 $parameters = array('context' => 'warehousecard', 'totalarray' => &$totalarray);
912 // Note that $action and $object may have been modified by hook
913 $reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object);
914 if ($reshook < 0) {
915 setEventMessages($hookmanager->error, $hookmanager->errors);
916 }
917
918 // Show total line
919 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
920 } else {
921 dol_print_error($db);
922 }
923 print "</table>";
924 print '</div>';
925 }
926
927
928 // Edit mode
929 if ($action == 'edit' || $action == 're-edit') {
930 $langs->trans("WarehouseEdit");
931
932 print '<form action="card.php" method="POST">';
933 print '<input type="hidden" name="token" value="'.newToken().'">';
934 print '<input type="hidden" name="action" value="update">';
935 print '<input type="hidden" name="id" value="'.$object->id.'">';
936
937 $head = stock_prepare_head($object);
938
939 print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock');
940
941 print '<table class="border centpercent">';
942
943 // Ref
944 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td><input name="libelle" size="20" value="'.$object->label.'"></td></tr>';
945
946 print '<tr><td>'.$langs->trans("LocationSummary").'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.'"></td></tr>';
947
948 // Parent entrepot
949 print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
950 print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1);
951 print '</td></tr>';
952
953 // Project
954 if (isModEnabled('project') && $formproject !== null) {
955 $projectid = $object->fk_project;
956 $langs->load('projects');
957 print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
958 print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
959 print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.($socid > 0 ? $socid : "").'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create'.($socid > 0 ? '&socid='.$socid : "")).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
960 print '</td></tr>';
961 }
962
963 // Description
964 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
965 // Editeur wysiwyg
966 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
967 $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%');
968 $doleditor->Create();
969 print '</td></tr>';
970
971 print '<tr><td>'.$langs->trans('Address').'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
972 print $object->address;
973 print '</textarea></td></tr>';
974
975 // Zip / Town
976 print '<tr><td>'.$langs->trans('Zip').'</td><td>';
977 print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
978 print '</td></tr>';
979 print '<tr><td>'.$langs->trans('Town').'</td><td>';
980 print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
981 print '</td></tr>';
982
983 // Country
984 print '<tr><td>'.$langs->trans('Country').'</td><td>';
985 print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
986 print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code, 'country_id');
987 if ($user->admin) {
988 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
989 }
990 print '</td></tr>';
991
992 // Phone / Fax
993 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td><td>';
994 print $form->showPhoneInput($object->phone, 'phone', $object->country_id, 'object_phoning', 'maxwidth150 widthcentpercentminusx');
995 print '</td></tr>';
996 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td><td>';
997 print $form->showPhoneInput($object->fax, 'fax', $object->country_id, 'object_phoning_fax', 'maxwidth150 widthcentpercentminusx');
998 print '</td></tr>';
999
1000 // Status
1001 print '<tr><td>'.$langs->trans("Status").'</td><td>';
1002 print '<select id="warehousestatus" name="statut" class="flat">';
1003 foreach ($object->labelStatus as $key => $value) {
1004 if ($key == $object->statut) {
1005 print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
1006 } else {
1007 print '<option value="'.$key.'">'.$langs->trans($value).'</option>';
1008 }
1009 }
1010 print '</select>';
1011 print ajax_combobox('warehousestatus');
1012
1013 print '</td></tr>';
1014
1015 // Other attributes
1016 $parameters = array('context' => 'warehousecard', 'colspan' => ' colspan="3"', 'cols' => '3');
1017 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1018 print $hookmanager->resPrint;
1019 if (empty($reshook)) {
1020 print $object->showOptionals($extrafields, 'edit', $parameters);
1021 }
1022
1023 // Tags-Categories
1024 if (isModEnabled('category')) {
1025 print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
1026 print $form->selectCategories(Categorie::TYPE_WAREHOUSE, 'categories', $object);
1027 print "</td></tr>";
1028 }
1029
1030 print '</table>';
1031
1032 print dol_get_fiche_end();
1033
1034 print $form->buttonsSaveCancel();
1035
1036 print '</form>';
1037 }
1038 }
1039}
1040
1041/*
1042 * Documents generated
1043 */
1044
1045$modulepart = 'stock';
1046
1047if ($action != 'create' && $action != 'edit' && $action != 'delete') {
1048 print '<br>';
1049 print '<div class="fichecenter"><div class="fichehalfleft">';
1050 print '<a name="builddoc"></a>'; // ancre
1051
1052 // Documents
1053 $objectref = dol_sanitizeFileName((string) $object->ref);
1054 $relativepath = $object->ref.'/'.$objectref.'.pdf';
1055 $filedir = $conf->stock->dir_output.'/'.$objectref;
1056 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
1057 $genallowed = $usercanread;
1058 $delallowed = $usercancreate;
1059 $modulepart = 'stock';
1060
1061 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', '', '', $object);
1062 $somethingshown = $formfile->numoffiles;
1063
1064 print '</div><div class="fichehalfright">';
1065
1066 $MAXEVENT = 10;
1067
1068 $morehtmlcenter = '';
1069 //$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/product/stock/agenda.php?id='.$object->id);
1070
1071 // List of actions on element
1072 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1073 $formactions = new FormActions($db);
1074 $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for product
1075
1076 print '</div></div>';
1077}
1078
1079// End of page
1080llxFooter();
1081$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
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:477
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 a WYSIWYG editor.
Class to manage warehouses.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage building of HTML components.
Class to manage products or services.
Class to manage projects.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:181
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
stock_prepare_head($object)
Prepare array with list of tabs.
Definition stock.lib.php:32