From 4f2f56fced7a8c5ce64b4420c29ef55e936b8400 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 30 Nov 2012 18:46:05 +0100 Subject: [PATCH] New: [ task #314 ] Can define if prof id are mandatory or not --- htdocs/langs/ca_ES/admin.lang | 1 + htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/es_ES/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/societe/admin/societe.php | 50 ++++++++++++++++++++++---------- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index 9c10b0fb1f7..768607eca53 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -963,6 +963,7 @@ DocumentModelOdt=Generació des dels documents amb format OpenDocument (Arxiu .O WatermarkOnDraft=Marca d'aigua en els documents esborrany CompanyIdProfChecker=Id Professional únic MustBeUnique=Ha de ser únic? +MustBeMandatory=Ha de ser obligatori? Miscellanous=Miscel·lània ##### Webcal setup ##### WebCalSetup=Configuració d'enllaç amb el calendari webcalendar diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6eb9b59b168..0919133f936 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -953,6 +953,7 @@ DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT files for WatermarkOnDraft=Watermark on draft document CompanyIdProfChecker=Professional Id unique MustBeUnique=Must be unique ? +MustBeMandatory=Must be mandatory ? Miscellanous=Miscellaneous ##### Webcal setup ##### WebCalSetup=Webcalendar link setup diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index 63d3180e8a9..7a7a53a6654 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -966,6 +966,7 @@ DocumentModelOdt=Generación desde los documentos OpenDocument (Archivo .ODT Ope WatermarkOnDraft=Marca de agua en los documentos borrador CompanyIdProfChecker=Id Profesional único MustBeUnique=¿Debe ser único? +MustBeMandatory=¿Debe ser obligatorio? Miscellanous=Miscelánea ##### Webcal setup ##### WebCalSetup=Configuración de enlace con el calendario Webcalendar diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 089ae7f5cda..67c1c1f6e19 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -960,6 +960,7 @@ DocumentModelOdt=Genération depuis des modèles OpenDocument (Fichier .ODT Open WatermarkOnDraft=Filigrane sur les documents brouillons CompanyIdProfChecker=Id professionel unique MustBeUnique=Doit être unique ? +MustBeMandatory=Doit être obligatoire? Miscellanous=Divers ##### Webcal setup ##### WebCalSetup= Configuration du lien vers le calendrier Webcalendar diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index bfff310636f..e058869d586 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -195,6 +195,23 @@ if ($action == 'setprofid') } } +//Activate ProfId +if ($action == 'setprofidmandatory') +{ + $status = GETPOST('status','alpha'); + + $idprof="SOCIETE_IDPROF".$value."_MANDATORY"; + if (dolibarr_set_const($db, $idprof,$status,'chaine',0,'',$conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + /* * View @@ -522,6 +539,7 @@ print ''; print ''.$langs->trans("Name").''; print ''.$langs->trans("Description").''; print ''.$langs->trans("MustBeUnique").''; +print ''.$langs->trans("MustBeMandatory").''; print "\n"; $profid[0][0]=$langs->trans("ProfId1"); @@ -546,21 +564,10 @@ while ($i < $nbofloop) print $profid[$i][1]; print ''; - switch($i) - { - case 0: - $verif=(empty($conf->global->SOCIETE_IDPROF1_UNIQUE)?false:true); - break; - case 1: - $verif=(empty($conf->global->SOCIETE_IDPROF2_UNIQUE)?false:true); - break; - case 2: - $verif=(empty($conf->global->SOCIETE_IDPROF3_UNIQUE)?false:true); - break; - case 3: - $verif=(empty($conf->global->SOCIETE_IDPROF4_UNIQUE)?false:true); - break; - } + $idprof_unique ='SOCIETE_IDPROF'.($i+1).'_UNIQUE'; + $idprof_mandatory ='SOCIETE_IDPROF'.($i+1).'_MANDATORY'; + $verif=(empty($conf->global->$idprof_unique)?false:true); + $mandatory=(empty($conf->global->$idprof_mandatory)?false:true); if ($verif) { @@ -574,6 +581,19 @@ while ($i < $nbofloop) print img_picto($langs->trans("Disabled"),'switch_off'); print ''; } + + if ($mandatory) + { + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + print ''; + } + else + { + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; + } print "\n"; $i++; }