src: |
  SELECT 'compta'::text AS table_schema,
      t_listes_tables.oid AS table_id,
      t_listes_tables.name AS table_name,
      t_listes_tables.code AS table_code,
      t_listes_tables.texte AS table_texte,
      COALESCE(t_listes.oid, 0::bigint) AS liste_id,
      COALESCE(t_listes.code, ''::character varying) AS liste_code,
      COALESCE(t_listes.texte, ''::character varying) AS liste_texte,
      COALESCE(t_listes.is_cti, '0'::bpchar) AS liste_is_cti,
          CASE
              WHEN substr(t_listes.code::text, 1, 4) = ANY (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text, t_settings.value || '_'::text]) THEN '1'::text
              ELSE '0'::text
          END AS liste_is_groupe,
      COALESCE(t_listes.utilisateur_createur, ''::character varying) AS liste_utilisateur_createur,
      COALESCE(t_listes.show_omit, '0'::bpchar) AS liste_show_omit,
      '0'::text AS liste_is_omit,
      COALESCE(t_listes.est_partagee_modification, ''::bpchar) AS liste_est_partagee_modification,
          CASE
              WHEN t_listes.is_cti = '1'::bpchar THEN 'Listes CTI'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'CTI_'::text THEN 'Listes CTI'::text
              WHEN t_settings.value <> ''::text AND substr(t_listes.code::text, 1, 4) = (t_settings.value || '_'::text) THEN 'Listes Groupe'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VIT_'::text THEN 'Listes Groupe'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VED_'::text THEN 'Listes Groupe'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'HPM_'::text THEN 'Listes Groupe'::text
              ELSE 'Listes Etablissement'::text
          END AS liste_chapitre,
          CASE
              WHEN t_listes.is_cti = '1'::bpchar THEN '3'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'CTI_'::text THEN '3'::text
              WHEN t_settings.value <> ''::text AND substr(t_listes.code::text, 1, 4) = (t_settings.value || '_'::text) THEN '2'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VIT_'::text THEN '2'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VED_'::text THEN '2'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'HPM_'::text THEN '2'::text
              ELSE '1'::text
          END AS liste_chapitre_sortkey,
      COALESCE(t_listes.chapitre, ''::character varying) AS liste_sous_chapitre
     FROM compta.t_listes_tables
       LEFT JOIN compta.t_listes ON t_listes.table_id = t_listes_tables.oid
       LEFT JOIN base.t_settings ON t_settings.code = 'REFSETTINGS/PREFIX'::text
  UNION ALL
   SELECT 'compta'::text AS table_schema,
      t_listes_tables.oid AS table_id,
      t_listes_tables.name AS table_name,
      t_listes_tables.code AS table_code,
      t_listes_tables.texte AS table_texte,
      COALESCE(t_listes.oid, 0::bigint) AS liste_id,
      COALESCE(t_listes.code, ''::character varying) AS liste_code,
      COALESCE('Sauf '::text || t_listes.texte::text, ''::character varying::text) AS liste_texte,
      COALESCE(t_listes.is_cti, '0'::bpchar) AS liste_is_cti,
          CASE
              WHEN substr(t_listes.code::text, 1, 4) = ANY (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text, t_settings.value || '_'::text]) THEN '1'::text
              ELSE '0'::text
          END AS liste_is_groupe,
      COALESCE(t_listes.utilisateur_createur, ''::character varying) AS liste_utilisateur_createur,
      COALESCE(t_listes.show_omit, '0'::bpchar) AS liste_show_omit,
      '1'::text AS liste_is_omit,
      COALESCE(t_listes.est_partagee_modification, ''::bpchar) AS liste_est_partagee_modification,
          CASE
              WHEN t_listes.is_cti = '1'::bpchar THEN 'Listes CTI'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'CTI_'::text THEN 'Listes CTI'::text
              WHEN t_settings.value <> ''::text AND substr(t_listes.code::text, 1, 4) = (t_settings.value || '_'::text) THEN 'Listes Groupe'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VIT_'::text THEN 'Listes Groupe'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VED_'::text THEN 'Listes Groupe'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'HPM_'::text THEN 'Listes Groupe'::text
              ELSE 'Listes Etablissement'::text
          END AS liste_chapitre,
          CASE
              WHEN t_listes.is_cti = '1'::bpchar THEN '3'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'CTI_'::text THEN '3'::text
              WHEN t_settings.value <> ''::text AND substr(t_listes.code::text, 1, 4) = (t_settings.value || '_'::text) THEN '2'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VIT_'::text THEN '2'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'VED_'::text THEN '2'::text
              WHEN substr(t_listes.code::text, 1, 4) = 'HPM_'::text THEN '2'::text
              ELSE '1'::text
          END AS liste_chapitre_sortkey,
      COALESCE(t_listes.chapitre, ''::character varying) AS liste_sous_chapitre
     FROM compta.t_listes_tables
       LEFT JOIN compta.t_listes ON t_listes.table_id = t_listes_tables.oid
       LEFT JOIN base.t_settings ON t_settings.code = 'REFSETTINGS/PREFIX'::text
    WHERE t_listes.show_omit = '1'::bpchar;