diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php
index 54e975c2f8c..8e12dec056e 100644
--- a/htdocs/adherents/document.php
+++ b/htdocs/adherents/document.php
@@ -144,7 +144,7 @@ if ($id > 0)
print '
| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
//Total taille
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 8ef875f0a23..aab9cfcb30a 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -160,7 +160,7 @@ if ($object->id > 0)
// Files infos
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print "\n";
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index 5a3f0c1973f..84cc9977e20 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -164,7 +164,7 @@ if ($id > 0 || ! empty($ref))
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print "
\n";
diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php
index 2fca317d1c4..a6e206c4b09 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -127,7 +127,7 @@ if ($id > 0 || !empty($ref)) {
print '';
print '| ' . $langs->trans("NbOfAttachedFiles") . ' | ' . count($filearray) . ' |
';
- print '| ' . $langs->trans("TotalSizeOfAttachedFiles") . ' | ' . $totalsize . ' ' . $langs->trans("bytes") . ' |
';
+ print '| ' . $langs->trans("TotalSizeOfAttachedFiles") . ' | ' .dol_print_size($totalsize,1,1).' |
';
print "
\n";
print '';
diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php
index 1f3974ce041..76481c4c8c0 100644
--- a/htdocs/compta/deplacement/document.php
+++ b/htdocs/compta/deplacement/document.php
@@ -115,7 +115,7 @@ if ($object->id)
//print "| ".$langs->trans("Company")." | ".$object->client->getNomUrl(1)." |
";
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print '';
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index a9396e445c9..70dcfebaacb 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -171,7 +171,7 @@ if ($id > 0 || ! empty($ref))
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print "
\n";
print "\n";
diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php
index 03cef9c07e8..00bc6185ffd 100644
--- a/htdocs/compta/salaries/document.php
+++ b/htdocs/compta/salaries/document.php
@@ -118,7 +118,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '
';
print '';
diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php
index 0bf1e7f6f13..0e2bcc5c986 100644
--- a/htdocs/compta/sociales/document.php
+++ b/htdocs/compta/sociales/document.php
@@ -150,7 +150,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '
';
print '';
diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php
index 2fb7ba272c8..9ffc2202b8a 100644
--- a/htdocs/compta/tva/document.php
+++ b/htdocs/compta/tva/document.php
@@ -151,7 +151,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '
';
print '';
diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php
index 281924cb589..2d729d8ebb4 100644
--- a/htdocs/contact/document.php
+++ b/htdocs/contact/document.php
@@ -153,7 +153,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print '';
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index 4bc2747a829..53125f3063b 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -181,7 +181,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '
';
print '';
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index c4ccd6fe982..0ea6af8d5de 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -375,6 +375,10 @@ class Conf
$this->service->dir_output=$rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp";
+ // Module productbatch
+ $this->productbatch->multidir_output=array($this->entity => $rootfordata."/produitlot");
+ $this->productbatch->multidir_temp =array($this->entity => $rootfordata."/produitlot/temp");
+
// Module contrat
$this->contrat->dir_output=$rootfordata."/contracts";
$this->contrat->dir_temp =$rootfordata."/contracts/temp";
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index e25709fd303..648f1295c25 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -94,6 +94,9 @@ class FileUpload
elseif ($element == 'product') {
$dir_output = $conf->product->multidir_output[$conf->entity];
}
+ elseif ($element == 'productbatch') {
+ $dir_output = $conf->productbatch->multidir_output[$conf->entity];
+ }
elseif ($element == 'action') {
$pathname = 'comm/action'; $filename='actioncomm';
$dir_output=$conf->agenda->dir_output;
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 0e125a7b944..50386e277a1 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -469,6 +469,15 @@ class FormFile
$modellist=ModelePDFProduct::liste_modeles($this->db);
}
}
+ elseif ($modulepart == 'product_batch')
+ {
+ if (is_array($genallowed)) $modellist=$genallowed;
+ else
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php';
+ $modellist=ModelePDFProductBatch::liste_modeles($this->db);
+ }
+ }
elseif ($modulepart == 'export')
{
if (is_array($genallowed)) $modellist=$genallowed;
@@ -740,7 +749,7 @@ class FormFile
// Show file size
$size=(! empty($file['size'])?$file['size']:dol_filesize($filedir."/".$file["name"]));
- $out.= ''.dol_print_size($size).' | ';
+ $out.= ''.dol_print_size($size,1,1).' | ';
// Show file date
$date=(! empty($file['date'])?$file['date']:dol_filemtime($filedir."/".$file["name"]));
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 6ea633f1f1d..040cec8758a 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -2625,6 +2625,17 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
elseif (! empty($conf->service->enabled)) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file;
}
+ // Wrapping pour les lots produits
+ else if ($modulepart == 'product_batch' || $modulepart == 'produitlot')
+ {
+ if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
+ if (($fuser->rights->produit->{$lire} ) || preg_match('/^specimen/i',$original_file))
+ {
+ $accessallowed=1;
+ }
+ if (! empty($conf->productbatch->enabled)) $original_file=$conf->productbatch->multidir_output[$entity].'/'.$original_file;
+ }
+
// Wrapping pour les contrats
else if ($modulepart == 'contract' && !empty($conf->contrat->dir_output))
{
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index 8d40f11d472..eedb994baed 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -199,7 +199,19 @@ function productlot_prepare_head($object)
$head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_card.php?id=".$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
- $h++;
+ $h++;
+
+ // Attachments
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+ $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
+ $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
+ $nbLinks=Link::count($db, $object->element, $object->id);
+ $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id;
+ $head[$h][1] = $langs->trans("Documents");
+ if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).'';
+ $head[$h][2] = 'documents';
+ $h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
diff --git a/htdocs/core/modules/product_batch/index.html b/htdocs/core/modules/product_batch/index.html
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/htdocs/core/modules/product_batch/modules_product_batch.class.php b/htdocs/core/modules/product_batch/modules_product_batch.class.php
new file mode 100644
index 00000000000..94818d17531
--- /dev/null
+++ b/htdocs/core/modules/product_batch/modules_product_batch.class.php
@@ -0,0 +1,63 @@
+
+ * Copyright (C) 2004-2010 Laurent Destailleur
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2005-2012 Regis Houssin
+ *
+ * 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
+ * along with this program. If not, see .
+ * or see http://www.gnu.org/
+ */
+
+
+/**
+ * \class ModeleProductCode
+ * \brief Parent class for product code generators
+ */
+
+/**
+ * \file htdocs/core/modules/contract/modules_contract.php
+ * \ingroup contract
+ * \brief File with parent class for generating contracts to PDF and File of class to manage contract numbering
+ */
+
+ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
+
+/**
+ * Parent class to manage intervention document templates
+ */
+abstract class ModelePDFProductBatch extends CommonDocGenerator
+{
+ var $error='';
+
+
+ /**
+ * Return list of active generation modules
+ *
+ * @param DoliDB $db Database handler
+ * @param integer $maxfilenamelength Max length of value to show
+ * @return array List of templates
+ */
+ static function liste_modeles($db,$maxfilenamelength=0)
+ {
+ global $conf;
+
+ $type='product_batch';
+ $liste=array();
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ $liste=getListOfModels($db,$type,$maxfilenamelength);
+ return $liste;
+ }
+}
+
diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php
index 65312110cc9..01d7b091a49 100644
--- a/htdocs/core/tpl/document_actions_post_headers.tpl.php
+++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php
@@ -62,7 +62,7 @@ $savingdocmask='';
if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
{
//var_dump($modulepart);
- if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','supplier_proposal','ficheinter','contract','expedition','project','project_task','expensereport','tax')))
+ if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','supplier_proposal','ficheinter','contract','expedition','project','project_task','expensereport','tax', 'produit', 'product_batch')))
{
$savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
}
diff --git a/htdocs/don/document.php b/htdocs/don/document.php
index 0ae81231bc1..020272d5bae 100644
--- a/htdocs/don/document.php
+++ b/htdocs/don/document.php
@@ -171,7 +171,7 @@ if ($object->id)
//print "| ".$langs->trans("Company")." | ".$object->client->getNomUrl(1)." |
";
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print '';
diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php
index 87d0932c64b..48c551bb7d1 100644
--- a/htdocs/expedition/document.php
+++ b/htdocs/expedition/document.php
@@ -163,7 +163,7 @@ if ($id > 0 || ! empty($ref)){
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print "
\n";
diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php
index ed588f3f961..dc4f1c8a7af 100644
--- a/htdocs/expensereport/document.php
+++ b/htdocs/expensereport/document.php
@@ -118,7 +118,7 @@ if ($object->id)
$linkback = ''.$langs->trans("BackToList").'';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print '';
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index c869387b211..4c6d51e89fe 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -158,7 +158,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '
';
print '';
diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php
index 11c3c59b313..59358279e31 100644
--- a/htdocs/fourn/commande/document.php
+++ b/htdocs/fourn/commande/document.php
@@ -168,7 +168,7 @@ if ($object->id > 0)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print "
\n";
print "\n";
diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php
index 5f8c5787773..1f0c9f86739 100644
--- a/htdocs/fourn/facture/document.php
+++ b/htdocs/fourn/facture/document.php
@@ -239,7 +239,7 @@ if ($object->id > 0)
// Nb of files
print '| '.$langs->trans('NbOfAttachedFiles').' | '.count($filearray).' |
';
- print '| '.$langs->trans('TotalSizeOfAttachedFiles').' | '.$totalsize.' '.$langs->trans('bytes').' |
';
+ print '| '.$langs->trans('TotalSizeOfAttachedFiles').' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print '';
diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php
index 94d32b3bc49..6e5137e5b57 100644
--- a/htdocs/holiday/document.php
+++ b/htdocs/holiday/document.php
@@ -211,7 +211,7 @@ if ($object->id)
}
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print ''."\n";
diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php
index 30f1efc69f7..54333029689 100644
--- a/htdocs/loan/document.php
+++ b/htdocs/loan/document.php
@@ -148,7 +148,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print "
\n";
print "\n";
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index 93267538936..442eb3f53f3 100644
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -227,7 +227,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '
';
print '';
diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php
index ab2b60f564a..f27dfa4a70e 100644
--- a/htdocs/product/stock/class/mouvementstock.class.php
+++ b/htdocs/product/stock/class/mouvementstock.class.php
@@ -249,6 +249,7 @@ class MouvementStock extends CommonObject
else // If not found, we add record
{
$productlot = new Productlot($this->db);
+ $productlot->entity = $conf->entity;
$productlot->fk_product = $fk_product;
$productlot->batch = $batch;
// If we are here = first time we manage this batch, so we used dates provided by users to create lot
diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php
index 56c9e1cebe4..6167a967199 100644
--- a/htdocs/product/stock/class/productlot.class.php
+++ b/htdocs/product/stock/class/productlot.class.php
@@ -91,6 +91,7 @@ class Productlot extends CommonObject
*/
public function create(User $user, $notrigger = false)
{
+ global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
@@ -133,7 +134,7 @@ class Productlot extends CommonObject
$sql.= 'fk_user_modif,';
$sql.= 'import_key';
$sql .= ') VALUES (';
- $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).',';
+ $sql .= ' '.(! isset($this->entity)?$conf->entity:$this->entity).',';
$sql .= ' '.(! isset($this->fk_product)?'NULL':$this->fk_product).',';
$sql .= ' '.(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").',';
$sql .= ' '.(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").',';
@@ -200,6 +201,7 @@ class Productlot extends CommonObject
*/
public function fetch($id = 0, $product_id = 0, $batch = '')
{
+ global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
@@ -232,8 +234,7 @@ class Productlot extends CommonObject
//$this->ref = $obj->fk_product.'_'.$obj->batch;
$this->batch = $obj->batch;
-
- $this->entity = $obj->entity;
+ $this->entity = (!empty($obj->entity)?$obj->entity:$conf->entity); // Prevent "null" entity
$this->fk_product = $obj->fk_product;
$this->eatby = $this->db->jdate($obj->eatby);
$this->sellby = $this->db->jdate($obj->sellby);
diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php
index 937e6c1240f..757d01868b5 100644
--- a/htdocs/product/stock/productlot_card.php
+++ b/htdocs/product/stock/productlot_card.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2018 All-3kcis
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
@@ -31,6 +32,7 @@ if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@includ
if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
if (! $res) die("Include of main fails");
// Change this following line to use the correct relative path from htdocs
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
include_once(DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php');
include_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
@@ -70,6 +72,7 @@ if ($user->societe_id > 0)
$object = new ProductLot($db);
$extrafields = new ExtraFields($db);
+$formfile = new FormFile($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
@@ -84,7 +87,8 @@ if ($id || $ref)
$productid=$tmp[0];
$batch=$tmp[1];
}
- $object->fetch($id, $productid, $batch);
+ $object->fetch($id, $productid, $batch);
+ $object->ref = $object->batch; // For document management ( it use $object->ref)
}
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
@@ -95,6 +99,9 @@ $permissionnote = $user->rights->stock->creer; // Used by the include of actio
$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php
$permissionedit = $user->rights->stock->creer; // Used by the include of actions_lineupdown.inc.php
+$usercanread = $user->rights->produit->lire;
+$usercancreate = $user->rights->produit->creer;
+$usercandelete = $user->rights->produit->supprimer;
/*
* Actions
@@ -253,6 +260,12 @@ if (empty($reshook))
else setEventMessages($object->error, null, 'errors');
}
}
+
+ // Actions to build doc
+ $upload_dir = $conf->productbatch->multidir_output[$conf->entity];
+ $permissioncreate = $usercancreate;
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
+
}
@@ -389,6 +402,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
+
+/*
+ * Documents generes
+ */
+
+if (empty($action))
+{
+ print '';
+ print '
'; // ancre
+
+ // Documents
+ $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref);
+ $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
+ $genallowed=$usercanread;
+ $delallowed=$usercancreate;
+
+ $var=true;
+
+ print $formfile->showdocuments('product_batch',dol_sanitizeFileName($object->ref),$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object);
+ $somethingshown=$formfile->numoffiles;
+
+ print '
';
+
+}
+
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php
new file mode 100644
index 00000000000..be93256858f
--- /dev/null
+++ b/htdocs/product/stock/productlot_document.php
@@ -0,0 +1,175 @@
+
+ * Copyright (C) 2004-2010 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2005 Simon TOSSER
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Cédric Salvador
+ * Copyright (C) 2017 Ferran Marcet
+ * Copyright (C) 2018 All-3kcis
+ *
+ * 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
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/product/stock/productlot_document.php
+ * \ingroup product
+ * \brief Page des documents joints sur les lots produits
+ */
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
+if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
+if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
+if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
+if (! $res) die("Include of main fails");
+require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+dol_include_once('/product/stock/class/productlot.class.php');
+
+$langs->load("other");
+$langs->load("products");
+
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$action = GETPOST('action','alpha');
+$confirm= GETPOST('confirm','alpha');
+
+// Security check
+$fieldvalue = (! empty($id) ? $id : '');
+$fieldtype = 'rowid';
+if ($user->societe_id) $socid=$user->societe_id;
+$result=restrictedArea($user,'produit|service');
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('productlotdocuments'));
+
+// Get parameters
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+$offset = $conf->liste_limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortorder) $sortorder="ASC";
+if (! $sortfield) $sortfield="position_name";
+
+$modulepart='product_batch';
+$object = new Productlot($db);
+if ($id || $ref)
+{
+ if ($ref)
+ {
+ $tmp=explode('_',$ref);
+ $productid=$tmp[0];
+ $batch=$tmp[1];
+ }
+ $object->fetch($id, $productid, $batch);
+ $object->ref = $object->batch; // For document management ( it use $object->ref)
+
+ if (! empty($conf->productbatch->enabled)) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, $modulepart).dol_sanitizeFileName($object->ref);
+}
+
+
+/*
+ * Actions
+ */
+
+$parameters=array('id'=>$id);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
+{
+
+ // Action submit/delete file/link
+ include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+
+}
+
+$permtoedit = $user->rights->produit->creer;
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+llxHeader('', $langs->trans('ProductLot'), '');
+
+
+if ($object->id)
+{
+
+ $head = productlot_prepare_head($object);
+ dol_fiche_head($head, 'documents', $langs->trans("Batch"), -1, 'barcode');
+
+
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ // Construit liste des fichiers
+ $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $totalsize=0;
+ foreach($filearray as $key => $file)
+ {
+ $totalsize+=$file['size'];
+ }
+
+
+ $linkback = '' . $langs->trans("BackToList") . '';
+
+ $shownav = 1;
+ if ($user->societe_id && ! in_array('batch', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
+
+ dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
+ print '
';
+
+ print '
';
+ print '';
+
+ dol_fiche_end();
+
+ $permission = ( $user->rights->produit->creer );
+ $param = '&id=' . $object->id;
+ include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
+
+
+}
+else
+{
+ print $langs->trans("ErrorUnknown");
+}
+
+
+llxFooter();
+$db->close();
diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index fbf9574bd75..4677e409f35 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -138,7 +138,7 @@ if ($object->id > 0)
// Files infos
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print "\n";
diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php
index 64ac151fede..43b5a852b10 100644
--- a/htdocs/resource/document.php
+++ b/htdocs/resource/document.php
@@ -125,7 +125,7 @@ if ($object->id)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print ' ';
diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php
index 2cab1da971f..e393fa64a2c 100644
--- a/htdocs/societe/document.php
+++ b/htdocs/societe/document.php
@@ -150,7 +150,7 @@ if ($object->id)
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
// Total size
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php
index 36c1df7329c..2be5dae222b 100644
--- a/htdocs/supplier_proposal/document.php
+++ b/htdocs/supplier_proposal/document.php
@@ -152,7 +152,7 @@ if ($object->id > 0)
print '';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '
';
diff --git a/htdocs/user/document.php b/htdocs/user/document.php
index 5d89ef1b162..9e665bd563b 100644
--- a/htdocs/user/document.php
+++ b/htdocs/user/document.php
@@ -159,7 +159,7 @@ if ($object->id)
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
//Total taille
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize,1,1).' |
';
print '';
print '';