--
-- BEGIN / [#9651] Gestion des prescriptions archéologiques
--

-- Récupération de la nomenclature TYPE_PRESCRIPTIONS
--
INSERT INTO avis_decision_type (avis_decision_type, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    101,
    'PRE1',
    'Diagnostic archéologique',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_type FROM avis_decision_type WHERE avis_decision_type = 101);
UPDATE avis_decision_type
SET
    libelle = 'Diagnostic archéologique',
    code = 'PRE1'
WHERE
    avis_decision_type = 101;
--
INSERT INTO avis_decision_type (avis_decision_type, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    102,
    'PRE2',
    'Fouille archéologique',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_type FROM avis_decision_type WHERE avis_decision_type = 102);
UPDATE avis_decision_type
SET
    libelle = 'Fouille archéologique',
    code = 'PRE2'
WHERE
    avis_decision_type = 102;
--
INSERT INTO avis_decision_type (avis_decision_type, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    103,
    'PRE3',
    'Modifications de consistance du projet',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_type FROM avis_decision_type WHERE avis_decision_type = 103);
UPDATE avis_decision_type
SET
    libelle = 'Modifications de consistance du projet',
    code = 'PRE3'
WHERE
    avis_decision_type = 103;
--
INSERT INTO avis_decision_type (avis_decision_type, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    104,
    'PRE4',
    'Autre',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_type FROM avis_decision_type WHERE avis_decision_type = 104);
UPDATE avis_decision_type
SET
    libelle = 'Autre',
    code = 'PRE4'
WHERE
    avis_decision_type = 104;

-- Récupération de la nomenclature NATURE_PRESCRIPTIONS
--
INSERT INTO avis_decision_nature (avis_decision_nature, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    101,
    'PRE1',
    'Absence de prescription / renonciation à prescrire',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_nature FROM avis_decision_nature WHERE avis_decision_nature = 101);
UPDATE avis_decision_nature
SET
    libelle = 'Absence de prescription / renonciation à prescrire',
    code = 'PRE1'
WHERE
    avis_decision_nature = 101;
--
INSERT INTO avis_decision_nature (avis_decision_nature, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    102,
    'PRE2',
    'Prescription(s) à satisfaire en préalable des travaux',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_nature FROM avis_decision_nature WHERE avis_decision_nature = 102);
UPDATE avis_decision_nature
SET
    libelle = 'Prescription(s) à satisfaire en préalable des travaux',
    code = 'PRE2'
WHERE
    avis_decision_nature = 102;
--
INSERT INTO avis_decision_nature (avis_decision_nature, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    103,
    'PRE3',
    'Prescription(s) à satisfaire dans le cadre des travaux',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_nature FROM avis_decision_nature WHERE avis_decision_nature = 103);
UPDATE avis_decision_nature
SET
    libelle = 'Prescription(s) à satisfaire dans le cadre des travaux',
    code = 'PRE3'
WHERE
    avis_decision_nature = 103;
--
INSERT INTO avis_decision_nature (avis_decision_nature, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    104,
    'PRE4',
    'Intention de prescrire',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_nature FROM avis_decision_nature WHERE avis_decision_nature = 104);
UPDATE avis_decision_nature
SET
    libelle = 'Intention de prescrire',
    code = 'PRE4'
WHERE
    avis_decision_nature = 104;
--
INSERT INTO avis_decision_nature (avis_decision_nature, code, libelle, description, om_validite_debut, om_validite_fin)
SELECT
    105,
    'PRE5',
    'Renonciation à prescrire a posteriori',
    '',
    NULL,
    NULL
WHERE NOT EXISTS (SELECT avis_decision_nature FROM avis_decision_nature WHERE avis_decision_nature = 105);
UPDATE avis_decision_nature
SET
    libelle = 'Renonciation à prescrire a posteriori',
    code = 'PRE5'
WHERE
    avis_decision_nature = 105;

--
-- END / [#9651] Gestion des prescriptions archéologiques
--
