30require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
47$langs->loadLangs(array(
'stocks',
'other',
'productbatch'));
50$action =
GETPOST(
'action',
'aZ09');
51$confirm =
GETPOST(
'confirm',
'alpha');
53$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'productlotcard';
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
59$batch =
GETPOST(
'batch',
'alpha');
64$modulepart =
'product_batch';
70$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
73$extrafields->fetch_name_optionals_label(
$object->table_element);
75$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
78$search_all =
GETPOST(
"search_all",
'alpha');
80foreach (
$object->fields as $key => $val) {
81 if (
GETPOST(
'search_'.$key,
'alpha')) {
82 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
86if (empty($action) && empty($id) && empty($ref)) {
91$search_fk_product =
GETPOSTINT(
'search_fk_product');
92$search_batch =
GETPOST(
'search_batch',
'alpha');
93$search_fk_user_creat =
GETPOSTINT(
'search_fk_user_creat');
94$search_fk_user_modif =
GETPOSTINT(
'search_fk_user_modif');
95$search_import_key =
GETPOSTINT(
'search_import_key');
97if (empty($action) && empty($id) && empty($ref)) {
105 $tmp = explode(
'_', $ref);
106 $productid = $tmp[0];
109 $object->fetch($id, $productid, $batch);
110 $upload_dir =
$conf->productbatch->multidir_output[
$object->entity ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
115$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
117$upload_dir =
$conf->productbatch->multidir_output[
$conf->entity];
119$usercanread = $user->hasRight(
'produit',
'lire');
120$usercancreate = $user->hasRight(
'produit',
'creer');
121$usercandelete = $user->hasRight(
'produit',
'supprimer');
123$permissiontoread = $usercanread;
124$permissiontoadd = $usercancreate;
125$permissiontodelete = $usercandelete;
126$permissionnote = $user->hasRight(
'produit',
'creer');
127$permissiondellink = $user->hasRight(
'produit',
'creer');
134if ($user->socid > 0) {
139if (!$permissiontoread) {
148$parameters = array();
149$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
154if (empty($reshook)) {
157 $backurlforlist =
dol_buildpath(
'/product/stock/productlot_list.php', 1);
159 if ($action ==
'seteatby' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
164 $res =
$object->checkSellOrEatByMandatory(
'eatby');
170 $result =
$object->setValueFrom(
'eatby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
178 $action =
'editeatby';
184 if ($action ==
'setsellby' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
189 $res =
$object->checkSellOrEatByMandatory(
'sellby');
195 $result =
$object->setValueFrom(
'sellby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
203 $action =
'editsellby';
209 if ($action ==
'seteol_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
211 $result =
$object->setValueFrom(
'eol_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
214 $action =
'editeol_date';
220 if ($action ==
'setmanufacturing_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
222 $result =
$object->setValueFrom(
'manufacturing_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
225 $action =
'editmanufacturing_date';
231 if ($action ==
'setscrapping_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
233 $result =
$object->setValueFrom(
'scrapping_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
236 $action =
'editscrapping_date';
253 if ($action ==
'setqc_frequency' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
254 $result =
$object->setValueFrom(
'qc_frequency',
GETPOST(
'qc_frequency'),
'',
null,
'int',
'', $user,
'PRODUCT_MODIFY');
257 $action =
'editqc_frequency';
263 $triggermodname =
'PRODUCT_LOT_MODIFY';
266 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
269 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
272 $triggersendname =
'PRODUCT_LOT_SENTBYMAIL';
273 $autocopy =
'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO';
274 $trackid =
'productlot'.$object->id;
275 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
290$title = $langs->trans(
'Batch').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
291$help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
293llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_productlot_card');
295$res =
$object->fetch_product();
296if ($res > 0 &&
$object->product) {
297 if (
$object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY) {
298 $object->fields[
'sellby'][
'notnull'] = 1;
299 } elseif (
$object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY) {
300 $object->fields[
'eatby'][
'notnull'] = 1;
301 } elseif (
$object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
302 $object->fields[
'sellby'][
'notnull'] = 1;
303 $object->fields[
'eatby'][
'notnull'] = 1;
307if ($action ==
'create') {
308 print
load_fiche_titre($langs->trans(
"Batch"),
'',
'object_'.$object->picto);
310 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
311 print
'<input type="hidden" name="token" value="'.newToken().
'">';
312 print
'<input type="hidden" name="action" value="add">';
314 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
316 if ($backtopageforcancel) {
317 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
322 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
325 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
328 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
330 print
'</table>'.
"\n";
334 print $form->buttonsSaveCancel(
"Create");
343if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
344 $res =
$object->fetch_optionals();
352 if ($action ==
'delete') {
353 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBatch'), $langs->trans(
'ConfirmDeleteBatch'),
'confirm_delete',
'', 0, 1);
357 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
358 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
359 if (empty($reshook)) {
360 $formconfirm .= $hookmanager->resPrint;
361 } elseif ($reshook > 0) {
362 $formconfirm = $hookmanager->resPrint;
370 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
373 if ($user->socid && !in_array(
'batch', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
379 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
381 print
'<div class="fichecenter">';
382 print
'<div class="fichehalfleft">';
383 print
'<div class="underbanner clearboth"></div>';
384 print
'<table class="border centpercent tableforfield">'.
"\n";
387 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
389 $producttmp->fetch(
$object->fk_product);
390 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
396 print $form->editfieldkey($langs->trans(
'SellByDate'),
'sellby',
$object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
$object->fields[
'sellby'][
'notnull']);
398 print $form->editfieldval($langs->trans(
'SellByDate'),
'sellby',
$object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
406 print $form->editfieldkey($langs->trans(
'EatByDate'),
'eatby',
$object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
$object->fields[
'eatby'][
'notnull']);
408 print $form->editfieldval($langs->trans(
'EatByDate'),
'eatby',
$object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
414 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'ManufacturingDate'),
'manufacturing_date',
$object->manufacturing_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
415 print
'<td>'.$form->editfieldval($langs->trans(
'ManufacturingDate'),
'manufacturing_date',
$object->manufacturing_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
420 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'DestructionDate'),
'scrapping_date',
$object->scrapping_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
421 print
'<td>'.$form->editfieldval($langs->trans(
'DestructionDate'),
'scrapping_date',
$object->scrapping_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
427 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'EndOfLife'),
'eol_date',
$object->eol_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
428 print
'<td>'.$form->editfieldval($langs->trans(
'EndOfLife'),
'eol_date',
$object->eol_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
430 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'QCFrequency'),
'qc_frequency',
$object->qc_frequency, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
431 print
'<td>'.$form->editfieldval($langs->trans(
'QCFrequency'),
'qc_frequency',
$object->qc_frequency, $object, $user->hasRight(
'stock',
'creer'),
'string').
'</td>';
433 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'Lifetime'),
'lifetime',
$object->lifetime, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
434 print
'<td>'.$form->editfieldval($langs->trans(
'Lifetime'),
'lifetime',
$object->lifetime, $object, $user->hasRight(
'stock',
'creer'),
'string').
'</td>';
439 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
445 print
'<div class="clearboth"></div>';
450 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>';
452 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>';
458 if ($action !=
'presend' && $action !=
'editline') {
459 print
'<div class="tabsAction">'.
"\n";
460 $parameters = array();
461 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
466 if (empty($reshook)) {
472 print dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete);
485if ($action !=
'presend') {
486 print
'<div class="fichecenter"><div class="fichehalfleft">';
487 print
'<a name="builddoc"></a>';
489 $includedocgeneration = 1;
492 if ($includedocgeneration) {
494 $relativepath =
$object->id.
'/'.$objref.
'.pdf';
495 $filedir =
$conf->productbatch->multidir_output[
$object->entity ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 1, $object,
'product_batch');
496 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
497 $genallowed = $usercanread;
498 $delallowed = $usercancreate;
499 print $formfile->showdocuments(
'product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 0, 0, 0, 28, 0,
'',
'',
'', (empty(
$object->default_lang) ?
'' :
$object->default_lang),
'',
$object);
502 print
'</div><div class="fichehalfright">';
506 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
508 $somethingshown = $formactions->showactions($object,
'productlot', 0, 1,
'', $MAXEVENT);
510 print
'</div></div>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.