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-2025 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 $result = $object->delete($user);
206 if ($result > 0) {
207 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
208 header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1');
209 exit;
210 } else {
211 setEventMessages($object->error, $object->errors, 'errors');
212 $action = '';
213 }
214 }
215
216 // Update warehouse
217 if ($action == 'update' && !$cancel && $user->hasRight('stock', 'creer')) {
218 if ($object->fetch($id)) {
219 $object->label = GETPOST("libelle");
220 $object->fk_parent = GETPOSTINT("fk_parent");
221 $object->fk_project = GETPOSTINT('projectid');
222 $object->description = GETPOST("desc", 'restricthtml');
223 $object->statut = GETPOSTINT("statut");
224 $object->lieu = GETPOST("lieu");
225 $object->address = GETPOST("address");
226 $object->zip = GETPOST("zipcode");
227 $object->town = GETPOST("town");
228 $object->country_id = GETPOSTINT("country_id");
229 $object->phone = GETPOST("phone");
230 $object->fax = GETPOST("fax");
231
232 // Fill array 'array_options' with data from add form
233 $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
234 if ($ret < 0) {
235 $error++;
236 }
237
238 if (!$error) {
239 $ret = $object->update($id, $user);
240 if ($ret < 0) {
241 $error++;
242 }
243 }
244
245 if ($error) {
246 $action = 'edit';
247 setEventMessages($object->error, $object->errors, 'errors');
248 } else {
249 $categories = GETPOST('categories', 'array:int');
250 $object->setCategories($categories);
251 $action = '';
252 }
253 } else {
254 $action = 'edit';
255 setEventMessages($object->error, $object->errors, 'errors');
256 }
257 } elseif ($action == 'update_extras' && $permissiontoeditextra) {
258 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
259
260 $attribute_name = GETPOST('attribute', 'aZ09');
261
262 // Fill array 'array_options' with data from update form
263 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
264 if ($ret < 0) {
265 $error++;
266 }
267
268 if (!$error) {
269 $result = $object->updateExtraField($attribute_name, 'PRODUCT_MODIFY');
270 if ($result < 0) {
271 setEventMessages($object->error, $object->errors, 'errors');
272 $error++;
273 }
274 }
275
276 if ($error) {
277 $action = 'edit_extras';
278 }
279 } elseif ($action == 'classin' && $usercancreate) {
280 // Link to a project
281 $object->setProject(GETPOSTINT('projectid'));
282 }
283
284 if ($cancel == $langs->trans("Cancel")) {
285 $action = '';
286 }
287
288 // Actions when printing a doc from card
289 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
290
291 // Actions to build doc
292 $upload_dir = $conf->stock->dir_output;
293 $permissiontoadd = $user->hasRight('stock', 'creer');
294 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
295}
296
297
298/*
299 * View
300 */
301
302$productstatic = new Product($db);
303$form = new Form($db);
304$formproduct = new FormProduct($db);
305$formcompany = new FormCompany($db);
306$formfile = new FormFile($db);
307$formproject = null;
308if (isModEnabled('project')) {
309 $formproject = new FormProjets($db);
310}
311
312$title = $langs->trans("WarehouseCard");
313if ($action == 'create') {
314 $title = $langs->trans("NewWarehouse");
315}
316
317$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
318llxHeader("", $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-stock_card');
319
320
321if ($action == 'create') {
322 print load_fiche_titre($langs->trans("NewWarehouse"), '', 'stock');
323
324 dol_set_focus('input[name="libelle"]');
325
326 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
327 print '<input type="hidden" name="token" value="'.newToken().'">';
328 print '<input type="hidden" name="action" value="add">';
329 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
330
331 print dol_get_fiche_head();
332
333 print '<table class="border centpercent">';
334
335 // Ref
336 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td><input class="width200" name="libelle" value=""></td></tr>';
337
338 print '<tr><td>'.$langs->trans("LocationSummary").'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu : '').'"></td></tr>';
339
340 // Parent entrepot
341 print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
342 print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses((GETPOSTISSET('fk_parent') ? GETPOSTINT('fk_parent') : 'ifone'), 'fk_parent', '', 1);
343 print '</td></tr>';
344
345 // Project
346 if (isModEnabled('project') && $formproject !== null) {
347 $langs->load('projects');
348 print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
349 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');
350 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>';
351 print '</td></tr>';
352 }
353
354 // Description
355 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
356 // Editeur wysiwyg
357 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
358 $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%');
359 $doleditor->Create();
360 print '</td></tr>';
361
362 print '<tr><td>'.$langs->trans('Address').'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
363 print(!empty($object->address) ? $object->address : '');
364 print '</textarea></td></tr>';
365
366 // Zip / Town
367 print '<tr><td>'.$langs->trans('Zip').'</td><td>';
368 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip : ''), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
369 print '</td></tr>';
370 print '<tr><td>'.$langs->trans('Town').'</td><td>';
371 print $formcompany->select_ziptown((!empty($object->town) ? $object->town : ''), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
372 print '</td></tr>';
373
374 // Country
375 print '<tr><td>'.$langs->trans('Country').'</td><td>';
376 print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
377 print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id');
378 if ($user->admin) {
379 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
380 }
381 print '</td></tr>';
382
383 // Phone / Fax
384 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td><td>';
385 print img_picto('', 'object_phoning', 'class="pictofixedwidth"');
386 print '<input name="phone" size="20" value="'.$object->phone.'"></td></tr>';
387 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td>';
388 print '<td>';
389 print img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"');
390 print '<input name="fax" size="20" value="'.$object->fax.'"></td></tr>';
391
392 // Warehouse usage
393 if (getDolGlobalInt("MAIN_FEATURES_LEVEL")) {
394 // TODO
395 }
396
397 // Status
398 print '<tr><td>'.$langs->trans("Status").'</td><td>';
399 print '<select id="warehousestatus" name="statut" class="flat minwidth100">';
400 foreach ($object->labelStatus as $key => $value) {
401 if ($key == 1) {
402 print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
403 } else {
404 print '<option value="'.$key.'">'.$langs->trans($value).'</option>';
405 }
406 }
407 print '</select>';
408 print ajax_combobox('warehousestatus');
409 print '</td></tr>';
410
411 // Other attributes
412 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
413
414 if (isModEnabled('category')) {
415 // Categories
416 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
417 print $form->selectCategories(Categorie::TYPE_WAREHOUSE, 'categories', $object);
418 print "</td></tr>";
419 }
420 print '</table>';
421
422 print dol_get_fiche_end();
423
424 print $form->buttonsSaveCancel("Create");
425
426 print '</form>';
427} else {
428 $id = GETPOSTINT("id");
429 if ($id > 0 || $ref) {
430 $object = new Entrepot($db);
431 $result = $object->fetch($id, $ref);
432 if ($result <= 0) {
433 print 'No record found';
434 exit;
435 }
436
437 // View mode
438 if ($action != 'edit' && $action != 're-edit') {
439 $head = stock_prepare_head($object);
440
441 print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock');
442
443 $formconfirm = '';
444
445 // Confirm delete warehouse
446 if ($action == 'delete') {
447 $formquestion = array(
448 array('type' => 'other', 'name' => 'info', 'label' => img_warning('').$langs->trans("WarningThisWIllAlsoDeleteStock"), 'morecss' => 'warning')
449 );
450 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", $formquestion, 0, 2);
451 }
452
453 // Call Hook formConfirm
454 $parameters = array('context' => 'warehousecard', 'formConfirm' => $formconfirm);
455 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
456 if (empty($reshook)) {
457 $formconfirm .= $hookmanager->resPrint;
458 } elseif ($reshook > 0) {
459 $formconfirm = $hookmanager->resPrint;
460 }
461
462 // Print form confirm
463 print $formconfirm;
464
465 // Warehouse card
466 $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
467
468 $morehtmlref = '<div class="refidno">';
469 $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
470
471 // Project
472 if (isModEnabled('project') && $formproject !== null) {
473 $langs->load("projects");
474 $morehtmlref .= '<br>'.img_picto('', 'project', 'class="pictofixedwidth"').' '.$langs->trans('Project').' ';
475 if ($usercancreate) {
476 if ($action != 'classify') {
477 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
478 }
479 if ($action == 'classify') {
480 $projectid = $object->fk_project;
481 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
482 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
483 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
484 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
485 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
486 $morehtmlref .= '</form>';
487 } else {
488 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, ($socid > 0 ? $socid : -1), (string) $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
489 }
490 } else {
491 if (!empty($object->fk_project)) {
492 $proj = new Project($db);
493 $proj->fetch($object->fk_project);
494 $morehtmlref .= ' : '.$proj->getNomUrl(1);
495 if ($proj->title) {
496 $morehtmlref .= ' - '.$proj->title;
497 }
498 } else {
499 $morehtmlref .= '';
500 }
501 }
502 }
503 $morehtmlref .= '</div>';
504
505 $shownav = 1;
506 if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
507 $shownav = 0;
508 }
509
510 dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref);
511
512 print '<div class="fichecenter">';
513 print '<div class="fichehalfleft">';
514 print '<div class="underbanner clearboth"></div>';
515
516 print '<table class="border centpercent tableforfield">';
517
518 // Parent entrepot
519 $parentwarehouse = new Entrepot($db);
520 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
521 print '<tr><td>'.$langs->trans("ParentWarehouse").'</td><td>';
522 print $parentwarehouse->getNomUrl(3);
523 print '</td></tr>';
524 }
525
526 print '<tr>';
527
528 // Description
529 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'.dol_htmlentitiesbr($object->description).'</td></tr>';
530
531 // Warehouse usage
532 if (getDolGlobalInt("STOCK_USE_WAREHOUSE_USAGE")) {
533 $labelusagestring = $object->fields['warehouse_usage']['arrayofkeyval'][empty($object->warehouse_usage) ? 1 : $object->warehouse_usage];
534 $labelusage = $labelusagestring ? $langs->trans($labelusagestring) : 'Unknown';
535 print '<td class="titlefield tdtop">'.$langs->trans("WarehouseUsage").'</td><td>'.dol_htmlentitiesbr($labelusage).'</td></tr>';
536 }
537
538 $calcproductsunique = $object->nb_different_products();
539 $calcproducts = $object->nb_products();
540
541 // Total nb of different products
542 print '<tr><td>'.$langs->trans("NumberOfDifferentProducts").'</td><td>';
543 print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb'];
544 print "</td></tr>";
545
546 // Nb of products
547 print '<tr><td>'.$langs->trans("NumberOfProducts").'</td><td>';
548 $valtoshow = price2num($calcproducts['nb'], 'MS');
549 print empty($valtoshow) ? '0' : $valtoshow;
550 print "</td></tr>";
551
552 print '</table>';
553
554 print '</div>';
555 print '<div class="fichehalfright">';
556 print '<div class="underbanner clearboth"></div>';
557
558 print '<table class="border centpercent tableforfield">';
559
560 // Value
561 if ($usercancreadsupplierprice) {
562 print '<tr><td class="titlefield">'.$langs->trans("EstimatedStockValueShort").'</td><td>';
563 print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency);
564 print "</td></tr>";
565 }
566
567 // Last movement
568 if ($user->hasRight('stock', 'mouvement', 'lire')) {
569 $sql = "SELECT max(m.datem) as datem";
570 $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
571 $sql .= " WHERE m.fk_entrepot = ".((int) $object->id);
572 $lastmovementdate = 0;
573 $resqlbis = $db->query($sql);
574 if ($resqlbis) {
575 $obj = $db->fetch_object($resqlbis);
576 $lastmovementdate = $db->jdate($obj->datem);
577 } else {
579 }
580 print '<tr><td>'.$langs->trans("LastMovement").'</td><td>';
581 if ($lastmovementdate) {
582 print dol_print_date($lastmovementdate, 'dayhour');
583 print ' &nbsp; &nbsp; ';
584 print img_picto($langs->trans('LastMovement'), 'movement', 'class="pictofixedwidth"');
585 print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id.'">'.$langs->trans("FullList").'</a>';
586 } else {
587 print $langs->trans("None");
588 }
589 print "</td></tr>";
590 }
591
592 // Other attributes
593 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
594
595 // Categories
596 if (isModEnabled('category')) {
597 print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
598 print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
599 print "</td></tr>";
600 }
601
602 print "</table>";
603
604 print '</div>';
605 print '</div>';
606
607 print '<div class="clearboth"></div>';
608
609 print dol_get_fiche_end();
610
611
612 /*
613 * Action bar
614 */
615 print "<div class=\"tabsAction\">\n";
616
617 $parameters = array('context' => 'warehousecard');
618 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
619 if (empty($reshook)) {
620 if (empty($action) || $action == 'classin') {
621 if ($user->hasRight('stock', 'creer')) {
622 print '<a class="butAction" href="card.php?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
623 } else {
624 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Modify").'</a>';
625 }
626
627 if ($user->hasRight('stock', 'supprimer')) {
628 print '<a class="butActionDelete" href="card.php?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
629 } else {
630 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete").'</a>';
631 }
632 }
633 }
634
635 print "</div>";
636
637 // Show list of products into warehouse
638
639 $totalarray = array();
640 $totalarray['val'] = array();
641 $totalarray['pos'] = array();
642 $totalarray['type'] = array();
643 $totalarray['nbfield'] = 0;
644
645 // TODO Create $arrayfields with all fields to show
646
647 print load_fiche_titre($langs->trans("Stock"), '', 'stock');
648
649 print '<div class="div-table-responsive">';
650 print '<table class="noborder centpercent liste">';
651 print '<tr class="liste_titre">';
652 $parameters = array('context' => 'warehousecard', 'totalarray' => &$totalarray);
653 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
654 print $hookmanager->resPrint;
655
656 print_liste_field_titre("Products", "", "p.ref", "", "&id=".$object->id, "", $sortfield, $sortorder);
657 print_liste_field_titre("Label", "", "p.label", "", "&id=".$object->id, "", $sortfield, $sortorder);
658 print_liste_field_titre("NumberOfUnit", "", "ps.reel", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
659 $totalarray['nbfield'] += 3;
660 $totalarray['pos'][$totalarray['nbfield']] = 'totalunit';
661 $totalarray['type'][$totalarray['nbfield']] = 'stock';
662
663 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
664 print_liste_field_titre("Unit", "", "p.fk_unit", "", "&id=".$object->id, 'align="left"', $sortfield, $sortorder);
665 $totalarray['nbfield']++;
666 $totalarray['pos'][$totalarray['nbfield']] = 'units';
667 $totalarray['type'][$totalarray['nbfield']] = 'string';
668 }
669 if ($usercancreadsupplierprice) {
670 print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
671 $totalarray['nbfield']++;
672
673 print_liste_field_titre("EstimatedStockValueShort", "", "svalue", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
674 $totalarray['nbfield']++;
675 $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue';
676 $totalarray['type'][$totalarray['nbfield']] = '';
677 }
678
679 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
680 print_liste_field_titre("SellPriceMin", "", "p.price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
681 $totalarray['nbfield']++;
682 }
683 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
684 print_liste_field_titre("EstimatedStockValueSellShort", "", "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right ');
685 $totalarray['nbfield']++;
686 $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell';
687 $totalarray['type'][$totalarray['nbfield']] = '';
688 }
689 if ($user->hasRight('stock', 'mouvement', 'creer')) {
691 $totalarray['nbfield']++;
692 }
693 if ($user->hasRight('stock', 'creer')) {
695 $totalarray['nbfield']++;
696 }
697 // Hook fields
698 $parameters = array('context' => 'warehousecard', 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
699 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
700 print $hookmanager->resPrint;
701 print "</tr>\n";
702
703 $totalunit = 0;
704 $totalvalue = $totalvaluesell = 0;
705
706 //For MultiCompany PMP per entity
707 $separatedPMP = false;
708 if (getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED') && getDolGlobalString('MULTICOMPANY_PMP_PER_ENTITY_ENABLED')) {
709 $separatedPMP = true;
710 }
711
712 $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,";
713 $sql .= "p.tosell, p.tobuy,";
714 $sql .= "p.accountancy_code_sell,";
715 $sql .= "p.accountancy_code_sell_intra,";
716 $sql .= "p.accountancy_code_sell_export,";
717 $sql .= "p.accountancy_code_buy,";
718 $sql .= "p.accountancy_code_buy_intra,";
719 $sql .= "p.accountancy_code_buy_export,";
720 $sql .= 'p.barcode,';
721 if ($separatedPMP) {
722 // COALESCE: a product may have no row yet in llx_product_perentity (rows are created
723 // on the first stock movement), so fall back on the global p.pmp like Product::fetch()
724 // does, instead of showing an empty AWP.
725 $sql .= " COALESCE(pa.pmp, p.pmp) as ppmp,";
726 } else {
727 $sql .= " p.pmp as ppmp,";
728 }
729 $sql .= " ps.reel as value";
730 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
731 $sql .= ",fk_unit";
732 }
733 // svalue is the sort key of the "estimated value" column, so it must use the same AWP
734 // as ppmp above (the displayed value is recomputed in PHP from ppmp).
735 if ($separatedPMP) {
736 $sql .= ", (ps.reel * COALESCE(pa.pmp, p.pmp)) as svalue";
737 } else {
738 $sql .= ", (ps.reel * p.pmp) as svalue";
739 }
740 // Add fields from hooks
741 $parameters = array('context' => 'warehousecard');
742 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
743 if ($reshook > 0) { //Note that $sql is replaced if reshook > 0
744 $sql = "";
745 }
746 $sql .= $hookmanager->resPrint;
747 $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
748
749 if ($separatedPMP) {
750 // LEFT JOIN (not an inner join): a product with no llx_product_perentity row must
751 // still be listed in the warehouse content, falling back on the global p.pmp.
752 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = ".((int) $conf->entity);
753 }
754 $parameters = array('context' => 'warehousecard');
755 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook
756 if ($reshook > 0) { //Note that $sql is replaced if reshook > 0
757 $sql = "";
758 }
759 $sql .= $hookmanager->resPrint;
760
761 $sql .= " WHERE ps.fk_product = p.rowid";
762 $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse)
763 $sql .= " AND ps.fk_entrepot = ".((int) $object->id);
764
765 $parameters = array('context' => 'warehousecard');
766 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
767 if ($reshook > 0) { //Note that $sql is replaced if reshook > 0
768 $sql = "";
769 }
770 $sql .= $hookmanager->resPrint;
771
772 $sql .= $db->order($sortfield, $sortorder);
773
774 dol_syslog('List products', LOG_DEBUG);
775 $resql = $db->query($sql);
776 if ($resql) {
777 $num = $db->num_rows($resql);
778 $i = 0;
779 $units = 0;
780 $sameunits = true;
781
782 while ($i < $num) {
783 $objp = $db->fetch_object($resql);
784
785 // Multilangs
786 if (getDolGlobalInt('MAIN_MULTILANGS')) { // si l'option est active
787 $sql = "SELECT label";
788 $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
789 $sql .= " WHERE fk_product = ".((int) $objp->rowid);
790 $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
791 $sql .= " LIMIT 1";
792
793 $result = $db->query($sql);
794 if ($result) {
795 $objtp = $db->fetch_object($result);
796 if (isset($objtp->label) && $objtp->label != '') {
797 $objp->produit = $objtp->label;
798 }
799 }
800 }
801
802 //print '<td>'.dol_print_date($objp->datem).'</td>';
803 print '<tr class="oddeven">';
804
805 $productstatic->id = $objp->rowid;
806 $productstatic->ref = $objp->ref;
807 $productstatic->label = $objp->produit;
808 $productstatic->type = $objp->type;
809 $productstatic->entity = $objp->entity;
810 $productstatic->status_batch = $objp->tobatch;
811 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
812 $productstatic->fk_unit = $objp->fk_unit;
813 }
814 $productstatic->status = $objp->tosell;
815 $productstatic->status_buy = $objp->tobuy;
816 $productstatic->barcode = $objp->barcode;
817 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
818 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
819 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
820 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
821 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
822 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
823
824 // Ref
825 print "<td>";
826 print $productstatic->getNomUrl(1, 'stock', 16);
827 print '</td>';
828
829 // Label
830 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).'">'.dol_escape_htmltag($objp->produit).'</td>';
831
832 // Value
833 print '<td class="right">';
834 $valtoshow = price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function
835 print empty($valtoshow) ? '0' : $valtoshow;
836 print '</td>';
837 $totalunit += $objp->value;
838
839 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
840 // Units
841 print '<td align="left">';
842 if (is_null($productstatic->fk_unit)) {
843 $productstatic->fk_unit = 1;
844 }
845 print $productstatic->getLabelOfUnit('long', $langs);
846 print '</td>';
847 }
848 if ($usercancreadsupplierprice) {
849 // Price buy PMP
850 print '<td class="right nowraponall">'.price(price2num($objp->ppmp, 'MU')).'</td>';
851
852 // Total PMP
853 print '<td class="right amount nowraponall">'.price(price2num($objp->ppmp * $objp->value, 'MT')).'</td>';
854 $totalvalue += price2num($objp->ppmp * $objp->value, 'MT');
855 }
856 $pricemin = 0;
857 // Price sell min
858 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
859 $pricemin = $objp->price;
860 print '<td class="right">';
861 print price(price2num($pricemin, 'MU'), 1);
862 print '</td>';
863 // Total sell min
864 print '<td class="right">';
865 print price(price2num($pricemin * $objp->value, 'MT'), 1);
866 print '</td>';
867 }
868 $totalvaluesell += price2num($pricemin * $objp->value, 'MT');
869
870 // Link to transfer
871 if ($user->hasRight('stock', 'mouvement', 'creer')) {
872 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).'">';
873 print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
874 print $langs->trans("TransferStock");
875 print "</a></td>";
876 }
877
878 // Link to stock
879 if ($user->hasRight('stock', 'creer')) {
880 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).'">';
881 print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
882 print $langs->trans("CorrectStock");
883 print "</a></td>";
884 }
885
886 $parameters = array('context' => 'warehousecard', 'obj' => $objp, 'totalarray' => &$totalarray);
887 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
888 print $hookmanager->resPrint;
889
890 print "</tr>";
891
892 // Define $unit and $sameunits
893 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
894 if ($i == 0) {
895 $units = $productstatic->fk_unit;
896 } elseif ($productstatic->fk_unit != $units) {
897 $sameunits = false;
898 }
899 }
900
901 $i++;
902 }
903 $db->free($resql);
904
905 $totalarray['val']['totalunit'] = $totalunit;
906 $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT');
907 $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT');
908 $totalarray['val']['units'] = $productstatic->getLabelOfUnit('long', $langs);
909
910 $parameters = array('context' => 'warehousecard', 'totalarray' => &$totalarray);
911 // Note that $action and $object may have been modified by hook
912 $reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object);
913 if ($reshook < 0) {
914 setEventMessages($hookmanager->error, $hookmanager->errors);
915 }
916
917 // Show total line
918 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
919 } else {
921 }
922 print "</table>";
923 print '</div>';
924 }
925
926
927 // Edit mode
928 if ($action == 'edit' || $action == 're-edit') {
929 $langs->trans("WarehouseEdit");
930
931 print '<form action="card.php" method="POST">';
932 print '<input type="hidden" name="token" value="'.newToken().'">';
933 print '<input type="hidden" name="action" value="update">';
934 print '<input type="hidden" name="id" value="'.$object->id.'">';
935
936 $head = stock_prepare_head($object);
937
938 print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock');
939
940 print '<table class="border centpercent">';
941
942 // Ref
943 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td><input name="libelle" size="20" value="'.$object->label.'"></td></tr>';
944
945 print '<tr><td>'.$langs->trans("LocationSummary").'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.'"></td></tr>';
946
947 // Parent entrepot
948 print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
949 print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1);
950 print '</td></tr>';
951
952 // Project
953 if (isModEnabled('project') && $formproject !== null) {
954 $projectid = $object->fk_project;
955 $langs->load('projects');
956 print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
957 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');
958 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>';
959 print '</td></tr>';
960 }
961
962 // Description
963 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
964 // Editeur wysiwyg
965 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
966 $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%');
967 $doleditor->Create();
968 print '</td></tr>';
969
970 print '<tr><td>'.$langs->trans('Address').'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
971 print $object->address;
972 print '</textarea></td></tr>';
973
974 // Zip / Town
975 print '<tr><td>'.$langs->trans('Zip').'</td><td>';
976 print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
977 print '</td></tr>';
978 print '<tr><td>'.$langs->trans('Town').'</td><td>';
979 print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
980 print '</td></tr>';
981
982 // Country
983 print '<tr><td>'.$langs->trans('Country').'</td><td>';
984 print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
985 print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code, 'country_id');
986 if ($user->admin) {
987 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
988 }
989 print '</td></tr>';
990
991 // Phone / Fax
992 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td><td>';
993 print img_picto('', 'object_phoning', 'class="pictofixedwidth"');
994 print '<input name="phone" size="20" value="'.$object->phone.'"></td></tr>';
995 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td><td>';
996 print img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"');
997 print '<input name="fax" size="20" value="'.$object->fax.'"></td></tr>';
998
999 // Status
1000 print '<tr><td>'.$langs->trans("Status").'</td><td>';
1001 print '<select id="warehousestatus" name="statut" class="flat">';
1002 foreach ($object->labelStatus as $key => $value) {
1003 if ($key == $object->statut) {
1004 print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
1005 } else {
1006 print '<option value="'.$key.'">'.$langs->trans($value).'</option>';
1007 }
1008 }
1009 print '</select>';
1010 print ajax_combobox('warehousestatus');
1011
1012 print '</td></tr>';
1013
1014 // Other attributes
1015 $parameters = array('context' => 'warehousecard', 'colspan' => ' colspan="3"', 'cols' => '3');
1016 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1017 print $hookmanager->resPrint;
1018 if (empty($reshook)) {
1019 print $object->showOptionals($extrafields, 'edit', $parameters);
1020 }
1021
1022 // Tags-Categories
1023 if (isModEnabled('category')) {
1024 print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
1025 print $form->selectCategories(Categorie::TYPE_WAREHOUSE, 'categories', $object);
1026 print "</td></tr>";
1027 }
1028
1029 print '</table>';
1030
1031 print dol_get_fiche_end();
1032
1033 print $form->buttonsSaveCancel();
1034
1035 print '</form>';
1036 }
1037 }
1038}
1039
1040/*
1041 * Documents generated
1042 */
1043
1044$modulepart = 'stock';
1045
1046if ($action != 'create' && $action != 'edit' && $action != 'delete') {
1047 print '<br>';
1048 print '<div class="fichecenter"><div class="fichehalfleft">';
1049 print '<a name="builddoc"></a>'; // ancre
1050
1051 // Documents
1052 $objectref = dol_sanitizeFileName((string) $object->ref);
1053 $relativepath = $object->ref.'/'.$objectref.'.pdf';
1054 $filedir = $conf->stock->dir_output.'/'.$objectref;
1055 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
1056 $genallowed = $usercanread;
1057 $delallowed = $usercancreate;
1058 $modulepart = 'stock';
1059
1060 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', '', '', $object);
1061 $somethingshown = $formfile->numoffiles;
1062
1063 print '</div><div class="fichehalfright">';
1064
1065 $MAXEVENT = 10;
1066
1067 $morehtmlcenter = '';
1068 //$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/product/stock/agenda.php?id='.$object->id);
1069
1070 // List of actions on element
1071 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1072 $formactions = new FormActions($db);
1073 $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for product
1074
1075 print '</div></div>';
1076}
1077
1078// End of page
1079llxFooter();
1080$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
$totalarray
Definition list.php:501
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:476
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:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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).
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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:519
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
Definition html.lib.php:172
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
stock_prepare_head($object)
Prepare array with list of tabs.
Definition stock.lib.php:32