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';
37global $conf, $db, $langs, $user;
40$langs->loadLangs(array(
'stocks',
'other',
'productbatch'));
43$action =
GETPOST(
'action',
'aZ09');
44$confirm =
GETPOST(
'confirm',
'alpha');
45$cancel =
GETPOST(
'cancel',
'aZ09');
46$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectcard';
47$backtopage =
GETPOST(
'backtopage',
'alpha');
48$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
52$batch =
GETPOST(
'batch',
'alpha');
59$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
62$extrafields->fetch_name_optionals_label(
$object->table_element);
64$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
67$search_all =
GETPOST(
"search_all",
'alpha');
69foreach (
$object->fields as $key => $val) {
70 if (
GETPOST(
'search_'.$key,
'alpha')) {
71 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
75if (empty($action) && empty($id) && empty($ref)) {
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');
86if (empty($action) && empty($id) && empty($ref)) {
94 $tmp = explode(
'_', $ref);
98 $object->fetch($id, $productid, $batch);
100 $upload_dir = $conf->productbatch->multidir_output[
$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
102 if (empty($filearray)) {
104 $object->fetch($id, $productid, $batch);
109$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
111$upload_dir = $conf->productbatch->multidir_output[$conf->entity];
113$usercanread = $user->hasRight(
'produit',
'lire');
114$usercancreate = $user->hasRight(
'produit',
'creer');
115$usercandelete = $user->hasRight(
'produit',
'supprimer');
117$permissiontoread = $usercanread;
118$permissiontoadd = $usercancreate;
119$permissiontodelete = $usercandelete;
120$permissionnote = $user->hasRight(
'produit',
'creer');
121$permissiondellink = $user->hasRight(
'produit',
'creer');
124if (!isModEnabled(
'productbatch')) {
128if ($user->socid > 0) {
133if (!$permissiontoread) {
142$parameters = array();
143$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
148if (empty($reshook)) {
151 $backurlforlist =
dol_buildpath(
'/product/stock/productlot_list.php', 1);
153 if ($action ==
'seteatby' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
158 $res =
$object->checkSellOrEatByMandatory(
'eatby');
164 $result =
$object->setValueFrom(
'eatby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
172 $action =
'editeatby';
178 if ($action ==
'setsellby' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
183 $res =
$object->checkSellOrEatByMandatory(
'sellby');
189 $result =
$object->setValueFrom(
'sellby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
197 $action =
'editsellby';
203 if ($action ==
'seteol_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
205 $result =
$object->setValueFrom(
'eol_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
208 $action =
'editeol_date';
214 if ($action ==
'setmanufacturing_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
216 $result =
$object->setValueFrom(
'manufacturing_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
219 $action =
'editmanufacturing_date';
225 if ($action ==
'setscrapping_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
227 $result =
$object->setValueFrom(
'scrapping_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
230 $action =
'editscrapping_date';
247 if ($action ==
'setqc_frequency' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
248 $result =
$object->setValueFrom(
'qc_frequency',
GETPOST(
'qc_frequency'),
'',
null,
'int',
'', $user,
'PRODUCT_MODIFY');
251 $action =
'editqc_frequency';
257 $triggermodname =
'PRODUCT_LOT_MODIFY';
260 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
375 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
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';
391$form =
new Form($db);
394$title = $langs->trans(
"ProductLot");
397llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_productlot_card');
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;
411if ($action ==
'create') {
412 print
load_fiche_titre($langs->trans(
"Batch"),
'',
'object_'.$object->picto);
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">';
418 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
420 if ($backtopageforcancel) {
421 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
426 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
429 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
432 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
434 print
'</table>'.
"\n";
438 print $form->buttonsSaveCancel(
"Create");
447if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
448 $res =
$object->fetch_optionals();
456 if ($action ==
'delete') {
457 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBatch'), $langs->trans(
'ConfirmDeleteBatch'),
'confirm_delete',
'', 0, 1);
461 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
462 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
463 if (empty($reshook)) {
464 $formconfirm .= $hookmanager->resPrint;
465 } elseif ($reshook > 0) {
466 $formconfirm = $hookmanager->resPrint;
474 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
477 if ($user->socid && !in_array(
'batch', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
483 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
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";
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;
500 print $form->editfieldkey($langs->trans(
'SellByDate'),
'sellby',
$object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
$object->fields[
'sellby'][
'notnull']);
502 print $form->editfieldval($langs->trans(
'SellByDate'),
'sellby',
$object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
510 print $form->editfieldkey($langs->trans(
'EatByDate'),
'eatby',
$object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
$object->fields[
'eatby'][
'notnull']);
512 print $form->editfieldval($langs->trans(
'EatByDate'),
'eatby',
$object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
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>';
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>';
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>';
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>';
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>';
543 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
549 print
'<div class="clearboth"></div>';
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>';
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>';
562 if ($action !=
'presend' && $action !=
'editline') {
563 print
'<div class="tabsAction">'.
"\n";
564 $parameters = array();
565 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
570 if (empty($reshook)) {
576 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
589if ($action !=
'presend') {
590 print
'<div class="fichecenter"><div class="fichehalfleft">';
591 print
'<a name="builddoc"></a>';
593 $includedocgeneration = 1;
596 if ($includedocgeneration) {
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;
602 $delallowed = $usercancreate;
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);
606 print
'</div><div class="fichehalfright">';
610 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
612 $somethingshown = $formactions->showactions($object,
'productlot', 0, 1,
'', $MAXEVENT);
614 print
'</div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
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.
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.