29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
36require_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');
52$cancel =
GETPOST(
'cancel',
'aZ09');
53$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectcard';
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
59$batch =
GETPOST(
'batch',
'alpha');
64$modulepart =
'product_batch';
71$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
74$extrafields->fetch_name_optionals_label(
$object->table_element);
76$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
79$search_all =
GETPOST(
"search_all",
'alpha');
81foreach (
$object->fields as $key => $val) {
82 if (
GETPOST(
'search_'.$key,
'alpha')) {
83 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
87if (empty($action) && empty($id) && empty($ref)) {
92$search_fk_product =
GETPOSTINT(
'search_fk_product');
93$search_batch =
GETPOST(
'search_batch',
'alpha');
94$search_fk_user_creat =
GETPOSTINT(
'search_fk_user_creat');
95$search_fk_user_modif =
GETPOSTINT(
'search_fk_user_modif');
96$search_import_key =
GETPOSTINT(
'search_import_key');
98if (empty($action) && empty($id) && empty($ref)) {
106 $tmp = explode(
'_', $ref);
107 $productid = $tmp[0];
110 $object->fetch($id, $productid, $batch);
111 $upload_dir =
$conf->productbatch->multidir_output[
$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
116$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
118$upload_dir =
$conf->productbatch->multidir_output[
$conf->entity];
120$usercanread = $user->hasRight(
'produit',
'lire');
121$usercancreate = $user->hasRight(
'produit',
'creer');
122$usercandelete = $user->hasRight(
'produit',
'supprimer');
124$permissiontoread = $usercanread;
125$permissiontoadd = $usercancreate;
126$permissiontodelete = $usercandelete;
127$permissionnote = $user->hasRight(
'produit',
'creer');
128$permissiondellink = $user->hasRight(
'produit',
'creer');
131if (!isModEnabled(
'productbatch')) {
135if ($user->socid > 0) {
140if (!$permissiontoread) {
149$parameters = array();
150$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
155if (empty($reshook)) {
158 $backurlforlist =
dol_buildpath(
'/product/stock/productlot_list.php', 1);
160 if ($action ==
'seteatby' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
165 $res =
$object->checkSellOrEatByMandatory(
'eatby');
171 $result =
$object->setValueFrom(
'eatby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
179 $action =
'editeatby';
185 if ($action ==
'setsellby' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
190 $res =
$object->checkSellOrEatByMandatory(
'sellby');
196 $result =
$object->setValueFrom(
'sellby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
204 $action =
'editsellby';
210 if ($action ==
'seteol_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
212 $result =
$object->setValueFrom(
'eol_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
215 $action =
'editeol_date';
221 if ($action ==
'setmanufacturing_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
223 $result =
$object->setValueFrom(
'manufacturing_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
226 $action =
'editmanufacturing_date';
232 if ($action ==
'setscrapping_date' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
234 $result =
$object->setValueFrom(
'scrapping_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
237 $action =
'editscrapping_date';
254 if ($action ==
'setqc_frequency' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
255 $result =
$object->setValueFrom(
'qc_frequency',
GETPOST(
'qc_frequency'),
'',
null,
'int',
'', $user,
'PRODUCT_MODIFY');
258 $action =
'editqc_frequency';
264 $triggermodname =
'PRODUCT_LOT_MODIFY';
267 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
382 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
385 $triggersendname =
'PRODUCT_LOT_SENTBYMAIL';
386 $autocopy =
'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO';
387 $trackid =
'productlot'.$object->id;
388 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
398$form =
new Form($db);
401$title = $langs->trans(
"ProductLot");
404llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_productlot_card');
406$res =
$object->fetch_product();
407if ($res > 0 &&
$object->product) {
408 if (
$object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY) {
409 $object->fields[
'sellby'][
'notnull'] = 1;
410 } elseif (
$object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY) {
411 $object->fields[
'eatby'][
'notnull'] = 1;
412 } elseif (
$object->product->sell_or_eat_by_mandatory == Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
413 $object->fields[
'sellby'][
'notnull'] = 1;
414 $object->fields[
'eatby'][
'notnull'] = 1;
418if ($action ==
'create') {
419 print
load_fiche_titre($langs->trans(
"Batch"),
'',
'object_'.$object->picto);
421 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
422 print
'<input type="hidden" name="token" value="'.newToken().
'">';
423 print
'<input type="hidden" name="action" value="add">';
425 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
427 if ($backtopageforcancel) {
428 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
433 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
436 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
439 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
441 print
'</table>'.
"\n";
445 print $form->buttonsSaveCancel(
"Create");
454if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
455 $res =
$object->fetch_optionals();
463 if ($action ==
'delete') {
464 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBatch'), $langs->trans(
'ConfirmDeleteBatch'),
'confirm_delete',
'', 0, 1);
468 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
469 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
470 if (empty($reshook)) {
471 $formconfirm .= $hookmanager->resPrint;
472 } elseif ($reshook > 0) {
473 $formconfirm = $hookmanager->resPrint;
481 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
484 if ($user->socid && !in_array(
'batch', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
490 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
492 print
'<div class="fichecenter">';
493 print
'<div class="fichehalfleft">';
494 print
'<div class="underbanner clearboth"></div>';
495 print
'<table class="border centpercent tableforfield">'.
"\n";
498 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
499 $producttmp =
new Product($db);
500 $producttmp->fetch(
$object->fk_product);
501 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
507 print $form->editfieldkey($langs->trans(
'SellByDate'),
'sellby',
$object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
$object->fields[
'sellby'][
'notnull']);
509 print $form->editfieldval($langs->trans(
'SellByDate'),
'sellby',
$object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
517 print $form->editfieldkey($langs->trans(
'EatByDate'),
'eatby',
$object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
$object->fields[
'eatby'][
'notnull']);
519 print $form->editfieldval($langs->trans(
'EatByDate'),
'eatby',
$object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
525 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'ManufacturingDate'),
'manufacturing_date',
$object->manufacturing_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
526 print
'<td>'.$form->editfieldval($langs->trans(
'ManufacturingDate'),
'manufacturing_date',
$object->manufacturing_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
531 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'DestructionDate'),
'scrapping_date',
$object->scrapping_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
532 print
'<td>'.$form->editfieldval($langs->trans(
'DestructionDate'),
'scrapping_date',
$object->scrapping_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
538 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'EndOfLife'),
'eol_date',
$object->eol_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
539 print
'<td>'.$form->editfieldval($langs->trans(
'EndOfLife'),
'eol_date',
$object->eol_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
541 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'QCFrequency'),
'qc_frequency',
$object->qc_frequency, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
542 print
'<td>'.$form->editfieldval($langs->trans(
'QCFrequency'),
'qc_frequency',
$object->qc_frequency, $object, $user->hasRight(
'stock',
'creer'),
'string').
'</td>';
544 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'Lifetime'),
'lifetime',
$object->lifetime, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
545 print
'<td>'.$form->editfieldval($langs->trans(
'Lifetime'),
'lifetime',
$object->lifetime, $object, $user->hasRight(
'stock',
'creer'),
'string').
'</td>';
550 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
556 print
'<div class="clearboth"></div>';
561 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>';
563 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>';
569 if ($action !=
'presend' && $action !=
'editline') {
570 print
'<div class="tabsAction">'.
"\n";
571 $parameters = array();
572 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
577 if (empty($reshook)) {
583 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
596if ($action !=
'presend') {
597 print
'<div class="fichecenter"><div class="fichehalfleft">';
598 print
'<a name="builddoc"></a>';
600 $includedocgeneration = 1;
603 if ($includedocgeneration) {
605 $relativepath =
$object->id.
'/'.$objref.
'.pdf';
606 $filedir =
$conf->productbatch->multidir_output[
$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object,
'product_batch');
607 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
608 $genallowed = $usercanread;
609 $delallowed = $usercancreate;
610 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);
613 print
'</div><div class="fichehalfright">';
617 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
619 $somethingshown = $formactions->showactions($object,
'productlot', 0, 1,
'', $MAXEVENT);
621 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($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...
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)
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)
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.
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 a 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.