dolibarr 21.0.0-beta
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 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
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$title = $langs->trans("ProductLot");
402$help_url = '';
403
404llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-stock_productlot_card');
405
406$res = $object->fetch_product();
407if ($res > 0 && $object->product) {
408 if ($object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY) {
409 $object->fields['sellby']['notnull'] = 1;
410 } elseif ($object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY) {
411 $object->fields['eatby']['notnull'] = 1;
412 } elseif ($object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
413 $object->fields['sellby']['notnull'] = 1;
414 $object->fields['eatby']['notnull'] = 1;
415 }
416}
417// Part to create
418if ($action == 'create') {
419 print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto);
420
421 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
422 print '<input type="hidden" name="token" value="'.newToken().'">';
423 print '<input type="hidden" name="action" value="add">';
424 if ($backtopage) {
425 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
426 }
427 if ($backtopageforcancel) {
428 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
429 }
430
431 print dol_get_fiche_head(array(), '');
432
433 print '<table class="border centpercent tableforfieldcreate">'."\n";
434
435 // Common attributes
436 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
437
438 // Other attributes
439 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
440
441 print '</table>'."\n";
442
443 print dol_get_fiche_end();
444
445 print $form->buttonsSaveCancel("Create");
446
447 print '</form>';
448
449 //dol_set_focus('input[name="ref"]');
450}
451
452
453// Part to show record
454if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
455 $res = $object->fetch_optionals();
456
457 $head = productlot_prepare_head($object);
458 print dol_get_fiche_head($head, 'card', $langs->trans("Batch"), -1, $object->picto);
459
460 $formconfirm = '';
461
462 // Confirmation to delete
463 if ($action == 'delete') {
464 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1);
465 }
466
467 // Call Hook formConfirm
468 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
469 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
470 if (empty($reshook)) {
471 $formconfirm .= $hookmanager->resPrint;
472 } elseif ($reshook > 0) {
473 $formconfirm = $hookmanager->resPrint;
474 }
475
476 // Print form confirm
477 print $formconfirm;
478
479 // Object card
480 // ------------------------------------------------------------
481 $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
482
483 $shownav = 1;
484 if ($user->socid && !in_array('batch', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
485 $shownav = 0;
486 }
487
488 $morehtmlref = '';
489
490 dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref);
491
492 print '<div class="fichecenter">';
493 print '<div class="fichehalfleft">';
494 print '<div class="underbanner clearboth"></div>';
495 print '<table class="border centpercent tableforfield">'."\n";
496
497 // Product
498 print '<tr><td class="titlefield">'.$langs->trans("Product").'</td><td>';
499 $producttmp = new Product($db);
500 $producttmp->fetch($object->fk_product);
501 print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label;
502 print '</td></tr>';
503
504 // Sell by
505 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
506 print '<tr><td>';
507 print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', $object->fields['sellby']['notnull']);
508 print '</td><td>';
509 print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
510 print '</td>';
511 print '</tr>';
512 }
513
514 // Eat by
515 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
516 print '<tr><td>';
517 print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', $object->fields['eatby']['notnull']);
518 print '</td><td>';
519 print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
520 print '</td>';
521 print '</tr>';
522 }
523
524 if (getDolGlobalString('PRODUCT_LOT_ENABLE_TRACEABILITY')) {
525 print '<tr><td>'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer')).'</td>';
526 print '<td>'.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
527 print '</tr>';
528 // print '<tr><td>'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer')).'</td>';
529 // print '<td>'.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
530 // print '</tr>';
531 print '<tr><td>'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer')).'</td>';
532 print '<td>'.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
533 print '</tr>';
534 }
535
536 // Quality control
537 if (getDolGlobalString('PRODUCT_LOT_ENABLE_QUALITY_CONTROL')) {
538 print '<tr><td>'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer')).'</td>';
539 print '<td>'.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
540 print '</tr>';
541 print '<tr><td>'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer')).'</td>';
542 print '<td>'.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer'), 'string').'</td>';
543 print '</tr>';
544 print '<tr><td>'.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer')).'</td>';
545 print '<td>'.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer'), 'string').'</td>';
546 print '</tr>';
547 }
548
549 // Other attributes
550 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
551
552 print '</table>';
553 print '</div>';
554 print '</div>';
555
556 print '<div class="clearboth"></div>';
557
558 print dol_get_fiche_end();
559
560 // Link to other lists
561 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>';
562 print '<br>';
563 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>';
564
565 print '<br>';
566
567
568 // Buttons for actions
569 if ($action != 'presend' && $action != 'editline') {
570 print '<div class="tabsAction">'."\n";
571 $parameters = array();
572 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
573 if ($reshook < 0) {
574 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
575 }
576
577 if (empty($reshook)) {
578 /*TODO
579 if ($user->hasRight('stock', 'lire')) {
580 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";
581 }
582 */
583 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
584 }
585
586 print '</div>'."\n";
587 }
588}
589
590
591
592/*
593 * Generated documents
594 */
595
596if ($action != 'presend') {
597 print '<div class="fichecenter"><div class="fichehalfleft">';
598 print '<a name="builddoc"></a>'; // ancre
599
600 $includedocgeneration = 1;
601
602 // Documents
603 if ($includedocgeneration) {
604 $objref = dol_sanitizeFileName($object->ref);
605 $relativepath = $object->id.'/'.$objref.'.pdf';
606 $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product_batch');
607 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
608 $genallowed = $usercanread; // If you can read, you can build the PDF to read content
609 $delallowed = $usercancreate; // If you can create/edit, you can remove a file on card
610 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);
611 }
612
613 print '</div><div class="fichehalfright">';
614
615 $MAXEVENT = 10;
616
617 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
618 $formactions = new FormActions($db);
619 $somethingshown = $formactions->showactions($object, 'productlot', 0, 1, '', $MAXEVENT);
620
621 print '</div></div>';
622}
623
624// End of page
625llxFooter();
626$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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.
llxFooter()
Footer empty.
Definition document.php:107
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
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.