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