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;

File diff suppressed because it is too large Load Diff

View File

@ -894,7 +894,7 @@ else
$ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete", '', 0, 1); $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
dol_htmloutput_errors($message); dol_htmloutput_errors($message);
/* /*
@ -911,22 +911,28 @@ else
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
$rowspan=13;
if ($conf->societe->enabled) $rowspan++;
if ($conf->adherent->enabled) $rowspan++;
if ($conf->webcalendar->enabled) $rowspan++;
if ($conf->phenix->enabled) $rowspan+=2;
// Lastname // Lastname
print '<tr><td valign="top">'.$langs->trans("Lastname").'</td>'; print '<tr><td valign="top">'.$langs->trans("Lastname").'</td>';
print '<td colspan="2">'.$fuser->nom.'</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"; print '</tr>'."\n";
// Firstname // Firstname
print '<tr><td valign="top">'.$langs->trans("Firstname").'</td>'; print '<tr><td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td colspan="2">'.$fuser->prenom.'</td>'; print '<td>'.$fuser->prenom.'</td>';
print '</tr>'."\n"; print '</tr>'."\n";
$rowspan=11;
if ($conf->societe->enabled) $rowspan++;
if ($conf->adherent->enabled) $rowspan++;
if ($conf->webcalendar->enabled) $rowspan++;
if ($conf->phenix->enabled) $rowspan+=2;
// 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
@ -1204,10 +1206,10 @@ else
// On selectionne les groupes auquel fait parti le user // On selectionne les groupes auquel fait parti le user
$exclude = array(); $exclude = array();
$usergroup=new UserGroup($db); $usergroup=new UserGroup($db);
$groupslist = $usergroup->listGroupsForUser($fuser->id); $groupslist = $usergroup->listGroupsForUser($fuser->id);
if (! empty($groupslist)) if (! empty($groupslist))
{ {
foreach($groupslist as $groupforuser) foreach($groupslist as $groupforuser)
@ -1246,7 +1248,7 @@ else
if (! empty($groupslist)) if (! empty($groupslist))
{ {
$var=true; $var=true;
foreach($groupslist as $group) foreach($groupslist as $group)
{ {
$var=!$var; $var=!$var;
@ -1300,11 +1302,11 @@ 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++;
if ($conf->phenix->enabled) $rowspan+=2; if ($conf->phenix->enabled) $rowspan+=2;
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>'; print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
@ -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

@ -59,8 +59,8 @@ if (GETPOST("cache"))
// each Dolibarr page access. // each Dolibarr page access.
if (empty($dolibarr_nocache)) if (empty($dolibarr_nocache))
{ {
header('Cache-Control: max-age=3600, public, must-revalidate'); header('Cache-Control: max-age=3600, public, must-revalidate');
header('Pragma: cache'); // This is to avoid having Pragma: no-cache header('Pragma: cache'); // This is to avoid having Pragma: no-cache
} }
else header('Cache-Control: no-cache'); else header('Cache-Control: no-cache');
//print $dolibarr_nocache; exit; //print $dolibarr_nocache; exit;
@ -79,210 +79,217 @@ if (empty($modulepart)) accessforbidden('Bad value for modulepart');
$accessallowed=0; $accessallowed=0;
if ($modulepart) if ($modulepart)
{ {
// Check permissions and define directory // Check permissions and define directory
// Wrapping for company logo // Wrapping for company logo
if ($modulepart == 'companylogo') if ($modulepart == 'companylogo')
{ {
$accessallowed=1; $accessallowed=1;
$original_file=$conf->mycompany->dir_output.'/logos/'.$original_file; $original_file=$conf->mycompany->dir_output.'/logos/'.$original_file;
} }
// Wrapping for users photos // Wrapping for users photos
elseif ($modulepart == 'userphoto') elseif ($modulepart == 'userphoto')
{ {
$accessallowed=1; $accessallowed=1;
$original_file=$conf->user->dir_output.'/'.$original_file; $original_file=$conf->user->dir_output.'/'.$original_file;
} }
// Wrapping for members photos // Wrapping for members photos
elseif ($modulepart == 'memberphoto') elseif ($modulepart == 'memberphoto')
{ {
$accessallowed=1; $accessallowed=1;
$original_file=$conf->adherent->dir_output.'/'.$original_file; $original_file=$conf->adherent->dir_output.'/'.$original_file;
} }
// Wrapping pour les apercu factures // Wrapping pour les images des societes
elseif ($modulepart == 'apercufacture') if ($modulepart == 'societe')
{ {
if ($user->rights->facture->lire) $accessallowed=1;
{ $original_file=$conf->societe->dir_output.'/'.$original_file;
$accessallowed=1; }
}
$original_file=$conf->facture->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu propal // Wrapping pour les apercu factures
elseif ($modulepart == 'apercupropal') elseif ($modulepart == 'apercufacture')
{ {
if ($user->rights->propale->lire) if ($user->rights->facture->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->propale->dir_output.'/'.$original_file; $original_file=$conf->facture->dir_output.'/'.$original_file;
} }
// Wrapping pour les apercu commande // Wrapping pour les apercu propal
elseif ($modulepart == 'apercucommande') elseif ($modulepart == 'apercupropal')
{ {
if ($user->rights->commande->lire) if ($user->rights->propale->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->commande->dir_output.'/'.$original_file; $original_file=$conf->propale->dir_output.'/'.$original_file;
} }
// Wrapping pour les apercu intervention // Wrapping pour les apercu commande
elseif ($modulepart == 'apercufichinter') elseif ($modulepart == 'apercucommande')
{ {
if ($user->rights->ficheinter->lire) if ($user->rights->commande->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->ficheinter->dir_output.'/'.$original_file; $original_file=$conf->commande->dir_output.'/'.$original_file;
} }
// Wrapping pour les images des stats propales // Wrapping pour les apercu intervention
elseif ($modulepart == 'propalstats') elseif ($modulepart == 'apercufichinter')
{ {
if ($user->rights->propale->lire) if ($user->rights->ficheinter->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->propale->dir_temp.'/'.$original_file; $original_file=$conf->ficheinter->dir_output.'/'.$original_file;
} }
// Wrapping pour les images des stats commandes // Wrapping pour les images des stats propales
elseif ($modulepart == 'orderstats') elseif ($modulepart == 'propalstats')
{ {
if ($user->rights->commande->lire) if ($user->rights->propale->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->commande->dir_temp.'/'.$original_file; $original_file=$conf->propale->dir_temp.'/'.$original_file;
} }
elseif ($modulepart == 'orderstatssupplier')
{
if ($user->rights->fournisseur->commande->lire)
{
$accessallowed=1;
}
$original_file=$conf->fournisseur->dir_output.'/commande/temp/'.$original_file;
}
// Wrapping pour les images des stats factures // Wrapping pour les images des stats commandes
elseif ($modulepart == 'billstats') elseif ($modulepart == 'orderstats')
{ {
if ($user->rights->facture->lire) if ($user->rights->commande->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->facture->dir_temp.'/'.$original_file; $original_file=$conf->commande->dir_temp.'/'.$original_file;
} }
elseif ($modulepart == 'billstatssupplier') elseif ($modulepart == 'orderstatssupplier')
{ {
if ($user->rights->fournisseur->facture->lire) if ($user->rights->fournisseur->commande->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->fournisseur->dir_output.'/facture/temp/'.$original_file; $original_file=$conf->fournisseur->dir_output.'/commande/temp/'.$original_file;
} }
// Wrapping pour les images des stats expeditions // Wrapping pour les images des stats factures
elseif ($modulepart == 'expeditionstats') elseif ($modulepart == 'billstats')
{ {
if ($user->rights->expedition->lire) if ($user->rights->facture->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->expedition->dir_temp.'/'.$original_file; $original_file=$conf->facture->dir_temp.'/'.$original_file;
} }
elseif ($modulepart == 'billstatssupplier')
{
if ($user->rights->fournisseur->facture->lire)
{
$accessallowed=1;
}
$original_file=$conf->fournisseur->dir_output.'/facture/temp/'.$original_file;
}
// Wrapping pour les images des stats expeditions // Wrapping pour les images des stats expeditions
elseif ($modulepart == 'tripsexpensesstats') elseif ($modulepart == 'expeditionstats')
{ {
if ($user->rights->deplacement->lire) if ($user->rights->expedition->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->deplacement->dir_temp.'/'.$original_file; $original_file=$conf->expedition->dir_temp.'/'.$original_file;
} }
// Wrapping pour les images des stats produits // Wrapping pour les images des stats expeditions
elseif (preg_match('/^productstats_/i',$modulepart)) elseif ($modulepart == 'tripsexpensesstats')
{ {
if ($user->rights->produit->lire || $user->rights->service->lire) if ($user->rights->deplacement->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=(!empty($conf->product->dir_temp)?$conf->product->dir_temp:$conf->service->dir_temp).'/'.$original_file; $original_file=$conf->deplacement->dir_temp.'/'.$original_file;
} }
// Wrapping for products or services // Wrapping pour les images des stats produits
elseif ($modulepart == 'product') elseif (preg_match('/^productstats_/i',$modulepart))
{ {
if ($user->rights->produit->lire || $user->rights->service->lire) if ($user->rights->produit->lire || $user->rights->service->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=(!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output).'/'.$original_file; $original_file=(!empty($conf->product->dir_temp)?$conf->product->dir_temp:$conf->service->dir_temp).'/'.$original_file;
} }
// Wrapping for categories // Wrapping for products or services
elseif ($modulepart == 'category') elseif ($modulepart == 'product')
{ {
if ($user->rights->categorie->lire) if ($user->rights->produit->lire || $user->rights->service->lire)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->categorie->dir_output.'/'.$original_file; $original_file=(!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output).'/'.$original_file;
} }
// Wrapping pour les prelevements // Wrapping for categories
elseif ($modulepart == 'prelevement') elseif ($modulepart == 'category')
{ {
if ($user->rights->prelevement->bons->lire) $accessallowed=1; if ($user->rights->categorie->lire)
{
$accessallowed=1;
}
$original_file=$conf->categorie->dir_output.'/'.$original_file;
}
$original_file=$conf->prelevement->dir_output.'/receipts/'.$original_file; // Wrapping pour les prelevements
} elseif ($modulepart == 'prelevement')
{
if ($user->rights->prelevement->bons->lire) $accessallowed=1;
// Wrapping pour les graph energie $original_file=$conf->prelevement->dir_output.'/receipts/'.$original_file;
elseif ($modulepart == 'graph_stock') }
{
$accessallowed=1;
$original_file=$conf->stock->dir_temp.'/'.$original_file;
}
// Wrapping pour les graph fournisseurs // Wrapping pour les graph energie
elseif ($modulepart == 'graph_fourn') elseif ($modulepart == 'graph_stock')
{ {
$accessallowed=1; $accessallowed=1;
$original_file=$conf->fournisseur->dir_temp.'/'.$original_file; $original_file=$conf->stock->dir_temp.'/'.$original_file;
} }
// Wrapping pour les graph des produits // Wrapping pour les graph fournisseurs
elseif ($modulepart == 'graph_product') elseif ($modulepart == 'graph_fourn')
{ {
$accessallowed=1; $accessallowed=1;
$original_file=$conf->product->dir_temp.'/'.$original_file; $original_file=$conf->fournisseur->dir_temp.'/'.$original_file;
} }
// Wrapping pour les code barre // Wrapping pour les graph des produits
elseif ($modulepart == 'barcode') elseif ($modulepart == 'graph_product')
{ {
$accessallowed=1; $accessallowed=1;
// If viewimage is called for barcode, we try to output an image on the fly, $original_file=$conf->product->dir_temp.'/'.$original_file;
// with not build of file on disk. }
//$original_file=$conf->barcode->dir_temp.'/'.$original_file;
$original_file=''; // Wrapping pour les code barre
} elseif ($modulepart == 'barcode')
{
$accessallowed=1;
// If viewimage is called for barcode, we try to output an image on the fly,
// with not build of file on disk.
//$original_file=$conf->barcode->dir_temp.'/'.$original_file;
$original_file='';
}
// Wrapping pour les icones de background des mailings // Wrapping pour les icones de background des mailings
elseif ($modulepart == 'iconmailing') elseif ($modulepart == 'iconmailing')
{ {
$accessallowed=1; $accessallowed=1;
$original_file=$conf->mailing->dir_temp.'/'.$original_file; $original_file=$conf->mailing->dir_temp.'/'.$original_file;
} }
// Wrapping pour les icones de background des mailings // Wrapping pour les icones de background des mailings
elseif ($modulepart == 'scanner_user_temp') elseif ($modulepart == 'scanner_user_temp')
@ -291,7 +298,7 @@ if ($modulepart)
$original_file=$conf->scanner->dir_temp.'/'.$user->id.'/'.$original_file; $original_file=$conf->scanner->dir_temp.'/'.$user->id.'/'.$original_file;
} }
// Wrapping pour les images fckeditor // Wrapping pour les images fckeditor
elseif ($modulepart == 'fckeditor') elseif ($modulepart == 'fckeditor')
{ {
$accessallowed=1; $accessallowed=1;
@ -299,50 +306,50 @@ if ($modulepart)
} }
// GENERIC Wrapping // GENERIC Wrapping
// If modulepart=module_user_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp/iduser // If modulepart=module_user_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp/iduser
// If modulepart=module_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp // If modulepart=module_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp
// If modulepart=module_user Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/iduser // If modulepart=module_user Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/iduser
// If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart // If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
else else
{ {
if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg)) if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
{ {
if ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read) $accessallowed=1; if ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read) $accessallowed=1;
$original_file=$conf->$reg[1]->dir_temp.'/'.$user->id.'/'.$original_file; $original_file=$conf->$reg[1]->dir_temp.'/'.$user->id.'/'.$original_file;
} }
else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
{ {
if ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read) $accessallowed=1; if ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read) $accessallowed=1;
$original_file=$conf->$reg[1]->dir_temp.'/'.$original_file; $original_file=$conf->$reg[1]->dir_temp.'/'.$original_file;
} }
else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
{ {
if ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read) $accessallowed=1; if ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read) $accessallowed=1;
$original_file=$conf->$reg[1]->dir_output.'/'.$user->id.'/'.$original_file; $original_file=$conf->$reg[1]->dir_output.'/'.$user->id.'/'.$original_file;
} }
else else
{ {
$perm=GETPOST('perm'); $perm=GETPOST('perm');
$subperm=GETPOST('subperm'); $subperm=GETPOST('subperm');
if ($perm || $subperm) if ($perm || $subperm)
{ {
if (($perm && $user->rights->$modulepart->$perm) || ($perm && $subperm && $user->rights->$modulepart->$perm->$subperm)) $accessallowed=1; if (($perm && $user->rights->$modulepart->$perm) || ($perm && $subperm && $user->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
$original_file=$conf->$modulepart->dir_output.'/'.$original_file; $original_file=$conf->$modulepart->dir_output.'/'.$original_file;
} }
else else
{ {
if ($user->rights->$modulepart->lire || $user->rights->$modulepart->read) $accessallowed=1; if ($user->rights->$modulepart->lire || $user->rights->$modulepart->read) $accessallowed=1;
$original_file=$conf->$modulepart->dir_output.'/'.$original_file; $original_file=$conf->$modulepart->dir_output.'/'.$original_file;
} }
} }
} }
} }
// Security: // Security:
// Limit access if permissions are wrong // Limit access if permissions are wrong
if (! $accessallowed) if (! $accessallowed)
{ {
accessforbidden(); accessforbidden();
} }
// Security: // Security:
@ -350,63 +357,63 @@ if (! $accessallowed)
// les noms de fichiers. // les noms de fichiers.
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
{ {
dol_syslog("Refused to deliver file ".$original_file, LOG_WARNING); dol_syslog("Refused to deliver file ".$original_file, LOG_WARNING);
// Do no show plain path in shown error message // Do no show plain path in shown error message
dol_print_error(0,'Error: File '.$_GET["file"].' does not exists'); dol_print_error(0,'Error: File '.$_GET["file"].' does not exists');
exit; exit;
} }
if ($modulepart == 'barcode') if ($modulepart == 'barcode')
{ {
$generator=$_GET["generator"]; $generator=$_GET["generator"];
$code=$_GET["code"]; $code=$_GET["code"];
$encoding=$_GET["encoding"]; $encoding=$_GET["encoding"];
$readable=$_GET["readable"]?$_GET["readable"]:"Y"; $readable=$_GET["readable"]?$_GET["readable"]:"Y";
// Output files with barcode generators // Output files with barcode generators
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir=$dirroot . "/includes/modules/barcode/"; $dir=$dirroot . "/includes/modules/barcode/";
$result=@include_once($dir.$generator.".modules.php"); $result=@include_once($dir.$generator.".modules.php");
if ($result) break; if ($result) break;
} }
// Chargement de la classe de codage // Chargement de la classe de codage
$classname = "mod".ucfirst($generator); $classname = "mod".ucfirst($generator);
$module = new $classname($db); $module = new $classname($db);
if ($module->encodingIsSupported($encoding)) if ($module->encodingIsSupported($encoding))
{ {
$result=$module->buildBarCode($code,$encoding,$readable); $result=$module->buildBarCode($code,$encoding,$readable);
} }
} }
else // Open and return file else // Open and return file
{ {
clearstatcache(); clearstatcache();
// Output files on browser // Output files on browser
dol_syslog("viewimage.php return file $original_file content-type=$type"); dol_syslog("viewimage.php return file $original_file content-type=$type");
$original_file_osencoded=dol_osencode($original_file); $original_file_osencoded=dol_osencode($original_file);
// This test if file exists should be useless. We keep it to find bug more easily // This test if file exists should be useless. We keep it to find bug more easily
if (! file_exists($original_file_osencoded)) if (! file_exists($original_file_osencoded))
{ {
dol_print_error(0,'Error: File '.$_GET["file"].' does not exists'); dol_print_error(0,'Error: File '.$_GET["file"].' does not exists');
exit; exit;
} }
// Les drois sont ok et fichier trouve // Les drois sont ok et fichier trouve
if ($type) if ($type)
{ {
header('Content-type: '.$type); header('Content-type: '.$type);
} }
else else
{ {
header('Content-type: image/png'); header('Content-type: image/png');
} }
readfile($original_file_osencoded); readfile($original_file_osencoded);
} }
?> ?>