* Copyright (C) 2003 Brian Fraval * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2007 Regis Houssin * * 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"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); $user->getrights('societe'); $user->getrights('commercial'); $langs->load("companies"); $langs->load("commercial"); $langs->load("bills"); $socid = isset($_GET["socid"])?$_GET["socid"]:''; // Sécurité accés client if (! $user->rights->societe->creer) { if ($_GET["action"] == 'create' || $_POST["action"] == 'create') { accessforbidden(); } } if ($user->societe_id > 0) { $_GET["action"] = ''; $_POST["action"] = ''; $socid = $user->societe_id; } // Protection restriction commercial if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0) { $sql = "SELECT sc.fk_soc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_user = ".$user->id; if ( $db->query($sql) ) { if ( $db->num_rows() == 0) accessforbidden(); } } // Initialisation de l'objet Societe $soc = new Societe($db); /* * Actions */ if ($_POST["getcustomercode"]) { // On défini valeur pour code_client $_POST["code_client"]="aa"; } if ($_POST["getsuppliercode"]) { // On défini valeur pour code_fournisseur $_POST["code_fournisseur"]="aa"; } if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) && ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer) { if ($_REQUEST["private"] == 1) { $soc->nom = $_POST["nom"].' '.$_POST["prenom"]; $soc->nom_particulier = $_POST["nom"]; $soc->prenom = $_POST["prenom"]; $soc->particulier = $_REQUEST["private"]; } else { $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->email = $_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->tva_assuj = $_POST["assujtva_value"]; $soc->tva_intra_code = $_POST["tva_intra_code"]; $soc->tva_intra_num = $_POST["tva_intra_num"]; $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"]; if ($_REQUEST["private"] == 1) { $soc->typent_id = 8; //todo prévoir autre méthode si le champs "particulier" change de rowid } else { $soc->typent_id = $_POST["typent_id"]; } $soc->client = $_POST["client"]; $soc->fournisseur = $_POST["fournisseur"]; $soc->fournisseur_categorie = $_POST["fournisseur_categorie"]; $soc->commercial_id = $_POST["commercial_id"]; if ($_POST["action"] == 'add') { $result = $soc->create($user); if ($result >= 0) { if ( $soc->client == 1 ) { Header("Location: comm/fiche.php?socid=".$soc->id); return; } else { if ( $soc->fournisseur == 1 ) { Header("Location: fourn/fiche.php?socid=".$soc->id); return; } else { Header("Location: soc.php?socid=".$soc->id); return; } } exit; } else { $mesg=$soc->error; $_GET["action"]='create'; } } if ($_POST["action"] == 'update') { if ($_POST["cancel"]) { Header("Location: soc.php?socid=".$socid); exit; } $oldsoc=new Societe($db); $result=$oldsoc->fetch($socid); $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable()); if ($result >= 0) { Header("Location: soc.php?socid=".$socid); exit; } else { $soc->id = $socid; $reload = 0; $mesg = $soc->error; $_GET["action"]= "edit"; } } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->supprimer) { $soc = new Societe($db); $soc->fetch($socid); $result = $soc->delete($socid); if ($result == 0) { llxHeader(); print '
'.$langs->trans("CompanyDeleted",$soc->nom).'
'; llxFooter(); exit ; } else { $reload = 0; $_GET["action"]=''; } } /** * * */ llxHeader(); $form = new Form($db); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || $_GET["action"] == 'create' || $_POST["action"] == 'create') { /* * Fiche en mode creation */ if ($user->rights->societe->creer) { // Charge objet 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, 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, strlen($module)-4); } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeFournisseur = new $module; /* * 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; } if ($_REQUEST["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"]; $soc->cp=$_POST["cp"]; $soc->ville=$_POST["ville"]; $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"]&&!$_POST["cleartype"])?$_POST["typent_id"]:($_REQUEST["private"]?'TE_PRIVATE':''); $soc->effectif_id=($_POST["effectif_id"]&&!$_POST["cleartype"])?$_POST["effectif_id_id"]:($_REQUEST["private"]?'EF1-5':''); $soc->tva_assuj = $_POST["assujtva_value"]; $soc->tva_intra_code=$_POST["tva_intra_code"]; $soc->tva_intra_num=$_POST["tva_intra_num"]; $soc->commercial_id=$_POST["commercial_id"]; // On positionne pays_id, pays_code et libelle du pays choisi $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; 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 { dolibarr_print_error($db); } $soc->pays_code=$obj->code; $soc->pays=$obj->libelle; } print_titre($langs->trans("NewCompany")); //$conf->use_javascript=0; if ($conf->use_javascript) { print "
\n"; print $langs->trans("ThirdPartyType").':   '; print ' '.$langs->trans("Company/Fundation"); print '     '; print ' '.$langs->trans("Individual"); print ' ('.$langs->trans("ToCreateContactWithSameName").')'; print "
\n"; print "
\n"; } if ($soc->error) { print '
'; print nl2br($soc->error); print '
'; } print '
'; print ''; print ''; print ''; print ''; print ''; print ''; if ($soc->particulier) { print ''; print ''; } // Client / Prospect print ''; print ''; // Fournisseur print ''; print ''; print ''; if ($soc->fournisseur) { $load = $soc->LoadSupplierCateg(); if ( $load == 0) { if (sizeof($soc->SupplierCategories) > 0) { print ''; print ''; } } } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($soc->pays_code == 'FR') { $maxlength1=9; $maxlength2=14; $maxlength3=4; $maxlength4=12; } // Id prof print ''; print ''; print ''; print ''; // Forme juridique print ''; print ''; print ''; print ''; // Assujeti TVA $html = new Form($db); print ''; print ''; // Code TVA intra if ($conf->use_javascript) { print "\n"; print ''; print "\n"; } print ''; print ''; print ''; if ($user->rights->commercial->client->voir) { //Affecter un commercial print ''; print ''; print ''; } print ''."\n"; print '
'.$langs->trans('Name').''.$langs->trans('Prefix').'
'.$langs->trans('FirstName').' 
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; print '
'; print ''; print ''; $s=$langs->trans("CustomerCodeDesc").'
'; $s.=$langs->trans("ValidityControledByModule").': '.$modCodeClient->getNom($langs).'
'; $s.=$langs->trans("RequiredIfCustomer").': '.yn(!$modCodeClient->code_null).'
'; $s.=$langs->trans("Example").': '.$modCodeClient->getExample($langs).''; print $form->textwithhelp('',$s,1); print '
'; print '
'.$langs->trans('Supplier').''; print $form->selectyesno("fournisseur",$soc->fournisseur,1); print ''.$langs->trans('SupplierCode').''; print '
'; print ''; print ''; $s=$langs->trans("SupplierCodeDesc").'
'; $s.=$langs->trans("ValidityControledByModule").': '.$modCodeFournisseur->getNom($langs).'
'; $s.=$langs->trans("RequiredIfSupplier").': '.yn(!$modCodeFournisseur->code_null).'
'; $s.=$langs->trans("Example").': '.$modCodeFournisseur->getExample($langs).''; print $form->textwithhelp('',$s,1); print '
'; print '
'.$langs->trans('SupplierCategory').''; $form->select_array("fournisseur_categorie",$soc->SupplierCategories); print '
'.$langs->trans('Address').'
'.$langs->trans('Zip').'use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; print '>'; if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' '; print ''.$langs->trans('Town').'
'.$langs->trans('Country').''; $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':''); print '
'.$langs->trans('State').''; if ($soc->pays_id) { $form->select_departement($soc->departement_id,$soc->pays_code); } else { print $countrynotdefined; } print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').''.$langs->trans('Web').'
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').''; if ($soc->pays_id) { if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print ''; else print ' '; } else { print $countrynotdefined; } print ''.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').''; if ($soc->pays_id) { if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print ''; else print ' '; } else { print $countrynotdefined; } print '
'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').''; if ($soc->pays_id) { if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print ''; else print ' '; } else { print $countrynotdefined; } print ''.($langs->transcountry("ProfId4",$soc->pays_code) != '-'?$langs->transcountry('ProfId4',$soc->pays_code):'').''; if ($soc->pays_id) { if ($langs->transcountry("ProfId4",$soc->pays_code) != '-') print ''; else print ' '; } else { print $countrynotdefined; } print '
'.$langs->trans('JuridicalStatus').''; if ($soc->pays_id) { $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); } else { print $countrynotdefined; } print '
'.$langs->trans("Type").''."\n"; $form->select_array("typent_id",$soc->typent_array(1), $soc->typent_id); print ''.$langs->trans("Staff").''; $form->select_array("effectif_id",$soc->effectif_array(1), $soc->effectif_id); print '
'.$langs->trans('VATIsUsed').''; print $html->selectyesno('assujtva_value',1,1); // Assujeti par défaut en creation print ''.$langs->trans('VATIntraShort').''; $s =''; $s.=''; $s.=' '; if ($conf->use_javascript) { $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').''; } print '
'.$langs->trans("AllocateCommercial").''; $form->select_users($soc->commercial_id,'commercial_id',1); print '
'; print '
'."\n"; print '
'."\n"; } } elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') { /* * Fiche societe en mode edition */ print_titre($langs->trans("EditCompany")); if ($socid) { // Charge objet 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, 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, strlen($module)-4); } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeFournisseur = new $module; if ($reload || ! $_POST["nom"]) { $soc = new Societe($db); $soc->id = $socid; $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"]; $soc->zip=$_POST["zip"]; $soc->ville=$_POST["ville"]; $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; $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->tva_assuj = $_POST["assujtva_value"]; $soc->tva_intra_code=$_POST["tva_intra_code"]; $soc->tva_intra_num=$_POST["tva_intra_num"]; // On positionne pays_id, pays_code et libelle du pays choisi 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 { dolibarr_print_error($db); } $soc->pays_code=$obj->code; $soc->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } } if ($soc->error) { print '
'; print $soc->error; print '
'; } print '
'; print ''; print ''; print ''; print ''; print ''; // Client / Prospect print ''; print ''; // Fournisseur print ''; print ''; print ''; if ($soc->fournisseur) { $load = $soc->LoadSupplierCateg(); if ( $load == 0) { if (sizeof($soc->SupplierCategories) > 0) { print ''; print ''; } } } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // IdProf1 (SIREN pour France) $idprof=$langs->transcountry('ProfId1',$soc->pays_code); if ($idprof!='-') { print ''; } else print ''; // IdProf2 (SIRET pour France) $idprof=$langs->transcountry('ProfId2',$soc->pays_code); if ($idprof!='-') { print ''; } else print ''; print ''; print ''; // IdProf3 (APE pour France) $idprof=$langs->transcountry('ProfId3',$soc->pays_code); if ($idprof!='-') { print ''; } else print ''; // IdProf4 (NU pour France) $idprof=$langs->transcountry('ProfId4',$soc->pays_code); if ($idprof!='-') { print ''; } else print ''; print ''; // Assujeti TVA print ''; // Code TVA intra if ($conf->use_javascript) { print "\n"; print ''; print "\n"; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Name').'
'.$langs->trans("Prefix").''; print ''; print '
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; print '
'; if ($soc->codeclient_modifiable()) { print ''; } else { print $soc->code_client; print ''; } print ''; $s=$langs->trans("CustomerCodeDesc").'
'; $s.=$langs->trans("ValidityControledByModule").': '.$modCodeClient->getNom($langs).'
'; $s.=$langs->trans("RequiredIfCustomer").': '.yn(!$modCodeClient->code_null).'
'; $s.=$langs->trans("Example").': '.$modCodeClient->getExample($langs).''; print $form->textwithhelp('',$s,1); print '
'; print '
'.$langs->trans('Supplier').''; print $form->selectyesno("fournisseur",$soc->fournisseur,1); print ''.$langs->trans('SupplierCode').''; print '
'; if ($soc->codefournisseur_modifiable()) { print ''; } else { print $soc->code_fournisseur; print ''; } print ''; $s=$langs->trans("SupplierCodeDesc").'
'; $s.=$langs->trans("ValidityControledByModule").': '.$modCodeFournisseur->getNom($langs).'
'; $s.=$langs->trans("RequiredIfSupplier").': '.yn(!$modCodeFournisseur->code_null).'
'; $s.=$langs->trans("Example").': '.$modCodeFournisseur->getExample($langs).''; print $form->textwithhelp('',$s,1); print '
'; print '
'.$langs->trans('SupplierCategory').''; $form->select_array("fournisseur_categorie",$soc->SupplierCategories); print '
'.$langs->trans('Address').'
'.$langs->trans('Zip').'use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; print '>'; if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' '; print ''.$langs->trans('Town').'
'.$langs->trans('Country').''; $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_edit()"':''); print '
'.$langs->trans('State').''; $form->select_departement($soc->departement_id,$soc->pays_code); print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').''.$langs->trans('Web').'
'.$idprof.''; $form->id_prof(1,$soc,'idprof1',$soc->siren); print '  '.$idprof.''; $form->id_prof(2,$soc,'idprof2',$soc->siret); print '  
'.$idprof.''; $form->id_prof(3,$soc,'idprof3',$soc->ape); print '  '.$idprof.''; $form->id_prof(4,$soc,'idprof4',$soc->idprof4); print '  
'.$langs->trans('VATIsUsed').''; print $form->selectyesno('assujtva_value',$soc->tva_assuj,1); print ''.$langs->trans('VATIntraShort').''; $s =''; $s.=''; $s.=' '; if ($conf->use_javascript) { $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').''; } print '
'.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('JuridicalStatus').''; $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); print '
'.$langs->trans("Type").''; $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id); print ''.$langs->trans("Staff").''; $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); print '
'; print ''; print '   '; print ''; print '
'; print '
'; } } else { /* * Fiche société en mode visu */ $soc = new Societe($db); $soc->id = $socid; $result=$soc->fetch($socid); if ($result < 0) { dolibarr_print_error($db,$soc->error); exit; } $head = societe_prepare_head($soc); dolibarr_fiche_head($head, 'company', $soc->nom); // 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 ''; if ($soc->client) { print ''; } if ($soc->fournisseur) { print ''; } print ""; print '"; print '"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // ProfId1 (SIREN pour France) $profid=$langs->transcountry('ProfId1',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // ProfId2 (SIRET pour France) $profid=$langs->transcountry('ProfId2',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // ProfId3 (APE pour France) $profid=$langs->transcountry('ProfId3',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // ProfId4 (NU pour France) $profid=$langs->transcountry('ProfId4',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // Assujeti TVA $html = new Form($db); print ''; print ''; print ''; // Capital print ''; // Statut juridique print ''; // Type + Staff $arr = $soc->typent_array($soc->typent_id); $soc->typent= $arr[$soc->typent_id]; print ''; // RIB print ''; print ''; // Maison mère print ''; print ''; // Commerciaux print ''; print ''; print '
'.$langs->trans('Name').''.$soc->nom.'
'.$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('SupplierCode').''; print $soc->code_fournisseur; if ($soc->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
".$langs->trans('Address')."".nl2br($soc->adresse)."
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans('Country').''.$soc->pays.'
'.$langs->trans('State').''.$soc->departement.'
'.$langs->trans('Phone').''.dolibarr_print_phone($soc->tel).''.$langs->trans('Fax').''.dolibarr_print_phone($soc->fax).'
'.$langs->trans('EMail').''; if ($soc->email) { print ''.$soc->email.''; } else print ' '; print ''.$langs->trans('Web').''; if ($soc->url) { print 'http://'.dolibarr_trunc($soc->url,32).''; } else print ' '; 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 '
  
