32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
41 $langs->loadLangs(array(
'other',
'products'));
45 $action =
GETPOST(
'action',
'aZ09');
46 $confirm =
GETPOST(
'confirm',
'alpha');
49 $fieldvalue = (!empty($id) ? $id :
'');
52 $socid = $user->socid;
57 $hookmanager->initHooks(array(
'productlotdocuments'));
60 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
61 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64 if (empty($page) || $page == -1) {
67 $offset = $limit * $page;
68 $pageprev = $page - 1;
69 $pagenext = $page + 1;
74 $sortfield =
"position_name";
77 $modulepart =
'product_batch';
81 $tmp = explode(
'_', $ref);
85 $object->fetch($id, $productid, $batch);
86 $object->ref = $object->batch;
88 if (!empty($conf->productbatch->enabled)) {
89 $upload_dir = $conf->productbatch->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
91 if (empty($filearray)) {
93 $object->fetch($id, $productid, $batch);
94 $upload_dir = $conf->productbatch->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object, $modulepart);
99 $usercanread = $user->rights->produit->lire;
100 $usercancreate = $user->rights->produit->creer;
101 $usercandelete = $user->rights->produit->supprimer;
103 if (empty($upload_dir)) {
104 $upload_dir = $conf->productbatch->multidir_output[$conf->entity];
107 $permissiontoread = $usercanread;
108 $permissiontoadd = $usercancreate;
109 $permtoedit = $user->rights->produit->creer;
113 if (empty($conf->productbatch->enabled)) {
117 if ($user->socid > 0) {
122 if (!$permissiontoread) {
131 $parameters = array(
'id'=>$id);
132 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
137 if (empty($reshook)) {
139 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
149 llxHeader(
'', $langs->trans(
'ProductLot'),
'');
157 $parameters = array();
158 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
159 print $hookmanager->resPrint;
165 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
168 foreach ($filearray as $key => $file) {
169 $totalsize += $file[
'size'];
173 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
176 if ($user->socid && !in_array(
'batch', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
180 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch');
182 print
'<div class="fichecenter">';
184 print
'<div class="underbanner clearboth"></div>';
185 print
'<table class="border tableforfield" width="100%">';
188 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
189 $producttmp =
new Product($db);
190 $producttmp->fetch($object->fk_product);
191 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
194 print
'<tr><td class="titlefield">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
195 print
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.
dol_print_size($totalsize, 1, 1).
'</td></tr>';
199 print
'<div style="clear:both"></div>';
203 $param =
'&id='.$object->id;
204 include DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
206 print $langs->trans(
"ErrorUnknown");