Fix: Error if country not defined

This commit is contained in:
Laurent Destailleur 2010-07-29 13:33:29 +00:00
parent ded13125c8
commit 8fd3642de0
2 changed files with 92 additions and 75 deletions

View File

@ -21,7 +21,7 @@
/** /**
* \file htdocs/compta/sociales/index.php * \file htdocs/compta/sociales/index.php
* \ingroup tax * \ingroup tax
* \brief Ecran des charges sociales * \brief Page to list all social contributions
* \version $Id$ * \version $Id$
*/ */
@ -130,6 +130,18 @@ if ($resql)
print $mesg."<br>"; print $mesg."<br>";
} }
if (empty($mysoc->pays_id) && empty($mysoc->pays_code))
{
print '<div class="error">';
$langs->load("errors");
$countrynotdefined=$langs->trans("ErrorSetACountryFirst");
print $countrynotdefined;
print '</div>';
}
else
{
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
@ -207,6 +219,7 @@ if ($resql)
print '</table>'; print '</table>';
print '</form>'; print '</form>';
}
} }
else else
{ {

View File

@ -345,7 +345,7 @@ class Form
/** /**
* \brief Return list of social contributions. * \brief Return list of social contributions.
* \remarks Use mysoc->pays_id or mysoc->pays_code * \remarks Use mysoc->pays_id or mysoc->pays_code so they must be defined.
* \param selected Preselected type * \param selected Preselected type
* \param htmlname Name of field in form * \param htmlname Name of field in form
* \param useempty Set to 1 if we want an empty value * \param useempty Set to 1 if we want an empty value
@ -356,7 +356,11 @@ class Form
{ {
global $db,$langs,$user,$mysoc; global $db,$langs,$user,$mysoc;
if (empty($mysoc->pays_id) && empty($mysoc->pays_code)) dol_print_error('','ErrorBadParameter'); if (empty($mysoc->pays_id) && empty($mysoc->pays_code))
{
dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
exit;
}
if (! empty($mysoc->pays_id)) if (! empty($mysoc->pays_id))
{ {