Fix: Quand on crée un tiers de type personne individu, on avait plus accès à des champs qui peuvent exister meme pour un individu physique (ex indépendant en EURL).

Fix: Le champ type de tiers n'était pas renseigné à particulier qd on créé un particulier.
De plus, un particulier doit rester appelé "tiers" pour mieux comprendre la compta.
Je modifie donc la "présentation" de la fonctionnalité du mode de création des triers de type particulier pour etre moins perturbante et gérer le champ type et j'ajoute le texte "Créera automatiquement un contact physique avec info identiques".
This commit is contained in:
Laurent Destailleur 2007-04-26 18:22:33 +00:00
parent d4569d10e6
commit 64c8da5a73
6 changed files with 336 additions and 315 deletions

View File

@ -180,7 +180,7 @@ class MenuLeft {
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
$newmenu->add_submenu(DOL_URL_ROOT."/soc.php?action=create", $langs->trans("MenuNewThirdParty")); $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?action=create", $langs->trans("MenuNewThirdParty"));
$newmenu->add_submenu(DOL_URL_ROOT."/soc.php?action=create&private=1",$langs->trans("MenuNewPrivateIndividual")); if (! $conf->use_javascript) $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?action=create&private=1",$langs->trans("MenuNewPrivateIndividual"));
} }
if(is_dir("societe/groupe")) if(is_dir("societe/groupe"))

View File

@ -29,6 +29,10 @@ ThirdPartyProspects=Prospects
ThirdPartyCustomers=Customers ThirdPartyCustomers=Customers
ThirdPartyCustomersWithIdProf12=Customers with %s or %s ThirdPartyCustomersWithIdProf12=Customers with %s or %s
ThirdPartySuppliers=Suppliers ThirdPartySuppliers=Suppliers
ThirdPartyType=Third party type
Company/Fundation=Company/Fundation
Individual=Private individual
ToCreateContactWithSameName=Will create automatically a physical contact with same informations
ParentCompany=Parent company ParentCompany=Parent company
ReportByCustomers=Report by customers ReportByCustomers=Report by customers
ReportByQuarter=Report by quarter ReportByQuarter=Report by quarter

View File

@ -29,6 +29,10 @@ ThirdPartyProspects=Prospets
ThirdPartyCustomers=Clients ThirdPartyCustomers=Clients
ThirdPartyCustomersWithIdProf12=Clients avec %s ou %s ThirdPartyCustomersWithIdProf12=Clients avec %s ou %s
ThirdPartySuppliers=Fournisseurs ThirdPartySuppliers=Fournisseurs
ThirdPartyType=Type du tiers
Company/Fundation=Société/Association
Individual=Individu privé
ToCreateContactWithSameName=Créera automatiquement un contact physique avec info identiques
ReportByCustomers=Rapport par client ReportByCustomers=Rapport par client
ReportByQuarter=Rapport par trimestre ReportByQuarter=Rapport par trimestre
ParentCompany=Maison mère ParentCompany=Maison mère

View File

