Fix: Le logo n'etait pas toujours la meme variable ou meme chemin. J'ai uniformis afin que le path et nom du logo soit dfini dans le fichier environnement master.inc.php.

Tous les modules utilisent $conf->societe->dir_logos et $mysoc->logo pour le patch des logos et pour le nom du fichier logo de la socit.
This commit is contained in:
Laurent Destailleur 2006-05-08 17:22:53 +00:00
parent 470a0b3b82
commit 31d6a4f9d3
16 changed files with 146 additions and 103 deletions

View File

@ -53,11 +53,21 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update')
if (eregi('([^\\\/:]+)$',$_FILES["logo"]["name"],$reg))
{
$original_file=$reg[1];
dolibarr_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".DOL_DATA_ROOT.'/logo/'.$original_file);
if (move_uploaded_file($_FILES["logo"]["tmp_name"],DOL_DATA_ROOT.'/logo/'.$original_file))
dolibarr_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".$conf->societe->dir_logos.'/'.$original_file);
if (! is_dir($conf->societe->dir_logos))
{
create_exdir($conf->societe->dir_logos);
}
if (doliMoveFileUpload($_FILES["logo"]["tmp_name"],$conf->societe->dir_logos.'/'.$original_file))
{
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file);
}
else
{
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
}
}
}
@ -166,7 +176,18 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Logo").' (png,jpg)</td><td>';
print '<input type="file" class="flat" name="logo" size="30"></td></tr>';
print '<table width="100%"><tr><td valign="center">';
print '<input type="file" class="flat" name="logo" size="30">';
print '</td><td valign="center" align="right">';
if (file_exists($conf->societe->dir_logos.'/'.$mysoc->logo))
{
print '<img height="30" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.$mysoc->logo.'">';
}
else
{
print '<img height="30" src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
}
print '</td></tr></table>';
print '</td></tr>';
$var=!$var;
@ -343,7 +364,8 @@ else
/*
* Affichage des paramètres
*/
if ($message) print $message.'<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("CompanyInfo").'</td><td>'.$langs->trans("Value").'</td></tr>';
$var=true;
@ -383,7 +405,22 @@ else
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Web").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_WEB . '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Logo").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_LOGO . '</td></tr>';
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Logo").'</td><td>';
print '<table width="100%"><tr><td valign="center">';
print $mysoc->logo;
print '</td><td valign="center" align="right">';
if (file_exists($conf->societe->dir_logos.'/'.$mysoc->logo))
{
print '<img height="30" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.$mysoc->logo.'">';
}
else
{
print '<img height="30" src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
}
print '</td></tr></table>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%" valign="top">'.$langs->trans("Note").'</td><td>' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '</td></tr>';

View File

