Les listes déroulantes formes juridiques, départements, les identifiants société (siren, siret, naf) s'affichent en fonction du pays
This commit is contained in:
parent
35b0af6d2a
commit
135c3e4987
@ -35,8 +35,6 @@ ActiveOn=Activated on
|
|||||||
SourceFile=Source file
|
SourceFile=Source file
|
||||||
TriggersAvailable=Triggers available
|
TriggersAvailable=Triggers available
|
||||||
TriggersDesc=Triggers are components that modify, once activated, the behaviour of Dolibarr workflow. They add new actions, activated on Dolibarr events (new company creation, invoice validation, ...).
|
TriggersDesc=Triggers are components that modify, once activated, the behaviour of Dolibarr workflow. They add new actions, activated on Dolibarr events (new company creation, invoice validation, ...).
|
||||||
SeeAbove=See above
|
|
||||||
ErrorSetACountryFirst=Set the country first
|
|
||||||
ModuleFamilyCrm=Customer Ressource Management (CRM)
|
ModuleFamilyCrm=Customer Ressource Management (CRM)
|
||||||
ModuleFamilyProducts=Products Management
|
ModuleFamilyProducts=Products Management
|
||||||
ModuleFamilyHr=Human Ressource Management
|
ModuleFamilyHr=Human Ressource Management
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
ErrorBadEMail=EMail %s is wrong
|
ErrorBadEMail=EMail %s is wrong
|
||||||
ErrorCompanyNameAlreadyExists=Company name %s already exists. Choose another one.
|
ErrorCompanyNameAlreadyExists=Company name %s already exists. Choose another one.
|
||||||
ErrorPrefixAlreadyExists=Prefix %s already exists. Choose another one.
|
ErrorPrefixAlreadyExists=Prefix %s already exists. Choose another one.
|
||||||
|
ErrorSetACountryFirst=Set the country first
|
||||||
ConfirmDeleteCompany=Are you sure you want to delete this company and all inherited informations ?
|
ConfirmDeleteCompany=Are you sure you want to delete this company and all inherited informations ?
|
||||||
MenuNewCompany=New company
|
MenuNewCompany=New company
|
||||||
MenuNewCustomer=New customer
|
MenuNewCustomer=New customer
|
||||||
|
|||||||
@ -21,6 +21,7 @@ ErrorWrongHostParameter=Wrong host parameter
|
|||||||
ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit and post again the form.
|
ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit and post again the form.
|
||||||
ErrorRecordIsUsedByChild=Failed to delete this record. This record is used by at least on child records.
|
ErrorRecordIsUsedByChild=Failed to delete this record. This record is used by at least on child records.
|
||||||
ErrorWrongValue=Wrong value
|
ErrorWrongValue=Wrong value
|
||||||
|
SeeAbove=See above
|
||||||
HomeArea=Home area
|
HomeArea=Home area
|
||||||
LastAccess=Last access
|
LastAccess=Last access
|
||||||
RequestedUrl=Requested Url
|
RequestedUrl=Requested Url
|
||||||
|
|||||||
@ -35,8 +35,6 @@ ActiveOn=Active sur
|
|||||||
SourceFile=Fichier source
|
SourceFile=Fichier source
|
||||||
TriggersAvailable=Triggers disponibles
|
TriggersAvailable=Triggers disponibles
|
||||||
TriggersDesc=Les triggers sont des composants qui, une fois activés, modifient le comportement du workflow de Dolibarr. Ils réalisent des actions suplémentaires, déclenchées par les événements Dolibarr (création société, validation facture, clôture contrat...).
|
TriggersDesc=Les triggers sont des composants qui, une fois activés, modifient le comportement du workflow de Dolibarr. Ils réalisent des actions suplémentaires, déclenchées par les événements Dolibarr (création société, validation facture, clôture contrat...).
|
||||||
SeeAbove=Voir ci-dessus
|
|
||||||
ErrorSetACountryFirst=Définissez d'abord le pays
|
|
||||||
ModuleFamilyCrm=Gestion client (CRM)
|
ModuleFamilyCrm=Gestion client (CRM)
|
||||||
ModuleFamilyProducts=Gestion produits
|
ModuleFamilyProducts=Gestion produits
|
||||||
ModuleFamilyHr=Ressources humaines
|
ModuleFamilyHr=Ressources humaines
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
ErrorBadEMail=e-mail %s invalide
|
ErrorBadEMail=e-mail %s invalide
|
||||||
ErrorCompanyNameAlreadyExists=Le nom de société %s existe déjà. Veuillez en choisir un autre.
|
ErrorCompanyNameAlreadyExists=Le nom de société %s existe déjà. Veuillez en choisir un autre.
|
||||||
ErrorPrefixAlreadyExists=Le préfixe %s existe déjà. Veuillez en choisir un autre.
|
ErrorPrefixAlreadyExists=Le préfixe %s existe déjà. Veuillez en choisir un autre.
|
||||||
|
ErrorSetACountryFirst=Définissez d'abord le pays
|
||||||
ConfirmDeleteCompany=Êtes-vous sûr de vouloir supprimer cette société et toutes les informations qui en dépendent ?
|
ConfirmDeleteCompany=Êtes-vous sûr de vouloir supprimer cette société et toutes les informations qui en dépendent ?
|
||||||
MenuNewCompany=Nouvelle société
|
MenuNewCompany=Nouvelle société
|
||||||
MenuNewCustomer=Nouveau client
|
MenuNewCustomer=Nouveau client
|
||||||
|
|||||||
@ -21,6 +21,7 @@ ErrorWrongHostParameter=Mauvais param
|
|||||||
ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Aller dans Configuration-Général-Editer et resoumettez le formulaire.
|
ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Aller dans Configuration-Général-Editer et resoumettez le formulaire.
|
||||||
ErrorRecordIsUsedByChild=Impossible de supprimer cet enregistrement. Ce dernier est utilisé en tant que père par au moins un enregistrement fils.
|
ErrorRecordIsUsedByChild=Impossible de supprimer cet enregistrement. Ce dernier est utilisé en tant que père par au moins un enregistrement fils.
|
||||||
ErrorWrongValue=Valeur incorrecte
|
ErrorWrongValue=Valeur incorrecte
|
||||||
|
SeeAbove=Voir ci-dessus
|
||||||
HomeArea=Espace accueil
|
HomeArea=Espace accueil
|
||||||
LastAccess=Dernière connexion
|
LastAccess=Dernière connexion
|
||||||
RequestedUrl=Url sollicitée
|
RequestedUrl=Url sollicitée
|
||||||
|
|||||||
391
htdocs/soc.php
391
htdocs/soc.php
@ -2,7 +2,7 @@
|
|||||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
|
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -46,15 +46,10 @@ if ($user->societe_id > 0)
|
|||||||
|
|
||||||
$soc = new Societe($db);
|
$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
|
* Actions
|
||||||
*/
|
*/
|
||||||
if (($_POST["action"] == 'add' && (! defined("COMPANY_CREATE_TWO_STEPS") || $step == 2)) or $_POST["action"] == 'update')
|
if ($_POST["action"] == 'add' or $_POST["action"] == 'update')
|
||||||
{
|
{
|
||||||
$soc->nom = stripslashes($_POST["nom"]);
|
$soc->nom = stripslashes($_POST["nom"]);
|
||||||
$soc->adresse = stripslashes($_POST["adresse"]);
|
$soc->adresse = stripslashes($_POST["adresse"]);
|
||||||
@ -90,7 +85,7 @@ if (($_POST["action"] == 'add' && (! defined("COMPANY_CREATE_TWO_STEPS") || $ste
|
|||||||
{
|
{
|
||||||
$soc->id = $_GET["socid"];
|
$soc->id = $_GET["socid"];
|
||||||
// doublon sur le prefix comm
|
// doublon sur le prefix comm
|
||||||
$no_reload = 1;
|
$reload = 0;
|
||||||
$mesg = $soc->error; //"Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre";
|
$mesg = $soc->error; //"Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre";
|
||||||
$_GET["action"]= "edit";
|
$_GET["action"]= "edit";
|
||||||
}
|
}
|
||||||
@ -134,7 +129,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user-
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$no_reload = 1;
|
$reload = 0;
|
||||||
$_GET["action"]='';
|
$_GET["action"]='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,6 +142,8 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user-
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||||
{
|
{
|
||||||
@ -159,33 +156,31 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
|||||||
if ($_GET["type"]=='f') { $soc->fournisseur=1; }
|
if ($_GET["type"]=='f') { $soc->fournisseur=1; }
|
||||||
if ($_GET["type"]=='c') { $soc->client=1; }
|
if ($_GET["type"]=='c') { $soc->client=1; }
|
||||||
if ($_GET["type"]=='p') { $soc->client=2; }
|
if ($_GET["type"]=='p') { $soc->client=2; }
|
||||||
if ($_POST["nom"]) { $soc->nom=$_POST["nom"]; }
|
if ($_POST["nom"])
|
||||||
|
|
||||||
print_titre($langs->trans("NewCompany"));
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
if ($soc->error)
|
|
||||||
{
|
{
|
||||||
print '<div class="error">';
|
$soc->nom=$_POST["nom"];
|
||||||
print nl2br($soc->error);
|
$soc->prefix_comm=$_POST["prefix_comm"];
|
||||||
print '</div>';
|
$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->departement_id=$_POST["departement_id"];
|
||||||
|
$soc->tel=$_POST["tel"];
|
||||||
|
$soc->fax=$_POST["fax"];
|
||||||
|
$soc->url=$_POST["url"];
|
||||||
|
$soc->capital=$_POST["capital"];
|
||||||
|
$soc->siren=$_POST["siren"];
|
||||||
|
$soc->siret=$_POST["siret"];
|
||||||
|
$soc->ape=$_POST["ape"];
|
||||||
|
$soc->typent_id=$_POST["typent_id"];
|
||||||
|
$soc->effectif_id=$_POST["effectif_id"];
|
||||||
|
$soc->tva_intra_code=$_POST["tva_intra_code"];
|
||||||
|
$soc->tva_intra_num=$_POST["tva_intra_num"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->global->MAIN_AUTO_FILLTOWNFROMZIP)
|
|
||||||
{
|
|
||||||
include("./soc.js.php");
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<form action="soc.php" method="post" name="formsoc">';
|
|
||||||
|
|
||||||
print '<input type="hidden" name="codeclient_modifiable" value="1">';
|
|
||||||
print '<input type="hidden" name="codefournisseur_modifiable" value="1">';
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" value="'.$soc->nom.'"></td>';
|
|
||||||
print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" name="prefix_comm" value="'.$soc->prefix_comm.'"></td></tr>';
|
|
||||||
|
|
||||||
// On positionne pays_id, pays_code et libelle du pays choisi
|
// 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:'');
|
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:'');
|
||||||
if ($soc->pays_id)
|
if ($soc->pays_id)
|
||||||
@ -204,115 +199,165 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
|||||||
$soc->pays=$obj->libelle;
|
$soc->pays=$obj->libelle;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($step==1 && defined("COMPANY_CREATE_TWO_STEPS"))
|
print_titre($langs->trans("NewCompany"));
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
if ($soc->error)
|
||||||
{
|
{
|
||||||
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
|
print '<div class="error">';
|
||||||
$form->select_pays($soc->pays_id);
|
print nl2br($soc->error);
|
||||||
print '</td></tr>';
|
print '</div>';
|
||||||
|
|
||||||
print '<input type="hidden" name="step" value="'.$step.'">';
|
|
||||||
print '<input type="hidden" name="action" value="create">';
|
|
||||||
print '<tr><td colspan="4" align="center"><input type="submit" class="button" name="createnextstep" value="'.$langs->trans('NextStep').'"></td></tr>'."\n";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($step==2 || ! defined("COMPANY_CREATE_TWO_STEPS")) {
|
|
||||||
|
|
||||||
// Client / Prospect
|
|
||||||
print '<tr><td width="25%">'.$langs->trans('ProspectCustomer').'</td><td width="25%"><select class="flat" name="client">';
|
|
||||||
print '<option value="2"'.($soc->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
|
||||||
print '<option value="1"'.($soc->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
|
||||||
print '<option value="0"'.($soc->client==0?' selected':'').'>Ni client, ni prospect</option>';
|
|
||||||
print '</select></td>';
|
|
||||||
print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
|
|
||||||
print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Fournisseur
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>'.$langs->trans('Supplier').'</td><td>';
|
|
||||||
$form->selectyesnonum("fournisseur",$soc->fournisseur);
|
|
||||||
print '</td>';
|
|
||||||
print '<td>'.$langs->trans('SupplierCode').'</td><td>';
|
|
||||||
print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
|
|
||||||
if (defined("COMPANY_CREATE_TWO_STEPS"))
|
|
||||||
{
|
|
||||||
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
|
|
||||||
print $soc->pays;
|
|
||||||
print '<input type="hidden" name="pays_id" value="'.$soc->pays_id.'">';
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
|
|
||||||
$form->select_pays($soc->pays_id);
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<input type="hidden" name="step" value="'.$step.'">';
|
|
||||||
print '<input type="hidden" name="action" value="add">';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
|
|
||||||
print $soc->adresse;
|
|
||||||
print '</textarea></td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"';
|
|
||||||
if ($conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="PopupPostalCode(cp.value,ville)"';
|
|
||||||
print '>';
|
|
||||||
if ($conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="PopupPostalCode(cp.value,ville)">';
|
|
||||||
print '</td>';
|
|
||||||
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
|
||||||
$form->select_departement($soc->departement_id,(defined("COMPANY_CREATE_TWO_STEPS")?$soc->pays_code:0));
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
|
||||||
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->transcountry('ProfId1',$soc->pays_code).'</td><td><input type="text" name="siren" size="15" maxlength="9" value="'.$soc->siren.'"></td>';
|
|
||||||
print '<td>'.$langs->transcountry('ProfId2',$soc->pays_code).'</td><td><input type="text" name="siret" size="15" maxlength="14" value="'.$soc->siret.'"></td></tr>';
|
|
||||||
print '<tr><td>'.$langs->transcountry('ProfId3',$soc->pays_code).'</td><td><input type="text" name="ape" size="5" maxlength="4" value="'.$soc->ape.'"></td><td colspan="2"> </td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
|
|
||||||
$form->select_forme_juridique($soc->forme_juridique_code,(defined("COMPANY_CREATE_TWO_STEPS")?$soc->pays_code:0));
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
|
||||||
$form->select_array("typent_id",$soc->typent_array(), $soc->typent_id);
|
|
||||||
print '</td>';
|
|
||||||
print '<td>'.$langs->trans("Staff").'</td><td>';
|
|
||||||
$form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td nowrap>'.$langs->trans('VATIntraShort').'</td><td colspan="3">';
|
|
||||||
|
|
||||||
print '<input type="text" name="tva_intra_code" size="3" maxlength="2" value="'.$soc->tva_intra_code.'">';
|
|
||||||
print '<input type="text" name="tva_intra_num" size="18" maxlength="18" value="'.$soc->tva_intra_num.'">';
|
|
||||||
print ' '.$langs->trans("VATIntraCheckableOnEUSite");
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td colspan="4" align="center">';
|
|
||||||
if (defined("COMPANY_CREATE_TWO_STEPS"))
|
|
||||||
{
|
|
||||||
print '<input type="submit" class="button" name="createpreviousstep" value="'.$langs->trans('PreviousStep').'"> ';
|
|
||||||
}
|
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans('AddCompany').'"></td></tr>'."\n";
|
|
||||||
|
|
||||||
|
if ($conf->global->MAIN_AUTO_FILLTOWNFROMZIP)
|
||||||
|
{
|
||||||
|
include("./soc.js.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '
|
||||||
|
<script language="javascript" type="text/javascript">
|
||||||
|
<!--
|
||||||
|
function save_refresh()
|
||||||
|
{
|
||||||
|
document.formsoc.action.value="create";
|
||||||
|
document.formsoc.submit();
|
||||||
|
// location.href = "index.php?action=updateedit";
|
||||||
|
}
|
||||||
|
-->
|
||||||
|
</script>
|
||||||
|
';
|
||||||
|
|
||||||
|
print '<form action="soc.php" method="post" name="formsoc">';
|
||||||
|
|
||||||
|
print '<input type="hidden" name="action" value="add">';
|
||||||
|
print '<input type="hidden" name="codeclient_modifiable" value="1">';
|
||||||
|
print '<input type="hidden" name="codefournisseur_modifiable" value="1">';
|
||||||
|
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" value="'.$soc->nom.'"></td>';
|
||||||
|
print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" name="prefix_comm" value="'.$soc->prefix_comm.'"></td></tr>';
|
||||||
|
|
||||||
|
// Client / Prospect
|
||||||
|
print '<tr><td width="25%">'.$langs->trans('ProspectCustomer').'</td><td width="25%"><select class="flat" name="client">';
|
||||||
|
print '<option value="2"'.($soc->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
||||||
|
print '<option value="1"'.($soc->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||||
|
print '<option value="0"'.($soc->client==0?' selected':'').'>Ni client, ni prospect</option>';
|
||||||
|
print '</select></td>';
|
||||||
|
print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
|
||||||
|
print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Fournisseur
|
||||||
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans('Supplier').'</td><td>';
|
||||||
|
$form->selectyesnonum("fournisseur",$soc->fournisseur);
|
||||||
|
print '</td>';
|
||||||
|
print '<td>'.$langs->trans('SupplierCode').'</td><td>';
|
||||||
|
print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
|
||||||
|
print $soc->adresse;
|
||||||
|
print '</textarea></td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"';
|
||||||
|
if ($conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="PopupPostalCode(cp.value,ville)"';
|
||||||
|
print '>';
|
||||||
|
if ($conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="PopupPostalCode(cp.value,ville)">';
|
||||||
|
print '</td>';
|
||||||
|
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
|
||||||
|
$form->select_pays($soc->pays_id,'pays_id',' onChange="save_refresh()"');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
||||||
|
if ($soc->pays_id)
|
||||||
|
{
|
||||||
|
$form->select_departement($soc->departement_id,$soc->pays_code);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $countrynotdefined;
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
||||||
|
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').'</td><td>';
|
||||||
|
if ($soc->pays_id)
|
||||||
|
{
|
||||||
|
if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print '<input type="text" name="siren" size="15" maxlength="9" value="'.$soc->siren.'">';
|
||||||
|
else print ' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $countrynotdefined;
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
print '<td>'.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').'</td><td>';
|
||||||
|
if ($soc->pays_id)
|
||||||
|
{
|
||||||
|
if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print '<input type="text" name="siret" size="15" maxlength="14" value="'.$soc->siret.'">';
|
||||||
|
else print ' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $countrynotdefined;
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
print '<tr><td>'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').'</td><td>';
|
||||||
|
if ($soc->pays_id)
|
||||||
|
{
|
||||||
|
if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print '<input type="text" name="ape" size="5" maxlength="4" value="'.$soc->ape.'">';
|
||||||
|
else print ' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $countrynotdefined;
|
||||||
|
}
|
||||||
|
print '</td><td colspan="2"> </td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
|
||||||
|
if ($soc->pays_id)
|
||||||
|
{
|
||||||
|
$form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $countrynotdefined;
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
||||||
|
$form->select_array("typent_id",$soc->typent_array(), $soc->typent_id);
|
||||||
|
print '</td>';
|
||||||
|
print '<td>'.$langs->trans("Staff").'</td><td>';
|
||||||
|
$form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td nowrap>'.$langs->trans('VATIntraShort').'</td><td colspan="3">';
|
||||||
|
|
||||||
|
print '<input type="text" name="tva_intra_code" size="3" maxlength="2" value="'.$soc->tva_intra_code.'">';
|
||||||
|
print '<input type="text" name="tva_intra_num" size="18" maxlength="18" value="'.$soc->tva_intra_num.'">';
|
||||||
|
print ' '.$langs->trans("VATIntraCheckableOnEUSite");
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td colspan="4" align="center">';
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans('AddCompany').'"></td></tr>'."\n";
|
||||||
|
|
||||||
print '</table>'."\n";
|
print '</table>'."\n";
|
||||||
print '</form>'."\n";
|
print '</form>'."\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($_GET["action"] == 'edit')
|
elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Fiche societe en mode edition
|
* Fiche societe en mode edition
|
||||||
@ -328,12 +373,68 @@ elseif ($_GET["action"] == 'edit')
|
|||||||
include("./soc.js.php");
|
include("./soc.js.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($no_reload <> 1)
|
print '
|
||||||
|
<script language="javascript" type="text/javascript">
|
||||||
|
<!--
|
||||||
|
function save_refresh()
|
||||||
|
{
|
||||||
|
document.formsoc.action.value="edit";
|
||||||
|
document.formsoc.submit();
|
||||||
|
// location.href = "index.php?action=updateedit";
|
||||||
|
}
|
||||||
|
-->
|
||||||
|
</script>
|
||||||
|
';
|
||||||
|
|
||||||
|
if ($reload || ! $_POST["nom"])
|
||||||
{
|
{
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->id = $_GET["socid"];
|
$soc->id = $_GET["socid"];
|
||||||
$soc->fetch($_GET["socid"]);
|
$soc->fetch($_GET["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"]:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:'');
|
||||||
|
$soc->departement_id=$_POST["departement_id"];
|
||||||
|
$soc->tel=$_POST["tel"];
|
||||||
|
$soc->fax=$_POST["fax"];
|
||||||
|
$soc->url=$_POST["url"];
|
||||||
|
$soc->capital=$_POST["capital"];
|
||||||
|
$soc->siren=$_POST["siren"];
|
||||||
|
$soc->siret=$_POST["siret"];
|
||||||
|
$soc->ape=$_POST["ape"];
|
||||||
|
$soc->typent_id=$_POST["typent_id"];
|
||||||
|
$soc->effectif_id=$_POST["effectif_id"];
|
||||||
|
$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)
|
if ($soc->error)
|
||||||
{
|
{
|
||||||
@ -344,6 +445,7 @@ elseif ($_GET["action"] == 'edit')
|
|||||||
|
|
||||||
print '<form action="soc.php?socid='.$soc->id.'" method="post" name="formsoc">';
|
print '<form action="soc.php?socid='.$soc->id.'" method="post" name="formsoc">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
|
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||||
print '<input type="hidden" name="codeclient_modifiable" value="'.$soc->codeclient_modifiable.'">';
|
print '<input type="hidden" name="codeclient_modifiable" value="'.$soc->codeclient_modifiable.'">';
|
||||||
print '<input type="hidden" name="codefournisseur_modifiable" value="'.$soc->codefournisseur_modifiable.'">';
|
print '<input type="hidden" name="codefournisseur_modifiable" value="'.$soc->codefournisseur_modifiable.'">';
|
||||||
|
|
||||||
@ -400,12 +502,12 @@ elseif ($_GET["action"] == 'edit')
|
|||||||
|
|
||||||
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
|
||||||
$form->select_departement($soc->departement_id,0);
|
$form->select_pays($soc->pays_id,'pays_id',' onChange="save_refresh()"');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
||||||
$form->select_pays($soc->pays_id);
|
$form->select_departement($soc->departement_id,$soc->pays_code);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
||||||
@ -464,7 +566,7 @@ elseif ($_GET["action"] == 'edit')
|
|||||||
print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
|
||||||
$form->select_forme_juridique($soc->forme_juridique_code,0);
|
$form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
||||||
@ -486,11 +588,13 @@ else
|
|||||||
* Fiche société en mode visu
|
* Fiche société en mode visu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($no_reload <> 1)
|
$soc = new Societe($db);
|
||||||
|
$soc->id = $_GET["socid"];
|
||||||
|
$result=$soc->fetch($_GET["socid"]);
|
||||||
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$soc = new Societe($db);
|
dolibarr_print_error($db,$soc->error);
|
||||||
$soc->id = $_GET["socid"];
|
exit;
|
||||||
$soc->fetch($_GET["socid"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$h=0;
|
$h=0;
|
||||||
@ -586,6 +690,9 @@ else
|
|||||||
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->ville."</td></tr>";
|
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->ville."</td></tr>";
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$soc->pays.'</td>';
|
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$soc->pays.'</td>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$soc->departement.'</td>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dolibarr_print_phone($soc->tel).'</td>';
|
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dolibarr_print_phone($soc->tel).'</td>';
|
||||||
print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>';
|
print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>';
|
||||||
|
|||||||
@ -236,189 +236,170 @@ class Societe {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mise a jour des paramètres de la société
|
* \brief Mise a jour des paramètres de la sociét
|
||||||
* \param id id societe
|
* \param id id societe
|
||||||
* \param user Utilisateur qui demande la mise à jour
|
* \param user Utilisateur qui demande la mise à jour
|
||||||
* \return 0 si ok, < 0 si erreur
|
* \return 0 si ok, < 0 si erreur
|
||||||
*/
|
*/
|
||||||
|
function update($id, $user='')
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
function update($id, $user='')
|
dolibarr_syslog("Societe::Update");
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
|
|
||||||
dolibarr_syslog("Societe::Update");
|
$this->id=$id;
|
||||||
|
$this->capital=trim($this->capital);
|
||||||
|
$this->nom=trim($this->nom);
|
||||||
|
$this->adresse=trim($this->adresse);
|
||||||
|
$this->cp=trim($this->cp);
|
||||||
|
$this->ville=trim($this->ville);
|
||||||
|
$this->departement_id=trim($this->departement_id);
|
||||||
|
$this->pays_id=trim($this->pays_id);
|
||||||
|
$this->tel=trim($this->tel);
|
||||||
|
$this->fax=trim($this->fax);
|
||||||
|
$this->url=trim($this->url);
|
||||||
|
$this->siren=trim($this->siren);
|
||||||
|
$this->siret=trim($this->siret);
|
||||||
|
$this->ape=trim($this->ape);
|
||||||
|
$this->prefix_comm=trim($this->prefix_comm);
|
||||||
|
$this->tva_intra=trim($this->tva_intra);
|
||||||
|
$this->capital=trim($this->capital);
|
||||||
|
$this->effectif_id=trim($this->effectif_id);
|
||||||
|
$this->forme_juridique_code=trim($this->forme_juridique_code);
|
||||||
|
|
||||||
$this->id=$id;
|
$result = $this->verify();
|
||||||
$this->capital=trim($this->capital);
|
|
||||||
$this->nom=trim($this->nom);
|
|
||||||
$this->adresse=trim($this->adresse);
|
|
||||||
$this->cp=trim($this->cp);
|
|
||||||
$this->ville=trim($this->ville);
|
|
||||||
$this->departement_id=trim($this->departement_id);
|
|
||||||
$this->pays_id=trim($this->pays_id);
|
|
||||||
$this->tel=trim($this->tel);
|
|
||||||
$this->fax=trim($this->fax);
|
|
||||||
$this->url=trim($this->url);
|
|
||||||
$this->siren=trim($this->siren);
|
|
||||||
$this->siret=trim($this->siret);
|
|
||||||
$this->ape=trim($this->ape);
|
|
||||||
$this->prefix_comm=trim($this->prefix_comm);
|
|
||||||
$this->tva_intra=trim($this->tva_intra);
|
|
||||||
$this->capital=trim($this->capital);
|
|
||||||
$this->effectif_id=trim($this->effectif_id);
|
|
||||||
$this->forme_juridique_code=trim($this->forme_juridique_code);
|
|
||||||
|
|
||||||
$result = $this->verify();
|
if ($result == 0)
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Societe::Update verify ok");
|
||||||
|
|
||||||
if ($result == 0)
|
if (strlen($this->capital) == 0)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Societe::Update verify ok");
|
$this->capital = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen($this->capital) == 0)
|
$this->tel = ereg_replace(" ","",$this->tel);
|
||||||
{
|
$this->tel = ereg_replace("\.","",$this->tel);
|
||||||
$this->capital = 0;
|
$this->fax = ereg_replace(" ","",$this->fax);
|
||||||
}
|
$this->fax = ereg_replace("\.","",$this->fax);
|
||||||
|
|
||||||
$this->tel = ereg_replace(" ","",$this->tel);
|
/*
|
||||||
$this->tel = ereg_replace("\.","",$this->tel);
|
* Supression des if (trim(valeur)) pour construire la requete
|
||||||
$this->fax = ereg_replace(" ","",$this->fax);
|
* sinon il est impossible de vider les champs
|
||||||
$this->fax = ereg_replace("\.","",$this->fax);
|
*/
|
||||||
|
|
||||||
/*
|
$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
|
||||||
* \todo simpliste pour l'instant mais remplit 95% des cas à améliorer
|
$sql .= " SET nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire
|
||||||
*/
|
|
||||||
if ($this->departement_id == -1 && $this->pays_id == 1)
|
|
||||||
{
|
|
||||||
if (strlen($this->cp) == 5)
|
|
||||||
{
|
|
||||||
$depid = departement_rowid($this->db, substr($this->cp,0,2), $this->pays_id);
|
|
||||||
if ($depid > 0)
|
|
||||||
{
|
|
||||||
$this->departement_id = $depid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
$sql .= ",address = '" . addslashes($this->adresse) ."'";
|
||||||
* Supression des if (trim(valeur)) pour construire la requete
|
|
||||||
* sinon il est impossible de vider les champs
|
|
||||||
*/
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
|
if ($this->cp)
|
||||||
$sql .= " SET nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire
|
{ $sql .= ",cp = '" . $this->cp ."'"; }
|
||||||
|
|
||||||
$sql .= ",address = '" . addslashes($this->adresse) ."'";
|
if ($this->ville)
|
||||||
|
{ $sql .= ",ville = '" . addslashes($this->ville) ."'"; }
|
||||||
|
|
||||||
if ($this->cp)
|
$sql .= ",fk_departement = '" . ($this->departement_id?$this->departement_id:'0') ."'";
|
||||||
{ $sql .= ",cp = '" . $this->cp ."'"; }
|
$sql .= ",fk_pays = '" . ($this->pays_id?$this->pays_id:'0') ."'";
|
||||||
|
|
||||||
if ($this->ville)
|
$sql .= ",tel = ".($this->tel?"'".$this->tel."'":"null");
|
||||||
{ $sql .= ",ville = '" . addslashes($this->ville) ."'"; }
|
$sql .= ",fax = ".($this->fax?"'".$this->fax."'":"null");
|
||||||
|
$sql .= ",url = ".($this->url?"'".$this->url."'":"null");
|
||||||
|
|
||||||
if ($this->departement_id)
|
$sql .= ",siren = '". $this->siren ."'";
|
||||||
{ $sql .= ",fk_departement = '" . $this->departement_id ."'"; }
|
$sql .= ",siret = '". $this->siret ."'";
|
||||||
|
$sql .= ",ape = '". $this->ape ."'";
|
||||||
|
|
||||||
if ($this->pays_id)
|
$sql .= ",tva_intra = '" . $this->tva_intra ."'";
|
||||||
{ $sql .= ",fk_pays = '" . $this->pays_id ."'"; }
|
$sql .= ",capital = '" . $this->capital ."'";
|
||||||
|
|
||||||
$sql .= ",tel = ".($this->tel?"'".$this->tel."'":"null");
|
if ($this->prefix_comm) $sql .= ",prefix_comm = '" . $this->prefix_comm ."'";
|
||||||
$sql .= ",fax = ".($this->fax?"'".$this->fax."'":"null");
|
|
||||||
$sql .= ",url = ".($this->url?"'".$this->url."'":"null");
|
|
||||||
|
|
||||||
$sql .= ",siren = '". $this->siren ."'";
|
if ($this->effectif_id) $sql .= ",fk_effectif = '" . $this->effectif_id ."'";
|
||||||
$sql .= ",siret = '". $this->siret ."'";
|
|
||||||
$sql .= ",ape = '". $this->ape ."'";
|
|
||||||
|
|
||||||
$sql .= ",tva_intra = '" . $this->tva_intra ."'";
|
if ($this->typent_id) $sql .= ",fk_typent = '" . $this->typent_id ."'";
|
||||||
$sql .= ",capital = '" . $this->capital ."'";
|
|
||||||
|
|
||||||
if ($this->prefix_comm) $sql .= ",prefix_comm = '" . $this->prefix_comm ."'";
|
if ($this->forme_juridique_code) $sql .= ",fk_forme_juridique = '".$this->forme_juridique_code."'";
|
||||||
|
|
||||||
if ($this->effectif_id) $sql .= ",fk_effectif = '" . $this->effectif_id ."'";
|
$sql .= ",client = " . $this->client;
|
||||||
|
$sql .= ",fournisseur = " . $this->fournisseur;
|
||||||
|
|
||||||
if ($this->typent_id) $sql .= ",fk_typent = '" . $this->typent_id ."'";
|
if ($this->creation_bit || $this->codeclient_modifiable)
|
||||||
|
{
|
||||||
|
// Attention check_codeclient peut modifier le code
|
||||||
|
// suivant le module utilis
|
||||||
|
|
||||||
if ($this->forme_juridique_code) $sql .= ",fk_forme_juridique = '".$this->forme_juridique_code."'";
|
$this->check_codeclient();
|
||||||
|
|
||||||
$sql .= ",client = " . $this->client;
|
$sql .= ", code_client = ".($this->code_client?"'".$this->code_client."'":"null");
|
||||||
$sql .= ",fournisseur = " . $this->fournisseur;
|
|
||||||
|
|
||||||
if ($this->creation_bit || $this->codeclient_modifiable)
|
// Attention check_codecompta_client peut modifier le code
|
||||||
{
|
// suivant le module utilis
|
||||||
// Attention check_codeclient peut modifier le code
|
|
||||||
// suivant le module utilisé
|
|
||||||
|
|
||||||
$this->check_codeclient();
|
$this->check_codecompta_client();
|
||||||
|
|
||||||
$sql .= ", code_client = ".($this->code_client?"'".$this->code_client."'":"null");
|
$sql .= ", code_compta = ".($this->code_compta?"'".$this->code_compta."'":"null");
|
||||||
|
}
|
||||||
|
|
||||||
// Attention check_codecompta_client peut modifier le code
|
if ($this->creation_bit || $this->codefournisseur_modifiable)
|
||||||
// suivant le module utilisé
|
{
|
||||||
|
// Attention check_codefournisseur peut modifier le code
|
||||||
|
// suivant le module utilis
|
||||||
|
|
||||||
$this->check_codecompta_client();
|
$this->check_codefournisseur();
|
||||||
|
|
||||||
$sql .= ", code_compta = ".($this->code_compta?"'".$this->code_compta."'":"null");
|
$sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".$this->code_fournisseur."'":"null");
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->creation_bit || $this->codefournisseur_modifiable)
|
// Attention check_codecompta_fournisseur peut modifier le code
|
||||||
{
|
// suivant le module utilis
|
||||||
// Attention check_codefournisseur peut modifier le code
|
|
||||||
// suivant le module utilisé
|
|
||||||
|
|
||||||
$this->check_codefournisseur();
|
$this->check_codecompta_fournisseur();
|
||||||
|
|
||||||
$sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".$this->code_fournisseur."'":"null");
|
$sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".$this->code_compta_fournisseur."'":"null");
|
||||||
|
}
|
||||||
// Attention check_codecompta_fournisseur peut modifier le code
|
|
||||||
// suivant le module utilisé
|
|
||||||
|
|
||||||
$this->check_codecompta_fournisseur();
|
|
||||||
|
|
||||||
$sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".$this->code_compta_fournisseur."'":"null");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($user) $sql .= ",fk_user_modif = '".$user->id."'";
|
if ($user) $sql .= ",fk_user_modif = '".$user->id."'";
|
||||||
|
|
||||||
$sql .= " WHERE idp = '" . $id ."'";
|
$sql .= " WHERE idp = '" . $id ."'";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$interface->run_triggers('COMPANY_MODIFY',$this,$user,$lang,$conf);
|
$interface->run_triggers('COMPANY_MODIFY',$this,$user,$lang,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->db->errno() == DB_ERROR_RECORD_ALREADY_EXISTS)
|
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||||
{
|
{
|
||||||
// Doublon
|
// Doublon
|
||||||
$this->error = $langs->trans("ErrorPrefixAlreadyExists",$this->prefix_comm);
|
$this->error = $langs->trans("ErrorPrefixAlreadyExists",$this->prefix_comm);
|
||||||
$result = -1;
|
$result = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Societe::Update echec sql=$sql");
|
dolibarr_syslog("Societe::Update echec sql=$sql");
|
||||||
$result = -2;
|
$result = -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge depuis la base l'objet societe
|
* \brief Charge depuis la base l'objet societe
|
||||||
* \param socid Id de la société à charger en mémoire
|
* \param socid Id de la société à charger en mémoire
|
||||||
* \param user Objet de l'utilisateur
|
* \param user Objet de l'utilisateur
|
||||||
* \return int >0 si ok, <0 si erreur
|
* \return int >0 si ok, <0 si ko
|
||||||
*/
|
*/
|
||||||
function fetch($socid, $user=0)
|
function fetch($socid, $user=0)
|
||||||
{
|
{
|
||||||
@ -460,14 +441,13 @@ class Societe {
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."c_effectif as e";
|
$sql .= ", ".MAIN_DB_PREFIX."c_effectif as e";
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."c_pays as p";
|
$sql .= ", ".MAIN_DB_PREFIX."c_pays as p";
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."c_departements as d";
|
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."c_forme_juridique as fj";
|
$sql .= ", ".MAIN_DB_PREFIX."c_forme_juridique as fj";
|
||||||
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON s.fk_departement = d.rowid";
|
||||||
$sql .= " WHERE s.idp = ".$socid;
|
$sql .= " WHERE s.idp = ".$socid;
|
||||||
$sql .= " AND s.fk_stcomm = st.id";
|
$sql .= " AND s.fk_stcomm = st.id";
|
||||||
$sql .= " AND s.fk_effectif = e.id";
|
$sql .= " AND s.fk_effectif = e.id";
|
||||||
$sql .= " AND s.fk_pays = p.rowid";
|
$sql .= " AND s.fk_pays = p.rowid";
|
||||||
$sql .= " AND s.fk_departement = d.rowid";
|
|
||||||
$sql .= " AND s.fk_forme_juridique = fj.code";
|
$sql .= " AND s.fk_forme_juridique = fj.code";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
@ -568,7 +548,8 @@ class Societe {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Erreur Societe::Fetch aucune societe avec id=".$this->id);
|
dolibarr_syslog("Erreur Societe::Fetch aucune societe avec id=".$this->id." - ".$sql);
|
||||||
|
$this->error="Erreur Societe::Fetch aucune societe avec id=".$this->id." - ".$sql;
|
||||||
$result = -2;
|
$result = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,6 +559,7 @@ class Societe {
|
|||||||
{
|
{
|
||||||
dolibarr_syslog("Erreur Societe::Fetch echec sql=$sql");
|
dolibarr_syslog("Erreur Societe::Fetch echec sql=$sql");
|
||||||
dolibarr_syslog("Erreur Societe::Fetch ".$this->db->error());
|
dolibarr_syslog("Erreur Societe::Fetch ".$this->db->error());
|
||||||
|
$this->error=$this->db->error();
|
||||||
$result = -3;
|
$result = -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user