* Copyright (C) 2003 Brian Fraval * Copyright (C) 2004-2005 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$ * */ /** \file htdocs/soc.php \ingroup societe \brief Onglet societe d'une societe \version $Revision$ */ require("pre.inc.php"); $user->getrights('societe'); $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); $step=$_POST["step"]; if ($_POST["createnextstep"]) { $step++; $_GET["action"]="create"; } if ($_POST["createpreviousstep"]) { $step--; $_GET["action"]="create"; } if (! $step) $step++; /* * Actions */ if (($_POST["action"] == 'add' && (! defined(COMPANY_CREATE_TWO_STEPS) || $step == 2)) or $_POST["action"] == 'update') { $soc->nom = stripslashes($_POST["nom"]); $soc->adresse = stripslashes($_POST["adresse"]); $soc->cp = stripslashes($_POST["cp"]); $soc->ville = stripslashes($_POST["ville"]); $soc->pays_id = stripslashes($_POST["pays_id"]); $soc->departement_id = stripslashes($_POST["departement_id"]); $soc->tel = stripslashes($_POST["tel"]); $soc->fax = stripslashes($_POST["fax"]); $soc->url = ereg_replace( "http://", "", $_POST["url"] ); $soc->siren = stripslashes($_POST["siren"]); $soc->siret = stripslashes($_POST["siret"]); $soc->ape = stripslashes($_POST["ape"]); $soc->prefix_comm = stripslashes($_POST["prefix_comm"]); $soc->code_client = stripslashes($_POST["code_client"]); $soc->codeclient_modifiable = stripslashes($_POST["codeclient_modifiable"]); $soc->capital = stripslashes($_POST["capital"]); $soc->tva_intra = stripslashes($_POST["tva_intra_code"] . $_POST["tva_intra_num"]); $soc->forme_juridique_code = stripslashes($_POST["forme_juridique_code"]); $soc->effectif_id = stripslashes($_POST["effectif_id"]); $soc->client = stripslashes($_POST["client"]); $soc->fournisseur = stripslashes($_POST["fournisseur"]); if ($_POST["action"] == 'update') { $result = $soc->update($_GET["socid"],$user); if ($result <> 0) { $soc->id = $_GET["socid"]; // doublon sur le prefix comm $no_reload = 1; $mesg = $soc->error; //"Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre"; $_GET["action"]= "edit"; } else { Header("Location: soc.php?socid=".$_GET["socid"]); } } if ($_POST["action"] == 'add') { $result = $soc->create($user); if ($result == 0) { Header("Location: soc.php?socid=".$soc->id); } else { $_GET["action"]='create'; //dolibarr_print_error($db); } } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer) { $soc = new Societe($db); $soc->fetch($_GET["socid"]); $result = $soc->delete($_GET["socid"]); if ($result == 0) { llxHeader(); print '
'.$langs->trans("CompanyDeleted",$soc->nom).'
'; llxFooter(); exit ; } else { $no_reload = 1; $_GET["action"]=''; } } /** * * */ llxHeader(); $form = new Form($db); if ($_GET["action"] == 'create' || $_POST["action"] == 'create') { if ($user->rights->societe->creer) { /* * Fiche societe en mode création (Creation en 1 ou 2 temps selon COMPANY_CREATE_TWO_STEPS) */ $soc->fournisseur=0; if ($_GET["type"]=='f') { $soc->fournisseur=1; } if ($_GET["type"]=='c') { $soc->client=1; } if ($_GET["type"]=='p') { $soc->client=2; } if ($_POST["nom"]) { $soc->nom=$_POST["nom"]; } print_titre($langs->trans("NewCompany")); print "
\n"; if ($soc->error) { print '
'; print nl2br($soc->error); print '
'; } print '
'; print ''; print ''; print ''; // On positionne pays_id, pays_code et libelle du pays choisi $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:''); if ($soc->pays_id) { $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; $result=$db->query($sql); if ($result) { $obj = $db->fetch_object($result); } else { dolibarr_print_error($db); } $soc->pays_code=$obj->code; $soc->pays=$obj->libelle; } if ($step==1 && defined(COMPANY_CREATE_TWO_STEPS)) { print ''; print ''; print ''; print ''."\n"; } if ($step==2 || ! defined(COMPANY_CREATE_TWO_STEPS)) { if (defined(COMPANY_CREATE_TWO_STEPS)) { print ''; } else { print ''; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''."\n"; print ''."\n"; print ''."\n"; } print '
'.$langs->trans('Name').'
'.$langs->trans('Country').''; $form->select_pays($soc->pays_id); print '
'.$langs->trans('Country').''; print $soc->pays; print ''; print '
'.$langs->trans('Country').''; $form->select_pays($soc->pays_id); print '
'.$langs->trans('Address').'
'.$langs->trans('Zip').''.$langs->trans('Town').'
'.$langs->trans('State').''; $form->select_departement($soc->departement_id,(defined(COMPANY_CREATE_TWO_STEPS)?$soc->pays_code:0)); print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('CustomerCode').'
'.$langs->trans('Web').'
'.$langs->transcountry('ProfId1',$soc->pays_code).''.$langs->transcountry('ProfId2',$soc->pays_code).'
'.$langs->transcountry('ProfId3',$soc->pays_code).' 
'.$langs->trans('Capital').' '.$conf->monnaie.'
Forme juridique'; $form->select_forme_juridique($soc->forme_juridique_code,(defined(COMPANY_CREATE_TWO_STEPS)?$soc->pays_code:0)); print '
Effectif'; $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').''."\n"; $form->selectyesnonum("fournisseur",$soc->fournisseur); print '
'; if (defined(COMPANY_CREATE_TWO_STEPS)) { print '     '; } print '
'."\n"; print '
'."\n"; } } elseif ($_GET["action"] == 'edit') { /* * Fiche societe en mode edition */ print_titre($langs->trans("EditCompany")); if ($_GET["socid"]) { if ($no_reload <> 1) { $soc = new Societe($db); $soc->id = $_GET["socid"]; $soc->fetch($_GET["socid"]); } if ($soc->error) { print '
'; print $soc->error; print '
'; } print '
'; print ''; print ''; 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('Prefix').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''.$langs->trans('Town').'
'.$langs->trans('State').''; $form->select_departement($soc->departement_id,0); print '
'.$langs->trans('Country').''; $form->select_pays($soc->pays_id); print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('CustomerCode').''; if ($soc->codeclient_modifiable == 1) { print ''; } else { print $soc->code_client; } print ''.$langs->trans("Type").''; $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id); print '
'.$langs->trans('Web').'
'.$langs->transcountry('ProfId1',$soc->pays_code).''.$langs->transcountry('ProfId2',$soc->pays_code).'
'.$langs->transcountry('ProfId3',$soc->pays_code).' 
'.$langs->trans("Capital").' '.$conf->monnaie.'
Forme juridique'; $form->select_forme_juridique($soc->forme_juridique_code,0); print '
Effectif'; $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); print '
'.$langs->trans('TVAIntra').''; print ''; print ''; print '
'.$langs->trans('ProspectCustomer').''.$langs->trans('Supplier').''; $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 { if ($no_reload <> 1) { $soc = new Societe($db); $soc->id = $_GET["socid"]; $soc->fetch($_GET["socid"]); } $head[0][0] = 'soc.php?socid='.$soc->id; $head[0][1] = $langs->trans("Company"); $h = 1; if ($soc->client==1) { $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id; $head[$h][1] = $langs->trans("Customer"); $h++; } if ($soc->client==2) { $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$soc->id; $head[$h][1] = $langs->trans("Prospect"); $h++; } if ($soc->fournisseur) { $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id; $head[$h][1] = $langs->trans("Supplier");; $h++; } if ($conf->compta->enabled) { $langs->load("compta"); $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id; $head[$h][1] = $langs->trans("Accountancy"); $h++; } $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$soc->id; $head[$h][1] = $langs->trans("Note"); $h++; if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$soc->id; $head[$h][1] = $langs->trans("Documents"); $h++; } $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$soc->id; $head[$h][1] = $langs->trans("Notifications"); dolibarr_fiche_head($head, 0, $soc->nom); /* * Fiche société en mode visu */ // Confirmation de la suppression de la facture if ($_GET["action"] == 'delete') { $html = new Form($db); $html->form_confirm("soc.php?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete"); print "
\n"; } if ($soc->error) { print '
'; print $soc->error; print '
'; } print ''; print ''; print ""; print '"; print '"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Name').''.$soc->nom.''.$langs->trans('Prefix').''.$soc->prefix_comm.'
".$langs->trans('Address')."".nl2br($soc->adresse)."
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans('Country').''.$soc->pays.'
'.$langs->trans('Phone').''.dolibarr_print_phone($soc->tel).''.$langs->trans('Fax').''.dolibarr_print_phone($soc->fax).'
'; print $langs->trans('CustomerCode').''; print $soc->code_client; if ($soc->check_codeclient() <> 0) { print "Code incorrect"; } print '
'.$langs->trans('Web').''; if ($soc->url) { print 'http://'.$soc->url.''; } print '
'.$langs->transcountry('ProfId1',$soc->pays_code).''; // Si société FR et siren fourni, on le vérifie if ($soc->pays_code == "FR" && $soc->siren) { if ($soc->check_siren() == 0) { print ''.$soc->siren.' '; } else { print ''.$soc->siren; // Siren invalide print " Code Siren Invalide !"; } } else { print $soc->siren; } print ''.$langs->transcountry('ProfId2',$soc->pays_code).''.$soc->siret.'
'.$langs->transcountry('ProfId3',$soc->pays_code).''.$soc->ape.' 
'.$langs->trans('Capital').''.$soc->capital.' '.$conf->monnaie.'
Forme juridique'.$soc->forme_juridique.'
Effectif'.$soc->effectif.'
'.$langs->trans('TVAIntra').''; print $soc->tva_intra; print '
'.img_edit() ." "; print $langs->trans('RIB').''; print $soc->display_rib(); print '
'; print "
\n"; /* * */ if ($_GET["action"] == '') { print ''; } /* * */ } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>