dolibarr 21.0.3
productlot_card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2018 All-3kcis <contact@all-3kcis.fr>
4 * Copyright (C) 2021 Noé Cendrier <noe.cendrier@altairis.fr>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
36require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
37
46// Load translation files required by the page
47$langs->loadLangs(array('stocks', 'other', 'productbatch'));
48
49// Get parameters
50$action = GETPOST('action', 'aZ09');
51$confirm = GETPOST('confirm', 'alpha');
52$cancel = GETPOST('cancel', 'aZ09');
53$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
54$backtopage = GETPOST('backtopage', 'alpha');
55$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
56
57$id = GETPOSTINT('id');
58$lineid = GETPOSTINT('lineid');
59$batch = GETPOST('batch', 'alpha');
60$productid = GETPOSTINT('productid');
61$ref = GETPOST('ref', 'alpha'); // ref is productid_batch
62
63
64$modulepart = 'product_batch';
65
66
67// Initialize a technical objects
68
69$object = new Productlot($db);
70$extrafields = new ExtraFields($db);
71$hookmanager->initHooks(array('productlotcard', 'globalcard')); // Note that conf->hooks_modules contains array
72
73// Fetch optionals attributes and labels
74$extrafields->fetch_name_optionals_label($object->table_element);
75
76$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
77
78// Initialize array of search criteria
79$search_all = GETPOST("search_all", 'alpha');
80$search = array();
81foreach ($object->fields as $key => $val) {
82 if (GETPOST('search_'.$key, 'alpha')) {
83 $search[$key] = GETPOST('search_'.$key, 'alpha');
84 }
85}
86
87if (empty($action) && empty($id) && empty($ref)) {
88 $action = 'view';
89}
90
91$search_entity = GETPOSTINT('search_entity');
92$search_fk_product = GETPOSTINT('search_fk_product');
93$search_batch = GETPOST('search_batch', 'alpha');
94$search_fk_user_creat = GETPOSTINT('search_fk_user_creat');
95$search_fk_user_modif = GETPOSTINT('search_fk_user_modif');
96$search_import_key = GETPOSTINT('search_import_key');
97
98if (empty($action) && empty($id) && empty($ref)) {
99 $action = 'list';
100}
101
102// Load object
103//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
104if ($id || $ref) {
105 if ($ref) {
106 $tmp = explode('_', $ref);
107 $productid = $tmp[0];
108 $batch = $tmp[1];
109 }
110 $object->fetch($id, $productid, $batch);
111 $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart);
112 $filearray = dol_dir_list($upload_dir, "files");
113}
114
115// Initialize a technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
116$hookmanager->initHooks(array('productlotcard', 'globalcard'));
117
118$upload_dir = $conf->productbatch->multidir_output[$conf->entity];
119
120$usercanread = $user->hasRight('produit', 'lire');
121$usercancreate = $user->hasRight('produit', 'creer');
122$usercandelete = $user->hasRight('produit', 'supprimer');
123
124$permissiontoread = $usercanread;
125$permissiontoadd = $usercancreate;
126$permissiontodelete = $usercandelete;
127$permissionnote = $user->hasRight('produit', 'creer'); // Used by the include of actions_setnotes.inc.php
128$permissiondellink = $user->hasRight('produit', 'creer'); // Used by the include of actions_setnotes.inc.php
129
130// Security check
131if (!isModEnabled('productbatch')) {
132 accessforbidden('Module not enabled');
133}
134$socid = 0;
135if ($user->socid > 0) { // Protection if external user
136 //$socid = $user->socid;
138}
139//$result = restrictedArea($user, 'productbatch');
140if (!$permissiontoread) {
142}
143
144
145/*
146 * Actions
147 */
148
149$parameters = array();
150$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
151if ($reshook < 0) {
152 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
153}
154
155if (empty($reshook)) {
156 $error = 0;
157
158 $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1);
159
160 if ($action == 'seteatby' && $permissiontoadd && ! GETPOST('cancel', 'alpha')) {
161 $newvalue = dol_mktime(12, 0, 0, GETPOSTINT('eatbymonth'), GETPOSTINT('eatbyday'), GETPOSTINT('eatbyyear'));
162
163 // check parameters
164 $object->eatby = $newvalue;
165 $res = $object->checkSellOrEatByMandatory('eatby');
166 if ($res < 0) {
167 $error++;
168 }
169
170 if (!$error) {
171 $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
172 if ($result < 0) {
173 $error++;
174 }
175 }
176
177 if ($error) {
178 setEventMessages($object->error, $object->errors, 'errors');
179 $action = 'editeatby';
180 } else {
181 $action = 'view';
182 }
183 }
184
185 if ($action == 'setsellby' && $permissiontoadd && ! GETPOST('cancel', 'alpha')) {
186 $newvalue = dol_mktime(12, 0, 0, GETPOSTINT('sellbymonth'), GETPOSTINT('sellbyday'), GETPOSTINT('sellbyyear'));
187
188 // check parameters
189 $object->sellby = $newvalue;
190 $res = $object->checkSellOrEatByMandatory('sellby');
191 if ($res < 0) {
192 $error++;
193 }
194
195 if (!$error) {
196 $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
197 if ($result < 0) {
198 $error++;
199 }
200 }
201
202 if ($error) {
203 setEventMessages($object->error, $object->errors, 'errors');
204 $action = 'editsellby';
205 } else {
206 $action = 'view';
207 }
208 }
209
210 if ($action == 'seteol_date' && $permissiontoadd && ! GETPOST('cancel', 'alpha')) {
211 $newvalue = dol_mktime(12, 0, 0, GETPOSTINT('eol_datemonth'), GETPOSTINT('eol_dateday'), GETPOSTINT('eol_dateyear'));
212 $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
213 if ($result < 0) {
214 setEventMessages($object->error, null, 'errors');
215 $action = 'editeol_date';
216 } else {
217 $action = 'view';
218 }
219 }
220
221 if ($action == 'setmanufacturing_date' && $permissiontoadd && ! GETPOST('cancel', 'alpha')) {
222 $newvalue = dol_mktime(12, 0, 0, GETPOSTINT('manufacturing_datemonth'), GETPOSTINT('manufacturing_dateday'), GETPOSTINT('manufacturing_dateyear'));
223 $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
224 if ($result < 0) {
225 setEventMessages($object->error, null, 'errors');
226 $action = 'editmanufacturing_date';
227 } else {
228 $action = 'view';
229 }
230 }
231
232 if ($action == 'setscrapping_date' && $permissiontoadd && ! GETPOST('cancel', 'alpha')) {
233 $newvalue = dol_mktime(12, 0, 0, GETPOSTINT('scrapping_datemonth'), GETPOSTINT('scrapping_dateday'), GETPOSTINT('scrapping_dateyear'));
234 $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
235 if ($result < 0) {
236 setEventMessages($object->error, null, 'errors');
237 $action = 'editscrapping_date';
238 } else {
239 $action = 'view';
240 }
241 }
242
243 /* if ($action == 'setcommissionning_date' && $permissiontoadd && ! GETPOST('cancel', 'alpha')) {
244 $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int'));
245 $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
246 if ($result < 0) {
247 setEventMessages($object->error, null, 'errors');
248 $action == 'editcommissionning_date';
249 } else {
250 $action = 'view';
251 }
252 } */
253
254 if ($action == 'setqc_frequency' && $permissiontoadd && ! GETPOST('cancel', 'alpha')) {
255 $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY');
256 if ($result < 0) { // Prévoir un test de format de durée
257 setEventMessages($object->error, null, 'errors');
258 $action = 'editqc_frequency';
259 } else {
260 $action = 'view';
261 }
262 }
263
264 $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record
265
266 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
267 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
268 /*
269 if ($action == 'update_extras' && $permissiontoadd) {
270 $object->oldcopy = dol_clone($object, 2);
271
272 // Fill array 'array_options' with data from update form
273 $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
274 if ($ret < 0) $error++;
275
276 if (!$error) {
277 // Actions on extra fields
278 $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY');
279 if ($result < 0) {
280 setEventMessages($object->error, $object->errors, 'errors');
281 $error++;
282 }
283 }
284
285 if ($error) {
286 $action = 'edit_extras';
287 }
288 }
289
290 // Action to add record
291 if ($action == 'add' && $permissiontoadd) {
292 if (GETPOST('cancel', 'alpha')) {
293 $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
294 header("Location: ".$urltogo);
295 exit;
296 }
297
298 $error = 0;
299
300 $object->entity = GETPOST('entity', 'int');
301 $object->fk_product = GETPOST('fk_product', 'int');
302 $object->batch = GETPOST('batch', 'alpha');
303 $object->fk_user_creat = GETPOST('fk_user_creat', 'int');
304 $object->fk_user_modif = GETPOST('fk_user_modif', 'int');
305 $object->import_key = GETPOST('import_key', 'int');
306
307 if (empty($object->ref)) {
308 $error++;
309 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
310 }
311
312 if (!$error) {
313 $result = $object->create($user);
314 if ($result > 0) {
315 // Creation OK
316 $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
317 header("Location: ".$urltogo);
318 exit;
319 }
320 {
321 // Creation KO
322 if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
323 else setEventMessages($object->error, null, 'errors');
324 $action = 'create';
325 }
326 } else {
327 $action = 'create';
328 }
329 }
330
331 // Cancel
332 if ($action == 'update' && GETPOST('cancel', 'alpha') && $permissiontoadd) {
333 $action = 'view';
334 }
335
336 // Action to update record
337 if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permissiontoadd) {
338 $error = 0;
339
340 $object->entity = GETPOST('entity', 'int');
341 $object->fk_product = GETPOST('fk_product', 'int');
342 $object->batch = GETPOST('batch', 'alpha');
343 $object->fk_user_creat = GETPOST('fk_user_creat', 'int');
344 $object->fk_user_modif = GETPOST('fk_user_modif', 'int');
345 $object->import_key = GETPOST('import_key', 'int');
346
347 if (empty($object->ref)) {
348 $error++;
349 setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
350 }
351
352 if (!$error) {
353 $result = $object->update($user);
354 if ($result > 0) {
355 $action = 'view';
356 } else {
357 // Creation KO
358 if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
359 else setEventMessages($object->error, null, 'errors');
360 $action = 'edit';
361 }
362 } else {
363 $action = 'edit';
364 }
365 }
366
367 // Action to delete
368 if ($action == 'confirm_delete' && $permissiontodelete) {
369 $result = $object->delete($user);
370 if ($result > 0) {
371 // Delete OK
372 setEventMessages("RecordDeleted", null, 'mesgs');
373 header("Location: ".dol_buildpath('/stock/list.php', 1));
374 exit;
375 } else {
376 if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
377 else setEventMessages($object->error, null, 'errors');
378 }
379 }
380 */
381 // Action to build doc
382 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
383
384 // Actions to send emails
385 $triggersendname = 'PRODUCT_LOT_SENTBYMAIL';
386 $autocopy = 'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO';
387 $trackid = 'productlot'.$object->id;
388 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
389}
390
391
392
393
394/*
395 * View
396 */
397
398$form = new Form($db);
399$formfile = new FormFile($db);
400
401$help_url = '';
402$shortlabel = dol_trunc($object->batch, 16);
403$title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Card');
404$help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
405
406llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-stock_productlot_card');
407
408$res = $object->fetch_product();
409if ($res > 0 && $object->product) {
410 if ($object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY) {
411 $object->fields['sellby']['notnull'] = 1;
412 } elseif ($object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY) {
413 $object->fields['eatby']['notnull'] = 1;
414 } elseif ($object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
415 $object->fields['sellby']['notnull'] = 1;
416 $object->fields['eatby']['notnull'] = 1;
417 }
418}
419// Part to create
420if ($action == 'create') {
421 print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto);
422
423 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
424 print '<input type="hidden" name="token" value="'.newToken().'">';
425 print '<input type="hidden" name="action" value="add">';
426 if ($backtopage) {
427 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
428 }
429 if ($backtopageforcancel) {
430 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
431 }
432
433 print dol_get_fiche_head(array(), '');
434
435 print '<table class="border centpercent tableforfieldcreate">'."\n";
436
437 // Common attributes
438 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
439
440 // Other attributes
441 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
442
443 print '</table>'."\n";
444
445 print dol_get_fiche_end();
446
447 print $form->buttonsSaveCancel("Create");
448
449 print '</form>';
450
451 //dol_set_focus('input[name="ref"]');
452}
453
454
455// Part to show record
456if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
457 $res = $object->fetch_optionals();
458
459 $head = productlot_prepare_head($object);
460 print dol_get_fiche_head($head, 'card', $langs->trans("Batch"), -1, $object->picto);
461
462 $formconfirm = '';
463
464 // Confirmation to delete
465 if ($action == 'delete') {
466 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1);
467 }
468
469 // Call Hook formConfirm
470 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
471 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
472 if (empty($reshook)) {
473 $formconfirm .= $hookmanager->resPrint;
474 } elseif ($reshook > 0) {
475 $formconfirm = $hookmanager->resPrint;
476 }
477
478 // Print form confirm
479 print $formconfirm;
480
481 // Object card
482 // ------------------------------------------------------------
483 $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
484
485 $shownav = 1;
486 if ($user->socid && !in_array('batch', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
487 $shownav = 0;
488 }
489
490 $morehtmlref = '';
491
492 dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref);
493
494 print '<div class="fichecenter">';
495 print '<div class="fichehalfleft">';
496 print '<div class="underbanner clearboth"></div>';
497 print '<table class="border centpercent tableforfield">'."\n";
498
499 // Product
500 print '<tr><td class="titlefield">'.$langs->trans("Product").'</td><td>';
501 $producttmp = new Product($db);
502 $producttmp->fetch($object->fk_product);
503 print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label;
504 print '</td></tr>';
505
506 // Sell by
507 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
508 print '<tr><td>';
509 print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', $object->fields['sellby']['notnull']);
510 print '</td><td>';
511 print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
512 print '</td>';
513 print '</tr>';
514 }
515
516 // Eat by
517 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
518 print '<tr><td>';
519 print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', $object->fields['eatby']['notnull']);
520 print '</td><td>';
521 print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
522 print '</td>';
523 print '</tr>';
524 }
525
526 if (getDolGlobalString('PRODUCT_LOT_ENABLE_TRACEABILITY')) {
527 print '<tr><td>'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer')).'</td>';
528 print '<td>'.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
529 print '</tr>';
530 // print '<tr><td>'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer')).'</td>';
531 // print '<td>'.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
532 // print '</tr>';
533 print '<tr><td>'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer')).'</td>';
534 print '<td>'.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
535 print '</tr>';
536 }
537
538 // Quality control
539 if (getDolGlobalString('PRODUCT_LOT_ENABLE_QUALITY_CONTROL')) {
540 print '<tr><td>'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer')).'</td>';
541 print '<td>'.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
542 print '</tr>';
543 print '<tr><td>'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer')).'</td>';
544 print '<td>'.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer'), 'string').'</td>';
545 print '</tr>';
546 print '<tr><td>'.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer')).'</td>';
547 print '<td>'.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer'), 'string').'</td>';
548 print '</tr>';
549 }
550
551 // Other attributes
552 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
553
554 print '</table>';
555 print '</div>';
556 print '</div>';
557
558 print '<div class="clearboth"></div>';
559
560 print dol_get_fiche_end();
561
562 // Link to other lists
563 print '<a href="'.DOL_URL_ROOT.'/product/reassortlot.php?sref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.img_object('', 'stock', 'class="pictofixedwidth"').$langs->trans("ShowCurrentStockOfLot").'</a><br>';
564 print '<br>';
565 print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?search_product_ref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.img_object('', 'movement', 'class="pictofixedwidth"').$langs->trans("ShowLogOfMovementIfLot").'</a><br>';
566
567 print '<br>';
568
569
570 // Buttons for actions
571 if ($action != 'presend' && $action != 'editline') {
572 print '<div class="tabsAction">'."\n";
573 $parameters = array();
574 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
575 if ($reshook < 0) {
576 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
577 }
578
579 if (empty($reshook)) {
580 /*TODO
581 if ($user->hasRight('stock', 'lire')) {
582 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a></div>'."\n";
583 }
584 */
585 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
586 }
587
588 print '</div>'."\n";
589 }
590}
591
592
593
594/*
595 * Generated documents
596 */
597
598if ($action != 'presend') {
599 print '<div class="fichecenter"><div class="fichehalfleft">';
600 print '<a name="builddoc"></a>'; // ancre
601
602 $includedocgeneration = 1;
603
604 // Documents
605 if ($includedocgeneration) {
606 $objref = dol_sanitizeFileName($object->ref);
607 $relativepath = $object->id.'/'.$objref.'.pdf';
608 $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product_batch');
609 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
610 $genallowed = $usercanread; // If you can read, you can build the PDF to read content
611 $delallowed = $usercancreate; // If you can create/edit, you can remove a file on card
612 print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object);
613 }
614
615 print '</div><div class="fichehalfright">';
616
617 $MAXEVENT = 10;
618
619 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
620 $formactions = new FormActions($db);
621 $somethingshown = $formactions->showactions($object, 'productlot', 0, 1, '', $MAXEVENT);
622
623 print '</div></div>';
624}
625
626// End of page
627llxFooter();
628$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
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:71
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
Class with list of lots and properties.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
productlot_prepare_head($object)
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.