2016-05-17 08:33:27 +00:00
< ? php
2018-11-08 09:21:43 +00:00
/* Copyright ( C ) 2007 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-04-12 13:55:08 +00:00
* Copyright ( C ) 2018 All - 3 kcis < contact @ all - 3 kcis . fr >
2016-05-17 08:33:27 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2016-05-17 08:33:27 +00:00
*/
/**
2016-08-08 18:31:03 +00:00
* \file product / stock / productlot_card . php
2016-05-17 08:33:27 +00:00
* \ingroup stock
* \brief This file is an example of a php page
2016-05-17 12:02:18 +00:00
* Initialy built by build_class_from_table on 2016 - 05 - 17 12 : 22
2016-05-17 08:33:27 +00:00
*/
2018-05-26 21:52:52 +00:00
require '../../main.inc.php' ;
2018-04-12 13:10:37 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2018-05-26 21:52:52 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
2016-09-12 15:27:44 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2018-05-26 21:52:52 +00:00
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/productlot.class.php' ;
2016-05-17 08:33:27 +00:00
2018-05-26 21:52:52 +00:00
// Load translation files required by the page
2020-02-24 10:00:55 +00:00
$langs -> loadLangs ( array ( 'stocks' , 'other' , 'productbatch' ));
2016-05-17 08:33:27 +00:00
// Get parameters
2019-11-13 17:32:11 +00:00
$id = GETPOST ( 'id' , 'int' );
2021-02-26 11:34:41 +00:00
$action = GETPOST ( 'action' , 'aZ09' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$cancel = GETPOST ( 'cancel' , 'aZ09' );
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'myobjectcard' ; // To manage different context of search
2019-01-27 10:55:16 +00:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2021-02-26 11:34:41 +00:00
// Initialize technical objects
$object = new ProductLot ( $db );
$extrafields = new ExtraFields ( $db );
$hookmanager -> initHooks ( array ( 'productlotcard' , 'globalcard' )); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
// Initialize array of search criterias
$search_all = GETPOST ( " search_all " , 'alpha' );
$search = array ();
foreach ( $object -> fields as $key => $val ) {
if ( GETPOST ( 'search_' . $key , 'alpha' )) {
$search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
}
}
if ( empty ( $action ) && empty ( $id ) && empty ( $ref )) {
$action = 'view' ;
}
2019-01-27 10:55:16 +00:00
$batch = GETPOST ( 'batch' , 'alpha' );
$productid = GETPOST ( 'productid' , 'int' );
2019-11-13 17:32:11 +00:00
$ref = GETPOST ( 'ref' , 'alpha' ); // ref is productid_batch
2019-01-27 10:55:16 +00:00
2019-11-13 17:32:11 +00:00
$search_entity = GETPOST ( 'search_entity' , 'int' );
$search_fk_product = GETPOST ( 'search_fk_product' , 'int' );
$search_batch = GETPOST ( 'search_batch' , 'alpha' );
$search_fk_user_creat = GETPOST ( 'search_fk_user_creat' , 'int' );
$search_fk_user_modif = GETPOST ( 'search_fk_user_modif' , 'int' );
$search_import_key = GETPOST ( 'search_import_key' , 'int' );
2016-05-17 08:33:27 +00:00
2019-11-13 17:32:11 +00:00
if ( empty ( $action ) && empty ( $id ) && empty ( $ref )) $action = 'list' ;
2016-05-17 08:33:27 +00:00
2016-09-12 15:27:44 +00:00
// Load object
//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ( $id || $ref )
2016-05-17 08:33:27 +00:00
{
2020-10-31 13:32:18 +00:00
if ( $ref )
{
$tmp = explode ( '_' , $ref );
$productid = $tmp [ 0 ];
$batch = $tmp [ 1 ];
}
2018-04-12 13:55:08 +00:00
$object -> fetch ( $id , $productid , $batch );
$object -> ref = $object -> batch ; // For document management ( it use $object->ref)
2016-05-17 08:33:27 +00:00
}
2021-02-26 11:34:41 +00:00
// Protection if external user
if ( $user -> socid > 0 )
{
//accessforbidden();
}
//$result = restrictedArea($user, 'mymodule', $id);
2016-05-17 08:33:27 +00:00
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
2019-11-13 17:32:11 +00:00
$hookmanager -> initHooks ( array ( 'productlotcard' , 'globalcard' ));
2016-09-12 15:27:44 +00:00
2016-05-17 08:33:27 +00:00
2019-11-13 17:32:11 +00:00
$permissionnote = $user -> rights -> stock -> creer ; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user -> rights -> stock -> creer ; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user -> rights -> stock -> creer ; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
2016-05-17 08:33:27 +00:00
2018-04-12 13:10:37 +00:00
$usercanread = $user -> rights -> produit -> lire ;
$usercancreate = $user -> rights -> produit -> creer ;
$usercandelete = $user -> rights -> produit -> supprimer ;
2016-05-17 08:33:27 +00:00
2021-02-26 11:34:41 +00:00
$upload_dir = $conf -> productbatch -> multidir_output [ $conf -> entity ];
$permissiontoadd = $usercancreate ;
2016-09-12 15:27:44 +00:00
/*
* Actions
*/
2016-05-17 08:33:27 +00:00
2019-11-13 17:32:11 +00:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 11:34:41 +00:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
if ( empty ( $reshook )) {
$error = 0 ;
$backurlforlist = dol_buildpath ( '/product/stock/productlot_list.php' , 1 );
2016-05-17 08:33:27 +00:00
2016-09-12 18:00:47 +00:00
if ( $action == 'seteatby' && $user -> rights -> stock -> creer )
{
2020-10-31 13:32:18 +00:00
$newvalue = dol_mktime ( 12 , 0 , 0 , $_POST [ 'eatbymonth' ], $_POST [ 'eatbyday' ], $_POST [ 'eatbyyear' ]);
2016-09-12 18:00:47 +00:00
$result = $object -> setValueFrom ( 'eatby' , $newvalue , '' , null , 'date' , '' , $user , 'PRODUCTLOT_MODIFY' );
if ( $result < 0 ) dol_print_error ( $db , $object -> error );
}
2017-06-12 14:26:25 +00:00
2016-09-12 18:00:47 +00:00
if ( $action == 'setsellby' && $user -> rights -> stock -> creer )
{
2020-10-31 13:32:18 +00:00
$newvalue = dol_mktime ( 12 , 0 , 0 , $_POST [ 'sellbymonth' ], $_POST [ 'sellbyday' ], $_POST [ 'sellbyyear' ]);
2016-09-12 18:00:47 +00:00
$result = $object -> setValueFrom ( 'sellby' , $newvalue , '' , null , 'date' , '' , $user , 'PRODUCTLOT_MODIFY' );
if ( $result < 0 ) dol_print_error ( $db , $object -> error );
}
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
$triggermodname = 'PRODUCT_LOT_MODIFY' ; // Name of trigger action code to execute when we modify record
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php' ;
/*
2016-09-12 18:00:47 +00:00
if ( $action == 'update_extras' )
2020-10-31 13:32:18 +00:00
{
$object -> oldcopy = dol_clone ( $object );
2018-02-23 15:11:00 +00:00
2020-10-31 13:32:18 +00:00
// Fill array 'array_options' with data from update form
$ret = $extrafields -> setOptionalsFromPost ( null , $object , GETPOST ( 'attribute' , 'restricthtml' ));
if ( $ret < 0 ) $error ++ ;
2017-06-12 14:26:25 +00:00
2020-10-31 13:32:18 +00:00
if ( ! $error )
{
// Actions on extra fields
$result = $object -> insertExtraFields ( 'PRODUCT_LOT_MODIFY' );
2018-04-10 10:03:01 +00:00
if ( $result < 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
2020-10-31 13:32:18 +00:00
}
2017-06-12 14:26:25 +00:00
2020-10-31 13:32:18 +00:00
if ( $error )
$action = 'edit_extras' ;
}
2017-06-12 14:26:25 +00:00
2016-05-17 08:33:27 +00:00
// Action to add record
if ( $action == 'add' )
{
2019-01-27 10:55:16 +00:00
if ( GETPOST ( 'cancel' , 'alpha' ))
2016-05-17 08:33:27 +00:00
{
2019-11-13 17:32:11 +00:00
$urltogo = $backtopage ? $backtopage : dol_buildpath ( '/stock/list.php' , 1 );
2016-05-17 08:33:27 +00:00
header ( " Location: " . $urltogo );
exit ;
}
2019-11-13 17:32:11 +00:00
$error = 0 ;
2016-05-17 08:33:27 +00:00
2020-10-31 13:32:18 +00:00
$object -> entity = GETPOST ( 'entity' , 'int' );
$object -> fk_product = GETPOST ( 'fk_product' , 'int' );
$object -> batch = GETPOST ( 'batch' , 'alpha' );
$object -> fk_user_creat = GETPOST ( 'fk_user_creat' , 'int' );
$object -> fk_user_modif = GETPOST ( 'fk_user_modif' , 'int' );
$object -> import_key = GETPOST ( 'import_key' , 'int' );
2016-05-17 08:33:27 +00:00
if ( empty ( $object -> ref ))
{
$error ++ ;
2019-01-27 10:55:16 +00:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Ref " )), null , 'errors' );
2016-05-17 08:33:27 +00:00
}
2019-11-13 17:32:11 +00:00
if ( ! $error )
2016-05-17 08:33:27 +00:00
{
2019-11-13 17:32:11 +00:00
$result = $object -> create ( $user );
2016-05-17 08:33:27 +00:00
if ( $result > 0 )
{
// Creation OK
2019-11-13 17:32:11 +00:00
$urltogo = $backtopage ? $backtopage : dol_buildpath ( '/stock/list.php' , 1 );
2016-05-17 08:33:27 +00:00
header ( " Location: " . $urltogo );
exit ;
}
{
// Creation KO
2019-11-13 17:32:11 +00:00
if ( ! empty ( $object -> errors )) setEventMessages ( null , $object -> errors , 'errors' );
2020-05-20 23:56:06 +00:00
else setEventMessages ( $object -> error , null , 'errors' );
2019-11-13 17:32:11 +00:00
$action = 'create' ;
2016-05-17 08:33:27 +00:00
}
2020-05-21 13:05:19 +00:00
} else {
2019-11-13 17:32:11 +00:00
$action = 'create' ;
2016-05-17 08:33:27 +00:00
}
}
// Cancel
2019-11-13 17:32:11 +00:00
if ( $action == 'update' && GETPOST ( 'cancel' , 'alpha' )) $action = 'view' ;
2016-05-17 08:33:27 +00:00
// Action to update record
2019-11-13 17:32:11 +00:00
if ( $action == 'update' && ! GETPOST ( 'cancel' , 'alpha' ))
2016-05-17 08:33:27 +00:00
{
2019-11-13 17:32:11 +00:00
$error = 0 ;
2017-06-12 14:26:25 +00:00
2020-10-31 13:32:18 +00:00
$object -> entity = GETPOST ( 'entity' , 'int' );
$object -> fk_product = GETPOST ( 'fk_product' , 'int' );
$object -> batch = GETPOST ( 'batch' , 'alpha' );
$object -> fk_user_creat = GETPOST ( 'fk_user_creat' , 'int' );
$object -> fk_user_modif = GETPOST ( 'fk_user_modif' , 'int' );
$object -> import_key = GETPOST ( 'import_key' , 'int' );
2016-05-17 08:33:27 +00:00
if ( empty ( $object -> ref ))
{
$error ++ ;
2019-01-27 10:55:16 +00:00
setEventMessages ( $langs -> transnoentitiesnoconv ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Ref " )), null , 'errors' );
2016-05-17 08:33:27 +00:00
}
2019-11-13 17:32:11 +00:00
if ( ! $error )
2016-05-17 08:33:27 +00:00
{
2019-11-13 17:32:11 +00:00
$result = $object -> update ( $user );
2016-05-17 08:33:27 +00:00
if ( $result > 0 )
{
2019-11-13 17:32:11 +00:00
$action = 'view' ;
2020-05-21 13:05:19 +00:00
} else {
2016-05-17 08:33:27 +00:00
// Creation KO
2019-11-13 17:32:11 +00:00
if ( ! empty ( $object -> errors )) setEventMessages ( null , $object -> errors , 'errors' );
2016-05-17 08:33:27 +00:00
else setEventMessages ( $object -> error , null , 'errors' );
2019-11-13 17:32:11 +00:00
$action = 'edit' ;
2016-05-17 08:33:27 +00:00
}
2020-05-21 13:05:19 +00:00
} else {
2019-11-13 17:32:11 +00:00
$action = 'edit' ;
2016-05-17 08:33:27 +00:00
}
}
// Action to delete
if ( $action == 'confirm_delete' )
{
2019-11-13 17:32:11 +00:00
$result = $object -> delete ( $user );
2016-05-17 08:33:27 +00:00
if ( $result > 0 )
{
// Delete OK
setEventMessages ( " RecordDeleted " , null , 'mesgs' );
2019-01-27 10:55:16 +00:00
header ( " Location: " . dol_buildpath ( '/stock/list.php' , 1 ));
2016-05-17 08:33:27 +00:00
exit ;
2020-05-21 13:05:19 +00:00
} else {
2019-11-13 17:32:11 +00:00
if ( ! empty ( $object -> errors )) setEventMessages ( null , $object -> errors , 'errors' );
2016-05-17 08:33:27 +00:00
else setEventMessages ( $object -> error , null , 'errors' );
}
}
2021-02-26 11:34:41 +00:00
*/
// Action to build doc
2020-10-31 13:32:18 +00:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
2021-02-26 11:34:41 +00:00
// Actions to send emails
$triggersendname = 'PRODUCT_LOT_SENTBYMAIL' ;
$autocopy = 'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO' ;
$trackid = 'productlot' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
2016-05-17 08:33:27 +00:00
}
2016-09-12 15:27:44 +00:00
/*
* View
*/
2016-05-17 08:33:27 +00:00
2019-11-13 17:32:11 +00:00
$form = new Form ( $db );
2021-02-26 11:34:41 +00:00
$formfile = new FormFile ( $db );
$title = $langs -> trans ( " ProductLot " );
$help_url = '' ;
llxHeader ( '' , $title , $help_url );
2016-05-17 08:33:27 +00:00
// Part to create
2021-02-26 11:34:41 +00:00
if ( $action == 'create' ) {
print load_fiche_titre ( $langs -> trans ( " Batch " ), '' , 'object_' . $object -> picto );
2016-05-17 08:33:27 +00:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-26 11:34:41 +00:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2016-05-17 08:33:27 +00:00
print '<input type="hidden" name="action" value="add">' ;
2021-02-26 11:34:41 +00:00
if ( $backtopage ) {
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
}
if ( $backtopageforcancel ) {
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">' ;
}
print dol_get_fiche_head ( array (), '' );
2016-05-17 08:33:27 +00:00
2021-02-26 11:34:41 +00:00
// Set some default values
//if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
2016-05-17 08:33:27 +00:00
2021-02-26 11:34:41 +00:00
print '<table class="border centpercent tableforfieldcreate">' . " \n " ;
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php' ;
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php' ;
2016-05-17 08:33:27 +00:00
print '</table>' . " \n " ;
2020-10-27 17:19:31 +00:00
print dol_get_fiche_end ();
2016-05-17 08:33:27 +00:00
2021-02-26 11:34:41 +00:00
print '<div class="center">' ;
print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag ( $langs -> trans ( " Create " )) . '">' ;
print ' ' ;
print '<input type="' . ( $backtopage ? " submit " : " button " ) . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '"' . ( $backtopage ? '' : ' onclick="javascript:history.go(-1)"' ) . '>' ; // Cancel for create does not post form if we don't know the backtopage
print '</div>' ;
2016-05-17 08:33:27 +00:00
print '</form>' ;
2021-02-26 11:34:41 +00:00
//dol_set_focus('input[name="ref"]');
2016-05-17 08:33:27 +00:00
}
// Part to show record
2021-02-26 11:34:41 +00:00
if ( $object -> id > 0 && ( empty ( $action ) || ( $action != 'edit' && $action != 'create' ))) {
2018-02-21 13:48:25 +00:00
$res = $object -> fetch_optionals ();
2017-06-12 14:26:25 +00:00
2020-10-31 13:32:18 +00:00
$head = productlot_prepare_head ( $object );
2021-02-26 11:34:41 +00:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " Batch " ), - 1 , $object -> picto );
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
$formconfirm = '' ;
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
// Confirmation to delete
2016-05-17 08:33:27 +00:00
if ( $action == 'delete' ) {
2019-11-13 17:32:11 +00:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'DeleteBatch' ), $langs -> trans ( 'ConfirmDeleteBatch' ), 'confirm_delete' , '' , 0 , 1 );
2016-05-17 08:33:27 +00:00
}
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
// Call Hook formConfirm
$parameters = array ( 'formConfirm' => $formconfirm , 'lineid' => $lineid );
$reshook = $hookmanager -> executeHooks ( 'formConfirm' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) {
$formconfirm .= $hookmanager -> resPrint ;
} elseif ( $reshook > 0 ) {
$formconfirm = $hookmanager -> resPrint ;
}
2021-02-26 11:53:06 +00:00
2021-02-26 11:34:41 +00:00
// Print form confirm
print $formconfirm ;
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
// Object card
// ------------------------------------------------------------
2019-11-13 17:32:11 +00:00
$linkback = '<a href="' . DOL_URL_ROOT . '/product/stock/productlot_list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-06-12 14:26:25 +00:00
2020-10-31 17:51:30 +00:00
$shownav = 1 ;
if ( $user -> socid && ! in_array ( 'batch' , explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL ))) $shownav = 0 ;
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
$morehtmlref = '' ;
2021-02-26 11:53:06 +00:00
2021-02-26 11:34:41 +00:00
dol_banner_tab ( $object , 'id' , $linkback , $shownav , 'rowid' , 'batch' , $morehtmlref );
2017-06-12 14:26:25 +00:00
2020-10-31 17:51:30 +00:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2021-02-26 11:34:41 +00:00
print '<table class="border centpercent tableforfield">' . " \n " ;
2017-06-12 14:26:25 +00:00
2016-09-12 18:00:47 +00:00
// Product
2020-10-31 17:51:30 +00:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Product " ) . '</td><td>' ;
$producttmp = new Product ( $db );
$producttmp -> fetch ( $object -> fk_product );
print $producttmp -> getNomUrl ( 1 , 'stock' ) . " - " . $producttmp -> label ;
print '</td></tr>' ;
2016-09-12 15:27:44 +00:00
2020-10-31 17:51:30 +00:00
// Eat by
2020-07-13 11:08:15 +00:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_EATBY )) {
print '<tr><td>' ;
2020-07-13 11:12:53 +00:00
print $form -> editfieldkey ( $langs -> trans ( 'EatByDate' ), 'eatby' , $object -> eatby , $object , $user -> rights -> stock -> creer , 'datepicker' );
2020-07-13 11:08:15 +00:00
print '</td><td>' ;
2020-07-13 11:12:53 +00:00
print $form -> editfieldval ( $langs -> trans ( 'EatByDate' ), 'eatby' , $object -> eatby , $object , $user -> rights -> stock -> creer , 'datepicker' );
2020-07-13 11:08:15 +00:00
print '</td>' ;
print '</tr>' ;
}
2017-06-12 14:26:25 +00:00
2020-10-31 13:32:18 +00:00
// Sell by
2020-07-13 11:08:15 +00:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SELLBY )) {
print '<tr><td>' ;
2020-07-13 11:12:53 +00:00
print $form -> editfieldkey ( $langs -> trans ( 'SellByDate' ), 'sellby' , $object -> sellby , $object , $user -> rights -> stock -> creer , 'datepicker' );
2020-07-13 11:08:15 +00:00
print '</td><td>' ;
2020-07-13 11:12:53 +00:00
print $form -> editfieldval ( $langs -> trans ( 'SellByDate' ), 'sellby' , $object -> sellby , $object , $user -> rights -> stock -> creer , 'datepicker' );
2020-07-13 11:08:15 +00:00
print '</td>' ;
print '</tr>' ;
}
2021-02-26 11:34:41 +00:00
// Other attributes. Fields from hook formObjectOptions and Extrafields.
2020-10-31 13:32:18 +00:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2017-06-12 14:26:25 +00:00
2016-05-17 08:33:27 +00:00
print '</table>' ;
2017-06-12 14:26:25 +00:00
2017-03-11 11:45:18 +00:00
print '</div>' ;
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
print '<div class="clearboth"></div>' ;
2021-02-26 11:53:06 +00:00
2020-10-27 17:19:31 +00:00
print dol_get_fiche_end ();
2016-05-17 08:33:27 +00:00
2021-02-26 11:34:41 +00:00
// Link to other lists
2016-10-10 00:01:30 +00:00
print '<a href="' . DOL_URL_ROOT . '/product/reassortlot.php?sref=' . urlencode ( $producttmp -> ref ) . '&search_batch=' . urlencode ( $object -> batch ) . '">' . $langs -> trans ( " ShowCurrentStockOfLot " ) . '</a><br>' ;
print '<br>' ;
2018-10-24 01:50:18 +00:00
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>' ;
2021-02-26 11:53:06 +00:00
2018-10-11 11:33:44 +00:00
print '<br>' ;
2016-05-17 08:33:27 +00:00
2021-02-26 11:34:41 +00:00
// Buttons for actions
if ( $action != 'presend' && $action != 'editline' ) {
print '<div class="tabsAction">' . " \n " ;
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
if ( empty ( $reshook )) {
/* TODO if ( $user -> rights -> stock -> lire )
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=edit">' . $langs -> trans ( " Modify " ) . '</a></div>' . " \n " ;
}
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
if ( $user -> rights -> stock -> supprimer )
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=delete&token=' . newToken () . '">' . $langs -> trans ( 'Delete' ) . '</a></div>' . " \n " ;
}
*/
}
2017-06-12 14:26:25 +00:00
2021-02-26 11:34:41 +00:00
print '</div>' . " \n " ;
}
2016-05-17 08:33:27 +00:00
}
2018-04-12 13:10:37 +00:00
/*
* Documents generes
*/
2021-02-26 11:34:41 +00:00
if ( $action != 'presend' ) {
2020-10-31 13:32:18 +00:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
print '<a name="builddoc"></a>' ; // ancre
2018-04-12 13:10:37 +00:00
2021-02-26 11:34:41 +00:00
$includedocgeneration = 1 ;
2021-02-26 11:53:06 +00:00
2020-10-31 13:32:18 +00:00
// Documents
2021-02-26 11:34:41 +00:00
if ( $includedocgeneration ) {
$objref = dol_sanitizeFileName ( $object -> ref );
$relativepath = $objref . '/' . $objref . '.pdf' ;
2021-02-26 11:53:06 +00:00
$filedir = $conf -> productbatch -> multidir_output [ $object -> entity ] . '/' . get_exdir ( 0 , 0 , 0 , 1 , $object , 'product_batch' );
2021-02-26 11:34:41 +00:00
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
$genallowed = $usercanread ; // If you can read, you can build the PDF to read content
$delallowed = $usercancreate ; // If you can create/edit, you can remove a file on card
print $formfile -> showdocuments ( 'product_batch' , $objref , $filedir , $urlsource , $genallowed , $delallowed , '' , 0 , 0 , 0 , 28 , 0 , '' , 0 , '' , $langs -> default_lang , '' , $object );
}
2021-02-25 14:47:14 +00:00
2021-02-26 11:34:41 +00:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2018-04-12 13:10:37 +00:00
2021-02-26 11:34:41 +00:00
$MAXEVENT = 10 ;
2021-02-26 11:53:06 +00:00
2021-02-25 14:47:14 +00:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
$formactions = new FormActions ( $db );
2021-02-26 11:53:06 +00:00
$somethingshown = $formactions -> showactions ( $object , 'productlot' , 0 , 1 , '' , $MAXEVENT );
2021-02-25 14:47:14 +00:00
2021-02-26 11:34:41 +00:00
print '</div></div></div>' ;
2018-04-12 13:10:37 +00:00
}
2016-05-17 08:33:27 +00:00
// End of page
llxFooter ();
$db -> close ();