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