Fix: avoid warning

This commit is contained in:
Regis Houssin 2011-12-28 09:57:48 +01:00
parent f2bfaa729a
commit dce5a3e708
2 changed files with 92 additions and 31 deletions

View File

@ -37,14 +37,15 @@ $langs->load("companies");
$langs->load("products");
$langs->load("members");
if (!$user->admin)
accessforbidden();
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
/*
* Actions
*/
if (isset($_POST["action"]) && $_POST["action"] == 'update')
if ($action == 'update')
{
dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
@ -75,8 +76,9 @@ print_fiche_titre($langs->trans("PDF"),'','setup');
print $langs->trans("PDFDesc")."<br>\n";
print "<br>\n";
$noCountryCode = (empty($mysoc->country_code) ? true : false);
if (isset($_GET["action"]) && $_GET["action"] == 'edit') // Edit
if ($action == 'edit') // Edit
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -113,34 +115,62 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') // Edit
// Show prof id 1 in address into pdf
$var=!$var;
$pid1=$langs->transcountry("ProfId1",$mysoc->pays_code);
if ($pid1 == '-') $pid1=$langs->transcountry("ProfId1");
if (! $noCountryCode)
{
$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
if ($pid1 == '-') $pid1=$langs->transcountry("ProfId1");
}
else
{
$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
print $form->selectyesno('MAIN_PROFID1_IN_ADDRESS',isset($conf->global->MAIN_PROFID1_IN_ADDRESS)?$conf->global->MAIN_PROFID1_IN_ADDRESS:0,1);
print $form->selectyesno('MAIN_PROFID1_IN_ADDRESS',isset($conf->global->MAIN_PROFID1_IN_ADDRESS)?$conf->global->MAIN_PROFID1_IN_ADDRESS:0,1,$noCountryCode);
print '</td></tr>';
// Show prof id 2 in address into pdf
$var=!$var;
$pid2=$langs->transcountry("ProfId2",$mysoc->pays_code);
if ($pid2 == '-') $pid2=$langs->transcountry("ProfId2");
if (! $noCountryCode)
{
$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
if ($pid2 == '-') $pid2=$langs->transcountry("ProfId2");
}
else
{
$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
print $form->selectyesno('MAIN_PROFID2_IN_ADDRESS',isset($conf->global->MAIN_PROFID2_IN_ADDRESS)?$conf->global->MAIN_PROFID2_IN_ADDRESS:0,1);
print $form->selectyesno('MAIN_PROFID2_IN_ADDRESS',isset($conf->global->MAIN_PROFID2_IN_ADDRESS)?$conf->global->MAIN_PROFID2_IN_ADDRESS:0,1,$noCountryCode);
print '</td></tr>';
// Show prof id 3 in address into pdf
$var=!$var;
$pid3=$langs->transcountry("ProfId3",$mysoc->pays_code);
if ($pid3 == '-') $pid3=$langs->transcountry("ProfId3");
if (! $noCountryCode)
{
$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
if ($pid3 == '-') $pid3=$langs->transcountry("ProfId3");
}
else
{
$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
print $form->selectyesno('MAIN_PROFID3_IN_ADDRESS',isset($conf->global->MAIN_PROFID3_IN_ADDRESS)?$conf->global->MAIN_PROFID3_IN_ADDRESS:0,1);
print $form->selectyesno('MAIN_PROFID3_IN_ADDRESS',isset($conf->global->MAIN_PROFID3_IN_ADDRESS)?$conf->global->MAIN_PROFID3_IN_ADDRESS:0,1,$noCountryCode);
print '</td></tr>';
// Show prof id 4 in address into pdf
$var=!$var;
$pid4=$langs->transcountry("ProfId4",$mysoc->pays_code);
if ($pid4 == '-') $pid4=$langs->transcountry("ProfId4");
if (! $noCountryCode)
{
$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
if ($pid4 == '-') $pid4=$langs->transcountry("ProfId4");
}
else
{
$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
print $form->selectyesno('MAIN_PROFID4_IN_ADDRESS',isset($conf->global->MAIN_PROFID4_IN_ADDRESS)?$conf->global->MAIN_PROFID4_IN_ADDRESS:0,1);
print $form->selectyesno('MAIN_PROFID4_IN_ADDRESS',isset($conf->global->MAIN_PROFID4_IN_ADDRESS)?$conf->global->MAIN_PROFID4_IN_ADDRESS:0,1,$noCountryCode);
print '</td></tr>';
print '</table>';
@ -207,32 +237,60 @@ else // Show
// Show prof id 1 in address into pdf
$var=!$var;
$pid1=$langs->transcountry("ProfId1",$mysoc->pays_code);
if ($pid1 == '-') $pid1=$langs->transcountry("ProfId1");
if (! $noCountryCode)
{
$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
if ($pid1 == '-') $pid1=$langs->transcountry("ProfId1");
}
else
{
$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
print yn($conf->global->MAIN_PROFID1_IN_ADDRESS,1);
print '</td></tr>';
// Show prof id 2 in address into pdf
$var=!$var;
$pid2=$langs->transcountry("ProfId2",$mysoc->pays_code);
if ($pid2 == '-') $pid2=$langs->transcountry("ProfId2");
if (! $noCountryCode)
{
$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
if ($pid2 == '-') $pid2=$langs->transcountry("ProfId2");
}
else
{
$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
print yn($conf->global->MAIN_PROFID2_IN_ADDRESS,1);
print '</td></tr>';
// Show prof id 3 in address into pdf
$var=!$var;
$pid3=$langs->transcountry("ProfId3",$mysoc->pays_code);
if ($pid3 == '-') $pid3=$langs->transcountry("ProfId3");
if (! $noCountryCode)
{
$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
if ($pid3 == '-') $pid3=$langs->transcountry("ProfId3");
}
else
{
$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
print yn($conf->global->MAIN_PROFID3_IN_ADDRESS,1);
print '</td></tr>';
// Show prof id 4 in address into pdf
$var=!$var;
$pid4=$langs->transcountry("ProfId4",$mysoc->pays_code);
if ($pid4 == '-') $pid4=$langs->transcountry("ProfId4");
if (! $noCountryCode)
{
$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
if ($pid4 == '-') $pid4=$langs->transcountry("ProfId4");
}
else
{
$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
}
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1);
print '</td></tr>';

View File

@ -3528,14 +3528,15 @@ class Form
/**
* Return an html string with a select combo box to choose yes or no
* Return an html string with a select combo box to choose yes or no
*
* @param name Name of html select field
* @param value Pre-selected value
* @param option 0 return yes/no, 1 return 1/0
* @return int or string See option
* @param string $name Name of html select field
* @param string $value Pre-selected value
* @param int $option 0 return yes/no, 1 return 1/0
* @param bool $disabled true or false
* @return mixed See option
*/
function selectyesno($htmlname,$value='',$option=0)
function selectyesno($htmlname,$value='',$option=0,$disabled=false)
{
global $langs;
@ -3546,8 +3547,10 @@ class Form
$yes="1";
$no="0";
}
$disabled = ($disabled ? ' disabled="disabled"' : '');
$resultyesno = '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'."\n";
$resultyesno = '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n";
if (("$value" == 'yes') || ($value == 1))
{
$resultyesno .= '<option value="'.$yes.'" selected="selected">'.$langs->trans("Yes").'</option>'."\n";