From 7d5f0c3723adeec91998062c3e86e8e56890107b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Jun 2011 14:14:27 +0000 Subject: [PATCH] New: Can add logo on third parties. Qual: Uniformize code to show photos/logos. --- htdocs/adherents/fiche.php | 15 +- htdocs/comm/fiche.php | 8 +- htdocs/comm/prospect/fiche.php | 11 +- htdocs/core/class/html.form.class.php | 11 +- htdocs/core/class/html.formcompany.class.php | 8 +- htdocs/fourn/fiche.php | 10 +- .../install/mysql/migration/3.0.0-3.1.0.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 1 + htdocs/product/fiche.php | 2 +- htdocs/societe/agenda.php | 7 - htdocs/societe/class/societe.class.php | 7 +- htdocs/societe/soc.php | 2822 +++++++++-------- htdocs/user/fiche.php | 94 +- htdocs/viewimage.php | 535 ++-- 14 files changed, 1855 insertions(+), 1678 deletions(-) diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 8dc6235ebc4..6c6ccdb042b 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -1166,7 +1166,7 @@ if ($rowid && $action != 'edit') if ($ret == 'html') print '
'; } - $rowspan=18+sizeof($adho->attribute_label); + $rowspan=19+sizeof($adho->attribute_label); if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1; if ($conf->societe->enabled) $rowspan++; @@ -1178,18 +1178,21 @@ if ($rowid && $action != 'edit') print $html->showrefnav($adh,'rowid'); print ''; + $showphoto=''; + $showphoto.=$html->showphoto('memberphoto',$adh); + $showphoto.=''; + // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' / '.$langs->trans("Id").''.$adh->login.' '; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").''.$adh->login.' '; + print $showphoto; $showphoto=''; print ''; } // Morphy print ''.$langs->trans("Nature").''.$adh->getmorphylib().''; - print ''; - print $html->showphoto('memberphoto',$adh); - print ''; + print $showphoto; $showphoto=''; print ''; // Type @@ -1221,7 +1224,7 @@ if ($rowid && $action != 'edit') print ''; // Zip / Town - print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->zip.' '.$adh->town.''; + print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->zip.(($adh->zip && $adh->town)?' / ':'').$adh->town.''; // Country print ''.$langs->trans("Country").''; diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 2b183fb4926..0ee75bd2bc1 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -227,8 +227,8 @@ if ($socid > 0) print ""; // Zip / Town - print ''.$langs->trans('Zip').''.$objsoc->cp.""; - print ''.$langs->trans('Town').''.$objsoc->ville.""; + print ''.$langs->trans('Zip').' / '.$langs->trans('Town').''.$objsoc->cp.(($objsoc->cp && $objsoc->ville)?' / ':'').$objsoc->ville.""; + print ''; // Country print ''.$langs->trans("Country").''; @@ -238,10 +238,10 @@ if ($socid > 0) print ''; // Phone - print ''.$langs->trans('Phone').''.dol_print_phone($objsoc->tel,$objsoc->pays_code,0,$objsoc->id,'AC_TEL').''; + print ''.$langs->trans('Phone').''.dol_print_phone($objsoc->tel,$objsoc->pays_code,0,$objsoc->id,'AC_TEL').''; // Fax - print ''.$langs->trans('Fax').''.dol_print_phone($objsoc->fax,$objsoc->pays_code,0,$objsoc->id,'AC_FAX').''; + print ''.$langs->trans('Fax').''.dol_print_phone($objsoc->fax,$objsoc->pays_code,0,$objsoc->id,'AC_FAX').''; // EMail print ''.$langs->trans('EMail').''.dol_print_email($objsoc->email,0,$objsoc->id,'AC_EMAIL').''; diff --git a/htdocs/comm/prospect/fiche.php b/htdocs/comm/prospect/fiche.php index 4212611d21d..003590ae350 100644 --- a/htdocs/comm/prospect/fiche.php +++ b/htdocs/comm/prospect/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -99,7 +99,7 @@ if ($socid > 0) print ''; print ''; - print ''; @@ -110,8 +110,8 @@ if ($socid > 0) print ""; // Zip / Town - print ''; - print ''; + print ''; + print ''; // Country print ''; // Phone - print ''; + print ''; + print ''; // EMail print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 67499017d1d..37ec9e05e67 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3326,6 +3326,13 @@ class Form $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') { $dir=$conf->user->dir_output; @@ -3347,13 +3354,13 @@ class Form { $ret.='Photo'; } - else if (file_exists($dir."/".$altfile)) + else if ($altfile && file_exists($dir."/".$altfile)) { $ret.='Photo'; } else { - if ($conf->gravatar->enabled) + if ($conf->gravatar->enabled && $email) { global $dolibarr_main_url_root; $ret.=''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index c42a48aa044..a6f3476ce19 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -77,11 +77,9 @@ class FormCompany $objp = $this->db->fetch_object($resql); if (! $mode) $key=$objp->id; else $key=$objp->code; - - if ($langs->trans($objp->code) != $objp->code) - $effs[$key] = $langs->trans($objp->code); - else - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; + if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); + else $effs[$key] = $objp->libelle; + if ($effs[$key]=='-') $effs[$key]=''; $i++; } $this->db->free($resql); diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index dedc6097f81..4c63f7d99e5 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Eric Seigne - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 Juanjo Menent * @@ -125,8 +125,8 @@ if ( $societe->fetch($socid) ) print ''; // Zip / Town - print ''; - print ''; + print ''; + print ''; // Country print ''; // Phone - print ''; + print ''; // Fax - print ''; + print ''; // EMail print ''; diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index 15433786e65..23fa75e94f7 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -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_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 logo varchar(255); ALTER TABLE llx_societe_remise MODIFY remise_client double(6,3) DEFAULT 0 NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index a87d9da5eb7..eff6387abee 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -85,6 +85,7 @@ create table llx_societe gencod varchar(255), -- barcode price_level integer NULL, -- level of price for multiprices default_lang varchar(6), -- default language + logo varchar(255), canvas varchar(32), -- type of canvas if used (null by default) import_key varchar(14) -- import key )ENGINE=innodb; diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 9e35c4c352e..7908ed29d4f 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -1047,7 +1047,7 @@ if ($id || $ref) if ($isphoto) { // Photo - print ''; } diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index c45050b5e1d..bedc9d1e301 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -140,13 +140,6 @@ if ($_GET["socid"]) print dol_print_url($soc->url); print ''; - // Assujeti a TVA ou pas - print ''; - print ''; - print ''; - print '
'.$langs->trans("ThirdPartyName").''; + print '
'.$langs->trans("ThirdPartyName").''; $societe->next_prev_filter="te.client in (2,3)"; print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print '
'.$langs->trans('Zip').''.$societe->cp.''.$langs->trans('Town').''.$societe->ville.'
'.$langs->trans('Zip').' / '.$langs->trans("Town").''.$societe->cp.(($societe->cp && $societe->ville)?' / ':'').$societe->ville.'
'.$langs->trans("Country").''; @@ -121,7 +121,8 @@ if ($socid > 0) print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code).'
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code).'
'.$langs->trans('EMail').''.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'
'.$langs->trans("Zip").''.$societe->cp.''.$langs->trans("Town").''.$societe->ville.'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$societe->cp.(($societe->cp && $societe->ville)?' / ':'').$societe->ville.'
'.$langs->trans("Country").''; @@ -136,10 +136,10 @@ if ( $societe->fetch($socid) ) print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'
'.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'
'.$langs->trans('EMail').''.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'
'; + print ''; print $product->show_photos($conf->product->dir_output,1,1,0,0,0,80); print '
'.$langs->trans('VATIsUsed').''; - print yn($soc->tva_assuj); - print '
'; print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index b6717eec065..f8946035f5b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -488,7 +488,7 @@ class Societe extends CommonObject $sql .= ",fournisseur = " . ($this->fournisseur?$this->fournisseur:0); $sql .= ",gencod = ".($this->gencod?"'".$this->gencod."'":"null"); $sql .= ",default_lang = ".($this->default_lang?"'".$this->default_lang."'":"null"); - + $sql .= ",logo = ".($this->logo?"'".$this->logo."'":"null"); if ($allowmodcodeclient) { @@ -585,6 +585,7 @@ class Societe extends CommonObject 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 .= ', s.status'; $sql .= ', s.price_level'; $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'; @@ -595,9 +596,8 @@ class Societe extends CommonObject $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.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.status'; $sql .= ', fj.libelle as forme_juridique'; $sql .= ', e.libelle as effectif'; $sql .= ', p.code as pays_code, p.libelle as pays'; @@ -730,6 +730,7 @@ class Societe extends CommonObject $this->note = $obj->note; $this->default_lang = $obj->default_lang; + $this->logo = $obj->logo; // multiprix $this->price_level = $obj->price_level; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index c449d1c2ad3..5476e23f176 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -31,6 +31,8 @@ require("../main.inc.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.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); @@ -58,16 +60,16 @@ $canvas = (!empty($soc->canvas)?$soc->canvas:GETPOST("canvas")); if (! empty($canvas)) { - require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); - $objcanvas = new Canvas($db,$action); - $objcanvas->getCanvas('thirdparty','card',$canvas); - // Security check - $result = $objcanvas->restrictedArea($user, 'societe', $socid); + require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); + $objcanvas = new Canvas($db,$action); + $objcanvas->getCanvas('thirdparty','card',$canvas); + // Security check + $result = $objcanvas->restrictedArea($user, 'societe', $socid); } else { - // Security check - $result = restrictedArea($user, 'societe', $socid); + // Security check + $result = restrictedArea($user, 'societe', $socid); } $error=0; $errors=array(); @@ -81,10 +83,10 @@ $error=0; $errors=array(); // If canvas actions are not defined, we use standard feature. if (method_exists($objcanvas->control,'doActions')) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - $objcanvas->doActions($socid); + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + $objcanvas->doActions($socid); if (empty($objcanvas->error) && (empty($objcanvas->errors) || sizeof($objcanvas->errors) == 0)) { @@ -100,271 +102,345 @@ if (method_exists($objcanvas->control,'doActions')) } else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- - if ($_POST["getcustomercode"]) - { - // We defined value code_client - $_POST["code_client"]="Acompleter"; - } + if ($_POST["getcustomercode"]) + { + // We defined value code_client + $_POST["code_client"]="Acompleter"; + } - if ($_POST["getsuppliercode"]) - { - // We defined value code_fournisseur - $_POST["code_fournisseur"]="Acompleter"; - } + if ($_POST["getsuppliercode"]) + { + // We defined value code_fournisseur + $_POST["code_fournisseur"]="Acompleter"; + } - // Add new third party - if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) - && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) - { - require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); + // Add new third party + if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) + && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) + { + require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); - if ($action == 'update') - { - $soc->fetch($socid); - } + if ($action == 'update') + { + $soc->fetch($socid); + } else if ($canvas) $soc->canvas=$canvas; - if ($_REQUEST["private"] == 1) - { - $soc->particulier = $_REQUEST["private"]; + if ($_REQUEST["private"] == 1) + { + $soc->particulier = $_REQUEST["private"]; - $soc->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]); - $soc->nom = $soc->name; // TODO obsolete - $soc->nom_particulier = $_POST["nom"]; - $soc->prenom = $_POST["prenom"]; - $soc->civilite_id = $_POST["civilite_id"]; - } - else - { + $soc->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]); + $soc->nom = $soc->name; // TODO obsolete + $soc->nom_particulier = $_POST["nom"]; + $soc->prenom = $_POST["prenom"]; + $soc->civilite_id = $_POST["civilite_id"]; + } + else + { $soc->name = $_POST["nom"]; - $soc->nom = $soc->name; // TODO obsolete - } + $soc->nom = $soc->name; // TODO obsolete + } $soc->address = $_POST["adresse"]; - $soc->adresse = $_POST["adresse"]; // TODO obsolete + $soc->adresse = $_POST["adresse"]; // TODO obsolete $soc->zip = $_POST["zipcode"]; - $soc->cp = $_POST["zipcode"]; // TODO obsolete + $soc->cp = $_POST["zipcode"]; // TODO obsolete $soc->town = $_POST["town"]; $soc->ville = $_POST["town"]; // TODO obsolete $soc->pays_id = $_POST["pays_id"]; - $soc->departement_id = $_POST["departement_id"]; - $soc->tel = $_POST["tel"]; - $soc->fax = $_POST["fax"]; - $soc->email = trim($_POST["email"]); - $soc->url = $_POST["url"]; - $soc->siren = $_POST["idprof1"]; - $soc->siret = $_POST["idprof2"]; - $soc->ape = $_POST["idprof3"]; - $soc->idprof4 = $_POST["idprof4"]; - $soc->prefix_comm = $_POST["prefix_comm"]; - $soc->code_client = $_POST["code_client"]; - $soc->code_fournisseur = $_POST["code_fournisseur"]; - $soc->capital = $_POST["capital"]; - $soc->gencod = $_POST["gencod"]; + $soc->departement_id = $_POST["departement_id"]; + $soc->tel = $_POST["tel"]; + $soc->fax = $_POST["fax"]; + $soc->email = trim($_POST["email"]); + $soc->url = $_POST["url"]; + $soc->siren = $_POST["idprof1"]; + $soc->siret = $_POST["idprof2"]; + $soc->ape = $_POST["idprof3"]; + $soc->idprof4 = $_POST["idprof4"]; + $soc->prefix_comm = $_POST["prefix_comm"]; + $soc->code_client = $_POST["code_client"]; + $soc->code_fournisseur = $_POST["code_fournisseur"]; + $soc->capital = $_POST["capital"]; + $soc->gencod = $_POST["gencod"]; $soc->tva_intra = $_POST["tva_intra"]; - $soc->tva_assuj = $_POST["assujtva_value"]; + $soc->tva_assuj = $_POST["assujtva_value"]; $soc->status = $_POST["status"]; - // Local Taxes - $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; - $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; + // Local Taxes + $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; + $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; - $soc->forme_juridique_code = $_POST["forme_juridique_code"]; - $soc->effectif_id = $_POST["effectif_id"]; - if ($_REQUEST["private"] == 1) - { - $soc->typent_id = 8; // TODO predict another method if the field "special" change of rowid - } - else - { - $soc->typent_id = $_POST["typent_id"]; - } + $soc->forme_juridique_code = $_POST["forme_juridique_code"]; + $soc->effectif_id = $_POST["effectif_id"]; + if ($_REQUEST["private"] == 1) + { + $soc->typent_id = 8; // TODO predict another method if the field "special" change of rowid + } + else + { + $soc->typent_id = $_POST["typent_id"]; + } - $soc->client = $_POST["client"]; - $soc->fournisseur = $_POST["fournisseur"]; - $soc->fournisseur_categorie = $_POST["fournisseur_categorie"]; + $soc->client = $_POST["client"]; + $soc->fournisseur = $_POST["fournisseur"]; + $soc->fournisseur_categorie = $_POST["fournisseur_categorie"]; - $soc->commercial_id = $_POST["commercial_id"]; - $soc->default_lang = $_POST["default_lang"]; + $soc->commercial_id = $_POST["commercial_id"]; + $soc->default_lang = $_POST["default_lang"]; - // Check parameters - if (empty($_POST["cancel"])) - { - if (! empty($soc->email) && ! isValidEMail($soc->email)) - { - $langs->load("errors"); - $error++; $errors[] = $langs->trans("ErrorBadEMail",$soc->email); - $action = ($action=='add'?'create':'edit'); - } - if (! empty($soc->url) && ! isValidUrl($soc->url)) - { - $langs->load("errors"); + $soc->logo = dol_sanitizeFileName($_FILES['logo']['name']); + + // Check parameters + if (empty($_POST["cancel"])) + { + if (! empty($soc->email) && ! isValidEMail($soc->email)) + { + $langs->load("errors"); + $error++; $errors[] = $langs->trans("ErrorBadEMail",$soc->email); + $action = ($action=='add'?'create':'edit'); + } + if (! empty($soc->url) && ! isValidUrl($soc->url)) + { + $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadUrl",$soc->url); - $action = ($action=='add'?'create':'edit'); - } - if ($soc->fournisseur && ! $conf->fournisseur->enabled) - { - $langs->load("errors"); + $action = ($action=='add'?'create':'edit'); + } + if ($soc->fournisseur && ! $conf->fournisseur->enabled) + { + $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled"); - $action = ($action=='add'?'create':'edit'); - } - } + $action = ($action=='add'?'create':'edit'); + } + } - if (! $error) - { - if ($action == 'add') - { - $db->begin(); + if (! $error) + { + if ($action == 'add') + { + $db->begin(); - if (empty($soc->client)) $soc->code_client=''; - if (empty($soc->fournisseur)) $soc->code_fournisseur=''; + if (empty($soc->client)) $soc->code_client=''; + if (empty($soc->fournisseur)) $soc->code_fournisseur=''; - $result = $soc->create($user); - if ($result >= 0) - { - if ($soc->particulier) - { - dol_syslog("This thirdparty is a personal people",LOG_DEBUG); - $contact=new Contact($db); + $result = $soc->create($user); + if ($result >= 0) + { + if ($soc->particulier) + { + dol_syslog("This thirdparty is a personal people",LOG_DEBUG); + $contact=new Contact($db); - $contact->civilite_id = $soc->civilite_id; - $contact->name=$soc->nom_particulier; - $contact->firstname=$soc->prenom; - $contact->address=$soc->address; - $contact->zip=$soc->zip; + $contact->civilite_id = $soc->civilite_id; + $contact->name=$soc->nom_particulier; + $contact->firstname=$soc->prenom; + $contact->address=$soc->address; + $contact->zip=$soc->zip; $contact->cp=$soc->cp; - $contact->town=$soc->town; + $contact->town=$soc->town; $contact->ville=$soc->ville; $contact->fk_pays=$soc->fk_pays; - $contact->socid=$soc->id; // fk_soc - $contact->status=1; - $contact->email=$soc->email; - $contact->priv=0; + $contact->socid=$soc->id; // fk_soc + $contact->status=1; + $contact->email=$soc->email; + $contact->priv=0; - $result=$contact->create($user); - } - } - else - { - $error=$soc->error; $errors=$soc->errors; - } + $result=$contact->create($user); + if (! $result >= 0) + { + $error=$contact->error; $errors=$contact->errors; + } + } - if ($result >= 0) - { - $db->commit(); + ### 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 + { + $error=$soc->error; $errors=$soc->errors; + } + + if ($result >= 0) + { + $db->commit(); $url=$_SERVER["PHP_SELF"]."?socid=".$soc->id; - if (($soc->client == 1 || $soc->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id; - else if ($soc->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id; - Header("Location: ".$url); - exit; - } - else - { - $db->rollback(); + if (($soc->client == 1 || $soc->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id; + else if ($soc->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id; + Header("Location: ".$url); + exit; + } + else + { + $db->rollback(); + $action='create'; + } + } - $langs->load("errors"); - $error=$langs->trans($soc->error); - $action='create'; - } - } + if ($action == 'update') + { + if ($_POST["cancel"]) + { + Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); + exit; + } - if ($action == 'update') - { - if ($_POST["cancel"]) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); - exit; - } + $oldsoc=new Societe($db); + $result=$oldsoc->fetch($socid); - $oldsoc=new Societe($db); - $result=$oldsoc->fetch($socid); - - // To not set code if third party is not concerned. But if it had values, we keep them. - if (empty($soc->client) && empty($oldsoc->code_client)) $soc->code_client=''; - if (empty($soc->fournisseur)&& empty($oldsoc->code_fournisseur)) $soc->code_fournisseur=''; + // To not set code if third party is not concerned. But if it had values, we keep them. + if (empty($soc->client) && empty($oldsoc->code_client)) $soc->code_client=''; + if (empty($soc->fournisseur)&& empty($oldsoc->code_fournisseur)) $soc->code_fournisseur=''; //var_dump($soc);exit; - $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable()); - if ($result >= 0) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); - exit; - } - else - { - $soc->id = $socid; - $error = $langs->trans($soc->error); $errors = $soc->errors; - $action= "edit"; - } - } - } - } + $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable()); + if ($result < 0) + { + $error = $soc->error; $errors = $soc->errors; + } - // Delete third party - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) - { - $soc->fetch($socid); - $result = $soc->delete($socid); + ### 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 ($result >= 0) - { - Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$soc->nom.""); - exit; - } - else - { - $langs->load("errors"); - $error=$langs->trans($soc->error); $errors = $soc->errors; - $action=''; - } - } + 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) + { + + Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); + exit; + } + else + { + $soc->id = $socid; + $action= "edit"; + } + } + } + } + + // Delete third party + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) + { + $soc->fetch($socid); + $result = $soc->delete($socid); + + if ($result >= 0) + { + Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$soc->nom.""); + exit; + } + else + { + $langs->load("errors"); + $error=$langs->trans($soc->error); $errors = $soc->errors; + $action=''; + } + } - /* - * Generate document - */ - if ($action == 'builddoc') // En get ou en post - { - if (is_numeric(GETPOST('model'))) - { - $error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); - } - else - { - require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php'); + /* + * Generate document + */ + if ($action == 'builddoc') // En get ou en post + { + if (is_numeric(GETPOST('model'))) + { + $error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); + } + else + { + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php'); - $soc = new Societe($db); - $soc->fetch($socid); - $soc->fetch_thirdparty(); + $soc = new Societe($db); + $soc->fetch($socid); + $soc->fetch_thirdparty(); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - else - { - Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; - } - } - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } + } + } } @@ -385,30 +461,30 @@ $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("Se if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - if ($action == 'create') - { + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if ($action == 'create') + { $objcanvas->assign_post(); // Assign POST data $objcanvas->assign_values($action); // Set value for templates $objcanvas->display_canvas($action); // Show template - } - elseif ($action == 'edit') - { - $objcanvas->control->object=$objcanvas->getObject($socid); // Load object - if (empty($objcanvas->control->object)) - { + } + elseif ($action == 'edit') + { + $objcanvas->control->object=$objcanvas->getObject($socid); // Load object + if (empty($objcanvas->control->object)) + { $object = new Societe($db); $object->fetch($socid); - $objcanvas->control->object=$object; - } - $objcanvas->assign_post(); // Assign POST data - $objcanvas->assign_values($action); // Set value for templates - $objcanvas->display_canvas($action); // Show template - } - else - { + $objcanvas->control->object=$object; + } + $objcanvas->assign_post(); // Assign POST data + $objcanvas->assign_values($action); // Set value for templates + $objcanvas->display_canvas($action); // Show template + } + else + { $objcanvas->control->object=$objcanvas->getObject($socid); // Load object if (empty($objcanvas->control->object)) { @@ -417,112 +493,147 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $objcanvas->control->object=$object; } $objcanvas->assign_values('view'); // Assign values - $objcanvas->display_canvas('view'); // Show template - } + $objcanvas->display_canvas('view'); // Show template + } } else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- - if ($action == 'create') - { - /* - * Creation - */ + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- + if ($action == 'create') + { + /* + * Creation + */ - // Load object modCodeTiers - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeClient = new $module; - $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; - if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeFournisseur = new $module; + // Load object modCodeTiers + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeClient = new $module; + $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; + if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeFournisseur = new $module; //if ($_GET["type"]=='cp') { $soc->client=3; } if (GETPOST("type")!='f') $soc->client=3; - if (GETPOST("type")=='c') { $soc->client=1; } + if (GETPOST("type")=='c') { $soc->client=1; } if (GETPOST("type")=='p') { $soc->client=2; } if ($conf->fournisseur->enabled && (GETPOST("type")=='f' || GETPOST("type")=='')) { $soc->fournisseur=1; } if (GETPOST("private")==1) { $soc->particulier=1; } - $soc->nom=$_POST["nom"]; - $soc->prenom=$_POST["prenom"]; - $soc->particulier=$_REQUEST["private"]; - $soc->prefix_comm=$_POST["prefix_comm"]; - $soc->client=$_POST["client"]?$_POST["client"]:$soc->client; - $soc->code_client=$_POST["code_client"]; - $soc->fournisseur=$_POST["fournisseur"]?$_POST["fournisseur"]:$soc->fournisseur; - $soc->code_fournisseur=$_POST["code_fournisseur"]; - $soc->adresse=$_POST["adresse"]; // TODO obsolete - $soc->address=$_POST["adresse"]; - $soc->cp=$_POST["zipcode"]; - $soc->ville=$_POST["town"]; - $soc->departement_id=$_POST["departement_id"]; - $soc->tel=$_POST["tel"]; - $soc->fax=$_POST["fax"]; - $soc->email=$_POST["email"]; - $soc->url=$_POST["url"]; - $soc->capital=$_POST["capital"]; - $soc->gencod=$_POST["gencod"]; - $soc->siren=$_POST["idprof1"]; - $soc->siret=$_POST["idprof2"]; - $soc->ape=$_POST["idprof3"]; - $soc->idprof4=$_POST["idprof4"]; - $soc->typent_id=$_POST["typent_id"]; - $soc->effectif_id=$_POST["effectif_id"]; + $soc->nom=$_POST["nom"]; + $soc->prenom=$_POST["prenom"]; + $soc->particulier=$_REQUEST["private"]; + $soc->prefix_comm=$_POST["prefix_comm"]; + $soc->client=$_POST["client"]?$_POST["client"]:$soc->client; + $soc->code_client=$_POST["code_client"]; + $soc->fournisseur=$_POST["fournisseur"]?$_POST["fournisseur"]:$soc->fournisseur; + $soc->code_fournisseur=$_POST["code_fournisseur"]; + $soc->adresse=$_POST["adresse"]; // TODO obsolete + $soc->address=$_POST["adresse"]; + $soc->cp=$_POST["zipcode"]; + $soc->ville=$_POST["town"]; + $soc->departement_id=$_POST["departement_id"]; + $soc->tel=$_POST["tel"]; + $soc->fax=$_POST["fax"]; + $soc->email=$_POST["email"]; + $soc->url=$_POST["url"]; + $soc->capital=$_POST["capital"]; + $soc->gencod=$_POST["gencod"]; + $soc->siren=$_POST["idprof1"]; + $soc->siret=$_POST["idprof2"]; + $soc->ape=$_POST["idprof3"]; + $soc->idprof4=$_POST["idprof4"]; + $soc->typent_id=$_POST["typent_id"]; + $soc->effectif_id=$_POST["effectif_id"]; - $soc->tva_assuj = $_POST["assujtva_value"]; + $soc->tva_assuj = $_POST["assujtva_value"]; $soc->status= $_POST["status"]; - //Local Taxes - $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; - $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; + //Local Taxes + $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; + $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; - $soc->tva_intra=$_POST["tva_intra"]; + $soc->tva_intra=$_POST["tva_intra"]; - $soc->commercial_id=$_POST["commercial_id"]; - $soc->default_lang=$_POST["default_lang"]; + $soc->commercial_id=$_POST["commercial_id"]; + $soc->default_lang=$_POST["default_lang"]; - // We set pays_id, pays_code and label for the selected country - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; - if ($soc->pays_id) - { - $sql = "SELECT code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; - $sql.= " WHERE rowid = ".$soc->pays_id; - $resql=$db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - } - else - { - dol_print_error($db); - } - $soc->pays_code=$obj->code; - $soc->pays=$obj->libelle; - } + $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 + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; + if ($soc->pays_id) + { + $sql = "SELECT code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; + $sql.= " WHERE rowid = ".$soc->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $soc->pays_code=$obj->code; + $soc->pays=$obj->libelle; + } $soc->forme_juridique_code=$_POST['forme_juridique_code']; - /* Show create form */ + /* Show create form */ - print_fiche_titre($langs->trans("NewCompany")); + print_fiche_titre($langs->trans("NewCompany")); - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; + print ''."\n"; - print "
\n"; - print $langs->trans("ThirdPartyType").':   '; - print ' '.$langs->trans("Company/Fundation"); - print '     '; - print ' '.$langs->trans("Individual"); - print ' ('.$langs->trans("ToCreateContactWithSameName").')'; - print "
\n"; - print "
\n"; - } + print "
\n"; + print $langs->trans("ThirdPartyType").':   '; + print ' '.$langs->trans("Company/Fundation"); + print '     '; + print ' '.$langs->trans("Individual"); + print ' ('.$langs->trans("ToCreateContactWithSameName").')'; + print "
\n"; + print "
\n"; + } - dol_htmloutput_errors($error,$errors); + dol_htmloutput_errors($error,$errors); - print '
'; + print ''; - print ''; - print ''; - print ''; - print ''; - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; + print ''; + print ''; + print ''; + print ''; + if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; - print ''; + print '
'; - // Name, firstname - if ($soc->particulier) - { - print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; + // Name, firstname + if ($soc->particulier) + { + print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } - print ''; - } - else - { - print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; + print ''; + } + else + { + print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } - print ''; - } - // If javascript on, we show option individual - if ($conf->use_javascript_ajax) - { - print ''; - print ''; - print ''; - print ''; - } + print ''; + } + // If javascript on, we show option individual + if ($conf->use_javascript_ajax) + { + print ''; + print ''; + print ''; + print ''; + } - // Prospect/Customer - print ''; + // Prospect/Customer + print ''; - print ''; + print ''; - if ($conf->fournisseur->enabled) - { - // Supplier - print ''; - print ''; - print ''; + if ($conf->fournisseur->enabled) + { + // Supplier + print ''; + print ''; + print ''; - // Category - if ($soc->fournisseur) - { - $load = $soc->LoadSupplierCateg(); - if ( $load == 0) - { - if (sizeof($soc->SupplierCategories) > 0) - { - print ''; - print ''; - } - } - } - } + // Category + if ($soc->fournisseur) + { + $load = $soc->LoadSupplierCateg(); + if ( $load == 0) + { + if (sizeof($soc->SupplierCategories) > 0) + { + print ''; + print ''; + } + } + } + } // Status print ''; // Barcode - if ($conf->global->MAIN_MODULE_BARCODE) - { - print ''; - } + if ($conf->global->MAIN_MODULE_BARCODE) + { + print ''; + } - // Address - print ''; + // Address + print ''; - // Zip / Town - print ''; + // Zip / Town + print ''; - // Country - print ''; + // Country + print ''; - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) - { - print ''; - } + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + print ''; + } - // Phone / Fax - print ''; - print ''; + // Phone / Fax + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print ''; - // IdProf1 (SIREN for France) - $idprof=$langs->transcountry('ProfId1',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - // IdProf2 (SIRET for France) - $idprof=$langs->transcountry('ProfId2',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - print ''; - print ''; - // IdProf3 (APE for France) - $idprof=$langs->transcountry('ProfId3',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - // IdProf4 (NU for France) - $idprof=$langs->transcountry('ProfId4',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - print ''; + print ''; + // IdProf1 (SIREN for France) + $idprof=$langs->transcountry('ProfId1',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + // IdProf2 (SIRET for France) + $idprof=$langs->transcountry('ProfId2',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + print ''; + print ''; + // IdProf3 (APE for France) + $idprof=$langs->transcountry('ProfId3',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + // IdProf4 (NU for France) + $idprof=$langs->transcountry('ProfId4',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + print ''; - // Legal Form - print ''; - print ''; + // Legal Form + print ''; + print ''; - // Type - print ''; - print ''; + // Type + print ''; + print ''; - if ($conf->global->MAIN_MULTILANGS) - { - print ''; - print ''; - } + if ($conf->global->MAIN_MULTILANGS) + { + print ''; + print ''; + } - // Assujeti TVA - $html = new Form($db); - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print $s; + print ''; - print ''; + print ''; - // Local Taxes - // TODO add specific function by country - if($mysoc->pays_code=='ES') - { - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") - { - print ''; + // Local Taxes + // TODO add specific function by country + if($mysoc->pays_code=='ES') + { + if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + { + print ''; - } - elseif($mysoc->localtax1_assuj=="1") - { - print ''; - } - elseif($mysoc->localtax2_assuj=="1") - { - print ''; - } - } + } + elseif($mysoc->localtax1_assuj=="1") + { + print ''; + } + elseif($mysoc->localtax2_assuj=="1") + { + print ''; + } + } - if ($user->rights->societe->client->voir) - { - // Assign a Name - print ''; - print ''; - print ''; - } + if ($user->rights->societe->client->voir) + { + // Assign a Name + print ''; + print ''; + print ''; + } + // Ajout du logo + print ''; + print ''; + print ''; + print ''; + print ''."\n"; - print ''."\n"; + print '
'.$langs->trans('LastName').'
'.$langs->trans('LastName').''.$langs->trans('Prefix').'
'.$langs->trans('ThirdPartyName').'
'.$langs->trans('ThirdPartyName').''.$langs->trans('Prefix').'
'.$langs->trans('FirstName').' 
'.$langs->trans("UserTitle").''; - print $formcompany->select_civilite($contact->civilite_id).' 
'.$langs->trans('FirstName').' 
'.$langs->trans("UserTitle").''; + print $formcompany->select_civilite($contact->civilite_id).' 
'.$langs->trans('ProspectCustomer').'
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; - print '
'; - $tmpcode=$soc->code_client; - if ($modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); - print ''; - print ''; - $s=$modCodeClient->getToolTip($langs,$soc,0); - print $form->textwithpicto('',$s,1); - print '
'; + print '
'.$langs->trans('CustomerCode').''; + print '
'; + $tmpcode=$soc->code_client; + if ($modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); + print ''; + print ''; + $s=$modCodeClient->getToolTip($langs,$soc,0); + print $form->textwithpicto('',$s,1); + print '
'; - print '
'.$langs->trans('Supplier').''; - print $form->selectyesno("fournisseur",$soc->fournisseur,1); - print ''.$langs->trans('SupplierCode').''; - print '
'; - $tmpcode=$soc->code_fournisseur; - if ($modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); - print ''; - print ''; - $s=$modCodeFournisseur->getToolTip($langs,$soc,1); - print $form->textwithpicto('',$s,1); - print '
'; - print '
'.$langs->trans('Supplier').''; + print $form->selectyesno("fournisseur",$soc->fournisseur,1); + print ''.$langs->trans('SupplierCode').''; + print '
'; + $tmpcode=$soc->code_fournisseur; + if ($modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); + print ''; + print ''; + $s=$modCodeFournisseur->getToolTip($langs,$soc,1); + print $form->textwithpicto('',$s,1); + print '
'; + print '
'.$langs->trans('SupplierCategory').''; - print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1); - print '
'.$langs->trans('SupplierCategory').''; + print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1); + print '
'.$langs->trans('Status').''; @@ -665,952 +776,1001 @@ else print '
'.$langs->trans('Gencod').''; - print $soc->gencod; - print '
'.$langs->trans('Gencod').''; + print $soc->gencod; + print '
'.$langs->trans('Address').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; - print $formcompany->select_ziptown($soc->cp,'zipcode',array('town','selectpays_id','departement_id'),6); - print ''.$langs->trans('Town').''; - print $formcompany->select_ziptown($soc->ville,'town',array('zipcode','selectpays_id','departement_id')); - print '
'.$langs->trans('Zip').''; + print $formcompany->select_ziptown($soc->cp,'zipcode',array('town','selectpays_id','departement_id'),6); + print ''.$langs->trans('Town').''; + print $formcompany->select_ziptown($soc->ville,'town',array('zipcode','selectpays_id','departement_id')); + print '
'.$langs->trans('Country').''; - $form->select_pays($soc->pays_id,'pays_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans('Country').''; + $form->select_pays($soc->pays_id,'pays_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; - if ($soc->pays_id) - { - $formcompany->select_departement($soc->departement_id,$soc->pays_code); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans('State').''; + if ($soc->pays_id) + { + $formcompany->select_departement($soc->departement_id,$soc->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.$idprof.''; - print $formcompany->get_input_id_prof(1,'idprof1',$soc->siren,$soc->pays_code); - print '  '.$idprof.''; - print $formcompany->get_input_id_prof(2,'idprof2',$soc->siret,$soc->pays_code); - print '  
'.$idprof.''; - print $formcompany->get_input_id_prof(3,'idprof3',$soc->ape,$soc->pays_code); - print '  '.$idprof.''; - print $formcompany->get_input_id_prof(4,'idprof4',$soc->idprof4,$soc->pays_code); - print '  
'.$idprof.''; + print $formcompany->get_input_id_prof(1,'idprof1',$soc->siren,$soc->pays_code); + print '  '.$idprof.''; + print $formcompany->get_input_id_prof(2,'idprof2',$soc->siret,$soc->pays_code); + print '  
'.$idprof.''; + print $formcompany->get_input_id_prof(3,'idprof3',$soc->ape,$soc->pays_code); + print '  '.$idprof.''; + print $formcompany->get_input_id_prof(4,'idprof4',$soc->idprof4,$soc->pays_code); + print '  
'.$langs->trans('JuridicalStatus').''; - if ($soc->pays_id) - { - $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans('JuridicalStatus').''; + if ($soc->pays_id) + { + $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("ThirdPartyType").''."\n"; - print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print ''.$langs->trans("Staff").''; - print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans("ThirdPartyType").''."\n"; + print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print ''.$langs->trans("Staff").''; + print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans("DefaultLang").''."\n"; - print $formadmin->select_language(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); - print '
'.$langs->trans("DefaultLang").''."\n"; + print $formadmin->select_language(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); + print '
'.$langs->trans('VATIsUsed').''; - print $html->selectyesno('assujtva_value',1,1); // Assujeti par defaut en creation - print ''.$langs->trans('VATIntra').''; - $s = ''; + // Assujeti TVA + $html = new Form($db); + print '
'.$langs->trans('VATIsUsed').''; + print $html->selectyesno('assujtva_value',1,1); // Assujeti par defaut en creation + print ''.$langs->trans('VATIntra').''; + $s = ''; - if (empty($conf->global->MAIN_DISABLEVATCHECK)) - { - $s.=' '; + if (empty($conf->global->MAIN_DISABLEVATCHECK)) + { + $s.=' '; - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''; - print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; - $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - } + if ($conf->use_javascript_ajax) + { + print "\n"; + print ''; + print "\n"; + $s.=''.$langs->trans("VATIntraCheck").''; + $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + } - print $s; - print '
'.$langs->trans("LocalTax1IsUsedES").''; - print $html->selectyesno('localtax1assuj_value',0,1); - print ''.$langs->trans("LocalTax2IsUsedES").''; - print $html->selectyesno('localtax2assuj_value',0,1); - print '
'.$langs->trans("LocalTax1IsUsedES").''; + print $html->selectyesno('localtax1assuj_value',0,1); + print ''.$langs->trans("LocalTax2IsUsedES").''; + print $html->selectyesno('localtax2assuj_value',0,1); + print '
'.$langs->trans("LocalTax1IsUsedES").''; - print $html->selectyesno('localtax1assuj_value',0,1); - print '
'.$langs->trans("LocalTax2IsUsedES").''; - print $html->selectyesno('localtax2assuj_value',0,1); - print '
'.$langs->trans("LocalTax1IsUsedES").''; + print $html->selectyesno('localtax1assuj_value',0,1); + print '
'.$langs->trans("LocalTax2IsUsedES").''; + print $html->selectyesno('localtax2assuj_value',0,1); + print '
'.$langs->trans("AllocateCommercial").''; - $form->select_users($soc->commercial_id,'commercial_id',1); - print '
'.$langs->trans("AllocateCommercial").''; + $form->select_users($soc->commercial_id,'commercial_id',1); + print '
'.$langs->trans("Logo").''; + print ''; + print '
'; + print ''; + print '
'; - print ''; - print '
'."\n"; + print '
'."\n"; + } + elseif ($action == 'edit') + { + /* + * Edition + */ + print_fiche_titre($langs->trans("EditCompany")); - print ''."\n"; - print ''."\n"; - } - elseif ($action == 'edit') - { - /* - * Edition - */ - print_fiche_titre($langs->trans("EditCompany")); + if ($socid) + { + // Load object modCodeTiers + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeClient = new $module; + // We verified if the tag prefix is used + if ($modCodeClient->code_auto) + { + $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); + } + $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; + if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeFournisseur = new $module; + // On verifie si la balise prefix est utilisee + if ($modCodeFournisseur->code_auto) + { + $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); + } - if ($socid) - { - // Load object modCodeTiers - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeClient = new $module; - // We verified if the tag prefix is used - if ($modCodeClient->code_auto) - { - $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); - } - $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; - if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeFournisseur = new $module; - // On verifie si la balise prefix est utilisee - if ($modCodeFournisseur->code_auto) - { - $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); - } + if (! $_POST["nom"]) + { + $soc = new Societe($db); + $soc->fetch($socid); + } + else + { + $soc->id=$_POST["socid"]; + $soc->nom=$_POST["nom"]; + $soc->prefix_comm=$_POST["prefix_comm"]; + $soc->client=$_POST["client"]; + $soc->code_client=$_POST["code_client"]; + $soc->fournisseur=$_POST["fournisseur"]; + $soc->code_fournisseur=$_POST["code_fournisseur"]; + $soc->adresse=$_POST["adresse"]; // TODO obsolete + $soc->address=$_POST["adresse"]; + $soc->cp=$_POST["zipcode"]; + $soc->ville=$_POST["town"]; + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; + $soc->departement_id=$_POST["departement_id"]; + $soc->tel=$_POST["tel"]; + $soc->fax=$_POST["fax"]; + $soc->email=$_POST["email"]; + $soc->url=$_POST["url"]; + $soc->capital=$_POST["capital"]; + $soc->siren=$_POST["idprof1"]; + $soc->siret=$_POST["idprof2"]; + $soc->ape=$_POST["idprof3"]; + $soc->idprof4=$_POST["idprof4"]; + $soc->typent_id=$_POST["typent_id"]; + $soc->effectif_id=$_POST["effectif_id"]; + $soc->gencod=$_POST["gencod"]; + $soc->forme_juridique_code=$_POST["forme_juridique_code"]; + $soc->default_lang=$_POST["default_lang"]; - if (! $_POST["nom"]) - { - $soc = new Societe($db); - $soc->fetch($socid); - } - else - { - $soc->id=$_POST["socid"]; - $soc->nom=$_POST["nom"]; - $soc->prefix_comm=$_POST["prefix_comm"]; - $soc->client=$_POST["client"]; - $soc->code_client=$_POST["code_client"]; - $soc->fournisseur=$_POST["fournisseur"]; - $soc->code_fournisseur=$_POST["code_fournisseur"]; - $soc->adresse=$_POST["adresse"]; // TODO obsolete - $soc->address=$_POST["adresse"]; - $soc->cp=$_POST["zipcode"]; - $soc->ville=$_POST["town"]; - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; - $soc->departement_id=$_POST["departement_id"]; - $soc->tel=$_POST["tel"]; - $soc->fax=$_POST["fax"]; - $soc->email=$_POST["email"]; - $soc->url=$_POST["url"]; - $soc->capital=$_POST["capital"]; - $soc->siren=$_POST["idprof1"]; - $soc->siret=$_POST["idprof2"]; - $soc->ape=$_POST["idprof3"]; - $soc->idprof4=$_POST["idprof4"]; - $soc->typent_id=$_POST["typent_id"]; - $soc->effectif_id=$_POST["effectif_id"]; - $soc->gencod=$_POST["gencod"]; - $soc->forme_juridique_code=$_POST["forme_juridique_code"]; - $soc->default_lang=$_POST["default_lang"]; - - $soc->tva_assuj = $_POST["assujtva_value"]; - $soc->tva_intra=$_POST["tva_intra"]; + $soc->tva_assuj = $_POST["assujtva_value"]; + $soc->tva_intra=$_POST["tva_intra"]; $soc->status=$_POST["status"]; - //Local Taxes - $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; - $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; + //Local Taxes + $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; + $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; - // We set pays_id, and pays_code label of the chosen country - if ($soc->pays_id) - { - $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; - $resql=$db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - } - else - { - dol_print_error($db); - } - $soc->pays_code=$obj->code; - $soc->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; - } - } + // We set pays_id, and pays_code label of the chosen country + if ($soc->pays_id) + { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $soc->pays_code=$obj->code; + $soc->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + } + } - dol_htmloutput_errors($error,$errors); + dol_htmloutput_errors($error,$errors); - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - } + print ''."\n"; + } - print '
'; - print ''; - print ''; - print ''; - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; + print ''; + print ''; + print ''; + print ''; + if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; - print ''; + print '
'; - // Name - print ''; + // Name + print ''; - // Prefix + // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; + // It does not change the prefix mode using the auto numbering prefix + if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $soc->prefix_comm) + { + print ''; + print $soc->prefix_comm; + } + else + { + print ''; + } + print ''; } - // Prospect/Customer - print ''; - print ''; + print ''; + print ''; - // Supplier - if ($conf->fournisseur->enabled) - { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - // Category - if ($conf->categorie->enabled && $soc->fournisseur) - { - $load = $soc->LoadSupplierCateg(); - if ( $load == 0) - { - if (sizeof($soc->SupplierCategories) > 0) - { - print ''; - print ''; - } - } - } - } + // Category + if ($conf->categorie->enabled && $soc->fournisseur) + { + $load = $soc->LoadSupplierCateg(); + if ( $load == 0) + { + if (sizeof($soc->SupplierCategories) > 0) + { + print ''; + print ''; + } + } + } + } - // Status - print ''; // Barcode - if ($conf->global->MAIN_MODULE_BARCODE) - { - print ''; - } + if ($conf->global->MAIN_MODULE_BARCODE) + { + print ''; + } - // Address - print ''; + // Address + print ''; - // Zip / Town - print ''; + // Zip / Town + print ''; - // Country - print ''; + // Country + print ''; - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) - { - print ''; - } + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + print ''; + } - // Phone / Fax - print ''; - print ''; + // Phone / Fax + print ''; + print ''; - // EMail / Web - print ''; - print ''; + // EMail / Web + print ''; + print ''; - print ''; - // IdProf1 (SIREN for France) - $idprof=$langs->transcountry('ProfId1',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - // IdProf2 (SIRET for France) - $idprof=$langs->transcountry('ProfId2',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - print ''; - print ''; - // IdProf3 (APE for France) - $idprof=$langs->transcountry('ProfId3',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - // IdProf4 (NU for France) - $idprof=$langs->transcountry('ProfId4',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - print ''; + print ''; + // IdProf1 (SIREN for France) + $idprof=$langs->transcountry('ProfId1',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + // IdProf2 (SIRET for France) + $idprof=$langs->transcountry('ProfId2',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + print ''; + print ''; + // IdProf3 (APE for France) + $idprof=$langs->transcountry('ProfId3',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + // IdProf4 (NU for France) + $idprof=$langs->transcountry('ProfId4',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + print ''; - // VAT payers - print ''; + // VAT payers + print ''; - // VAT Code - print ''; - print ''; + print ''; - print ''; + print ''; + print ''; - // Local Taxes - // TODO add specific function by country - if($mysoc->pays_code=='ES') - { - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") - { - print ''; + // Local Taxes + // TODO add specific function by country + if($mysoc->pays_code=='ES') + { + if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + { + print ''; - } - elseif($mysoc->localtax1_assuj=="1") - { - print ''; + } + elseif($mysoc->localtax1_assuj=="1") + { + print ''; - } - elseif($mysoc->localtax2_assuj=="1") - { - print ''; - } - } + } + elseif($mysoc->localtax2_assuj=="1") + { + print ''; + } + } - print ''; + print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - if ($conf->global->MAIN_MULTILANGS) - { - print ''; - print ''; - } + // Default language + if ($conf->global->MAIN_MULTILANGS) + { + print ''; + print ''; + } - print '
'.$langs->trans('ThirdPartyName').'
'.$langs->trans('ThirdPartyName').'
'.$langs->trans("Prefix").''; - // It does not change the prefix mode using the auto numbering prefix - if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $soc->prefix_comm) - { - print ''; - print $soc->prefix_comm; - } - else - { - print ''; - } - print '
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; + // Prospect/Customer + print '
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; - print '
'; - if ((!$soc->code_client || $soc->code_client == -1) && $modCodeClient->code_auto) - { - $tmpcode=$soc->code_client; - if (empty($tmpcode) && $modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); - print ''; - } - else if ($soc->codeclient_modifiable()) - { - print ''; - } - else - { - print $soc->code_client; - print ''; - } - print ''; - $s=$modCodeClient->getToolTip($langs,$soc,0); - print $form->textwithpicto('',$s,1); - print '
'; + print '
'; + if ((!$soc->code_client || $soc->code_client == -1) && $modCodeClient->code_auto) + { + $tmpcode=$soc->code_client; + if (empty($tmpcode) && $modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); + print ''; + } + else if ($soc->codeclient_modifiable()) + { + print ''; + } + else + { + print $soc->code_client; + print ''; + } + print ''; + $s=$modCodeClient->getToolTip($langs,$soc,0); + print $form->textwithpicto('',$s,1); + print '
'; - print '
'.$langs->trans('Supplier').''; - print $form->selectyesno("fournisseur",$soc->fournisseur,1); - print ''.$langs->trans('SupplierCode').''; + // Supplier + if ($conf->fournisseur->enabled) + { + print '
'.$langs->trans('Supplier').''; + print $form->selectyesno("fournisseur",$soc->fournisseur,1); + print ''.$langs->trans('SupplierCode').''; - print '
'; - if ((!$soc->code_fournisseur || $soc->code_fournisseur == -1) && $modCodeFournisseur->code_auto) - { - $tmpcode=$soc->code_fournisseur; - if (empty($tmpcode) && $modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); - print ''; - } - else if ($soc->codefournisseur_modifiable()) - { - print ''; - } - else - { - print $soc->code_fournisseur; - print ''; - } - print ''; - $s=$modCodeFournisseur->getToolTip($langs,$soc,1); - print $form->textwithpicto('',$s,1); - print '
'; + print '
'; + if ((!$soc->code_fournisseur || $soc->code_fournisseur == -1) && $modCodeFournisseur->code_auto) + { + $tmpcode=$soc->code_fournisseur; + if (empty($tmpcode) && $modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); + print ''; + } + else if ($soc->codefournisseur_modifiable()) + { + print ''; + } + else + { + print $soc->code_fournisseur; + print ''; + } + print ''; + $s=$modCodeFournisseur->getToolTip($langs,$soc,1); + print $form->textwithpicto('',$s,1); + print '
'; - print '
'.$langs->trans('SupplierCategory').''; - print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,'',1); - print '
'.$langs->trans('SupplierCategory').''; + print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,'',1); + print '
'.$langs->trans("Status").''; + // Status + print '
'.$langs->trans("Status").''; print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$soc->status); print '
'.$langs->trans('Gencod').''; - print '
'.$langs->trans('Gencod').''; + print '
'.$langs->trans('Address').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; - print $formcompany->select_ziptown($soc->cp,'zipcode',array('town','selectpays_id','departement_id'),6); - print ''.$langs->trans('Town').''; - print $formcompany->select_ziptown($soc->ville,'town',array('zipcode','selectpays_id','departement_id')); - print '
'.$langs->trans('Zip').''; + print $formcompany->select_ziptown($soc->cp,'zipcode',array('town','selectpays_id','departement_id'),6); + print ''.$langs->trans('Town').''; + print $formcompany->select_ziptown($soc->ville,'town',array('zipcode','selectpays_id','departement_id')); + print '
'.$langs->trans('Country').''; - $form->select_pays($soc->pays_id,'pays_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans('Country').''; + $form->select_pays($soc->pays_id,'pays_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; - $formcompany->select_departement($soc->departement_id,$soc->pays_code); - print '
'.$langs->trans('State').''; + $formcompany->select_departement($soc->departement_id,$soc->pays_code); + print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$idprof.''; - print $formcompany->get_input_id_prof(1,'idprof1',$soc->siren,$soc->pays_code); - print '  '.$idprof.''; - print $formcompany->get_input_id_prof(2,'idprof2',$soc->siret,$soc->pays_code); - print '  
'.$idprof.''; - print $formcompany->get_input_id_prof(3,'idprof3',$soc->ape,$soc->pays_code); - print '  '.$idprof.''; - print $formcompany->get_input_id_prof(4,'idprof4',$soc->idprof4,$soc->pays_code); - print '  
'.$idprof.''; + print $formcompany->get_input_id_prof(1,'idprof1',$soc->siren,$soc->pays_code); + print '  '.$idprof.''; + print $formcompany->get_input_id_prof(2,'idprof2',$soc->siret,$soc->pays_code); + print '  
'.$idprof.''; + print $formcompany->get_input_id_prof(3,'idprof3',$soc->ape,$soc->pays_code); + print '  '.$idprof.''; + print $formcompany->get_input_id_prof(4,'idprof4',$soc->idprof4,$soc->pays_code); + print '  
'.$langs->trans('VATIsUsed').''; - print $form->selectyesno('assujtva_value',$soc->tva_assuj,1); - print '
'.$langs->trans('VATIsUsed').''; + print $form->selectyesno('assujtva_value',$soc->tva_assuj,1); + print ''.$langs->trans('VATIntra').''; - $s =''; + // VAT Code + print ''.$langs->trans('VATIntra').''; + $s =''; - if (empty($conf->global->MAIN_DISABLEVATCHECK)) - { - $s.='   '; + if (empty($conf->global->MAIN_DISABLEVATCHECK)) + { + $s.='   '; - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''; - print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; - $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - } + if ($conf->use_javascript_ajax) + { + print "\n"; + print ''; + print "\n"; + $s.=''.$langs->trans("VATIntraCheck").''; + $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + } - print $s; + print $s; - print '
'.$langs->trans("LocalTax1IsUsedES").''; - print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); - print ''.$langs->trans("LocalTax2IsUsedES").''; - print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); - print '
'.$langs->trans("LocalTax1IsUsedES").''; + print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); + print ''.$langs->trans("LocalTax2IsUsedES").''; + print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); + print '
'.$langs->trans("LocalTax1IsUsedES").''; - print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); - print '
'.$langs->trans("LocalTax1IsUsedES").''; + print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); + print '
'.$langs->trans("LocalTax2IsUsedES").''; - print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); - print '
'.$langs->trans("LocalTax2IsUsedES").''; + print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); + print '
'.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('JuridicalStatus').''; - $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); - print '
'.$langs->trans('JuridicalStatus').''; + $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + print '
'.$langs->trans("ThirdPartyType").''; - print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print ''.$langs->trans("Staff").''; - print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans("ThirdPartyType").''; + print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print ''.$langs->trans("Staff").''; + print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans("DefaultLang").''."\n"; - print $formadmin->select_language($soc->default_lang,'default_lang',0,0,1); - print '
'.$langs->trans("DefaultLang").''."\n"; + print $formadmin->select_language($soc->default_lang,'default_lang',0,0,1); + print '
'; - print '
'; + // Logo + print ''; + print ''.$langs->trans("Logo").''; + print ''; + print ''; - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print ''; + print '
'; - print '
'; - } - } - else - { - /* - * View - */ - $soc = new Societe($db); - $result=$soc->fetch($socid); - if ($result < 0) - { - dol_print_error($db,$soc->error); - exit; - } + print '
'; + print ''; + print '     '; + print ''; + print '
'; - $head = societe_prepare_head($soc); + print ''; + } + } + else + { + /* + * View + */ + $soc = new Societe($db); + $result=$soc->fetch($socid); + if ($result < 0) + { + dol_print_error($db,$soc->error); + exit; + } - dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); + $head = societe_prepare_head($soc); - $html = new Form($db); + dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); + + $html = new Form($db); - // Confirm delete third party - if ($action == 'delete' || $conf->use_javascript_ajax) - { - $html = new Form($db); - $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,"action-delete"); - if ($ret == 'html') print '
'; - } + // Confirm delete third party + if ($action == 'delete' || $conf->use_javascript_ajax) + { + $html = new Form($db); + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,"action-delete"); + if ($ret == 'html') print '
'; + } - dol_htmloutput_errors($error,$errors); + dol_htmloutput_errors($error,$errors); - print ''; + print '
'; - // Name - print ''; - print ''; + // Ref + /* + print ''; + print ''; + print ''; + */ + + // Name + print ''; + print ''; + print ''; + + // 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.=''; + } if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print ''; + print ''; + print $showlogo; $showlogo=''; + print ''; } - if ($soc->client) - { - print ''; - } + if ($soc->client) + { + print ''; + print $showlogo; $showlogo=''; + print ''; + } - if ($conf->fournisseur->enabled && $soc->fournisseur) - { - print ''; - } + if ($conf->fournisseur->enabled && $soc->fournisseur) + { + print ''; + print $showlogo; $showlogo=''; + print ''; + } - // Status - print ''; - print ''; + print ''; + print $showlogo; $showlogo=''; + print ''; + + // Barcode + if ($conf->global->MAIN_MODULE_BARCODE) + { + print ''; + } + + // Address + print ""; + + // Zip / Town + print '"; + print ''; + + // Country + print ''; - // Barcode - if ($conf->global->MAIN_MODULE_BARCODE) - { - print ''; - } + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) print ''; - // Address - print ""; + print ''; + print ''; - print '"; - print '"; + // EMail + print ''; - // Country - print ''; + // Web + print ''; - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) print ''; + // ProfId1 (SIREN for France) + $profid=$langs->transcountry('ProfId1',$soc->pays_code); + if ($profid!='-') + { + print ''; + } + else print ''; + // ProfId2 (SIRET for France) + $profid=$langs->transcountry('ProfId2',$soc->pays_code); + if ($profid!='-') + { + print ''; + } + else print ''; - print ''; - print ''; + // ProfId3 (APE for France) + $profid=$langs->transcountry('ProfId3',$soc->pays_code); + if ($profid!='-') + { + print ''; + } + else print ''; + // ProfId4 (NU for France) + $profid=$langs->transcountry('ProfId4',$soc->pays_code); + if ($profid!='-') + { + print ''; + } + else print ''; - // EMail - print ''; + // VAT payers + $html = new Form($db); + print ''; - // Web - print ''; + // VAT Code + print ''; - } - else print ''; - // ProfId2 (SIRET for France) - $profid=$langs->transcountry('ProfId2',$soc->pays_code); - if ($profid!='-') - { - print ''; - } - else print ''; + if (empty($conf->global->MAIN_DISABLEVATCHECK)) + { + $s.='   '; - // ProfId3 (APE for France) - $profid=$langs->transcountry('ProfId3',$soc->pays_code); - if ($profid!='-') - { - print ''; - } - else print ''; - // ProfId4 (NU for France) - $profid=$langs->transcountry('ProfId4',$soc->pays_code); - if ($profid!='-') - { - print ''; - } - else print ''; + if ($conf->use_javascript_ajax) + { + print "\n"; + print ''; + print "\n"; + $s.=''.$langs->trans("VATIntraCheck").''; + $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + } + print $s; + } + else + { + print ' '; + } + print ''; - // VAT payers - $html = new Form($db); - print ''; + print ''; - // VAT Code - print ''; - if (empty($conf->global->MAIN_DISABLEVATCHECK)) - { - $s.='   '; + } + elseif($mysoc->localtax1_assuj=="1") + { + print ''; + } + elseif($mysoc->localtax2_assuj=="1") + { + print ''; + } + } - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''; - print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; - $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - } - print $s; - } - else - { - print ' '; - } - print ''; + // Capital + print ''; - print ''; + // Legal + print ''; - // Local Taxes - // TODO add specific function by country - if($mysoc->pays_code=='ES') - { - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") - { - print ''; + // Type + Staff + $arr = $formcompany->typent_array(1); + $soc->typent= $arr[$soc->typent_code]; + print ''; - } - elseif($mysoc->localtax1_assuj=="1") - { - print ''; - } - elseif($mysoc->localtax2_assuj=="1") - { - print ''; - } - } + // Default language + if ($conf->global->MAIN_MULTILANGS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); + print ''; + } - // Capital - print ''; + // Ban + if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) + { + print ''; + print ''; + } - // Legal - print ''; + // Parent company + if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) + { + print ''; + print ''; + } - // Type + Staff - $arr = $formcompany->typent_array(1); - $soc->typent= $arr[$soc->typent_code]; - print ''; + // Commercial + print ''; + print ''; - } - - // Ban - if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) - { - print ''; - print ''; - } - - // Parent company - if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) - { - print ''; - print ''; - } - - // Commercial - print ''; - print ''; + } + else print $langs->trans("NoSalesRepresentativeAffected"); + print ''; - // Module Adherent - if ($conf->adherent->enabled) - { - $langs->load("members"); - print ''; - print ''; - print "\n"; - } + // Module Adherent + if ($conf->adherent->enabled) + { + $langs->load("members"); + print ''; + print ''; + print "\n"; + } - print '
'.$langs->trans('ThirdPartyName').''; - print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); - print '
'.$langs->trans("Ref").''; + print $fuser->id; + print '
'.$langs->trans('ThirdPartyName').''; + print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); + print '
'; + $showlogo.=$html->showphoto('societe',$soc,50); + $showlogo.='
'.$langs->trans('Prefix').''.$soc->prefix_comm.'
'.$langs->trans('Prefix').''.$soc->prefix_comm.'
'; - print $langs->trans('CustomerCode').''; - print $soc->code_client; - if ($soc->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; - print '
'; + print $langs->trans('CustomerCode').''; + print $soc->code_client; + if ($soc->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print '
'; - print $langs->trans('SupplierCode').''; - print $soc->code_fournisseur; - if ($soc->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; - print '
'; + print $langs->trans('SupplierCode').''; + print $soc->code_fournisseur; + if ($soc->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print '
'.$langs->trans("Status").''; + // Status + print '
'.$langs->trans("Status").''; print $soc->getLibStatut(2); + print '
'.$langs->trans('Gencod').''.$soc->gencod.'
".$langs->trans('Address').''; + dol_print_address($soc->address,'gmap','thirdparty',$soc->id); + print "
'.$langs->trans('Zip').' / '.$langs->trans("Town").''; + print $soc->cp.($soc->cp && $soc->ville?" / ":"").$soc->ville; + print "
'.$langs->trans("Country").''; + $img=picto_from_langcode($soc->pays_code); + if ($soc->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$soc->pays,$langs->trans("CountryIsInEEC"),1,0); + else print ($img?$img.' ':'').$soc->pays; print '
'.$langs->trans('Gencod').''.$soc->gencod.'
'.$langs->trans('State').''.$soc->departement.'
".$langs->trans('Address').""; - dol_print_address($soc->address,'gmap','thirdparty',$soc->id); - print "
'.$langs->trans('Phone').''.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id,'AC_TEL').''.$langs->trans('Fax').''.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id,'AC_FAX').'
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans('EMail').''; + print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL'); + print '
'.$langs->trans("Country").''; - $img=picto_from_langcode($soc->pays_code); - if ($soc->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$soc->pays,$langs->trans("CountryIsInEEC"),1,0); - else print ($img?$img.' ':'').$soc->pays; - print '
'.$langs->trans('Web').''; + print dol_print_url($soc->url); + print '
'.$langs->trans('State').''.$soc->departement.'
'.$profid.''; + print $soc->siren; + if ($soc->siren) + { + if ($soc->id_prof_check(1,$soc) > 0) print '   '.$soc->id_prof_url(1,$soc); + else print ' ('.$langs->trans("ErrorWrongValue").')'; + } + print '
  '.$profid.''; + print $soc->siret; + if ($soc->siret) + { + if ($soc->id_prof_check(2,$soc) > 0) print '   '.$soc->id_prof_url(2,$soc); + else print ' ('.$langs->trans("ErrorWrongValue").')'; + } + print '
  
'.$langs->trans('Phone').''.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id,'AC_TEL').''.$langs->trans('Fax').''.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id,'AC_FAX').'
'.$profid.''; + print $soc->ape; + if ($soc->ape) + { + if ($soc->id_prof_check(3,$soc) > 0) print '   '.$soc->id_prof_url(3,$soc); + else print ' ('.$langs->trans("ErrorWrongValue").')'; + } + print '
  '.$profid.''; + print $soc->idprof4; + if ($soc->idprof4) + { + if ($soc->id_prof_check(4,$soc) > 0) print '   '.$soc->id_prof_url(4,$soc); + else print ' ('.$langs->trans("ErrorWrongValue").')'; + } + print '
  
'.$langs->trans('EMail').''; - print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL'); - print '
'; + print $langs->trans('VATIsUsed'); + print ''; + print yn($soc->tva_assuj); + print ''.$langs->trans('Web').''; - print dol_print_url($soc->url); - print '
'.$langs->trans('VATIntra').''; + if ($soc->tva_intra) + { + $s=''; + $s.=$soc->tva_intra; + $s.=''; - // ProfId1 (SIREN for France) - $profid=$langs->transcountry('ProfId1',$soc->pays_code); - if ($profid!='-') - { - print '
'.$profid.''; - print $soc->siren; - if ($soc->siren) - { - if ($soc->id_prof_check(1,$soc) > 0) print '   '.$soc->id_prof_url(1,$soc); - else print ' ('.$langs->trans("ErrorWrongValue").')'; - } - print '
  '.$profid.''; - print $soc->siret; - if ($soc->siret) - { - if ($soc->id_prof_check(2,$soc) > 0) print '   '.$soc->id_prof_url(2,$soc); - else print ' ('.$langs->trans("ErrorWrongValue").')'; - } - print '
  
'.$profid.''; - print $soc->ape; - if ($soc->ape) - { - if ($soc->id_prof_check(3,$soc) > 0) print '   '.$soc->id_prof_url(3,$soc); - else print ' ('.$langs->trans("ErrorWrongValue").')'; - } - print '
  '.$profid.''; - print $soc->idprof4; - if ($soc->idprof4) - { - if ($soc->id_prof_check(4,$soc) > 0) print '   '.$soc->id_prof_url(4,$soc); - else print ' ('.$langs->trans("ErrorWrongValue").')'; - } - print '
  
'; - print $langs->trans('VATIsUsed'); - print ''; - print yn($soc->tva_assuj); - print '
'.$langs->trans('VATIntra').''; - if ($soc->tva_intra) - { - $s=''; - $s.=$soc->tva_intra; - $s.=''; + // Local Taxes + // TODO add specific function by country + if($mysoc->pays_code=='ES') + { + if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + { + print '
'.$langs->trans("LocalTax1IsUsedES").''; + print yn($soc->localtax1_assuj); + print ''.$langs->trans("LocalTax2IsUsedES").''; + print yn($soc->localtax2_assuj); + print '
'.$langs->trans("LocalTax1IsUsedES").''; + print yn($soc->localtax1_assuj); + print '
'.$langs->trans("LocalTax2IsUsedES").''; + print yn($soc->localtax2_assuj); + print '
'.$langs->trans('Capital').''; + if ($soc->capital) print $soc->capital.' '.$langs->trans("Currency".$conf->monnaie); + else print ' '; + print '
'.$langs->trans('JuridicalStatus').''.$soc->forme_juridique.'
'.$langs->trans("LocalTax1IsUsedES").''; - print yn($soc->localtax1_assuj); - print ''.$langs->trans("LocalTax2IsUsedES").''; - print yn($soc->localtax2_assuj); - print '
'.$langs->trans("ThirdPartyType").''.$soc->typent.''.$langs->trans("Staff").''.$soc->effectif.'
'.$langs->trans("LocalTax1IsUsedES").''; - print yn($soc->localtax1_assuj); - print '
'.$langs->trans("LocalTax2IsUsedES").''; - print yn($soc->localtax2_assuj); - print '
'.$langs->trans("DefaultLang").''; + //$s=picto_from_langcode($soc->default_lang); + //print ($s?$s.' ':''); + $langs->load("languages"); + $labellang = ($soc->default_lang?$langs->trans('Language_'.$soc->default_lang):''); + print $labellang; + print '
'.$langs->trans('Capital').''; - if ($soc->capital) print $soc->capital.' '.$langs->trans("Currency".$conf->monnaie); - else print ' '; - print '
'; + print '
'; + print $langs->trans('RIB'); + print ''; + if ($user->rights->societe->creer) + print ''.img_edit().''; + else + print ' '; + print '
'; + print '
'; + print $soc->display_rib(); + print '
'.$langs->trans('JuridicalStatus').''.$soc->forme_juridique.'
'; + print '
'; + print $langs->trans('ParentCompany'); + print ''; + if ($user->rights->societe->creer) + print ''.img_edit() .''; + else + print ' '; + print '
'; + print '
'; + if ($soc->parent) + { + $socm = new Societe($db); + $socm->fetch($soc->parent); + print $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); + print $socm->ville?' - '.$socm->ville:''; + } + else { + print $langs->trans("NoParentCompany"); + } + print '
'.$langs->trans("ThirdPartyType").''.$soc->typent.''.$langs->trans("Staff").''.$soc->effectif.'
'; + print '
'; + print $langs->trans('SalesRepresentatives'); + print ''; + if ($user->rights->societe->creer) + print ''.img_edit().''; + else + print ' '; + print '
'; + print '
'; - // Default language - if ($conf->global->MAIN_MULTILANGS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); - print '
'.$langs->trans("DefaultLang").''; - //$s=picto_from_langcode($soc->default_lang); - //print ($s?$s.' ':''); - $langs->load("languages"); - $labellang = ($soc->default_lang?$langs->trans('Language_'.$soc->default_lang):''); - print $labellang; - print '
'; - print '
'; - print $langs->trans('RIB'); - print ''; - if ($user->rights->societe->creer) - print ''.img_edit().''; - else - print ' '; - print '
'; - print '
'; - print $soc->display_rib(); - print '
'; - print '
'; - print $langs->trans('ParentCompany'); - print ''; - if ($user->rights->societe->creer) - print ''.img_edit() .''; - else - print ' '; - print '
'; - print '
'; - if ($soc->parent) - { - $socm = new Societe($db); - $socm->fetch($soc->parent); - print $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); - print $socm->ville?' - '.$socm->ville:''; - } - else { - print $langs->trans("NoParentCompany"); - } - print '
'; - print '
'; - print $langs->trans('SalesRepresentatives'); - print ''; - if ($user->rights->societe->creer) - print ''.img_edit().''; - else - print ' '; - print '
'; - print '
'; - - $listsalesrepresentatives=$soc->getSalesRepresentatives($user); - $nbofsalesrepresentative=sizeof($listsalesrepresentatives); + $listsalesrepresentatives=$soc->getSalesRepresentatives($user); + $nbofsalesrepresentative=sizeof($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number - { + { print ''; print $nbofsalesrepresentative; print ''; - } - else if ($nbofsalesrepresentative > 0) - { - $userstatic=new User($db); - $i=0; + } + else if ($nbofsalesrepresentative > 0) + { + $userstatic=new User($db); + $i=0; foreach($listsalesrepresentatives as $val) { $userstatic->id=$val['id']; @@ -1620,106 +1780,106 @@ else $i++; if ($i < $nbofsalesrepresentative) print ', '; } - } - else print $langs->trans("NoSalesRepresentativeAffected"); - print '
'.$langs->trans("LinkedToDolibarrMember").''; - $adh=new Adherent($db); - $result=$adh->fetch('','',$soc->id); - if ($result > 0) - { - $adh->ref=$adh->getFullName($langs); - print $adh->getNomUrl(1); - } - else - { - print $langs->trans("UserNotLinkedToMember"); - } - print '
'.$langs->trans("LinkedToDolibarrMember").''; + $adh=new Adherent($db); + $result=$adh->fetch('','',$soc->id); + if ($result > 0) + { + $adh->ref=$adh->getFullName($langs); + print $adh->getNomUrl(1); + } + else + { + print $langs->trans("UserNotLinkedToMember"); + } + print '
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); - /* - * Actions - */ - print '
'."\n"; + /* + * Actions + */ + print '
'."\n"; - if ($user->rights->societe->creer) - { - print ''.$langs->trans("Modify").''."\n"; - } + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Modify").''."\n"; + } - if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans("AddContact").''."\n"; - } + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans("AddContact").''."\n"; + } - if ($conf->projet->enabled && $user->rights->projet->creer) - { - print ''.$langs->trans("AddProject").''."\n"; - } + if ($conf->projet->enabled && $user->rights->projet->creer) + { + print ''.$langs->trans("AddProject").''."\n"; + } - if ($user->rights->societe->supprimer) - { - if ($conf->use_javascript_ajax) - { - print ''.$langs->trans('Delete').''."\n"; - } - else - { - print ''.$langs->trans('Delete').''."\n"; - } - } + if ($user->rights->societe->supprimer) + { + if ($conf->use_javascript_ajax) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } - print '
'."\n"; - print '
'; + print '
'."\n"; + print '
'; - print ''; + print ''; + print ''; + print '
'; - print ''; // ancre + print ''; - print ''; - print ''; - print '
'; + print ''; // ancre - /* - * Documents generes - */ - $filedir=$conf->societe->dir_output.'/'.$soc->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$soc->id; - $genallowed=$user->rights->societe->creer; - $delallowed=$user->rights->societe->supprimer; + /* + * Documents generes + */ + $filedir=$conf->societe->dir_output.'/'.$soc->id; + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$soc->id; + $genallowed=$user->rights->societe->creer; + $delallowed=$user->rights->societe->supprimer; - $var=true; + $var=true; - $somethingshown=$formfile->show_documents('company',$soc->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$soc->default_lang); + $somethingshown=$formfile->show_documents('company',$soc->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$soc->default_lang); - print ''; - print '
'; + print '
'; + print '
'; - print '
'; + print '
'; - // Subsidiaries list - $result=show_subsidiaries($conf,$langs,$db,$soc); + // Subsidiaries list + $result=show_subsidiaries($conf,$langs,$db,$soc); - // Contacts list - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $result=show_contacts($conf,$langs,$db,$soc); - } + // Contacts list + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $result=show_contacts($conf,$langs,$db,$soc); + } - // Projects list - $result=show_projects($conf,$langs,$db,$soc); - } + // Projects list + $result=show_projects($conf,$langs,$db,$soc); + } } diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index c6c13d54a93..ed2b95961ba 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -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); if ($ret == 'html') print '
'; } - + dol_htmloutput_errors($message); /* @@ -911,22 +911,28 @@ else print ''; print ''."\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 print ''.$langs->trans("Lastname").''; - print ''.$fuser->nom.''; + print ''.$fuser->nom.''; + + // Photo + print ''; + print $html->showphoto('userphoto',$fuser,100); + print ''; + print ''."\n"; // Firstname print ''.$langs->trans("Firstname").''; - print ''.$fuser->prenom.''; + print ''.$fuser->prenom.''; print ''."\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 print ''.$langs->trans("Login").''; if ($fuser->ldap_sid && $fuser->statut==0) @@ -937,10 +943,6 @@ else { print ''.$fuser->login.''; } - // Photo - print ''; - print $html->showphoto('userphoto',$fuser,100,1); - print ''; print ''."\n"; // Password @@ -1204,10 +1206,10 @@ else // On selectionne les groupes auquel fait parti le user $exclude = array(); - + $usergroup=new UserGroup($db); $groupslist = $usergroup->listGroupsForUser($fuser->id); - + if (! empty($groupslist)) { foreach($groupslist as $groupforuser) @@ -1246,7 +1248,7 @@ else if (! empty($groupslist)) { $var=true; - + foreach($groupslist as $group) { $var=!$var; @@ -1300,11 +1302,11 @@ else print ''; print ''; - $rowspan=9; - if ($conf->societe->enabled) $rowspan++; - if ($conf->adherent->enabled) $rowspan++; - if ($conf->webcalendar->enabled) $rowspan++; - if ($conf->phenix->enabled) $rowspan+=2; + $rowspan=11; + if ($conf->societe->enabled) $rowspan++; + if ($conf->adherent->enabled) $rowspan++; + if ($conf->webcalendar->enabled) $rowspan++; + if ($conf->phenix->enabled) $rowspan+=2; print ''; print ''; print ''; - // Nom - print "".''; - print '"; + print ''; + print ''; + print ''; + // Photo + print ''; + print ''; - // Prenom + // Firstname print "".''; - print ''; - - // Photo - print ''; print ''; // Pass @@ -1401,9 +1404,11 @@ else else { print '\n"; } - print '
'.$langs->trans("Ref").''; @@ -1312,9 +1314,10 @@ else print '
'.$langs->trans("Lastname").''; + // Lastname + print "
'.$langs->trans("Lastname").''; if ($caneditfield && !$fuser->ldap_sid) { print ''; @@ -1324,11 +1327,23 @@ else print ''; print $fuser->nom; } - print '
'; + print $html->showphoto('userphoto',$fuser); + if ($caneditfield) + { + print '

'; + print '
'.$langs->trans("PhotoFile").'
'; + print ''; + print '
'; + } + print '
'.$langs->trans("Firstname").''; + print ''; if ($caneditfield && !$fuser->ldap_sid) { print ''; @@ -1353,18 +1368,6 @@ else print $fuser->login; } print ''; - print $html->showphoto('userphoto',$fuser); - if ($caneditfield) - { - print '

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