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 $action =
GETPOST(
'action',
'aZ09');
43 $confirm =
GETPOST(
'confirm',
'alpha');
44 $cancel =
GETPOST(
'cancel',
'aZ09');
45 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectcard';
46 $backtopage =
GETPOST(
'backtopage',
'alpha');
49 $object =
new ProductLot($db);
51 $hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
54 $extrafields->fetch_name_optionals_label($object->table_element);
56 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
59 $search_all =
GETPOST(
"search_all",
'alpha');
61 foreach ($object->fields as $key => $val) {
62 if (
GETPOST(
'search_'.$key,
'alpha')) {
63 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
67 if (empty($action) && empty($id) && empty($ref)) {
71 $batch =
GETPOST(
'batch',
'alpha');
72 $productid =
GETPOST(
'productid',
'int');
75 $search_entity =
GETPOST(
'search_entity',
'int');
76 $search_fk_product =
GETPOST(
'search_fk_product',
'int');
77 $search_batch =
GETPOST(
'search_batch',
'alpha');
78 $search_fk_user_creat =
GETPOST(
'search_fk_user_creat',
'int');
79 $search_fk_user_modif =
GETPOST(
'search_fk_user_modif',
'int');
80 $search_import_key =
GETPOST(
'search_import_key',
'int');
82 if (empty($action) && empty($id) && empty($ref)) {
90 $tmp = explode(
'_', $ref);
94 $object->fetch($id, $productid, $batch);
95 $object->ref = $object->batch;
96 $upload_dir = $conf->productbatch->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
98 if (empty($filearray)) {
100 $object->fetch($id, $productid, $batch);
105 $hookmanager->initHooks(array(
'productlotcard',
'globalcard'));
108 $permissionnote = $user->rights->stock->creer;
109 $permissiondellink = $user->rights->stock->creer;
110 $permissiontoadd = $user->rights->stock->creer;
112 $usercanread = $user->rights->produit->lire;
113 $usercancreate = $user->rights->produit->creer;
114 $usercandelete = $user->rights->produit->supprimer;
116 $upload_dir = $conf->productbatch->multidir_output[$conf->entity];
118 $permissiontoread = $usercanread;
119 $permissiontoadd = $usercancreate;
123 if (empty($conf->productbatch->enabled)) {
127 if ($user->socid > 0) {
139 $parameters = array();
140 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
145 if (empty($reshook)) {
148 $backurlforlist =
dol_buildpath(
'/product/stock/productlot_list.php', 1);
150 if ($action ==
'seteatby' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
152 $result = $object->setValueFrom(
'eatby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
155 $action ==
'editeatby';
161 if ($action ==
'setsellby' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
163 $result = $object->setValueFrom(
'sellby', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
166 $action ==
'editsellby';
172 if ($action ==
'seteol_date' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
174 $result = $object->setValueFrom(
'eol_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
177 $action ==
'editeol_date';
183 if ($action ==
'setmanufacturing_date' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
184 $newvalue =
dol_mktime(12, 0, 0,
GETPOST(
'manufacturing_datemonth',
'int'),
GETPOST(
'manufacturing_dateday',
'int'),
GETPOST(
'manufacturing_dateyear',
'int'));
185 $result = $object->setValueFrom(
'manufacturing_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
188 $action ==
'editmanufacturing_date';
194 if ($action ==
'setscrapping_date' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
196 $result = $object->setValueFrom(
'scrapping_date', $newvalue,
'',
null,
'date',
'', $user,
'PRODUCTLOT_MODIFY');
199 $action ==
'editscrapping_date';
216 if ($action ==
'setqc_frequency' && $user->rights->stock->creer && !
GETPOST(
'cancel',
'alpha')) {
217 $result = $object->setValueFrom(
'qc_frequency',
GETPOST(
'qc_frequency'),
'',
null,
'int',
'', $user,
'PRODUCT_MODIFY');
220 $action ==
'editqc_frequency';
226 $triggermodname =
'PRODUCT_LOT_MODIFY';
229 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
356 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
359 $triggersendname =
'PRODUCT_LOT_SENTBYMAIL';
360 $autocopy =
'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO';
361 $trackid =
'productlot'.$object->id;
362 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
375 $title = $langs->trans(
"ProductLot");
382 if ($action ==
'create') {
383 print
load_fiche_titre($langs->trans(
"Batch"),
'',
'object_'.$object->picto);
385 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
386 print
'<input type="hidden" name="token" value="'.newToken().
'">';
387 print
'<input type="hidden" name="action" value="add">';
389 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
391 if ($backtopageforcancel) {
392 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
397 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
400 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
403 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
405 print
'</table>'.
"\n";
409 print
$form->buttonsSaveCancel(
"Create");
418 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
419 $res = $object->fetch_optionals();
427 if ($action ==
'delete') {
428 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteBatch'), $langs->trans(
'ConfirmDeleteBatch'),
'confirm_delete',
'', 0, 1);
432 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
433 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
434 if (empty($reshook)) {
436 } elseif ($reshook > 0) {
445 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
448 if ($user->socid && !in_array(
'batch', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
454 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
456 print
'<div class="fichecenter">';
457 print
'<div class="underbanner clearboth"></div>';
458 print
'<table class="border centpercent tableforfield">'.
"\n";
461 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
462 $producttmp =
new Product($db);
463 $producttmp->fetch($object->fk_product);
464 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
468 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
470 print
$form->editfieldkey($langs->trans(
'SellByDate'),
'sellby', $object->sellby, $object, $user->rights->stock->creer,
'datepicker');
472 print
$form->editfieldval($langs->trans(
'SellByDate'),
'sellby', $object->sellby, $object, $user->rights->stock->creer,
'datepicker');
478 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
480 print
$form->editfieldkey($langs->trans(
'EatByDate'),
'eatby', $object->eatby, $object, $user->rights->stock->creer,
'datepicker');
482 print
$form->editfieldval($langs->trans(
'EatByDate'),
'eatby', $object->eatby, $object, $user->rights->stock->creer,
'datepicker');
487 if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) {
488 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'ManufacturingDate'),
'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).
'</td>';
489 print
'<td>'.$form->editfieldval($langs->trans(
'ManufacturingDate'),
'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer,
'datepicker').
'</td>';
494 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'DestructionDate'),
'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).
'</td>';
495 print
'<td>'.$form->editfieldval($langs->trans(
'DestructionDate'),
'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer,
'datepicker').
'</td>';
500 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
501 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'EndOfLife'),
'eol_date', $object->eol_date, $object, $user->rights->stock->creer).
'</td>';
502 print
'<td>'.$form->editfieldval($langs->trans(
'EndOfLife'),
'eol_date', $object->eol_date, $object, $user->rights->stock->creer,
'datepicker').
'</td>';
504 print
'<tr><td>'.$form->editfieldkey($langs->trans(
'QCFrequency'),
'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).
'</td>';
505 print
'<td>'.$form->editfieldval($langs->trans(
'QCFrequency'),
'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer,
'numeric').
'</td>';
510 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
516 print
'<div class="clearboth"></div>';
521 print
'<a href="'.DOL_URL_ROOT.
'/product/reassortlot.php?sref='.urlencode($producttmp->ref).
'&search_batch='.urlencode($object->batch).
'">'.$langs->trans(
"ShowCurrentStockOfLot").
'</a><br>';
523 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_product_ref='.urlencode($producttmp->ref).
'&search_batch='.urlencode($object->batch).
'">'.$langs->trans(
"ShowLogOfMovementIfLot").
'</a><br>';
529 if ($action !=
'presend' && $action !=
'editline') {
530 print
'<div class="tabsAction">'.
"\n";
531 $parameters = array();
532 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
537 if (empty($reshook)) {
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,
'', 0, 0, 0, 28, 0,
'', 0,
'', $langs->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.
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='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.