Fixed: Location for file storage from tab attached files was not at same

place than from tab images.
This commit is contained in:
Laurent Destailleur 2015-02-06 21:26:41 +01:00
parent 35129f2192
commit 553181a5d9
2 changed files with 27 additions and 12 deletions

View File

@ -57,11 +57,6 @@ function product_prepare_head($object, $user)
$h++;
}
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id;
$head[$h][1] = $langs->trans("Photos");
$head[$h][2] = 'photos';
$h++;
// Show category tab
if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire)
{
@ -116,14 +111,19 @@ function product_prepare_head($object, $user)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'product');
// Attachments
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id;
$head[$h][1] = $langs->trans("Photos");
$head[$h][2] = 'photos';
$h++;
// Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
$head[$h][2] = 'documents';
$h++;

View File

@ -3101,10 +3101,14 @@ class Product extends CommonObject
*/
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
{
global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$result = 0;
$dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/photos";
$dir = $sdir;
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos";
dol_mkdir($dir);
@ -3156,8 +3160,8 @@ class Product extends CommonObject
{
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
$pdir = get_exdir($this->id,2) . $this->id ."/photos/";
$dir = $sdir . '/'. $pdir;
$dir = $sdir;
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos";
$nbphoto=0;
@ -3199,8 +3203,19 @@ class Product extends CommonObject
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
$pdir = get_exdir($this->id,2) . $this->id ."/photos/";
$dir = $sdir . '/'. $pdir;
$dir = $sdir . '/';
$pdir = '/';
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
$dir .= get_exdir($this->id,2) . $this->id ."/photos/";
$pdir .= get_exdir($this->id,2) . $this->id ."/photos/";
}
else
{
$dir .= $this->ref.'/';
$pdir .= $this->ref.'/';
}
$dirthumb = $dir.'thumbs/';
$pdirthumb = $pdir.'thumbs/';