* Copyright (C) 2003 Brian Fraval * Copyright (C) 2004 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. * * $Id$ * $Source$ * */ require("pre.inc.php"); $langs->load("companies"); /* * Sécurité accés client */ if ($user->societe_id > 0) { $_GET["action"] = ''; $_POST["action"] = ''; $_GET["socid"] = $user->societe_id; } $soc = new Societe($db); if ($_POST["action"] == 'add' or $_POST["action"] == 'update') { $soc->nom = $_POST["nom"]; $soc->adresse = $_POST["adresse"]; $soc->cp = $_POST["cp"]; $soc->ville = $_POST["ville"]; $soc->pays_id = $_POST["pays_id"]; $soc->departement_id = $_POST["departement_id"]; $soc->tel = $_POST["tel"]; $soc->fax = $_POST["fax"]; $soc->url = ereg_replace( "http://", "", $_POST["url"] ); $soc->siren = $_POST["siren"]; $soc->siret = $_POST["siret"]; $soc->ape = $_POST["ape"]; $soc->prefix_comm = $_POST["prefix_comm"]; $soc->capital = $_POST["capital"]; $soc->tva_intra = $_POST["tva_intra_code"] . $_POST["tva_intra_num"]; $soc->forme_juridique_code = $_POST["forme_juridique_code"]; $soc->effectif_id = $_POST["effectif_id"]; $soc->client = $_POST["client"]; $soc->fournisseur = $_POST["fournisseur"]; if ($_POST["action"] == 'update') { $result = $soc->update($_GET["socid"],$user); if ($result == -1) { $soc->id = $_GET["socid"]; // doublon sur le prefix comm $no_reload = 1; $mesg = "Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre"; $_GET["action"]= "edit"; } } if ($_POST["action"] == 'add') { $socid = $soc->create($user); if ($socid > 0) { Header("Location: soc.php?socid=$socid"); } elseif ($socid == -1) { $mesg="Erreur, cette société existe déjà sous ce nom ou pour ce prefix commercial"; $_GET["action"]='create'; } else { dolibarr_print_error($db); } } } llxHeader(); $form = new Form($db); if ($_GET["action"] == 'create') { if ($user->rights->societe->creer) { /* * Fiche societe en mode création */ if ($_GET["type"]=='f') { $soc->fournisseur=1; } if ($_GET["type"]=='c') { $soc->client=1; } if ($_GET["type"]=='p') { $soc->client=2; } print_titre($langs->trans("NewCompany")); print "
\n"; print $mesg; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Name').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').' '; print $langs->trans('Town').' '.$langs->trans('State').''; print $form->select_departement($soc->departement_id); print '
'.$langs->trans('Country').''; print $form->select_pays(MAIN_INFO_SOCIETE_PAYS); print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('Web').'http://
'.$langs->trans('ProfIdSiren').''.$langs->trans('ProfIdSiret').'
'.$langs->trans('Ape').'Capital '.MAIN_MONNAIE.'
Forme juridique'; print $form->select_forme_juridique($soc->forme_juridique_code); print '
Effectif'; print $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); print '
'.$langs->trans('TVAIntra').''; print ''; print ''; print '
Vous pouvez vérifier ce numéro sur le site de la commission européenne'; print '
'.$langs->trans('ProspectCustomer').''.$langs->trans('Supplier').''; print $form->selectyesnonum("fournisseur",$soc->fournisseur); print '
'; print '
'; } } elseif ($_GET["action"] == 'edit') { /* * Fiche societe en mode edition */ print_titre("Edition de la société"); if ($_GET["socid"]) { if ($no_reload <> 1) { $soc = new Societe($db); $soc->id = $_GET["socid"]; $soc->fetch($_GET["socid"]); } print $mesg; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
NomPréfix
'.$langs->trans('Adresse').'
CP '; print 'Ville Département/Province/Canton'; print $form->select_departement($soc->departement_id); print '
Pays'; print $form->select_pays($soc->pays_id); print '
'.$langs->trans('Téléphone').''.$langs->trans('Fax').'
Webhttp://
SirenSiret
ApeCapital '.MAIN_MONNAIE.'
Forme juridique'; print $form->select_forme_juridique($soc->forme_juridique_code); print '
Effectif'; print $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); print '
Numéro de TVA Intracommunautaire'; print ''; print ''; print '
Prospect / Client'.$langs->trans('Supplier').''; print $form->selectyesnonum("fournisseur",$soc->fournisseur); print '
'; print '
'; print 'Astuce : Vous pouvez vérifier le numéro de TVA intra communautaire sur le site de la commission européenne'; } } else { $soc = new Societe($db); $soc->id = $_GET["socid"]; $soc->fetch($_GET["socid"]); $head[0][0] = 'soc.php?socid='.$soc->id; $head[0][1] = "Fiche société"; $h = 1; if ($soc->client==1) { $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id; $head[$h][1] = 'Client'; $h++; } if ($soc->client==2) { $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$soc->id; $head[$h][1] = 'Prospect'; $h++; } if ($soc->fournisseur) { $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id; $head[$h][1] = 'Fiche fournisseur'; $h++; } if ($conf->compta->enabled) { $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id; $head[$h][1] = 'Comptabilité'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$soc->id; $head[$h][1] = 'Note'; $h++; if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$soc->id; $head[$h][1] = 'Documents'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$soc->id; $head[$h][1] = 'Notifications'; dolibarr_fiche_head($head, 0, $soc->nom); /* * Fiche société en mode visu */ print ''; print ''; print ""; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
Nom'.$soc->nom.'Préfix'.$soc->prefix_comm.'
".$langs->trans('Adresse')."".nl2br($soc->adresse)."
".$soc->cp." ".$soc->ville." ".$soc->pays."
'.$langs->trans('Téléphone').''.dolibarr_print_phone($soc->tel).''.$langs->trans('Fax').''.dolibarr_print_phone($soc->fax).'
Web'; if ($soc->url) { print 'http://'.$soc->url.''; } print '
Siren'.$soc->siren.' Siret'.$soc->siret.'
Ape'.$soc->ape.'Capital'.$soc->capital.' '.MAIN_MONNAIE.'
Forme juridique'.$soc->forme_juridique.'
Effectif'.$soc->effectif.'
Numéro de TVA Intracommunautaire'; print $soc->tva_intra; print '
'; print "
\n"; /* * */ print ''; /* * */ } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>