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