Fix: avoid warning for country with < 4 profid
This commit is contained in:
parent
f2bfaa729a
commit
3df2810f29
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -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,35 +115,75 @@ 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");
|
||||
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 '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
|
||||
if ($pid1 == '-') $pid1=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid1)
|
||||
{
|
||||
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,$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");
|
||||
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 '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
|
||||
if ($pid2 == '-') $pid2=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid2)
|
||||
{
|
||||
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,$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");
|
||||
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 '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
|
||||
if ($pid3 == '-') $pid3=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid3)
|
||||
{
|
||||
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,$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");
|
||||
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 '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
|
||||
if ($pid4 == '-') $pid4=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid4)
|
||||
{
|
||||
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,$noCountryCode);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -207,35 +249,75 @@ 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");
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
|
||||
print yn($conf->global->MAIN_PROFID1_IN_ADDRESS,1);
|
||||
print '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
|
||||
if ($pid1 == '-') $pid1=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid1)
|
||||
{
|
||||
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");
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
|
||||
print yn($conf->global->MAIN_PROFID2_IN_ADDRESS,1);
|
||||
print '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
|
||||
if ($pid2 == '-') $pid2=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid2)
|
||||
{
|
||||
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");
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
|
||||
print yn($conf->global->MAIN_PROFID3_IN_ADDRESS,1);
|
||||
print '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
|
||||
if ($pid3 == '-') $pid3=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid3)
|
||||
{
|
||||
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");
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
|
||||
print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1);
|
||||
print '</td></tr>';
|
||||
if (! $noCountryCode)
|
||||
{
|
||||
$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
|
||||
if ($pid4 == '-') $pid4=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
if ($pid4)
|
||||
{
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
|
||||
print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>'."\n";
|
||||
|
||||
|
||||
@ -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";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user