@ -7,6 +7,13 @@
// \version $Revision$ // \version $Revision$
function dolibarr_type_reload(param)
{
document.formsoc.action.value="create";
document.formsoc.private.value=param;
document.formsoc.cleartype.value=1;
document.formsoc.submit();
}
/*================================================================= /*=================================================================
Purpose: Pour la fonction de saisie auto des villes Purpose: Pour la fonction de saisie auto des villes

View File

@ -92,12 +92,12 @@ if ($_POST["getsuppliercode"])
if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
&& ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer) && ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer)
{ {
if ($_POST["private"] == 1) if ($_REQUEST["private"] == 1)
{ {
$soc->nom = $_POST["nom"].' '.$_POST["prenom"]; $soc->nom = $_POST["nom"].' '.$_POST["prenom"];
$soc->nom_particulier = $_POST["nom"]; $soc->nom_particulier = $_POST["nom"];
$soc->prenom = $_POST["prenom"]; $soc->prenom = $_POST["prenom"];
$soc->particulier = $_POST["private"]; $soc->particulier = $_REQUEST["private"];
} }
else else
{ {
@ -128,7 +128,7 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
$soc->forme_juridique_code = $_POST["forme_juridique_code"]; $soc->forme_juridique_code = $_POST["forme_juridique_code"];
$soc->effectif_id = $_POST["effectif_id"]; $soc->effectif_id = $_POST["effectif_id"];
if ($_POST["private"] == 1) if ($_REQUEST["private"] == 1)
{ {
$soc->typent_id = 8; //todo prévoir autre méthode si le champs "particulier" change de rowid $soc->typent_id = 8; //todo prévoir autre méthode si le champs "particulier" change de rowid
} }
@ -240,8 +240,8 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
/* /*
* Fiche en mode creation * Fiche en mode creation
*/ */
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
// Charge objet modCodeTiers // Charge objet modCodeTiers
$module=$conf->global->SOCIETE_CODECLIENT_ADDON; $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
@ -259,327 +259,325 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
} }
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
$modCodeFournisseur = new $module; $modCodeFournisseur = new $module;
/* /*
* Fiche societe en mode création * Fiche societe en mode création
*/ */
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 ($_GET["private"]==1) { $soc->particulier=1; } if ($_REQUEST["private"]==1) { $soc->particulier=1; }
if ($_POST["nom"])
{
$soc->nom=$_POST["nom"];
$soc->prenom=$_POST["prenom"];
$soc->particulier=$_POST["private"];
$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->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"];
$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"];
$soc->commercial_id=$_POST["commercial_id"];
}
// On positionne pays_id, pays_code et libelle du pays choisi $soc->nom=$_POST["nom"];
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; $soc->prenom=$_POST["prenom"];
if ($soc->pays_id) $soc->particulier=$_REQUEST["private"];
{ $soc->prefix_comm=$_POST["prefix_comm"];
$sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; $soc->client=$_POST["client"];
$resql=$db->query($sql); $soc->code_client=$_POST["code_client"];
if ($resql) $soc->fournisseur=$_POST["fournisseur"];
{ $soc->code_fournisseur=$_POST["code_fournisseur"];
$obj = $db->fetch_object($resql); $soc->adresse=$_POST["adresse"];
} $soc->cp=$_POST["cp"];
else $soc->ville=$_POST["ville"];
{ $soc->departement_id=$_POST["departement_id"];
dolibarr_print_error($db); $soc->tel=$_POST["tel"];
} $soc->fax=$_POST["fax"];
$soc->pays_code=$obj->code; $soc->email=$_POST["email"];
$soc->pays=$obj->libelle; $soc->url=$_POST["url"];
} $soc->capital=$_POST["capital"];
$soc->siren=$_POST["idprof1"];
if (!$soc->particulier) $soc->siret=$_POST["idprof2"];
{ $soc->ape=$_POST["idprof3"];
print_titre($langs->trans("NewCompany")); $soc->idprof4=$_POST["idprof4"];
} $soc->typent_id=($_POST["typent_id"]&&!$_POST["cleartype"])?$_POST["typent_id"]:($_REQUEST["private"]?'TE_PRIVATE':'');
else $soc->effectif_id=($_POST["effectif_id"]&&!$_POST["cleartype"])?$_POST["effectif_id_id"]:($_REQUEST["private"]?'EF1-5':'');
{
print_titre($langs->trans("NewPrivateIndividual")); $soc->tva_assuj = $_POST["assujtva_value"];
} $soc->tva_intra_code=$_POST["tva_intra_code"];
print "<br>\n"; $soc->tva_intra_num=$_POST["tva_intra_num"];
if ($soc->error) $soc->commercial_id=$_POST["commercial_id"];
{
print '<div class="error">';
print nl2br($soc->error);
print '</div>';
}
print '<form action="soc.php" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="private" value='.$soc->particulier.'>';
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>';
if ($soc->particulier)
{
print '<tr><td>'.$langs->trans('FirstName').'</td><td><input type="text" size="30" name="prenom" value="'.$soc->firstname.'"></td>';
print '<td colspan=2>&nbsp;</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="true"':'').'>'.$langs->trans('Prospect').'</option>';
print '<option value="1"'.($soc->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>';
print '<option value="0"'.($soc->client==0?' selected="true"':'').'>Ni client, ni prospect</option>';
print '</select></td>';
print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">'; // On positionne pays_id, pays_code et libelle du pays choisi
print '<table class="nobordernopadding"><tr><td>'; $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">'; if ($soc->pays_id)
print '</td><td>'; {
$s=$langs->trans("CustomerCodeDesc").'<br>'; $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id;
$s.=$langs->trans("ValidityControledByModule").': <b>'.$modCodeClient->getNom($langs).'</b><br>'; $resql=$db->query($sql);
$s.=$langs->trans("RequiredIfCustomer").': <b>'.yn(!$modCodeClient->code_null).'</b><br>'; if ($resql)
$s.=$langs->trans("Example").': <b>'.$modCodeClient->getExample($langs).'</b>'; {
print $form->textwithhelp('',$s,1); $obj = $db->fetch_object($resql);
print '</td></tr></table>'; }
else
{
dolibarr_print_error($db);
}
$soc->pays_code=$obj->code;
$soc->pays=$obj->libelle;
}
print_titre($langs->trans("NewCompany"));
print '</td></tr>'; //$conf->use_javascript=0;
if ($conf->use_javascript)
{
print "<br>\n";
print $langs->trans("ThirdPartyType").': &nbsp; ';
print '<input type="radio" class="flat" name="private" value="0"'.(! $_REQUEST["private"]?' checked="true"':'');
print 'onclick="dolibarr_type_reload(0)"';
print '> '.$langs->trans("Company/Fundation");
print ' &nbsp; &nbsp; ';
print '<input type="radio" class="flat" name="private" value="1"'.(! $_REQUEST["private"]?'':' checked="true"');
print 'onclick="dolibarr_type_reload(1)"';
print '> '.$langs->trans("Individual");
print ' ('.$langs->trans("ToCreateContactWithSameName").')';
print "<br>\n";
print "<br>\n";
}
if ($soc->error)
{
print '<div class="error">';
print nl2br($soc->error);
print '</div>';
}
print '<form action="soc.php" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="cleartype" value="0">';
print '<input type="hidden" name="private" value='.$soc->particulier.'>';
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>';
if ($soc->particulier)
{
print '<tr><td>'.$langs->trans('FirstName').'</td><td><input type="text" size="30" name="prenom" value="'.$soc->firstname.'"></td>';
print '<td colspan=2>&nbsp;</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="true"':'').'>'.$langs->trans('Prospect').'</option>';
print '<option value="1"'.($soc->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>';
print '<option value="0"'.($soc->client==0?' selected="true"':'').'>Ni client, ni prospect</option>';
print '</select></td>';
// Fournisseur print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
print '<tr>'; print '<table class="nobordernopadding"><tr><td>';
print '<td>'.$langs->trans('Supplier').'</td><td>'; print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">';
$form->selectyesnonum("fournisseur",$soc->fournisseur); print '</td><td>';
print '</td>'; $s=$langs->trans("CustomerCodeDesc").'<br>';
print '<td>'.$langs->trans('SupplierCode').'</td><td>'; $s.=$langs->trans("ValidityControledByModule").': <b>'.$modCodeClient->getNom($langs).'</b><br>';
$s.=$langs->trans("RequiredIfCustomer").': <b>'.yn(!$modCodeClient->code_null).'</b><br>';
print '<table class="nobordernopadding"><tr><td>'; $s.=$langs->trans("Example").': <b>'.$modCodeClient->getExample($langs).'</b>';
print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">'; print $form->textwithhelp('',$s,1);
print '</td><td>'; print '</td></tr></table>';
$s=$langs->trans("SupplierCodeDesc").'<br>';
$s.=$langs->trans("ValidityControledByModule").': <b>'.$modCodeFournisseur->getNom($langs).'</b><br>';
$s.=$langs->trans("RequiredIfSupplier").': <b>'.yn(!$modCodeFournisseur->code_null).'</b><br>';
$s.=$langs->trans("Example").': <b>'.$modCodeFournisseur->getExample($langs).'</b>';
print $form->textwithhelp('',$s,1);
print '</td></tr></table>';
print '</td></tr>'; print '</td></tr>';
if ($soc->fournisseur) // Fournisseur
{ print '<tr>';
$load = $soc->LoadSupplierCateg(); print '<td>'.$langs->trans('Supplier').'</td><td>';
if ( $load == 0) $form->selectyesnonum("fournisseur",$soc->fournisseur);
{ print '</td>';
if (sizeof($soc->SupplierCategories) > 0) print '<td>'.$langs->trans('SupplierCode').'</td><td>';
{
print '<tr>'; print '<table class="nobordernopadding"><tr><td>';
print '<td>'.$langs->trans('SupplierCategory').'</td><td colspan="3">'; print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">';
$form->select_array("fournisseur_categorie",$soc->SupplierCategories); print '</td><td>';
print '</td></tr>'; $s=$langs->trans("SupplierCodeDesc").'<br>';
} $s.=$langs->trans("ValidityControledByModule").': <b>'.$modCodeFournisseur->getNom($langs).'</b><br>';
} $s.=$langs->trans("RequiredIfSupplier").': <b>'.yn(!$modCodeFournisseur->code_null).'</b><br>';
} $s.=$langs->trans("Example").': <b>'.$modCodeFournisseur->getExample($langs).'</b>';
print $form->textwithhelp('',$s,1);
print '</td></tr></table>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">'; print '</td></tr>';
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 ($soc->fournisseur)
if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; {
print '>'; $load = $soc->LoadSupplierCateg();
if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">'; if ( $load == 0)
print '</td>'; {
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>'; if (sizeof($soc->SupplierCategories) > 0)
{
print '<tr>';
print '<td>'.$langs->trans('SupplierCategory').'</td><td colspan="3">';
$form->select_array("fournisseur_categorie",$soc->SupplierCategories);
print '</td></tr>';
}
}
}
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
$form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':''); print $soc->adresse;
if ($conf->use_javascript && $conf->use_ajax) print '<div id="hint"></div>';//utile pour afficher la recherche des pays avec ajax print '</textarea></td></tr>';
print '</td></tr>';
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"';
if ($soc->pays_id) if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"';
{ print '>';
$form->select_departement($soc->departement_id,$soc->pays_code); if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">';
} print '</td>';
else print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
{
print $countrynotdefined;
}
print '</td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>'; print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>'; $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':'');
if ($conf->use_javascript && $conf->use_ajax) print '<div id="hint"></div>';//utile pour afficher la recherche des pays avec ajax
print '</td></tr>';
print '<tr><td>'.$langs->trans('EMail').'</td><td><input type="text" name="email" size="32" value="'.$soc->email.'"></td>'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
print '<td>'.$langs->trans('Web').'</td><td><input type="text" name="url" size="32" value="'.$soc->url.'"></td></tr>'; if ($soc->pays_id)
{
$form->select_departement($soc->departement_id,$soc->pays_code);
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
if (!$soc->particulier) 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('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
if ($soc->pays_code == 'FR') print '<tr><td>'.$langs->trans('EMail').'</td><td><input type="text" name="email" size="32" value="'.$soc->email.'"></td>';
{ print '<td>'.$langs->trans('Web').'</td><td><input type="text" name="url" size="32" value="'.$soc->url.'"></td></tr>';
$maxlength1=9;
$maxlength2=14;
$maxlength3=4;
$maxlength4=12;
}
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="idprof1" size="15" maxlength="'.$maxlength1.'" value="'.$soc->siren.'">';
else print '&nbsp;';
}
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="idprof2" size="15" maxlength="'.$maxlength2.'" value="'.$soc->siret.'">';
else print '&nbsp;';
}
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="idprof3" size="15" maxlength="'.$maxlength3.'" value="'.$soc->ape.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td>';
print '<td>'.($langs->transcountry("ProfId4",$soc->pays_code) != '-'?$langs->transcountry('ProfId4',$soc->pays_code):'').'</td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId4",$soc->pays_code) != '-') print '<input type="text" name="idprof4" size="15" maxlength="'.$maxlength4.'" value="'.$soc->idprof4.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
// Forme juridique 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>';
print '<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>'."\n"; if ($soc->pays_code == 'FR')
$form->select_array("typent_id",$soc->typent_array(), $soc->typent_id); {
print '</td>'; $maxlength1=9;
print '<td>'.$langs->trans("Staff").'</td><td>'; $maxlength2=14;
$form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); $maxlength3=4;
print '</td></tr>'; $maxlength4=12;
} }
// Id prof
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="idprof1" size="15" maxlength="'.$maxlength1.'" value="'.$soc->siren.'">';
else print '&nbsp;';
}
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="idprof2" size="15" maxlength="'.$maxlength2.'" value="'.$soc->siret.'">';
else print '&nbsp;';
}
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="idprof3" size="15" maxlength="'.$maxlength3.'" value="'.$soc->ape.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td>';
print '<td>'.($langs->transcountry("ProfId4",$soc->pays_code) != '-'?$langs->transcountry('ProfId4',$soc->pays_code):'').'</td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId4",$soc->pays_code) != '-') print '<input type="text" name="idprof4" size="15" maxlength="'.$maxlength4.'" value="'.$soc->idprof4.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
// Assujeti TVA // Forme juridique
$html = new Form($db); print '<tr><td>'.$langs->trans('JuridicalStatus').'</td>';
print '<tr><td>'.$langs->trans('VATIsUsed').'</td>'; print '<td colspan="3">';
if ($soc->particulier) if ($soc->pays_id)
{ {
print '<td colspan="3">'; $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
} }
else else
{ {
print '<td>'; print $countrynotdefined;
} }
$html->select_YesNo("1",'assujtva_value'); // Assujeti par défaut en creation print '</td></tr>';
print '</td>';
print '<tr><td>'.$langs->trans("Type").'</td><td>'."\n";
$form->select_array("typent_id",$soc->typent_array(1), $soc->typent_id);
print '</td>';
print '<td>'.$langs->trans("Staff").'</td><td>';
$form->select_array("effectif_id",$soc->effectif_array(1), $soc->effectif_id);
print '</td></tr>';
// Assujeti TVA
$html = new Form($db);
print '<tr><td>'.$langs->trans('VATIsUsed').'</td>';
print '<td>';
$html->select_YesNo("1",'assujtva_value'); // Assujeti par défaut en creation
print '</td>';
// Code TVA intra // Code TVA intra
if (!$soc->particulier) if ($conf->use_javascript)
{ {
if ($conf->use_javascript) print "\n";
{ print '<script language="JavaScript" type="text/javascript">';
print "\n"; print "function CheckVAT(a,b) {\n";
print '<script language="JavaScript" type="text/javascript">'; print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?countryCode='+a+'&vatNumber='+b,'".$langs->trans("VATIntraCheckableOnEUSite")."',500,230);\n";
print "function CheckVAT(a,b) {\n"; print "}\n";
print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?countryCode='+a+'&vatNumber='+b,'".$langs->trans("VATIntraCheckableOnEUSite")."',500,230);\n"; print '</script>';
print "}\n"; print "\n";
print '</script>'; }
print "\n"; print '<td nowrap="nowrap">'.$langs->trans('VATIntraShort').'</td>';
} print '<td nowrap="nowrap">';
print '<td nowrap="nowrap">'.$langs->trans('VATIntraShort').'</td>'; $s ='<input type="text" class="flat" name="tva_intra_code" size="1" maxlength="2" value="'.$soc->tva_intra_code.'">';
print '<td nowrap="nowrap">'; $s.='<input type="text" class="flat" name="tva_intra_num" size="12" maxlength="18" value="'.$soc->tva_intra_num.'">';
$s ='<input type="text" class="flat" name="tva_intra_code" size="1" maxlength="2" value="'.$soc->tva_intra_code.'">'; $s.=' ';
$s.='<input type="text" class="flat" name="tva_intra_num" size="12" maxlength="18" value="'.$soc->tva_intra_num.'">'; if ($conf->use_javascript)
$s.=' '; {
if ($conf->use_javascript) $s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra_code.value,document.formsoc.tva_intra_num.value);" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.$langs->trans("VATIntraCheck").'</a>';
{ print $form->textwithhelp($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
$s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra_code.value,document.formsoc.tva_intra_num.value);" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.$langs->trans("VATIntraCheck").'</a>'; }
print $form->textwithhelp($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); else
} {
else print $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
{ }
print $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; print '</td>';
}
print '</td>'; print '</tr>';
}
print '</tr>'; if ($user->rights->commercial->client->voir)
{
if ($user->rights->commercial->client->voir) //Affecter un commercial
{ print '<tr>';
//Affecter un commercial print '<td>'.$langs->trans("AllocateCommercial").'</td>';
print '<tr>'; print '<td colspan="3">';
print '<td>'.$langs->trans("AllocateCommercial").'</td>'; $form->select_users($soc->commercial_id,'commercial_id',1);
print '<td colspan="3">'; print '</td></tr>';
$form->select_users($soc->commercial_id,'commercial_id',1); }
print '</td></tr>';
}
print '<tr><td colspan="4" align="center">'; print '<tr><td colspan="4" align="center">';
print '<input type="submit" class="button" value="'.$langs->trans('AddThirdParty').'"></td></tr>'."\n"; print '<input type="submit" class="button" value="'.$langs->trans('AddThirdParty').'"></td></tr>'."\n";
print '</table>'."\n"; print '</table>'."\n";
print '</form>'."\n"; print '</form>'."\n";
} }
} }
elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
{ {

View File

@ -1308,10 +1308,11 @@ class Societe
/** /**
* \brief Renvoie la liste des libellés traduits des types actifs de sociétés * \brief Renvoie la liste des libellés traduits des types actifs de sociétés
* \return array tableau des types * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
* \return array tableau des typesl
*/ */
function typent_array() function typent_array($mode=0)
{ {
global $langs; global $langs;
@ -1330,10 +1331,13 @@ class Societe
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
if (! $mode) $key=$objp->id;
else $key=$objp->code;
if ($langs->trans($objp->code) != $objp->code) if ($langs->trans($objp->code) != $objp->code)
$effs[$objp->id] = $langs->trans($objp->code); $effs[$key] = $langs->trans($objp->code);
else else
$effs[$objp->id] = $objp->libelle!='-'?$objp->libelle:''; $effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
$i++; $i++;
} }
$this->db->free($result); $this->db->free($result);
@ -1344,14 +1348,15 @@ class Societe
/** /**
* \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) * \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
* \return array tableau des types d'effectifs * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
* \return array tableau des types d'effectifs
*/ */
function effectif_array() function effectif_array($mode=0)
{ {
$effs = array(); $effs = array();
$sql = "SELECT id, libelle"; $sql = "SELECT id, code, libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif";
$sql .= " ORDER BY id ASC"; $sql .= " ORDER BY id ASC";
if ($this->db->query($sql)) if ($this->db->query($sql))
@ -1362,7 +1367,10 @@ class Societe
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object(); $objp = $this->db->fetch_object();
$effs[$objp->id] = $objp->libelle!='-'?$objp->libelle:''; if (! $mode) $key=$objp->id;
else $key=$objp->code;
$effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
$i++; $i++;
} }
$this->db->free(); $this->db->free();