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