Skip to content
Snippets Groups Projects
Commit 8fd3642d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Error if country not defined

parent ded13125
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@
/**
* \file htdocs/compta/sociales/index.php
* \ingroup tax
* \brief Ecran des charges sociales
* \brief Page to list all social contributions
* \version $Id$
*/
......@@ -130,83 +130,96 @@ if ($resql)
print $mesg."<br>";
}
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"index.php","id","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"index.php","s.libelle","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),"index.php","type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PeriodEndDate"),"index.php","periode","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),"index.php","s.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDue"),"index.php","de","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","",$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
// Type
print '<td class="liste_titre" align="left">';
$html->select_type_socialcontrib($typeid,'typeid',1,16,0);
print '</td>';
// Period end date
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
print '</td>';
print "</tr>\n";
while ($i < min($num,$limit))
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
{
$obj = $db->fetch_object($resql);
$var = !$var;
print "<tr $bc[$var]>";
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
// Ref
print '<td width="60">';
$chargesociale_static->id=$obj->id;
$chargesociale_static->lib=$obj->id;
$chargesociale_static->ref=$obj->id;
print $chargesociale_static->getNomUrl(1,'20');
print '</td>';
print "<table class=\"noborder\" width=\"100%\">";
// Label
print '<td>'.dol_trunc($obj->libelle,42).'</td>';
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"index.php","id","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"index.php","s.libelle","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),"index.php","type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PeriodEndDate"),"index.php","periode","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),"index.php","s.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDue"),"index.php","de","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","",$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
// Type
print '<td>'.dol_trunc($obj->type_lib,16).'</td>';
print '<td class="liste_titre" align="left">';
$html->select_type_socialcontrib($typeid,'typeid',1,16,0);
print '</td>';
// Period end date
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
print '</td>';
print "</tr>\n";
// Date end period
print '<td align="center">';
if ($obj->periode)
while ($i < min($num,$limit))
{
print '<a href="index.php?year='.strftime("%Y",$db->jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode),'day').'</a>';
$obj = $db->fetch_object($resql);
$var = !$var;
print "<tr $bc[$var]>";
// Ref
print '<td width="60">';
$chargesociale_static->id=$obj->id;
$chargesociale_static->lib=$obj->id;
$chargesociale_static->ref=$obj->id;
print $chargesociale_static->getNomUrl(1,'20');
print '</td>';
// Label
print '<td>'.dol_trunc($obj->libelle,42).'</td>';
// Type
print '<td>'.dol_trunc($obj->type_lib,16).'</td>';
// Date end period
print '<td align="center">';
if ($obj->periode)
{
print '<a href="index.php?year='.strftime("%Y",$db->jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode),'day').'</a>';
}
else
{
print '&nbsp;';
}
print '</td>';
print '<td align="right" width="100">'.price($obj->amount).'</td>';
// Due date
print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->de), 'day').'</td>';
print '<td align="right" nowrap="nowrap">'.$chargesociale_static->LibStatut($obj->paye,5).'</a></td>';
print '</tr>';
$i++;
}
else
{
print '&nbsp;';
}
print '</td>';
print '<td align="right" width="100">'.price($obj->amount).'</td>';
// Due date
print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->de), 'day').'</td>';
print '</table>';
print '<td align="right" nowrap="nowrap">'.$chargesociale_static->LibStatut($obj->paye,5).'</a></td>';
print '</tr>';
$i++;
print '</form>';
}
print '</table>';
print '</form>';
}
else
{
......
......@@ -345,7 +345,7 @@ class Form
/**
* \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 htmlname Name of field in form
* \param useempty Set to 1 if we want an empty value
......@@ -356,7 +356,11 @@ class Form
{
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))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment