New: Can add logo on third parties.

Qual: Uniformize code to show photos/logos.
This commit is contained in:
Laurent Destailleur 2011-06-11 14:14:27 +00:00
parent 2854809ce5
commit 7d5f0c3723
14 changed files with 1855 additions and 1678 deletions

View File

@ -1166,7 +1166,7 @@ if ($rowid && $action != 'edit')
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
$rowspan=18+sizeof($adho->attribute_label); $rowspan=19+sizeof($adho->attribute_label);
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1;
if ($conf->societe->enabled) $rowspan++; if ($conf->societe->enabled) $rowspan++;
@ -1178,18 +1178,21 @@ if ($rowid && $action != 'edit')
print $html->showrefnav($adh,'rowid'); print $html->showrefnav($adh,'rowid');
print '</td></tr>'; print '</td></tr>';
$showphoto='<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">';
$showphoto.=$html->showphoto('memberphoto',$adh);
$showphoto.='</td>';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{ {
print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur" colspan="2">'.$adh->login.'&nbsp;</td>'; print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$adh->login.'&nbsp;</td>';
print $showphoto; $showphoto='';
print '</tr>'; print '</tr>';
} }
// Morphy // Morphy
print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$adh->getmorphylib().'</td>'; print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$adh->getmorphylib().'</td>';
print '<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">'; print $showphoto; $showphoto='';
print $html->showphoto('memberphoto',$adh);
print '</td>';
print '</tr>'; print '</tr>';
// Type // Type
@ -1221,7 +1224,7 @@ if ($rowid && $action != 'edit')
print '</td></tr>'; print '</td></tr>';
// Zip / Town // Zip / Town
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->zip.' '.$adh->town.'</td></tr>'; print '<tr><td nowrap="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->zip.(($adh->zip && $adh->town)?' / ':'').$adh->town.'</td></tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'; print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">';

View File

@ -227,8 +227,8 @@ if ($socid > 0)
print "</td></tr>"; print "</td></tr>";
// Zip / Town // Zip / Town
print '<tr><td>'.$langs->trans('Zip').'</td><td>'.$objsoc->cp."</td>"; print '<tr><td nowrap="nowrap">'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td colspan="3">'.$objsoc->cp.(($objsoc->cp && $objsoc->ville)?' / ':'').$objsoc->ville."</td>";
print '<td>'.$langs->trans('Town').'</td><td>'.$objsoc->ville."</td></tr>"; print '</tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
@ -238,10 +238,10 @@ if ($socid > 0)
print '</td></tr>'; print '</td></tr>';
// Phone // Phone
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($objsoc->tel,$objsoc->pays_code,0,$objsoc->id,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans('Phone').'</td><td style="min-width: 25%;">'.dol_print_phone($objsoc->tel,$objsoc->pays_code,0,$objsoc->id,'AC_TEL').'</td>';
// Fax // Fax
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($objsoc->fax,$objsoc->pays_code,0,$objsoc->id,'AC_FAX').'</td></tr>'; print '<td>'.$langs->trans('Fax').'</td><td style="min-width: 25%;">'.dol_print_phone($objsoc->fax,$objsoc->pays_code,0,$objsoc->id,'AC_FAX').'</td></tr>';
// EMail // EMail
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($objsoc->email,0,$objsoc->id,'AC_EMAIL').'</td></tr>'; print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($objsoc->email,0,$objsoc->id,'AC_EMAIL').'</td></tr>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -99,7 +99,7 @@ if ($socid > 0)
print '<tr><td valign="top" width="50%" class="notopnoleft">'; print '<tr><td valign="top" width="50%" class="notopnoleft">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td width="80%" colspan="3">'; print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">';
$societe->next_prev_filter="te.client in (2,3)"; $societe->next_prev_filter="te.client in (2,3)";
print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>'; print '</td></tr>';
@ -110,8 +110,8 @@ if ($socid > 0)
print "</td></tr>"; print "</td></tr>";
// Zip / Town // Zip / Town
print '<tr><td>'.$langs->trans('Zip').'</td><td>'.$societe->cp.'</td>'; print '<tr><td nowrap="nowrap">'.$langs->trans('Zip').' / '.$langs->trans("Town").'</td><td colspan="3">'.$societe->cp.(($societe->cp && $societe->ville)?' / ':'').$societe->ville.'</td>';
print '<td>'.$langs->trans('Town').'</td><td>'.$societe->ville.'</td></tr>'; print '</tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
@ -121,7 +121,8 @@ if ($socid > 0)
print '</td></tr>'; print '</td></tr>';
// Phone // Phone
print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'</td><td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($societe->fax,$societe->pays_code).'</td></tr>'; print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'</td>';
print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->fax,$societe->pays_code).'</td></tr>';
// EMail // EMail
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'</td></tr>'; print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'</td></tr>';

