From dce5a3e708955533926dc1efe7a090cf0a1681ad Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 28 Dec 2011 09:57:48 +0100 Subject: [PATCH] Fix: avoid warning --- htdocs/admin/pdf.php | 106 ++++++++++++++++++++------ htdocs/core/class/html.form.class.php | 17 +++-- 2 files changed, 92 insertions(+), 31 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index abbc1e038c5..044b57689d8 100755 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -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")."
\n"; print "
\n"; +$noCountryCode = (empty($mysoc->country_code) ? true : false); -if (isset($_GET["action"]) && $_GET["action"] == 'edit') // Edit +if ($action == 'edit') // Edit { print '
'; print ''; @@ -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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid1.''; - 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 ''; // 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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid2.''; - 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 ''; // 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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid3.''; - 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 ''; // 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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid4.''; - 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 ''; print ''; @@ -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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid1.''; print yn($conf->global->MAIN_PROFID1_IN_ADDRESS,1); print ''; // 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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid2.''; print yn($conf->global->MAIN_PROFID2_IN_ADDRESS,1); print ''; // 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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid3.''; print yn($conf->global->MAIN_PROFID3_IN_ADDRESS,1); print ''; // 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().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid4.''; print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1); print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ba5e55398bc..70c61bc5891 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -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 = ''."\n"; if (("$value" == 'yes') || ($value == 1)) { $resultyesno .= ''."\n";