'; /* Pas besoin de gérer l'icone "Modifier" car le champ est déja editable quand société en mode "Edit" print '
'; print $langs->trans('VATIsUsed'); print ''; if ($user->rights->societe->creer && $_GET['action'] != 'editassujtva') print 'id.'">'.img_edit($langs->trans('SetMode')).''; else print ' '; print '
'; print '
'; if($_GET['action'] == 'editassujtva') print $html->form_assujetti_tva($_SERVER['PHP_SELF'].'?socid='.$soc->id,$soc->tva_assuj,'assujtva_value'); else if($soc->tva_assuj == 1) print 'oui'; else print 'non'; print ''; */ print $langs->trans('VATIsUsed'); print ''; print yn($soc->tva_assuj); print ''.$langs->trans('VATIntraShort').''; print $soc->tva_intra; 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("Type").''.$soc->typent.''.$langs->trans("Staff").''.$soc->effectif.'
'; 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 ''.img_object($langs->trans("ShowCompany"),'company').' '.$socm->nom.''.($socm->code_client?"(".$socm->code_client.")":"").' - '.$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 '
'; $sql = "SELECT count(sc.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE sc.fk_soc =".$soc->id; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $obj = $db->fetch_object($resql); print $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected"); } else { dolibarr_print_error($db); } print '
'; print "\n"; /* * */ if ($_GET["action"] == '') { print '
'; if ($user->rights->societe->creer) { print ''.$langs->trans("Edit").''; } if ($conf->projet->enabled && $user->rights->projet->creer) { $langs->load("projects"); print ''.$langs->trans("AddProject").''; } if ($user->rights->societe->contact->creer) { print ''.$langs->trans("AddContact").''; } if ($user->rights->societe->supprimer) { print ''.$langs->trans("Delete").''; } print '
'; } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>