View File

@ -3326,6 +3326,13 @@ class Form
$ret='';$dir='';$file='';$email=''; $ret='';$dir='';$file='';$email='';
if ($modulepart=='societe')
{
$dir=$conf->societe->dir_output;
$smallfile=$object->logo;
$smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile);
$file=$object->id.'/logos/thumbs/'.$smallfile;
}
if ($modulepart=='userphoto') if ($modulepart=='userphoto')
{ {
$dir=$conf->user->dir_output; $dir=$conf->user->dir_output;
@ -3347,13 +3354,13 @@ class Form
{ {
$ret.='<img alt="Photo" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'">'; $ret.='<img alt="Photo" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'">';
} }
else if (file_exists($dir."/".$altfile)) else if ($altfile && file_exists($dir."/".$altfile))
{ {
$ret.='<img alt="Photo" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($altfile).'">'; $ret.='<img alt="Photo" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($altfile).'">';
} }
else else
{ {
if ($conf->gravatar->enabled) if ($conf->gravatar->enabled && $email)
{ {
global $dolibarr_main_url_root; global $dolibarr_main_url_root;
$ret.='<!-- Put link to gravatar -->'; $ret.='<!-- Put link to gravatar -->';

View File

@ -77,11 +77,9 @@ class FormCompany
$objp = $this->db->fetch_object($resql); $objp = $this->db->fetch_object($resql);
if (! $mode) $key=$objp->id; if (! $mode) $key=$objp->id;
else $key=$objp->code; else $key=$objp->code;
if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code);
if ($langs->trans($objp->code) != $objp->code) else $effs[$key] = $objp->libelle;
$effs[$key] = $langs->trans($objp->code); if ($effs[$key]=='-') $effs[$key]='';
else
$effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Eric Seigne <erics@rycks.com> * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* *
@ -125,8 +125,8 @@ if ( $societe->fetch($socid) )
print '</td></tr>'; print '</td></tr>';
// Zip / Town // Zip / Town
print '<tr><td>'.$langs->trans("Zip").'</td><td>'.$societe->cp.'</td>'; print '<tr><td nowrap="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$societe->cp.(($societe->cp && $societe->ville)?' / ':'').$societe->ville.'</td>';
print '<td>'.$langs->trans("Town").'</td><td>'.$societe->ville.'</td></tr>'; print '</tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
@ -136,10 +136,10 @@ if ( $societe->fetch($socid) )
print '</td></tr>'; print '</td></tr>';
// Phone // Phone
print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'</td>';
// Fax // Fax
print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'</td></tr>'; print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'</td></tr>';
// EMail // EMail
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'</td></tr>'; print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'</td></tr>';

View File

@ -60,8 +60,8 @@ ALTER TABLE llx_facturedet DROP INDEX uk_fk_remise_except;
ALTER TABLE llx_facturedet ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_except, fk_facture); ALTER TABLE llx_facturedet ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_except, fk_facture);
ALTER TABLE llx_societe ADD COLUMN fk_currency integer DEFAULT 0 AFTER fk_forme_juridique; ALTER TABLE llx_societe ADD COLUMN fk_currency integer DEFAULT 0 AFTER fk_forme_juridique;
ALTER TABLE llx_societe ADD COLUMN status tinyint DEFAULT 1; ALTER TABLE llx_societe ADD COLUMN status tinyint DEFAULT 1;
ALTER TABLE llx_societe ADD COLUMN logo varchar(255);
ALTER TABLE llx_societe_remise MODIFY remise_client double(6,3) DEFAULT 0 NOT NULL; ALTER TABLE llx_societe_remise MODIFY remise_client double(6,3) DEFAULT 0 NOT NULL;

View File

@ -85,6 +85,7 @@ create table llx_societe
gencod varchar(255), -- barcode gencod varchar(255), -- barcode
price_level integer NULL, -- level of price for multiprices price_level integer NULL, -- level of price for multiprices
default_lang varchar(6), -- default language default_lang varchar(6), -- default language
logo varchar(255),
canvas varchar(32), -- type of canvas if used (null by default) canvas varchar(32), -- type of canvas if used (null by default)
import_key varchar(14) -- import key import_key varchar(14) -- import key
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -1047,7 +1047,7 @@ if ($id || $ref)
if ($isphoto) if ($isphoto)
{ {
// Photo // Photo
print '<td valign="middle" align="center" width="30%" rowspan="'.$nblignes.'">'; print '<td valign="middle" align="center" width="25%" rowspan="'.$nblignes.'">';
print $product->show_photos($conf->product->dir_output,1,1,0,0,0,80); print $product->show_photos($conf->product->dir_output,1,1,0,0,0,80);
print '</td>'; print '</td>';
} }

View File

@ -140,13 +140,6 @@ if ($_GET["socid"])
print dol_print_url($soc->url); print dol_print_url($soc->url);
print '</td></tr>'; print '</td></tr>';
// Assujeti a TVA ou pas
print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
print yn($soc->tva_assuj);
print '</td>';
print '</tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';

View File

@ -488,7 +488,7 @@ class Societe extends CommonObject
$sql .= ",fournisseur = " . ($this->fournisseur?$this->fournisseur:0); $sql .= ",fournisseur = " . ($this->fournisseur?$this->fournisseur:0);
$sql .= ",gencod = ".($this->gencod?"'".$this->gencod."'":"null"); $sql .= ",gencod = ".($this->gencod?"'".$this->gencod."'":"null");
$sql .= ",default_lang = ".($this->default_lang?"'".$this->default_lang."'":"null"); $sql .= ",default_lang = ".($this->default_lang?"'".$this->default_lang."'":"null");
$sql .= ",logo = ".($this->logo?"'".$this->logo."'":"null");
if ($allowmodcodeclient) if ($allowmodcodeclient)
{ {
@ -585,6 +585,7 @@ class Societe extends CommonObject
if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
$sql = 'SELECT s.rowid, s.nom as name, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as datec, s.prefix_comm'; $sql = 'SELECT s.rowid, s.nom as name, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as datec, s.prefix_comm';
$sql .= ', s.status';
$sql .= ', s.price_level'; $sql .= ', s.price_level';
$sql .= ', s.tms as date_update'; $sql .= ', s.tms as date_update';
$sql .= ', s.tel, s.fax, s.email, s.url, s.cp as zip, s.ville as town, s.note, s.client, s.fournisseur'; $sql .= ', s.tel, s.fax, s.email, s.url, s.cp as zip, s.ville as town, s.note, s.client, s.fournisseur';
@ -595,9 +596,8 @@ class Societe extends CommonObject
$sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.fk_forme_juridique as forme_juridique_code';
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.gencod'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.gencod';
$sql .= ', s.fk_departement, s.fk_pays, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj'; $sql .= ', s.fk_departement, s.fk_pays, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
$sql .= ', s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang'; $sql .= ', s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.import_key'; $sql .= ', s.import_key';
$sql .= ', s.status';
$sql .= ', fj.libelle as forme_juridique'; $sql .= ', fj.libelle as forme_juridique';
$sql .= ', e.libelle as effectif'; $sql .= ', e.libelle as effectif';
$sql .= ', p.code as pays_code, p.libelle as pays'; $sql .= ', p.code as pays_code, p.libelle as pays';
@ -730,6 +730,7 @@ class Societe extends CommonObject
$this->note = $obj->note; $this->note = $obj->note;
$this->default_lang = $obj->default_lang; $this->default_lang = $obj->default_lang;
$this->logo = $obj->logo;
// multiprix // multiprix
$this->price_level = $obj->price_level; $this->price_level = $obj->price_level;

View File

@ -31,6 +31,8 @@
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
@ -191,6 +193,8 @@ else
$soc->commercial_id = $_POST["commercial_id"]; $soc->commercial_id = $_POST["commercial_id"];
$soc->default_lang = $_POST["default_lang"]; $soc->default_lang = $_POST["default_lang"];
$soc->logo = dol_sanitizeFileName($_FILES['logo']['name']);
// Check parameters // Check parameters
if (empty($_POST["cancel"])) if (empty($_POST["cancel"]))
{ {
@ -246,8 +250,45 @@ else
$contact->priv=0; $contact->priv=0;
$result=$contact->create($user); $result=$contact->create($user);
if (! $result >= 0)
{
$error=$contact->error; $errors=$contact->errors;
} }
} }
### Gestion du logo de la société
$dir = $conf->societe->dir_output."/".$soc->id."/logos/";
$file_OK = is_uploaded_file($_FILES['logo']['tmp_name']);
if ($file_OK)
{
if (image_format_supported($_FILES['logo']['name']))
{
create_exdir($dir);
if (@is_dir($dir))
{
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['logo']['name']);
$result = dol_move_uploaded_file($_FILES['logo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
$errors[] = "ErrorFailedToSaveFile";
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}
}
}
### Gestion du logo de la société
}
else else
{ {
$error=$soc->error; $errors=$soc->errors; $error=$soc->error; $errors=$soc->errors;
@ -266,9 +307,6 @@ else
else else
{ {
$db->rollback(); $db->rollback();
$langs->load("errors");
$error=$langs->trans($soc->error);
$action='create'; $action='create';
} }
} }
@ -290,15 +328,53 @@ else
//var_dump($soc);exit; //var_dump($soc);exit;
$result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable()); $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable());
if ($result < 0)
{
$error = $soc->error; $errors = $soc->errors;
}
### Gestion du logo de la société
$dir = $conf->societe->dir_output."/".$soc->id."/logos/";
$file_OK = is_uploaded_file($_FILES['logo']['tmp_name']);
if ($file_OK)
{
if (image_format_supported($_FILES['logo']['name']))
{
create_exdir($dir);
if (@is_dir($dir))
{
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['logo']['name']);
$result = dol_move_uploaded_file($_FILES['logo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
$errors[] = "ErrorFailedToSaveFile";
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}
}
}
### Gestion du logo de la société
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
exit; exit;
} }
else else
{ {
$soc->id = $socid; $soc->id = $socid;
$error = $langs->trans($soc->error); $errors = $soc->errors;
$action= "edit"; $action= "edit";
} }
} }
@ -494,6 +570,41 @@ else
$soc->commercial_id=$_POST["commercial_id"]; $soc->commercial_id=$_POST["commercial_id"];
$soc->default_lang=$_POST["default_lang"]; $soc->default_lang=$_POST["default_lang"];
$soc->logo = dol_sanitizeFileName($_FILES['logo']['name']);
### Gestion du logo de la société
$dir = $conf->societe->dir_output."/".$soc->id."/logos/";
$file_OK = is_uploaded_file($_FILES['logo']['tmp_name']);
if ($file_OK)
{
if (image_format_supported($_FILES['logo']['name']))
{
create_exdir($dir);
if (@is_dir($dir))
{
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['logo']['name']);
$result = dol_move_uploaded_file($_FILES['logo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
$errors[] = "ErrorFailedToSaveFile";
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}
}
}
### Gestion du logo de la société
// We set pays_id, pays_code and label for the selected country // We set pays_id, pays_code and label for the selected country
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
if ($soc->pays_id) if ($soc->pays_id)
@ -565,7 +676,7 @@ else
dol_htmloutput_errors($error,$errors); dol_htmloutput_errors($error,$errors);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">'; print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -861,7 +972,13 @@ else
print '</td></tr>'; print '</td></tr>';
} }
// Ajout du logo
print '<tr>';
print '<td>'.$langs->trans("Logo").'</td>';
print '<td colspan="3">';
print '<input class="flat" type="file" name="logo" />';
print '</td>';
print '</tr>';
print '<tr><td colspan="4" align="center">'; print '<tr><td colspan="4" align="center">';
print '<input type="submit" class="button" value="'.$langs->trans('AddThirdParty').'">'; print '<input type="submit" class="button" value="'.$langs->trans('AddThirdParty').'">';
@ -982,7 +1099,7 @@ else
print '</script>'."\n"; print '</script>'."\n";
} }
print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$soc->id.'" method="post" name="formsoc">'; print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?socid='.$soc->id.'" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="socid" value="'.$soc->id.'">'; print '<input type="hidden" name="socid" value="'.$soc->id.'">';
@ -1092,7 +1209,7 @@ else
} }
// Status // Status
print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$soc->status); print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$soc->status);
print '</td></tr>'; print '</td></tr>';
@ -1258,6 +1375,7 @@ else
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>'; print '</td></tr>';
// Default language
if ($conf->global->MAIN_MULTILANGS) if ($conf->global->MAIN_MULTILANGS)
{ {
print '<tr><td>'.$langs->trans("DefaultLang").'</td><td colspan="3">'."\n"; print '<tr><td>'.$langs->trans("DefaultLang").'</td><td colspan="3">'."\n";
@ -1266,6 +1384,12 @@ else
print '</tr>'; print '</tr>';
} }
// Logo
print '<tr>';
print '<td>'.$langs->trans("Logo").'</span></td>';
print '<td colspan="3"><input type="file" name="logo" /></td>';
print '</tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -1310,70 +1434,106 @@ else
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref
/*
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">';
print $fuser->id;
print '</td>';
print '</tr>';
*/
// Name // Name
print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>'; print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom');
print '</td></tr>'; print '</td>';
print '</tr>';
// Logo
$rowspan=4;
if (! empty($conf->global->SOCIETE_USEPREFIX)) $rowspan++;
if ($soc->client) $rowspan++;
if ($conf->fournisseur->enabled && $soc->fournisseur) $rowspan++;
if ($conf->global->MAIN_MODULE_BARCODE) $rowspan++;
if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++;
$showlogo='';
if ($soc->logo)
{
$showlogo.='<td rowspan="'.$rowspan.'" style="text-align: center;" width="25%">';
$showlogo.=$html->showphoto('societe',$soc,50);
$showlogo.='</td>';
}
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{ {
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>'; print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="'.(2+($soc->logo?0:1)).'">'.$soc->prefix_comm.'</td>';
print $showlogo; $showlogo='';
print '</tr>';
} }
if ($soc->client) if ($soc->client)
{ {
print '<tr><td>'; print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="'.(2+($soc->logo?0:1)).'">';
print $soc->code_client; print $soc->code_client;
if ($soc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; if ($soc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>'; print '</td>';
print $showlogo; $showlogo='';
print '</tr>';
} }
if ($conf->fournisseur->enabled && $soc->fournisseur) if ($conf->fournisseur->enabled && $soc->fournisseur)
{ {
print '<tr><td>'; print '<tr><td>';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="'.(2+($soc->logo?0:1)).'">';
print $soc->code_fournisseur; print $soc->code_fournisseur;
if ($soc->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; if ($soc->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td></tr>'; print '</td>';
print $showlogo; $showlogo='';
print '</tr>';
} }
// Status // Status
print '<tr><td>'.$langs->trans("Status").'</td>'; print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td colspan="3">'; print '<td colspan="'.(2+($soc->logo?0:1)).'">';
print $soc->getLibStatut(2); print $soc->getLibStatut(2);
print '</td></tr>'; print '</td>';
print $showlogo; $showlogo='';
print '</tr>';
// Barcode // Barcode
if ($conf->global->MAIN_MODULE_BARCODE) if ($conf->global->MAIN_MODULE_BARCODE)
{ {
print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="3">'.$soc->gencod.'</td></tr>'; print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="'.(2+($soc->logo?0:1)).'">'.$soc->gencod.'</td></tr>';
} }
// Address // Address
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">"; print "<tr><td valign=\"top\">".$langs->trans('Address').'</td><td colspan="'.(2+($soc->logo?0:1)).'">';
dol_print_address($soc->address,'gmap','thirdparty',$soc->id); dol_print_address($soc->address,'gmap','thirdparty',$soc->id);
print "</td></tr>"; print "</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->cp."</td>"; // Zip / Town
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->ville."</td></tr>"; print '<tr><td width="25%">'.$langs->trans('Zip').' / '.$langs->trans("Town").'</td><td colspan="'.(2+($soc->logo?0:1)).'">';
print $soc->cp.($soc->cp && $soc->ville?" / ":"").$soc->ville;
print "</td>";
print '</tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3" nowrap="nowrap">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="'.(2+($soc->logo?0:1)).'" nowrap="nowrap">';
$img=picto_from_langcode($soc->pays_code); $img=picto_from_langcode($soc->pays_code);
if ($soc->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$soc->pays,$langs->trans("CountryIsInEEC"),1,0); if ($soc->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$soc->pays,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$soc->pays; else print ($img?$img.' ':'').$soc->pays;
print '</td></tr>'; print '</td></tr>';
// State // State
if (empty($conf->global->SOCIETE_DISABLE_STATE)) print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$soc->departement.'</td>'; if (empty($conf->global->SOCIETE_DISABLE_STATE)) print '<tr><td>'.$langs->trans('State').'</td><td colspan="'.(2+($soc->logo?0:1)).'">'.$soc->departement.'</td>';
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans('Phone').'</td><td style="min-width: 25%;">'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id,'AC_TEL').'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id,'AC_FAX').'</td></tr>'; print '<td>'.$langs->trans('Fax').'</td><td style="min-width: 25%;">'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id,'AC_FAX').'</td></tr>';
// EMail // EMail
print '<tr><td>'.$langs->trans('EMail').'</td><td>'; print '<tr><td>'.$langs->trans('EMail').'</td><td width="25%">';
print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL'); print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL');
print '</td>'; print '</td>';

View File

@ -911,22 +911,28 @@ else
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
// Lastname $rowspan=13;
print '<tr><td valign="top">'.$langs->trans("Lastname").'</td>';
print '<td colspan="2">'.$fuser->nom.'</td>';
print '</tr>'."\n";
// Firstname
print '<tr><td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td colspan="2">'.$fuser->prenom.'</td>';
print '</tr>'."\n";
$rowspan=11;
if ($conf->societe->enabled) $rowspan++; if ($conf->societe->enabled) $rowspan++;
if ($conf->adherent->enabled) $rowspan++; if ($conf->adherent->enabled) $rowspan++;
if ($conf->webcalendar->enabled) $rowspan++; if ($conf->webcalendar->enabled) $rowspan++;
if ($conf->phenix->enabled) $rowspan+=2; if ($conf->phenix->enabled) $rowspan+=2;
// Lastname
print '<tr><td valign="top">'.$langs->trans("Lastname").'</td>';
print '<td>'.$fuser->nom.'</td>';
// Photo
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $html->showphoto('userphoto',$fuser,100);
print '</td>';
print '</tr>'."\n";
// Firstname
print '<tr><td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td>'.$fuser->prenom.'</td>';
print '</tr>'."\n";
// Login // Login
print '<tr><td valign="top">'.$langs->trans("Login").'</td>'; print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
if ($fuser->ldap_sid && $fuser->statut==0) if ($fuser->ldap_sid && $fuser->statut==0)
@ -937,10 +943,6 @@ else
{ {
print '<td>'.$fuser->login.'</td>'; print '<td>'.$fuser->login.'</td>';
} }
// Photo
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $html->showphoto('userphoto',$fuser,100,1);
print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
// Password // Password
@ -1300,7 +1302,7 @@ else
print '<input type="hidden" name="entity" value="'.$conf->entity.'">'; print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
$rowspan=9; $rowspan=11;
if ($conf->societe->enabled) $rowspan++; if ($conf->societe->enabled) $rowspan++;
if ($conf->adherent->enabled) $rowspan++; if ($conf->adherent->enabled) $rowspan++;
if ($conf->webcalendar->enabled) $rowspan++; if ($conf->webcalendar->enabled) $rowspan++;
@ -1312,9 +1314,10 @@ else
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Nom // Lastname
print "<tr>".'<td valign="top" class="fieldrequired">'.$langs->trans("Lastname").'</span></td>'; print "<tr>";
print '<td colspan="2">'; print '<td valign="top" class="fieldrequired">'.$langs->trans("Lastname").'</td>';
print '<td>';
if ($caneditfield && !$fuser->ldap_sid) if ($caneditfield && !$fuser->ldap_sid)
{ {
print '<input size="30" type="text" class="flat" name="nom" value="'.$fuser->nom.'">'; print '<input size="30" type="text" class="flat" name="nom" value="'.$fuser->nom.'">';
@ -1324,11 +1327,23 @@ else
print '<input type="hidden" name="nom" value="'.$fuser->nom.'">'; print '<input type="hidden" name="nom" value="'.$fuser->nom.'">';
print $fuser->nom; print $fuser->nom;
} }
print '</td></tr>'; print '</td>';
// Photo
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $html->showphoto('userphoto',$fuser);
if ($caneditfield)
{
print '<br><br><table class="nobordernopadding"><tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td>';
print '<input type="file" class="flat" name="photo">';
print '</td></tr></table>';
}
print '</td>';
print '</tr>';
// Prenom // Firstname
print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>'; print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td colspan="2">'; print '<td>';
if ($caneditfield && !$fuser->ldap_sid) if ($caneditfield && !$fuser->ldap_sid)
{ {
print '<input size="30" type="text" class="flat" name="prenom" value="'.$fuser->prenom.'">'; print '<input size="30" type="text" class="flat" name="prenom" value="'.$fuser->prenom.'">';
@ -1353,18 +1368,6 @@ else
print $fuser->login; print $fuser->login;
} }
print '</td>'; print '</td>';
// Photo
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $html->showphoto('userphoto',$fuser);
if ($caneditfield)
{
print '<br><br><table class="nobordernopadding"><tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td>';
print '<input type="file" class="flat" name="photo">';
print '</td></tr></table>';
}
print '</td>';
print '</tr>'; print '</tr>';
// Pass // Pass
@ -1401,9 +1404,11 @@ else
else else
{ {
print '<td>'; print '<td>';
// Don't downgrade a superadmin if alone
$nbSuperAdmin = $user->getNbOfUsers('superadmin'); $nbSuperAdmin = $user->getNbOfUsers('superadmin');
if ($user->admin && ($fuser->entity > 0 || $nbSuperAdmin > 1) ) if ($user->admin
&& ($user->id != $fuser->id) // Don't downgrade ourself
&& ($fuser->entity > 0 || $nbSuperAdmin > 1) // Don't downgrade a superadmin if alone
)
{ {
print $form->selectyesno('admin',$fuser->admin,1); print $form->selectyesno('admin',$fuser->admin,1);
@ -1618,13 +1623,14 @@ else
print "</tr>\n"; print "</tr>\n";
} }
print '<tr><td align="center" colspan="3">'; print '</table>';
print '<br><center>';
print '<input value="'.$langs->trans("Save").'" class="button" type="submit" name="save">'; print '<input value="'.$langs->trans("Save").'" class="button" type="submit" name="save">';
print ' &nbsp; '; print ' &nbsp; ';
print '<input value="'.$langs->trans("Cancel").'" class="button" type="submit" name="cancel">'; print '<input value="'.$langs->trans("Cancel").'" class="button" type="submit" name="cancel">';
print '</td></tr>'; print '</center>';
print '</table>';
print '</form>'; print '</form>';
print '</div>'; print '</div>';

View File

@ -102,6 +102,13 @@ if ($modulepart)
$original_file=$conf->adherent->dir_output.'/'.$original_file; $original_file=$conf->adherent->dir_output.'/'.$original_file;
} }
// Wrapping pour les images des societes
if ($modulepart == 'societe')
{
$accessallowed=1;
$original_file=$conf->societe->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu factures // Wrapping pour les apercu factures
elseif ($modulepart == 'apercufacture') elseif ($modulepart == 'apercufacture')
{ {