@ -35,7 +35,7 @@ if ( $_POST["sendit"] )
mkdir($upload_dir, 0755);
}
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
{
print "Le fichier est valide, et a &eacute;t&eacute; t&eacute;l&eacute;charg&eacute; avec succ&egrave;s.\n";
//print_r($_FILES);

View File

@ -212,21 +212,28 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$tab4_hl = 6;
$tab4_sl = 4;
$ligne = 2;
//*********************LOGO****************************
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO){
$this->SetXY(10,5);
if (file_exists(FAC_PDF_LOGO)) {
$this->Image(FAC_PDF_LOGO, 10, 5,85.0, 17.0, 'PNG');
}else {
//Cas Erreur Fichier introuvable
$this->SetTextColor(200,0,0);
$this->SetFont('Arial','B',8);
$this->MultiCell(80, 3, $langs->trans("ErrorLogoFileNotFound",FAC_PDF_LOGO), 0, 'L');
$this->MultiCell(80, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L');
}
}else if (defined("FAC_PDF_INTITULE")){
$this->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L');
}
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))
{
$pdf->Image($logo,10, 5, 0, 24);
}
else
{
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(100, 3, $langs->trans("ErrorLogoFileNotFound",$logo), 0, 'L');
$pdf->MultiCell(100, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L');
}
}
else if(defined("MAIN_INFO_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM)
{
$pdf->MultiCell(100, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L');
}
//*********************Entete****************************
//Nom du Document
$Yoff = 0;

View File

@ -64,7 +64,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$this->marge_haute=10;
$this->marge_basse=10;
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
$this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode règlement
$this->option_condreg = 1; // Affiche conditions règlement
@ -642,8 +642,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetXY($this->marge_gauche,$posy);
// Logo
$logo=$mysoc->logo;
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -640,8 +640,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($this->marge_gauche,$posy);
// Logo
$logo=$mysoc->logo;
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -62,7 +62,7 @@ class pdf_crabe extends ModelePDFFactures
$this->marge_haute=10;
$this->marge_basse=10;
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
$this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode règlement
$this->option_condreg = 1; // Affiche conditions règlement
@ -100,26 +100,26 @@ class pdf_crabe extends ModelePDFFactures
/**
\brief Fonction générant la facture sur le disque
\param id Id de la facture à générer
\return int 1=ok, 0=ko
\remarks Variables utilisées
\remarks MAIN_INFO_SOCIETE_NOM
\remarks MAIN_INFO_ADRESSE
\remarks MAIN_INFO_CP
\remarks MAIN_INFO_VILLE
\remarks MAIN_INFO_TEL
\remarks MAIN_INFO_FAX
\remarks MAIN_INFO_WEB
\remarks MAIN_INFO_SIRET
\remarks MAIN_INFO_SIREN
\remarks MAIN_INFO_RCS
\remarks MAIN_INFO_CAPITAL
\remarks MAIN_INFO_TVAINTRA
\remarks MAIN_INFO_LOGO
\remarks FACTURE_CHQ_NUMBER
\remarks FACTURE_RIB_NUMBER
*/
* \brief Fonction générant la facture sur le disque
* \param id Id de la facture à générer
* \return int 1=ok, 0=ko
* \remarks Variables utilisées
* \remarks MAIN_INFO_SOCIETE_NOM
* \remarks MAIN_INFO_SOCIETE_ADRESSE
* \remarks MAIN_INFO_SOCIETE_CP
* \remarks MAIN_INFO_SOCIETE_VILLE
* \remarks MAIN_INFO_SOCIETE_TEL
* \remarks MAIN_INFO_SOCIETE_FAX
* \remarks MAIN_INFO_SOCIETE_WEB
* \remarks MAIN_INFO_SOCIETE_LOGO
* \remarks MAIN_INFO_SIRET
* \remarks MAIN_INFO_SIREN
* \remarks MAIN_INFO_RCS
* \remarks MAIN_INFO_CAPITAL
* \remarks MAIN_INFO_TVAINTRA
* \remarks FACTURE_CHQ_NUMBER
* \remarks FACTURE_RIB_NUMBER
*/
function write_pdf_file($id)
{
global $user,$langs,$conf,$mysoc;
@ -760,8 +760,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($this->marge_gauche,$posy);
// Logo
$logo=$mysoc->logo;
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -431,7 +431,7 @@ class pdf_huitre extends ModelePDFFactures {
$ligne = 2;
// Logo
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -82,26 +82,27 @@ class pdf_oursin extends ModelePDFFactures
}
/**
\brief Fonction générant la facture sur le disque
\param facid id de la facture à générer
\return int 1=ok, 0=ko
\remarks Variables utilisées
\remarks MAIN_INFO_SOCIETE_NOM
\remarks MAIN_INFO_SIRET
\remarks MAIN_INFO_SIREN
\remarks MAIN_INFO_CAPITAL
\remarks MAIN_INFO_TVAINTRA
\remarks FAC_PDF_LOGO
\remarks FACTURE_CODEPRODUITSERVICE
\remarks FACTURE_CHQ_NUMBER
\remarks FACTURE_RIB_NUMBER
\remarks FAC_PDF_INTITULE
\remarks FAC_PDF_TEL
\remarks FAC_PDF_ADRESSE
*/
function write_pdf_file($facid)
{
/**
* \brief Fonction générant la facture sur le disque
* \param facid id de la facture à générer
* \return int 1=ok, 0=ko
* \remarks Variables utilisées
* \remarks MAIN_INFO_SOCIETE_NOM
* \remarks MAIN_INFO_SOCIETE_ADRESSE
* \remarks MAIN_INFO_SOCIETE_CP
* \remarks MAIN_INFO_SOCIETE_VILLE
* \remarks MAIN_INFO_SOCIETE_TEL
* \remarks MAIN_INFO_SOCIETE_FAX
* \remarks MAIN_INFO_SOCIETE_WEB
* \remarks MAIN_INFO_SOCIETE_LOGO
* \remarks MAIN_INFO_SIRET
* \remarks MAIN_INFO_SIREN
* \remarks MAIN_INFO_RCS
* \remarks MAIN_INFO_CAPITAL
* \remarks MAIN_INFO_TVAINTRA
*/
function write_pdf_file($facid)
{
global $user,$langs,$conf;
$langs->load("main");
@ -578,7 +579,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY($this->marges['g'],6);
// Logo
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -86,8 +86,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->SetXY(10,5);
// Logo
$logo=$mysoc->logo;
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -109,11 +109,6 @@ class modFacture extends DolibarrModules
$this->const[5][2] = "www.masociete.com";
$this->const[5][4] = 1;
$this->const[6][0] = "FAC_PDF_LOGO";
$this->const[6][1] = "chaine";
$this->const[6][2] = "/logo/mylogo.png";
$this->const[6][4] = 1;
$this->const[7][0] = "FACTURE_ADDON_PDF";
$this->const[7][1] = "chaine";
$this->const[7][2] = "bulot";

View File

@ -63,7 +63,7 @@ class pdf_propale_azur extends ModelePDFPropales
$this->marge_haute=10;
$this->marge_basse=10;
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
$this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode règlement
$this->option_condreg = 1; // Affiche conditions règlement
@ -114,18 +114,18 @@ class pdf_propale_azur extends ModelePDFPropales
\return int 1=ok, 0=ko
\remarks Variables utilisées
\remarks MAIN_INFO_SOCIETE_NOM
\remarks MAIN_INFO_ADRESSE
\remarks MAIN_INFO_CP
\remarks MAIN_INFO_VILLE
\remarks MAIN_INFO_TEL
\remarks MAIN_INFO_FAX
\remarks MAIN_INFO_WEB
\remarks MAIN_INFO_SOCIETE_ADRESSE
\remarks MAIN_INFO_SOCIETE_CP
\remarks MAIN_INFO_SOCIETE_VILLE
\remarks MAIN_INFO_SOCIETE_TEL
\remarks MAIN_INFO_SOCIETE_FAX
\remarks MAIN_INFO_SOCIETE_WEB
\remarks MAIN_INFO_SOCIETE_LOGO
\remarks MAIN_INFO_SIRET
\remarks MAIN_INFO_SIREN
\remarks MAIN_INFO_RCS
\remarks MAIN_INFO_CAPITAL
\remarks MAIN_INFO_TVAINTRA
\remarks MAIN_INFO_LOGO
*/
function write_pdf_file($id)
{
@ -670,8 +670,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetXY($this->marge_gauche,$posy);
// Logo
$logo=$mysoc->logo;
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -1135,21 +1135,21 @@ function dolibarr_print_error($db='',$msg='')
/**
\brief Deplacer les fichiers telechargés
\brief Deplacer les fichiers telechargés, apres quelques controles divers
\param src_file fichier source
\param dest_file fichier de destination
\return int le resultat du move_uploaded_file
*/
function doliMoveFileUpload($src_file, $dest_file)
{
$file_name = $dest_file;
if (substr($file_name, strlen($file_name) -3 , 3) == 'php')
{
$file_name = $dest_file . ".txt";
}
return move_uploaded_file($src_file, $file_name);
$file_name = $dest_file;
if (substr($file_name, strlen($file_name) -3 , 3) == 'php')
{
$file_name = $dest_file . ".txt";
}
return move_uploaded_file($src_file, $file_name);
}

View File

@ -640,8 +640,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetXY($this->marge_gauche,$posy);
// Logo
$logo=$mysoc->logo;
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
if ($logo)
{
if (is_readable($logo))

View File

@ -232,7 +232,8 @@ $conf->livraison->dir_images=DOL_DATA_ROOT."/livraison/images";
$conf->societe->enabled=defined("MAIN_MODULE_SOCIETE")?MAIN_MODULE_SOCIETE:0;
$conf->societe->dir_output=DOL_DATA_ROOT."/societe";
$conf->societe->dir_images=DOL_DATA_ROOT."/societe/images";
if (defined('SOCIETE_OUTPUTDIR') && SOCIETE_OUTPUTDIR) { $conf->societe->dir_output=SOCIETE_OUTPUTDIR; } # Pour passer outre le rep par d?faut
$conf->societe->dir_logos=DOL_DATA_ROOT."/societe/logos";
if (defined('SOCIETE_OUTPUTDIR') && SOCIETE_OUTPUTDIR) { $conf->societe->dir_output=SOCIETE_OUTPUTDIR; } # Pour passer outre le rep par defaut
// Module commercial
$conf->commercial->enabled=defined("MAIN_MODULE_COMMERCIAL")?MAIN_MODULE_COMMERCIAL:0;
$conf->commercial->dir_output=DOL_DATA_ROOT."/rapport";
@ -485,6 +486,7 @@ $mysoc->capital=$conf->global->MAIN_INFO_CAPITAL;
$mysoc->forme_juridique_code=$conf->global->MAIN_INFO_FORME_JURIDIQUE;
$mysoc->email=$conf->global->MAIN_INFO_SOCIETE_MAIL;
$mysoc->adresse_full=$mysoc->adresse."\n".$mysoc->cp." ".$mysoc->ville;
$mysoc->logo=$conf->global->MAIN_INFO_SOCIETE_LOGO;
/* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de désactiver la fonction TVA
* (pour particuliers ou libéraux en franchise)

View File

@ -472,7 +472,7 @@ else
}
else
{
print '<img src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
print '<img width="100" src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
}
print '</td></tr>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -19,7 +19,6 @@
*
* $Id$
* $Source$
*
*/
/** \file htdocs/viewimage.php
@ -28,7 +27,7 @@
\version $Revision$
*/
require_once("main.inc.php");
require_once("master.inc.php");
// C'est un wrapper, donc header vierge
@ -48,6 +47,14 @@ if ($modulepart)
{
// On fait une vérification des droits et on définit le répertoire concerné
// Wrapping pour les photo utilisateurs
if ($modulepart == 'companylogo')
{
$accessallowed=1;
//}
$original_file=$conf->societe->dir_logos.'/'.$original_file;
}
// Wrapping pour les photo utilisateurs
if ($modulepart == 'userphoto')
{