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';
38 $langs->loadLangs(array(
'stocks',
'other',
'productbatch'));
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';
47 $backtopage =
GETPOST(
'backtopage',
'alpha');
52 $hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
55 $extrafields->fetch_name_optionals_label($object->table_element);
57 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
60 $search_all =
GETPOST(
"search_all",
'alpha');
62 foreach ($object->fields as $key => $val) {
63 if (
GETPOST(
'search_'.$key,
'alpha')) {
64 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
68 if (empty($action) && empty($id) && empty($ref)) {
72 $batch =
GETPOST(
'batch',
'alpha');
73 $productid =
GETPOST(
'productid',
'int');
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');
83 if (empty($action) && empty($id) && empty($ref)) {
91 $tmp = explode(
'_', $ref);
95 $object->fetch($id, $productid, $batch);
96 $object->ref = $object->batch;
97 $upload_dir = $conf->productbatch->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
99 if (empty($filearray)) {
101 $object->fetch($id, $productid, $batch);
106 $hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
109 $permissionnote = $user->rights->stock->creer;
110 $permissiondellink = $user->rights->stock->creer;
111 $permissiontoadd = $user->rights->stock->creer;
113 $usercanread = $user->rights->produit->lire;
114 $usercancreate = $user->rights->produit->creer;
115 $usercandelete = $user->rights->produit->supprimer;
117 $upload_dir = $conf->productbatch->multidir_output[$conf->entity];
119 $permissiontoread = $usercanread;
120 $permissiontoadd = $usercancreate;
121 $permissiontodelete = $usercandelete;
124 if (empty($conf->productbatch->enabled)) {
128 if ($user->socid > 0) {
140 $parameters = array();
141 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
146 if (empty($reshook)) {
149 $backurlforlist =
dol_buildpath(
'/product/stock/productlot_list.php', 1);
151 if ($action ==
'seteatby' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
153 $result = $object->setValueFrom(
'eatby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
156 $action =
'editeatby';
162 if ($action ==
'setsellby' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
164 $result = $object->setValueFrom(
'sellby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
167 $action =
'editsellby';
173 if ($action ==
'seteol_date' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
175 $result = $object->setValueFrom(
'eol_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
178 $action =
'editeol_date';
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');
189 $action =
'editmanufacturing_date';
195 if ($action ==
'setscrapping_date' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
197 $result = $object->setValueFrom(
'scrapping_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
200 $action =
'editscrapping_date';
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');
221 $action =
'editqc_frequency';
227 $triggermodname =
'PRODUCT_LOT_MODIFY';
230 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
357 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
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';
376 $title = $langs->trans(
"ProductLot");
383 if ($action ==
'create') {
384 print
load_fiche_titre($langs->trans(
"Batch"),
'',
'object_'.$object->picto);
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">';
390 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
392 if ($backtopageforcancel) {
393 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
398 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
401 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
404 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
406 print
'</table>'.
"\n";
410 print
$form->buttonsSaveCancel(
"Create");
419 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
420 $res = $object->fetch_optionals();
428 if ($action ==
'delete') {
429 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteBatch'), $langs->trans(
'ConfirmDeleteBatch'),
'confirm_delete',
'', 0, 1);
433 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
434 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
435 if (empty($reshook)) {
437 } elseif ($reshook > 0) {
446 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
449 if ($user->socid && !in_array(
'batch', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
455 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
457 print
'<div class="fichecenter">';
458 print
'<div class="underbanner clearboth"></div>';
459 print
'<table class="border centpercent tableforfield">'.
"\n";
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;
469 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
471 print
$form->editfieldkey($langs->trans(
'SellByDate'),
'sellby', $object->sellby, $object, $user->rights->stock->creer,
'datepicker');
473 print
$form->editfieldval($langs->trans(
'SellByDate'),
'sellby', $object->sellby, $object, $user->rights->stock->creer,
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
479 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
481 print
$form->editfieldkey($langs->trans(
'EatByDate'),
'eatby', $object->eatby, $object, $user->rights->stock->creer,
'datepicker');
483 print
$form->editfieldval($langs->trans(
'EatByDate'),
'eatby', $object->eatby, $object, $user->rights->stock->creer,
'datepicker',
'',
null,
null,
'', 1,
'',
'id',
'auto', array(), $action);
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>';
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>';
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>';
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>';
511 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
517 print
'<div class="clearboth"></div>';
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>';
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>';
530 if ($action !=
'presend' && $action !=
'editline') {
531 print
'<div class="tabsAction">'.
"\n";
532 $parameters = array();
533 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
538 if (empty($reshook)) {
544 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
557 if ($action !=
'presend') {
558 print
'<div class="fichecenter"><div class="fichehalfleft">';
559 print
'<a name="builddoc"></a>';
561 $includedocgeneration = 1;
564 if ($includedocgeneration) {
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;
570 $delallowed = $usercancreate;
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);
574 print
'</div><div class="fichehalfright">';
578 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
580 $somethingshown =
$formactions->showactions($object,
'productlot', 0, 1,
'', $MAXEVENT);
582 print
'</div></div>';
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.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
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.