dolibarr  13.0.2
productlot_document.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
7  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
8  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
9  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
10  * Copyright (C) 2018 All-3kcis <contact@all-3kcis.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  */
25 
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';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array('other', 'products'));
42 
43 $id = GETPOST('id', 'int');
44 $ref = GETPOST('ref', 'alpha');
45 $action = GETPOST('action', 'aZ09');
46 $confirm = GETPOST('confirm', 'alpha');
47 
48 // Security check
49 $fieldvalue = (!empty($id) ? $id : '');
50 $fieldtype = 'rowid';
51 if ($user->socid) $socid = $user->socid;
52 $result = restrictedArea($user, 'produit|service');
53 
54 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
55 $hookmanager->initHooks(array('productlotdocuments'));
56 
57 // Get parameters
58 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
59 $sortfield = GETPOST("sortfield", 'alpha');
60 $sortorder = GETPOST("sortorder", 'alpha');
61 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
62 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
63 $offset = $limit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
66 if (!$sortorder) $sortorder = "ASC";
67 if (!$sortfield) $sortfield = "position_name";
68 
69 $modulepart = 'product_batch';
70 $object = new Productlot($db);
71 if ($id || $ref)
72 {
73  if ($ref)
74  {
75  $tmp = explode('_', $ref);
76  $productid = $tmp[0];
77  $batch = $tmp[1];
78  }
79  $object->fetch($id, $productid, $batch);
80  $object->ref = $object->batch; // For document management ( it use $object->ref)
81 
82  if (!empty($conf->productbatch->enabled)) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart);
83 }
84 
85 
86 /*
87  * Actions
88  */
89 
90 $parameters = array('id'=>$id);
91 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
92 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93 
94 if (empty($reshook))
95 {
96  // Action submit/delete file/link
97  include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
98 }
99 
100 $permtoedit = $user->rights->produit->creer;
101 
102 
103 /*
104  * View
105  */
106 
107 $form = new Form($db);
108 
109 llxHeader('', $langs->trans('ProductLot'), '');
110 
111 
112 if ($object->id)
113 {
114  $head = productlot_prepare_head($object);
115  print dol_get_fiche_head($head, 'documents', $langs->trans("Batch"), -1, 'barcode');
116 
117 
118  $parameters = array();
119  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
120  print $hookmanager->resPrint;
121  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
122 
123  // Build file list
124  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
125 
126  $totalsize = 0;
127  foreach ($filearray as $key => $file)
128  {
129  $totalsize += $file['size'];
130  }
131 
132 
133  $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
134 
135  $shownav = 1;
136  if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
137 
138  dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch');
139 
140  print '<div class="fichecenter">';
141 
142  print '<div class="underbanner clearboth"></div>';
143  print '<table class="border tableforfield" width="100%">';
144 
145  print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
146  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
147  print '</table>';
148 
149  print '</div>';
150  print '<div style="clear:both"></div>';
151 
153 
154  $permission = ($user->rights->produit->creer);
155  $param = '&id='.$object->id;
156  include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
157 } else {
158  print $langs->trans("ErrorUnknown");
159 }
160 
161 
162 llxFooter();
163 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class with list of lots and properties.
productlot_prepare_head($object)
Prepare array with list of tabs.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59