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'));
44$lineid =
GETPOST(
'lineid',
'int');
45$action =
GETPOST(
'action',
'aZ09');
46$confirm =
GETPOST(
'confirm',
'alpha');
47$cancel =
GETPOST(
'cancel',
'aZ09');
48$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectcard';
49$backtopage =
GETPOST(
'backtopage',
'alpha');
54$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
57$extrafields->fetch_name_optionals_label($object->table_element);
59$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
62$search_all =
GETPOST(
"search_all",
'alpha');
64foreach ($object->fields as $key => $val) {
65 if (
GETPOST(
'search_'.$key,
'alpha')) {
66 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
70if (empty($action) && empty($id) && empty($ref)) {
74$batch =
GETPOST(
'batch',
'alpha');
75$productid =
GETPOST(
'productid',
'int');
78$search_entity =
GETPOST(
'search_entity',
'int');
79$search_fk_product =
GETPOST(
'search_fk_product',
'int');
80$search_batch =
GETPOST(
'search_batch',
'alpha');
81$search_fk_user_creat =
GETPOST(
'search_fk_user_creat',
'int');
82$search_fk_user_modif =
GETPOST(
'search_fk_user_modif',
'int');
83$search_import_key =
GETPOST(
'search_import_key',
'int');
85if (empty($action) && empty($id) && empty($ref)) {
93 $tmp = explode(
'_', $ref);
97 $object->fetch($id, $productid, $batch);
98 $object->ref = $object->batch;
99 $upload_dir = $conf->productbatch->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
101 if (empty($filearray)) {
103 $object->fetch($id, $productid, $batch);
108$hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
111$permissionnote = $user->hasRight(
'stock',
'creer');
112$permissiondellink = $user->hasRight(
'stock',
'creer');
113$permissiontoadd = $user->hasRight(
'stock',
'creer');
115$usercanread = $user->hasRight(
'produit',
'lire');
116$usercancreate = $user->hasRight(
'produit',
'creer');
117$usercandelete = $user->hasRight(
'produit',
'supprimer');
119$upload_dir = $conf->productbatch->multidir_output[$conf->entity];
121$permissiontoread = $usercanread;
122$permissiontoadd = $usercancreate;
123$permissiontodelete = $usercandelete;
126if (!isModEnabled(
'productbatch')) {
130if ($user->socid > 0) {
135if (!$permissiontoread) {
144$parameters = array();
145$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
150if (empty($reshook)) {
153 $backurlforlist =
dol_buildpath(
'/product/stock/productlot_list.php', 1);
155 if ($action ==
'seteatby' && $user->hasRight(
'stock',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
157 $result = $object->setValueFrom(
'eatby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
160 $action =
'editeatby';
166 if ($action ==
'setsellby' && $user->hasRight(
'stock',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
168 $result = $object->setValueFrom(
'sellby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
171 $action =
'editsellby';
177 if ($action ==
'seteol_date' && $user->hasRight(
'stock',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
179 $result = $object->setValueFrom(
'eol_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
182 $action =
'editeol_date';
188 if ($action ==
'setmanufacturing_date' && $user->hasRight(
'stock',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
189 $newvalue =
dol_mktime(12, 0, 0,
GETPOST(
'manufacturing_datemonth',
'int'),
GETPOST(
'manufacturing_dateday',
'int'),
GETPOST(
'manufacturing_dateyear',
'int'));
190 $result = $object->setValueFrom(
'manufacturing_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
193 $action =
'editmanufacturing_date';
199 if ($action ==
'setscrapping_date' && $user->hasRight(
'stock',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
201 $result = $object->setValueFrom(
'scrapping_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
204 $action =
'editscrapping_date';
221 if ($action ==
'setqc_frequency' && $user->hasRight(
'stock',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
222 $result = $object->setValueFrom(
'qc_frequency',
GETPOST(
'qc_frequency'),
'',
null,
'int',
'', $user,
'PRODUCT_MODIFY');
225 $action =
'editqc_frequency';
231 $triggermodname =
'PRODUCT_LOT_MODIFY';
234 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
347 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
350 $triggersendname =
'PRODUCT_LOT_SENTBYMAIL';
351 $autocopy =
'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO';
352 $trackid =
'productlot'.$object->id;
353 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
363$form =
new Form($db);
366$title = $langs->trans(
"ProductLot");
373if ($action ==
'create') {
374 print
load_fiche_titre($langs->trans(
"Batch"),
'',
'object_'.$object->picto);
376 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
377 print
'<input type="hidden" name="token" value="'.newToken().
'">';
378 print
'<input type="hidden" name="action" value="add">';
380 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
382 if ($backtopageforcancel) {
383 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
388 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
391 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
394 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
396 print
'</table>'.
"\n";
400 print $form->buttonsSaveCancel(
"Create");
409if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
410 $res = $object->fetch_optionals();
418 if ($action ==
'delete') {
419 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteBatch'), $langs->trans(
'ConfirmDeleteBatch'),
'confirm_delete',
'', 0, 1);
423 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
424 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
425 if (empty($reshook)) {
426 $formconfirm .= $hookmanager->resPrint;
427 } elseif ($reshook > 0) {
428 $formconfirm = $hookmanager->resPrint;
436 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
439 if ($user->socid && !in_array(
'batch', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
445 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
447 print
'<div class="fichecenter">';
448 print
'<div class="underbanner clearboth"></div>';
449 print
'<table class="border centpercent tableforfield">'.
"\n";
452 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
453 $producttmp =
new Product($db);
454 $producttmp->fetch($object->fk_product);
455 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
461 print $form->editfieldkey($langs->trans(
'SellByDate'),
'sellby', $object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker');
463 print $form->editfieldval($langs->trans(
'SellByDate'),
'sellby', $object->sellby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
471 print $form->editfieldkey($langs->trans(
'EatByDate'),
'eatby', $object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker');
473 print $form->editfieldval($langs->trans(
'EatByDate'),
'eatby', $object->eatby, $object, $user->hasRight(
'stock',
'creer'),
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
479 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'ManufacturingDate'),
'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
480 print
'<td>'.$form->editfieldval($langs->trans(
'ManufacturingDate'),
'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
485 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'DestructionDate'),
'scrapping_date', $object->scrapping_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
486 print
'<td>'.$form->editfieldval($langs->trans(
'DestructionDate'),
'scrapping_date', $object->scrapping_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
492 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'EndOfLife'),
'eol_date', $object->eol_date, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
493 print
'<td>'.$form->editfieldval($langs->trans(
'EndOfLife'),
'eol_date', $object->eol_date, $object, $user->hasRight(
'stock',
'creer'),
'datepicker').
'</td>';
495 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'QCFrequency'),
'qc_frequency', $object->qc_frequency, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
496 print
'<td>'.$form->editfieldval($langs->trans(
'QCFrequency'),
'qc_frequency', $object->qc_frequency, $object, $user->hasRight(
'stock',
'creer'),
'string').
'</td>';
498 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'Lifetime'),
'lifetime', $object->lifetime, $object, $user->hasRight(
'stock',
'creer')).
'</td>';
499 print
'<td>'.$form->editfieldval($langs->trans(
'Lifetime'),
'lifetime', $object->lifetime, $object, $user->hasRight(
'stock',
'creer'),
'string').
'</td>';
504 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
510 print
'<div class="clearboth"></div>';
515 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>';
517 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>';
523 if ($action !=
'presend' && $action !=
'editline') {
524 print
'<div class="tabsAction">'.
"\n";
525 $parameters = array();
526 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
531 if (empty($reshook)) {
537 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete);
550if ($action !=
'presend') {
551 print
'<div class="fichecenter"><div class="fichehalfleft">';
552 print
'<a name="builddoc"></a>';
554 $includedocgeneration = 1;
557 if ($includedocgeneration) {
559 $relativepath = $objref.
'/'.$objref.
'.pdf';
560 $filedir = $conf->productbatch->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object,
'product_batch');
561 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
562 $genallowed = $usercanread;
563 $delallowed = $usercancreate;
564 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);
567 print
'</div><div class="fichehalfright">';
571 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
573 $somethingshown =
$formactions->showactions($object,
'productlot', 0, 1,
'', $MAXEVENT);
575 print
'</div></div>';
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.
Class to manage products or services.
Class with list of lots and properties.
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.
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.
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.