Add option to save file with product batch ref

+ use batch number like ref instead of id
+ debug access to shared link
This commit is contained in:
All-3kcis 2018-04-12 15:55:08 +02:00
parent a8fbf4a370
commit 21df700325
5 changed files with 11 additions and 13 deletions

View File

@ -2626,7 +2626,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
// Wrapping pour les lots produits
else if ($modulepart == 'product_batch')
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))

View File

@ -204,7 +204,7 @@ function productlot_prepare_head($object)
// 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].'/'.$object->id;
$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;

View File

@ -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', 'produit')))
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__';
}

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 All-3kcis <contact@all-3kcis.fr>
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
@ -86,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
@ -411,14 +413,14 @@ if (empty($action))
print '<a name="builddoc"></a>'; // ancre
// Documents
$filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').$object->id;
$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',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object);
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 '</div>';

View File

@ -71,7 +71,7 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="position_name";
$modulepart='product_batch';
$object = new Productlot($db);
if ($id || $ref)
{
@ -82,13 +82,9 @@ if ($id || $ref)
$batch=$tmp[1];
}
$object->fetch($id, $productid, $batch);
}
$modulepart='product_batch';
if ($id > 0 || ! empty($ref))
{
$result = $object->fetch($id, $ref);
$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).$object->id;
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);
}