* Copyright (C) 2004-2008 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * \file htdocs/admin/company.php * \ingroup company * \brief Page d'accueil de l'espace administration/configuration * \version $Id$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); $langs->load("admin"); $langs->load("companies"); if (!$user->admin) accessforbidden(); if ( (isset($_POST["action"]) && $_POST["action"] == 'update') || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VILLE",$_POST["ville"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_CP",$_POST["cp"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS",$_POST["pays_id"]); dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL",$_POST["tel"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX",$_POST["fax"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL",$_POST["mail"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB",$_POST["web"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE",$_POST["note"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD",$_POST["gencod"]); if ($_FILES["logo"]["tmp_name"]) { if (eregi('([^\\\/:]+)$',$_FILES["logo"]["name"],$reg)) { $original_file=$reg[1]; $isimage=image_format_supported($original_file); if ($isimage >= 0) { dolibarr_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".$conf->societe->dir_logos.'/'.$original_file); if (! is_dir($conf->societe->dir_logos)) { create_exdir($conf->societe->dir_logos); } if (dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->societe->dir_logos.'/'.$original_file,1) > 0) { dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file); // Create thumbs of logo if ($isimage > 0) { $quality = 80; $imgThumbSmall = vignette($conf->societe->dir_logos.'/'.$original_file, 200, 100, '_small', $quality); if (eregi('([^\\\/:]+)$',$imgThumbSmall,$reg)) { $imgThumbSmall = $reg[1]; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall); } else dolibarr_syslog($imgThumbSmall); // Création de la vignette de la page "Société/Institution" $imgThumbMini = vignette($conf->societe->dir_logos.'/'.$original_file, 100, 30, '_mini', $quality); if (eregi('([^\\\/:]+)$',$imgThumbMini,$reg)) { $imgThumbMini = $reg[1]; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini); } else dolibarr_syslog($imgThumbMini); } else dolibarr_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING); } else { $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; } } else { $message .= '
'.$langs->trans("ErrorOnlyPngJpgSupported").'
'; } } } dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE",$_POST["forme_juridique_code"]); dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"]); dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"]); dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"]); dolibarr_set_const($db, "MAIN_INFO_RCS",$_POST["rcs"]); dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"]); dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START",$_POST["fiscalmonthstart"]); dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"]); if ($_POST['action'] != 'updateedit' && ! $message) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } } if ($_GET["action"] == 'addthumb') { if (file_exists($conf->societe->dir_logos.'/'.$_GET["file"])) { $isimage=image_format_supported($_GET["file"]); // Create thumbs of logo if ($isimage > 0) { // Création de la vignette de la page login $imgThumbSmall = vignette($conf->societe->dir_logos.'/'.$_GET["file"], 200, 100, '_small',80); if (image_format_supported($imgThumbSmall) >= 0 && eregi('([^\\\/:]+)$',$imgThumbSmall,$reg)) { $imgThumbSmall = $reg[1]; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall); } else dolibarr_syslog($imgThumbSmall); // Création de la vignette de la page "Société/Institution" $imgThumbMini = vignette($conf->societe->dir_logos.'/'.$_GET["file"], 100, 30, '_mini',80); if (image_format_supported($imgThumbSmall) >= 0 && eregi('([^\\\/:]+)$',$imgThumbMini,$reg)) { $imgThumbMini = $reg[1]; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini); } else dolibarr_syslog($imgThumbMini); Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { $message .= '
'.$langs->trans("ErrorImageFormatNotSupported").'
'; dolibarr_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING); } } else { $message .= '
'.$langs->trans("ErrorFileDoesNotExists",$_GET["file"]).'
'; dolibarr_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING); } } if ($_GET["action"] == 'removelogo') { $logofile=$conf->societe->dir_logos.'/'.$mysoc->logo; dol_delete_file($logofile); dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO"); $mysoc->logo=''; $logosmallfile=$conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_small; dol_delete_file($logosmallfile); dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL"); $mysoc->logo_small=''; $logominifile=$conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini; dol_delete_file($logominifile); dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI"); $mysoc->logo_mini=''; } /* * Affichage page */ llxHeader(); $form = new Form($db); $formcompany = new FormCompany($db); $countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; print_fiche_titre($langs->trans("CompanyFundation"),'','setup'); print $langs->trans("CompanyFundationDesc")."
\n"; print "
\n"; if ((isset($_GET["action"]) && $_GET["action"] == 'edit') || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { /** * Edition des paramètres */ print '
'; print ''; $var=true; print ''; print ''."\n"; $var=!$var; print ''."\n"; $var=!$var; print ''."\n"; $var=!$var; print ''."\n"; $var=!$var; print ''."\n"; $var=!$var; print ''."\n"; $var=!$var; print ''."\n"; $var=!$var; print ''; print ''."\n"; $var=!$var; print ''; print ''."\n"; $var=!$var; print ''; print ''."\n"; $var=!$var; print ''; print ''."\n"; $var=!$var; print ''; print ''; $var=!$var; print ''; $var=!$var; print ''; print ''; print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").''; print '
'.$langs->trans("CompanyAddress").''; print '
'.$langs->trans("CompanyZip").''; print '
'.$langs->trans("CompanyTown").''; print '
'.$langs->trans("Country").''; $form->select_pays($conf->global->MAIN_INFO_SOCIETE_PAYS,'pays_id',($conf->use_javascript_ajax?' onChange="company_save_refresh()"':'')); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print '
'.$langs->trans("CompanyCurrency").''; $form->select_currency($conf->global->MAIN_MONNAIE,"currency"); print '
'.$langs->trans("Tel").''; print '
'.$langs->trans("Fax").''; print '
'.$langs->trans("Mail").''; print '
'.$langs->trans("Web").''; print '
'.$langs->trans("Gencod").''; print '
'.$langs->trans("Logo").' (png,jpg)'; print '
'; print ''; print ''; if ($mysoc->logo_mini && file_exists($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini)) { print ''.img_delete($langs->trans("Delete")).''; print '   '; print ''; } else { print ''; } print '
'; print '
'.$langs->trans("Note").''; print '
'; print '
'; // Identifiants de la société (propre au pays) print ''; print ''; $var=true; $langs->load("companies"); // Recupere code pays $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation if ($conf->global->MAIN_INFO_SOCIETE_PAYS) { $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj->code) $code_pays=$obj->code; } else { dolibarr_print_error($db); } } // Capital $var=!$var; print ''; // Forme juridique $var=!$var; print ''; // ProfID1 if ($langs->transcountry("ProfId1",$code_pays) != '-') { $var=!$var; print ''; } // ProfId2 if ($langs->transcountry("ProfId2",$code_pays) != '-') { $var=!$var; print ''; } // ProfId3 if ($langs->transcountry("ProfId3",$code_pays) != '-') { $var=!$var; print ''; } // ProfId4 if ($langs->transcountry("ProfId4",$code_pays) != '-') { $var=!$var; print ''; } // TVA Intra $var=!$var; print ''; print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("Capital").''; print '
'.$langs->trans("JuridicalStatus").''; if ($conf->global->MAIN_INFO_SOCIETE_PAYS) { $formcompany->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$code_pays); } else { print $countrynotdefined; } print '
'.$langs->transcountry("ProfId1",$code_pays).''; if ($conf->global->MAIN_INFO_SOCIETE_PAYS) { print ''; } else { print $countrynotdefined; } print '
'.$langs->transcountry("ProfId2",$code_pays).''; if ($conf->global->MAIN_INFO_SOCIETE_PAYS) { print ''; } else { print $countrynotdefined; } print '
'.$langs->transcountry("ProfId3",$code_pays).''; if ($conf->global->MAIN_INFO_SOCIETE_PAYS) { print ''; } else { print $countrynotdefined; } print '
'.$langs->transcountry("ProfId4",$code_pays).''; if ($conf->global->MAIN_INFO_SOCIETE_PAYS) { print ''; } else { print $countrynotdefined; } print '
'.$langs->trans("VATIntra").''; print ''; print '
'; /* * Début d'année fiscale */ print '
'; print ''; print ''; print ''; print "\n"; $var=true; $var=!$var; print ''; print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'.$langs->trans("FiscalMonthStart").''; print $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '
"; /* * Options fiscale */ print '
'; print ''; print ''; print ''; print ''; print "\n"; $var=true; $var=!$var; print ""; print '\n"; /* Je désactive cette option "facturation" car ce statut fiscal n'existe pas. Seul le réel et franchise existe. Cette option ne doit donc pas etre en "exclusif" avec l'option fiscale de gestion de tva. Peut etre faut-il une option a part qui n'entre pas en conflit avec les choix "assujéti TVA" ou "non". $var=!$var; print ""; print "\n"; */ $var=!$var; print ""; print '\n"; print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; print ""; print ""; print "\n"; print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; print "
L'option 'facturation' est utilisée par les entreprises qui payent la TVA à facturation (vente de matériel).
'; print ""; print ""; print "\n"; print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; print "
"; print '
'; print '
'; print '
'; } else { /* * Affichage des paramètres */ if ($message) print $message.'
'; print ''; print ''; $var=true; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").'' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '
'.$langs->trans("CompanyZip").'' . $conf->global->MAIN_INFO_SOCIETE_CP . '
'.$langs->trans("CompanyTown").'' . $conf->global->MAIN_INFO_SOCIETE_VILLE . '
'.$langs->trans("CompanyCountry").''; print getCountryLabel($conf->global->MAIN_INFO_SOCIETE_PAYS,1); print '
'.$langs->trans("CompanyCurrency").''; print currency_name($conf->global->MAIN_MONNAIE,1); print ' ('.$conf->global->MAIN_MONNAIE.')'; print '
'.$langs->trans("Tel").'' . $conf->global->MAIN_INFO_SOCIETE_TEL . '
'.$langs->trans("Fax").'' . $conf->global->MAIN_INFO_SOCIETE_FAX . '
'.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL) . '
'.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB) . '
'.$langs->trans("Gencod").'' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '
'.$langs->trans("Logo").''; print '
'; print $mysoc->logo; print ''; // On propose la génération de la vignette si elle n'existe pas if (!is_file($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini) && eregi('(\.jpg|\.jpeg|\.png)$',$mysoc->logo)) { print 'logo).'">'.img_refresh($langs->trans('GenerateThumb')).'  '; } else if ($mysoc->logo_mini && is_file($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini)) { print ''; } else { print ''; } print '
'; print '
'.$langs->trans("Note").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '
'; print '
'; // Identifiants de la société (propre au pays) print '
'; print ''; print ''; $var=true; // Recupere code pays $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation if ($conf->global->MAIN_INFO_SOCIETE_PAYS) { $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; $result=$db->query($sql); if ($result) { $obj = $db->fetch_object(); if ($obj->code) $code_pays=$obj->code; } else { dolibarr_print_error($db); } } // Capital $var=!$var; print ''; // Forme juridique $var=!$var; print ''; // ProfId1 if ($langs->transcountry("ProfId1",$code_pays) != '-') { $var=!$var; print ''; } // ProfId2 if ($langs->transcountry("ProfId2",$code_pays) != '-') { $var=!$var; print ''; } // ProfId3 if ($langs->transcountry("ProfId3",$code_pays) != '-') { $var=!$var; print ''; } // ProfId4 if ($langs->transcountry("ProfId4",$code_pays) != '-') { $var=!$var; print ''; } // TVA if ($conf->use_javascript_ajax) { print "\n"; print ''; print "\n"; } $var=!$var; print ''; print ''; print ''; print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("Capital").''; print $conf->global->MAIN_INFO_CAPITAL . '
'.$langs->trans("JuridicalStatus").''; print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1); print '
'.$langs->transcountry("ProfId1",$code_pays).''; if ($langs->transcountry("ProfId1",$code_pays) != '-') { print $conf->global->MAIN_INFO_SIREN; } print '
'.$langs->transcountry("ProfId2",$code_pays).''; if ($langs->transcountry("ProfId2",$code_pays) != '-') { print $conf->global->MAIN_INFO_SIRET; } print '
'.$langs->transcountry("ProfId3",$code_pays).''; if ($langs->transcountry("ProfId3",$code_pays) != '-') { print $conf->global->MAIN_INFO_APE; } print '
'.$langs->transcountry("ProfId4",$code_pays).''; if ($langs->transcountry("ProfId4",$code_pays) != '-') { print $conf->global->MAIN_INFO_RCS; } print '
'.$langs->trans("VATIntra").''; if ($conf->global->MAIN_INFO_TVAINTRA) { $s=''; $code=substr($conf->global->MAIN_INFO_TVAINTRA,0,2); $num=substr($conf->global->MAIN_INFO_TVAINTRA,2); $s.=$conf->global->MAIN_INFO_TVAINTRA; $s.=''; $s.=''; $s.='   '; if ($conf->use_javascript_ajax) { $s.=''.$langs->trans("VATIntraCheck").''; print $form->textwithhelp($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); } else { print $s.'id_pays).'" target="_blank" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; } } else { print ' '; } print '
'; print '
'; /* * Début d'année fiscale */ print '
'; print ''; print ''; print ''; print "\n"; $var=true; $var=!$var; print ''; print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'.$langs->trans("FiscalMonthStart").''; $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1; print monthArrayOrSelected($monthstart) . '
"; /* * Options fiscale */ print '
'; print ''; print ''; print ''; print ''; print "\n"; $var=true; $var=!$var; print ""; print '\n"; $var=!$var; print ""; print '\n"; print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; print ""; print ""; print "\n"; print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; print "
'; print ""; print ""; print "\n"; print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; print "
"; // Boutons d'action print '
'; print ''.$langs->trans("Modify").''; print '
'; print '
'; } $db->close(); llxFooter('$Date$ - $Revision$'); /** * \brief Retourne le nom traduit ou code+nom d'une devise * \param code_iso Code iso de la devise * \param withcode 1=affiche code + nom * \return string Nom traduit de la devise */ function currency_name($code_iso,$withcode=0) { global $langs,$db; // Si il existe une traduction, on peut renvoyer de suite le libellé if ($langs->trans("Currency".$code_iso)!="Currency".$code_iso) { return $langs->trans("Currency".$code_iso); } // Si pas de traduction, on consulte le libellé par défaut en table $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " WHERE code_iso='".$code_iso."'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { $obj = $db->fetch_object($resql); $label=($obj->label!='-'?$obj->label:''); if ($withcode) return ($label==$code_iso)?"$code_iso":"$code_iso - $label"; else return $label; } else { return $code_iso; } } } ?>