Prepare to generalize usage of get_exdir
This commit is contained in:
parent
6d03ba228d
commit
4d6b25eb45
@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
||||||
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
@ -265,7 +265,6 @@ class FormFile
|
|||||||
|
|
||||||
if (! is_object($form)) $form=new Form($this->db);
|
if (! is_object($form)) $form=new Form($this->db);
|
||||||
|
|
||||||
// filedir = $conf->...->dir_ouput."/".get_exdir(id)
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
@ -707,7 +706,7 @@ class FormFile
|
|||||||
$relativepath = $file["name"];
|
$relativepath = $file["name"];
|
||||||
}
|
}
|
||||||
if ($modulepart == 'facture_fournisseur') {
|
if ($modulepart == 'facture_fournisseur') {
|
||||||
$relativepath = get_exdir($modulesubdir, 2). $modulesubdir. "/" . $file["name"];
|
$relativepath = get_exdir($modulesubdir, 2). $modulesubdir. "/" . $file["name"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show file name with link to download
|
// Show file name with link to download
|
||||||
|
|||||||
@ -3701,26 +3701,42 @@ function yn($yesno, $case=1, $color=0)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a path to have a directory according to an id
|
* Return a path to have a directory according to object.
|
||||||
* Examples: '001' with level 3->"0/0/1/", '015' with level 3->"0/1/5/"
|
* Examples: '001' with level 3->"0/0/1/", '015' with level 3->"0/1/5/"
|
||||||
* Examples: 'ABC-1' with level 3 ->"0/0/1/", '015' with level 1->"5/"
|
* Examples: 'ABC-1' with level 3 ->"0/0/1/", '015' with level 1->"5/"
|
||||||
*
|
*
|
||||||
* @param string $num Id to develop
|
* @param string $num Id of object
|
||||||
* @param int $level Level of development (1, 2 or 3 level)
|
* @param int $level Level of subdirs to return (1, 2 or 3 levels)
|
||||||
* @param int $alpha Use alpha ref
|
* @param int $alpha Use alpha ref
|
||||||
* @param int $withoutslash 0=With slash at end, 1=without slash at end
|
* @param int $withoutslash 0=With slash at end, 1=without slash at end (except if '/', we return '')
|
||||||
* @return string Dir to use
|
* @param string $ref Not used yet. May be used to manage different option of directory path according to element.
|
||||||
|
* @param string $modulepart Not used yet. May be used to manage different option of directory path according to element.
|
||||||
|
* @return string Dir to use ending. Example '' or '1/' or '1/2/'
|
||||||
*/
|
*/
|
||||||
function get_exdir($num,$level=3,$alpha=0,$withoutslash=0)
|
function get_exdir($num,$level,$alpha=0,$withoutslash=0,$ref='',$modulepart='')
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$path = '';
|
$path = '';
|
||||||
if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
|
|
||||||
else $num = preg_replace('/^.*\-/i','',$num);
|
if (in_array($modulepart, array('don','donation','supplier_invoice','invoice_supplier')))
|
||||||
$num = substr("000".$num, -$level);
|
{
|
||||||
if ($level == 1) $path = substr($num,0,1);
|
if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
|
||||||
if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1);
|
else $num = preg_replace('/^.*\-/i','',$num);
|
||||||
if ($level == 3) $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1);
|
$num = substr("000".$num, -$level);
|
||||||
if (empty($withoutslash)) $path.='/';
|
if ($level == 1) $path = substr($num,0,1);
|
||||||
|
if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1);
|
||||||
|
if ($level == 3) $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
// We will introduce here a common way of forging path for document storage
|
||||||
|
// Here, $num=id, ref and modulepart are required.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($withoutslash) && ! empty($path)) $path.='/';
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -184,8 +184,8 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$pdir[0] = dol_sanitizeFileName($objphoto->ref).'/';
|
$pdir[0] = dol_sanitizeFileName($objphoto->ref).'/'; // default
|
||||||
$pdir[1] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/";
|
$pdir[1] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/"; // alternative
|
||||||
}
|
}
|
||||||
|
|
||||||
$arephoto = false;
|
$arephoto = false;
|
||||||
@ -331,7 +331,7 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
|
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
|
||||||
$tab_height = 130;
|
$tab_height = 130;
|
||||||
$tab_height_newpage = 150;
|
$tab_height_newpage = 150;
|
||||||
|
|
||||||
// Incoterm
|
// Incoterm
|
||||||
$height_incoterms = 0;
|
$height_incoterms = 0;
|
||||||
if ($conf->incoterm->enabled)
|
if ($conf->incoterm->enabled)
|
||||||
@ -345,11 +345,11 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
|
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
|
||||||
$nexY = $pdf->GetY();
|
$nexY = $pdf->GetY();
|
||||||
$height_incoterms=$nexY-$tab_top;
|
$height_incoterms=$nexY-$tab_top;
|
||||||
|
|
||||||
// Rect prend une longueur en 3eme param
|
// Rect prend une longueur en 3eme param
|
||||||
$pdf->SetDrawColor(192,192,192);
|
$pdf->SetDrawColor(192,192,192);
|
||||||
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
|
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
|
||||||
|
|
||||||
$tab_top = $nexY+6;
|
$tab_top = $nexY+6;
|
||||||
$height_incoterms += 4;
|
$height_incoterms += 4;
|
||||||
}
|
}
|
||||||
@ -644,7 +644,7 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
|
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Customer signature area
|
// Customer signature area
|
||||||
$posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
|
$posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
|
||||||
|
|
||||||
@ -653,33 +653,33 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
|
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
|
||||||
|
|
||||||
//If propal merge product PDF is active
|
//If propal merge product PDF is active
|
||||||
if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
|
if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
|
||||||
|
|
||||||
$already_merged = array ();
|
$already_merged = array ();
|
||||||
foreach ( $object->lines as $line ) {
|
foreach ( $object->lines as $line ) {
|
||||||
if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
|
if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
|
||||||
// Find the desire PDF
|
// Find the desire PDF
|
||||||
$filetomerge = new Propalmergepdfproduct($this->db);
|
$filetomerge = new Propalmergepdfproduct($this->db);
|
||||||
|
|
||||||
if ($conf->global->MAIN_MULTILANGS) {
|
if ($conf->global->MAIN_MULTILANGS) {
|
||||||
$filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
|
$filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
|
||||||
} else {
|
} else {
|
||||||
$filetomerge->fetch_by_product($line->fk_product);
|
$filetomerge->fetch_by_product($line->fk_product);
|
||||||
}
|
}
|
||||||
|
|
||||||
$already_merged[] = $line->fk_product;
|
$already_merged[] = $line->fk_product;
|
||||||
|
|
||||||
$product = new Product($this->db);
|
$product = new Product($this->db);
|
||||||
$product->fetch($line->fk_product);
|
$product->fetch($line->fk_product);
|
||||||
|
|
||||||
if ($product->entity!=$conf->entity) {
|
if ($product->entity!=$conf->entity) {
|
||||||
$entity_product_file=$product->entity;
|
$entity_product_file=$product->entity;
|
||||||
} else {
|
} else {
|
||||||
$entity_product_file=$conf->entity;
|
$entity_product_file=$conf->entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If PDF is selected and file is not empty
|
// If PDF is selected and file is not empty
|
||||||
if (count($filetomerge->lines) > 0) {
|
if (count($filetomerge->lines) > 0) {
|
||||||
foreach ( $filetomerge->lines as $linefile ) {
|
foreach ( $filetomerge->lines as $linefile ) {
|
||||||
@ -688,9 +688,9 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref);
|
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref);
|
||||||
elseif (! empty($conf->service->enabled))
|
elseif (! empty($conf->service->enabled))
|
||||||
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref);
|
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref);
|
||||||
|
|
||||||
dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
|
dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
|
||||||
|
|
||||||
$infile = $filetomerge_dir . '/' . $linefile->file_name;
|
$infile = $filetomerge_dir . '/' . $linefile->file_name;
|
||||||
if (is_file($infile)) {
|
if (is_file($infile)) {
|
||||||
$pagecount = $pdf->setSourceFile($infile);
|
$pagecount = $pdf->setSourceFile($infile);
|
||||||
@ -707,11 +707,11 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//exit;
|
//exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$pdf->Close();
|
$pdf->Close();
|
||||||
|
|
||||||
$pdf->Output($file,'F');
|
$pdf->Output($file,'F');
|
||||||
@ -1567,10 +1567,10 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
$pdf->SetFillColor(255,255,255);
|
$pdf->SetFillColor(255,255,255);
|
||||||
$pdf->SetXY($posx, $tab_top + 0);
|
$pdf->SetXY($posx, $tab_top + 0);
|
||||||
$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
|
$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
|
||||||
|
|
||||||
$pdf->SetXY($posx, $tab_top + $tab_hl);
|
$pdf->SetXY($posx, $tab_top + $tab_hl);
|
||||||
$pdf->MultiCell($largcol, $tab_hl*6, '', 1, 'R');
|
$pdf->MultiCell($largcol, $tab_hl*6, '', 1, 'R');
|
||||||
|
|
||||||
return ($tab_hl*7);
|
return ($tab_hl*7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user