commit c532ad34d7c2593dda04492a9d253f677ceb0d56 Author: ymi Date: Fri Sep 19 14:03:41 2025 +0200 initial commit diff --git a/db/aliciarh_lc_entree.csv b/db/aliciarh_lc_entree.csv new file mode 100644 index 0000000..f2a6393 --- /dev/null +++ b/db/aliciarh_lc_entree.csv @@ -0,0 +1,28 @@ +10|CDD MI-TEMPS THERAPEUTIQUE +11|CDD SURCROIT DE TRAVAIL +12|CDD REMPL. MALADIE / AT +13|CDD REMPL. MATERNITE +14|CDD REMPL. CONGES PAYES +15|CDD REMPL. CONGES PARENTAL +16|CDD REMPL. DISPONIBILITE +17|CDD REMPL. EVENEMENTS FAMILIAUX +18|CDD REMPL. ENFANTS MALADES +19|CDD REMPL. FORMATION +20|CDD REMPL. RECUPERATION +21|CDD REMPL. DELEGATION +28|CDD SUR POSTE TITULAIRE +29|CDD AUTRES +50|CDI REMPLACEMENT +51|CDI REMPLACEMENT DEPART RETRAITE +52|CDI REMPLACEMENT DEPART PRE-RETRAITE +53|CDI REMPLACEMENT DEMISSION +54|CDI REMPLACEMENT LICENCIEMENT +55|CDI REMPLACEMENT DECES +56|CDI REMPLACEMENT TEMPS PARTIEL DEFINITIF +60|CDI CREATION POSTE 35 HEURES +70|CDI CREATION POSTE NON BUDGETE +71|CDI CREATION POSTE BUDGET COMA +72|CDI CREATION POSTE BUDGET SOINS PALIATIFS +90|CHANGEMENT DE CATEGORIE PROFESSIONNELLE +91|NOUVELLES CONDITIONS CONTRACTUELLES +92|MUTATION \ No newline at end of file diff --git a/db/aliciarh_lc_groupe_cotisation.csv b/db/aliciarh_lc_groupe_cotisation.csv new file mode 100644 index 0000000..086e72b --- /dev/null +++ b/db/aliciarh_lc_groupe_cotisation.csv @@ -0,0 +1,13 @@ +10|Non Cadre +11|Cadre Emploie Multiple +12|Non cadre retraité FP +20|Cadre +30|Cadre Dirigeant +50|Emploi Jeune +51|Qualification +52|Contrat Initiative Emploi +53|Emploi Solidarité +54|Emploi Consolidé +60|Employé TP exo 30% +80|Emploi protégé +90|Apprenti \ No newline at end of file diff --git a/db/aliciarh_lc_pays.csv b/db/aliciarh_lc_pays.csv new file mode 100644 index 0000000..61b5bf3 --- /dev/null +++ b/db/aliciarh_lc_pays.csv @@ -0,0 +1,201 @@ +100|FRANCE +101|DANEMARK +102|ISLANDE +103|NORVEGE +104|SUEDE +105|FINLANDE +106|ESTONIE +107|LETTONIE +108|LITUANIE +109|ALLEMAGNE +110|AUTRICHE +111|BULGARIE +112|HONGRIE +113|LIECHTENSTEIN +114|ROUMANIE +115|TCHECOSLOVAQUIE +119|CROATIE +121|YOUGOSLAVIE +122|POLOGNE +123|RUSSIE +125|ALBANIE +126|GRECE +127|ITALIE +128|SAN MARIN +129|VATICAN +130|ANDORRE +131|BELGIQUE +132|ROYAUME UNI +133|GIBRALTAR +134|ESPAGNE +135|PAYS BAS +136|EIRE +137|LEXEMBOURG +138|MONACO +139|PORTUGAL +140|SUISSE +143|CHYPRE +144|MALTE +145|SLOVNIE +146|ARMENIE +147|AZERBAIDJAN +148|BIELORUSSIE +149|KAZAKHSTAN +150|KIRGHIZISTAN +151|MOLDAVIE +152|OUZELISTAN +153|TADJIKISTAN +154|TUKMENISTAN +155|UKRAINE +201|ARABIE SAOUDITE +203|IRAQ +204|IRAN +205|LIBAN +206|SYRIE +207|ISRAEL +208|TURQUIE +212|AFGHANISTAN +213|PAKISTAN +214|BOUTHAN +215|NEPAL +216|CHINE +217|JAPON +219|THAILANDE +220|PHILIPPINES +222|JORDANIE +223|INDE +224|BIRMANIE +225|BRUNEI +226|SINGAPOUR +227|MALAISIE +229|MALDIVES +230|HONG KONG +231|INDONESIE +232|MACAO +234|CAMBODGE +235|SRI LANKA +236|TAIWAN +237|COREE +238|COREE DU NORD +239|CORRE DU SUD +240|KOWAIT +241|LAOS +242|MONGOLIE +243|VIET NAM +246|BANGLADESH +247|EMIRAT ARABES UNIS +248|QATAR +249|BAHREIN +250|OMAN +251|YEMEN +301|EGYPTE +302|LIBERIA +303|AFRIQUE DU SUD +304|GAMBIE +306|SAINTE HELENE +308|ILES CHAGOS +309|TANZANIE +310|ZIMBABWE +311|NAMIBIE +312|ZAIRE +313|CANARIES +314|GUINEE EQUATORIALE +315|ETHIOPIE +316|LYBIE +318|SOMALIE +319|ACORES MADERE +321|BURUNDI +322|CAMEROUN +323|CENTRAFRIQUE +324|CONGO +326|COTE D'IVOIRE +327|BENIN +328|GABON +329|GHANA +330|GUINEE +331|BURKINA FASSO +332|KENYA +333|MADAGASCAR +334|MALAWI +335|MALI +336|MAURITANIE +337|NIGER +338|NIGERIA +339|OUGANDA +340|RWANDA +341|SENEGAL +342|SIERRA LEONE +343|SOUDAN +344|TCHAD +345|TOGO +346|ZAMBIE +347|BOTSWANA +348|LESOTHO +350|MAROC +351|TUNISIE +352|ALGERIE +390|MAURICE +391|SWAZILAND +392|GUINE-BISSAU +393|MOZAMBIQUE +394|SAO TOME +395|ANGOLA +396|CAP VERT +397|COMORES +398|SEYCHELLE +399|DJIBOUTI +401|CANADA +404|ETATS UNIS +405|MEXIQUE +406|COSTA RICA +407|CUBA +408|SAINT DOMINGUE +409|GUATEMALA +410|HAITI +411|HONDURAS +412|NICARAGUA +413|PANAMA +414|SALVADOR +415|ARGENTINE +416|BRESIL +417|CHILI +418|BILIVIE +419|COLOMBIE +420|EQUATEUR +421|PARAGUAY +422|PEROU +423|URUGUAY +424|VENEZUELA +425|ILES VIERGES BERMUDES CAIMAN +426|JAMAIQUE +427|ILES MALOUINES +428|GYUANA +429|BELIZE +430|GROENLAND +431|ANTILLES NEERLANDAISES +432|PORTO RICO +433|TRINITE ET TOBAGOO +434|BARBADE +435|GRENADE +436|BAHAMAS +437|SURINAM +438|DOMINIQUE +439|SAINT LUCIE +440|SAINT VINCENT ET LES GRENADINES +441|ANTIGUA ET BARBUDA +442|SAINT CHRISTOPHE ET NIEVES +501|AUSTRALIE +502|NOUVELLE ZELANDE +503|ILES PITCAIRN +505|MARIANNES +506|SAMOA OCCIDENTALES +507|NAURU +508|FIDJI +509|TONGA +510|NOUVELLE GUINEE +511|TUVALU +512|SALOMON +513|KIRIBATI +514|VANUATU +515|ILES MARSHALL +516|MICRONESIE \ No newline at end of file diff --git a/db/aliciarh_lc_sortie.csv b/db/aliciarh_lc_sortie.csv new file mode 100644 index 0000000..a6e46d3 --- /dev/null +++ b/db/aliciarh_lc_sortie.csv @@ -0,0 +1,22 @@ +CE|RUPTURE ANTICIPEE CDD PAR L'EMPLOYEUR +CS|RUPTURE ANTICIPEE CDD PAR LE SALARIE +DC|DECES +DD|DEMISSION CDD +DI|FIN DE CDD AVEC REPRISE +DM|DEMISSION +FA|FIN CONTRAT APPRENTISSAGE +FC|FIN CDD +FE|FIN PERIODE D'ESSAI PAR L'EMPLOYEUR +FS|FIN PERIODE D'ESSAI PAR LE SALARIE +FT|FIN DE STAGE +LE|LICENCIEMENT ECONOMIQUE +LG|LICENCIEMENT FAUTE GRAVE +LI|LICENCIEMENT INAP PHYSIQUE +LL|LICENCIEMENT FAUTE LOURDE +LM|LICENCIEMENT LONGUE MALADIE +LP|LICENCIEMENT CAUSE PERSONNELLE +LS|LICENCIEMENT FAUTE SIMPLE +RC|RUPTURE CONVENTION DE CONVERSION LIC. ECO. +RD|DEPART RETRAITE +RM|MISE A LA RETRAITE +TF|TRANSFERT FILIALE \ No newline at end of file diff --git a/db/aliciarh_rub.csv b/db/aliciarh_rub.csv new file mode 100644 index 0000000..0acc5a4 --- /dev/null +++ b/db/aliciarh_rub.csv @@ -0,0 +1,795 @@ +A000|PAIE DE COMPLEMENT|0 +A001|DATE DE PAYE |-1 +A002|PERIODE DE PAYE |-1 +A004|N° DE CONTRAT|-1 +A005|DATE DEBUT PERIODE DE PAIE|0 +A006|DATE FIN PERIODE DE PAIE|-1 +A007|MODE DE REGLEMENT |0 +A010|NOMBRE JOURS SS |-1 +A011|NOMBRE JOURS SS MANUEL |-1 +A019|BULLETIN EXCLU BASE 10EMME|0 +A020|CP ACQUIS|0 +A022|CP ANCIENNETE ACQUIS|0 +A056|CODE EMPLOI|-1 +A060|EMPLOI|0 +A064|CODE INSEE EMPLOI |-1 +A066|GRILLE INDICIAIRE|0 +A067|NIVEAU|0 +A068|ECHELON|0 +A070|COEFFICIENT|0 +A080|HEURES THEORIQUES|0 +A085|JOURS OUVRES THEORIQUES PAYES|0 +A090|SLD TT COMPTE A PAYER EN BULLETIN COMPL|0 +A155|HORAIRE MENSUEL|0 +A15A|Heures avenant|0 +A200|FORMATION : SANS MAINTIEN DE SALAIRE|0 +A250|DROIT RTT MENSUEL|0 +A51Q|QUART-TREIZIEME MOIS|0 +A51T|DEMI-TREIZIEME MOIS|0 +A890|CODE ETABLISSEMENT|-1 +A900|SECTION 1|0 +A901|SOUS-SECTION|0 +A902|SECTION 3|0 +A903|SECTION 4|0 +A904|SECTION 5|0 +A905|SECTION 6|0 +A906|SECTION 7|0 +A907|SECTION 8|0 +A908|SECTION 9|0 +A909|SECTION 10|0 +A990|VENTILATION COMPTABLE|0 +AFIA|Regul Allègemet FILLON|0 +ALOF|Allocations familiales|0 +AP00|BULLETIN DE PORTABILITE|0 +AZGC|Grille des cumuls forcés|0 +B001|COMMENTAIRE|-1 +B005|SALAIRE CONVENTIONNEL|0 +B006|SALAIRE HORAIRE JOUR|-1 +B007|SALAIRE HORAIRE NUIT|-1 +B008|SALAIRE HORAIRE|-1 +B009|SALAIRE CONVENTIONNEL CCU|0 +B010|SALAIRE DE BASE|0 +B013|COMPLEMENT SALAIRE SMIC|-1 +B014|COMPLEMENT RTT|-1 +B017|COMMENTAIRE|-1 +B018|RAPPEL DE SALAIRE DE BASE|-1 +B019|RAPPEL HEURES MOIS PRECEDENT|-1 +B01A|RAPPEL SALAIRE INDICIAIRE|-1 +B020|--- COMPLEMENT DE SALAIRE|0 +B030|INDEMNITE DIFFERENTIELLE|0 +B032|COMPLEMENT DE SALAIRE|0 +B040|SALAIRE DE BASE|-1 +B04V|Vacation|-1 +B04W||-1 +B05Z|********** ASTREINTE|-1 +B060|ASTREINTES A DOMICILE|-1 +B061|ASTREINTES NON TRAVAILLEES |-1 +B062|ASTREINTES TRAVAILLE|-1 +B070|--- PRIMES ETABLISSEMENT|0 +B071|ASTREINTE|-1 +B072|PRIME DE RESPONSABILITE|-1 +B073|PRIME DE LINGERIE|-1 +B074|PRIME DE LINGE|-1 +B075|ASTREINTE ADMINISTRATIVE|-1 +B076|PRIME DE TECHNICITE|-1 +B077|PRIME D'ASSIDUITE|-1 +B082|COMMENTAIRE|-1 +B084|REGUL SALAIRE BRUT CONVENTION|-1 +B091|PRIME DE DIALYSE|-1 +B092|PRIME EXCEPTIONNELLE|-1 +B093|PRIME SUR VARIABLE|-1 +B094|PRIME/FONCTION|-1 +B095|PRIME D'INSTALLATION|-1 +B097|COMMENTAIRE|-1 +B098|REGULARISATION DE BRUT|-1 +B100|------ HEURES -----|0 +B101|COMMENTAIRE|-1 +B102|HRS COMPL TEPA|-1 +B103|HEURES SUPPL 25 % AVEC RC|-1 +B104|HRS COMPLEMENTAIRE|-1 +B105|HRS COMPL. 10%|-1 +B106|HRS SUPPL 25% TEPA|-1 +B107|REGUL HEURES SUPPL. A 25 %|-1 +B108|HEURES SUPPL 25%|-1 +B109|HRS COMPL. 25%|-1 +B110|HEURES SUPPLEMENTAIRES 50%|-1 +B111|regul HRS COMPLEMENTAIRE|-1 +B112|REGUL HEURES SUPPL. A 50 %|-1 +B114|HEURES SUPPLEMNTAIRES 100%|-1 +B116|REGUL HEURES SUPPL. A 100 %|-1 +B200|----- DEDUCTION ENTRE SORTIE|0 +B202|DEDUCTION ENTREE SORTIE|-1 +B204|DEDUCTION ENTREE SORTIE|-1 +B21Z|----- SUSPENTION DE CONTRAT|0 +B220|PERIODE SUSPENSION CONTRAT |-1 +B222|SUSPENSION CONGE PARENTAL|-1 +B224|SUSPENSION CONGE SABATIQUE|-1 +B226|SUSPENSION CREATION ENTREPRISE|-1 +B228|SUSPENSION SERVICE MILITAIRE|-1 +B230|SUSPENSION CONGE SOLIDARITE |-1 +B232|SUSPENSION CONGE FORMATION|-1 +B234|SUSPENS CONVENANCE PERSONNELLE|-1 +B238|SUSPENSION INCAPACITE DE TRAVAIL|-1 +B239|SUSPENSION MISE A PIED|-1 +B23A|SUSPENSION THERAPEUTIQUE (H)|-1 +B23B|SUSPENSION THERAPEUTIQUE (1/30)|-1 +B23C|MAINTIEN THERAPEUTIQUE|-1 +B240|-----------------------------ABSENCE RTT|0 +B241|COMMENTAIRE|-1 +B242|PERIODE ABSENCE RTT|-1 +B244|ABSENCE RTT|-1 +B246|MAINTIEN RTT|-1 +B24A|--------------ABSENCE CPTE EPARGNE TEMPS|0 +B24C|PERIODE ABSENCE CET|-1 +B24E|HEURES C.E.T. PRISES|-1 +B24G|MAINTIEN ABSENCES C.E.T.|-1 +B250|-------------------------ABSENCES DIVERS|0 +B258|PERIODE ABSENCES DIVERSES|-1 +B259|ABSENCES DIVERSES|-1 +B260|ABSENCES DIVERSES HRS|-1 +B261|PERIODE ABSENCES RECUPERATION|-1 +B262|ABSENCE RECUPERATION|-1 +B263|MAINTIEN ABSENCE RECUPERATION|-1 +B264|PERIODE ABSENCE AUTORISEE|0 +B265|ABSENCE AUTORISEE|-1 +B266|MAINTIEN ABS AUTORISEE|-1 +B26Z|----------------------ABSENCE FORMATIONS|0 +B270|PERIODE ABSENCE FORMATION|-1 +B271|ABSENCE FORMATION|-1 +B272|MAINTIEN ABS. FORMATION|-1 +B275|PERIODE ABSENCE FORMATION E.S.S.|-1 +B276|ABSENCE FORMATION E.S.S.|-1 +B277|MAINTIEN FORMATION E.S.S.|-1 +B27Z|------------ABSENCE EVENEMENTS FAMILIAUX|0 +B280|PERIODE EVENEMENTS FAMILIAUX|-1 +B281|ABSENCE EVENEMENTS FAMILIAUX|-1 +B282|MAINTIEN ABS. EVENEMENTS FAMILIAUX|-1 +B28Z|-----------------ABSENCE ENFANTS MALADES|0 +B290|PERIODE ENFANTS MALADES|-1 +B291|ABSENCE ENFANTS MALADES|-1 +B292|MAINTIEN ABS. ENFANTS MALADES|-1 +B300|-------------------------ABSENCE MALADIE|0 +B301|COMMENTAIRE|-1 +B302|PERIODE ABSENCE MALADIE|-1 +B303|MISE A PIED CONSERVATOIRE|-1 +B304|ABSENCE MALADIE |-1 +B305|HEURES DE MALADIE|0 +B306|MAINTIEN ABS. MALADIE A TAUX 1|-1 +B308|MAINTIEN ABS. MALADIE A TAUX 2|-1 +B30A|MAINTIEN ABS. MALADIE A TAUX 3|-1 +B30E|DEDUCTION DES IJSS MALADIE|-1 +B30G|IJSS DE SUBROGATION MALADIE|0 +B30I|IJ PREVOYANCE MALADIE|-1 +B30J|Régul Absence maladie|-1 +B310|-------------ABSENCE ACCIDENT DU TRAVAIL|0 +B312|PERIODE ABSENCE AT|-1 +B314|ABSENCE AT|-1 +B315|HEURES DE AT|0 +B316|MAINTIEN ABSENCE AT A TAUX 1|-1 +B318|MAINTIEN ABSENCE AT A TAUX 2|-1 +B31A|MAINTIEN ABSENCE AT A TAUX 3|-1 +B31E|DEDUCTION DES IJSS AT|-1 +B31G|IJSS DE SUBROGATION AT|0 +B31I|IJ PREVOYANCE AT|-1 +B320|----------------------ABSENCE MATERNITE|0 +B322|PERIODE ABSENCE MATERNITE|-1 +B324|ABSENCE MATERNITE|-1 +B325|HEURES DE MATERNITE|0 +B326|MAINTIEN ABS MATERNITE|-1 +B327|REGUL ABSENCE MATERNITE|-1 +B32E|DEDUCTION DES IJSS MATERNITE|-1 +B32G|IJSS DE SUBROGATION MATERNITE|0 +B32I|IJ PREVOYANCE MATERNITE|-1 +B330|------------------ABSENCE CONGE PARENTAL|0 +B332|PERIODE ABSENCE CONGES PARENTAL|-1 +B334|ABSENCE CONGE PARENTAL|-1 +B340|------------------MI TEMPS THERAPEUTIQUE|0 +B342|PERIODE MI-TEMPS THERAPEUTIQUE|-1 +B344|ABSENCE MI-TEMPS THERAPEUTIQUE|-1 +B346|MAINTIEN MI-TEMPS THERAPEUTIQUE|-1 +B34E|DEDUCTION DES IJSS MI-TEMPS|-1 +B34G|IJSS DE SUBROGATION MI-TEMPS|0 +B34I|IJ PREVOYANCE MI-TEMPS|-1 +B350|-----------------------ABSENCE PATERNITE|0 +B352|PERIODE ABSENCE PATERNITE|-1 +B354|ABSENCE D'ABSENCE PATERNITE|-1 +B356|MAINTIEN ABSENCE PATERNITE|-1 +B360|------------------ABSENCE LONGUE MALADIE|0 +B362|PERIODE ABS LONGUE MALADIE|-1 +B364|ABSENCE LONGUE MALADIE |-1 +B365|HEURES DE LONGUE MALADIE|0 +B366|MAINTIEN ABS. LONGUE MALADIE A TAUX 1|-1 +B368|MAINTIEN ABS. LONGUE MALADIE A TAUX 2|-1 +B36A|MAINTIEN ABS. LONGUE MALADIE A TAUX 3|-1 +B36E|DEDUCTION DES IJSS LONGUE MALADIE|-1 +B36G|IJSS DE SUBROGATION LONGUE MALADIE|0 +B36I|IJ PREVOYANCE LONGUE MALADIE|-1 +B500|------ INDEMNITE DIMANCHE FERIE|0 +B501|COMMENTAIRE|-1 +B502|FERIE NON TRAVAILLE|-1 +B503|PAYEMENT RC FERIE NON TRV|0 +B504|INDEMINITE DE FERIE NON TRAVAILLE|-1 +B505|INDEMNITE FERIE TRAVAILLE|-1 +B506|INDEMNITE 1er mai TRAVAILLE|-1 +B507|PAYEMENT RC FERIE TRAVAIL|0 +B508|INDEMNITE DIMANCHE TRAVAILLE|-1 +B509|PAYEMENT RC DIMANCHE TRAVAIL|0 +B50A|HEURES RC FERIE ACQUIS|0 +B50B|PAIEMENT HEURES RC FERIE|-1 +B50C|********** PRIME DE NUIT|-1 +B50E|PRIME DE NUIT|-1 +B50F|PAYEMENT RC DE NUIT|0 +B50G|HEURES RC DE NUIT ACQUIS|0 +B50J|PAIEMENT HEURES RC DE NUIT|-1 +B50K|PAIEMENT HEURES 1er MAI|-1 +B50M|MAINTIEN PRIME DE NUIT AT|-1 +B50N|HEURES RC ACQUISES|-1 +B50P|COMMENTAIRE|-1 +B510|------ PRIME|0 +B512|PRIME EXCEPTIONNELLE|-1 +B513|PRIME EXCEPTIONNELLE|-1 +B514|INDEMNITE DEPART EN RETRAITE|-1 +B519|INDEMNITE COMPENSATRICE DE PREAVIS|-1 +B51A|------ PRIME DE FIN D'ANNEE|0 +B51C|PRIME DE FIN D'ANNEE|-1 +B51D|13è mois|-1 +B51Q|QUART-TREIZIEME MOIS|-1 +B51T|DEMI-TREIZIEME MOIS|-1 +B520|--------------------REPOS COMPENSATEURS |0 +B521|PERIODE ABSENCE RC|-1 +B522|HEURES ABSENCE RC|-1 +B523|HEURES MAINTIEN RC|-1 +B526|PAIEMENT SOLDE HEURES RC|-1 +B528|PAIEMENT HEURES RC|-1 +B530|------ AVANTAGE EN NATURE|0 +B532|AVANTAGE EN NATURE PETIT DEJEUNE|-1 +B533|AVANTAGE EN NATURE REPAS|-1 +B53L|AVANTAGES LOGEMENT |-1 +B53V|AVANTAGE EN NATURE VOITURE|-1 +B54A|------ COMPLEMENT RAG|0 +B54S|ETAT RAG Za = Bulletin ZB = Cumul |0 +B54V|COMPLEMENT RAG|-1 +B54W|** BASE MAINTIEN MOIS/CAL/OUVRE/OUVRA/HR|0 +B54Z|** BASE 1/10 CP MOIS/REL/REF/NEW|0 +B550|PERIODE CONGES PAYES|-1 +B551|ABSENCE CONGES PAYES|-1 +B552|INDEMNITE CP Année antérieure|-1 +B553|INDEMNITE CP Année encours|-1 +B554|INDEMNITE CP Année future|-1 +B556|INDEMNITE CP Fractionnement|-1 +B558|INDEMNITE CP Ancienneté|-1 +B55P|COMMENTAIRE|-1 +B55Z|------ IND.COMP. CP -------|0 +B561|DECLANCHEMENT IND.COMP. CP CDI|0 +B562|IND.COMP. CP Antérieur|-1 +B563|IND.COMP. CP Année encours|-1 +B564|IND.COMP. CP Année future|-1 +B566|IND.COMP. CP Fractionnement|-1 +B568|IND.COMP. CP Ancienneté|-1 +B56B|PAIEMENT IND.COMP. CP Année antérieure|-1 +B56C|PAIEMENT IND.COMP. CP Année encours|-1 +B56D|PAIEMENT IND.COMP. CP Année future|-1 +B56G|INDEMNITE CONGES PAYES|-1 +B56H|PAIEMENT IND.COMP. CP|-1 +B56Z|------ IND.COMP. CP CDD -------|0 +B570|INDEMNITE DE PRECARITE|-1 +B571|DECLANCHEMENT IND.COMP. CP CDD|0 +B573|IND.COMP. CP CDD Année encours|-1 +B574|IND.COMP. CP CDD Année futur|-1 +B576|IND.COMP. CP CDD Fractionnement|-1 +B578|IND.COMP. CP CDD Ancienneté|-1 +B57M|IND.COMP. CP CDD Année en cours **|-1 +B57P|INDEMNITE CONGES PAYES CDD (Mensuelle)|-1 +B57Z|------ IND.PRECARITE CDD -------|0 +B580|INDEMNITE DE PRECARITE|-1 +B582|INDEMNITE DE PRECARITE|-1 +B590|COMPLEMENT AU 10EME|-1 +B595|INDEMNITE COMPENSATRICE CP|-1 +B598|INDEMNITE CONGES PAYES CDD|-1 +B5ZZ|----- INDEMNITES JOURNALIERES ----|0 +B600|IJSS|-1 +B601|REGULARISATION BASE NEGATIVE |-1 +B60E|DEDUCTION I.J.S.S. BRUTES A PERCEVOIR|-1 +B60M|I.J.S.S. BRUTES|-1 +B610|MAINTIEN DU NET|-1 +B640|IND. PREVOYANCE SOUMISE|-1 +B641|IND. PREVOYANCE EXONEREE|-1 +B64M|IND. PREVOYANCE (Régul. base cotis.)|-1 +B65A|MAINTIEN SALAIRE 100% BRUT SOUMIS|-1 +B65B|MAINTIEN SALAIRE 100% BRUT EXO|-1 +B65C|MAINTIEN SALAIRE 80% BRUT SOUMIS|-1 +B65D|MAINTIEN SALAIRE 80% BRUT EXO|-1 +B65I|I.J.S.S. BRUT SOUMIS|-1 +B65J|I.J.S.S. BRUT EXO|-1 +B750|INDEMNITE DEPART RETRAITE |-1 +B760|IND. LICENCIEMENT CONVENTIONNELLE|-1 +B761|IND. LICENCIEMENT non imposable|-1 +B765|INTERESSEMENT|-1 +B79Z|--- Salaire Emploi protégé (HAND) ----|0 +B800|ABATTEMENT Salaire Emploi Protégé (50%)|-1 +B805|COMPLEMENT ETAT Salaire Emploi Protégé|-1 +B830|----- AVANTAGES EN NATURE -----|0 +B833|AVANTAGES EN NATURE REPAS|-1 +B851|AVANTAGES NOURRITURE |-1 +B855|AVANTAGES LOGEMENT |-1 +B860|AVANTAGES VOITURE|-1 +B865|AVANTAGES AUTRES |-1 +B880|************************** RAPPEL|-1 +B88B|RAPPEL COEFFICIEN|-1 +B88C|RAPPEL ASTREINTES A DOMICILE|-1 +B88D|RAPPEL FERIE NON TRAVAILLE|-1 +B88E|RAPPEL INDEMNITE DIMANCHE ET FERIE|-1 +B88F|RAPPEL PRIME DE NUIT|-1 +B88Z|--- COMPTE EPARGNE TEMPS ----|0 +B890|ALIMENTATION COMPTE EPARGNE TEMPS (en H)|-1 +B89Z|**** BASE BRUT MOINS IJSS MOIS|0 +B900|***************************** TOTAL BRUT|-1 +B910|BASE COTISATION |0 +B911|URSSAF TA/TB/TC/T3A/TAB |-1 +B912|SUP_RETRAITE BR/PL/TA/TB/TC |-1 +B9A0|SMIC FILLON|0 +B9C0|MONTANT DIFFERENTIEL APPRENTI|0 +BFIL|SALAIRE REFERENCE FILLON|0 +C002|***** URSSAF ******* |-1 +C008|CSG PARTICIPATION PLACEE|0 +C105|CSG DEDUCTIBLE- HORS ABATTEMENT|-1 +C106|CSG CRDS - HORS ABATTEMENT|0 +C107|CSG REGUL |0 +C108|CSG CRDS |0 +C109|CSG DEDUCTIBLE |-1 +C10A|REGUL CSG DEDUCTIBLE |-1 +C10F|CSG NON DEDUCTIBLE HORS ABATTEMENT|0 +C110|URSSAF / TOTALITE|-1 +C11A|URSSAF / TOTALITE AL|-1 +C11T|REGUL URSSAF / TOTALITE|-1 +C12C|MAJORATION ALLOC. FAMILIALES |-1 +C12D|MAJORATION ALLOC. FAMILIALES |-1 +C12E|MAJORATION ALLOC. FAMILIALES |-1 +C12P|REGUL MAJO ALLOC. FAMILIALES |-1 +C12Q|REGUL MAJO ALLOC. FAMILIALES |-1 +C12R|REGUL MAJO ALLOC. FAMILIALES PIGISTES|-1 +C12S|REGUL MAJO ALLOC. FAMILIALES PIGISTES|-1 +C141|FNAL SUPPL. TA|-1 +C142|FNAL SUPPL. > PLAFOND|-1 +C143|FNAL SUPPL. TA APP|-1 +C144|FNAL SUPPL. > PLAFOND APP|-1 +C145|FNAL SUPPL. TA ART|-1 +C146|FNAL SUPPL. > PLAFOND ART|-1 +C149|FORFAIT SOCIAL|-1 +C14C|REGUL FNAL TR A|-1 +C14D|REGUL FNAL > PLAFOND|-1 +C150|URSSAF / PLAFOND |-1 +C15T|REGUL URSSAF / PLAFOND|-1 +C1A0|***** URSSAF Apprenti ******* |-1 +C1A5|URSSAF / PLAFOND APPRENTI|-1 +C1C0|***** URSSAF C.E.C. ******* |-1 +C1C1|URSSAF / TOTALITE CEC Exonéré|-1 +C1C5|URSSAF / PLAFOND CEC Exonéré|-1 +C1CA|URSSAF / TOTALITE CEC Exonéré AL|-1 +C1CS|CONTRIBUTION SOLIDARITE APPRENTI|-1 +C1D0|***** URSSAF DETACHE F.PUBL ******* |-1 +C1D1|URSSAF / TOTALITE Détaché Fonct.Publ|-1 +C1D5|URSSAF / PLAFOND Détaché Fonct.Publ.|-1 +C1DF| FORFAIT SOCIAL|-1 +C1DZ|REGUL COTISATION FORFAIT SOCIAL|-1 +C1E1|CONTRIBUTION SYNDICALE|-1 +C1I0|***** URSSAF C.I.E. ******* |-1 +C1I1|URSSAF / TOTALITE CIE Exonéré|-1 +C1I5|URSSAF / PLAFOND CIE Exonéré|-1 +C1IA|URSSAF / TOTALITE CIE Exonéré AL|-1 +C1J0|***** URSSAF C.E.J. ******* |-1 +C1J1|URSSAF / TOTALITE CEJ|-1 +C1J5|URSSAF / PLAFOND CEJ|-1 +C1JA|URSSAF / TOTALITE CEJ AL|-1 +C1P0|***** URSSAF MEDECIN PEM ******* |-1 +C1P1|URSSAF / TOTALITE Médecin PEM|-1 +C1P5|URSSAF / PLAFOND Médecin PEM|-1 +C1PA|URSSAF / TOTALITE Médecin PEM AL|-1 +C1Q0|***** URSSAF C.Qualif. ******* |-1 +C1Q1|URSSAF / TOTALITE C.Qualif. Exonéré|-1 +C1Q5|URSSAF / PLAFOND C.Qualif. Exonéré|-1 +C1QA|URSSAF / TOTALITE C.Qualif. Exonéré AL|-1 +C1R0|***** URSSAF CRE ******* |-1 +C1R1|URSSAF / TOTALITE CRE Exonéré|-1 +C1R5|URSSAF / PLAFOND CRE Exonéré|-1 +C1RA|URSSAF / TOTALITE CRE Exonéré AL|-1 +C1S0|***** URSSAF C.E.S. ******* |-1 +C1S1|URSSAF / TOTALITE CES Exonéré|-1 +C1S5|URSSAF / PLAFOND CES Exonéré|-1 +C1SA|URSSAF / TOTALITE CES Exonéré AL|-1 +C1T0|***** URSSAF T.P. Exo 30% ******* |-1 +C1T1|URSSAF / TOTALITE TP Exo 30%|-1 +C1T5|URSSAF / PLAFOND TP Exo 30%|-1 +C1TA|URSSAF / TOTALITE TP Exo 30% AL|-1 +C200|***** URSSAF COTISATIONS COMMUNES ******|-1 +C210|URSSAF FNAL / Totalite|-1 +C211|URSSAF FNAL/Totalité REGUL|-1 +C215|URSSAF FNAL AP / Tranche A |-1 +C220|URSSAF ACCIDENT DU TRAVAIL|-1 +C230|URSSAF VERSEMENT TRANSPORT|-1 +C23R|URSSAF TRANSPORT REGUL |-1 +C240|URSSAF TAXE SUR PREVOYANCE|-1 +C242|REGUL TAXE SUR PREVOYANCE|-1 +C244|REGUL ALLEGEMENT TEPA|-1 +C245|CSG CRDS HRS. SUPP. |-1 +C246|ALLEGEMENT HEURES SUPPL. SAL.|-1 +C247|ALLEGEMENT HEURES SUPPL. PAT.|-1 +C248|ALLEGEMENT HEURES SUPPL. PAT.|-1 +C24R|REGUL ALLEGEMENT HRS SUPPL|-1 +C250|***** URSSAF ALLEGEMENT ******* |-1 +C251|URSSAF Reduction Bas Salaires|-1 +C255|URSSAF Alleg AUBRY I|-1 +C257|ALLEGEMENT FILLON|-1 +C258|ALLEGEMENT FILLON ANNUALISE|-1 +C259|URSSAF Alleg AUBRY II|-1 +C25Z|******* Total URSSAF |-1 +C260|ASSEDIC AC Tranche A |-1 +C262|ASSEDIC ASF Tranche A |-1 +C265|ASSEDIC AC Apprenti|-1 +C266|ASSEDIC ASF Apprenti|-1 +C26T|REGUL ASSEDIC Tranche A |-1 +C270|ASSEDIC AC Tranche B |-1 +C272|ASSEDIC ASF Tranche B |-1 +C27R|ASSEDIC TB REGUL |-1 +C290|ASSEDIC F.N.G.S. |-1 +C291|ASSEDIC F.N.G.S. Apprenti |-1 +C292|ASSEDIC F.N.G.S. REGUL |-1 +C29Z|******* Total ASSEDIC |-1 +C300|Humanis Retr. N.C. Tr.A|-1 +C301|Humanis AGFF Tr.A|-1 +C302|Humanis Retr. N.C. Tr.B|-1 +C303|humanis AGFF Non Cadre Tr.B|-1 +C304|Humanis T.B. NC. REGUL |-1 +C305|AGFF N.C. T.B. REGUL |-1 +C306|HumanisN.C. Tr.A retraité|-1 +C307|Humanis AGFF Tr.A retraité|-1 +C308|Humanis N.C. Tr.B retraité|-1 +C309|Humanis AGFF NC Tr.B retraité|-1 +C30A|Humanis Retr. Apprenti Tr.A|-1 +C30B|Humanis Retr. Apprenti Tr.B|-1 +C30C|Humanis Retr. Cadre Tr.A|-1 +C30D|Humanis AGFF Cadre Tr.A|-1 +C30M|Humanis Retr. Art.36 Tr.A|-1 +C30N|Humanis AGFF Art. 36 Tr.A|-1 +C30P|Humanis Regul. Retr. Tr.A|-1 +C30Q|Humanis Regul. AGFF NC T.A.|-1 +C30R|Humanis Regul. Retr. Cadre Tr.A|-1 +C30Z|******* Total non cadre|-1 +C500|MEDERIC Retr. Cadre Tr.A|-1 +C501|MEDERIC AGFF Cadre Tr.A|-1 +C502|MEDERIC Retr. Cadre Tr.B|-1 +C503|MEDERIC AGFF Cadre Tr.B|-1 +C504|MEDERIC Retr. Cadre Tr.C|-1 +C505|REGUL MEDERIC Retr. Cadre Tr.A|-1 +C506|REGUL MEDERIC Retr. Cadre Tr.B|-1 +C507|REGUL MEDERIC Retr. Cadre Tr.C|-1 +C50A|MEDERIC APEC Cadre Tr.B |-1 +C50B|MEDERIC APEC Cadre Forfait Annuel|-1 +C50C|MEDERIC CET |-1 +C50D|MEDERIC APEC Cadre Tr.A |-1 +C50G|MEDERIC Retr. cadre GMP|-1 +C50H|MEDERIC GMP REGUL|-1 +C50M|MEDERIC Retr. Art.36 TrB|-1 +C50N|MEDERIC AGFF Art.36 TrB|-1 +C50P|MEDERIC CET Art.36 |-1 +C50Z|******* Total Cadres|-1 +C510|MORNAY Retr. cadre Tr.A|-1 +C512|MORNAY AGFF cadre Tr.A|-1 +C513|MORNAY Retr. Cadre Tr.B|-1 +C514|MORNAY AGFF Cadre Tr.B|-1 +C515|MORNAY Retr. Cadre Tr.C|-1 +C51A|MORNAY APEC Cadre Tr.B |-1 +C51B|MORNAY APEC Cadre Forfait Annuel|-1 +C51C|MORNAY CET |-1 +C51G|MORNAY Retr. cadre GMP|-1 +C51M|MORNAY Retr. Art.36 TrB|-1 +C51N|MORNAY AGFF Art.36 TrB|-1 +C51P|MORNAY CET Art.36 |-1 +C51Z|******* Total cadre|-1 +C520|GENERALI Retr. C.D.TrA |-1 +C521|GENERALI Retr. C.D.TrB |-1 +C522|GENERALI Retr. C.D. Tr.C|-1 +C523|GENERALI Prév. C.D.TrA |-1 +C524|GENERALI Prév. C.D.TrB |-1 +C52Z|******* Total C.D.|-1 +C650|VAUBAN Prév. Cadre TrA Incapacité décès|-1 +C651|VAUBANPrév. Cadre TrA Maintien|-1 +C652|VAUBAN PREV CADRE T.A INC REGUL|-1 +C653|VAUBAN PREV CADRE T.A. MAINT.REGUL|-1 +C655|VAUBAN Prév. Cadre TrB Incapacité décès|-1 +C656|VAUBAN Prév. Cadre TrB Maintien|-1 +C657|VAUBAN PREV CADRE T.B. INC REGUL|-1 +C658|VAUBAN PREV CADRE T.B. MAINT. REGUL|-1 +C65A|VAUBAN Prév. Cadre TrC Incapacité décès|-1 +C65B|VAUBAN Prév. Cadre TrC Maintien|-1 +C65R|VAUBAN Prév. Cadre REGUL|-1 +C65Z|******* Total VAUBAN Prév. Cadre|-1 +C660|Collecteam Prév. N.C TrA Incap décès|-1 +C661|Collecteam Prév. N.C TrA Maintien|-1 +C662|Regul Collecteam Prév. N.C TrA Incap|-1 +C665|Collecteam Prév. N.C TrB Incap décès|-1 +C666|Collecteam Prév. N.C TrB Maintien|-1 +C667|Régul Collecteam Prév. N.C TrB Incap|-1 +C66A|Collecteam Prév. N.C TrC Incap décès|-1 +C66B|Collecteam Prév. N.C TrC Maintien|-1 +C66R|Collecteam Prév. N.C REGUL|-1 +C66Z|******* Total Collecteam Prév. N.C|-1 +C700|MUTUELLE |-1 +C710|MUTUELLE |-1 +C805|MEDECINE DU TRAVAIL|0 +C810|COMITE ENTREPRISE |0 +C811|COMITE ENTREPRISE FONCTIONNEMENT|0 +C820|AIDE A LA CONSTRUCTION|0 +C82R|AIDE LOGEMENT REGUL |-1 +C830|TAXE APPRENTISSAGE|0 +C840|FC PLAN DE FORMATION|0 +C841|FC FORMATION EN ALTERNANCE|0 +C842|FC CONGE INDIVIDUEL FORMATION|0 +C844|FORMATION PROFESSIONNEL CDD|0 +C850|CONTRIBUTION HANDICAPES|0 +C859|SOUS TOTAL AUTRES COTISATIONS|-1 +C900|TAXE SUR LES SALAIRES TAUX NORMAL|0 +C902|TAXE SUR LES SALAIRES 1ERE TAUX|0 +C904|TAXE SUR LES SALAIRES 2EME TAUX|0 +C905|TAXE SUR LES SALAIRES 3EME TAUX|0 +C906|TAXE SUR LES SALAIRES PRORATA|0 +C909|TOTAL TAXE SUR LES SALAIRES|-1 +C910|PROVISION CP N|0 +C912|CHARGE/PROVISION CP N|0 +C920|PROVISION CP N-1|0 +C922|CHARGE/PROVISION CP N-1|0 +C930|PROVISION CP RELIQUAT|0 +C932|CHARGE PROVISION CP RELIQUAT|0 +C949|SOUS TOTAL PROVISIONS CP|0 +D |********** TOTAL AUTRES COTIS.PATRONALES|-1 +D000|******************** TOTAL COTISATIONS|-1 +D001|COUT EMPLOYEUR|-1 +D008|PARTICIPATION|-1 +D009|INTERESSEMENT NET IMPOSABLE |-1 +D010|INTERESSEMENT |-1 +D015|IND. JOURNALIERES Sécurité Sociale|-1 +D018|REGULARISATION DE COTISATION|-1 +D01R|REGUL DEDUCTION HEURES SUPPL.|-1 +D01S|DEDUCTION HEURES SUPPL.|-1 +D020|NET IMPOSABLE |-1 +E000|----- NON IMPOSABLE EN PLUS ----|-1 +E005|CARTE ORANGE NON|0 +E008|PARTICIPATION PLACEE|-1 +E010|REMBOURSEMENT TRANSPORT|-1 +E012|REMBOURSEMENT TRANSPORT|-1 +E014|INDEMNITE DE TRANSPORT EXONEREE|-1 +E015|FRAIS DE DEPLACEMENT|-1 +E016|FRAIS DE DEPLACEMENT|-1 +E017|FRAIS DE DEPLACEMENT|-1 +E01R|REGUL REINTEGRATION HEURES SUPPL.|-1 +E01S|REINTEGRATION HEURES SUPPL.|-1 +E020|REMBOURSEMENT FRAIS|-1 +E021|REMBOURSEMENT IJ MALADIE|-1 +E022|REMBOURSEMENT SAISIE ARRET|-1 +E030|INDEMNITE DE MISE A LA RETRAITE|-1 +E040|INDEMNITE DE LICENCIEMENT|-1 +E041|INDEM RUPTURE CONVENTIONNELLE|-1 +E042|INDEMNITE SPECIALE LICENCIEMENT|-1 +E044|AUTRES INDEMNITE LICENCIEMENT|-1 +E045|INDEMNITE REQUALIFICATION|-1 +E046|IND. POUR IRREGULARITE PROCEDURE|-1 +E047|DOMMAGE & INTERET/LICENCIEMENT ABUSIF|-1 +E048|INDEMNITE TRANSACTIONNELLE|-1 +E050|PRIME DE PANIER|-1 +E051|PRIME 1/2 PANIER|-1 +E052|PRIME DE PANIER|-1 +E060|DIVERS ACHATS +|-1 +E300|PARTICIPATION CE MUTUELLE|-1 +E301|REMBOURSEMENT MUTUELLE|-1 +E691|INTERETS A COMPTER DU 01.04.1997|-1 +E900|AVANCE PAYE NEGATIVE|-1 +E960|INDEMN.PREVOYANCE NON CADRE (Nettes)|0 +E96M|INDEMN.PREVOYANCE NON CADRE (Nettes) ***|0 +E980|IND. JOURNALIERES Sécurité Sociale|-1 +E98M|IND. JOURNALIERES Sécurité Sociale ***|-1 +E98T|IND. JOURNALIERES Séc.Soc. MTT|-1 +E990|** TOTAL NON IMPOSABLE PLUS **|0 +F000|---- NON IMPOSABLE EN MOINS ----|-1 +F001|REGULARISATION BASE FIN D'ANNEE|-1 +F008|REPRISE PARTICIPATION PLACEE|-1 +F010|ACOMPTE |-1 +F012|ACOMPTE PERMANENT |-1 +F014|AVANCE |-1 +F015|ACOMPTE TREIZIEME MOIS|-1 +F020|RETENUES DIVERSES |-1 +F021|ACOMPTE PARKING|-1 +F022|TICKETS RESTAURANTS|-1 +F023|RETENUE DIVERSE|-1 +F024|REPAS PRIS|-1 +F025|REGULARISATION REPAS PRIS|-1 +F026|REPAS PRIS TARIF 2|-1 +F027|TICKETS REPAS|-1 +F029|MUTUELLE REGULARISATION|-1 +F02C|COLLATION|-1 +F02S|TICKET SUPPLEMENT|-1 +F030|MUTUELLE |-1 +F031|REGULARISATION MUTUELLE |-1 +F040|PENSION ALIMENTAIRE |-1 +F050|REMBOURSEMENT PRET |-1 +F052|REMBOURSEMENT PRET |-1 +F054|INTERETS PRET |-1 +F100|CSG CRDS NON DEDUCTIBLE|-1 +F102|CSG DEDUCTIBLE|0 +F104|TAXE PREVOYANCE|0 +F107|REGUL CSG CRDS|-1 +F10F|CSG NON DEDUCTIBLE HORS ABATTEMENT|-1 +F10G|CSG DEDUCTIBLE - HORS ABATTEMENT|0 +F10H|CSG CRDS - HORS ABATTEMENT|-1 +F110|SAISIE ARRET |-1 +F112|SAISIE ARRET|-1 +F114|SAISIE ARRET (Régularisation)|-1 +F116|TEST SAISIE ARRET SI IJSS|0 +F1D1|COTISATION FORFAIT SOCIAL|0 +F1HS|CSG CRDS HRS. SUPP.|0 +F200|LOGEMENT |-1 +F800|REPRISE AVANTAGE NATURE|-1 +F801|REPRISE AVANTAGE NATURE|-1 +F833|REPRISE AVANTAGE NATURE |-1 +F900|RETENUE PAYE NEGATIVE |-1 +F990|** TOTAL NON IMPOSABLE MOINS **|0 +FTPA|DECLENCHEMENT CALCUL TEPA|0 +G000|**** TOTAL NON IMPOSABLE ****|-1 +G010|NET A PAYER BULLETIN|0 +G011|NET A PAYER EN FRANCS|0 +GZZZ|COMMENTAIRE FIN DE BULLETIN|-1 +H000|HEURES PAYEES/TRAVAILLEES|0 +H004|Heures payées sans heure supplémentaire|0 +HDU0|Heures payées sans heure supplémentaire|0 +I01S|RECAPITULATIF HRS. SUPPL.|0 +IA01|SALAIRE REEL PLAF APPRENTIS|0 +IA02|BRUT FISCAL INTERMEDIAIRE|0 +IC02|Détail calcul base CSG CRDS (2011)|0 +ID01|Détail calcul Assiette CICE|0 +ID02|Détail calcul SMIC CICE|0 +ID03|Montants intermédiaires CICE|0 +IFIL|Détail Fillon AT|0 +K108|Base Régul. CSG CRDS |0 +K109|Base Régul. CSG DEDUCTIBLE |0 +K141|Base Régul. fnal suppl. T.A.|0 +K142|Base Régul. fnal suppl. > plafond|0 +K150|Base Régul. URSSAF / PLAFOND|0 +K260|Base Régul. ASSEDIC TA C260|0 +K262|Base Régul. ASF TA C262|0 +K270|Base Régul. ASSEDIC TB C270|0 +K272|Base Régul. ASF TB C272|0 +K290|Base Régul. ASSEDIC FNGS C290|0 +K300|Base Régul. RNC C300|0 +K301|Base Régul. AGFF C301|0 +K306|Base Régul. RNC C306|0 +K307|Base Régul. AGFF C307|0 +K30C|Base Régul. RETR TA C30C|0 +K502|Base Régul. Retr. Tr.B C502|0 +K503|Base Régul. AGFF Tr.B C503|0 +K50A|Base Régul. APEC TB |0 +K50D|Base Régul. Mederic APEC T.A.|0 +K50G|Base Régul. Retr. GMP C50G|0 +K51A|Base Régul. APEC TB C51A|0 +K51G|Base Régul. Retr. GMP C51G|0 +K524|Base Régul. AGFF TB C524|0 +K610|Base Régul. Prév. C610|0 +K611|Base Régul. Prév. C611|0 +K650|Base Régul. PREV TA C650|0 +K651|Base Régul. Prév. C651|0 +K655|Base Régul.PREV TB C655|0 +K656|Base Régul.PREV TB C656|0 +K65M|Base Régul. Prév. C65M|0 +K665|Base Régul. Prév. C665|0 +K666|Base Régul. Prév. C666|0 +K700|Base Régul. Mutuelle C700|0 +Q005|CUMUL JOURS OUVRES/OUVRABLES/CAL |-1 +Q008|CUMUL JOURS SS |-1 +Q009|CUMUL JOURS SS |-1 +Q010|HEURES PAYEES/TRAVAILLES|-1 +Q011|CUMUL HEURES CONTINGENT|-1 +Q014|CUMUL HEURES COMP / 25% / 50% / 100%|-1 +Q017|CUMUL CHOMAGE PARTIEL|-1 +Q020|CUMUL ABSENCE MALADIE|0 +Q021|JOURS MALADIE INDEMNISES 100%/50%|0 +Q022|CUMUL ABSENCE AT|0 +Q023|JOURS AT INDEMNISES 100%/50%|0 +Q024|CUMUL ABSENCE MATERNITE|0 +Q026|CUMUL ABSENCE AUTRE|0 +Q030|HEURES MALADIE INDEMNISES 100%/50%|0 +Q031|HEURES AT INDEMNISES 100%/50%|0 +Q032|HEURES MATERNITE INDEMNISES 100%|0 +Q090|RAG THEO/RAG_REEL/PAYE|-1 +Q100|BRUT/B.ABT/ABT/ /NET IMPOSABLE|-1 +Q101|NET A PAYE BULLETIN / CUMUL NAP|-1 +Q110|URSSAF PLAF/BASE/A/B/C |-1 +Q111|URSSAF TD/3TA/4TA |-1 +Q112|TRANCHE C SUR EXERCICE PRECEDENT|-1 +Q121|ASSEDIC PLAF/BASE/A/B/C |-1 +Q122|ASSEDIC TD/3TA/4TA|-1 +Q123|RET CA PLAF/BASE/A/B/C |-1 +Q124|RET CA TD/3TA/4TA |-1 +Q125|RET AM PLAF/BASE/A/B/C |-1 +Q126|RET AM TD/3TA/4TA |-1 +Q127|RET NC PLAF/BASE/A/B/C |-1 +Q128|RET NC TD/3TA/4TA |-1 +Q12A|GMP|-1 +Q12G|PREV CA PLAF/BASE/A/B/C |-1 +Q12H|PREV CA TD/3TA/4TA |-1 +Q12I|PREV AM PLAF/BASE/A/B/C |-1 +Q12J|PREV AM TD/3TA/4TA |-1 +Q12K|PREV NC PLAF/BASE/A/B/C |-1 +Q12L|PREV NC TD/3TA/4TA |-1 +Q12M|RET CA CET APEC PLAF/BASE/A/B/C |-1 +Q12N|RET CA CET APEC TD/3TA/4TA |-1 +Q12O|CUM RETRAITE SUP Brut Theorique|-1 +Q12P|CUM RETRAITE SUP TP PLA/TA/TB/SSTH|-1 +Q130|CUM.AV.NAT.N/L/V/A |-1 +Q132|CUMUL PEE MENSUEL/EXCEPT |-1 +Q140|CUM.FP.F/R/P/D/T |-1 +Q160|PREVOY BR/PL/TA/TB/TC|-1 +Q180|RETENUE A LA SOURCE|-1 +Q190|TAXE SUR SALAIRE|-1 +Q192|TAXE SUR SALAIRE(limitée)|-1 +Q220|CSG CRDS BASE/COT NON DED/COT DED|0 +Q222|CSG CRDS BASE/PLAF/AV. ABAT/ABAT/100%|0 +Q230|BASE TAXE PREVOYANCE|0 +Q250|BASE FORFAIT SOCIAL|0 +Q300|CUMUL ABS ENFANT MALADE|0 +Q900|CUMUL COTISATIONS SAL/PAT/COUT|0 +Q991|CUMUL AUBRY 1|-1 +Q992|CUMUL AUBRY 2|-1 +Q996|CUMUL ALLEG BAS SALAIRE |-1 +QALF|ALLOC FAM SMIC MAJ/REM/BASE/TAUX/MONTANT|-1 +QALR|ALLOC FAM SMIC MAJ/REM/BASE/TAUX/MONTANT|-1 +QDU0|DADSU - Cumuls / Etab. de rattachement|0 +QDU1|DADSU - PARTICIPATION|0 +QDU2|DADSU - INTERESSEMENT|0 +QDU3|DADSU - Abondement au PLAN D'EPARGNE|0 +QDU4|DADSU - DIVIDENDE du travail|0 +QFI1|CUMUL ALLEGEMENT FILLON|-1 +QFI2|CUMUL COT PAT FILLON|-1 +QFIA|FILLON SMIC/BRUT/BRUT-HS EXO/MONT/CotPat|-1 +QIA1|SALAIRE APPRENTIS PLAF/BASE/A/B/C |-1 +QIA2|SALAIRE APPRENTIS TD/3TA/4TA |-1 +R001|NET A PAYER MOIS PRECEDENT |-1 +R018|CP JRS PRESENCE/JRS ABSENCE|-1 +R019|CP RELIQUAT JAC/JPR/BFA/BFP|-1 +R020|CP REFERENCE JAC/JPR/BFA/BFP|0 +R021|CP EN COURS JAC/JPR/BFA/BFP|-1 +R023|CP FRACTIONNEMENT JAC/JPR|-1 +R024|CP ANCIENNETE JAC/JPR|-1 +R030|CUMUL RC ACQUIS/PRIS/SOLDE|0 +R031|CUMUL RC FERIE ACQUIS/PRIS/SOLDE|0 +R032|CUMUL HEURES RTT|0 +R035|PROVISION CP MT N/CH N/MT N-1/CH N-1|-1 +R036|PROVISION CP MT REL/CH REL|-1 +R100|PRET MNT INIT/MENS/REMB/SOLDE|-1 +R110|SAISIE ARRET Mt Initial / Mt Remboursé|-1 +R200|CUMUL BRUT CDD |-1 +R210|CUMUL TRC EXERCICE PRECEDENT|0 +R260|CUMUL COMPTE EPARGNE TEMPS|0 +R300|CUMUL GEL ANCIENNETE|0 +R301|CUMUL ANCIENNETE CDD|0 +R601|NBIJSS/MAL/AT/MAT/PLAFOND(janvier)|0 +R602|NBIJSS/MAL/AT/MAT/PLAFOND(fevrier)|0 +R603|NBIJSS/MAL/AT/MAT/PLAFOND(mars)|0 +R604|NBIJSS/MAL/AT/MAT/PLAFOND(avril)|0 +R605|NBIJSS/MAL/AT/MAT/PLAFOND(mai)|0 +R606|NBIJSS/MAL/AT/MAT/PLAFOND(juin)|0 +R607|NBIJSS/MAL/AT/MAT/PLAFOND(juillet)|0 +R608|NBIJSS/MAL/AT/MAT/PLAFOND(aout)|0 +R609|NBIJSS/MAL/AT/MAT/PLAFOND(septembre)|0 +R610|NBIJSS/MAL/AT/MAT/PLAFOND(octobre)|0 +R611|NBIJSS/MAL/AT/MAT/PLAFOND(novembre)|0 +R612|NBIJSS/MAL/AT/MAT/PLAFOND(decembre)|0 +R701|BASE SS MOIS/ PRIME MOIS AT (janvier)|0 +R702|BASE SS MOIS/ PRIME MOIS AT (fevrier)|0 +R703|BASE SS MOIS/ PRIME MOIS AT (mars)|0 +R704|BASE SS MOIS/ PRIME MOIS AT (avril)|0 +R705|BASE SS MOIS/ PRIME MOIS AT (mai)|0 +R706|BASE SS MOIS/ PRIME MOIS AT (juin)|0 +R707|BASE SS MOIS/ PRIME MOIS AT (juillet)|0 +R708|BASE SS MOIS/ PRIME MOIS AT (aout)|0 +R709|BASE SS MOIS/ PRIME MOIS AT (septembre)|0 +R710|BASE SS MOIS/ PRIME MOIS AT (octobre)|0 +R711|BASE SS MOIS/ PRIME MOIS AT (novembre)|0 +R712|BASE SS MOIS/ PRIME MOIS AT (decembre)|0 diff --git a/db/data/dbdata_rh_t_ages.SQL b/db/data/dbdata_rh_t_ages.SQL new file mode 100644 index 0000000..dc47224 --- /dev/null +++ b/db/data/dbdata_rh_t_ages.SQL @@ -0,0 +1,148 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + oid AS keepoid, + code, + texte + FROM rh.t_ages + ORDER BY code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + keepoid, + code, + texte +) +VALUES +(0, '000', 'Nouveaux nés'), +(1, '001', '1 an'), +(2, '002', '2 ans'), +(3, '003', '3 ans'), +(4, '004', '4 ans'), +(5, '005', '5 ans'), +(6, '006', '6 ans'), +(7, '007', '7 ans'), +(8, '008', '8 ans'), +(9, '009', '9 ans'), +(10, '010', '10 ans'), +(11, '011', '11 ans'), +(12, '012', '12 ans'), +(13, '013', '13 ans'), +(14, '014', '14 ans'), +(15, '015', '15 ans'), +(16, '016', '16 ans'), +(17, '017', '17 ans'), +(18, '018', '18 ans'), +(19, '019', '19 ans'), +(20, '020', '20 ans'), +(21, '021', '21 ans'), +(22, '022', '22 ans'), +(23, '023', '23 ans'), +(24, '024', '24 ans'), +(25, '025', '25 ans'), +(26, '026', '26 ans'), +(27, '027', '27 ans'), +(28, '028', '28 ans'), +(29, '029', '29 ans'), +(30, '030', '30 ans'), +(31, '031', '31 ans'), +(32, '032', '32 ans'), +(33, '033', '33 ans'), +(34, '034', '34 ans'), +(35, '035', '35 ans'), +(36, '036', '36 ans'), +(37, '037', '37 ans'), +(38, '038', '38 ans'), +(39, '039', '39 ans'), +(40, '040', '40 ans'), +(41, '041', '41 ans'), +(42, '042', '42 ans'), +(43, '043', '43 ans'), +(44, '044', '44 ans'), +(45, '045', '45 ans'), +(46, '046', '46 ans'), +(47, '047', '47 ans'), +(48, '048', '48 ans'), +(49, '049', '49 ans'), +(50, '050', '50 ans'), +(51, '051', '51 ans'), +(52, '052', '52 ans'), +(53, '053', '53 ans'), +(54, '054', '54 ans'), +(55, '055', '55 ans'), +(56, '056', '56 ans'), +(57, '057', '57 ans'), +(58, '058', '58 ans'), +(59, '059', '59 ans'), +(60, '060', '60 ans'), +(61, '061', '61 ans'), +(62, '062', '62 ans'), +(63, '063', '63 ans'), +(64, '064', '64 ans'), +(65, '065', '65 ans'), +(66, '066', '66 ans'), +(67, '067', '67 ans'), +(68, '068', '68 ans'), +(69, '069', '69 ans'), +(70, '070', '70 ans'), +(71, '071', '71 ans'), +(72, '072', '72 ans'), +(73, '073', '73 ans'), +(74, '074', '74 ans'), +(75, '075', '75 ans'), +(76, '076', '76 ans'), +(77, '077', '77 ans'), +(78, '078', '78 ans'), +(79, '079', '79 ans'), +(80, '080', '80 ans'), +(81, '081', '81 ans'), +(82, '082', '82 ans'), +(83, '083', '83 ans'), +(84, '084', '84 ans'), +(85, '085', '85 ans'), +(86, '086', '86 ans'), +(87, '087', '87 ans'), +(88, '088', '88 ans'), +(89, '089', '89 ans'), +(90, '090', '90 ans'), +(91, '091', '91 ans'), +(92, '092', '92 ans'), +(93, '093', '93 ans'), +(94, '094', '94 ans'), +(95, '095', '95 ans'), +(96, '096', '96 ans'), +(97, '097', '97 ans'), +(98, '098', '98 ans'), +(99, '099', '99 ans'), +(100, '100', '100 ans'), +(101, '101', '101 ans'), +(102, '102', '102 ans'), +(103, '103', '103 ans'), +(104, '104', '104 ans'), +(105, '105', '105 ans'), +(106, '106', '106 ans'), +(107, '107', '107 ans'), +(108, '108', '108 ans'), +(109, '109', '109 ans'), +(110, '110', '110 ans') +; + +-- 3/3 : Màj de la table iCTI +UPDATE rh.t_ages SET + code = w_dbsetup.code, + texte = w_dbsetup.texte +FROM w_dbsetup +WHERE t_ages.oid = w_dbsetup.keepoid +; + +INSERT INTO rh.t_ages(oid, code, texte) + SELECT keepoid, code, texte FROM w_dbsetup WHERE keepoid NOT IN (SELECT oid FROM rh.t_ages) +; + +SELECT * FROM rh.cti_update_schema_classes('AGE') +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_anciennetes_annee.SQL b/db/data/dbdata_rh_t_anciennetes_annee.SQL new file mode 100644 index 0000000..2339525 --- /dev/null +++ b/db/data/dbdata_rh_t_anciennetes_annee.SQL @@ -0,0 +1,88 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + oid AS keepoid, + code, + texte + FROM rh.t_anciennetes_annee + ORDER BY code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + keepoid, + code, + texte +) +VALUES +(0, '00', 'Moins de 1 an'), +(1, '01', '1 an'), +(2, '02', '2 ans'), +(3, '03', '3 ans'), +(4, '04', '4 ans'), +(5, '05', '5 ans'), +(6, '06', '6 ans'), +(7, '07', '7 ans'), +(8, '08', '8 ans'), +(9, '09', '9 ans'), +(10, '10', '10 ans'), +(11, '11', '11 ans'), +(12, '12', '12 ans'), +(13, '13', '13 ans'), +(14, '14', '14 ans'), +(15, '15', '15 ans'), +(16, '16', '16 ans'), +(17, '17', '17 ans'), +(18, '18', '18 ans'), +(19, '19', '19 ans'), +(20, '20', '20 ans'), +(21, '21', '21 ans'), +(22, '22', '22 ans'), +(23, '23', '23 ans'), +(24, '24', '24 ans'), +(25, '25', '25 ans'), +(26, '26', '26 ans'), +(27, '27', '27 ans'), +(28, '28', '28 ans'), +(29, '29', '29 ans'), +(30, '30', '30 ans'), +(31, '31', '31 ans'), +(32, '32', '32 ans'), +(33, '33', '33 ans'), +(34, '34', '34 ans'), +(35, '35', '35 ans'), +(36, '36', '36 ans'), +(37, '37', '37 ans'), +(38, '38', '38 ans'), +(39, '39', '39 ans'), +(40, '40', '40 ans'), +(41, '41', '41 ans'), +(42, '42', '42 ans'), +(43, '43', '43 ans'), +(44, '44', '44 ans'), +(45, '45', '45 ans'), +(46, '46', '46 ans'), +(47, '47', '47 ans'), +(48, '48', '48 ans'), +(49, '49', '49 ans'), +(50, '50', '50 ans') +; + +-- 3/3 : Màj de la table iCTI +UPDATE rh.t_anciennetes_annee SET + code = w_dbsetup.code, + texte = w_dbsetup.texte +FROM w_dbsetup +WHERE t_anciennetes_annee.oid = w_dbsetup.keepoid +; + +INSERT INTO rh.t_anciennetes_annee(oid, code, texte) + SELECT keepoid, code, texte FROM w_dbsetup WHERE keepoid NOT IN (SELECT oid FROM rh.t_anciennetes_annee) +; + +SELECT * FROM rh.cti_update_schema_classes('AGE') +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_categories_socio_professionnelle.SQL b/db/data/dbdata_rh_t_categories_socio_professionnelle.SQL new file mode 100644 index 0000000..7ea09ae --- /dev/null +++ b/db/data/dbdata_rh_t_categories_socio_professionnelle.SQL @@ -0,0 +1,495 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + max(oid) AS oid, + code, + texte, + texte_court + FROM rh.t_categories_socio_professionnelle + WHERE 1=1 + AND code != texte + AND substr(code, 4, 1) !~ '[0-9]' + AND code NOT IN ('642k', '643d') + GROUP BY 2,3,4 + ORDER BY code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + code, + texte, + texte_court +) +VALUES +(0, '*', 'Non renseignée', 'N/R'), +(1, '100x', 'Agriculteurs et éleveurs, salariés de leur exploitation', 'Agriculteurs et éleveurs, salariés de leur explo'), +(1, '210x', 'Artisans salariés de leur entreprise', 'Artisans salariés de leur entreprise'), +(1, '220x', 'Commerçants et assimilés, salariés de leur entreprise', 'Commerçants et assimilés, salariés de leur entr'), +(1, '231a', 'Chefs de grande entreprise de 500 salariés et plus', 'Chefs de grande entreprise de 500 salariés et plu'), +(1, '232a', 'Chefs de moyenne entreprise, de 50 à 499 salariés', 'Chefs de moyenne entreprise, de 50 à 499 salarié'), +(1, '233a', 'Chefs d''entreprise du bâtiment et des travaux publics, de 10 à 49 salariés', 'Chefs d''entreprise du bâtiment et des travaux pub'), +(1, '233b', 'Chefs d''entreprise de l''industrie ou des transports, de 10 à 49 salariés', 'Chefs d''entreprise de l''industrie ou des transport'), +(1, '233c', 'Chefs d''entreprise commerciale, de 10 à 49 salariés', 'Chefs d''entreprise commerciale, de 10 à 49 salari'), +(1, '233d', 'Chefs d''entreprise de services, de 10 à 49 salariés', 'Chefs d''entreprise de services, de 10 à 49 salari'), +(1, '311c', 'Chirurgiens dentistes', 'Chirurgiens dentistes'), +(1, '311d', 'Psychologues, psychanalystes, psychothérapeutes (non médecins)', 'Psychologues, psychanalystes, psychothérapeutes ('), +(1, '311e', 'Vétérinaires', 'Vétérinaires'), +(1, '312a', 'Avocats', 'Avocats'), +(1, '331a', 'Personnels de direction de la fonction publique (Etat, collectivités locales, hôpitaux)', 'Personnels de direction de la fonction publique (E'), +(1, '332a', 'Ingénieurs de l''Etat (y.c. ingénieurs militaires) et assimilés', 'Ingénieurs de l''Etat (y.c. ingénieurs militaires'), +(1, '332b', 'Ingénieurs des collectivités locales et des hôpitaux', 'Ingénieurs des collectivités locales et des hôp'), +(1, '333a', 'Magistrats*', 'Magistrats*'), +(1, '333b', 'Inspecteurs et autres personnels de catégorie A des Impôts, du Trésor et des Douanes', 'Inspecteurs et autres personnels de catégorie A d'), +(1, '333c', 'Cadres de la Poste*', 'Cadres de la Poste*'), +(1, '333d', 'Cadres administratifs de France Télécom (statut public)', 'Cadres administratifs de France Télécom (statut '), +(1, '333e', 'Autres personnels administratifs de catégorie A de l''Etat (hors Enseignement, Patrimoine, Impôts, Trésor, Douanes)', 'Autres personnels administratifs de catégorie A d'), +(1, '333f', 'Personnels administratifs de catégorie A des collectivités locales et hôpitaux publics (hors Enseignement, Patrimoine)', 'Personnels administratifs de catégorie A des coll'), +(1, '334a', 'Officiers des Armées et de la Gendarmerie (sauf officiers généraux)*', 'Officiers des Armées et de la Gendarmerie (sauf o'), +(1, '335a', 'Personnes exerçant un mandat politique ou syndical*', 'Personnes exerçant un mandat politique ou syndica'), +(1, '341a', 'Professeurs agrégés et certifiés de l''enseignement secondaire', 'Professeurs agrégés et certifiés de l''enseignem'), +(1, '341b', 'Chefs d''établissement de l''enseignement secondaire et inspecteurs', 'Chefs d''établissement de l''enseignement secondair'), +(1, '342b', 'Professeurs et maîtres de conférences', 'Professeurs et maîtres de conférences'), +(1, '342c', 'Professeurs agrégés et certifiés en fonction dans l''enseignement supérieur', 'Professeurs agrégés et certifiés en fonction da'), +(1, '342d', 'Personnel enseignant temporaire de l''enseignement supérieur', 'Personnel enseignant temporaire de l''enseignement '), +(1, '342f', 'Directeurs et chargés de recherche de la recherche publique', 'Directeurs et chargés de recherche de la recherch'), +(1, '342g', 'Ingénieurs d''étude et de recherche de la recherche publique', 'Ingénieurs d''étude et de recherche de la recherc'), +(1, '342h', 'Allocataires de la recherche publique', 'Allocataires de la recherche publique'), +(1, '343a', 'Psychologues spécialistes de l''orientation scolaire et professionnelle', 'Psychologues spécialistes de l''orientation scolai'), +(1, '344a', 'Médecins hospitaliers sans activité libérale', 'Médecins hospitaliers sans activité libérale'), +(1, '344b', 'Médecins salariés non hospitaliers', 'Médecins salariés non hospitaliers'), +(1, '344c', 'Internes en médecine, odontologie et pharmacie', 'Internes en médecine, odontologie et pharmacie'), +(1, '344d', 'Pharmaciens salariés', 'Pharmaciens salariés'), +(1, '351a', 'Bibliothécaires, archivistes, conservateurs et autres cadres du patrimoine', 'Bibliothécaires, archivistes, conservateurs et au'), +(1, '352a', 'Journalistes (y c. rédacteurs en chef)', 'Journalistes (y c. rédacteurs en chef)'), +(1, '352b', 'Auteurs littéraires, scénaristes, dialoguistes', 'Auteurs littéraires, scénaristes, dialoguistes'), +(1, '353a', 'Directeurs de journaux, administrateurs de presse, directeurs d''éditions (littéraire, musicale, audiovisuelle et multimédia)', 'Directeurs de journaux, administrateurs de presse,'), +(1, '353b', 'Directeurs, responsables de programmation et de production de l''audiovisuel et des spectacles', 'Directeurs, responsables de programmation et de pr'), +(1, '353c', 'Cadres artistiques et technico-artistiques de la réalisation de l''audiovisuel et des spectacles', 'Cadres artistiques et technico-artistiques de la r'), +(1, '354a', 'Artistes plasticiens', 'Artistes plasticiens'), +(1, '354b', 'Artistes de la musique et du chant', 'Artistes de la musique et du chant'), +(1, '354c', 'Artistes dramatiques', 'Artistes dramatiques'), +(1, '354e', 'Artistes de la danse', 'Artistes de la danse'), +(1, '354f', 'Artistes du cirque et des spectacles divers', 'Artistes du cirque et des spectacles divers'), +(1, '354g', 'Professeurs d''art (hors établissements scolaires)', 'Professeurs d''art (hors établissements scolaires)'), +(1, '371a', 'Cadres d''état-major administratifs, financiers, commerciaux des grandes entreprises', 'Cadres d''état-major administratifs, financiers, c'), +(1, '372a', 'Cadres chargés d''études économiques, financières, commerciales', 'Cadres chargés d''études économiques, financièr'), +(1, '372b', 'Cadres de l''organisation ou du contrôle des services administratifs et financiers', 'Cadres de l''organisation ou du contrôle des servi'), +(1, '372c', 'Cadres spécialistes des ressources humaines et du recrutement', 'Cadres spécialistes des ressources humaines et du'), +(1, '372d', 'Cadres spécialistes de la formation', 'Cadres spécialistes de la formation'), +(1, '372e', 'Juristes', 'Juristes'), +(1, '372f', 'Cadres de la documentation, de l''archivage (hors fonction publique)', 'Cadres de la documentation, de l''archivage (hors f'), +(1, '373a', 'Cadres des services financiers ou comptables des grandes entreprises', 'Cadres des services financiers ou comptables des g'), +(1, '373b', 'Cadres des autres services administratifs des grandes entreprises', 'Cadres des autres services administratifs des gran'), +(1, '373c', 'Cadres des services financiers ou comptables des petites et moyennes entreprises', 'Cadres des services financiers ou comptables des p'), +(1, '373d', 'Cadres des autres services administratifs des petites et moyennes entreprises', 'Cadres des autres services administratifs des peti'), +(1, '374a', 'Cadres de l''exploitation des magasins de vente du commerce de détail', 'Cadres de l''exploitation des magasins de vente du '), +(1, '374b', 'Chefs de produits, acheteurs du commerce et autres cadres de la mercatique', 'Chefs de produits, acheteurs du commerce et autres'), +(1, '374c', 'Cadres commerciaux des grandes entreprises (hors commerce de détail)', 'Cadres commerciaux des grandes entreprises (hors c'), +(1, '374d', 'Cadres commerciaux des petites et moyennes entreprises (hors commerce de détail)', 'Cadres commerciaux des petites et moyennes entrepr'), +(1, '375a', 'Cadres de la publicité', 'Cadres de la publicité'), +(1, '375b', 'Cadres des relations publiques et de la communication', 'Cadres des relations publiques et de la communicat'), +(1, '376a', 'Cadres des marchés financiers', 'Cadres des marchés financiers'), +(1, '376b', 'Cadres des opérations bancaires', 'Cadres des opérations bancaires'), +(1, '376c', 'Cadres commerciaux de la banque', 'Cadres commerciaux de la banque'), +(1, '376d', 'Chefs d''établissements et responsables de l''exploitation bancaire', 'Chefs d''établissements et responsables de l''explo'), +(1, '376e', 'Cadres des services techniques des assurances', 'Cadres des services techniques des assurances'), +(1, '376f', 'Cadres des services techniques des organismes de sécurité sociale et assimilés', 'Cadres des services techniques des organismes de s'), +(1, '376g', 'Cadres de l''immobilier', 'Cadres de l''immobilier'), +(1, '377a', 'Cadres de l''hôtellerie et de la restauration', 'Cadres de l''hôtellerie et de la restauration'), +(1, '380a', 'Directeurs techniques des grandes entreprises', 'Directeurs techniques des grandes entreprises'), +(1, '381b', 'Ingénieurs et cadres d''étude et développement de l''agriculture, la pêche, les eaux et forêts', 'Ingénieurs et cadres d''étude et développement d'), +(1, '381c', 'Ingénieurs et cadres de production et d''exploitation de l''agriculture, la pêche, les eaux et forêts', 'Ingénieurs et cadres de production et d''exploitat'), +(1, '382a', 'Ingénieurs et cadres d''étude du bâtiment et des travaux publics', 'Ingénieurs et cadres d''étude du bâtiment et des'), +(1, '382b', 'Architectes salariés', 'Architectes salariés'), +(1, '382c', 'Ingénieurs, cadres de chantier et conducteurs de travaux (cadres) du bâtiment et des travaux publics', 'Ingénieurs, cadres de chantier et conducteurs de '), +(1, '382d', 'Ingénieurs et cadres technico-commerciaux en bâtiment, travaux publics', 'Ingénieurs et cadres technico-commerciaux en bât'), +(1, '383a', 'Ingénieurs et cadres d''étude, recherche et développement en électricité, électronique', 'Ingénieurs et cadres d''étude, recherche et déve'), +(1, '383b', 'Ingénieurs et cadres de fabrication en matériel électrique, électronique', 'Ingénieurs et cadres de fabrication en matériel '), +(1, '383c', 'Ingénieurs et cadres technico-commerciaux en matériel électrique ou électronique professionnel', 'Ingénieurs et cadres technico-commerciaux en mat?'), +(1, '384a', 'Ingénieurs et cadres d''étude, recherche et développement en mécanique et travail des métaux', 'Ingénieurs et cadres d''étude, recherche et déve'), +(1, '384b', 'Ingénieurs et cadres de fabrication en mécanique et travail des métaux', 'Ingénieurs et cadres de fabrication en mécanique'), +(1, '384c', 'Ingénieurs et cadres technico-commerciaux en matériel mécanique professionnel', 'Ingénieurs et cadres technico-commerciaux en mat?'), +(1, '385a', 'Ingénieurs et cadres d''étude, recherche et développement des industries de transformation (agroalimentaire, chimie, métallurgie, matériaux lourds)', 'Ingénieurs et cadres d''étude, recherche et déve'), +(1, '385b', 'Ingénieurs et cadres de fabrication des industries de transformation (agroalimentaire, chimie, métallurgie, matériaux lourds)', 'Ingénieurs et cadres de fabrication des industrie'), +(1, '385c', 'Ingénieurs et cadres technico-commerciaux des industries de transformations (biens intermédiaires)', 'Ingénieurs et cadres technico-commerciaux des ind'), +(1, '386b', 'Ingénieurs et cadres d''étude, recherche et développement de la distribution d''énergie, eau', 'Ingénieurs et cadres d''étude, recherche et déve'), +(1, '386c', 'Ingénieurs et cadres d''étude, recherche et développement des autres industries (imprimerie, matériaux souples, ameublement et bois)', 'Ingénieurs et cadres d''étude, recherche et déve'), +(1, '386d', 'Ingénieurs et cadres de la production et de la distribution d''énergie, eau', 'Ingénieurs et cadres de la production et de la di'), +(1, '386e', 'Ingénieurs et cadres de fabrication des autres industries (imprimerie, matériaux souples, ameublement et bois)', 'Ingénieurs et cadres de fabrication des autres in'), +(1, '387a', 'Ingénieurs et cadres des achats et approvisionnements industriels', 'Ingénieurs et cadres des achats et approvisionnem'), +(1, '387b', 'Ingénieurs et cadres de la logistique, du planning et de l''ordonnancement', 'Ingénieurs et cadres de la logistique, du plannin'), +(1, '387c', 'Ingénieurs et cadres des méthodes de production', 'Ingénieurs et cadres des méthodes de production'), +(1, '387d', 'Ingénieurs et cadres du contrôle-qualité', 'Ingénieurs et cadres du contrôle-qualité'), +(1, '387e', 'Ingénieurs et cadres de la maintenance, de l''entretien et des travaux neufs', 'Ingénieurs et cadres de la maintenance, de l''entr'), +(1, '387f', 'Ingénieurs et cadres techniques de l''environnement', 'Ingénieurs et cadres techniques de l''environnemen'), +(1, '388a', 'Ingénieurs et cadres d''étude, recherche et développement en informatique', 'Ingénieurs et cadres d''étude, recherche et déve'), +(1, '388b', 'Ingénieurs et cadres d''administration, maintenance, support et services aux utilisateurs en informatique', 'Ingénieurs et cadres d''administration, maintenanc'), +(1, '388c', 'Chefs de projets informatiques, responsables informatiques', 'Chefs de projets informatiques, responsables infor'), +(1, '388d', 'Ingénieurs et cadres technico-commerciaux en informatique et télécommunications', 'Ingénieurs et cadres technico-commerciaux en info'), +(1, '388e', 'Ingénieurs et cadres spécialistes des télécommunications', 'Ingénieurs et cadres spécialistes des télécomm'), +(1, '389a', 'Ingénieurs et cadres techniques de l''exploitation des transports', 'Ingénieurs et cadres techniques de l''exploitation'), +(1, '389b', 'Officiers et cadres navigants techniques et commerciaux de l''aviation civile', 'Officiers et cadres navigants techniques et commer'), +(1, '389c', 'Officiers et cadres navigants techniques de la marine marchande', 'Officiers et cadres navigants techniques de la mar'), +(1, '421a', 'Instituteurs', 'Instituteurs'), +(1, '421b', 'Professeurs des écoles', 'Professeurs des écoles'), +(1, '422a', 'Professeurs d''enseignement général des collèges', 'Professeurs d''enseignement général des collèges'), +(1, '422b', 'Professeurs de lycée professionnel', 'Professeurs de lycée professionnel'), +(1, '422c', 'Maîtres auxiliaires et professeurs contractuels de l''enseignement secondaire', 'Maîtres auxiliaires et professeurs contractuels d'), +(1, '422d', 'Conseillers principaux d''éducation', 'Conseillers principaux d''éducation'), +(1, '422e', 'Surveillants et aides-éducateurs des établissements d''enseignement', 'Surveillants et aides-éducateurs des établisseme'), +(1, '423a', 'Moniteurs d''école de conduite', 'Moniteurs d''école de conduite'), +(1, '423b', 'Formateurs et animateurs de formation continue', 'Formateurs et animateurs de formation continue'), +(1, '424a', 'Moniteurs et éducateurs sportifs, sportifs professionnels', 'Moniteurs et éducateurs sportifs, sportifs profes'), +(1, '425a', 'Sous-bibliothécaires, cadres intermédiaires du patrimoine', 'Sous-bibliothécaires, cadres intermédiaires du p'), +(1, '431a', 'Cadres infirmiers et assimilés', 'Cadres infirmiers et assimilés'), +(1, '431b', 'Infirmiers psychiatriques', 'Infirmiers psychiatriques'), +(1, '431c', 'Puéricultrices', 'Puéricultrices'), +(1, '431d', 'Infirmiers spécialisés (autres qu''infirmiers psychiatriques et puéricultrices)', 'Infirmiers spécialisés (autres qu''infirmiers psy'), +(1, '431e', 'Sages-femmes salariées', 'Sages-femmes salariées'), +(1, '431f', 'Infirmiers en soins généraux, salariés', 'Infirmiers en soins généraux, salariés'), +(1, '432b', 'Masseurs-kinésithérapeutes rééducateurs, salariés', 'Masseurs-kinésithérapeutes rééducateurs, salar'), +(1, '432d', 'Autres spécialistes de la rééducation, salariés', 'Autres spécialistes de la rééducation, salarié'), +(1, '433a', 'Techniciens médicaux', 'Techniciens médicaux'), +(1, '433b', 'Opticiens lunetiers et audioprothésistes salariés', 'Opticiens lunetiers et audioprothésistes salarié'), +(1, '433c', 'Autres spécialistes de l''appareillage médical salariés', 'Autres spécialistes de l''appareillage médical sa'), +(1, '433d', 'Préparateurs en pharmacie', 'Préparateurs en pharmacie'), +(1, '434a', 'Cadres de l''intervention socio-éducative', 'Cadres de l''intervention socio-éducative'), +(1, '434b', 'Assistants de service social', 'Assistants de service social'), +(1, '434c', 'Conseillers en économie sociale familiale', 'Conseillers en économie sociale familiale'), +(1, '434d', 'Educateurs spécialisés', 'Educateurs spécialisés'), +(1, '434e', 'Moniteurs éducateurs', 'Moniteurs éducateurs'), +(1, '434f', 'Educateurs techniques spécialisés, moniteurs d''atelier', 'Educateurs techniques spécialisés, moniteurs d''a'), +(1, '434g', 'Educateurs de jeunes enfants', 'Educateurs de jeunes enfants'), +(1, '435a', 'Directeurs de centres socioculturels et de loisirs', 'Directeurs de centres socioculturels et de loisirs'), +(1, '435b', 'Animateurs socioculturels et de loisirs', 'Animateurs socioculturels et de loisirs'), +(1, '441a', 'Clergé séculier', 'Clergé séculier'), +(1, '441b', 'Clergé régulier', 'Clergé régulier'), +(1, '451a', 'Professions intermédiaires de la Poste', 'Professions intermédiaires de la Poste'), +(1, '451b', 'Professions intermédiaires administratives de France Télécom (statut public)', 'Professions intermédiaires administratives de Fra'), +(1, '451c', 'Contrôleurs des Impôts, du Trésor, des Douanes et assimilés*', 'Contrôleurs des Impôts, du Trésor, des Douanes '), +(1, '451d', 'Ingénieurs du contrôle de la navigation aérienne*', 'Ingénieurs du contrôle de la navigation aérienn'), +(1, '451e', 'Autres personnels administratifs de catégorie B de l''Etat (hors Enseignement, Patrimoine, Impôts, Trésor, Douanes)', 'Autres personnels administratifs de catégorie B d'), +(1, '451g', 'Professions intermédiaires administratives des collectivités locales', 'Professions intermédiaires administratives des co'), +(1, '451h', 'Professions intermédiaires administratives des hôpitaux', 'Professions intermédiaires administratives des h?'), +(1, '452a', 'Inspecteurs et officiers de police*', 'Inspecteurs et officiers de police*'), +(1, '452b', 'Adjudants-chefs, adjudants et sous-officiers de rang supérieur de l''Armée et de la Gendarmerie*', 'Adjudants-chefs, adjudants et sous-officiers de ra'), +(1, '461b', 'Secrétaires de direction, assistants de direction (non cadres)', 'Secrétaires de direction, assistants de direction'), +(1, '461c', 'Secrétaires de niveau supérieur (non cadres, hors secrétaires de direction)', 'Secrétaires de niveau supérieur (non cadres, hor'), +(1, '461d', 'Maîtrise et techniciens des services financiers ou comptables', 'Maîtrise et techniciens des services financiers o'), +(1, '461e', 'Maîtrise et techniciens administratifs des services juridiques ou du personnel', 'Maîtrise et techniciens administratifs des servic'), +(1, '461f', 'Maîtrise et techniciens administratifs des autres services administratifs', 'Maîtrise et techniciens administratifs des autres'), +(1, '462a', 'Chefs de petites surfaces de vente', 'Chefs de petites surfaces de vente'), +(1, '462b', 'Maîtrise de l''exploitation des magasins de vente', 'Maîtrise de l''exploitation des magasins de vente'), +(1, '462c', 'Acheteurs non classés cadres, aides-acheteurs', 'Acheteurs non classés cadres, aides-acheteurs'), +(1, '462d', 'Animateurs commerciaux des magasins de vente, marchandiseurs (non cadres)', 'Animateurs commerciaux des magasins de vente, marc'), +(1, '462e', 'Autres professions intermédiaires commerciales (sauf techniciens des forces de vente)', 'Autres professions intermédiaires commerciales (s'), +(1, '463a', 'Techniciens commerciaux et technico-commerciaux, représentants en informatique', 'Techniciens commerciaux et technico-commerciaux, r'), +(1, '463b', 'Techniciens commerciaux et technico-commerciaux, représentants en biens d''équipement, en biens intermédiaires, commerce interindustriel (hors informatique)', 'Techniciens commerciaux et technico-commerciaux, r'), +(1, '463c', 'Techniciens commerciaux et technico-commerciaux, représentants en biens de consommation auprès d''entreprises', 'Techniciens commerciaux et technico-commerciaux, r'), +(1, '463d', 'Techniciens commerciaux et technico-commerciaux, représentants en services auprès d''entreprises ou de professionnels (hors banque, assurance, informatique)', 'Techniciens commerciaux et technico-commerciaux, r'), +(1, '463e', 'Techniciens commerciaux et technico-commerciaux, représentants auprès de particuliers (hors banque, assurance, informatique)', 'Techniciens commerciaux et technico-commerciaux, r'), +(1, '464a', 'Assistants de la publicité, des relations publiques', 'Assistants de la publicité, des relations publiqu'), +(1, '464b', 'Interprètes, traducteurs', 'Interprètes, traducteurs'), +(1, '465a', 'Concepteurs et assistants techniques des arts graphiques, de la mode et de la décoration salariés', 'Concepteurs et assistants techniques des arts grap'), +(1, '465b', 'Assistants techniques de la réalisation des spectacles vivants et audiovisuels salariés', 'Assistants techniques de la réalisation des spect'), +(1, '465c', 'Photographes', 'Photographes'), +(1, '466a', 'Responsables commerciaux et administratifs des transports de voyageurs et du tourisme (non cadres)', 'Responsables commerciaux et administratifs des tra'), +(1, '466b', 'Responsables commerciaux et administratifs des transports de marchandises (non cadres)', 'Responsables commerciaux et administratifs des tra'), +(1, '466c', 'Responsables d''exploitation des transports de voyageurs et de marchandises (non cadres)', 'Responsables d''exploitation des transports de voya'), +(1, '467a', 'Chargés de clientèle bancaire', 'Chargés de clientèle bancaire'), +(1, '467b', 'Techniciens des opérations bancaires', 'Techniciens des opérations bancaires'), +(1, '467c', 'Professions intermédiaires techniques et commerciales des assurances', 'Professions intermédiaires techniques et commerci'), +(1, '467d', 'Professions intermédiaires techniques des organismes de sécurité sociale', 'Professions intermédiaires techniques des organis'), +(1, '468a', 'Maîtrise de restauration : salle et service', 'Maîtrise de restauration : salle et service'), +(1, '468b', 'Maîtrise de l''hébergement : hall et étages', 'Maîtrise de l''hébergement : hall et étages'), +(1, '471a', 'Techniciens d''étude et de conseil en agriculture, eaux et forêt', 'Techniciens d''étude et de conseil en agriculture,'), +(1, '471b', 'Techniciens d''exploitation et de contrôle de la production en agriculture, eaux et forêt', 'Techniciens d''exploitation et de contrôle de la p'), +(1, '472a', 'Dessinateurs en bâtiment, travaux publics', 'Dessinateurs en bâtiment, travaux publics'), +(1, '472b', 'Géomètres, topographes', 'Géomètres, topographes'), +(1, '472c', 'Métreurs et techniciens divers du bâtiment et des travaux publics', 'Métreurs et techniciens divers du bâtiment et de'), +(1, '472d', 'Techniciens des travaux publics de l''Etat et des collectivités locales', 'Techniciens des travaux publics de l''Etat et des c'), +(1, '473a', 'Dessinateurs en électricité, électromécanique et électronique', 'Dessinateurs en électricité, électromécanique '), +(1, '473b', 'Techniciens de recherche-développement et des méthodes de fabrication en électricité, électromécanique et électronique', 'Techniciens de recherche-développement et des mé'), +(1, '473c', 'Techniciens de fabrication et de contrôle-qualité en électricité, électromécanique et électronique', 'Techniciens de fabrication et de contrôle-qualit?'), +(1, '474a', 'Dessinateurs en construction mécanique et travail des métaux', 'Dessinateurs en construction mécanique et travail'), +(1, '474b', 'Techniciens de recherche-développement et des méthodes de fabrication en construction mécanique et travail des métaux', 'Techniciens de recherche-développement et des mé'), +(1, '474c', 'Techniciens de fabrication et de contrôle-qualité en construction mécanique et travail des métaux', 'Techniciens de fabrication et de contrôle-qualit?'), +(1, '475a', 'Techniciens de recherche-développement et des méthodes de production des industries de transformation', 'Techniciens de recherche-développement et des mé'), +(1, '475b', 'Techniciens de production et de contrôle-qualité des industries de transformation', 'Techniciens de production et de contrôle-qualité'), +(1, '476a', 'Assistants techniques, techniciens de l''imprimerie et de l''édition', 'Assistants techniques, techniciens de l''imprimerie'), +(1, '476b', 'Techniciens de l''industrie des matériaux souples, de l''ameublement et du bois', 'Techniciens de l''industrie des matériaux souples,'), +(1, '477a', 'Techniciens de la logistique, du planning et de l''ordonnancement', 'Techniciens de la logistique, du planning et de l'''), +(1, '477b', 'Techniciens d''installation et de maintenance des équipements industriels (électriques, électromécaniques, mécaniques, hors informatique)', 'Techniciens d''installation et de maintenance des ?'), +(1, '477c', 'Techniciens d''installation et de maintenance des équipements non industriels (hors informatique et télécommunications)', 'Techniciens d''installation et de maintenance des ?'), +(1, '477d', 'Techniciens de l''environnement et du traitement des pollutions', 'Techniciens de l''environnement et du traitement de'), +(1, '478a', 'Techniciens d''étude et de développement en informatique', 'Techniciens d''étude et de développement en infor'), +(1, '478b', 'Techniciens de production, d''exploitation en informatique', 'Techniciens de production, d''exploitation en infor'), +(1, '478c', 'Techniciens d''installation, de maintenance, support et services aux utilisateurs en informatique', 'Techniciens d''installation, de maintenance, suppor'), +(1, '478d', 'Techniciens des télécommunications et de l''informatique des réseaux', 'Techniciens des télécommunications et de l''infor'), +(1, '479a', 'Techniciens des laboratoires de recherche publique ou de l''enseignement', 'Techniciens des laboratoires de recherche publique'), +(1, '479b', 'Experts salariés de niveau technicien, techniciens divers', 'Experts salariés de niveau technicien, technicien'), +(1, '480a', 'Contremaîtres et agents d''encadrement (non cadres) en agriculture, sylviculture', 'Contremaîtres et agents d''encadrement (non cadres'), +(1, '480b', 'Maîtres d''équipage de la marine marchande et de la pêche', 'Maîtres d''équipage de la marine marchande et de '), +(1, '481a', 'Conducteurs de travaux (non cadres)', 'Conducteurs de travaux (non cadres)'), +(1, '481b', 'Chefs de chantier (non cadres)', 'Chefs de chantier (non cadres)'), +(1, '482a', 'Agents de maîtrise en fabrication de matériel électrique, électronique', 'Agents de maîtrise en fabrication de matériel é'), +(1, '483a', 'Agents de maîtrise en construction mécanique, travail des métaux', 'Agents de maîtrise en construction mécanique, tr'), +(1, '484a', 'Agents de maîtrise en fabrication : agroalimentaire, chimie, plasturgie, pharmacie.', 'Agents de maîtrise en fabrication : agroalimentai'), +(1, '484b', 'Agents de maîtrise en fabrication : métallurgie, matériaux lourds et autres industries de transformation', 'Agents de maîtrise en fabrication : métallurgie,'), +(1, '485a', 'Agents de maîtrise et techniciens en production et distribution d''énergie, eau, chauffage', 'Agents de maîtrise et techniciens en production e'), +(1, '485b', 'Agents de maîtrise en fabrication des autres industries (imprimerie, matériaux souples, ameublement et bois)', 'Agents de maîtrise en fabrication des autres indu'), +(1, '486b', 'Agents de maîtrise en maintenance, installation en électricité et électronique', 'Agents de maîtrise en maintenance, installation e'), +(1, '486c', 'Agents de maîtrise en maintenance, installation en électromécanique', 'Agents de maîtrise en maintenance, installation e'), +(1, '486d', 'Agents de maîtrise en maintenance, installation en mécanique', 'Agents de maîtrise en maintenance, installation e'), +(1, '486e', 'Agents de maîtrise en entretien général, installation, travaux neufs (hors mécanique, électromécanique, électronique)', 'Agents de maîtrise en entretien général, instal'), +(1, '487a', 'Responsables d''entrepôt, de magasinage', 'Responsables d''entrepôt, de magasinage'), +(1, '487b', 'Responsables du tri, de l''emballage, de l''expédition et autres responsables de la manutention', 'Responsables du tri, de l''emballage, de l''expédit'), +(1, '488a', 'Maîtrise de restauration : cuisine/production', 'Maîtrise de restauration : cuisine/production'), +(1, '488b', 'Maîtrise de restauration : gestion d''établissement', 'Maîtrise de restauration : gestion d''établissem'), +(1, '521a', 'Employés de la Poste', 'Employés de la Poste'), +(1, '521b', 'Employés de France Télécom (statut public)', 'Employés de France Télécom (statut public)'), +(1, '522a', 'Agents de constatation ou de recouvrement des Impôts, du Trésor, des Douanes*', 'Agents de constatation ou de recouvrement des Imp?'), +(1, '523a', 'Adjoints administratifs de la fonction publique (y c. enseignement)*', 'Adjoints administratifs de la fonction publique (y'), +(1, '523b', 'Adjoints administratifs de l''Etat et assimilés (sauf Poste, France Télécom)', 'Adjoints administratifs de l''Etat et assimilés (s'), +(1, '523c', 'Adjoints administratifs des collectivités locales', 'Adjoints administratifs des collectivités locales'), +(1, '523d', 'Adjoints administratifs des hôpitaux publics', 'Adjoints administratifs des hôpitaux publics'), +(1, '524a', 'Agents administratifs de la fonction publique (y c. enseignement)*', 'Agents administratifs de la fonction publique (y c'), +(1, '524b', 'Agents administratifs de l''Etat et assimilés (sauf Poste, France Télécom)', 'Agents administratifs de l''Etat et assimilés (sau'), +(1, '524c', 'Agents administratifs des collectivités locales', 'Agents administratifs des collectivités locales'), +(1, '524d', 'Agents administratifs des hôpitaux publics', 'Agents administratifs des hôpitaux publics'), +(1, '525a', 'Agents de service des établissements primaires', 'Agents de service des établissements primaires'), +(1, '525b', 'Agents de service des autres établissements d''enseignement', 'Agents de service des autres établissements d''ens'), +(1, '525c', 'Agents de service de la fonction publique (sauf écoles, hôpitaux)', 'Agents de service de la fonction publique (sauf é'), +(1, '525d', 'Agents de service hospitaliers', 'Agents de service hospitaliers'), +(1, '526a', 'Aides-soignants', 'Aides-soignants'), +(1, '526b', 'Assistants dentaires, médicaux et vétérinaires, aides de techniciens médicaux', 'Assistants dentaires, médicaux et vétérinaires,'), +(1, '526c', 'Auxiliaires de puériculture', 'Auxiliaires de puériculture'), +(1, '526d', 'Aides médico-psychologiques', 'Aides médico-psychologiques'), +(1, '526e', 'Ambulanciers salariés', 'Ambulanciers salariés'), +(1, '531a', 'Agents de police de l''Etat*', 'Agents de police de l''Etat*'), +(1, '531b', 'Agents des polices municipales*', 'Agents des polices municipales*'), +(1, '531c', 'Surveillants de l''administration pénitentiaire*', 'Surveillants de l''administration pénitentiaire*'), +(1, '532a', 'Gendarmes (de grade inférieur à adjudant)*', 'Gendarmes (de grade inférieur à adjudant)*'), +(1, '532b', 'Sergents et sous-officiers de grade équivalent des Armées (sauf pompiers militaires)*', 'Sergents et sous-officiers de grade équivalent de'), +(1, '532c', 'Hommes du rang (sauf pompiers militaires)*', 'Hommes du rang (sauf pompiers militaires)*'), +(1, '533a', 'Pompiers (y.c. pompiers militaires)', 'Pompiers (y.c. pompiers militaires)'), +(1, '533b', 'Agents techniques forestiers, gardes des espaces naturels', 'Agents techniques forestiers, gardes des espaces n'), +(1, '533c', 'Agents de surveillance du patrimoine et des administrations', 'Agents de surveillance du patrimoine et des admini'), +(1, '534a', 'Agents civils de sécurité et de surveillance', 'Agents civils de sécurité et de surveillance'), +(1, '534b', 'Convoyeurs de fonds, gardes du corps, enquêteurs privés et métiers assimilés (salariés)', 'Convoyeurs de fonds, gardes du corps, enquêteurs '), +(1, '541b', 'Agents d''accueil qualifiés, hôtesses d''accueil et d''information', 'Agents d''accueil qualifiés, hôtesses d''accueil e'), +(1, '541c', 'Agents d''accueil non qualifiés', 'Agents d''accueil non qualifiés'), +(1, '541d', 'Standardistes, téléphonistes', 'Standardistes, téléphonistes'), +(1, '542a', 'Secrétaires', 'Secrétaires'), +(1, '542b', 'Dactylos, sténodactylos (sans secrétariat), opérateurs de traitement de texte', 'Dactylos, sténodactylos (sans secrétariat), opé'), +(1, '543b', 'Employés qualifiés des services comptables ou financiers', 'Employés qualifiés des services comptables ou fi'), +(1, '543c', 'Employés non qualifiés des services comptables ou financiers', 'Employés non qualifiés des services comptables o'), +(1, '543e', 'Employés qualifiés des services du personnel et des services juridiques', 'Employés qualifiés des services du personnel et '), +(1, '543f', 'Employés qualifiés des services commerciaux des entreprises (hors vente)', 'Employés qualifiés des services commerciaux des '), +(1, '543g', 'Employés administratifs qualifiés des autres services des entreprises', 'Employés administratifs qualifiés des autres ser'), +(1, '543h', 'Employés administratifs non qualifiés', 'Employés administratifs non qualifiés'), +(1, '544a', 'Employés et opérateurs d''exploitation en informatique', 'Employés et opérateurs d''exploitation en informa'), +(1, '545a', 'Employés administratifs des services techniques de la banque', 'Employés administratifs des services techniques d'), +(1, '545b', 'Employés des services commerciaux de la banque', 'Employés des services commerciaux de la banque'), +(1, '545c', 'Employés des services techniques des assurances', 'Employés des services techniques des assurances'), +(1, '545d', 'Employés des services techniques des organismes de sécurité sociale et assimilés', 'Employés des services techniques des organismes d'), +(1, '546a', 'Contrôleurs des transports (personnels roulants)', 'Contrôleurs des transports (personnels roulants)'), +(1, '546b', 'Agents des services commerciaux des transports de voyageurs et du tourisme', 'Agents des services commerciaux des transports de '), +(1, '546c', 'Employés administratifs d''exploitation des transports de marchandises', 'Employés administratifs d''exploitation des transp'), +(1, '546d', 'Hôtesses de l''air et stewards', 'Hôtesses de l''air et stewards'), +(1, '546e', 'Autres agents et hôtesses d''accompagnement (transports, tourisme)', 'Autres agents et hôtesses d''accompagnement (trans'), +(1, '551a', 'Employés de libre service du commerce et magasiniers', 'Employés de libre service du commerce et magasini'), +(1, '552a', 'Caissiers de magasin', 'Caissiers de magasin'), +(1, '553b', 'Vendeurs polyvalents des grands magasins', 'Vendeurs polyvalents des grands magasins'), +(1, '553c', ' Autres vendeurs non spécialisés', ' Autres vendeurs non spécialisés'), +(1, '554a', 'Vendeurs en alimentation', 'Vendeurs en alimentation'), +(1, '554b', 'Vendeurs en ameublement, décor, équipement du foyer', 'Vendeurs en ameublement, décor, équipement du fo'), +(1, '554c', 'Vendeurs en droguerie, bazar, quincaillerie, bricolage', 'Vendeurs en droguerie, bazar, quincaillerie, brico'), +(1, '554d', 'Vendeurs du commerce de fleurs', 'Vendeurs du commerce de fleurs'), +(1, '554e', 'Vendeurs en habillement et articles de sport', 'Vendeurs en habillement et articles de sport'), +(1, '554f', 'Vendeurs en produits de beauté, de luxe (hors biens culturels) et optique', 'Vendeurs en produits de beauté, de luxe (hors bie'), +(1, '554g', 'Vendeurs de biens culturels (livres, disques, multimédia, objets d''art)', 'Vendeurs de biens culturels (livres, disques, mult'), +(1, '554h', 'Vendeurs de tabac, presse et articles divers', 'Vendeurs de tabac, presse et articles divers'), +(1, '554j', 'Pompistes et gérants de station-service (salariés ou mandataires)', 'Pompistes et gérants de station-service (salarié'), +(1, '555a', 'Vendeurs par correspondance, télévendeurs', 'Vendeurs par correspondance, télévendeurs'), +(1, '556a', 'Vendeurs en gros de biens d''équipement, biens intermédiaires', 'Vendeurs en gros de biens d''équipement, biens int'), +(1, '561b', 'Serveurs, commis de restaurant, garçons qualifiés', 'Serveurs, commis de restaurant, garçons qualifié'), +(1, '561c', 'Serveurs, commis de restaurant, garçons non qualifiés', 'Serveurs, commis de restaurant, garçons non quali'), +(1, '561d', 'Aides de cuisine, apprentis de cuisine et employés polyvalents de la restauration', 'Aides de cuisine, apprentis de cuisine et employé'), +(1, '561e', 'Employés de l''hôtellerie : réception et hall', 'Employés de l''hôtellerie : réception et hall'), +(1, '561f', 'Employés d''étage et employés polyvalents de l''hôtellerie', 'Employés d''étage et employés polyvalents de l''h'), +(1, '562a', 'Manucures, esthéticiens ', 'Manucures, esthéticiens '), +(1, '562b', 'Coiffeurs salariés', 'Coiffeurs salariés'), +(1, '563a', 'Assistantes maternelles, gardiennes d''enfants, familles d''accueil', 'Assistantes maternelles, gardiennes d''enfants, fam'), +(1, '563b', 'Aides à domicile, aides ménagères, travailleuses familiales', 'Aides à domicile, aides ménagères, travailleuse'), +(1, '563c', 'Employés de maison et personnels de ménage chez des particuliers', 'Employés de maison et personnels de ménage chez '), +(1, '564a', 'Concierges, gardiens d''immeubles', 'Concierges, gardiens d''immeubles'), +(1, '564b', 'Employés des services divers', 'Employés des services divers'), +(1, '621a', 'Chefs d''équipe du gros oeuvre et des travaux publics', 'Chefs d''équipe du gros oeuvre et des travaux publ'), +(1, '621b', 'Ouvriers qualifiés du travail du béton', 'Ouvriers qualifiés du travail du béton'), +(1, '621c', 'Conducteurs qualifiés d''engins de chantiers du bâtiment et des travaux publics', 'Conducteurs qualifiés d''engins de chantiers du b?'), +(1, '621d', 'Ouvriers des travaux publics en installations électriques et de télécommunications', 'Ouvriers des travaux publics en installations éle'), +(1, '621e', 'Autres ouvriers qualifiés des travaux publics', 'Autres ouvriers qualifiés des travaux publics'), +(1, '621f', 'Ouvriers qualifiés des travaux publics (salariés de l''Etat et des collectivités locales)', 'Ouvriers qualifiés des travaux publics (salariés'), +(1, '621g', 'Mineurs de fond qualifiés et autres ouvriers qualifiés des industries d''extraction (carrières, pétrole, gaz...)', 'Mineurs de fond qualifiés et autres ouvriers qual'), +(1, '622a', 'Opérateurs qualifiés sur machines automatiques en production électrique ou électronique', 'Opérateurs qualifiés sur machines automatiques e'), +(1, '622c', 'Monteurs câbleurs qualifiés en électricité', 'Monteurs câbleurs qualifiés en électricité'), +(1, '622d', 'Câbleurs qualifiés en électronique (prototype, unité, petite série)', 'Câbleurs qualifiés en électronique (prototype, '), +(1, '622e', 'Autres monteurs câbleurs en électronique', 'Autres monteurs câbleurs en électronique'), +(1, '622f', 'Bobiniers qualifiés', 'Bobiniers qualifiés'), +(1, '622g', 'Plateformistes, contrôleurs qualifiés de matériel électrique ou électronique', 'Plateformistes, contrôleurs qualifiés de matéri'), +(1, '623a', 'Chaudronniers-tôliers industriels, opérateurs qualifiés du travail en forge, conducteurs qualifiés d''équipement de formage, traceurs qualifiés', 'Chaudronniers-tôliers industriels, opérateurs qu'), +(1, '623b', 'Tuyauteurs industriels qualifiés', 'Tuyauteurs industriels qualifiés'), +(1, '623d', 'Opérateurs qualifiés sur machine de soudage', 'Opérateurs qualifiés sur machine de soudage'), +(1, '623e', 'Soudeurs manuels', 'Soudeurs manuels'), +(1, '623f', 'Opérateurs qualifiés d''usinage des métaux travaillant à l''unité ou en petite série, moulistes qualifiés', 'Opérateurs qualifiés d''usinage des métaux trava'), +(1, '623g', 'Opérateurs qualifiés d''usinage des métaux sur autres machines (sauf moulistes)', 'Opérateurs qualifiés d''usinage des métaux sur a'), +(1, '624b', 'Monteurs, metteurs au point très qualifiés d''ensembles mécaniques travaillant à l''unité ou en petite série', 'Monteurs, metteurs au point très qualifiés d''ens'), +(1, '624c', 'Monteurs qualifiés d''ensembles mécaniques travaillant en moyenne ou en grande série', 'Monteurs qualifiés d''ensembles mécaniques travai'), +(1, '624d', 'Monteurs qualifiés en structures métalliques', 'Monteurs qualifiés en structures métalliques'), +(1, '624e', 'Ouvriers qualifiés de contrôle et d''essais en mécanique', 'Ouvriers qualifiés de contrôle et d''essais en m?'), +(1, '624f', 'Ouvriers qualifiés des traitements thermiques et de surface sur métaux', 'Ouvriers qualifiés des traitements thermiques et '), +(1, '624g', 'Autres mécaniciens ou ajusteurs qualifiés (ou spécialité non reconnue)', 'Autres mécaniciens ou ajusteurs qualifiés (ou sp'), +(1, '625a', 'Pilotes d''installation lourde des industries de transformation : agroalimentaire, chimie, plasturgie, énergie', 'Pilotes d''installation lourde des industries de tr'), +(1, '625b', 'Ouvriers qualifiés et agents qualifiés de laboratoire : agroalimentaire, chimie, biologie, pharmacie', 'Ouvriers qualifiés et agents qualifiés de labora'), +(1, '625c', 'Autres opérateurs et ouvriers qualifiés de la chimie (y.c. pharmacie) et de la plasturgie', 'Autres opérateurs et ouvriers qualifiés de la ch'), +(1, '625d', 'Opérateurs de la transformation des viandes', 'Opérateurs de la transformation des viandes'), +(1, '625f', 'Autres opérateurs travaillant sur installations ou machines : industrie agroalimentaire (hors transformation des viandes)', 'Autres opérateurs travaillant sur installations o'), +(1, '625g', 'Autres ouvriers de production qualifiés ne travaillant pas sur machine : industrie agroalimentaire (hors transformation des viandes)', 'Autres ouvriers de production qualifiés ne travai'), +(1, '625h', 'Ouvriers qualifiés des autres industries (eau, gaz, énergie, chauffage)', 'Ouvriers qualifiés des autres industries (eau, ga'), +(1, '626a', 'Pilotes d''installation lourde des industries de transformation : métallurgie, production verrière, matériaux de construction', 'Pilotes d''installation lourde des industries de tr'), +(1, '626b', 'Autres opérateurs et ouvriers qualifiés : métallurgie, production verrière, matériaux de construction', 'Autres opérateurs et ouvriers qualifiés : métal'), +(1, '626c', 'Opérateurs et ouvriers qualifiés des industries lourdes du bois et de la fabrication du papier-carton', 'Opérateurs et ouvriers qualifiés des industries '), +(1, '627a', 'Opérateurs qualifiés du textile et de la mégisserie', 'Opérateurs qualifiés du textile et de la mégiss'), +(1, '627b', 'Ouvriers qualifiés de la coupe des vêtements et de l''habillement, autres opérateurs de confection qualifiés', 'Ouvriers qualifiés de la coupe des vêtements et '), +(1, '627c', 'Ouvriers qualifiés du travail industriel du cuir', 'Ouvriers qualifiés du travail industriel du cuir'), +(1, '627d', 'Ouvriers qualifiés de scierie, de la menuiserie industrielle et de l''ameublement', 'Ouvriers qualifiés de scierie, de la menuiserie i'), +(1, '627e', 'Ouvriers de la photogravure et des laboratoires photographiques et cinématographiques', 'Ouvriers de la photogravure et des laboratoires ph'), +(1, '627f', 'Ouvriers de la composition et de l''impression, ouvriers qualifiés de la brochure, de la reliure et du façonnage du papier-carton', 'Ouvriers de la composition et de l''impression, ouv'), +(1, '628a', 'Mécaniciens qualifiés de maintenance, entretien : équipements industriels', 'Mécaniciens qualifiés de maintenance, entretien '), +(1, '628b', 'Electromécaniciens, électriciens qualifiés d''entretien : équipements industriels', 'Electromécaniciens, électriciens qualifiés d''en'), +(1, '628c', 'Régleurs qualifiés d''équipements de fabrication (travail des métaux, mécanique)', 'Régleurs qualifiés d''équipements de fabrication'), +(1, '628d', 'Régleurs qualifiés d''équipements de fabrication (hors travail des métaux et mécanique)', 'Régleurs qualifiés d''équipements de fabrication'), +(1, '628e', 'Ouvriers qualifiés de l''assainissement et du traitement des déchets', 'Ouvriers qualifiés de l''assainissement et du trai'), +(1, '628f', 'Agents qualifiés de laboratoire (sauf chimie, santé)', 'Agents qualifiés de laboratoire (sauf chimie, san'), +(1, '628g', 'Ouvriers qualifiés divers de type industriel', 'Ouvriers qualifiés divers de type industriel'), +(1, '631a', 'Jardiniers', 'Jardiniers'), +(1, '632a', 'Maçons qualifiés', 'Maçons qualifiés'), +(1, '632b', 'Ouvriers qualifiés du travail de la pierre', 'Ouvriers qualifiés du travail de la pierre'), +(1, '632c', 'Charpentiers en bois qualifiés', 'Charpentiers en bois qualifiés'), +(1, '632d', 'Menuisiers qualifiés du bâtiment', 'Menuisiers qualifiés du bâtiment'), +(1, '632e', 'Couvreurs qualifiés', 'Couvreurs qualifiés'), +(1, '632f', 'Plombiers et chauffagistes qualifiés', 'Plombiers et chauffagistes qualifiés'), +(1, '632g', 'Peintres et ouvriers qualifiés de pose de revêtements sur supports verticaux', 'Peintres et ouvriers qualifiés de pose de revête'), +(1, '632h', 'Soliers moquetteurs et ouvriers qualifiés de pose de revêtements souples sur supports horizontaux', 'Soliers moquetteurs et ouvriers qualifiés de pose'), +(1, '632j', 'Monteurs qualifiés en agencement, isolation', 'Monteurs qualifiés en agencement, isolation'), +(1, '632k', 'Ouvriers qualifiés d''entretien général des bâtiments', 'Ouvriers qualifiés d''entretien général des bât'), +(1, '633a', 'Electriciens qualifiés de type artisanal (y.c. bâtiment)', 'Electriciens qualifiés de type artisanal (y.c. b?'), +(1, '633b', 'Dépanneurs qualifiés en radiotélévision, électroménager, matériel électronique (salariés)', 'Dépanneurs qualifiés en radiotélévision, élec'), +(1, '633c', 'Electriciens, électroniciens qualifiés en maintenance entretien, réparation : automobile', 'Electriciens, électroniciens qualifiés en mainte'), +(1, '633d', 'Electriciens, électroniciens qualifiés en maintenance, entretien : équipements non industriels', 'Electriciens, électroniciens qualifiés en mainte'), +(1, '634a', 'Carrossiers d''automobiles qualifiés', 'Carrossiers d''automobiles qualifiés'), +(1, '634b', 'Métalliers, serruriers qualifiés', 'Métalliers, serruriers qualifiés'), +(1, '634c', 'Mécaniciens qualifiés en maintenance, entretien, réparation : automobile', 'Mécaniciens qualifiés en maintenance, entretien,'), +(1, '634d', 'Mécaniciens qualifiés de maintenance, entretien : équipements non industriels', 'Mécaniciens qualifiés de maintenance, entretien '), +(1, '635a', 'Tailleurs et couturières qualifiés, ouvriers qualifiés du travail des étoffes (sauf fabrication de vêtements), ouvriers qualifiés de type artisanal du travail du cuir', 'Tailleurs et couturières qualifiés, ouvriers qua'), +(1, '636a', 'Bouchers (sauf industrie de la viande)', 'Bouchers (sauf industrie de la viande)'), +(1, '636b', 'Charcutiers (sauf industrie de la viande)', 'Charcutiers (sauf industrie de la viande)'), +(1, '636c', 'Boulangers, pâtissiers (sauf activité industrielle)', 'Boulangers, pâtissiers (sauf activité industriel'), +(1, '636d', 'Cuisiniers et commis de cuisine', 'Cuisiniers et commis de cuisine'), +(1, '637a', 'Modeleurs (sauf modeleurs de métal), mouleurs-noyauteurs à la main, ouvriers qualifiés du travail du verre ou de la céramique à la main', 'Modeleurs (sauf modeleurs de métal), mouleurs-noy'), +(1, '637b', 'Ouvriers d''art', 'Ouvriers d''art'), +(1, '637c', 'Ouvriers et techniciens des spectacles vivants et audiovisuels', 'Ouvriers et techniciens des spectacles vivants et '), +(1, '637d', 'Ouvriers qualifiés divers de type artisanal', 'Ouvriers qualifiés divers de type artisanal'), +(1, '641a', 'Conducteurs routiers et grands routiers', 'Conducteurs routiers et grands routiers'), +(1, '641b', 'Conducteurs de véhicule routier de transport en commun', 'Conducteurs de véhicule routier de transport en c'), +(1, '642a', 'Conducteurs de taxi', 'Conducteurs de taxi'), +(1, '642b', 'Conducteurs de voiture particulière', 'Conducteurs de voiture particulière'), +(1, '643a', 'Conducteurs livreurs, coursiers', 'Conducteurs livreurs, coursiers'), +(1, '644a', 'Conducteurs de véhicule de ramassage des ordures ménagères', 'Conducteurs de véhicule de ramassage des ordures '), +(1, '651a', 'Conducteurs d''engin lourd de levage', 'Conducteurs d''engin lourd de levage'), +(1, '651b', 'Conducteurs d''engin lourd de manoeuvre', 'Conducteurs d''engin lourd de manoeuvre'), +(1, '652a', 'Ouvriers qualifiés de la manutention, conducteurs de chariots élévateurs, caristes', 'Ouvriers qualifiés de la manutention, conducteurs'), +(1, '652b', 'Dockers', 'Dockers'), +(1, '653a', 'Magasiniers qualifiés', 'Magasiniers qualifiés'), +(1, '654b', 'Conducteurs qualifiés d''engins de transport guidés (sauf remontées mécaniques)', 'Conducteurs qualifiés d''engins de transport guid?'), +(1, '654c', 'Conducteurs qualifiés de systèmes de remontées mécaniques', 'Conducteurs qualifiés de systèmes de remontées '), +(1, '655a', 'Autres agents et ouvriers qualifiés (sédentaires) des services d''exploitation des transports', 'Autres agents et ouvriers qualifiés (sédentaires'), +(1, '656b', 'Matelots de la marine marchande', 'Matelots de la marine marchande'), +(1, '656c', 'Capitaines et matelots timoniers de la navigation fluviale', 'Capitaines et matelots timoniers de la navigation '), +(1, '671a', 'Ouvriers non qualifiés des travaux publics de l''Etat et des collectivités locales', 'Ouvriers non qualifiés des travaux publics de l''E'), +(1, '671c', 'Ouvriers non qualifiés des travaux publics et du travail du béton', 'Ouvriers non qualifiés des travaux publics et du '), +(1, '671d', 'Aides-mineurs, ouvriers non qualifiés de l''extraction', 'Aides-mineurs, ouvriers non qualifiés de l''extrac'), +(1, '672a', 'Ouvriers non qualifiés de l''électricité et de l''électronique', 'Ouvriers non qualifiés de l''électricité et de l'), +(1, '673a', 'Ouvriers de production non qualifiés travaillant par enlèvement de métal', 'Ouvriers de production non qualifiés travaillant '), +(1, '673b', 'Ouvriers de production non qualifiés travaillant par formage de métal', 'Ouvriers de production non qualifiés travaillant '), +(1, '673c', 'Ouvriers non qualifiés de montage, contrôle en mécanique et travail des métaux', 'Ouvriers non qualifiés de montage, contrôle en m'), +(1, '674a', 'Ouvriers de production non qualifiés : chimie, pharmacie, plasturgie', 'Ouvriers de production non qualifiés : chimie, ph'), +(1, '674b', 'Ouvriers de production non qualifiés de la transformation des viandes', 'Ouvriers de production non qualifiés de la transf'), +(1, '674c', 'Autres ouvriers de production non qualifiés : industrie agroalimentaire', 'Autres ouvriers de production non qualifiés : ind'), +(1, '674d', 'Ouvriers de production non qualifiés : métallurgie, production verrière, céramique, matériaux de construction', 'Ouvriers de production non qualifiés : métallurg'), +(1, '674e', 'Ouvriers de production non qualifiés : industrie lourde du bois, fabrication des papiers et cartons', 'Ouvriers de production non qualifiés : industrie '), +(1, '675a', 'Ouvriers de production non qualifiés du textile et de la confection, de la tannerie-mégisserie et du travail du cuir', 'Ouvriers de production non qualifiés du textile e'), +(1, '675b', 'Ouvriers de production non qualifiés du travail du bois et de l''ameublement', 'Ouvriers de production non qualifiés du travail d'), +(1, '675c', 'Ouvriers de production non qualifiés de l''imprimerie, presse, édition', 'Ouvriers de production non qualifiés de l''imprime'), +(1, '676a', 'Manutentionnaires non qualifiés', 'Manutentionnaires non qualifiés'), +(1, '676b', 'Déménageurs (hors chauffeurs-déménageurs), non qualifiés', 'Déménageurs (hors chauffeurs-déménageurs), non'), +(1, '676c', 'Ouvriers du tri, de l''emballage, de l''expédition, non qualifiés', 'Ouvriers du tri, de l''emballage, de l''expédition,'), +(1, '676d', 'Agents non qualifiés des services d''exploitation des transports', 'Agents non qualifiés des services d''exploitation '), +(1, '676e', 'Ouvriers non qualifiés divers de type industriel', 'Ouvriers non qualifiés divers de type industriel'), +(1, '681a', 'Ouvriers non qualifiés du gros oeuvre du bâtiment', 'Ouvriers non qualifiés du gros oeuvre du bâtimen'), +(1, '681b', 'Ouvriers non qualifiés du second oeuvre du bâtiment', 'Ouvriers non qualifiés du second oeuvre du bâtim'), +(1, '682a', 'Métalliers, serruriers, réparateurs en mécanique non qualifiés', 'Métalliers, serruriers, réparateurs en mécaniqu'), +(1, '683a', 'Apprentis boulangers, bouchers, charcutiers', 'Apprentis boulangers, bouchers, charcutiers'), +(1, '684a', 'Nettoyeurs', 'Nettoyeurs'), +(1, '684b', 'Ouvriers non qualifiés de l''assainissement et du traitement des déchets', 'Ouvriers non qualifiés de l''assainissement et du '), +(1, '685a', 'Ouvriers non qualifiés divers de type artisanal', 'Ouvriers non qualifiés divers de type artisanal'), +(1, '691a', 'Conducteurs d''engin agricole ou forestier', 'Conducteurs d''engin agricole ou forestier'), +(1, '691b', 'Ouvriers de l''élevage', 'Ouvriers de l''élevage'), +(1, '691c', 'Ouvriers du maraîchage ou de l''horticulture', 'Ouvriers du maraîchage ou de l''horticulture'), +(1, '691d', 'Ouvriers de la viticulture ou de l''arboriculture fruitière', 'Ouvriers de la viticulture ou de l''arboriculture f'), +(1, '691e', 'Ouvriers agricoles sans spécialisation particulière', 'Ouvriers agricoles sans spécialisation particuli?'), +(1, '691f', 'Ouvriers de l''exploitation forestière ou de la sylviculture', 'Ouvriers de l''exploitation forestière ou de la sy'), +(1, '692a', 'Marins-pêcheurs et ouvriers de l''aquaculture', 'Marins-pêcheurs et ouvriers de l''aquaculture') +; + +-- 3/3 : Màj de la table iCTI +UPDATE rh.t_categories_socio_professionnelle +SET code = w_dbsetup.code +FROM w_dbsetup +WHERE 1=1 + AND t_categories_socio_professionnelle.oid = w_dbsetup.oid + AND w_dbsetup.oid = 0 +; + +UPDATE rh.t_categories_socio_professionnelle +SET + texte = w_dbsetup.texte, + texte_court = w_dbsetup.texte_court +FROM w_dbsetup +WHERE t_categories_socio_professionnelle.code = w_dbsetup.code +; + +INSERT INTO rh.t_categories_socio_professionnelle(oid, code, texte, texte_court, code_original) + SELECT oid, code, texte, texte_court, code + FROM w_dbsetup + WHERE 1=1 + AND oid = 0 + AND oid NOT IN (SELECT oid FROM rh.t_categories_socio_professionnelle) +; + +INSERT INTO rh.t_categories_socio_professionnelle(code, texte, texte_court, code_original) + SELECT code, texte, texte_court, code + FROM w_dbsetup + WHERE 1=1 + AND oid != 0 + AND code NOT IN (SELECT code FROM rh.t_categories_socio_professionnelle) +; + +SELECT rh.cti_update_schema_classes('CSC') +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_chart.SQL b/db/data/dbdata_rh_t_chart.SQL new file mode 100644 index 0000000..a57a5c2 --- /dev/null +++ b/db/data/dbdata_rh_t_chart.SQL @@ -0,0 +1,62 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_chart.type, + t_chart.category, + t_chart.name, + t_chart.default_time_calc, + t_chart.label_view_code, + t_chart.code, + array_agg(DISTINCT t_indicateur_serie.code) as serie_code + FROM rh.t_chart + LEFT JOIN rh.t_indicateur_serie ON ARRAY[t_indicateur_serie.oid] <@ t_chart.serie_id + GROUP BY 1,2,3,4,5,6 + ORDER BY 1 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + type, + category, + name, + default_time_calc, + label_view_code, + code, + serie_code +) +VALUES +('card', 'date', 'Carte effectifs', 'val', 0, 'CTI_STATCAR', '{"CTI_FEMMES", "CTI_HOMMES"}'), +('donut', 'CTI_TYPECONTRAT#LS#CTI_TCNT', 'Types de contrats', 'val', 0, 'CTI_TYPECNT', '{"CTI_FEMMES", "CTI_HOMMES"}'), +('spread', 'CTI_AGE#LS#CTI_AGE', 'Effectifs par tranches age', 'val', 0, 'CTI_EFFAGE', '{"CTI_FEMMES", "CTI_HOMMES"}'), +('spread', 'CTI_AGE#LS#CTI_AGE', 'Masse salariale par tranche d''age', 'val', 0, 'CTI_MSAGE', '{"CTI_MSF", "CTI_MSH"}'), +('spread', 'CTI_ANCIENNETE#LS#CTI_ANC', 'Effectifs par tranches anciente', 'val', 0, 'CTI_EFFANC', '{"CTI_FEMMES", "CTI_HOMMES"}'), +('spread', 'CTI_STATUT#LS#CTI_STATUT', 'Effectifs par statut', 'val', 0, 'CTI_EFFSTAT', '{"CTI_FEMMES", "CTI_HOMMES"}'), +('stacked', 'CTI_CSP#DT#', 'Masse salariale par CSP', 'val', 1, 'CTI_MSCSP', '{"CTI_MSF", "CTI_MSH"}'), +('stacked', 'date', 'Effectifs par genre', 'val', 0, 'CTI_EFFGEN', '{"CTI_FEMMES", "CTI_HOMMES"}'), +('stacked', 'date', 'Heures supplementaires', 'val', 0, 'CTI_HSUPP', '{"CTI_HSUPF", "CTI_HSUPH"}'), +('stackedPercent', 'date', 'Repartition par genre', 'val', 0, 'CTI_REPGEN', '{"CTI_FEMMES", "CTI_HOMMES"}'), +('table', 'date', 'Entrees sorties carte', 'val', 0, 'CTI_ENTSORCAR', '{"CTI_DEPSALF", "CTI_DEPSALH", "CTI_EFFDF", "CTI_EFFDH", "CTI_ENTSORF", "CTI_ENTSORH", "CTI_NVSALF", "CTI_NVSALH", "CTI_TOF", "CTI_TOH"}'), +('table2d', 'CTI_STATUT#LS#CTI_STATUT', 'Tableau statuts', 'val', 0, 'CTI_STAT', '{"CTI_FEMMES", "CTI_HOMMES", "CTI_TOTSAL"}'), +('table2dTime', 'CTI_STATUT#LS#CTI_STATUT', 'Statuts temps', 'cum', 0, 'CTI_STATTIME', '{"CTI_TAUXSTAT", "CTI_TOTSAL", "CTI_TOTSALF"}'), +('treemap', 'CTI_CSP#DT#', 'Masse salariale par CSP (MAP)', 'val', 1, 'CTI_MSCSPMAP', '{"CTI_MS"}') +; + +-- 3/3 : Màj de la table iCTI +TRUNCATE rh.t_chart; + +INSERT INTO rh.t_chart(type, serie_id, category, name, default_time_calc, label_view_code, code) + SELECT + type, + array_agg(DISTINCT t_indicateur_serie.oid), + w_dbsetup.category, + w_dbsetup.name, + w_dbsetup.default_time_calc, + w_dbsetup.label_view_code, + w_dbsetup.code + FROM w_dbsetup + LEFT JOIN rh.t_indicateur_serie ON ARRAY[t_indicateur_serie.code] <@ w_dbsetup.serie_code + GROUP BY 1,3,4,5,6,7 +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_classes.SQL b/db/data/dbdata_rh_t_classes.SQL new file mode 100644 index 0000000..d350c6e --- /dev/null +++ b/db/data/dbdata_rh_t_classes.SQL @@ -0,0 +1,132 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_listes_tables.code AS table_code, + t_classes.code AS classe_code, + t_classes.texte, + t_classes.is_cti, + t_classes.contenu_by_code, + t_classes.contenu_non_replicable_ailleurs + FROM rh.t_classes + JOIN rh.t_listes_tables ON table_id = t_listes_tables.oid + WHERE t_classes.code <> '' AND + (is_cti = '1' OR t_classes.code ilike 'CTI_%') AND is_cti = '1' + ORDER BY 1,2 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + table_code, + classe_code, + texte, + is_cti, + contenu_by_code, + contenu_non_replicable_ailleurs +) +VALUES +('AGE', 'CTI_AGE', 'Tranche d''ages Bilan Social', '1', '0', '0'), +('ANC', 'CTI_ANC', 'Tranche d''ancienneté Bilan Social', '1', '0', '0'), +('MOA', 'CTI_ARRET', 'Arrêt de travail Bilan Social', '1', '0', '0'), +('MTF', 'CTI_MFIN', 'Motif de fin Bilan Social', '1', '0', '0'), +('NAT', 'CTI_NAT', 'Nationalité Bilan Social', '1', '0', '0'), +('PSE', 'CTI_CONTRIBUTION_BLOC_OPERATOIRE', 'Services du bloc opératoire pour le calcul de la contribution', '1', '0', '0'), +('QUA', 'CTI_QUAL', 'Qualifications personnels', '1', '0', '0'), +('QUA', 'CTI_SAE_CATEGORIES_PERSONNEL', 'Catégories de personnel SAE', '1', '1', '0'), +('QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL', 'Spécialités détaillées du personnel SAE', '1', '0', '0'), +('QUA', 'CTI_SAE_SPECIALITES_PERSONNEL', 'Spécialités du personnel SAE', '1', '1', '0'), +('QUA', 'CTI_SAE_TYPES_PERSONNEL', 'Types du personnel SAE', '1', '1', '0'), +('RUP', 'ALM_HRS', 'ALM Détail des heures contrat, sup, abs, maintien', '1', '0', '0'), +('RUP', 'CTI_RUB', 'Rubrique Bilan Social', '1', '0', '0'), +('SER', 'CTI_SAE_GROUPES_DISCIPLINES', 'Groupes de disciplines SAE', '1', '0', '0'), +('STA', 'CTI_STATUT', 'Statuts CTI', '1', '0', '0'), +('TCN', 'CTI_TCNT', 'Type de contrat Bilan Social', '1', '0', '0'), +('TTT', 'CTI_TTT', 'Type de temps de travail Bilan Social', '1', '0', '0') +; + +-- 3/3 : Màj de la table iCTI +ALTER TABLE w_dbsetup ADD COLUMN IF NOT EXISTS table_id bigint DEFAULT 0 +; + +UPDATE w_dbsetup +SET table_id = t_listes_tables.oid +FROM rh.t_listes_tables +WHERE t_listes_tables.code = table_code +; + +ALTER TABLE w_dbsetup ADD COLUMN IF NOT EXISTS sequence integer DEFAULT 0 +; + +UPDATE w_dbsetup +SET sequence = t_classes.sequence +FROM rh.t_classes +WHERE t_classes.code = w_dbsetup.classe_code AND + t_classes.table_id = w_dbsetup.table_id +; + + +UPDATE w_dbsetup +SET sequence = subview.sequence +FROM +( + SELECT + w_dbsetup.classe_code, + w_dbsetup.table_id, + subview.max_sequence_by_table + row_number() OVER (PARTITION BY w_dbsetup.table_id ORDER BY classe_code) AS sequence + FROM w_dbsetup + JOIN ( + SELECT + t_listes_tables.oid AS table_id, + MAX(COALESCE(t_classes.sequence, 0)) AS max_sequence_by_table + FROM rh.t_listes_tables + LEFT JOIN rh.t_classes ON t_classes.table_id = t_listes_tables.oid + GROUP BY 1 + ) AS subview ON w_dbsetup.table_id = subview.table_id + WHERE w_dbsetup.sequence = 0 +) AS subview +WHERE w_dbsetup.table_id = subview.table_id AND + w_dbsetup.classe_code = subview.classe_code AND + w_dbsetup.sequence = 0 +; + +UPDATE rh.t_classes SET + texte = w_dbsetup.texte, + table_id = w_dbsetup.table_id, + is_cti = w_dbsetup.is_cti, + contenu_by_code = w_dbsetup.contenu_by_code, + contenu_non_replicable_ailleurs = w_dbsetup.contenu_non_replicable_ailleurs +FROM w_dbsetup +WHERE 1=1 + AND t_classes.code = w_dbsetup.classe_code + AND t_classes.table_id = w_dbsetup.table_id + AND (1!=1 + OR t_classes.texte IS DISTINCT FROM w_dbsetup.texte + OR t_classes.is_cti IS DISTINCT FROM w_dbsetup.is_cti + OR t_classes.contenu_by_code IS DISTINCT FROM w_dbsetup.contenu_by_code + OR t_classes.contenu_non_replicable_ailleurs IS DISTINCT FROM w_dbsetup.contenu_non_replicable_ailleurs) +; + +INSERT INTO rh.t_classes( + code, + texte, + table_id, + is_cti, + sequence, + contenu_by_code, + contenu_non_replicable_ailleurs + ) +SELECT + w_dbsetup.classe_code, + w_dbsetup.texte, + w_dbsetup.table_id, + w_dbsetup.is_cti, + w_dbsetup.sequence, + w_dbsetup.contenu_by_code, + w_dbsetup.contenu_non_replicable_ailleurs +FROM w_dbsetup +WHERE 1=1 + AND w_dbsetup.table_id::text || '-' || w_dbsetup.sequence::text NOT IN (SELECT table_id::text || '-' || sequence::text FROM rh.t_classes) + AND w_dbsetup.texte NOT LIKE '*SUPPRIME%' +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_classes_sections.SQL b/db/data/dbdata_rh_t_classes_sections.SQL new file mode 100644 index 0000000..9ac9bc1 --- /dev/null +++ b/db/data/dbdata_rh_t_classes_sections.SQL @@ -0,0 +1,280 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_classes_sections.code, + t_classes_sections.texte, + t_classes_sections.condition, + t_classes_sections.exclude_code, + t_classes_sections.include_code, + t_listes_tables.code as table_code, + t_classes.code as classe_code + FROM rh.t_classes_sections + JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + JOIN rh.t_listes_tables ON t_listes_tables.oid = t_classes.table_id + WHERE t_classes.is_cti = 1 + ORDER BY + t_listes_tables.code, + t_classes.code, + t_classes_sections.code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + code, + texte, + condition, + exclude_code, + include_code, + table_code, + classe_code +) +VALUES +('S1', '- 25 ans', '', '', '', 'AGE', 'CTI_AGE'), +('S2', 'De 25 à 35 ans', '', '', '', 'AGE', 'CTI_AGE'), +('S3', 'De 36 à 45 ans', '', '', '', 'AGE', 'CTI_AGE'), +('S4', 'De 46 à 55 ans', '', '', '', 'AGE', 'CTI_AGE'), +('S5', 'De 56 à 65 ans', '', '', '', 'AGE', 'CTI_AGE'), +('S6', '+ de 65 ans', '', '', '', 'AGE', 'CTI_AGE'), +('S1', '- 10 ans', '', '', '', 'ANC', 'CTI_ANC'), +('S2', 'De 10 à 20 ans', '', '', '', 'ANC', 'CTI_ANC'), +('S3', 'De 21 à 30 ans', '', '', '', 'ANC', 'CTI_ANC'), +('S4', '+ de 30 ans', '', '', '', 'ANC', 'CTI_ANC'), +('ABS', 'Absence (hors divers congés, conflits et service national)', '', '', '', 'MOA', 'CTI_ARRET'), +('ACT', 'Accident du travail, de trajet ou maladie professionnelle', '', '', '', 'MOA', 'CTI_ARRET'), +('AUT', 'Autre', '', '', '', 'MOA', 'CTI_ARRET'), +('COA', 'Congé autorisé (événements familiaux, congés spéciaux pour les femmes...)', '', '', '', 'MOA', 'CTI_ARRET'), +('MAL', 'Maladie', '', '', '', 'MOA', 'CTI_ARRET'), +('MAT', 'Maternité', '', '', '', 'MOA', 'CTI_ARRET'), +('AUT', 'Autre', '', '', '', 'MTF', 'CTI_MFIN'), +('DEC', 'Décés', '', '', '', 'MTF', 'CTI_MFIN'), +('DEM', 'Démission', '', '', '', 'MTF', 'CTI_MFIN'), +('DPE', 'Départ en cours de période d''essai', '', '', '', 'MTF', 'CTI_MFIN'), +('FCD', 'Fin de CDD', '', '', '', 'MTF', 'CTI_MFIN'), +('LAC', 'Licenciement pour autres causes', '', '', '', 'MTF', 'CTI_MFIN'), +('LRP', 'Licenciement économique, dont départ en retraite et préretraite', '', '', '', 'MTF', 'CTI_MFIN'), +('MUT', 'Mutation inter entreprise', '', '', '', 'MTF', 'CTI_MFIN'), +('RPR', 'Départ volontaire en retraite et préretraite', '', '', '', 'MTF', 'CTI_MFIN'), +('ET', 'Etrangère', '', '', '', 'NAT', 'CTI_NAT'), +('FR', 'Française', '', '', '', 'NAT', 'CTI_NAT'), +('UE', 'Union Européenne', '', '', '', 'NAT', 'CTI_NAT'), +('S1', 'Bloc opératoire', '', '', '', 'PSE', 'CTI_CONTRIBUTION_BLOC_OPERATOIRE'), +('PA', 'Personnel administratif et autre', '', '', '', 'QUA', 'CTI_QUAL'), +('PM', 'Personnel médical', '', '', '', 'QUA', 'CTI_QUAL'), +('PS', 'Personnel soignant', '', '', '', 'QUA', 'CTI_QUAL'), +('M9000', 'Personnels médicaux', '', '', '[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:M*]', 'QUA', 'CTI_SAE_CATEGORIES_PERSONNEL'), +('N1000', 'Personnels de direction', '', '', '[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N1*]', 'QUA', 'CTI_SAE_CATEGORIES_PERSONNEL'), +('N2000', 'Personnels des services de soins', '', '', '[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N2*]', 'QUA', 'CTI_SAE_CATEGORIES_PERSONNEL'), +('N3000', 'Personnels éducatifs et sociaux', '', '', '[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N3*]', 'QUA', 'CTI_SAE_CATEGORIES_PERSONNEL'), +('N4000', 'Personnels médico-techniques', '', '', '[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N4*]', 'QUA', 'CTI_SAE_CATEGORIES_PERSONNEL'), +('N5000', 'Personnels techniques et ouvriers', '', '', '[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N5*]', 'QUA', 'CTI_SAE_CATEGORIES_PERSONNEL'), +('X9000', 'Hors champ SAE', '', '', '[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:X*]', 'QUA', 'CTI_SAE_CATEGORIES_PERSONNEL'), +('M1010', 'Médecine générale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1020', 'Anatomie et cytologie pathologiques', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1030', 'Anesthésie-réanimation', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1031', 'Réanimation médicale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1040', 'Cardiologie et maladies cardiovasculaires', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1050', 'Dermatologie - Vénérologie - Allergologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1070', 'Endocrinologie et maladies métaboliques', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1090', 'Gastro entérologie et hépatologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1100', 'Médecine interne etimmunologie clinique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1110', 'Néphrologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1120', 'Neurologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1130', 'Oncologie médicale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1140', 'Pédiatrie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1150', 'Pneumologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1160', 'Radiologie et imagerie médicale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1170', 'Oncologie radiothérapique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1180', 'Médecine physique et de réadaptation', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1190', 'Rhumatologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1200', 'Autres spécialités médicales', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1210', 'Médecine nucléaire', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1310', 'Génétique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1320', 'Gériatrie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1330', 'Hématologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1340', 'Médecine d''urgence', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2010', 'Chirurgie générale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2020', 'Chirurgie maxillo-faciale - Stomatologie et chirurgie orale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2030', 'Chirurgie orthopédique et traumatologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2040', 'Chirurgie plastique reconstructrice et esthétique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2050', 'Gynécologie - Obstétrique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2060', 'Neuro-chirurgie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2070', 'Ophtalmologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2080', 'Oto-rhino-laryngologie et cervico-faciale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2100', 'Chirurgie Urologique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2110', 'Autres spécialités chirurgicale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2120', 'Chirurgie viscérale et digestive', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2130', 'Chirurgie vasculaire', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2140', 'Chirurgie thoracique et cardiaque', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M2150', 'Chirurgie infantile', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3011', 'Médecins spécialisés en biologie médicale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3012', 'Pharmaciens spécialisés en biologie médicale', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3020', 'Psychiatrie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3030', 'Odontologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3040', 'Santé publique (y compris DIM)', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3050', 'Pharmacien (hors biologie médicale)', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3060', 'Médecins du travail', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M3070', 'Autres', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N1110', 'Personnel de direction', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N1210', 'Secrétaires médicaux et assistants médico-administratif', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N1220', 'Autres personnels administratifs', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N1310', 'Directeurs des soins (écoles paramédicales et soins non infirmiers)', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N1410', 'Directeur de soins infirmiers', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2120', 'Surveillants et autres personnels d''encadrement infirmiers', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2130', 'Surveillants des personnels de rééducation et autres personnels d''encadrement non infirmier', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2210', 'Infirmiers DE sans spécialisation (hors secteur psy)', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2220', 'Infirmiers DE en secteur psychiatrique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2310', 'Infirmiers DE anesthésistes', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2320', 'Infirmiers DE bloc opératoire', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2340', 'Puericultrices DE', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2350', 'Infirmiers en pratique avancée (IPA)', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2410', 'Masseurs kinésithérapeuthes', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2420', 'Pédicures - Podologues', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2430', 'Orthophonistes', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2440', 'Orthoptistes', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2450', 'Diététiciens', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2460', 'Ergothérapeuthes', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2470', 'Psychomotricien', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2480', 'Autres emplois des services de rééducation', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2510', 'Aides soignants', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2520', 'Aides médico-psychologique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2530', 'Auxilliaires de puériculture', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2610', 'Agents de service hospitalier', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2620', 'Autres personnels de service des services de soins', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2630', 'Fammilles d''accueil', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2710', 'Psychologues', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N2810', 'Sages-femmes y compris encadrement et écoles', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N3110', 'Personnels éducatifs', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N3111', 'Educateurs spécialisés', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N3120', 'Assistants de service social', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N3121', 'Cadres socio-éducatifs', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N3130', 'Autres personnels éducatifs et sociaux', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4110', 'Personnels des services de laboratoire', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N411B', 'Techniciens de laboratoire', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N411C', 'Autres personnels des services de laboratoire', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4120', 'Préparateurs en pharmacie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N412A', 'Autres personnels des services de pharmacie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4130', 'Manipulateurs d''électroradiologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4140', 'Autres personnels des services de radiologie', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4150', 'Autres personnels médico-technique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4160', 'Surveillants, cadres et autres personnels d''encadrement médico-technique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4170', 'Dosimétristes', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4180', 'Radiophysiciens - Physiciens médicaux', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N4190', 'Conseillers en génétique', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N5110', 'Ingénieurs', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N511A', 'Personnels des services techniques hors ingénieurs', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N5120', 'Personnel informatique et organisation hors ingénieur', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('N5130', 'Personnels des services techniques et des services intérieurs', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('X9190', 'Hors champ SAE Autres', '', '', '', 'QUA', 'CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL'), +('M1000', 'Spécialités médicales', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:M1*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('M2000', 'Spécialités chirurgicales', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:M2*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('M3000', 'Autres disciplines médicales', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:M3*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N1100', 'Personnels de direction', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N11*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N1200', 'Autres personnels administratifs', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N12*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N1300', 'Directeur de soins', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N13*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N1400', 'Directeur de soins infirmiers', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N14*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2100', 'Personnels d''encadrement du personnel des services de soins', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N21*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2200', 'Infirmiers DE sans spécialisation', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N22*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2300', 'Infirmiers DE avec spécialisation', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N23*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2400', 'Personnels de rééducation', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N24*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2500', 'Aides-soignants', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N25*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2600', 'Agents de services hospitaliers', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N26*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2700', 'Psychologues', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N27*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N2800', 'Sages-femmes y compris encadrement et écoles', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N28*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N3100', 'Personnels éducatifs et sociaux', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N31*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N4100', 'Personnels médico-techniques', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N41*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('N5100', 'Personnels techniques et ouvriers', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N51*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('X9100', 'Hors champs SAE', '', '', '[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:X*]', 'QUA', 'CTI_SAE_SPECIALITES_PERSONNEL'), +('M9999', 'Personnels médicaux', '', '', '[CLASSE:CTI_SAE_CATEGORIES_PERSONNEL:M*]', 'QUA', 'CTI_SAE_TYPES_PERSONNEL'), +('N9999', 'Personnels non médicaux', '', '', '[CLASSE:CTI_SAE_CATEGORIES_PERSONNEL:N*]', 'QUA', 'CTI_SAE_TYPES_PERSONNEL'), +('X9999', 'Hors champ SAE', '', '', '[CLASSE:CTI_SAE_CATEGORIES_PERSONNEL:X*]', 'QUA', 'CTI_SAE_TYPES_PERSONNEL'), +('01', 'Absence maladie', '', '', '', 'RUP', 'ALM_HRS'), +('02', 'Absence maternité', '', '', '', 'RUP', 'ALM_HRS'), +('03', 'Absence CP', '', '', '', 'RUP', 'ALM_HRS'), +('04', 'Autres absences', '', '', '', 'RUP', 'ALM_HRS'), +('05', 'Heures contractuelles', '', '', '', 'RUP', 'ALM_HRS'), +('06', 'Heures sup. et comp.', '', '', '', 'RUP', 'ALM_HRS'), +('07', 'Absence AT et MP', '', '', '', 'RUP', 'ALM_HRS'), +('08', 'Absences congés parental', '', '', '', 'RUP', 'ALM_HRS'), +('09', 'Maintien Absence maladie', '', '', '', 'RUP', 'ALM_HRS'), +('10', 'Maintien Absence maternité', '', '', '', 'RUP', 'ALM_HRS'), +('11', 'Maintien Absence CP', '', '', '', 'RUP', 'ALM_HRS'), +('12', 'Maintien Autres absences', '', '', '', 'RUP', 'ALM_HRS'), +('13', 'Maintien AT et MP', '', '', '', 'RUP', 'ALM_HRS'), +('14', 'Maintien Absence congés parental', '', '', '', 'RUP', 'ALM_HRS'), +('15', 'Heures payées', '', '', '', 'RUP', 'ALM_HRS'), +('16', 'Absences payées non travaillées SAGE', '', '', '', 'RUP', 'ALM_HRS'), +('BRU', 'Brut', '', '', '', 'RUP', 'CTI_RUB'), +('CDE', 'Cotisations déductibles', '', '', '', 'RUP', 'CTI_RUB'), +('CND', 'Cotisations non déductibles', '', '', '', 'RUP', 'CTI_RUB'), +('EXO', 'Exonérations', '', '', '', 'RUP', 'CTI_RUB'), +('GAI', 'Gains non imposables', '', '', '', 'RUP', 'CTI_RUB'), +('NAT', 'Avantages en nature', '', '', '', 'RUP', 'CTI_RUB'), +('RET', 'Retenues non imposables', '', '', '', 'RUP', 'CTI_RUB'), +('1', 'MCO', '', '', '', 'SER', 'CTI_SAE_GROUPES_DISCIPLINES'), +('2', 'PSY', '', '', '', 'SER', 'CTI_SAE_GROUPES_DISCIPLINES'), +('3', 'HAD', '', '', '', 'SER', 'CTI_SAE_GROUPES_DISCIPLINES'), +('4', 'SSR', '', '', '', 'SER', 'CTI_SAE_GROUPES_DISCIPLINES'), +('S1', 'Ouvrier', '', '', '', 'STA', 'CTI_STATUT'), +('S2', 'Employé', '', '', '', 'STA', 'CTI_STATUT'), +('S3', 'Technicien', '', '', '', 'STA', 'CTI_STATUT'), +('S4', 'Agent de maitrise', '', '', '', 'STA', 'CTI_STATUT'), +('S5', 'Cadre', '', '', '', 'STA', 'CTI_STATUT'), +('CDD', 'Contrats à durée déterminée', '', '', '', 'TCN', 'CTI_TCNT'), +('CDI', 'Contrats à durée indéterminée', '', '', '', 'TCN', 'CTI_TCNT'), +('TC', 'Temps complet', '', '', '', 'TTT', 'CTI_TTT'), +('TP', 'Temps partiel', '', '', '', 'TTT', 'CTI_TTT') +; + +-- 3/3 : Màj de la table iCTI +-- Màj des sections de classe. +UPDATE rh.t_classes_sections +SET + texte = w_dbsetup.texte, + condition = w_dbsetup.condition, + exclude_code = w_dbsetup.exclude_code, + include_code = w_dbsetup.include_code +FROM + w_dbsetup, + rh.t_classes, + rh.t_listes_tables +WHERE 1=1 + AND t_classes.oid = t_classes_sections.classe_id + AND t_listes_tables.oid = t_classes.table_id + AND w_dbsetup.code = t_classes_sections.code + AND w_dbsetup.classe_code = t_classes.code + AND w_dbsetup.table_code = t_listes_tables.code AND + ( + t_classes_sections.texte IS DISTINCT FROM w_dbsetup.texte OR + t_classes_sections.condition IS DISTINCT FROM w_dbsetup.condition OR + t_classes_sections.exclude_code IS DISTINCT FROM w_dbsetup.exclude_code OR + t_classes_sections.include_code IS DISTINCT FROM w_dbsetup.include_code + ) +; + +-- Alimentation des sections de classe. +INSERT INTO rh.t_classes_sections(code, texte, condition, exclude_code, include_code, classe_id) + SELECT + w_dbsetup.code, + w_dbsetup.texte, + w_dbsetup.condition, + w_dbsetup.exclude_code, + w_dbsetup.include_code, + t_classes.oid + FROM w_dbsetup + JOIN rh.t_listes_tables ON t_listes_tables.code = w_dbsetup.table_code + JOIN rh.t_classes ON 1=1 + AND t_classes.table_id = t_listes_tables.oid + AND t_classes.code = w_dbsetup.classe_code + WHERE 1=1 + AND w_dbsetup.code||'@'||w_dbsetup.classe_code||'@'||w_dbsetup.table_code + NOT IN ( + SELECT t_classes_sections.code||'@'||t_classes.code||'@'||t_listes_tables.code + FROM rh.t_classes_sections + JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + JOIN rh.t_listes_tables ON t_listes_tables.oid = t_classes.table_id + ) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_classes_sections_elements_ages.SQL b/db/data/dbdata_rh_t_classes_sections_elements_ages.SQL new file mode 100644 index 0000000..8de3c2e --- /dev/null +++ b/db/data/dbdata_rh_t_classes_sections_elements_ages.SQL @@ -0,0 +1,170 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_classes_sections.code AS section_code, + t_ages.code as to_code, + t_listes_tables.code as table_code, + t_classes.sequence as classe_sequence + FROM + rh.t_classes_sections_elements, + rh.t_classes_sections, + rh.t_classes, + rh.t_listes_tables, + rh.t_ages + WHERE + t_classes_sections_elements.section_id = t_classes_sections.oid + AND t_classes_sections.classe_id = t_classes.oid + AND t_classes.is_cti = 1 + AND table_id = t_listes_tables.oid + AND t_listes_tables.code = 'AGE' + AND t_classes_sections_elements.to_id = t_ages.oid + ORDER BY + t_classes.sequence, + t_classes_sections.code, + t_ages.code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + section_code, + to_code, + table_code, + classe_sequence +) +VALUES +('S1', '001', 'AGE', 9), +('S1', '002', 'AGE', 9), +('S1', '003', 'AGE', 9), +('S1', '004', 'AGE', 9), +('S1', '005', 'AGE', 9), +('S1', '006', 'AGE', 9), +('S1', '007', 'AGE', 9), +('S1', '008', 'AGE', 9), +('S1', '009', 'AGE', 9), +('S1', '010', 'AGE', 9), +('S1', '011', 'AGE', 9), +('S1', '012', 'AGE', 9), +('S1', '013', 'AGE', 9), +('S1', '014', 'AGE', 9), +('S1', '015', 'AGE', 9), +('S1', '016', 'AGE', 9), +('S1', '017', 'AGE', 9), +('S1', '018', 'AGE', 9), +('S1', '019', 'AGE', 9), +('S1', '020', 'AGE', 9), +('S1', '021', 'AGE', 9), +('S1', '022', 'AGE', 9), +('S1', '023', 'AGE', 9), +('S1', '024', 'AGE', 9), +('S2', '025', 'AGE', 9), +('S2', '026', 'AGE', 9), +('S2', '027', 'AGE', 9), +('S2', '028', 'AGE', 9), +('S2', '029', 'AGE', 9), +('S2', '030', 'AGE', 9), +('S2', '031', 'AGE', 9), +('S2', '032', 'AGE', 9), +('S2', '033', 'AGE', 9), +('S2', '034', 'AGE', 9), +('S2', '035', 'AGE', 9), +('S3', '036', 'AGE', 9), +('S3', '037', 'AGE', 9), +('S3', '038', 'AGE', 9), +('S3', '039', 'AGE', 9), +('S3', '040', 'AGE', 9), +('S3', '041', 'AGE', 9), +('S3', '042', 'AGE', 9), +('S3', '043', 'AGE', 9), +('S3', '044', 'AGE', 9), +('S3', '045', 'AGE', 9), +('S4', '046', 'AGE', 9), +('S4', '047', 'AGE', 9), +('S4', '048', 'AGE', 9), +('S4', '049', 'AGE', 9), +('S4', '050', 'AGE', 9), +('S4', '051', 'AGE', 9), +('S4', '052', 'AGE', 9), +('S4', '053', 'AGE', 9), +('S4', '054', 'AGE', 9), +('S4', '055', 'AGE', 9), +('S5', '056', 'AGE', 9), +('S5', '057', 'AGE', 9), +('S5', '058', 'AGE', 9), +('S5', '059', 'AGE', 9), +('S5', '060', 'AGE', 9), +('S5', '061', 'AGE', 9), +('S5', '062', 'AGE', 9), +('S5', '063', 'AGE', 9), +('S5', '064', 'AGE', 9), +('S5', '065', 'AGE', 9), +('S6', '066', 'AGE', 9), +('S6', '067', 'AGE', 9), +('S6', '068', 'AGE', 9), +('S6', '069', 'AGE', 9), +('S6', '070', 'AGE', 9), +('S6', '071', 'AGE', 9), +('S6', '072', 'AGE', 9), +('S6', '073', 'AGE', 9), +('S6', '074', 'AGE', 9), +('S6', '075', 'AGE', 9), +('S6', '076', 'AGE', 9), +('S6', '077', 'AGE', 9), +('S6', '078', 'AGE', 9), +('S6', '079', 'AGE', 9), +('S6', '080', 'AGE', 9), +('S6', '081', 'AGE', 9), +('S6', '082', 'AGE', 9), +('S6', '083', 'AGE', 9), +('S6', '084', 'AGE', 9), +('S6', '085', 'AGE', 9), +('S6', '086', 'AGE', 9), +('S6', '087', 'AGE', 9), +('S6', '088', 'AGE', 9), +('S6', '089', 'AGE', 9), +('S6', '090', 'AGE', 9), +('S6', '091', 'AGE', 9), +('S6', '092', 'AGE', 9), +('S6', '093', 'AGE', 9), +('S6', '094', 'AGE', 9), +('S6', '095', 'AGE', 9), +('S6', '096', 'AGE', 9), +('S6', '097', 'AGE', 9), +('S6', '098', 'AGE', 9), +('S6', '099', 'AGE', 9), +('S6', '100', 'AGE', 9), +('S6', '101', 'AGE', 9), +('S6', '102', 'AGE', 9), +('S6', '103', 'AGE', 9), +('S6', '104', 'AGE', 9), +('S6', '105', 'AGE', 9), +('S6', '106', 'AGE', 9), +('S6', '107', 'AGE', 9), +('S6', '108', 'AGE', 9), +('S6', '109', 'AGE', 9), +('S6', '110', 'AGE', 9) +; + +-- 3/3 : Màj de la table iCTI +INSERT INTO rh.t_classes_sections_elements(section_id, to_id) + SELECT + t_classes_sections.oid, + t_ages.oid + FROM w_dbsetup + JOIN rh.t_listes_tables ON t_listes_tables.code = w_dbsetup.table_code + JOIN rh.t_classes ON 1=1 + AND t_classes.table_id = t_listes_tables.oid + AND t_classes.sequence = w_dbsetup.classe_sequence + JOIN rh.t_classes_sections ON 1=1 + AND t_classes_sections.classe_id = t_classes.oid + AND t_classes_sections.code = w_dbsetup.section_code + JOIN rh.t_ages ON t_ages.code = w_dbsetup.to_code + WHERE t_classes_sections.oid::text || '-' || t_ages.oid::text NOT IN + ( + SELECT section_id::text || '-' || to_id::text + FROM rh.t_classes_sections_elements + ) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_classes_sections_elements_anciennetes_annee.SQL b/db/data/dbdata_rh_t_classes_sections_elements_anciennetes_annee.SQL new file mode 100644 index 0000000..47e9712 --- /dev/null +++ b/db/data/dbdata_rh_t_classes_sections_elements_anciennetes_annee.SQL @@ -0,0 +1,111 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_classes_sections.code AS section_code, + t_anciennetes_annee.code as to_code, + t_listes_tables.code as table_code, + t_classes.sequence as classe_sequence + FROM + rh.t_classes_sections_elements, + rh.t_classes_sections, + rh.t_classes, + rh.t_listes_tables, + rh.t_anciennetes_annee + WHERE + t_classes_sections_elements.section_id = t_classes_sections.oid + AND t_classes_sections.classe_id = t_classes.oid + AND t_classes.is_cti = 1 + AND table_id = t_listes_tables.oid + AND t_listes_tables.code = 'ANC' + AND t_classes_sections_elements.to_id = t_anciennetes_annee.oid + ORDER BY + t_classes.sequence, + t_classes_sections.code, + t_anciennetes_annee.code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + section_code, + to_code, + table_code, + classe_sequence +) +VALUES +('S1', '00', 'ANC', 9), +('S1', '01', 'ANC', 9), +('S1', '02', 'ANC', 9), +('S1', '03', 'ANC', 9), +('S1', '04', 'ANC', 9), +('S1', '05', 'ANC', 9), +('S1', '06', 'ANC', 9), +('S1', '07', 'ANC', 9), +('S1', '08', 'ANC', 9), +('S1', '09', 'ANC', 9), +('S2', '10', 'ANC', 9), +('S2', '11', 'ANC', 9), +('S2', '12', 'ANC', 9), +('S2', '13', 'ANC', 9), +('S2', '14', 'ANC', 9), +('S2', '15', 'ANC', 9), +('S2', '16', 'ANC', 9), +('S2', '17', 'ANC', 9), +('S2', '18', 'ANC', 9), +('S2', '19', 'ANC', 9), +('S2', '20', 'ANC', 9), +('S3', '21', 'ANC', 9), +('S3', '22', 'ANC', 9), +('S3', '23', 'ANC', 9), +('S3', '24', 'ANC', 9), +('S3', '25', 'ANC', 9), +('S3', '26', 'ANC', 9), +('S3', '27', 'ANC', 9), +('S3', '28', 'ANC', 9), +('S3', '29', 'ANC', 9), +('S3', '30', 'ANC', 9), +('S4', '31', 'ANC', 9), +('S4', '32', 'ANC', 9), +('S4', '33', 'ANC', 9), +('S4', '34', 'ANC', 9), +('S4', '35', 'ANC', 9), +('S4', '36', 'ANC', 9), +('S4', '37', 'ANC', 9), +('S4', '38', 'ANC', 9), +('S4', '39', 'ANC', 9), +('S4', '40', 'ANC', 9), +('S4', '41', 'ANC', 9), +('S4', '42', 'ANC', 9), +('S4', '43', 'ANC', 9), +('S4', '44', 'ANC', 9), +('S4', '45', 'ANC', 9), +('S4', '46', 'ANC', 9), +('S4', '47', 'ANC', 9), +('S4', '48', 'ANC', 9), +('S4', '49', 'ANC', 9), +('S4', '50', 'ANC', 9) +; + +-- 3/3 : Màj de la table iCTI +INSERT INTO rh.t_classes_sections_elements(section_id, to_id) + SELECT + t_classes_sections.oid, + t_anciennetes_annee.oid + FROM w_dbsetup + JOIN rh.t_listes_tables ON t_listes_tables.code = w_dbsetup.table_code + JOIN rh.t_classes ON 1=1 + AND t_classes.table_id = t_listes_tables.oid + AND t_classes.sequence = w_dbsetup.classe_sequence + JOIN rh.t_classes_sections ON 1=1 + AND t_classes_sections.classe_id = t_classes.oid + AND t_classes_sections.code = w_dbsetup.section_code + JOIN rh.t_anciennetes_annee ON t_anciennetes_annee.code = w_dbsetup.to_code + WHERE t_classes_sections.oid::text || '-' || t_anciennetes_annee.oid::text NOT IN + ( + SELECT section_id::text || '-' || to_id::text + FROM rh.t_classes_sections_elements + ) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_dashboard.SQL b/db/data/dbdata_rh_t_dashboard.SQL new file mode 100644 index 0000000..293b1c2 --- /dev/null +++ b/db/data/dbdata_rh_t_dashboard.SQL @@ -0,0 +1,29 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + code, label + FROM rh.t_dashboard + ORDER BY code LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + code, + label +) +VALUES +('CTI_EGAPRO', 'Cockpit RH') +; + +-- 3/3 : Màj de la table iCTI +TRUNCATE rh.t_dashboard; + +INSERT INTO rh.t_dashboard(code, label) + SELECT + w_dbsetup.code, + w_dbsetup.label + FROM w_dbsetup +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_dashboard_filter.SQL b/db/data/dbdata_rh_t_dashboard_filter.SQL new file mode 100644 index 0000000..40004bc --- /dev/null +++ b/db/data/dbdata_rh_t_dashboard_filter.SQL @@ -0,0 +1,40 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_dashboard_filter.oid, + t_dashboard.code as dashboard_code, + t_indicateur_condition.external_code2 + FROM rh.t_dashboard_filter + LEFT JOIN rh.t_dashboard ON t_dashboard.oid = dashboard_id + LEFT JOIN rh.t_indicateur_condition ON t_indicateur_condition.oid = condition_id + ORDER BY 2, 3 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + dashboard_code, + external_code2 +) +VALUES +(1, 'CTI_EGAPRO', 'CTI_AGE#LS#AGE:CTI_AGE:S1'), +(1, 'CTI_EGAPRO', 'CTI_AGE#LS#AGE:CTI_AGE:S3'), +(1, 'CTI_EGAPRO', 'CTI_AGE#LS#AGE:CTI_AGE:S6'), +(1, 'CTI_EGAPRO', 'CTI_SEXE#DT#1'), +(1, 'CTI_EGAPRO', 'CTI_SEXE#DT#2') +; + +-- 3/3 : Màj de la table iCTI +TRUNCATE rh.t_dashboard_filter; + +INSERT INTO rh.t_dashboard_filter(dashboard_id,condition_id) + SELECT + t_dashboard.oid, + t_indicateur_condition.oid + FROM w_dbsetup + LEFT JOIN rh.t_dashboard ON t_dashboard.code = w_dbsetup.dashboard_code + LEFT JOIN rh.t_indicateur_condition ON t_indicateur_condition.external_code2 = w_dbsetup.external_code2 +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_dashboard_onglet.SQL b/db/data/dbdata_rh_t_dashboard_onglet.SQL new file mode 100644 index 0000000..b4aa737 --- /dev/null +++ b/db/data/dbdata_rh_t_dashboard_onglet.SQL @@ -0,0 +1,38 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_dashboard_onglet.oid, + t_dashboard.code as dashboard_code, + name, + index + FROM rh.t_dashboard_onglet + LEFT JOIN rh.t_dashboard ON t_dashboard.oid = dashboard_id + ORDER BY 2, 4 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + dashboard_code, + name, + index +) +VALUES +(1, 'CTI_EGAPRO', 'Effectif', 0), +(1, 'CTI_EGAPRO', 'Masse Salariale', 1) +; + +-- 3/3 : Màj de la table iCTI +TRUNCATE rh.t_dashboard_onglet; + +INSERT INTO rh.t_dashboard_onglet(dashboard_id, name, index) + SELECT + t_dashboard.oid, + w_dbsetup.name, + w_dbsetup.index + FROM w_dbsetup + LEFT JOIN rh.t_dashboard ON t_dashboard.code = dashboard_code +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_dashboard_widget.SQL b/db/data/dbdata_rh_t_dashboard_widget.SQL new file mode 100644 index 0000000..21a7ff1 --- /dev/null +++ b/db/data/dbdata_rh_t_dashboard_widget.SQL @@ -0,0 +1,49 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_dashboard_widget.oid, + t_chart.code as chart_code, + t_dashboard.code as dashboard_code, + t_dashboard_widget.deprecated + FROM rh.t_dashboard_widget + LEFT JOIN rh.t_chart ON t_chart.oid = chart_id + LEFT JOIN rh.t_dashboard ON t_dashboard.oid = dashboard_id + ORDER BY 1 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + chart_code, + dashboard_code, + deprecated +) +VALUES +(1, 'CTI_STATTIME', 'CTI_EGAPRO', 't'), +(1, 'CTI_TYPECNT', 'CTI_EGAPRO', 'f'), +(1, 'CTI_STAT', 'CTI_EGAPRO', 'f'), +(1, 'CTI_EFFANC', 'CTI_EGAPRO', 'f'), +(1, 'CTI_ENTSORCAR', 'CTI_EGAPRO', 'f'), +(1, 'CTI_MSCSPMAP', 'CTI_EGAPRO', 'f'), +(1, 'CTI_MSAGE', 'CTI_EGAPRO', 'f'), +(1, 'CTI_EFFGEN', 'CTI_EGAPRO', 'f'), +(1, 'CTI_EFFAGE', 'CTI_EGAPRO', 'f'), +(1, 'CTI_EFFSTAT', 'CTI_EGAPRO', 'f'), +(1, 'CTI_MSCSP', 'CTI_EGAPRO', 'f') +; + +-- 3/3 : Màj de la table iCTI +TRUNCATE rh.t_dashboard_widget; + +INSERT INTO rh.t_dashboard_widget(dashboard_id, chart_id, deprecated) + SELECT + t_dashboard.oid, + t_chart.oid, + w_dbsetup.deprecated + FROM w_dbsetup + LEFT JOIN rh.t_chart ON t_chart.code = chart_code + LEFT JOIN rh.t_dashboard ON t_dashboard.code = dashboard_code +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_expert_controle.SQL b/db/data/dbdata_rh_t_expert_controle.SQL new file mode 100644 index 0000000..3345981 --- /dev/null +++ b/db/data/dbdata_rh_t_expert_controle.SQL @@ -0,0 +1,163 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + oid, + code, + texte, + description, + is_cti, + gravite_id + FROM rh.t_expert_controle + WHERE is_cti = '1' + ORDER BY code LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + code, + texte, + description, + is_cti, + gravite_id +) +VALUES +(0, '', '', '', '1', 1), +(1, 'CTI_NIV1_C000', 'Présence de C000', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_CAD_EMP_NR', 'Cadre d''emploi non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_CAT_STAT_NR', 'Catégorie statutaire non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_CE_NR', 'Code emploi non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_COD_POST_NR', 'Code postal non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_COM_PAR_NR', 'Commission paritaire non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_CSP_NR', 'Catégorie socio-professionnelle non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_CTRID_NULL', 'Contrat ID null en paie', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_DAT_NAIS_NR', 'Date de naissance non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_DTEDEB_NR', 'Date de début de contrat non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_DTEFIN_NR', 'Date de fin de contrat non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_FIL_NR', 'Filière non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_GRI_NR', 'Grille non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_GROGRI_NR', 'Groupe Grille non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_GRO_COT_NR', 'Groupe de cotisant non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_MOTDEB_NR', 'Motif de début non renseigné', 'Contrats sans motif de début.', '1', '9', 'A1'), +(1, 'CTI_NIV1_MOTFIN_NR', 'Motif de Fin non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_NAT_NR', 'Nationalité non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_QUAL_NR', 'Qualification non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_SEX_NR', 'Sexe non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_SPE_NR', 'Spécialité non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_SRV_NR', 'Service non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_STT_NR', 'Statut non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_TC_NR', 'Type de contrat non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_TTT_NR', 'Type temps travail non renseigné', '', '1', '9', 'A1'), +(1, 'CTI_NIV1_UNI_FONC_NR', 'Unité fonctionnelle non renseignée', '', '1', '9', 'A1'), +(1, 'CTI_NIV2_C000_BRUT', 'Présence C000 BRUT', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_COT_PAT', 'Présence C000 Cotisation Patronale', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_COT_SAL', 'Présence C000 Cotisation Salariale', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_H_CONTRAT', 'Présence C000 Heures Contrat', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_H_PAYEES', 'Présence C000 Heures Payées', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_H_TRAVAILLEES', 'Présence C000 Heures Travaillées', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_MASSE_SALARIALE', 'Présence C000 Masse Salariale', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_NET_A_PAYE', 'Présence C000 Net A Payer Salarié', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_C000_NET_IMP', 'Présence C000 Net Imposable Salarié', '', '1', '5', 'A1'), +(1, 'CTI_NIV2_HCSORTI', 'Salarié avec plus d''une paie avec heures contrat après sortie de l''établissement', '', '1', '5', 'A1'), +(1, 'CTI_NIV3_PRESENCE_PAIE_PAS_PLANNING', 'Liste des salariés présents en paie mais pas au planning', 'Liste des salariés présents en paie mais pas au planning', '1', 1, 'A2'), +(1, 'CTI_NIV3_PRESENCE_PLANNING_PAS_PAIE', 'Liste des personnes présentes au planning mais pas en planning', 'Liste des personnes présentes au planning mais pas en planning', '1', 1, 'A2') + +; + +-- 3/3 : Màj de la table iCTI +UPDATE rh.t_expert_controle SET + code = w_dbsetup.code, + texte = w_dbsetup.texte, + description = w_dbsetup.description, + is_cti = w_dbsetup.is_cti, + gravite_id = w_dbsetup.gravite_id +FROM w_dbsetup +WHERE 1=1 + AND w_dbsetup.oid = 0 + AND rh.t_expert_controle.oid = w_dbsetup.oid + AND + ( + t_expert_controle.code IS DISTINCT FROM w_dbsetup.code OR + t_expert_controle.texte IS DISTINCT FROM w_dbsetup.texte OR + t_expert_controle.description IS DISTINCT FROM w_dbsetup.description OR + t_expert_controle.is_cti IS DISTINCT FROM w_dbsetup.is_cti OR + t_expert_controle.gravite_id IS DISTINCT FROM w_dbsetup.gravite_id + ) +; + +UPDATE rh.t_expert_controle SET + code = w_dbsetup.code, + texte = w_dbsetup.texte, + description = w_dbsetup.description, + is_cti = w_dbsetup.is_cti, + gravite_id = w_dbsetup.gravite_id +FROM w_dbsetup +WHERE 1=1 + AND w_dbsetup.oid <> 0 + AND rh.t_expert_controle.code = w_dbsetup.code + AND + ( + t_expert_controle.texte IS DISTINCT FROM w_dbsetup.texte OR + t_expert_controle.description IS DISTINCT FROM w_dbsetup.description OR + t_expert_controle.is_cti IS DISTINCT FROM w_dbsetup.is_cti OR + t_expert_controle.gravite_id IS DISTINCT FROM w_dbsetup.gravite_id + ) +; + +INSERT INTO rh.t_expert_controle( + oid, + code, + texte, + description, + is_active, + was_active, + is_hide, + alerte_id, + is_cti, + gravite_id + ) +SELECT + oid, + code, + texte, + description, + '1' AS is_active, + '0' AS is_hide, + 0::bigint AS alerte_id, + is_cti, + gravite_id, + date(date_trunc('year',now())) AS date_validite_debut +FROM w_dbsetup +WHERE 1=1 + AND w_dbsetup.oid = 0 + AND w_dbsetup.oid NOT IN (SELECT oid FROM rh.t_expert_controle) +; + +INSERT INTO rh.t_expert_controle( + code, + texte, + description, + is_active, + is_hide, + alerte_id, + is_cti, + gravite_id + ) +SELECT + code, + texte, + description, + '1' AS is_active, + '0' AS was_active, + '0' AS is_hide, + 0::bigint AS alerte_id, + is_cti, + gravite_id +FROM w_dbsetup +WHERE 1=1 + AND w_dbsetup.oid <> 0 + AND w_dbsetup.code NOT IN (SELECT code FROM rh.t_expert_controle) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_expert_controle_rule.SQL b/db/data/dbdata_rh_t_expert_controle_rule.SQL new file mode 100644 index 0000000..622b022 --- /dev/null +++ b/db/data/dbdata_rh_t_expert_controle_rule.SQL @@ -0,0 +1,273 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_expert_controle_rule.oid, + t_expert_controle.code AS expert_controle_code, + t_expert_controle_rule.data_type, + t_indicateurs.code AS indicateur_code, + COALESCE(t_indicateur_condition_1.external_code2,'') AS indicateur_condition_external_code_1, + COALESCE(t_indicateur_condition_2.external_code2,'') AS indicateur_condition_external_code_2, + COALESCE(t_indicateur_condition_3.external_code2,'') AS indicateur_condition_external_code_3, + t_expert_controle_rule.formula, + t_indicateurs_2.code AS indicateur_code_2, + COALESCE(t_indicateur_condition_21.external_code2,'') AS indicateur_condition_external_code_21, + COALESCE(t_indicateur_condition_22.external_code2,'') AS indicateur_condition_external_code_22, + COALESCE(t_indicateur_condition_23.external_code2,'') AS indicateur_condition_external_code_23, + t_expert_controle_rule.formula_2, + t_indicateurs_3.code AS indicateur_code_3, + COALESCE(t_indicateur_condition_31.external_code2,'') AS indicateur_condition_external_code_31, + COALESCE(t_indicateur_condition_32.external_code2,'') AS indicateur_condition_external_code_32, + COALESCE(t_indicateur_condition_33.external_code2,'') AS indicateur_condition_external_code_33, + t_expert_controle_rule.formula_3, + 0::bigint AS expert_controle_id, + 0::bigint AS expert_controle_rule_id, + 0::bigint AS indicateur_id, + 0::bigint AS indicateur_condition_id_1, + 0::bigint AS indicateur_condition_id_2, + 0::bigint AS indicateur_condition_id_3, + 0::bigint AS indicateur_2_id, + 0::bigint AS indicateur_condition_id_21, + 0::bigint AS indicateur_condition_id_22, + 0::bigint AS indicateur_condition_id_23, + 0::bigint AS indicateur_3_id, + 0::bigint AS indicateur_condition_id_31, + 0::bigint AS indicateur_condition_id_32, + 0::bigint AS indicateur_condition_id_33 + FROM rh.t_expert_controle_rule + JOIN rh.t_expert_controle ON expert_controle_id = t_expert_controle.oid + JOIN rh.t_indicateurs t_indicateurs ON indicateur_id = t_indicateurs.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_1 ON indicateur_condition_id[1] = t_indicateur_condition_1.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_2 ON indicateur_condition_id[2] = t_indicateur_condition_2.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_3 ON indicateur_condition_id[3] = t_indicateur_condition_3.oid + LEFT JOIN rh.t_indicateurs t_indicateurs_2 ON indicateur_2_id = t_indicateurs_2.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_21 ON indicateur_condition_2_id[1] = t_indicateur_condition_21.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_22 ON indicateur_condition_2_id[2] = t_indicateur_condition_22.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_23 ON indicateur_condition_2_id[3] = t_indicateur_condition_23.oid + LEFT JOIN rh.t_indicateurs t_indicateurs_3 ON indicateur_3_id = t_indicateurs_3.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_31 ON indicateur_condition_3_id[1] = t_indicateur_condition_31.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_32 ON indicateur_condition_3_id[2] = t_indicateur_condition_32.oid + LEFT JOIN rh.t_indicateur_condition t_indicateur_condition_33 ON indicateur_condition_3_id[3] = t_indicateur_condition_33.oid + WHERE t_expert_controle_rule.is_cti = '1' AND + t_expert_controle_rule.indicateur_id > 0 AND + t_expert_controle.is_cti = '1' + ORDER BY t_expert_controle.code, + t_indicateurs.code, + t_indicateur_condition_1.code, + t_indicateur_condition_2.code, + t_indicateur_condition_3.code + + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + expert_controle_code, + data_type, + indicateur_code, + indicateur_condition_external_code_1, + indicateur_condition_external_code_2, + indicateur_condition_external_code_3, + formula, + indicateur_code_2, + indicateur_condition_external_code_21, + indicateur_condition_external_code_22, + indicateur_condition_external_code_23, + formula_2, + indicateur_code_3, + indicateur_condition_external_code_31, + indicateur_condition_external_code_32, + indicateur_condition_external_code_33, + formula_3, + expert_controle_id, + expert_controle_rule_id, + indicateur_id, + indicateur_condition_id_1, + indicateur_condition_id_2, + indicateur_condition_id_3, + indicateur_2_id, + indicateur_condition_id_21, + indicateur_condition_id_22, + indicateur_condition_id_23, + indicateur_3_id, + indicateur_condition_id_31, + indicateur_condition_id_32, + indicateur_condition_id_33 +) +VALUES +(1, 'CTI_NIV1_C000', 'salarie', 'CTI_C000', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_CAD_EMP_NR', 'salarie', 'CTI_CDM', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_CAT_STAT_NR', 'salarie', 'CTI_CST', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_CE_NR', 'salarie', 'CTI_CEM', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_COD_POST_NR', 'salarie', 'CTI_CPO', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_COM_PAR_NR', 'salarie', 'CTI_CPA', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_CSP_NR', 'salarie', 'CTI_CSP', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_CTRID_NULL', 'salarie', 'CTI_CTRID_NULL', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_DAT_NAIS_NR', 'salarie', 'CTI_DNA', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_DTEDEB_NR', 'salarie', 'CTI_DTEDEB_NR', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_DTEFIN_NR', 'salarie', 'CTI_DTEFIN_NR', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_FIL_NR', 'salarie', 'CTI_FIL', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_GRI_NR', 'salarie', 'CTI_GRI', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_GROGRI_NR', 'salarie', 'CTI_GGR', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_GRO_COT_NR', 'salarie', 'CTI_GCO', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_MOTDEB_NR', 'salarie', 'CTI_MDD', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_MOTFIN_NR', 'salarie', 'CTI_MDF', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_NAT_NR', 'salarie', 'CTI_NAT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_QUAL_NR', 'salarie', 'CTI_QUA', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_SEX_NR', 'salarie', 'CTI_SEX', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_SPE_NR', 'salarie', 'CTI_SPE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_SRV_NR', 'salarie', 'CTI_SER', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_STT_NR', 'salarie', 'CTI_STA', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_TC_NR', 'salarie', 'CTI_TCNT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_TTT_NR', 'salarie', 'CTI_TTT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV1_UNI_FONC_NR', 'salarie', 'CTI_UFO', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_BRUT', 'salarie', 'CTI_C000_BRUT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_COT_PAT', 'salarie', 'CTI_C000_COT_PAT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_COT_SAL', 'salarie', 'CTI_C000_COT_SAL', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_H_CONTRAT', 'salarie', 'CTI_C000_H_CONTRAT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_H_PAYEES', 'salarie', 'CTI_C000_H_PAYEES', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_H_TRAVAILLEES', 'salarie', 'CTI_C000_H_TRAVAILLES', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_MASSE_SALARIALE', 'salarie', 'CTI_C000_MASSE_SALARIALE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_NET_A_PAYE', 'salarie', 'CTI_C000_NET_A_PAYE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV2_C000_NET_IMP', 'salarie', 'CTINETIMPOS', 'CTI_RUBRIQUE#DT#C000', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV3_PRESENCE_PAIE_PAS_PLANNING', 'salarie', 'CTI_PRESENCE_PAIE_PAS_PLANNING', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(1, 'CTI_NIV3_PRESENCE_PLANNING_PAS_PAIE', 'salarie', 'CTI_PRESENCE_PLANNING_PAS_PAIE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) +; + +-- 3/3 : Màj de la table iCTI +SELECT rh.cti_reorganize_indicateur_condition() +; + +UPDATE w_dbsetup +SET expert_controle_id = t_expert_controle.oid +FROM rh.t_expert_controle +WHERE expert_controle_code = t_expert_controle.code +; + +UPDATE w_dbsetup +SET indicateur_id = t_indicateurs.oid +FROM rh.t_indicateurs +WHERE indicateur_code = t_indicateurs.code +; +UPDATE w_dbsetup +SET indicateur_2_id = t_indicateurs.oid +FROM rh.t_indicateurs +WHERE indicateur_code_2 = t_indicateurs.code +; +UPDATE w_dbsetup +SET indicateur_3_id = t_indicateurs.oid +FROM rh.t_indicateurs +WHERE indicateur_code_3 = t_indicateurs.code +; + +UPDATE w_dbsetup +SET indicateur_condition_id_1 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_1 = t_indicateur_condition.external_code2 +; +UPDATE w_dbsetup +SET indicateur_condition_id_2 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_2 = t_indicateur_condition.external_code2 +; +UPDATE w_dbsetup +SET indicateur_condition_id_3 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_3 = t_indicateur_condition.external_code2 +; +UPDATE w_dbsetup +SET indicateur_condition_id_21 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_21 = t_indicateur_condition.external_code2 +; +UPDATE w_dbsetup +SET indicateur_condition_id_22 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_22 = t_indicateur_condition.external_code2 +; +UPDATE w_dbsetup +SET indicateur_condition_id_23 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_23 = t_indicateur_condition.external_code2 +; + +UPDATE w_dbsetup +SET indicateur_condition_id_31 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_31 = t_indicateur_condition.external_code2 +; +UPDATE w_dbsetup +SET indicateur_condition_id_32 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_32 = t_indicateur_condition.external_code2 +; +UPDATE w_dbsetup +SET indicateur_condition_id_33 = t_indicateur_condition.oid +FROM rh.t_indicateur_condition +WHERE indicateur_condition_external_code_33 = t_indicateur_condition.external_code2 +; + + +UPDATE w_dbsetup +SET expert_controle_rule_id = t_expert_controle_rule.oid +FROM rh. t_expert_controle_rule +WHERE w_dbsetup.expert_controle_id = t_expert_controle_rule.expert_controle_id AND + w_dbsetup.indicateur_id = t_expert_controle_rule.indicateur_id AND + w_dbsetup.indicateur_condition_id_1 = COALESCE(t_expert_controle_rule.indicateur_condition_id[1],0) AND + w_dbsetup.indicateur_condition_id_2 = COALESCE(t_expert_controle_rule.indicateur_condition_id[2],0) AND + w_dbsetup.indicateur_condition_id_3 = COALESCE(t_expert_controle_rule.indicateur_condition_id[3],0) AND + w_dbsetup.indicateur_2_id = t_expert_controle_rule.indicateur_2_id AND + w_dbsetup.indicateur_condition_id_21 = COALESCE(t_expert_controle_rule.indicateur_condition_2_id[1],0) AND + w_dbsetup.indicateur_condition_id_22 = COALESCE(t_expert_controle_rule.indicateur_condition_2_id[2],0) AND + w_dbsetup.indicateur_condition_id_23 = COALESCE(t_expert_controle_rule.indicateur_condition_2_id[3],0) AND + w_dbsetup.indicateur_3_id = t_expert_controle_rule.indicateur_3_id AND + w_dbsetup.indicateur_condition_id_31 = COALESCE(t_expert_controle_rule.indicateur_condition_3_id[1],0) AND + w_dbsetup.indicateur_condition_id_32 = COALESCE(t_expert_controle_rule.indicateur_condition_3_id[2],0) AND + w_dbsetup.indicateur_condition_id_33 = COALESCE(t_expert_controle_rule.indicateur_condition_3_id[3],0) AND + w_dbsetup.data_type = t_expert_controle_rule.data_type AND + w_dbsetup.formula = t_expert_controle_rule.formula +; + +DELETE +FROM rh.t_expert_controle_rule +WHERE expert_controle_id IN +(SELECT oid +FROM rh.t_expert_controle +WHERE code IN (SELECT expert_controle_code FROM w_dbsetup)) AND + is_cti = '1' AND + oid NOT IN (SELECT expert_controle_rule_id FROM w_dbsetup) +; + +INSERT INTO rh.t_expert_controle_rule( + expert_controle_id, + data_type, + indicateur_id, + indicateur_condition_id, + formula, + indicateur_2_id, + indicateur_condition_2_id, + formula_2, + indicateur_3_id, + indicateur_condition_3_id, + formula_3, + is_cti) +SELECT + expert_controle_id, + data_type, + indicateur_id, + ARRAY[w_dbsetup.indicateur_condition_id_1,w_dbsetup.indicateur_condition_id_2,w_dbsetup.indicateur_condition_id_3], + formula, + indicateur_2_id, + ARRAY[w_dbsetup.indicateur_condition_id_21,w_dbsetup.indicateur_condition_id_22,w_dbsetup.indicateur_condition_id_23], + formula_2, + indicateur_3_id, + ARRAY[w_dbsetup.indicateur_condition_id_31,w_dbsetup.indicateur_condition_id_32,w_dbsetup.indicateur_condition_id_33], + formula_3, + '1'::text AS is_cti +FROM w_dbsetup +WHERE expert_controle_rule_id = 0 AND + indicateur_id > 0 +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_indicateur_serie.SQL b/db/data/dbdata_rh_t_indicateur_serie.SQL new file mode 100644 index 0000000..be934b0 --- /dev/null +++ b/db/data/dbdata_rh_t_indicateur_serie.SQL @@ -0,0 +1,125 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + WITH flatSeries as ( + SELECT + oid, + cast(jsonb_array_elements(replace('[' || serie_id || ']', '|', ',')::jsonb)->>'pos' as bigint) as position, + cast(jsonb_array_elements(replace('[' || serie_id || ']', '|', ',')::jsonb)->>'id' as bigint) as id + FROM rh.t_indicateur_serie + WHERE serie_id != '{}' AND serie_id != '' + ORDER BY oid, position + ), + + flatCodes as (SELECT + flatSeries.oid, + array_agg(position::text || ':' || t_indicateur_serie.code::text) as codes + FROM flatSeries + LEFT JOIN rh.t_indicateur_serie on t_indicateur_serie.oid = id + GROUP BY 1) + + SELECT + t_indicateur_serie.code, + coalesce(t_indicateurs.code, '') as indicateur_code, + t_indicateur_serie.name, + t_indicateur_serie.color, + t_indicateur_serie.formula, + t_indicateur_serie.calc, + t_indicateur_serie.total, + t_indicateur_serie.format, + case when array_agg(DISTINCT t_indicateur_condition.external_code2) = ARRAY[null] then ARRAY[]::text[] else array_agg(DISTINCT t_indicateur_condition.external_code2) end as external_code2, + CASE WHEN flatCodes.codes = ARRAY[null] THEN '{}'::text[] ELSE flatCodes.codes::text[] END as serie_code + FROM rh.t_indicateur_serie + LEFT JOIN rh.t_indicateurs ON t_indicateurs.oid = indicateur_id + LEFT JOIN rh.t_indicateur_condition ON ARRAY[t_indicateur_condition.oid] <@ t_indicateur_serie.condition_id + LEFT JOIN flatCodes on flatCodes.oid = t_indicateur_serie.oid + GROUP BY 1,2,3,4,5,6,7,8, flatCodes.codes + ORDER BY 2,1 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + code, + indicateur_code, + name, + color, + formula, + calc, + total, + format, + external_code2, + serie_code +) +VALUES +('CTI_ENTSORF', '', 'Nombre entrees et sorties Femmes', '#d19aed', '[1] + [2]', 't', 'f', '', '{""}', '{"1:CTI_NVSALF", "2:CTI_DEPSALF"}'), +('CTI_ENTSORH', '', 'Nombre entrees et sorties Hommes', '#7b53e8', '[1] + [2]', 't', 'f', '', '{""}', '{"1:CTI_NVSALH", "2:CTI_DEPSALH"}'), +('CTI_HSUPF', '', 'Heures supplementaires Femmes', '#d19aed', '', 'f', 'f', '', '{"CTI_SEXE#DT#2"}', '{}'), +('CTI_HSUPH', '', 'Heures supplementaires Hommes', '#7b53e8', '', 'f', 'f', '', '{"CTI_SEXE#DT#1"}', '{}'), +('CTI_TAUXSTAT', '', 'Taux par statut', '', '([1] / [2])', 't', 'f', '0.00%', '{""}', '{"1:CTI_TOTSAL", "2:CTI_TOTSALF"}'), +('CTI_TOF', '', 'Turn Over Femmes', '#d19aed', '([1]/2) / [2]', 't', 'f', '0.00%', '{""}', '{"1:CTI_ENTSORF", "2:CTI_EFFDF"}'), +('CTI_TOH', '', 'Turn Over Hommes', '#7b53e8', '([1]/2) / [2]', 't', 'f', '0.00%', '{""}', '{"1:CTI_ENTSORH", "2:CTI_EFFDH"}'), +('CTI_MS', 'CTIMTMASSE', 'Masse salariale', '#7b53e8', '', 'f', 'f', '', '{""}', '{}'), +('CTI_MSF', 'CTIMTMASSE', 'Masse salariale Femmes', '#d19aed', '', 'f', 'f', '', '{"CTI_SEXE#DT#2"}', '{}'), +('CTI_MSH', 'CTIMTMASSE', 'Masse salariale Hommes', '#7b53e8', '', 'f', 'f', '', '{"CTI_SEXE#DT#1"}', '{}'), +('CTI_EFFDF', 'CTI_EFFDJPER', 'Effectifs dernier jour Femmes', '#d19aed', '', 'f', 'f', '', '{"CTI_SEXE#DT#2"}', '{}'), +('CTI_EFFDH', 'CTI_EFFDJPER', 'Effectifs dernier jour Hommes', '#7b53e8', '', 'f', 'f', '', '{"CTI_SEXE#DT#1"}', '{}'), +('CTI_FEMMES', 'CTI_NBSALCNT', 'Femmes', '#d19aed', '', 'f', 'f', '', '{"CTI_SEXE#DT#2"}', '{}'), +('CTI_HOMMES', 'CTI_NBSALCNT', 'Hommes', '#7b53e8', '', 'f', 'f', '', '{"CTI_SEXE#DT#1"}', '{}'), +('CTI_TOTSAL', 'CTI_NBSALCNT', 'Total salaries', '', '', 'f', 'f', '', '{""}', '{}'), +('CTI_TOTSALF', 'CTI_NBSALCNT', 'Total Salaries fin annee', '', '', 'f', 't', '', '{""}', '{}'), +('CTI_NVSALF', 'CTI_NOUVSALS', 'Nouveaux salaries Femmes', '#d19aed', '', 'f', 'f', '', '{"CTI_SEXE#DT#2"}', '{}'), +('CTI_NVSALH', 'CTI_NOUVSALS', 'Nouveaux salaries Hommes', '#7b53e8', '', 'f', 'f', '', '{"CTI_SEXE#DT#1"}', '{}'), +('CTI_DEPSALF', 'CTI_SALPARTISSP', 'Departs salaries Femmes', '#d19aed', '', 'f', 'f', '', '{"CTI_SEXE#DT#2"}', '{}'), +('CTI_DEPSALH', 'CTI_SALPARTISSP', 'Departs salaries Hommes', '#7b53e8', '', 'f', 'f', '', '{"CTI_SEXE#DT#1"}', '{}') +; + +-- 3/3 : Màj de la table iCTI +SELECT rh.cti_reorganize_indicateur_condition(); + +TRUNCATE rh.t_indicateur_serie; + +INSERT INTO rh.t_indicateur_serie(indicateur_id, condition_id, name, color, formula, calc, serie_id, total, format, code) + SELECT + coalesce(t_indicateurs.oid, 0), + case when array_agg(DISTINCT t_indicateur_condition.oid) = ARRAY[NULL]::bigint[] then ARRAY[]::bigint[] else array_agg(DISTINCT t_indicateur_condition.oid) end, + w_dbsetup.name, + w_dbsetup.color, + w_dbsetup.formula, + w_dbsetup.calc, + case when array_agg(DISTINCT rec.oid) = ARRAY[NULL]::bigint[] then ARRAY[]::bigint[] else array_agg(DISTINCT rec.oid) end, + w_dbsetup.total, + w_dbsetup.format, + w_dbsetup.code +FROM w_dbsetup +LEFT JOIN rh.t_indicateurs ON t_indicateurs.code = w_dbsetup.indicateur_code +LEFT JOIN rh.t_indicateur_condition ON ARRAY[t_indicateur_condition.external_code2] <@ w_dbsetup.external_code2 +LEFT JOIN rh.t_indicateur_serie as rec ON ARRAY[rec.code] <@ w_dbsetup.serie_code +GROUP BY 1,3,4,5,6,8,9,10 +; + +WITH series_id as ( +SELECT + w_dbsetup.code, + split_part(unnest(w_dbsetup.serie_code), ':', 1) as pos, + split_part(unnest(w_dbsetup.serie_code), ':', 2) as serie_code +FROM w_dbsetup +), + +full_series as ( +SELECT + series_id.code, + coalesce(string_agg('{"pos": ' || pos || ', "id": ' || t_indicateur_serie.oid || '}', '|'), '') as serie_id +FROM series_id +LEFT JOIN rh.t_indicateur_serie ON t_indicateur_serie.code = serie_code +GROUP BY 1 +) + + +UPDATE rh.t_indicateur_serie SET + serie_id = CASE WHEN full_series.serie_id IS NULL THEN '' ELSE full_series.serie_id END + FROM w_dbsetup + LEFT JOIN full_series ON full_series.code = w_dbsetup.code +WHERE t_indicateur_serie.code = w_dbsetup.code +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_indicateurs.SQL b/db/data/dbdata_rh_t_indicateurs.SQL new file mode 100644 index 0000000..2087010 --- /dev/null +++ b/db/data/dbdata_rh_t_indicateurs.SQL @@ -0,0 +1,395 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_indicateurs.oid, + t_indicateurs.code, + t_indicateurs.texte, + t_indicateurs.table_name, + t_indicateurs.column_name, + t_indicateurs.is_cti, + t_indicateurs.entete, + t_indicateurs.total_function, + t_indicateurs.output_format, + t_indicateurs.width, + t_indicateurs.entete_etendue, + t_indicateurs.dimension_date_1, + t_indicateurs.dimension_date_2, + t_indicateurs.dimension_date_3, + t_indicateurs.dimension_date_4, + t_indicateurs.dimension_date_5, + t_indicateurs.dimension_date, + t_indicateurs_1.code as indicateur_associe_1_code, + t_indicateurs_2.code as indicateur_associe_2_code, + t_indicateurs_3.code as indicateur_associe_3_code, + t_indicateurs_4.code as indicateur_associe_4_code, + t_indicateurs_5.code as indicateur_associe_5_code, + t_indicateurs_6.code as indicateur_associe_6_code, + t_indicateurs_7.code as indicateur_associe_7_code, + t_indicateurs_8.code as indicateur_associe_8_code, + t_indicateurs_9.code as indicateur_associe_9_code, + t_indicateurs_10.code as indicateur_associe_10_code, + t_indicateurs_11.code as indicateur_associe_11_code, + t_indicateurs_12.code as indicateur_associe_12_code, + t_indicateurs_13.code as indicateur_associe_13_code, + t_indicateurs_14.code as indicateur_associe_14_code, + t_indicateurs_15.code as indicateur_associe_15_code, + t_indicateurs_16.code as indicateur_associe_16_code, + t_indicateurs_17.code as indicateur_associe_17_code, + t_indicateurs_18.code as indicateur_associe_18_code, + t_indicateurs_19.code as indicateur_associe_19_code, + t_indicateurs_20.code as indicateur_associe_20_code, + t_indicateurs_reference.code as indicateur_reference_code + FROM rh.t_indicateurs + LEFT JOIN rh.t_indicateurs t_indicateurs_1 ON (t_indicateurs.indicateur_associe_1_id = t_indicateurs_1.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_2 ON (t_indicateurs.indicateur_associe_2_id = t_indicateurs_2.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_3 ON (t_indicateurs.indicateur_associe_3_id = t_indicateurs_3.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_4 ON (t_indicateurs.indicateur_associe_4_id = t_indicateurs_4.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_5 ON (t_indicateurs.indicateur_associe_5_id = t_indicateurs_5.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_6 ON (t_indicateurs.indicateur_associe_6_id = t_indicateurs_6.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_7 ON (t_indicateurs.indicateur_associe_7_id = t_indicateurs_7.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_8 ON (t_indicateurs.indicateur_associe_8_id = t_indicateurs_8.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_9 ON (t_indicateurs.indicateur_associe_9_id = t_indicateurs_9.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_10 ON (t_indicateurs.indicateur_associe_10_id = t_indicateurs_10.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_11 ON (t_indicateurs.indicateur_associe_11_id = t_indicateurs_11.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_12 ON (t_indicateurs.indicateur_associe_12_id = t_indicateurs_12.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_13 ON (t_indicateurs.indicateur_associe_13_id = t_indicateurs_13.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_14 ON (t_indicateurs.indicateur_associe_14_id = t_indicateurs_14.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_15 ON (t_indicateurs.indicateur_associe_15_id = t_indicateurs_15.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_16 ON (t_indicateurs.indicateur_associe_16_id = t_indicateurs_16.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_17 ON (t_indicateurs.indicateur_associe_17_id = t_indicateurs_17.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_18 ON (t_indicateurs.indicateur_associe_18_id = t_indicateurs_18.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_19 ON (t_indicateurs.indicateur_associe_19_id = t_indicateurs_19.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_20 ON (t_indicateurs.indicateur_associe_20_id = t_indicateurs_20.oid) + LEFT JOIN rh.t_indicateurs t_indicateurs_reference ON (t_indicateurs.indicateur_reference_id = t_indicateurs_reference.oid) + WHERE t_indicateurs.is_cti = '1' + ORDER BY t_indicateurs.code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + code, + texte, + table_name, + column_name, + is_cti, + entete, + total_function, + output_format, + width, + entete_etendue, + dimension_date_1, + dimension_date_2, + dimension_date_3, + dimension_date_4, + dimension_date_5, + dimension_date, + indicateur_associe_1_code, + indicateur_associe_2_code, + indicateur_associe_3_code, + indicateur_associe_4_code, + indicateur_associe_5_code, + indicateur_associe_6_code, + indicateur_associe_7_code, + indicateur_associe_8_code, + indicateur_associe_9_code, + indicateur_associe_10_code, + indicateur_associe_11_code, + indicateur_associe_12_code, + indicateur_associe_13_code, + indicateur_associe_14_code, + indicateur_associe_15_code, + indicateur_associe_16_code, + indicateur_associe_17_code, + indicateur_associe_18_code, + indicateur_associe_19_code, + indicateur_associe_20_code, + indicateur_reference_code +) +VALUES +(1, 'CTIAN', 'Avantages en nature', 'v_historique_paie_1', 'montant_avantage_nature', '1', 'Avantage nature', 'SUM', '#E', 80, 'Avantages nature', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTICOTPAT', 'Cotisations patronales', 'v_historique_paie_1', 'montant_cotisation_patronale', '1', 'Cotisations patronales', 'SUM', '#E', 80, 'Cotisations patronales', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTICOTSAL ', 'Cotisations salariales', 'v_historique_paie_1', 'montant_cotisation_salarie', '1', 'Cotisations salariales', 'SUM', '#E', 80, 'Cotisations salariales', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTIETPTHM', 'ETP travaillé moyen', '*CALC', 'base.cti_division([1], [2])', '1', 'ETP travaillé moyen', '*CALC', '#,00', 0, 'ETP travaillé moyen', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_ETPW', 'CTI_NBMOIS', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTIHP', 'Heures payées', 'v_historique_paie_1', 'heures_payees', '1', 'Heures payées', 'SUM', '', 80, 'Heures payées', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTIHT', 'Heures travaillées', 'v_historique_paie_1', 'heures_travaillees', '1', 'Heures travaillées', 'SUM', '', 80, 'Heures travaillées', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTIMASSMOY', 'Masse salariale moyenne', '*CALC', 'base.cti_division([1], [2])', '1', 'Masse moyenne', '*CALC', '#E', 80, 'Masse salariale moyenne', ' ', ' ', ' ', ' ', ' ', ' ', 'CTIMTMASSE', 'CTI_ETPPAYE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTIMTBRUT', 'Montant brut', 'v_historique_paie_1', 'montant_brut', '1', 'Brut', 'SUM', '#E', 80, 'Montant brut', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTIMTMASSE', 'Masse salariale', 'v_historique_paie_1', 'montant_masse_salariale', '1', 'Masse', 'SUM', '#E', 80, 'Masse salariale', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTINBCNT', 'Nombre de contrats', 'v_contrats_mois_1', 'DISTINCT contrat_id', '1', 'Contrats', 'COUNT', '', 80, 'Nombre de contrats', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTINBDSAL', 'Nombre de salariés distincts (Historique)', 'v_historique_paie_1', 'DISTINCT salarie_id', '1', 'Salariés distincts', 'COUNT', '', 80, 'Nombre de salariés distincts (Historique)', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTINBHOMME', 'Nombre d''Hommes', 'v_historique_paie_1', 'DISTINCT (CASE WHEN sexe_code = ''M'' THEN salarie_id ELSE null END)', '1', 'NB d''Hommes', 'COUNT', '', 0, 'Nombre d''Hommes', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTINBJARRET', 'Jours d''arret de travail', 'v_arrets_travail_mois_1', 'nb_jours_arret', '1', 'Arrets', 'SUM', '#j', 60, 'Jours d''arret de travail', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTINBSAL', 'Nombre de salariés (Historique)', 'v_historique_paie_1', 'salarie_id', '1', 'Salariés', 'COUNT', '', 80, 'Nombre de salariés (Historique)', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTINETAPAYER', 'Net à Payer', 'v_historique_paie_1', 'montant_net_a_payer_salarie', '1', 'Net A Payer', 'SUM', '#E', 80, 'Net A Payer', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTINETIMPOS', 'Net Imposable', 'v_historique_paie_1', 'montant_net_imposable_salarie', '1', 'Net Imposable', 'SUM', '#E', 80, 'Net Imposable', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTIODNET', 'OD sur Net', 'v_historique_paie_1', 'montant_od_net_salarie', '1', 'OD sur Net', 'SUM', '#E', 80, 'OD sur Net', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTISALCHGMOYH', 'Salaire Horaire Chargé', '*CALC', '[1] / [2]', '1', 'Salaire Chargé Moyen', '*CALC', '', 0, 'Salaire Chargé Moyen', ' ', ' ', ' ', ' ', ' ', ' ', 'CTIMASSMOY', 'CTIHP', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTISEP', 'Séparateur', 'SEP', '', '1', '', 'SUM', '', 0, '', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTITA', 'Base 4600 TA', 'v_historique_paie_1', 'CASE WHEN rubrique_code = ''4600'' THEN base ELSE 0 END', '1', 'Base 4600 TA', 'SUM', '#¤', 80, 'Base 4600 TA', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTITB', 'Base 4610 TB', 'v_historique_paie_1', 'CASE WHEN rubrique_code = ''4610'' THEN base ELSE 0 END', '1', 'Base 4610 TB', 'SUM', '#¤', 80, 'Base 4610 TB', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_ACTJPCT', 'Pourcentage de jours d''accident du travail', '*CALC', 'base.cti_division([1], [2]) * 100', '1', 'Pourcentage de jours d''accident du travail', '*CALC', '#,0%', 0, 'Pourcentage de jours d''accident du travail', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBJARRET_ACT', 'CTINBJARRET', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_ACTPCT', 'Pourcentage d''accident du travail', '*CALC', 'base.cti_division([1], [2]) * 100', '1', 'Pourcentage d''accident du travail', '*CALC', '#,0%', 0, 'Pourcentage d''accident du travail', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBARRET_ACT', 'CTI_NBARRET', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_AGEMOY', 'Age moyen', '*CALC', 'base.cti_division([1]::numeric, [2]::numeric)', '1', 'Age moyen', '*CALC', '#,0', 0, 'Age moyen', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_SAGE', 'CTI_CAGE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_AGESUM', 'Somme totale des ages', 'v_contrats_mois_1', 'rhp_age_id', '1', 'Somme totale des ages', 'SUM', '', 0, 'Somme totale des ages', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_BRUTCPA1', 'Montant Brut CP A-1 ( rub 1981)', 'v_historique_paie_1', 'CASE WHEN rubrique_code = ''1981'' THEN montant_brut ELSE 0 END', '1', 'Brut CP A-1', 'SUM', '#E', 80, 'Montant Brut CP A-1', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_BRUTMOYEN', 'Brut moyen/ETP', '*CALC', '[1] / [2]', '1', 'Brut Moyen(/ETP)', '*CALC', '', 0, 'Brut Moyen(/ETP)', ' ', ' ', ' ', ' ', ' ', ' ', 'CTIMTBRUT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_BRUTMOYENETP', 'Brut moyen/ETP', '*CALC', 'base.cti_division([1], [2])', '1', 'Brut Moyen(/ETP)', '*CALC', '#E', 0, 'Brut Moyen(/ETP)', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_MTBRUT', 'CTI_ETPPAYE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CAGE', 'Comptage salariés pour Age moyen', 'v_contrats_mois_1', 'DISTINCT salarie_id::text||''-''||age_id::text', '1', 'Comptage salariés pour Age moyen', 'COUNT', '#,0', 0, 'Comptage salariés pour Age moyen', '1', ' ', ' ', ' ', ' ', '1', 'CTI_AGESUM', 'CTI_NDSAL', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CALNBJ_OUVRE', 'Nombre de jours ouvrés', 'CALENDRIER', 'nb_jour_ouvre', '1', 'Jours ouvrés', 'SUM', '#', 80, 'Jours ouvrés', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CALNBJ_SEM', 'Nombre de jours semaine', 'CALENDRIER', 'nb_jour_semaine', '1', 'Jours semaine', 'SUM', '#', 80, 'Jours semaine', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CCO', 'Qualité - Catégorie de congé', 'v_contrats_mois_1', 'DISTINCT CASE WHEN categorie_conge_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Catégorie de congé', 'COUNT', '', 0, 'Catégorie de congé', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CDDSALP', 'Salarié en CDD : Nombre Moyen de contrats', '*CALC', 'base.cti_division([1], [2])', '1', 'Salarié en CDD : Nombre Moyen de contrats', '*CALC', '#,0', 0, 'Salarié en CDD : Nombre Moyen de contrats', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBCONTRATCDD', 'CTI_NBSALCDD', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CDM', 'Qualité - Cadre d''emploi', 'v_contrats_mois_1', 'DISTINCT CASE WHEN cadre_emploi_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Cadre d''emploi', 'COUNT', '', 0, 'Cadre d''emploi', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CEM', 'Qualité - Code emploi', 'v_contrats_mois_1', 'DISTINCT CASE WHEN code_emploi_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Code emploi', 'COUNT', '', 0, 'Code emploi', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CNTCMP', 'Contrats en temps complet', 'v_contrats_mois_1', 'CASE WHEN type_temps_travail_section_code[9] = ''TC'' THEN contrat_id ELSE null END', '1', 'Temps complet', 'COUNT', '', 0, 'Contrats en temps complet', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CNTPAR', 'Contrats en temps partiel', 'v_contrats_mois_1', 'CASE WHEN type_temps_travail_section_code[9] = ''TP'' THEN contrat_id ELSE null END', '1', 'Temps partiel', 'COUNT', '', 0, 'Contrats en temps partiel', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CPA', 'Qualité - Commission paritaire', 'v_contrats_mois_1', 'DISTINCT CASE WHEN commission_paritaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Commission paritaire', 'COUNT', '', 0, 'Commission paritaire', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CPA1', 'Base CP Pris sur A-1 1981', 'v_historique_paie_1', 'CASE WHEN rubrique_code = ''1981'' THEN base ELSE 0 END', '1', 'Base CP a-1', 'SUM', '#j', 80, 'Base CP A-1', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CPO', 'Qualité - Code postal', 'v_contrats_mois_1', 'DISTINCT CASE WHEN code_postal_id = 0 THEN salarie_id ELSE null END', '1', 'Code postal', 'COUNT', '', 0, 'Code postal', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CSA', 'Qualité - Compte salarié', 'v_contrats_mois_1', 'DISTINCT CASE WHEN compte_salarie_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Compte salarié', 'COUNT', '', 0, 'Compte salarié', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CSP', 'Qualité - Catégorie socio-professionnelle', 'v_contrats_mois_1', 'DISTINCT CASE WHEN categorie_socio_professionnelle_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Catégorie socio-professionnelle', 'COUNT', '', 0, 'Catégorie socio-professionnelle', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_CST', 'Qualité - Catégorie statutaire', 'v_contrats_mois_1', 'DISTINCT CASE WHEN categorie_statutaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Catégorie statutaire', 'COUNT', '', 0, 'Catégorie statutaire', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_DBTCDD', 'Nombre débuts de CDD', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN 1=1 + AND nombre_debut_contrat > 0 + AND type_contrat_section_code[9] = ''CDD'' + THEN contrat_id + ELSE null END)', '1', 'Débuts de CDD', 'COUNT', '', 0, 'Nombre débuts de CDD', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_DBTCDI', 'Nombre de début de CDI', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN 1=1 + AND nombre_debut_contrat > 0 + AND type_contrat_section_code[9] = ''CDI'' + THEN contrat_id + ELSE null END)', '1', 'Débuts de CDI', 'COUNT', '', 0, 'Nombre de début de CDI', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_DNA', 'Qualité - Date de naissance', 'v_contrats_mois_1', 'DISTINCT CASE WHEN date_naissance <= ''19200101''::date THEN salarie_id ELSE null END', '1', 'Date de naissance', 'COUNT', '', 0, 'Date de naissance', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_DUREEMOYARRETS', 'Durée moyenne des arrêts', '*CALC', 'base.cti_division([1], [2])', '1', 'Durée moyenne des arrêts', '*CALC', '#,0', 0, 'Durée moyenne des arrêts', ' ', ' ', ' ', ' ', ' ', ' ', 'CTINBJARRET', 'CTI_NBARRET', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EFF1ERJANV', 'Effectif total au 1er janvier', 'v_contrats_mois_1', 'DISTINCT CASE + WHEN 1=1 + AND present_debut_mois = 1 + AND date_part(''month'', date_debut_activite) = 1 + THEN salarie_id + ELSE null +END', '1', 'Effectif total au 1er janvier', 'COUNT', '', 0, 'Effectif total au 1er janvier', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EFF31DEV', 'Effectif total au 31 décembre', 'v_contrats_mois_1', 'DISTINCT CASE + WHEN 1=1 + AND present_fin_mois = 1 + AND date_part(''month'', date_debut_activite) = 12 + THEN salarie_id + ELSE null +END', '1', 'Effectif total au 31 décembre', 'COUNT', '', 0, 'Effectif total au 31 décembre', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EFFDJPER', 'Effectif au dernier jour de la période', 'v_contrats_mois_1', 'DISTINCT CASE +WHEN 1=1 +AND present_fin_mois = 1 +THEN salarie_id +ELSE null +END', '1', 'Effectif au dernier jour', 'COUNTLASTMONTH', '', 0, 'Effectif au dernier jour de la période', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EFFPERM', 'Effectif permanent', 'v_contrats_mois_1', 'DISTINCT CASE WHEN effectif_permanent = 1 then salarie_id ELSE null END', '1', 'Effectif permanent', 'COUNTLASTMONTH', '', 0, 'Effectif permanent', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EFFPJPER', 'Effectif au premier jour de la période', 'v_contrats_mois_1', 'DISTINCT CASE + WHEN 1=1 + AND present_debut_mois = 1 + AND to_char(date_debut_activite, ''YYYYMM'') = to_char( periode::date, ''YYYYMM'') + THEN salarie_id + ELSE null +END', '1', 'Effectif au premier jour', 'COUNT', '', 0, 'Effectif au premier jour de la période', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EMBCDD', 'Nombre d''embauche en CDD', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN 1=1 + AND nombre_entrees = 1 + AND type_contrat_section_code[9] = ''CDD'' + THEN salarie_id + ELSE null END)', '1', 'Embauche en CDD', 'COUNT', '', 0, 'Nombre d''embauche en CDD', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EMBCDI', 'Nombre d''embauche en CDI', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN 1=1 + AND nombre_entrees = 1 + AND type_contrat_section_code[9] = ''CDI'' + THEN salarie_id + ELSE null END)', '1', 'Embauche en CDI', 'COUNT', '', 0, 'Nombre d''embauche en CDI', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_EMBMS25', 'Nombre d''embauche de salariés de moins de 25 ans', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN 1=1 + AND nombre_entrees = 1 + AND rhp_age_id < 25 + THEN salarie_id + ELSE null END)', '1', 'Embauche < 25 ans', 'COUNT', '', 0, 'Nombre d''embauche de salariés de moins de 25 ans', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_ETPPAYE', 'ETP rémunéré', 'v_historique_paie_1', 'etp_paye', '1', 'ETP rémunéré', 'SUM', '#,00', 80, 'ETP rémunéré', '4', ' ', ' ', ' ', ' ', '4', 'CTIHP', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_ETPREMMOY', 'ETP rémunéré moyen', '*CALC', 'base.cti_division([1], [2])', '1', 'ETP rémunéré moyen', '*CALC', '#,00', 0, 'ETP rémunéré moyen', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_ETPPAYE', 'CTI_NBMOIS', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_ETPW', 'ETP travaillé', 'v_historique_paie_1', 'etp_travaille', '1', 'ETP travaillé', 'SUM', '#,00', 80, 'ETP travaillé', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_FIL', 'Qualité - Filière', 'v_contrats_mois_1', 'DISTINCT CASE WHEN filiere_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Filière', 'COUNT', '', 0, 'Filière', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_FINCNT', 'Nombre de fin de contrats', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN nombre_fin_contrat > 0 THEN contrat_id ELSE null END)', '1', 'Fin de contrats', 'COUNT', '', 0, 'Nombre de fin de contrats', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_FINCNTCDD', 'Nombre de fin de CDD', 'v_contrats_mois_1', 'DISTINCT ( +CASE WHEN 1=1 + AND nombre_fin_contrat > 0 + AND type_contrat_section_code[9] = ''CDD'' + THEN contrat_id + ELSE null +END)', '1', 'Fin de CDD', 'COUNT', '', 0, 'Nombre de fin de CDD', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_FINCNTCDI', 'Nombre de fin de CDI', 'v_contrats_mois_1', 'DISTINCT ( +CASE WHEN 1=1 + AND nombre_fin_contrat > 0 + AND type_contrat_section_code[9] = ''CDI'' + THEN contrat_id + ELSE null +END)', '1', 'Fin de CDI', 'COUNT', '', 0, 'Nombre de fin de CDI', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_FRIMPOS', 'Frais Imposable', 'v_historique_paie_1', 'montant_frais_imposables', '1', 'Frais Imposable', 'SUM', '#E', 80, 'Frais Imposable', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_GCO', 'Qualité - Groupe de cotisant', 'v_contrats_mois_1', 'DISTINCT CASE WHEN groupe_cotisant_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Groupe de cotisant', 'COUNT', '', 0, 'Groupe de cotisant', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_GGR', 'Qualité - Groupe de grille', 'v_contrats_mois_1', 'DISTINCT CASE WHEN grille_groupe_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Groupe de grille', 'COUNT', '', 0, 'Groupe de grille', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_GRI', 'Qualité - Grille', 'v_contrats_mois_1', 'DISTINCT CASE WHEN grille_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Grille', 'COUNT', '', 0, 'Grille', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_LBU', 'Qualité - Lettre budgétaire', 'v_contrats_mois_1', 'DISTINCT CASE WHEN lettre_budgetaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Lettre budgétaire', 'COUNT', '', 0, 'Lettre budgétaire', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MALJPCT', 'Pourcentage de jours de maladie', '*CALC', 'base.cti_division([1], [2]) * 100', '1', 'Pourcentage de jours de maladie', '*CALC', '#,0%', 0, 'Pourcentage de jours de maladie', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBJARRET_MAL', 'CTINBJARRET', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MALPCT', 'Pourcentage de maladie', '*CALC', 'base.cti_division([1], [2]) * 100', '1', 'Pourcentage de maladie', '*CALC', '#,0%', 0, 'Pourcentage de maladie', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBARRET_MAL', 'CTI_NBARRET', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MATJPCT', 'Pourcentage de jours de maternité', '*CALC', 'base.cti_division([1], [2]) * 100', '1', 'Pourcentage de jours de maternité', '*CALC', '#,0%', 0, 'Pourcentage de jours de maternité', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBJARRET_MAT', 'CTINBJARRET', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MATPCT', 'Pourcentage de maternité', '*CALC', 'base.cti_division([1], [2]) * 100', '1', 'Pourcentage de maternité', '*CALC', '#,0%', 0, 'Pourcentage de maternité', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBARRET_MAT', 'CTI_NBARRET', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MDD', 'Qualité - Motif de début de contrat', 'v_contrats_mois_1', 'DISTINCT CASE WHEN motif_debut_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Motif de début', 'COUNT', '', 0, 'Motif de début', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MDF', 'Qualité - Motif de fin de contrat', 'v_contrats_mois_1', 'DISTINCT CASE WHEN motif_fin_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Motif de fin', 'COUNT', '', 0, 'Motif de fin', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MHMC', 'Montant Horaire Moyen Chargé', '*CALC', 'base.cti_division([1], [2])', '1', 'Mnt H. Moy. Chargé', '*CALC', '#,0E', 0, 'Montant Horaire Moyen Chargé', ' ', ' ', ' ', ' ', ' ', ' ', 'CTIMTMASSE', 'CTIHP', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MTBRUT', 'Montant brut', 'v_historique_paie_1', 'montant_brut', '1', 'Brut', 'SUM', '#E', 80, 'Montant brut', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MT_CNT', 'Montant rupture de contrat', 'v_historique_paie_1', 'CASE WHEN rubrique_id IN [LISTE:CTI_EXP_CNT] THEN montant_od_net_salarie ELSE 0 END', '1', 'Montant rupture de contrat', 'SUM', '#E', 0, 'Montant rupture de contrat', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MT_IJ', 'Montant IJSS', 'v_historique_paie_1', 'CASE WHEN rubrique_id IN [LISTE:CTI_EXP_IJS] THEN montant_od_net_salarie ELSE 0 END', '1', 'Montant IJSS', 'SUM', '#E', 0, 'Montant IJSS', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MT_PRE', 'Montant prime de précarité', 'v_historique_paie_1', 'CASE WHEN rubrique_id IN [LISTE:CTI_EXP_PRE] THEN montant_masse_salariale ELSE 0 END', '1', 'Montant Prime de précarité', 'SUM', '#E', 0, 'Montant prime de précarité', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_MT_RET', 'Montant départ à la retraite', 'v_historique_paie_1', 'CASE WHEN rubrique_id IN [LISTE:CTI_EXP_RET] THEN montant_masse_salariale ELSE 0 END', '1', 'Montant retraite', 'SUM', '#E', 0, 'Montant départ à la retraite', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NAT', 'Qualité - Nationalité', 'v_contrats_mois_1', 'DISTINCT CASE WHEN nationalite_id = 0 THEN salarie_id ELSE null END', '1', 'Nationalité', 'COUNT', '', 0, 'Nationalité', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBARRET', 'Nombre d''arrêts', 'v_arrets_travail_mois_1', 'DISTINCT CASE WHEN nb_arret = 1 THEN arret_travail_id ELSE null END', '1', 'Nombre d''arrêts', 'COUNT', '', 0, 'Nombre d''arrêts', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBARRETMOY', 'Nombre d''arrêts moyen', '*CALC', 'base.cti_division([1], [2])', '1', 'Nb d''arrêts moyen', '*CALC', '#,0', 0, 'Nombre d''arrêts moyen', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBARRET', 'CTI_NBSALCNT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBARRET_ACT', 'Nombre d''arrêts pour accident du travail', 'v_arrets_travail_mois_1', 'DISTINCT CASE WHEN nb_arret = 1 AND motif_arret_section_code[9] = ''ACT'' THEN arret_travail_id ELSE null END', '1', 'Nb accident du travail', 'COUNT', '', 0, 'Nombre d''arrêts pour accident du travail', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBARRET_MAL', 'Nombre d''arrêts maladie', 'v_arrets_travail_mois_1', 'DISTINCT CASE WHEN nb_arret = 1 AND motif_arret_section_code[9] = ''MAL'' THEN arret_travail_id ELSE null END', '1', 'Nb maladies', 'COUNT', '', 0, 'Nombre d''arrêts maladie', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBARRET_MAT', 'Nombre d''arrêts maternité', 'v_arrets_travail_mois_1', 'DISTINCT CASE WHEN nb_arret = 1 AND motif_arret_section_code[9] = ''MAT'' THEN arret_travail_id ELSE null END', '1', 'Nb maternités', 'COUNT', '', 0, 'Nombre d''arrêts maternité', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBCNT', 'Nombre de contrats', 'v_contrats_mois_1', 'DISTINCT contrat_id', '1', 'Contrats', 'COUNT', '', 80, 'Nombre de contrats', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBCONTRATCDD', 'Nombre de contrats en CDD', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN type_contrat_section_code[9] = ''CDD'' THEN contrat_id ELSE null END)', '1', 'Contrats CDD', 'COUNT', '', 80, 'Nombre de contrats en CDD', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBCONTRATCDI', 'Nombre de contrats en CDI', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN type_contrat_section_code[9] = ''CDI'' THEN contrat_id ELSE null END)', '1', 'Contrats CDI', 'COUNT', '', 80, 'Nombre de contrats en CDI', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBETRANGERS', 'Nombre d''étrangers', 'v_historique_paie_1', 'DISTINCT (CASE WHEN nationalite_section_code[9] != ''FR'' THEN salarie_id ELSE null END)', '1', 'NB d''étrangers', 'COUNT', '', 0, 'Nombre d''étrangers', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBFEMMECNT', 'Nombre de Femmes (Contrats)', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN sexe_code = ''F'' THEN salarie_id ELSE null END)', '1', 'NB de Femmes', 'COUNT', '', 0, 'Nombre de Femmes', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBFEMMEPAIE', 'Nombre de Femmes (Paie)', 'v_historique_paie_1', 'DISTINCT (CASE WHEN sexe_code = ''F'' THEN salarie_id ELSE null END)', '1', 'NB de Femmes', 'COUNT', '', 0, 'Nombre de Femmes', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBHANDICAP', 'Nombre d''handicapés', 'v_historique_paie_1', 'DISTINCT (CASE WHEN handicap_id = ''1'' THEN salarie_id ELSE null END)', '1', 'NB d''handicapés', 'COUNT', '', 0, 'Nombre d''handicapés', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBIJSS', 'Nombre d''IJSS', 'v_historique_paie_1', 'DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_IJS] THEN salarie_id ELSE null END', '1', 'IJSS', 'COUNT', '', 0, 'Nombre d''IJSS', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBJARRET_ACT', 'Nombre de jours d''arrêt pour accident du travail', 'v_arrets_travail_mois_1', 'CASE WHEN motif_arret_section_code[9] = ''ACT'' THEN nb_jours_arret ELSE 0 END', '1', 'Nb jours accident du travail', 'SUM', '', 0, 'Nombre de jours d''arrêt pour accident du travail', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBJARRET_MAL', 'Nombre de jours d''arrêt maladie', 'v_arrets_travail_mois_1', 'CASE WHEN motif_arret_section_code[9] = ''MAL'' THEN nb_jours_arret ELSE 0 END', '1', 'Nb jours maladie', 'SUM', '', 0, 'Nombre de jours d''arrêt maladie', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBJARRET_MAT', 'Nombre de jours d''arrêt maternité', 'v_arrets_travail_mois_1', 'CASE WHEN motif_arret_section_code[9] = ''MAT'' THEN nb_jours_arret ELSE 0 END', '1', 'Nb jours maternité', 'SUM', '', 0, 'Nombre de jours d''arrêt maternité', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBJT', 'Nombre de journées théoriques travaillées', 'v_historique_paie_1', 'heures_travaillees / 7.0', '1', 'Journées théoriques travaillées', 'SUM', '', 0, 'Nombre de journées théoriques travaillées', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBMOIS', 'Nombre de mois sur la période', 'v_contrats_mois_1', 'DISTINCT mois_activite_id', '1', 'Mois /période', 'COUNT', '', 0, 'Nombre de mois sur la période', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBRUPT', 'Nombre de rupture de contrat', 'v_historique_paie_1', 'DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_CNT] THEN salarie_id ELSE null END', '1', 'Rupture de contrat', 'COUNT', '', 0, 'Nombre de rupture de contrat', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBSAL', 'Nombre de salariés (Paie)', 'v_historique_paie_1', 'DISTINCT salarie_id', '1', 'Salariés', 'COUNT', '', 80, 'Nombre de salariés (Paie)', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBSALCDD', 'Nombre de salariés en CDD', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN type_contrat_section_code[9] = ''CDD'' THEN salarie_id ELSE null END)', '1', 'Salariés CDD', 'COUNT', '', 80, 'Nombre de salariés en CDD', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBSALCNT', 'Nombre de salariés (Contrats)', 'v_contrats_mois_1', 'DISTINCT salarie_id', '1', 'Salariés', 'COUNT', '', 80, 'Nombre de salariés', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBSALCNTFR', 'Nombre de Français (Contrat)', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN nationalite_section_code[9] = ''FR'' THEN salarie_id ELSE null END)', '1', 'NB de Français', 'COUNT', '', 0, 'Nombre de Français', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NBSALPAIEFR', 'Nombre de Français (Paie)', 'v_historique_paie_1', 'DISTINCT (CASE WHEN nationalite_section_code[9] = ''FR'' THEN salarie_id ELSE null END)', '1', 'NB de Français', 'COUNT', '', 0, 'Nombre de Français', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NB_PRE', 'Nombre de prime de précarité', 'v_historique_paie_1', 'DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_PRE] THEN salarie_id ELSE null END', '1', 'Prime de précarité', 'COUNT', '', 0, 'Nombre de prime de précarité', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NB_RET', 'Nombre de départ à la retraite', 'v_historique_paie_1', 'DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_RET] THEN salarie_id ELSE null END', '1', 'Départ à la retraite', 'COUNT', '', 0, 'Nombre de départ à la retraite', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NDSAL', 'Nombre NON DISTINCT de salariés', 'v_contrats_mois_1', 'salarie_id', '1', 'Nombre NON DISTINCT de salariés', 'COUNT', '', 0, 'Nombre NON DISTINCT de salariés', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NOUVSALS', 'Nouveaux salariés', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN nombre_entrees = 1 THEN salarie_id ELSE null END)', '1', 'Nouveaux salariés', 'COUNT', '', 0, 'Nouveaux salariés', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_NVXCNT', 'Nombre de nouveaux contrats', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN nombre_debut_contrat > 0 THEN contrat_id ELSE null END)', '1', 'Nouveaux contrats', 'COUNT', '', 0, 'Nombre de nouveaux contrats', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_PCDD', '% de CDD', '*CALC', 'base.cti_division([1], [2]) * 100', '1', '% CDD', '*CALC', '#,0%', 0, '% de CDD/nb de contrat', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBCONTRATCDD', 'CTI_NBCNT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_PCDI', '% de CDI', '*CALC', 'base.cti_division([1], [2]) * 100', '1', '% CDI', '*CALC', '#,0%', 0, '% de CDI/nb de contrat', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBCONTRATCDI', 'CTI_NBCNT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_PCTFEMMECNT', '% de femmes', '*CALC', 'base.cti_division([1], [2]) * 100', '1', '% de femmes', '*CALC', '#,0%', 0, '% de femmes', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NBFEMMECNT', 'CTI_NBSALCNT', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_PRESENCE_PAIE_PAS_PLANNING', 'Liste des salariés présents en paie mais pas au planning', 'v_presence_salaries_1', 'CASE WHEN present_paie= true AND present_planning = false THEN 1 ELSE 0 END', '1', '', 'SUM', '#', 0, '', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_PRESENCE_PLANNING_PAS_PAIE', 'Liste des personnes présentes au planning mais pas en paie', 'v_presence_salaries_1', 'CASE WHEN present_paie= false AND present_planning = true THEN 1 ELSE 0 END', '1', '', 'SUM', '#', 0, '', '4', ' ', ' ', ' ', ' ', '4', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_QUA', 'Qualité - Qualification', 'v_contrats_mois_1', 'DISTINCT CASE WHEN qualification_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Qualification', 'COUNT', '', 0, 'Qualification', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_RAPPORTCALC', 'Calcul d''indicateurs dans le rapport', '*RAPPORTCALC', '', '1', '', 'sum', '#', 0, '', '0', ' ', ' ', ' ', ' ', '0', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_ROTATIONEMP', 'Rotation de l''emploi', '*CALC', 'base.cti_division((([1] + [2]) / 2), [3]) * 100', '1', 'Rotation de l''emploi', '*CALC', '#,0%', 0, 'Rotation de l''emploi', ' ', ' ', ' ', ' ', ' ', ' ', 'CTI_NOUVSALS', 'CTI_SALPARTISSP', 'CTI_EFFPJPER', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SAC', 'Qualité - Section analytique comptable', 'v_contrats_mois_1', 'DISTINCT CASE WHEN section_analytique_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Section analytique comptable', 'COUNT', '', 0, 'Section analytique comptable', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SAGE', 'Somme Ages pour Age moyen', 'v_contrats_mois_1', 'DISTINCT ARRAY[salarie_id::numeric, age_id::numeric]', '1', 'Somme Ages pour Age moyen', 'base.cti_sum_distinct_on', '#,0', 0, 'Somme Ages pour Age moyen', '1', ' ', ' ', ' ', ' ', '1', 'CTI_AGESUM', 'CTI_NDSAL', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SAL60', 'Nombre de salariés 60 ans et +', 'v_contrats_mois_1', 'DISTINCT CASE WHEN rhp_age_id >= 60 THEN salarie_id ELSE null END', '1', 'Salariés 60 ans et +', 'COUNT', '', 0, 'Nombre de salariés 60 ans et +', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SALCHGMOY', 'Salaire Moyen Chargé', '*CALC', 'base.cti_division([1], [2])', '1', 'Salaire Chargé Moyen', '*CALC', '', 0, 'Salaire Chargé Moyen', ' ', ' ', ' ', ' ', ' ', ' ', 'CTINETAPAYER', 'CTI_ETPPAYE', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SALCHGMOYH', 'Salaire Horaire Chargé Moyen', '*CALC', 'base.cti_division([1], [2])', '1', 'Salaire Chargé Moyen', '*CALC', '', 0, 'Salaire Chargé Moyen', ' ', ' ', ' ', ' ', ' ', ' ', 'CTIMASSMOY', 'CTIHP', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SALPARTISSP', 'Salarié partis sur la période', 'v_contrats_mois_1', 'DISTINCT (CASE WHEN nombre_departs = 1 THEN salarie_id ELSE null END)', '1', 'Salarié partis /période', 'COUNT', '', 0, 'Salarié partis sur la période', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SAP', 'Qualité - Section analytique paie', 'v_contrats_mois_1', 'DISTINCT CASE WHEN section_analytique_paie_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Section analytique paie', 'COUNT', '', 0, 'Section analytique paie', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SEP', 'Séparateur', 'SEP', '', '1', '', 'SUM', '', 0, '', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SER', 'Qualité - Service', 'v_contrats_mois_1', 'DISTINCT CASE WHEN service_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Service', 'COUNT', '', 0, 'Service', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SEX', 'Qualité - Sexe', 'v_contrats_mois_1', 'DISTINCT CASE WHEN sexe_id = 0 THEN salarie_id ELSE null END', '1', 'Sexe', 'COUNT', '', 0, 'Sexe', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SFA', 'Qualité - Situation de famille', 'v_contrats_mois_1', 'DISTINCT CASE WHEN situation_famille_id = 0 THEN salarie_id ELSE null END', '1', 'Situation de famille', 'COUNT', '', 0, 'Situation de famille', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SIN', 'Qualité - Société d''interim', 'v_contrats_mois_1', 'DISTINCT CASE WHEN societe_interim_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Société d''interim', 'COUNT', '', 0, 'Société d''interim', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_SPE', 'Qualité - Spécialité', 'v_contrats_mois_1', 'DISTINCT CASE WHEN specialite_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Spécialité', 'COUNT', '', 0, 'Spécialité', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_STA', 'Qualité - Statut', 'v_contrats_mois_1', 'DISTINCT CASE WHEN statut_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Statut', 'COUNT', '', 0, 'Statut', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_TCNT', 'Qualité - Type de contrat', 'v_contrats_mois_1', 'DISTINCT CASE WHEN type_contrat_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Type de contrat', 'COUNT', '', 0, 'Type de contrat', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_THO', 'Qualité - Type horaire', 'v_contrats_mois_1', 'DISTINCT CASE WHEN type_horaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Type horaire', 'COUNT', '', 0, 'Type horaire', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_TRACDI', 'Transformation CDI', 'v_contrats_mois_1', 'DISTINCT case when nombre_transformation_cdi = ''1'' then salarie_id else null end', '1', 'Transformation CDI', 'COUNT', '', 0, 'Transformation CDI', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_TTT', 'Qualité - Type de temps de travail', 'v_contrats_mois_1', 'DISTINCT CASE WHEN type_temps_travail_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Type de temps de travail', 'COUNT', '', 0, 'Type de temps de travail', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(1, 'CTI_UFO', 'Qualité - Unité fonctionnelle', 'v_contrats_mois_1', 'DISTINCT CASE WHEN unite_fonctionnelle_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END', '1', 'Unité fonctionnelle', 'COUNT', '', 0, 'Unité fonctionnelle', '1', ' ', ' ', ' ', ' ', '1', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '') +; + +-- 3/3 : Màj de la table iCTI +DELETE FROM rh.t_indicateurs +USING + ( + SELECT code, MIN(oid) AS minoid FROM rh.t_indicateurs WHERE code <> '' GROUP BY 1 HAVING count(*) > 1 + ) subview +WHERE t_indicateurs.code = subview.code AND t_indicateurs.oid <> subview.minoid +; + +UPDATE rh.t_indicateurs SET + texte = w_dbsetup.texte, + table_name = w_dbsetup.table_name, + column_name = w_dbsetup.column_name, + is_cti = w_dbsetup.is_cti, + entete = w_dbsetup.entete, + entete_etendue = w_dbsetup.entete_etendue, + total_function = w_dbsetup.total_function, + output_format = w_dbsetup.output_format, + width = w_dbsetup.width, + dimension_date_1 = w_dbsetup.dimension_date_1, + dimension_date_2 = w_dbsetup.dimension_date_2, + dimension_date_3 = w_dbsetup.dimension_date_3, + dimension_date_4 = w_dbsetup.dimension_date_4, + dimension_date_5 = w_dbsetup.dimension_date_5, + dimension_date = w_dbsetup.dimension_date +FROM w_dbsetup +WHERE t_indicateurs.code = w_dbsetup.code +; + +INSERT INTO rh.t_indicateurs(texte, table_name, column_name, is_cti, entete, entete_etendue, code, total_function, output_format, width, + dimension_date_1, dimension_date_2, dimension_date_3, dimension_date_4, dimension_date_5, dimension_date) +SELECT texte, table_name, column_name, is_cti, entete, entete_etendue, code, total_function, output_format, width, + dimension_date_1, dimension_date_2, dimension_date_3, dimension_date_4, dimension_date_5, dimension_date +FROM w_dbsetup WHERE oid <> 0 AND code NOT IN (SELECT code FROM rh.t_indicateurs WHERE code IS NOT NULL) +; + +UPDATE rh.t_indicateurs SET + indicateur_associe_1_id = COALESCE(t_indicateurs_1.oid,0), + indicateur_associe_2_id = COALESCE(t_indicateurs_2.oid,0), + indicateur_associe_3_id = COALESCE(t_indicateurs_3.oid,0), + indicateur_associe_4_id = COALESCE(t_indicateurs_4.oid,0), + indicateur_associe_5_id = COALESCE(t_indicateurs_5.oid,0), + indicateur_associe_6_id = COALESCE(t_indicateurs_6.oid,0), + indicateur_associe_7_id = COALESCE(t_indicateurs_7.oid,0), + indicateur_associe_8_id = COALESCE(t_indicateurs_8.oid,0), + indicateur_associe_9_id = COALESCE(t_indicateurs_9.oid,0), + indicateur_associe_10_id = COALESCE(t_indicateurs_10.oid,0), + indicateur_associe_11_id = COALESCE(t_indicateurs_11.oid,0), + indicateur_associe_12_id = COALESCE(t_indicateurs_12.oid,0), + indicateur_associe_13_id = COALESCE(t_indicateurs_13.oid,0), + indicateur_associe_14_id = COALESCE(t_indicateurs_14.oid,0), + indicateur_associe_15_id = COALESCE(t_indicateurs_15.oid,0), + indicateur_associe_16_id = COALESCE(t_indicateurs_16.oid,0), + indicateur_associe_17_id = COALESCE(t_indicateurs_17.oid,0), + indicateur_associe_18_id = COALESCE(t_indicateurs_18.oid,0), + indicateur_associe_19_id = COALESCE(t_indicateurs_19.oid,0), + indicateur_associe_20_id = COALESCE(t_indicateurs_20.oid,0), + indicateur_reference_id = COALESCE(t_indicateurs_reference.oid,0) +FROM w_dbsetup + LEFT JOIN rh.t_indicateurs t_indicateurs_1 ON (w_dbsetup.indicateur_associe_1_code = t_indicateurs_1.code AND w_dbsetup.indicateur_associe_1_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_2 ON (w_dbsetup.indicateur_associe_2_code = t_indicateurs_2.code AND w_dbsetup.indicateur_associe_2_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_3 ON (w_dbsetup.indicateur_associe_3_code = t_indicateurs_3.code AND w_dbsetup.indicateur_associe_3_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_4 ON (w_dbsetup.indicateur_associe_4_code = t_indicateurs_4.code AND w_dbsetup.indicateur_associe_4_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_5 ON (w_dbsetup.indicateur_associe_5_code = t_indicateurs_5.code AND w_dbsetup.indicateur_associe_5_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_6 ON (w_dbsetup.indicateur_associe_6_code = t_indicateurs_6.code AND w_dbsetup.indicateur_associe_6_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_7 ON (w_dbsetup.indicateur_associe_7_code = t_indicateurs_7.code AND w_dbsetup.indicateur_associe_7_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_8 ON (w_dbsetup.indicateur_associe_8_code = t_indicateurs_8.code AND w_dbsetup.indicateur_associe_8_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_9 ON (w_dbsetup.indicateur_associe_9_code = t_indicateurs_9.code AND w_dbsetup.indicateur_associe_9_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_10 ON (w_dbsetup.indicateur_associe_10_code = t_indicateurs_10.code AND w_dbsetup.indicateur_associe_10_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_11 ON (w_dbsetup.indicateur_associe_11_code = t_indicateurs_11.code AND w_dbsetup.indicateur_associe_11_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_12 ON (w_dbsetup.indicateur_associe_12_code = t_indicateurs_12.code AND w_dbsetup.indicateur_associe_12_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_13 ON (w_dbsetup.indicateur_associe_13_code = t_indicateurs_13.code AND w_dbsetup.indicateur_associe_13_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_14 ON (w_dbsetup.indicateur_associe_14_code = t_indicateurs_14.code AND w_dbsetup.indicateur_associe_14_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_15 ON (w_dbsetup.indicateur_associe_15_code = t_indicateurs_15.code AND w_dbsetup.indicateur_associe_15_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_16 ON (w_dbsetup.indicateur_associe_16_code = t_indicateurs_16.code AND w_dbsetup.indicateur_associe_16_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_17 ON (w_dbsetup.indicateur_associe_17_code = t_indicateurs_17.code AND w_dbsetup.indicateur_associe_17_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_18 ON (w_dbsetup.indicateur_associe_18_code = t_indicateurs_18.code AND w_dbsetup.indicateur_associe_18_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_19 ON (w_dbsetup.indicateur_associe_19_code = t_indicateurs_19.code AND w_dbsetup.indicateur_associe_19_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_20 ON (w_dbsetup.indicateur_associe_20_code = t_indicateurs_20.code AND w_dbsetup.indicateur_associe_20_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_reference ON (w_dbsetup.indicateur_reference_code = t_indicateurs_reference.code AND w_dbsetup.indicateur_reference_code <> '') +WHERE t_indicateurs.code = w_dbsetup.code + AND (indicateur_associe_1_code <> '' OR + indicateur_associe_2_code <> '' OR + indicateur_associe_3_code <> '' OR + indicateur_reference_code <> '') +; + +SELECT base.cti_reorganize_indicateurs('rh') +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_listes.SQL b/db/data/dbdata_rh_t_listes.SQL new file mode 100644 index 0000000..1b091b7 --- /dev/null +++ b/db/data/dbdata_rh_t_listes.SQL @@ -0,0 +1,73 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_listes.oid, + t_listes.texte, + t_listes.chapitre, + t_listes.code, + t_listes.is_cti, + t_listes.show_omit, + t_listes.utilisateur_createur, + t_listes.est_partagee_modification, + t_listes_tables.name as table_name + FROM + rh.t_listes, + rh.t_listes_tables + WHERE 1=1 + AND is_cti = '1' + AND t_listes.code != '' + AND table_id = t_listes_tables.oid + ORDER BY t_listes.code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + texte, + chapitre, + code, + is_cti, + show_omit, + utilisateur_createur, + est_partagee_modification, + table_name +) +VALUES +(1, 'Primes à périodicité non mensuelle - Bilan Social', '', 'CTI_BS_PPNM', '1', '1', '*CTI', '1', 't_rubriques'), +(1, 'Eléments exceptionnels : Rupture de contrat : OD/Net.', 'Elements exceptionnels', 'CTI_EXP_CNT', '1', '1', '*CTI', '1', 't_rubriques'), +(1, 'IJSS : Payé SS / OD/Net.', 'Elements exceptionnels', 'CTI_EXP_IJS', '1', '1', '*CTI', '1', 't_rubriques'), +(1, 'Eléments exceptionnels : Prime de précarité', 'Elements exceptionnels', 'CTI_EXP_PRE', '1', '1', '*CTI', '1', 't_rubriques'), +(1, 'Eléments exceptionnels : Retraite', 'Elements exceptionnels', 'CTI_EXP_RET', '1', '1', '*CTI', '1', 't_rubriques'), +(1, 'Elements exceptionnels Retraite et rupture.', 'Elements exceptionnels', 'CTI_EXP_RRU', '1', '1', '*CTI', '1', 't_rubriques'), +(1, 'Heures contrat', 'Paramétrage', 'CTI_HCNT', '1', '0', '*CTI', '1', 't_rubriques'), +(1, 'Pegase forfaits jours', 'Paramétrage', 'CTI_PEGASE_FTJ', '1', '0', '*CTI', '1', 't_rubriques') +; + +-- 3/3 : Màj de la table iCTI +UPDATE rh.t_listes SET + texte = w_dbsetup.texte, + chapitre = w_dbsetup.chapitre, + table_id = t_listes_tables.oid, + is_cti = w_dbsetup.is_cti, + show_omit = w_dbsetup.show_omit, + utilisateur_createur = w_dbsetup.utilisateur_createur, + est_partagee_modification = w_dbsetup.est_partagee_modification +FROM w_dbsetup, rh.t_listes_tables +WHERE w_dbsetup.table_name = t_listes_tables.name and t_listes.code = w_dbsetup.code +; + +INSERT INTO rh.t_listes(code, texte, chapitre, table_id, is_cti, show_omit, utilisateur_createur, est_partagee_modification) +SELECT w_dbsetup.code, w_dbsetup.texte, w_dbsetup.chapitre, t_listes_tables.oid, w_dbsetup.is_cti, w_dbsetup.show_omit, w_dbsetup.utilisateur_createur, w_dbsetup.est_partagee_modification + FROM w_dbsetup, rh.t_listes_tables + WHERE 1=1 + AND w_dbsetup.table_name = t_listes_tables.name + AND w_dbsetup.code NOT IN (SELECT code FROM rh.t_listes) + AND w_dbsetup.texte NOT LIKE '*SUPPRIME%' +; + +DELETE FROM rh.t_listes WHERE texte like '*SUPPRIME%' AND is_cti = '1' +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_listes_tables.SQL b/db/data/dbdata_rh_t_listes_tables.SQL new file mode 100644 index 0000000..20e3fb4 --- /dev/null +++ b/db/data/dbdata_rh_t_listes_tables.SQL @@ -0,0 +1,473 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + oid, + name, + texte, + select_cmd, + code + FROM rh.t_listes_tables + ORDER BY code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + name, + texte, + select_cmd, + code +) +VALUES +(1, 't_ages', 'Age', 'SELECT t_ages.oid, t_ages.code, t_ages.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_ages LEFT JOIN rh.p_oids ON (t_ages.oid = p_oids.oid AND code_table = ''ages'') +WHERE t_ages.oid > 0 +ORDER BY t_ages.code', 'AGE'), +(1, 't_section_analytique', 'Section analytique NG', 'SELECT t_section_analytique.oid, + t_section_analytique.code, + t_section_analytique.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_section_analytique + LEFT JOIN rh.p_oids ON (t_section_analytique.oid = p_oids.oid AND code_table = ''section_analytique'') +WHERE t_section_analytique.oid > 0 +ORDER BY t_section_analytique.code', 'ANA'), +(1, 't_anciennetes_annee', 'Ancienneté', 'SELECT t_anciennetes_annee.oid, t_anciennetes_annee.code, t_anciennetes_annee.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_anciennetes_annee LEFT JOIN rh.p_oids ON (t_anciennetes_annee.oid = p_oids.oid AND code_table = ''anciennete_annee'') +ORDER BY t_anciennetes_annee.code', 'ANC'), +(1, 't_accident_circonstance', '[DICT.RH.CIRCONSTANCE] accident du travail', 'SELECT t_accident_circonstance.oid, + t_accident_circonstance.code, + t_accident_circonstance.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_accident_circonstance + LEFT JOIN rh.p_oids ON (t_accident_circonstance.oid = p_oids.oid AND code_table = ''accident_circonstance'') +WHERE t_accident_circonstance.oid > 0 +ORDER BY t_accident_circonstance.code', 'ATC'), +(1, 't_accident_lieu', '[DICT.RH.LIEU] accident du travail', 'SELECT t_accident_lieu.oid, + t_accident_lieu.code, + t_accident_lieu.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_accident_lieu + LEFT JOIN rh.p_oids ON (t_accident_lieu.oid = p_oids.oid AND code_table = ''accident_lieu'') +WHERE t_accident_lieu.oid > 0 +ORDER BY t_accident_lieu.code', 'ATL'), +(1, 't_accident_nature', 'Nature accident du travail', 'SELECT t_accident_nature.oid, + t_accident_nature.code, + t_accident_nature.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_accident_nature + LEFT JOIN rh.p_oids ON (t_accident_nature.oid = p_oids.oid AND code_table = ''accident_nature'') +WHERE t_accident_nature.oid > 0 +ORDER BY t_accident_nature.code', 'ATN'), +(1, 't_accident_siege', 'Siège accident du travail', 'SELECT t_accident_siege.oid, + t_accident_siege.code, + t_accident_siege.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_accident_siege + LEFT JOIN rh.p_oids ON (t_accident_siege.oid = p_oids.oid AND code_table = ''accident_siege'') +WHERE t_accident_siege.oid > 0 +ORDER BY t_accident_siege.code', 'ATS'), +(1, 't_categorie_conge', 'Catégorie de congé', 'SELECT t_categorie_conge.oid, + t_categorie_conge.code, + t_categorie_conge.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_categorie_conge + LEFT JOIN rh.p_oids ON (t_categorie_conge.oid = p_oids.oid AND code_table = ''categorie_conge'') +WHERE t_categorie_conge.oid > 0 +ORDER BY t_categorie_conge.code', 'CAC'), +(1, 't_cadre_emploi', 'Cadre d''emploi', 'SELECT t_cadre_emploi.oid, + t_cadre_emploi.code, + t_cadre_emploi.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_cadre_emploi + LEFT JOIN rh.p_oids ON (t_cadre_emploi.oid = p_oids.oid AND code_table = ''cadre_emploi'') +WHERE t_cadre_emploi.oid > 0 +ORDER BY t_cadre_emploi.code', 'CAE'), +(1, 't_categorie_statutaire', 'Catégorie statutaire', 'SELECT t_categorie_statutaire.oid, + t_categorie_statutaire.code, + t_categorie_statutaire.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_categorie_statutaire + LEFT JOIN rh.p_oids ON (t_categorie_statutaire.oid = p_oids.oid AND code_table = ''categorie_statutaire'') +WHERE t_categorie_statutaire.oid > 0 +ORDER BY t_categorie_statutaire.code', 'CAS'), +(1, 't_codes_emploi', '[DICT.RH.CODE_EMPLOI]', 'SELECT t_codes_emploi.oid, t_codes_emploi.code, t_codes_emploi.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_codes_emploi LEFT JOIN rh.p_oids ON (t_codes_emploi.oid = p_oids.oid AND code_table = ''codes_emploi'') +WHERE t_codes_emploi.oid > 0 +ORDER BY t_codes_emploi.code', 'CEM'), +(1, 't_compte_imputation', 'Compte d''imputation', 'SELECT t_compte_imputation.oid, + t_compte_imputation.code, + t_compte_imputation.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_compte_imputation + LEFT JOIN rh.p_oids ON (t_compte_imputation.oid = p_oids.oid AND code_table = ''compte_imputation'') +WHERE t_compte_imputation.oid > 0 +ORDER BY t_compte_imputation.code', 'COI'), +(1, 't_code_cotisation', 'Code cotisation', 'SELECT t_code_cotisation.oid, + t_code_cotisation.code, + t_code_cotisation.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_code_cotisation + LEFT JOIN rh.p_oids ON (t_code_cotisation.oid = p_oids.oid AND code_table = ''code_cotisation'') +WHERE t_code_cotisation.oid > 0 +ORDER BY t_code_cotisation.code', 'COT'), +(1, 't_codes_postaux', 'Code postal', 'SELECT t_codes_postaux.oid, t_codes_postaux.code, t_codes_postaux.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_codes_postaux LEFT JOIN rh.p_oids ON (t_codes_postaux.oid = p_oids.oid AND code_table = ''codes_postaux'') +WHERE t_codes_postaux.oid > 0 +ORDER BY t_codes_postaux.code', 'CPO'), +(1, 't_compte', 'Compte', 'SELECT t_compte.oid, + t_compte.code, + t_compte.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_compte + LEFT JOIN rh.p_oids ON (t_compte.oid = p_oids.oid AND code_table = ''compte'') +WHERE t_compte.oid > 0 +ORDER BY t_compte.code', 'CPT'), +(1, 't_categories_socio_professionnelles', '[DICT.RH.CATEGORIE_SOC_PRO]', 'SELECT t_categories_socio_professionnelle.oid, t_categories_socio_professionnelle.code, t_categories_socio_professionnelle.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_categories_socio_professionnelle LEFT JOIN rh.p_oids ON (t_categories_socio_professionnelle.oid = p_oids.oid AND code_table = ''categories_socio_professionnelle'') +WHERE t_categories_socio_professionnelle.oid > 0 +ORDER BY t_categories_socio_professionnelle.code', 'CSC'), +(1, 't_etablissements', 'Etablissement', 'SELECT t_etablissements.oid, + t_etablissements.code, + t_etablissements.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_etablissements + LEFT JOIN rh.p_oids ON (t_etablissements.oid = p_oids.oid AND code_table = ''etablissements'') +WHERE t_etablissements.oid > 0 +ORDER BY t_etablissements.code', 'ETS'), +(1, 't_filiere', 'Filière', 'SELECT t_filiere.oid, + t_filiere.code, + t_filiere.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_filiere + LEFT JOIN rh.p_oids ON (t_filiere.oid = p_oids.oid AND code_table = ''filiere'') +WHERE t_filiere.oid > 0 +ORDER BY t_filiere.code', 'FIL'), +(1, 't_liste_formations', 'Liste des formations', 'SELECT t_liste_formations.oid, + t_liste_formations.code, + t_liste_formations.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_liste_formations + LEFT JOIN rh.p_oids ON (t_liste_visites.oid = p_oids.oid AND code_table = ''liste_formations'') +WHERE t_liste_formations.oid > 0 +ORDER BY t_liste_formations.code', 'FOR'), +(1, 't_commission_paritaire', 'Groupe de commission paritaire', 'SELECT t_commission_paritaire.oid, + t_commission_paritaire.code, + t_commission_paritaire.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_commission_paritaire + LEFT JOIN rh.p_oids ON (t_commission_paritaire.oid = p_oids.oid AND code_table = ''commission_paritaire'') +WHERE t_commission_paritaire.oid > 0 +ORDER BY t_commission_paritaire.code', 'GCP'), +(1, 't_groupes_cotisant', '[DICT.RH.GROUPE_COTISANT]', 'SELECT t_groupes_cotisant.oid, t_groupes_cotisant.code, t_groupes_cotisant.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_groupes_cotisant LEFT JOIN rh.p_oids ON (t_groupes_cotisant.oid = p_oids.oid AND code_table = ''groupes_cotisant'') +WHERE t_groupes_cotisant.oid > 0 +ORDER BY t_groupes_cotisant.code', 'GCT'), +(1, 't_grilles_groupes', '[DICT.RH.GROUPE_GRILLE]', 'SELECT t_grilles_groupes.oid, + t_grilles_groupes.code, + t_grilles_groupes.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_grilles_groupes + LEFT JOIN rh.p_oids ON (t_grilles_groupes.oid = p_oids.oid AND code_table = ''grilles_groupes'') +WHERE t_grilles_groupes.oid > 0 +ORDER BY t_grilles_groupes.code', 'GRG'), +(1, 't_grilles', '[DICT.RH.GRILLE]', 'SELECT t_grilles.oid, + t_grilles.code, + t_grilles.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_grilles + LEFT JOIN rh.p_oids ON (t_grilles.oid = p_oids.oid AND code_table = ''grilles'') +WHERE t_grilles.oid > 0 +ORDER BY t_grilles.code', 'GRI'), +(1, 't_lettre_budgetaire', 'Lettre Budgétaire', 'SELECT t_lettre_budgetaire.oid, + t_lettre_budgetaire.code, + t_lettre_budgetaire.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_lettre_budgetaire + LEFT JOIN rh.p_oids ON (t_lettre_budgetaire.oid = p_oids.oid AND code_table = ''lettre_budgetaire'') +WHERE t_lettre_budgetaire.oid > 0 +ORDER BY t_lettre_budgetaire.code', 'LEB'), +(1, 't_motifs_arret', 'Motif [DICT.RH.ARRET_TRAVAIL#2]', 'SELECT t_motifs_arret.oid, + t_motifs_arret.code, + t_motifs_arret.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_motifs_arret + LEFT JOIN rh.p_oids ON (t_motifs_arret.oid = p_oids.oid AND code_table = ''motifs_arret'') +WHERE t_motifs_arret.oid > 0 +ORDER BY t_motifs_arret.code', 'MOA'), +(1, 't_motifs_debut_contrat', '[DICT.RH.MOTIF_DEBUT#1] [DICT.RH.CONTRAT#2]', 'SELECT t_motifs_debut_contrat.oid, t_motifs_debut_contrat.code, t_motifs_debut_contrat.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_motifs_debut_contrat LEFT JOIN rh.p_oids ON (t_motifs_debut_contrat.oid = p_oids.oid AND code_table = ''motifs_debut_contrat'') +WHERE t_motifs_debut_contrat.oid > 0 +ORDER BY t_motifs_debut_contrat.code', 'MTD'), +(1, 't_motifs_fin_contrat', 'Motif fin [DICT.RH.CONTRAT#2]', 'SELECT t_motifs_fin_contrat.oid, t_motifs_fin_contrat.code, t_motifs_fin_contrat.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_motifs_fin_contrat LEFT JOIN rh.p_oids ON (t_motifs_fin_contrat.oid = p_oids.oid AND code_table = ''motifs_fin_contrat'') +WHERE t_motifs_fin_contrat.oid > 0 +ORDER BY t_motifs_fin_contrat.code', 'MTF'), +(1, 't_motifs_visite', 'Motif visite médicale', 'SELECT t_motifs_visite.oid, + t_motifs_visite.code, + t_motifs_visite.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_motifs_visite + LEFT JOIN rh.p_oids ON (t_motifs_visite.oid = p_oids.oid AND code_table = ''motifs_visite'') +WHERE t_motifs_visite.oid > 0 +ORDER BY t_motifs_visite.code', 'MVM'), +(1, 't_nationalites', 'Nationalité', 'SELECT t_nationalites.oid, + t_nationalites.code, + t_nationalites.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_nationalites + LEFT JOIN rh.p_oids ON (t_nationalites.oid = p_oids.oid AND code_table = ''nationalites'') +WHERE t_nationalites.oid > 0 +ORDER BY t_nationalites.code', 'NAT'), +(1, 't_organismes_cotisation', '[DICT.RH.ORGANISME_COTISATION]', 'SELECT t_organismes_cotisation.oid, t_organismes_cotisation.code, t_organismes_cotisation.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_organismes_cotisation LEFT JOIN rh.p_oids ON (t_organismes_cotisation.oid = p_oids.oid AND code_table = ''organismes_cotisation'') +WHERE t_organismes_cotisation.oid > 0 +ORDER BY t_organismes_cotisation.code', 'ORC'), +(1, 't_planning_type_absence', 'Type d''absences (planning)', 'SELECT t_planning_type_absence.oid, + t_planning_type_absence.code, + t_planning_type_absence.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_planning_type_absence + LEFT JOIN rh.p_oids ON (t_planning_type_absence.oid = p_oids.oid AND code_table = ''planning_type_absence'') +WHERE t_planning_type_absence.oid > 0 +ORDER BY t_planning_type_absence.code', 'PAB'), +(1, 't_planning_code_horaire', 'Code Horaire (planning)', 'SELECT t_planning_code_horaire.oid, + t_planning_code_horaire.code, + t_planning_code_horaire.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_planning_code_horaire + LEFT JOIN rh.p_oids ON (t_planning_code_horaire.oid = p_oids.oid AND code_table = ''planning_code_horaire'') +WHERE t_planning_code_horaire.oid > 0 +ORDER BY t_planning_code_horaire.code', 'PCH'), +(1, 't_planning_niveau', '[DICT.RH.NIVEAU#3]', 'SELECT t_planning_niveau.oid, + t_planning_niveau.code, + t_planning_niveau.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_planning_niveau + LEFT JOIN rh.p_oids ON (t_planning_niveau.oid = p_oids.oid AND code_table = ''t_planning_niveau'') +WHERE t_planning_niveau.oid > 0 +ORDER BY t_planning_niveau.code', 'PNI'), +(1, 't_population', 'Population', 'SELECT t_population.oid, + t_population.code, + t_population.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_population + LEFT JOIN rh.p_oids ON (t_population.oid = p_oids.oid AND code_table = ''population'') +WHERE t_population.oid > 0 +ORDER BY t_population.code', 'POP'), +(1, 't_planning_qualification', 'Qualifications (planning)', 'SELECT t_planning_qualification.oid, + t_planning_qualification.code, + t_planning_qualification.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_planning_qualification + LEFT JOIN rh.p_oids ON (t_planning_qualification.oid = p_oids.oid AND code_table = ''planning_qualification'') +WHERE t_planning_qualification.oid > 0 +ORDER BY t_planning_qualification.code', 'PQU'), +(1, 't_planning_service', 'Services (planning)', 'SELECT t_planning_service.oid, + t_planning_service.code, + t_planning_service.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_planning_service + LEFT JOIN rh.p_oids ON (t_planning_service.oid = p_oids.oid AND code_table = ''planning_service'') +WHERE t_planning_service.oid > 0 +ORDER BY t_planning_service.code', 'PSE'), +(1, 't_qualifications', 'Qualification', 'SELECT t_qualifications.oid, t_qualifications.code, t_qualifications.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_qualifications LEFT JOIN rh.p_oids ON (t_qualifications.oid = p_oids.oid AND code_table = ''qualifications'') +WHERE t_qualifications.oid > 0 +ORDER BY t_qualifications.code', 'QUA'), +(1, 't_rubriques', 'Rubrique', 'SELECT t_rubriques.oid, t_rubriques.code, t_rubriques.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_rubriques LEFT JOIN rh.p_oids ON (t_rubriques.oid = p_oids.oid AND code_table = ''rubriques'') +WHERE t_rubriques.oid > 0 +ORDER BY t_rubriques.code', 'RUP'), +(1, 't_sections_analytiques', '[DICT.RH.SECTION_ANA_CPT#1]', 'SELECT t_sections_analytiques.oid, t_sections_analytiques.code, t_sections_analytiques.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_sections_analytiques LEFT JOIN rh.p_oids ON (t_sections_analytiques.oid = p_oids.oid AND code_table = ''sections_analytiques'') +WHERE t_sections_analytiques.oid > 0 +ORDER BY t_sections_analytiques.code', 'SAC'), +(1, 'p_salaries', '[DICT.RH.SALARIE]', 'SELECT v_salaries_1.salarie_id AS oid, v_salaries_1.salarie_code AS code, v_salaries_1.salarie_texte || CASE WHEN date_fin_contrat < ''20991231'' THEN '' ('' || date_fin_contrat || '')'' ELSE '''' END AS texte, qualification_texte || '' - ''|| service_texte as complement, ''O''::text as utilise +FROM rh.v_salaries_1 +ORDER BY v_salaries_1.salarie_code', 'SAL'), +(1, 't_sections_analytiques_paie', '[DICT.RH.SECTION_ANA_PAIE#1]', 'SELECT t_sections_analytiques_paie.oid, t_sections_analytiques_paie.code, t_sections_analytiques_paie.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_sections_analytiques_paie LEFT JOIN rh.p_oids ON (t_sections_analytiques_paie.oid = p_oids.oid AND code_table = ''sections_analytiques_paie'') +WHERE t_sections_analytiques_paie.oid > 0 +ORDER BY t_sections_analytiques_paie.code', 'SAP'), +(1, 't_services', '[DICT.RH.SERVICE]', 'SELECT t_services.oid, t_services.code, t_services.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_services LEFT JOIN rh.p_oids ON (t_services.oid = p_oids.oid AND code_table = ''services'') +WHERE t_services.oid > 0 +ORDER BY t_services.code', 'SER'), +(1, 't_specialites', 'Spécialité', 'SELECT t_specialites.oid, t_specialites.code, t_specialites.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_specialites LEFT JOIN rh.p_oids ON (t_specialites.oid = p_oids.oid AND code_table = ''specialites'') +WHERE t_specialites.oid > 0 +ORDER BY t_specialites.code', 'SPE'), +(1, 't_statuts', '[DICT.RH.STATUT]', 'SELECT t_statuts.oid, + t_statuts.code, + t_statuts.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_statuts + LEFT JOIN rh.p_oids ON (t_statuts.oid = p_oids.oid AND code_table = ''statuts'') +WHERE t_statuts.oid > 0 +ORDER BY t_statuts.code', 'STA'), +(1, 't_types_contrat', '[DICT.RH.TYPE_CONTRAT]', 'SELECT t_types_contrat.oid, t_types_contrat.code, t_types_contrat.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_types_contrat LEFT JOIN rh.p_oids ON (t_types_contrat.oid = p_oids.oid AND code_table = ''types_contrat'') +WHERE t_types_contrat.oid > 0 +ORDER BY t_types_contrat.code', 'TCN'), +(1, 't_types_horaire', 'Type horaire', 'SELECT t_types_horaire.oid, t_types_horaire.code, t_types_horaire.texte, ''''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN ''O'' ELSE ''N'' END as utilise +FROM rh.t_types_horaire LEFT JOIN rh.p_oids ON (t_types_horaire.oid = p_oids.oid AND code_table = ''types_horaire'') +WHERE t_types_horaire.oid > 0 +ORDER BY t_types_horaire.code', 'THO'), +(1, 't_types_temps_travail', 'Type temps travail', 'SELECT t_types_temps_travail.oid, + t_types_temps_travail.code, + t_types_temps_travail.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_types_temps_travail + LEFT JOIN rh.p_oids ON (t_types_temps_travail.oid = p_oids.oid AND code_table = ''types_temps_travail'') +WHERE t_types_temps_travail.oid > 0 +ORDER BY t_types_temps_travail.code', 'TTT'), +(1, 't_unite_fonctionnelle', 'Unité fonctionnelle', 'SELECT t_unite_fonctionnelle.oid, + t_unite_fonctionnelle.code, + t_unite_fonctionnelle.texte, + ''''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN ''O'' + ELSE ''N'' + END AS utilise +FROM rh.t_unite_fonctionnelle + LEFT JOIN rh.p_oids ON (t_unite_fonctionnelle.oid = p_oids.oid AND code_table = ''unite_fonctionnelle'') +WHERE t_unite_fonctionnelle.oid > 0 +ORDER BY t_unite_fonctionnelle.code', 'UNF') +; + +-- 3/3 : Màj de la table iCTI +UPDATE rh.t_listes_tables SET + code = w_dbsetup.code, + texte = w_dbsetup.texte, + select_cmd = w_dbsetup.select_cmd +FROM w_dbsetup +WHERE t_listes_tables.name = w_dbsetup.name +; + +INSERT INTO rh.t_listes_tables(oid, code, name, texte, select_cmd) + SELECT oid, code, name, texte, select_cmd FROM w_dbsetup WHERE oid = 0 AND oid NOT IN (SELECT oid FROM rh.t_listes_tables) +; + +INSERT INTO rh.t_listes_tables(code, name, texte, select_cmd) + SELECT code, name, texte, select_cmd FROM w_dbsetup WHERE oid <> 0 AND name NOT IN (SELECT name FROM rh.t_listes_tables) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_rapports.SQL b/db/data/dbdata_rh_t_rapports.SQL new file mode 100644 index 0000000..46106ce --- /dev/null +++ b/db/data/dbdata_rh_t_rapports.SQL @@ -0,0 +1,49 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + oid, + code, + texte, + is_cti, + is_essentiel + FROM rh.t_rapports + WHERE is_cti = '1' + ORDER BY code + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + code, + texte, + is_cti, + is_essentiel +) +VALUES +(1, 'CTI_ESS_10', 'RH-Paie', '1', '1'), +(1, 'CTI_ESS_11', 'Rémunérations', '1', '1'), +(1, 'CTI_PF_AGG', 'CTI Portfolio', '1', '1'), +(1, 'CTI_QUA', 'Qualité des données', '1', '0'), +(1, 'RH1', 'Rapport personnalisé RH', '1', '0') +; + +-- 3/3 : Màj de la table iCTI +UPDATE rh.t_rapports SET + texte = w_dbsetup.texte, + is_cti = w_dbsetup.is_cti, + is_essentiel = w_dbsetup.is_essentiel +FROM w_dbsetup +WHERE t_rapports.code = w_dbsetup.code +; + +INSERT INTO rh.t_rapports(oid, code, texte, is_cti, is_essentiel) + SELECT oid, code, texte, is_cti, is_essentiel FROM w_dbsetup WHERE oid = 0 AND oid NOT IN (SELECT oid FROM rh.t_rapports) +; + +INSERT INTO rh.t_rapports(code, texte, is_cti, is_essentiel) + SELECT code, texte, is_cti, is_essentiel FROM w_dbsetup WHERE oid <> 0 AND code NOT IN (SELECT code FROM rh.t_rapports) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_rapports_rubriques.SQL b/db/data/dbdata_rh_t_rapports_rubriques.SQL new file mode 100644 index 0000000..0ff486c --- /dev/null +++ b/db/data/dbdata_rh_t_rapports_rubriques.SQL @@ -0,0 +1,270 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_rapports.code AS rapport_code, + ind1.code AS indicateur_code, + t_rapports_rubriques.numero_rubrique, + t_rapports_rubriques.rapport_id, + t_rapports_rubriques.indicateur_id, + t_rapports_rubriques.entete, + t_rapports_rubriques.output_format, + t_rapports_rubriques.width, + t_rapports_rubriques.entete_etendue, + t_rapports_rubriques.periode_reference, + t_rapports_rubriques.row_height, + t_rapports_rubriques.padding, + t_rapports_rubriques.font_size, + t_rapports_rubriques.font_weight, + t_rapports_rubriques.border_thickness, + t_rapports_rubriques.color, + t_rapports_rubriques.background_color, + t_rapports_rubriques.base_nationale, + t_rapports_rubriques.base_nationale_qualifiee, + t_rapports_rubriques.viewlink, + t_rapports_rubriques.viewlink_label, + t_rapports_rubriques.viewlink_param, + t_rapports_rubriques.picto_enabled, + t_rapports_rubriques.positif_is_good, + t_rapports_rubriques.indicateur_associe_id, + ind2.code AS indicateur_associe_code + FROM rh.t_rapports_rubriques + JOIN rh.t_rapports ON t_rapports_rubriques.rapport_id = t_rapports.oid + JOIN rh.t_indicateurs ind1 ON t_rapports_rubriques.indicateur_id = ind1.oid + LEFT JOIN rh.t_indicateurs ind2 ON t_rapports_rubriques.indicateur_associe_id = ind2.oid + WHERE 1=1 + AND ind1.is_cti = '1' + AND ind1.code <> '' + AND t_rapports.is_cti = '1' + ORDER BY t_rapports.code, ind1.code, t_rapports_rubriques.numero_rubrique + LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + rapport_code, + indicateur_code, + numero_rubrique, + rapport_id, + indicateur_id, + entete, + output_format, + width, + entete_etendue, + periode_reference, + row_height, + padding, + font_size, + font_weight, + border_thickness, + color, + background_color, + base_nationale, + base_nationale_qualifiee, + viewlink, + viewlink_label, + viewlink_param, + picto_enabled, + positif_is_good, + indicateur_associe_id, + indicateur_associe_code +) +VALUES +('CTI_ESS_10', 'CTINBJARRET', 30, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par code emploi et salarié', 'GROUPBY=CEM&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_AGEMOY', 12, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000023', 'Pyramide des âges par Age et salarié.', 'GROUPBY=AGE&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_CDDSALP', 11, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par type de contrat et catégorie socio-professionnelle', 'GROUPBY=TCN&GROUPBY_2=CSC&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_DBTCDD', 21, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par spécialité et salarié', 'GROUPBY=SPE&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#LSCDD&VIEWTAB=2', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_DBTCDI', 20, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par type de temps de travail et salarié', 'GROUPBY=TTT&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_DUREEMOYARRETS', 34, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par code sexe et salarié', 'GROUPBY=SEX&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#DTCTI_CDD&VIEWTAB=2', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_EFF1ERJANV', 7, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par spécialité', 'GROUPBY=SPE', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_EFF31DEV', 8, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par code emploi', 'GROUPBY=CEM', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_EFFPERM', 6, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par type de temps de travail', 'GROUPBY=TTT', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_EMBMS25', 9, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Salarié de mois de 25 ans par qualification et par salarié', 'GROUPBY=QUA&GROUPBY_2=SAL&AGE=IN&AGE_INT=&AGE_INT2=25&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_FINCNT', 22, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par code emploi et salarié', 'GROUPBY=CEM&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_FINCNTCDD', 24, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse des CDD par indice et salarié', 'GROUPBY=GRI&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#LSCDD&VIEWTAB=2', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_FINCNTCDI', 23, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse des CDI par code emploi et salarié', 'GROUPBY=CEM&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#LSCDI&VIEWTAB=2', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBARRET', 26, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par catégorie socio-professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBARRETMOY', 35, 1, 1, 'Nombre d''arrêts moyen (sur total des salariés)', '', 0, 'Nombre d''arrêts moyen (sur total des salariés)', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par catégorie socio-professionnelle', 'GROUPBY=CSC', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBARRET_ACT', 29, 1, 1, 'Dont accident du travail', '', 0, 'Dont accident du travail', ' ', 22, 20, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par spécialité et salarié', 'GROUPBY=SPE&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBARRET_MAL', 27, 1, 1, 'Dont maladie', '', 0, 'Dont maladie', ' ', 22, 20, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par motif d''arrêt et salarié', 'GROUPBY=MOA&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBARRET_MAT', 28, 1, 1, 'Dont maternité', '', 0, 'Dont maternité', ' ', 22, 20, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par service et salarié', 'GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBCNT', 16, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par catégorie socio-professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBCONTRATCDD', 18, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par service et salarié', 'GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBCONTRATCDI', 17, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par qualification et salarié', 'GROUPBY=QUA&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBJARRET_ACT', 33, 1, 1, 'Dont accident du travail', '', 0, 'Dont accident du travail', ' ', 22, 20, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par tranche d''age du bilan social et salarié', 'GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBJARRET_MAL', 31, 1, 1, 'Dont maladie', '', 0, 'Dont maladie', ' ', 22, 20, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par indice et salarié', 'GROUPBY=GRI&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBJARRET_MAT', 32, 1, 1, 'Dont maternité', '', 0, 'Dont maternité', ' ', 22, 20, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000008', 'Analyse par qualification et salarié', 'GROUPBY=QUA&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBSALCNT', 2, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par catégorie socio-professionnelle', 'GROUPBY=CSC', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NBSALCNTFR', 14, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000023', 'Analyse par tranche d''âge du bilan social', 'GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NOUVSALS', 3, 1, 1, '', '', 0, 'Nouveaux salariés', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par qualification', 'GROUPBY=QUA', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_NVXCNT', 19, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par type de contrat et salarié', 'GROUPBY=TCN&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_PCTFEMMECNT', 13, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par classe d''âge du bilan social et salarié', 'GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_ROTATIONEMP', 5, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par type de contrat et qualification', 'GROUPBY=TCN', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_SAL60', 10, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Salariés de 60 ans et + par qualification et par salarié', 'GROUPBY=QUA&GROUPBY_2=SAL&AGE=IN&AGE_INT=60&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_SALPARTISSP', 4, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000003', 'Analyse par service', 'GROUPBY=SER', '1', '1', 0, ''), +('CTI_ESS_10', 'CTI_SEP', 1, 1, 1, '', '', 0, 'Salariés', ' ', 26, 0, 14, 'bold ', 2, '#9B59B6 ', '0xCCCCCC ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_ESS_10', 'CTI_SEP', 15, 1, 1, '', '', 0, 'Contrats', ' ', 26, 0, 14, 'bold ', 2, '#9B59B6 ', '0xCCCCCC ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_ESS_10', 'CTI_SEP', 25, 1, 1, '', '', 0, 'Arrêts de travail', ' ', 26, 0, 14, 'bold ', 2, '#9B59B6 ', '0xCCCCCC ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_ESS_11', 'CTIAN', 12, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par Type de contrat et salarié', 'GROUPBY=TCN&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTICOTPAT', 16, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par rubrique de paie', 'GROUPBY=RUPCLS', '1', '1', 0, ''), +('CTI_ESS_11', 'CTICOTSAL ', 14, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par salarié', 'GROUPBY=SAL', '1', '1', 0, ''), +('CTI_ESS_11', 'CTIETPTHM', 6, 1, 1, 'ETP Travaillé', '', 0, 'ETP Travaillé', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par spécialité', 'GROUPBY=SPE', '0', '0', 0, ''), +('CTI_ESS_11', 'CTIHP', 3, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par catégorie socio-professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTIHT', 4, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par qualification', 'GROUPBY=QUA', '1', '1', 0, ''), +('CTI_ESS_11', 'CTIMASSMOY', 9, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par catégorie socio-professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTIMTMASSE', 8, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par catégorie socio-professionnelle', 'GROUPBY=CSC', '1', '1', 0, ''), +('CTI_ESS_11', 'CTINETAPAYER', 18, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par catégorie socio-professionnelle et type de contrat bilan social', 'GROUPBY=CSC&GROUPBY_2=TCNCLS9', '1', '1', 0, ''), +('CTI_ESS_11', 'CTINETIMPOS', 17, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par type de temps de travail et salarié', 'GROUPBY=TTT&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTIODNET', 15, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par contrat et section analytique comptable', 'GROUPBY=CNT&GROUPBY_2=SAC&GROUPBY_TAB=ARB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_BRUTMOYENETP', 11, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par service et salarié', 'GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_ETPREMMOY', 5, 1, 1, 'ETP Payé', '', 0, 'ETP Payé', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par service', 'GROUPBY=SER', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_FRIMPOS', 13, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par spécialité et salarié', 'GROUPBY=SPE&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_MHMC', 20, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par age bilan social et salarié', 'GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_MTBRUT', 10, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par qualification et salarié', 'GROUPBY=QUA&GROUPBY_2=SAL&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_MT_CNT', 27, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Rupture de contrat par service et salarié', 'GROUPBY=SER&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_CNT', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_MT_IJ', 29, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'IJSS par service et salarié', 'GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB&RUBRIQUE=#LICTI_EXP_IJS', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_MT_PRE', 25, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Précarité par service et salarié', 'GROUPBY=SER&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_PRE&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_MT_RET', 23, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Départ à la retraite par service et salarié', 'GROUPBY=SER&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_RET', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_NBIJSS', 28, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'IJSS par catégorie socio-professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB&RUBRIQUE=#LICTI_EXP_IJS', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_NBRUPT', 26, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Rupture de contrat par catégorie socio-professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_CNT', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_NBSAL', 2, 1, 1, 'Nombre de salariés', '', 0, 'Nombre de salariés', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par catégorie socio-professionnelle', 'GROUPBY=CSC', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_NB_PRE', 24, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Précarité par catégorie socio-professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_PRE&GROUPBY_TAB=TAB', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_NB_RET', 22, 1, 1, '', '', 0, '', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Départ à la retraite par catégorie socio--professionnelle et salarié', 'GROUPBY=CSC&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_RET', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_SALCHGMOY', 19, 1, 1, 'Net à Payer Moyen', '', 0, 'Net à Payer Moyen', ' ', 22, 10, 12, ' ', 0, ' ', ' ', '0', '0', 'RH000007', 'Analyse par catégorie socio-professionnelle et type de temps de travail', 'GROUPBY=CSC&GROUPBY_2=TTTCLS9', '1', '1', 0, ''), +('CTI_ESS_11', 'CTI_SEP', 1, 1, 1, '', '', 0, 'Historique de Paie', ' ', 26, 0, 14, 'bold ', 2, '#9B59B6 ', '0xcccccc ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_ESS_11', 'CTI_SEP', 7, 1, 1, '', '', 0, 'Masse Salariale', ' ', 26, 0, 14, 'bold ', 0, '#9B59B6 ', '0xcccccc ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_ESS_11', 'CTI_SEP', 21, 1, 1, '', '', 0, 'Evènements exceptionnels', ' ', 26, 0, 14, 'bold ', 2, '#9B59B6 ', '0xcccccc ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_QUA', 'CTI_CEM', 12, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_CPO', 7, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_CSP', 13, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_DNA', 4, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_GCO', 20, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_GGR', 21, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_GRI', 22, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_MDD', 10, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_MDF', 11, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_NAT', 5, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_NBSALCNT', 1, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_QUA', 14, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_SAC', 24, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_SAP', 23, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_SEP', 2, 1, 1, '', '', 0, 'Salarié', ' ', 0, 0, 12, 'bold ', 0, '0xffffff ', '0x2c3e50 ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_QUA', 'CTI_SEP', 8, 1, 1, '', '', 0, 'Contrat', ' ', 0, 0, 0, 'bold ', 0, '0xffffff ', '0x2c3e50 ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('CTI_QUA', 'CTI_SER', 15, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_SEX', 3, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_SFA', 6, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_SIN', 25, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_SPE', 16, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_STA', 17, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_TCNT', 9, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_THO', 19, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('CTI_QUA', 'CTI_TTT', 18, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTIHP', 6, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTIMASSMOY', 12, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTINBHOMME', 1, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTINBJARRET', 8, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTITA', 14, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTITB', 15, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_ETPW', 5, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_MTBRUT', 13, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_NBARRET', 7, 1, 1, '', '', 0, '', ' ', 0, 0, 0, ' ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_NBCNT', 3, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_NBFEMMEPAIE', 2, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_PCDD', 10, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_PCDI', 11, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', '0', '0', 0, ''), +('RH1', 'CTI_SEP', 4, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', ' ', ' ', 0, ''), +('RH1', 'CTI_SEP', 9, 1, 1, '', '', 0, '', ' ', 0, 0, 0, 'normal ', 0, ' ', ' ', '0', '0', '', '', '', ' ', ' ', 0, '') +; + +-- 3/3 : Màj de la table iCTI +-- Sauvegarder les donnees sources pour rejouer le specifique +SELECT base.cti_verify_table_encoding('rh','t_rapports_rubriques') +; +DROP TABLE IF EXISTS w_specific_rapports_rubriques ; +CREATE TEMP TABLE w_specific_rapports_rubriques AS +SELECT t_rapports_rubriques.* +FROM rh.t_rapports_rubriques +JOIN rh.t_rapports ON t_rapports_rubriques.rapport_id = t_rapports.oid +WHERE t_rapports.is_essentiel = '1' +; + +-- Installer les donnees CTI +DELETE FROM rh.t_rapports_rubriques +WHERE 1=1 + AND rapport_id IN (SELECT oid FROM rh.t_rapports WHERE is_cti = '1') +; + +INSERT INTO rh.t_rapports_rubriques( + rapport_id, + numero_rubrique, + indicateur_id, + entete, + entete_etendue, + output_format, + width, + periode_reference, + row_height, + padding, + font_size, + font_weight, + border_thickness, + color, + base_nationale, + base_nationale_qualifiee, + background_color, + viewlink, + viewlink_label, + viewlink_param, + picto_enabled, + positif_is_good, + indicateur_associe_id + ) +SELECT + t_rapports.oid, + numero_rubrique, + ind1.oid, + w_dbsetup.entete, + w_dbsetup.entete_etendue, + w_dbsetup.output_format, + w_dbsetup.width, + w_dbsetup.periode_reference, + w_dbsetup.row_height, + w_dbsetup.padding, + w_dbsetup.font_size, + w_dbsetup.font_weight, + w_dbsetup.border_thickness, + w_dbsetup.color, + w_dbsetup.base_nationale, + w_dbsetup.base_nationale_qualifiee, + w_dbsetup.background_color, + w_dbsetup.viewlink, + w_dbsetup.viewlink_label, + w_dbsetup.viewlink_param, + w_dbsetup.picto_enabled, + w_dbsetup.positif_is_good, + COALESCE(ind2.oid, 0) +FROM w_dbsetup + JOIN rh.t_rapports ON w_dbsetup.rapport_code = t_rapports.code + JOIN rh.t_indicateurs ind1 ON w_dbsetup.indicateur_code = ind1.code + LEFT JOIN rh.t_indicateurs ind2 ON w_dbsetup.indicateur_associe_code = ind2.code +; + +-- Rejouer le specifique +UPDATE rh.t_rapports_rubriques SET + is_hide = w_specific_rapports_rubriques.is_hide, + specific_viewlink = w_specific_rapports_rubriques.specific_viewlink, + specific_viewlink_label = w_specific_rapports_rubriques.specific_viewlink_label, + specific_viewlink_param = w_specific_rapports_rubriques.specific_viewlink_param +FROM w_specific_rapports_rubriques +WHERE w_specific_rapports_rubriques.rapport_id = t_rapports_rubriques.rapport_id AND + w_specific_rapports_rubriques.indicateur_id = t_rapports_rubriques.indicateur_id AND + w_specific_rapports_rubriques.entete_etendue = t_rapports_rubriques.entete_etendue AND + ( + w_specific_rapports_rubriques.is_hide = '1' OR + w_specific_rapports_rubriques.specific_viewlink <> '' OR + w_specific_rapports_rubriques.specific_viewlink_label <> '' OR + w_specific_rapports_rubriques.specific_viewlink_param <> '' + ) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_vue_parametre.SQL b/db/data/dbdata_rh_t_vue_parametre.SQL new file mode 100644 index 0000000..d78910e --- /dev/null +++ b/db/data/dbdata_rh_t_vue_parametre.SQL @@ -0,0 +1,56 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT oid, + code, + texte, + array_to_string(data_code, '@') as data_code, + array_to_string(data_entete, '@') as data_entete, + array_to_string(data_format, '@') as data_format, + array_to_string(data_description, '@') as data_description, + position_ratio, + rang + FROM rh.t_vue_parametre + ORDER BY 2 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + oid, + code, + texte, + data_code, + data_entete, + data_format, + data_description, + position_ratio, + rang +) +VALUES +(1, 'BS_LDATA_2', 'CTI : Bilan social', 'NSAL@CNTTOT@NCDI@NCDD@NSALH@NSALF@AGEMOYDJ@EFFPERM@0@0@0@0@0@0@0', 'Nombre Salariés@Contrats total@Nombre CDI@Nombre CDD@Nombre hommes@Nombre Femmes@Age moyen@Effectif permanent', '#@#@#@#@#@#@#,0@#', 'Nombre de salarié total@Nombre de contrat total@Nombre contrats CDI@Nombre contrats CDD@Nombre salariés hommes@Nombre salariés femmes@Age moyen@Salariés titulaires d''un CDI à temps complet et présents sur l''ensemble de la période.', '000000000000000', 0), +(1, 'CT_LDATA_1', 'CTI : Effectif', 'NSAL@EFFPERM@ROTEMP@NSALH@NSALF@AGEMOYDJ@0@0@0@0@0@0@0@0@0', 'NB Salariées@Effectif permanent@Rotation de l''emploi@NB hommes@NB Femmes@Age moyen', '#@#@#%@#@#@#,0', 'Nombre de salarié total@Salariés titulaires d''un CDI à temps complet et présents sur l''ensemble de la période.@(nb d''entrées Ets. + nb de sorties Ets.) / 2 / nb de [DICT.RH.SALARIE#4] en début de période * 100@Nombre salariés hommes@Nombre salariés femmes@Age moyen', '000000000000000', 0), +(1, 'CT_LDATA_3', 'CTI : Contrat', 'NSAL@CNTTOT@NCDI@NCDD@CNTTERM@NHCNT@ETPTH@0@0@0@0@0@0@0@0', 'NB Salariées@Contrats total@Nombre CDI@Nombre CDD@Contrats terminés@Heures contrat@ETP contrat', '#@#@#@#@#@#,00@#,00', 'Nombre de salarié total@Nombre de contrat total@Nombre contrats CDI@Nombre contrats CDD@Contrats terminés@Nombre heures contrat@ETP Contrat', '000000000000000', 0), +(1, 'HP_LDATA_1', 'CTI : Livre de paie', 'NBSAL@MTMASSE@NBHP@NBHT@MTBRUT@MTCOTSALARIE@MTCOTPATRONALE@MTNETIMPOSABLE@MTNETAPAYER@0@0@0@0@0@0', 'NB Salariés@Masse sal.@Heures Payées@Heures Travaillées@Brut@Cot. Salariales@Cot. Patronales@Net imposable@Net à payer', '#@#E@#h@#h@#E@#E@#E@#E@#E', 'Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@Heures issues de la rubrique de paie paramétrée comme «Heures payées» dans la table des rubriques.@Heures paramétrées comme «travaillées» OU heures payées - heures paramétrées comme «Heures non travaillées».@Montant BRUT@Montant Cotisations Salariales@Montant Cotisations Patronales@Montant Net Imposable@Montant Net à payer@0@0@0@0@0@0', '000000000000000', 0), +(1, 'HP_LDATA_2', 'CTI : Livre de paie ( Avec nombre et base )', 'NBSAL@MTMASSE@NBHP@NBHT@MTBRUT@MTCOTSALARIE@MTCOTPATRONALE@MTNETIMPOSABLE@MTNETAPAYER@NOMBRE@BASE@0@0@0@0', 'NB Salariés@Masse sal.@Heures Payées@Heures Travaillées@Brut@Cot. Salariales@Cot. Patronales@Net imposable@Net à payer@Nombre@Base', '#@#E@#h@#h@#E@#E@#E@#E@#E@#,0@#,0', 'Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@Heures issues de la rubrique de paie paramétrée comme «Heures payées» dans la table des rubriques.@Heures paramétrées comme «travaillées» OU heures payées - heures paramétrées comme «Heures non travaillées».@Montant BRUT@Montant Cotisations Salariales@Montant Cotisations Patronales@Montant Net Imposable@Montant Net à payer@Nombre@Base@0@0@0@0', '000000000000000', 0), +(1, 'HP_LDATA_3', 'CTI : Décomposition Masse Salariale', 'NBSAL@MTMASSE@MTMASSEMOY@NBHP@MTBRUT@MTBRUTMOY@MTBRUTAVANTAGE@MTFRAISIMPOS@MTCOTPATRONALE@MTODNETPATRONALE@MTHORMOYCHAR@0@0@0@0', 'NB Salariés@Masse sal.@Masse sal. moyen@Heures Payées@Brut@Brut moyen@A. N.@F.I.@Cot. Patronales@OD/NET Patronales@Mnt h. moy. chargé', '#@#E@#E@#h@#E@#E@#E@#E@#E@#E@#,0E', 'Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@(Masse salariale ÷ ETP payé) ÷ Nb mois de la période.@Heures issues de la rubrique de paie paramétrée comme «Heures payées» dans la table des rubriques.@Montant BRUT@Montant BRUT Moyen@Montant Avantages en nature@Montant Frais imposables@Montant Cotisations Patronales@Montant OD NET Patronales@Montant horaire moyen chargé@0@0@0@0', '000000000000000', 0), +(1, 'HP_LDATA_4', 'CTI : Décomposition ETP', 'NBSAL@MTMASSE@MTMASSEMOY@NBETP@NBETPT@0@0@0@0@0@0@0@0@0@0', 'NB Salariés@Masse sal.@Masse sal. moyen@ETP Rémunéré@ETP travaillé', '#@#E@#E@#,00@#,00', 'Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@(Masse salariale ÷ ETP payé) ÷ Nb mois de la période.@Equivalent temps plein basé sur les Heures payées. Heures payées ÷ Base de calcul de l''ETP (par défaut 151,67 h.) ÷ Nb mois de la période.@Equivalent temps plein basé sur les Heures travaillées. Heures travaillées ÷ Base de calcul de l''ETP (par défaut 151,67 h.) ÷ Nb mois de la période.@0@0@0@0@0@0@0@0@0@0', '000000000000000', 0), +(1, 'HP_LDATA_5', 'CTI : Qualification', 'NBSAL@MTBRUT@MTCOTSALARIE@MTCOTPATRONALE@MTNETAPAYER@MTNETIMPOSABLE@MTMASSE@MTODNETSALARIE@0@0@0@0@0@0@0', 'NB Salariées@Montant Brut@Cotisations salariales@Cotisations patronales@Net à payer@Net imposable@Masse salariale@OD/net salariales', '#@#@#@#@#@#@#@#', 'Nombre de salarié @Montant BRUT@Montant cotisations salariales@Montant cotisations patronales@Montant net à payer@Montant net imposable@Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@Montant OD/net salariales@0@0@0@0@0@0@0', '000000000000000', 0), +(1, 'HP_LDATA_6', 'CTI : Brut / ETP Payé', 'NBSAL@MTBRUT@NBETP@0@0@0@0@0@0@0@0@0@0@0@0', 'NB Salariées@Montant Brut@ETP payé', '#@#@#,00', 'Nombre de salarié @Montant BRUT@Equivalent temps plein basé sur les Heures payées Heures payées Base de calcul de l''ETP (par défaut 151,67 h.) Nb mois de la période.@0@0@0@0@0@0@0@0@0@0@0', '000000000000000', 0) +; + +-- 3/3 : Màj de la table iCTI +INSERT INTO rh.t_vue_parametre(code, texte, data_code, data_entete, data_format, data_description,position_ratio,rang) + SELECT code, + texte, + string_to_array(data_code, '@') as data_code, + string_to_array(data_entete, '@') as data_entete, + string_to_array(data_format, '@') as data_format, + string_to_array(data_description, '@') as data_description, + position_ratio, + rang + FROM w_dbsetup + WHERE 1=1 + AND code NOT IN (SELECT code FROM rh.t_vue_parametre) +; \ No newline at end of file diff --git a/db/data/dbdata_rh_t_widget_user_parameter.SQL b/db/data/dbdata_rh_t_widget_user_parameter.SQL new file mode 100644 index 0000000..1bde54d --- /dev/null +++ b/db/data/dbdata_rh_t_widget_user_parameter.SQL @@ -0,0 +1,103 @@ +-- 1/3 : Création de la table temporaire +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup AS + SELECT + t_widget_user_parameter.oid as uuid, + t_dashboard.code || '|' || t_chart.code as dashboard_widget_code, + username, + title, + x, + y, + w, + h, + time_calc, + visible, + t_dashboard.code || '|' || t_dashboard_onglet.index as tab_code, + max_cat, + array_agg(DISTINCT t_indicateur_serie.code) as include_series_code + FROM rh.t_widget_user_parameter + JOIN rh.t_dashboard_widget ON t_dashboard_widget.oid = dashboard_widget_id + JOIN rh.t_dashboard ON t_dashboard.oid= t_dashboard_widget.dashboard_id + JOIN rh.t_chart on t_chart.oid = t_dashboard_widget.chart_id + JOIN rh.t_dashboard_onglet on t_dashboard_onglet.oid = tab_id + LEFT JOIN rh.t_indicateur_serie ON ARRAY[t_indicateur_serie.oid] <@ include_series_id + WHERE username = 'cti' + GROUP BY 1,2,3,4,5,6,7,8,9,10,11, t_dashboard_onglet.index + ORDER BY 2, 6, 7 LIMIT 0 +; + +-- 2/3 : Peuplement de la table temporaire +INSERT INTO w_dbsetup( + uuid, + dashboard_widget_code, + username, + title, + x, + y, + w, + h, + time_calc, + visible, + tab_code, + max_cat, + include_series_code +) +VALUES +('60a09a2f-1714-4903-8a48-e0c7c5d5597e', 'CTI_EGAPRO|CTI_EFFAGE', 'cti', 'Répartion par tranche d''âge', 0, 18, 3, 7, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_FEMMES", "CTI_HOMMES"}'), +('2f166ff5-9eca-4a08-a72f-838cdc314385', 'CTI_EGAPRO|CTI_EFFANC', 'cti', 'Répartion par tranche d''ancienneté', 3, 18, 3, 7, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_FEMMES", "CTI_HOMMES"}'), +('4629419f-a2c6-4627-86b3-786d03ec1db7', 'CTI_EGAPRO|CTI_EFFGEN', 'cti', 'Effectif ', 2, 8, 4, 10, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_FEMMES", "CTI_HOMMES"}'), +('54980aad-8b6b-43e5-8d86-b4b47d46ff66', 'CTI_EGAPRO|CTI_EFFSTAT', 'cti', 'Effectifs par statut', 3, 25, 3, 8, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_FEMMES", "CTI_HOMMES"}'), +('fe63666a-69b0-4c35-8564-d243f605f520', 'CTI_EGAPRO|CTI_ENTSORCAR', 'cti', 'Hommes', 0, 8, 2, 5, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_DEPSALH", "CTI_EFFDH", "CTI_ENTSORH", "CTI_NVSALH", "CTI_TOH"}'), +('591c31d9-cf2a-4b9d-afd3-3605a476fc29', 'CTI_EGAPRO|CTI_ENTSORCAR', 'cti', 'Femmes', 0, 13, 2, 5, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_DEPSALF", "CTI_EFFDF", "CTI_ENTSORF", "CTI_NVSALF", "CTI_TOF"}'), +('da27e182-48ea-4c44-b874-4d3b860c875f', 'CTI_EGAPRO|CTI_MSAGE', 'cti', 'Masse salariale par tranche age', 0, 0, 6, 9, 'val', 't', 'CTI_EGAPRO|1', 0, '{"CTI_MSF", "CTI_MSH"}'), +('8230cb17-4b23-4f64-b513-c1f20d8d91f0', 'CTI_EGAPRO|CTI_MSCSP', 'cti', 'Masse salariale par CSP', 3, 9, 3, 13, 'val', 't', 'CTI_EGAPRO|1', 0, '{"CTI_MSF", "CTI_MSH"}'), +('7506a3e7-1b44-41e9-8727-e9fb1af75441', 'CTI_EGAPRO|CTI_MSCSPMAP', 'cti', 'Masse salariale par CSP (MAP)', 0, 9, 3, 13, 'val', 't', 'CTI_EGAPRO|1', 0, '{"CTI_MS"}'), +('1736e926-d668-4375-b042-95299d51b67c', 'CTI_EGAPRO|CTI_STAT', 'cti', 'Tableau statuts', 4, 0, 2, 8, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_FEMMES", "CTI_HOMMES", "CTI_TOTSAL"}'), +('1bf148e8-996a-4e64-b2b4-df19575c3368', 'CTI_EGAPRO|CTI_STATTIME', 'cti', 'Statuts', 0, 25, 3, 8, 'cum', 't', 'CTI_EGAPRO|0', 0, '{"CTI_TAUXSTAT", "CTI_TOTSAL", "CTI_TOTSALF"}'), +('732c7aad-a075-4ed8-a0b6-7a378af82d81', 'CTI_EGAPRO|CTI_TYPECNT', 'cti', 'Types de contrats - Femmes', 0, 0, 2, 8, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_FEMMES"}'), +('ac7b3909-8d3a-497e-9996-3b1111ded80e', 'CTI_EGAPRO|CTI_TYPECNT', 'cti', 'Types de contrats - Hommes', 2, 0, 2, 8, 'val', 't', 'CTI_EGAPRO|0', 0, '{"CTI_HOMMES"}') +; + +-- 3/3 : Màj de la table iCTI +DELETE FROM rh.t_widget_user_parameter WHERE username = 'cti'; + +INSERT INTO rh.t_widget_user_parameter( + oid, + dashboard_widget_id, + username, + title, + x, + y, + w, + h, + time_calc, + visible, + tab_id, + max_cat, + include_series_id +) + SELECT + w_dbsetup.uuid, + t_dashboard_widget.oid, + w_dbsetup.username, + w_dbsetup.title, + w_dbsetup.x, + w_dbsetup.y, + w_dbsetup.w, + w_dbsetup.h, + w_dbsetup.time_calc, + w_dbsetup.visible, + rh.t_dashboard_onglet.oid, + w_dbsetup.max_cat, + case when array_agg(DISTINCT t_indicateur_serie.oid) = ARRAY[NULL]::bigint[] then ARRAY[]::bigint[] else array_agg(DISTINCT t_indicateur_serie.oid) end + FROM w_dbsetup + JOIN rh.t_dashboard ON t_dashboard.code = SPLIT_PART(dashboard_widget_code, '|', 1) + JOIN rh.t_chart on t_chart.code = SPLIT_PART(dashboard_widget_code, '|', 2) + JOIN rh.t_dashboard_widget ON t_dashboard_widget.dashboard_id = t_dashboard.oid and t_dashboard_widget.chart_id = t_chart.oid + JOIN rh.t_dashboard_onglet ON t_dashboard_onglet.dashboard_id = t_dashboard.oid and t_dashboard_onglet.index = SPLIT_PART(tab_code, '|', 2) + LEFT JOIN rh.t_indicateur_serie ON ARRAY[t_indicateur_serie.code] <@ include_series_code + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12 + ORDER BY 1 +; \ No newline at end of file diff --git a/db/data2/dbdata_rh_t_ages.csv b/db/data2/dbdata_rh_t_ages.csv new file mode 100644 index 0000000..419f4ff --- /dev/null +++ b/db/data2/dbdata_rh_t_ages.csv @@ -0,0 +1,112 @@ +keepoid|code|texte +0|000|Nouveaux nés +1|001|1 an +2|002|2 ans +3|003|3 ans +4|004|4 ans +5|005|5 ans +6|006|6 ans +7|007|7 ans +8|008|8 ans +9|009|9 ans +10|010|10 ans +11|011|11 ans +12|012|12 ans +13|013|13 ans +14|014|14 ans +15|015|15 ans +16|016|16 ans +17|017|17 ans +18|018|18 ans +19|019|19 ans +20|020|20 ans +21|021|21 ans +22|022|22 ans +23|023|23 ans +24|024|24 ans +25|025|25 ans +26|026|26 ans +27|027|27 ans +28|028|28 ans +29|029|29 ans +30|030|30 ans +31|031|31 ans +32|032|32 ans +33|033|33 ans +34|034|34 ans +35|035|35 ans +36|036|36 ans +37|037|37 ans +38|038|38 ans +39|039|39 ans +40|040|40 ans +41|041|41 ans +42|042|42 ans +43|043|43 ans +44|044|44 ans +45|045|45 ans +46|046|46 ans +47|047|47 ans +48|048|48 ans +49|049|49 ans +50|050|50 ans +51|051|51 ans +52|052|52 ans +53|053|53 ans +54|054|54 ans +55|055|55 ans +56|056|56 ans +57|057|57 ans +58|058|58 ans +59|059|59 ans +60|060|60 ans +61|061|61 ans +62|062|62 ans +63|063|63 ans +64|064|64 ans +65|065|65 ans +66|066|66 ans +67|067|67 ans +68|068|68 ans +69|069|69 ans +70|070|70 ans +71|071|71 ans +72|072|72 ans +73|073|73 ans +74|074|74 ans +75|075|75 ans +76|076|76 ans +77|077|77 ans +78|078|78 ans +79|079|79 ans +80|080|80 ans +81|081|81 ans +82|082|82 ans +83|083|83 ans +84|084|84 ans +85|085|85 ans +86|086|86 ans +87|087|87 ans +88|088|88 ans +89|089|89 ans +90|090|90 ans +91|091|91 ans +92|092|92 ans +93|093|93 ans +94|094|94 ans +95|095|95 ans +96|096|96 ans +97|097|97 ans +98|098|98 ans +99|099|99 ans +100|100|100 ans +101|101|101 ans +102|102|102 ans +103|103|103 ans +104|104|104 ans +105|105|105 ans +106|106|106 ans +107|107|107 ans +108|108|108 ans +109|109|109 ans +110|110|110 ans diff --git a/db/data2/dbdata_rh_t_anciennetes_annee.csv b/db/data2/dbdata_rh_t_anciennetes_annee.csv new file mode 100644 index 0000000..b2899d1 --- /dev/null +++ b/db/data2/dbdata_rh_t_anciennetes_annee.csv @@ -0,0 +1,52 @@ +keepoid|code|texte +0|00|Moins de 1 an +1|01|1 an +2|02|2 ans +3|03|3 ans +4|04|4 ans +5|05|5 ans +6|06|6 ans +7|07|7 ans +8|08|8 ans +9|09|9 ans +10|10|10 ans +11|11|11 ans +12|12|12 ans +13|13|13 ans +14|14|14 ans +15|15|15 ans +16|16|16 ans +17|17|17 ans +18|18|18 ans +19|19|19 ans +20|20|20 ans +21|21|21 ans +22|22|22 ans +23|23|23 ans +24|24|24 ans +25|25|25 ans +26|26|26 ans +27|27|27 ans +28|28|28 ans +29|29|29 ans +30|30|30 ans +31|31|31 ans +32|32|32 ans +33|33|33 ans +34|34|34 ans +35|35|35 ans +36|36|36 ans +37|37|37 ans +38|38|38 ans +39|39|39 ans +40|40|40 ans +41|41|41 ans +42|42|42 ans +43|43|43 ans +44|44|44 ans +45|45|45 ans +46|46|46 ans +47|47|47 ans +48|48|48 ans +49|49|49 ans +50|50|50 ans diff --git a/db/data2/dbdata_rh_t_categories_socio_professionnelle.csv b/db/data2/dbdata_rh_t_categories_socio_professionnelle.csv new file mode 100644 index 0000000..1b1c780 --- /dev/null +++ b/db/data2/dbdata_rh_t_categories_socio_professionnelle.csv @@ -0,0 +1,431 @@ +oid|code|texte|texte_court +0|*|Non renseignée|N/R +1|100x|Agriculteurs et éleveurs, salariés de leur exploitation|Agriculteurs et éleveurs, salariés de leur explo +1|210x|Artisans salariés de leur entreprise|Artisans salariés de leur entreprise +1|220x|Commerçants et assimilés, salariés de leur entreprise|Commerçants et assimilés, salariés de leur entr +1|231a|Chefs de grande entreprise de 500 salariés et plus|Chefs de grande entreprise de 500 salariés et plu +1|232a|Chefs de moyenne entreprise, de 50 à 499 salariés|Chefs de moyenne entreprise, de 50 à 499 salarié +1|233a|Chefs d'entreprise du bâtiment et des travaux publics, de 10 à 49 salariés|Chefs d'entreprise du bâtiment et des travaux pub +1|233b|Chefs d'entreprise de l'industrie ou des transports, de 10 à 49 salariés|Chefs d'entreprise de l'industrie ou des transport +1|233c|Chefs d'entreprise commerciale, de 10 à 49 salariés|Chefs d'entreprise commerciale, de 10 à 49 salari +1|233d|Chefs d'entreprise de services, de 10 à 49 salariés|Chefs d'entreprise de services, de 10 à 49 salari +1|311c|Chirurgiens dentistes|Chirurgiens dentistes +1|311d|Psychologues, psychanalystes, psychothérapeutes (non médecins)|Psychologues, psychanalystes, psychothérapeutes ( +1|311e|Vétérinaires|Vétérinaires +1|312a|Avocats|Avocats +1|331a|Personnels de direction de la fonction publique (Etat, collectivités locales, hôpitaux)|Personnels de direction de la fonction publique (E +1|332a|Ingénieurs de l'Etat (y.c. ingénieurs militaires) et assimilés|Ingénieurs de l'Etat (y.c. ingénieurs militaires +1|332b|Ingénieurs des collectivités locales et des hôpitaux|Ingénieurs des collectivités locales et des hôp +1|333a|Magistrats*|Magistrats* +1|333b|Inspecteurs et autres personnels de catégorie A des Impôts, du Trésor et des Douanes|Inspecteurs et autres personnels de catégorie A d +1|333c|Cadres de la Poste*|Cadres de la Poste* +1|333d|Cadres administratifs de France Télécom (statut public)|Cadres administratifs de France Télécom (statut +1|333e|Autres personnels administratifs de catégorie A de l'Etat (hors Enseignement, Patrimoine, Impôts, Trésor, Douanes)|Autres personnels administratifs de catégorie A d +1|333f|Personnels administratifs de catégorie A des collectivités locales et hôpitaux publics (hors Enseignement, Patrimoine)|Personnels administratifs de catégorie A des coll +1|334a|Officiers des Armées et de la Gendarmerie (sauf officiers généraux)*|Officiers des Armées et de la Gendarmerie (sauf o +1|335a|Personnes exerçant un mandat politique ou syndical*|Personnes exerçant un mandat politique ou syndica +1|341a|Professeurs agrégés et certifiés de l'enseignement secondaire|Professeurs agrégés et certifiés de l'enseignem +1|341b|Chefs d'établissement de l'enseignement secondaire et inspecteurs|Chefs d'établissement de l'enseignement secondair +1|342b|Professeurs et maîtres de conférences|Professeurs et maîtres de conférences +1|342c|Professeurs agrégés et certifiés en fonction dans l'enseignement supérieur|Professeurs agrégés et certifiés en fonction da +1|342d|Personnel enseignant temporaire de l'enseignement supérieur|Personnel enseignant temporaire de l'enseignement +1|342f|Directeurs et chargés de recherche de la recherche publique|Directeurs et chargés de recherche de la recherch +1|342g|Ingénieurs d'étude et de recherche de la recherche publique|Ingénieurs d'étude et de recherche de la recherc +1|342h|Allocataires de la recherche publique|Allocataires de la recherche publique +1|343a|Psychologues spécialistes de l'orientation scolaire et professionnelle|Psychologues spécialistes de l'orientation scolai +1|344a|Médecins hospitaliers sans activité libérale|Médecins hospitaliers sans activité libérale +1|344b|Médecins salariés non hospitaliers|Médecins salariés non hospitaliers +1|344c|Internes en médecine, odontologie et pharmacie|Internes en médecine, odontologie et pharmacie +1|344d|Pharmaciens salariés|Pharmaciens salariés +1|351a|Bibliothécaires, archivistes, conservateurs et autres cadres du patrimoine|Bibliothécaires, archivistes, conservateurs et au +1|352a|Journalistes (y c. rédacteurs en chef)|Journalistes (y c. rédacteurs en chef) +1|352b|Auteurs littéraires, scénaristes, dialoguistes|Auteurs littéraires, scénaristes, dialoguistes +1|353a|Directeurs de journaux, administrateurs de presse, directeurs d'éditions (littéraire, musicale, audiovisuelle et multimédia)|Directeurs de journaux, administrateurs de presse, +1|353b|Directeurs, responsables de programmation et de production de l'audiovisuel et des spectacles|Directeurs, responsables de programmation et de pr +1|353c|Cadres artistiques et technico-artistiques de la réalisation de l'audiovisuel et des spectacles|Cadres artistiques et technico-artistiques de la r +1|354a|Artistes plasticiens|Artistes plasticiens +1|354b|Artistes de la musique et du chant|Artistes de la musique et du chant +1|354c|Artistes dramatiques|Artistes dramatiques +1|354e|Artistes de la danse|Artistes de la danse +1|354f|Artistes du cirque et des spectacles divers|Artistes du cirque et des spectacles divers +1|354g|Professeurs d'art (hors établissements scolaires)|Professeurs d'art (hors établissements scolaires) +1|371a|Cadres d'état-major administratifs, financiers, commerciaux des grandes entreprises|Cadres d'état-major administratifs, financiers, c +1|372a|Cadres chargés d'études économiques, financières, commerciales|Cadres chargés d'études économiques, financièr +1|372b|Cadres de l'organisation ou du contrôle des services administratifs et financiers|Cadres de l'organisation ou du contrôle des servi +1|372c|Cadres spécialistes des ressources humaines et du recrutement|Cadres spécialistes des ressources humaines et du +1|372d|Cadres spécialistes de la formation|Cadres spécialistes de la formation +1|372e|Juristes|Juristes +1|372f|Cadres de la documentation, de l'archivage (hors fonction publique)|Cadres de la documentation, de l'archivage (hors f +1|373a|Cadres des services financiers ou comptables des grandes entreprises|Cadres des services financiers ou comptables des g +1|373b|Cadres des autres services administratifs des grandes entreprises|Cadres des autres services administratifs des gran +1|373c|Cadres des services financiers ou comptables des petites et moyennes entreprises|Cadres des services financiers ou comptables des p +1|373d|Cadres des autres services administratifs des petites et moyennes entreprises|Cadres des autres services administratifs des peti +1|374a|Cadres de l'exploitation des magasins de vente du commerce de détail|Cadres de l'exploitation des magasins de vente du +1|374b|Chefs de produits, acheteurs du commerce et autres cadres de la mercatique|Chefs de produits, acheteurs du commerce et autres +1|374c|Cadres commerciaux des grandes entreprises (hors commerce de détail)|Cadres commerciaux des grandes entreprises (hors c +1|374d|Cadres commerciaux des petites et moyennes entreprises (hors commerce de détail)|Cadres commerciaux des petites et moyennes entrepr +1|375a|Cadres de la publicité|Cadres de la publicité +1|375b|Cadres des relations publiques et de la communication|Cadres des relations publiques et de la communicat +1|376a|Cadres des marchés financiers|Cadres des marchés financiers +1|376b|Cadres des opérations bancaires|Cadres des opérations bancaires +1|376c|Cadres commerciaux de la banque|Cadres commerciaux de la banque +1|376d|Chefs d'établissements et responsables de l'exploitation bancaire|Chefs d'établissements et responsables de l'explo +1|376e|Cadres des services techniques des assurances|Cadres des services techniques des assurances +1|376f|Cadres des services techniques des organismes de sécurité sociale et assimilés|Cadres des services techniques des organismes de s +1|376g|Cadres de l'immobilier|Cadres de l'immobilier +1|377a|Cadres de l'hôtellerie et de la restauration|Cadres de l'hôtellerie et de la restauration +1|380a|Directeurs techniques des grandes entreprises|Directeurs techniques des grandes entreprises +1|381b|Ingénieurs et cadres d'étude et développement de l'agriculture, la pêche, les eaux et forêts|Ingénieurs et cadres d'étude et développement d +1|381c|Ingénieurs et cadres de production et d'exploitation de l'agriculture, la pêche, les eaux et forêts|Ingénieurs et cadres de production et d'exploitat +1|382a|Ingénieurs et cadres d'étude du bâtiment et des travaux publics|Ingénieurs et cadres d'étude du bâtiment et des +1|382b|Architectes salariés|Architectes salariés +1|382c|Ingénieurs, cadres de chantier et conducteurs de travaux (cadres) du bâtiment et des travaux publics|Ingénieurs, cadres de chantier et conducteurs de +1|382d|Ingénieurs et cadres technico-commerciaux en bâtiment, travaux publics|Ingénieurs et cadres technico-commerciaux en bât +1|383a|Ingénieurs et cadres d'étude, recherche et développement en électricité, électronique|Ingénieurs et cadres d'étude, recherche et déve +1|383b|Ingénieurs et cadres de fabrication en matériel électrique, électronique|Ingénieurs et cadres de fabrication en matériel +1|383c|Ingénieurs et cadres technico-commerciaux en matériel électrique ou électronique professionnel|Ingénieurs et cadres technico-commerciaux en mat? +1|384a|Ingénieurs et cadres d'étude, recherche et développement en mécanique et travail des métaux|Ingénieurs et cadres d'étude, recherche et déve +1|384b|Ingénieurs et cadres de fabrication en mécanique et travail des métaux|Ingénieurs et cadres de fabrication en mécanique +1|384c|Ingénieurs et cadres technico-commerciaux en matériel mécanique professionnel|Ingénieurs et cadres technico-commerciaux en mat? +1|385a|Ingénieurs et cadres d'étude, recherche et développement des industries de transformation (agroalimentaire, chimie, métallurgie, matériaux lourds)|Ingénieurs et cadres d'étude, recherche et déve +1|385b|Ingénieurs et cadres de fabrication des industries de transformation (agroalimentaire, chimie, métallurgie, matériaux lourds)|Ingénieurs et cadres de fabrication des industrie +1|385c|Ingénieurs et cadres technico-commerciaux des industries de transformations (biens intermédiaires)|Ingénieurs et cadres technico-commerciaux des ind +1|386b|Ingénieurs et cadres d'étude, recherche et développement de la distribution d'énergie, eau|Ingénieurs et cadres d'étude, recherche et déve +1|386c|Ingénieurs et cadres d'étude, recherche et développement des autres industries (imprimerie, matériaux souples, ameublement et bois)|Ingénieurs et cadres d'étude, recherche et déve +1|386d|Ingénieurs et cadres de la production et de la distribution d'énergie, eau|Ingénieurs et cadres de la production et de la di +1|386e|Ingénieurs et cadres de fabrication des autres industries (imprimerie, matériaux souples, ameublement et bois)|Ingénieurs et cadres de fabrication des autres in +1|387a|Ingénieurs et cadres des achats et approvisionnements industriels|Ingénieurs et cadres des achats et approvisionnem +1|387b|Ingénieurs et cadres de la logistique, du planning et de l'ordonnancement|Ingénieurs et cadres de la logistique, du plannin +1|387c|Ingénieurs et cadres des méthodes de production|Ingénieurs et cadres des méthodes de production +1|387d|Ingénieurs et cadres du contrôle-qualité|Ingénieurs et cadres du contrôle-qualité +1|387e|Ingénieurs et cadres de la maintenance, de l'entretien et des travaux neufs|Ingénieurs et cadres de la maintenance, de l'entr +1|387f|Ingénieurs et cadres techniques de l'environnement|Ingénieurs et cadres techniques de l'environnemen +1|388a|Ingénieurs et cadres d'étude, recherche et développement en informatique|Ingénieurs et cadres d'étude, recherche et déve +1|388b|Ingénieurs et cadres d'administration, maintenance, support et services aux utilisateurs en informatique|Ingénieurs et cadres d'administration, maintenanc +1|388c|Chefs de projets informatiques, responsables informatiques|Chefs de projets informatiques, responsables infor +1|388d|Ingénieurs et cadres technico-commerciaux en informatique et télécommunications|Ingénieurs et cadres technico-commerciaux en info +1|388e|Ingénieurs et cadres spécialistes des télécommunications|Ingénieurs et cadres spécialistes des télécomm +1|389a|Ingénieurs et cadres techniques de l'exploitation des transports|Ingénieurs et cadres techniques de l'exploitation +1|389b|Officiers et cadres navigants techniques et commerciaux de l'aviation civile|Officiers et cadres navigants techniques et commer +1|389c|Officiers et cadres navigants techniques de la marine marchande|Officiers et cadres navigants techniques de la mar +1|421a|Instituteurs|Instituteurs +1|421b|Professeurs des écoles|Professeurs des écoles +1|422a|Professeurs d'enseignement général des collèges|Professeurs d'enseignement général des collèges +1|422b|Professeurs de lycée professionnel|Professeurs de lycée professionnel +1|422c|Maîtres auxiliaires et professeurs contractuels de l'enseignement secondaire|Maîtres auxiliaires et professeurs contractuels d +1|422d|Conseillers principaux d'éducation|Conseillers principaux d'éducation +1|422e|Surveillants et aides-éducateurs des établissements d'enseignement|Surveillants et aides-éducateurs des établisseme +1|423a|Moniteurs d'école de conduite|Moniteurs d'école de conduite +1|423b|Formateurs et animateurs de formation continue|Formateurs et animateurs de formation continue +1|424a|Moniteurs et éducateurs sportifs, sportifs professionnels|Moniteurs et éducateurs sportifs, sportifs profes +1|425a|Sous-bibliothécaires, cadres intermédiaires du patrimoine|Sous-bibliothécaires, cadres intermédiaires du p +1|431a|Cadres infirmiers et assimilés|Cadres infirmiers et assimilés +1|431b|Infirmiers psychiatriques|Infirmiers psychiatriques +1|431c|Puéricultrices|Puéricultrices +1|431d|Infirmiers spécialisés (autres qu'infirmiers psychiatriques et puéricultrices)|Infirmiers spécialisés (autres qu'infirmiers psy +1|431e|Sages-femmes salariées|Sages-femmes salariées +1|431f|Infirmiers en soins généraux, salariés|Infirmiers en soins généraux, salariés +1|432b|Masseurs-kinésithérapeutes rééducateurs, salariés|Masseurs-kinésithérapeutes rééducateurs, salar +1|432d|Autres spécialistes de la rééducation, salariés|Autres spécialistes de la rééducation, salarié +1|433a|Techniciens médicaux|Techniciens médicaux +1|433b|Opticiens lunetiers et audioprothésistes salariés|Opticiens lunetiers et audioprothésistes salarié +1|433c|Autres spécialistes de l'appareillage médical salariés|Autres spécialistes de l'appareillage médical sa +1|433d|Préparateurs en pharmacie|Préparateurs en pharmacie +1|434a|Cadres de l'intervention socio-éducative|Cadres de l'intervention socio-éducative +1|434b|Assistants de service social|Assistants de service social +1|434c|Conseillers en économie sociale familiale|Conseillers en économie sociale familiale +1|434d|Educateurs spécialisés|Educateurs spécialisés +1|434e|Moniteurs éducateurs|Moniteurs éducateurs +1|434f|Educateurs techniques spécialisés, moniteurs d'atelier|Educateurs techniques spécialisés, moniteurs d'a +1|434g|Educateurs de jeunes enfants|Educateurs de jeunes enfants +1|435a|Directeurs de centres socioculturels et de loisirs|Directeurs de centres socioculturels et de loisirs +1|435b|Animateurs socioculturels et de loisirs|Animateurs socioculturels et de loisirs +1|441a|Clergé séculier|Clergé séculier +1|441b|Clergé régulier|Clergé régulier +1|451a|Professions intermédiaires de la Poste|Professions intermédiaires de la Poste +1|451b|Professions intermédiaires administratives de France Télécom (statut public)|Professions intermédiaires administratives de Fra +1|451c|Contrôleurs des Impôts, du Trésor, des Douanes et assimilés*|Contrôleurs des Impôts, du Trésor, des Douanes +1|451d|Ingénieurs du contrôle de la navigation aérienne*|Ingénieurs du contrôle de la navigation aérienn +1|451e|Autres personnels administratifs de catégorie B de l'Etat (hors Enseignement, Patrimoine, Impôts, Trésor, Douanes)|Autres personnels administratifs de catégorie B d +1|451g|Professions intermédiaires administratives des collectivités locales|Professions intermédiaires administratives des co +1|451h|Professions intermédiaires administratives des hôpitaux|Professions intermédiaires administratives des h? +1|452a|Inspecteurs et officiers de police*|Inspecteurs et officiers de police* +1|452b|Adjudants-chefs, adjudants et sous-officiers de rang supérieur de l'Armée et de la Gendarmerie*|Adjudants-chefs, adjudants et sous-officiers de ra +1|461b|Secrétaires de direction, assistants de direction (non cadres)|Secrétaires de direction, assistants de direction +1|461c|Secrétaires de niveau supérieur (non cadres, hors secrétaires de direction)|Secrétaires de niveau supérieur (non cadres, hor +1|461d|Maîtrise et techniciens des services financiers ou comptables|Maîtrise et techniciens des services financiers o +1|461e|Maîtrise et techniciens administratifs des services juridiques ou du personnel|Maîtrise et techniciens administratifs des servic +1|461f|Maîtrise et techniciens administratifs des autres services administratifs|Maîtrise et techniciens administratifs des autres +1|462a|Chefs de petites surfaces de vente|Chefs de petites surfaces de vente +1|462b|Maîtrise de l'exploitation des magasins de vente|Maîtrise de l'exploitation des magasins de vente +1|462c|Acheteurs non classés cadres, aides-acheteurs|Acheteurs non classés cadres, aides-acheteurs +1|462d|Animateurs commerciaux des magasins de vente, marchandiseurs (non cadres)|Animateurs commerciaux des magasins de vente, marc +1|462e|Autres professions intermédiaires commerciales (sauf techniciens des forces de vente)|Autres professions intermédiaires commerciales (s +1|463a|Techniciens commerciaux et technico-commerciaux, représentants en informatique|Techniciens commerciaux et technico-commerciaux, r +1|463b|Techniciens commerciaux et technico-commerciaux, représentants en biens d'équipement, en biens intermédiaires, commerce interindustriel (hors informatique)|Techniciens commerciaux et technico-commerciaux, r +1|463c|Techniciens commerciaux et technico-commerciaux, représentants en biens de consommation auprès d'entreprises|Techniciens commerciaux et technico-commerciaux, r +1|463d|Techniciens commerciaux et technico-commerciaux, représentants en services auprès d'entreprises ou de professionnels (hors banque, assurance, informatique)|Techniciens commerciaux et technico-commerciaux, r +1|463e|Techniciens commerciaux et technico-commerciaux, représentants auprès de particuliers (hors banque, assurance, informatique)|Techniciens commerciaux et technico-commerciaux, r +1|464a|Assistants de la publicité, des relations publiques|Assistants de la publicité, des relations publiqu +1|464b|Interprètes, traducteurs|Interprètes, traducteurs +1|465a|Concepteurs et assistants techniques des arts graphiques, de la mode et de la décoration salariés|Concepteurs et assistants techniques des arts grap +1|465b|Assistants techniques de la réalisation des spectacles vivants et audiovisuels salariés|Assistants techniques de la réalisation des spect +1|465c|Photographes|Photographes +1|466a|Responsables commerciaux et administratifs des transports de voyageurs et du tourisme (non cadres)|Responsables commerciaux et administratifs des tra +1|466b|Responsables commerciaux et administratifs des transports de marchandises (non cadres)|Responsables commerciaux et administratifs des tra +1|466c|Responsables d'exploitation des transports de voyageurs et de marchandises (non cadres)|Responsables d'exploitation des transports de voya +1|467a|Chargés de clientèle bancaire|Chargés de clientèle bancaire +1|467b|Techniciens des opérations bancaires|Techniciens des opérations bancaires +1|467c|Professions intermédiaires techniques et commerciales des assurances|Professions intermédiaires techniques et commerci +1|467d|Professions intermédiaires techniques des organismes de sécurité sociale|Professions intermédiaires techniques des organis +1|468a|Maîtrise de restauration : salle et service|Maîtrise de restauration : salle et service +1|468b|Maîtrise de l'hébergement : hall et étages|Maîtrise de l'hébergement : hall et étages +1|471a|Techniciens d'étude et de conseil en agriculture, eaux et forêt|Techniciens d'étude et de conseil en agriculture, +1|471b|Techniciens d'exploitation et de contrôle de la production en agriculture, eaux et forêt|Techniciens d'exploitation et de contrôle de la p +1|472a|Dessinateurs en bâtiment, travaux publics|Dessinateurs en bâtiment, travaux publics +1|472b|Géomètres, topographes|Géomètres, topographes +1|472c|Métreurs et techniciens divers du bâtiment et des travaux publics|Métreurs et techniciens divers du bâtiment et de +1|472d|Techniciens des travaux publics de l'Etat et des collectivités locales|Techniciens des travaux publics de l'Etat et des c +1|473a|Dessinateurs en électricité, électromécanique et électronique|Dessinateurs en électricité, électromécanique +1|473b|Techniciens de recherche-développement et des méthodes de fabrication en électricité, électromécanique et électronique|Techniciens de recherche-développement et des mé +1|473c|Techniciens de fabrication et de contrôle-qualité en électricité, électromécanique et électronique|Techniciens de fabrication et de contrôle-qualit? +1|474a|Dessinateurs en construction mécanique et travail des métaux|Dessinateurs en construction mécanique et travail +1|474b|Techniciens de recherche-développement et des méthodes de fabrication en construction mécanique et travail des métaux|Techniciens de recherche-développement et des mé +1|474c|Techniciens de fabrication et de contrôle-qualité en construction mécanique et travail des métaux|Techniciens de fabrication et de contrôle-qualit? +1|475a|Techniciens de recherche-développement et des méthodes de production des industries de transformation|Techniciens de recherche-développement et des mé +1|475b|Techniciens de production et de contrôle-qualité des industries de transformation|Techniciens de production et de contrôle-qualité +1|476a|Assistants techniques, techniciens de l'imprimerie et de l'édition|Assistants techniques, techniciens de l'imprimerie +1|476b|Techniciens de l'industrie des matériaux souples, de l'ameublement et du bois|Techniciens de l'industrie des matériaux souples, +1|477a|Techniciens de la logistique, du planning et de l'ordonnancement|Techniciens de la logistique, du planning et de l' +1|477b|Techniciens d'installation et de maintenance des équipements industriels (électriques, électromécaniques, mécaniques, hors informatique)|Techniciens d'installation et de maintenance des ? +1|477c|Techniciens d'installation et de maintenance des équipements non industriels (hors informatique et télécommunications)|Techniciens d'installation et de maintenance des ? +1|477d|Techniciens de l'environnement et du traitement des pollutions|Techniciens de l'environnement et du traitement de +1|478a|Techniciens d'étude et de développement en informatique|Techniciens d'étude et de développement en infor +1|478b|Techniciens de production, d'exploitation en informatique|Techniciens de production, d'exploitation en infor +1|478c|Techniciens d'installation, de maintenance, support et services aux utilisateurs en informatique|Techniciens d'installation, de maintenance, suppor +1|478d|Techniciens des télécommunications et de l'informatique des réseaux|Techniciens des télécommunications et de l'infor +1|479a|Techniciens des laboratoires de recherche publique ou de l'enseignement|Techniciens des laboratoires de recherche publique +1|479b|Experts salariés de niveau technicien, techniciens divers|Experts salariés de niveau technicien, technicien +1|480a|Contremaîtres et agents d'encadrement (non cadres) en agriculture, sylviculture|Contremaîtres et agents d'encadrement (non cadres +1|480b|Maîtres d'équipage de la marine marchande et de la pêche|Maîtres d'équipage de la marine marchande et de +1|481a|Conducteurs de travaux (non cadres)|Conducteurs de travaux (non cadres) +1|481b|Chefs de chantier (non cadres)|Chefs de chantier (non cadres) +1|482a|Agents de maîtrise en fabrication de matériel électrique, électronique|Agents de maîtrise en fabrication de matériel é +1|483a|Agents de maîtrise en construction mécanique, travail des métaux|Agents de maîtrise en construction mécanique, tr +1|484a|Agents de maîtrise en fabrication : agroalimentaire, chimie, plasturgie, pharmacie.|Agents de maîtrise en fabrication : agroalimentai +1|484b|Agents de maîtrise en fabrication : métallurgie, matériaux lourds et autres industries de transformation|Agents de maîtrise en fabrication : métallurgie, +1|485a|Agents de maîtrise et techniciens en production et distribution d'énergie, eau, chauffage|Agents de maîtrise et techniciens en production e +1|485b|Agents de maîtrise en fabrication des autres industries (imprimerie, matériaux souples, ameublement et bois)|Agents de maîtrise en fabrication des autres indu +1|486b|Agents de maîtrise en maintenance, installation en électricité et électronique|Agents de maîtrise en maintenance, installation e +1|486c|Agents de maîtrise en maintenance, installation en électromécanique|Agents de maîtrise en maintenance, installation e +1|486d|Agents de maîtrise en maintenance, installation en mécanique|Agents de maîtrise en maintenance, installation e +1|486e|Agents de maîtrise en entretien général, installation, travaux neufs (hors mécanique, électromécanique, électronique)|Agents de maîtrise en entretien général, instal +1|487a|Responsables d'entrepôt, de magasinage|Responsables d'entrepôt, de magasinage +1|487b|Responsables du tri, de l'emballage, de l'expédition et autres responsables de la manutention|Responsables du tri, de l'emballage, de l'expédit +1|488a|Maîtrise de restauration : cuisine/production|Maîtrise de restauration : cuisine/production +1|488b|Maîtrise de restauration : gestion d'établissement|Maîtrise de restauration : gestion d'établissem +1|521a|Employés de la Poste|Employés de la Poste +1|521b|Employés de France Télécom (statut public)|Employés de France Télécom (statut public) +1|522a|Agents de constatation ou de recouvrement des Impôts, du Trésor, des Douanes*|Agents de constatation ou de recouvrement des Imp? +1|523a|Adjoints administratifs de la fonction publique (y c. enseignement)*|Adjoints administratifs de la fonction publique (y +1|523b|Adjoints administratifs de l'Etat et assimilés (sauf Poste, France Télécom)|Adjoints administratifs de l'Etat et assimilés (s +1|523c|Adjoints administratifs des collectivités locales|Adjoints administratifs des collectivités locales +1|523d|Adjoints administratifs des hôpitaux publics|Adjoints administratifs des hôpitaux publics +1|524a|Agents administratifs de la fonction publique (y c. enseignement)*|Agents administratifs de la fonction publique (y c +1|524b|Agents administratifs de l'Etat et assimilés (sauf Poste, France Télécom)|Agents administratifs de l'Etat et assimilés (sau +1|524c|Agents administratifs des collectivités locales|Agents administratifs des collectivités locales +1|524d|Agents administratifs des hôpitaux publics|Agents administratifs des hôpitaux publics +1|525a|Agents de service des établissements primaires|Agents de service des établissements primaires +1|525b|Agents de service des autres établissements d'enseignement|Agents de service des autres établissements d'ens +1|525c|Agents de service de la fonction publique (sauf écoles, hôpitaux)|Agents de service de la fonction publique (sauf é +1|525d|Agents de service hospitaliers|Agents de service hospitaliers +1|526a|Aides-soignants|Aides-soignants +1|526b|Assistants dentaires, médicaux et vétérinaires, aides de techniciens médicaux|Assistants dentaires, médicaux et vétérinaires, +1|526c|Auxiliaires de puériculture|Auxiliaires de puériculture +1|526d|Aides médico-psychologiques|Aides médico-psychologiques +1|526e|Ambulanciers salariés|Ambulanciers salariés +1|531a|Agents de police de l'Etat*|Agents de police de l'Etat* +1|531b|Agents des polices municipales*|Agents des polices municipales* +1|531c|Surveillants de l'administration pénitentiaire*|Surveillants de l'administration pénitentiaire* +1|532a|Gendarmes (de grade inférieur à adjudant)*|Gendarmes (de grade inférieur à adjudant)* +1|532b|Sergents et sous-officiers de grade équivalent des Armées (sauf pompiers militaires)*|Sergents et sous-officiers de grade équivalent de +1|532c|Hommes du rang (sauf pompiers militaires)*|Hommes du rang (sauf pompiers militaires)* +1|533a|Pompiers (y.c. pompiers militaires)|Pompiers (y.c. pompiers militaires) +1|533b|Agents techniques forestiers, gardes des espaces naturels|Agents techniques forestiers, gardes des espaces n +1|533c|Agents de surveillance du patrimoine et des administrations|Agents de surveillance du patrimoine et des admini +1|534a|Agents civils de sécurité et de surveillance|Agents civils de sécurité et de surveillance +1|534b|Convoyeurs de fonds, gardes du corps, enquêteurs privés et métiers assimilés (salariés)|Convoyeurs de fonds, gardes du corps, enquêteurs +1|541b|Agents d'accueil qualifiés, hôtesses d'accueil et d'information|Agents d'accueil qualifiés, hôtesses d'accueil e +1|541c|Agents d'accueil non qualifiés|Agents d'accueil non qualifiés +1|541d|Standardistes, téléphonistes|Standardistes, téléphonistes +1|542a|Secrétaires|Secrétaires +1|542b|Dactylos, sténodactylos (sans secrétariat), opérateurs de traitement de texte|Dactylos, sténodactylos (sans secrétariat), opé +1|543b|Employés qualifiés des services comptables ou financiers|Employés qualifiés des services comptables ou fi +1|543c|Employés non qualifiés des services comptables ou financiers|Employés non qualifiés des services comptables o +1|543e|Employés qualifiés des services du personnel et des services juridiques|Employés qualifiés des services du personnel et +1|543f|Employés qualifiés des services commerciaux des entreprises (hors vente)|Employés qualifiés des services commerciaux des +1|543g|Employés administratifs qualifiés des autres services des entreprises|Employés administratifs qualifiés des autres ser +1|543h|Employés administratifs non qualifiés|Employés administratifs non qualifiés +1|544a|Employés et opérateurs d'exploitation en informatique|Employés et opérateurs d'exploitation en informa +1|545a|Employés administratifs des services techniques de la banque|Employés administratifs des services techniques d +1|545b|Employés des services commerciaux de la banque|Employés des services commerciaux de la banque +1|545c|Employés des services techniques des assurances|Employés des services techniques des assurances +1|545d|Employés des services techniques des organismes de sécurité sociale et assimilés|Employés des services techniques des organismes d +1|546a|Contrôleurs des transports (personnels roulants)|Contrôleurs des transports (personnels roulants) +1|546b|Agents des services commerciaux des transports de voyageurs et du tourisme|Agents des services commerciaux des transports de +1|546c|Employés administratifs d'exploitation des transports de marchandises|Employés administratifs d'exploitation des transp +1|546d|Hôtesses de l'air et stewards|Hôtesses de l'air et stewards +1|546e|Autres agents et hôtesses d'accompagnement (transports, tourisme)|Autres agents et hôtesses d'accompagnement (trans +1|551a|Employés de libre service du commerce et magasiniers|Employés de libre service du commerce et magasini +1|552a|Caissiers de magasin|Caissiers de magasin +1|553b|Vendeurs polyvalents des grands magasins|Vendeurs polyvalents des grands magasins +1|553c| Autres vendeurs non spécialisés| Autres vendeurs non spécialisés +1|554a|Vendeurs en alimentation|Vendeurs en alimentation +1|554b|Vendeurs en ameublement, décor, équipement du foyer|Vendeurs en ameublement, décor, équipement du fo +1|554c|Vendeurs en droguerie, bazar, quincaillerie, bricolage|Vendeurs en droguerie, bazar, quincaillerie, brico +1|554d|Vendeurs du commerce de fleurs|Vendeurs du commerce de fleurs +1|554e|Vendeurs en habillement et articles de sport|Vendeurs en habillement et articles de sport +1|554f|Vendeurs en produits de beauté, de luxe (hors biens culturels) et optique|Vendeurs en produits de beauté, de luxe (hors bie +1|554g|Vendeurs de biens culturels (livres, disques, multimédia, objets d'art)|Vendeurs de biens culturels (livres, disques, mult +1|554h|Vendeurs de tabac, presse et articles divers|Vendeurs de tabac, presse et articles divers +1|554j|Pompistes et gérants de station-service (salariés ou mandataires)|Pompistes et gérants de station-service (salarié +1|555a|Vendeurs par correspondance, télévendeurs|Vendeurs par correspondance, télévendeurs +1|556a|Vendeurs en gros de biens d'équipement, biens intermédiaires|Vendeurs en gros de biens d'équipement, biens int +1|561b|Serveurs, commis de restaurant, garçons qualifiés|Serveurs, commis de restaurant, garçons qualifié +1|561c|Serveurs, commis de restaurant, garçons non qualifiés|Serveurs, commis de restaurant, garçons non quali +1|561d|Aides de cuisine, apprentis de cuisine et employés polyvalents de la restauration|Aides de cuisine, apprentis de cuisine et employé +1|561e|Employés de l'hôtellerie : réception et hall|Employés de l'hôtellerie : réception et hall +1|561f|Employés d'étage et employés polyvalents de l'hôtellerie|Employés d'étage et employés polyvalents de l'h +1|562a|Manucures, esthéticiens |Manucures, esthéticiens +1|562b|Coiffeurs salariés|Coiffeurs salariés +1|563a|Assistantes maternelles, gardiennes d'enfants, familles d'accueil|Assistantes maternelles, gardiennes d'enfants, fam +1|563b|Aides à domicile, aides ménagères, travailleuses familiales|Aides à domicile, aides ménagères, travailleuse +1|563c|Employés de maison et personnels de ménage chez des particuliers|Employés de maison et personnels de ménage chez +1|564a|Concierges, gardiens d'immeubles|Concierges, gardiens d'immeubles +1|564b|Employés des services divers|Employés des services divers +1|621a|Chefs d'équipe du gros oeuvre et des travaux publics|Chefs d'équipe du gros oeuvre et des travaux publ +1|621b|Ouvriers qualifiés du travail du béton|Ouvriers qualifiés du travail du béton +1|621c|Conducteurs qualifiés d'engins de chantiers du bâtiment et des travaux publics|Conducteurs qualifiés d'engins de chantiers du b? +1|621d|Ouvriers des travaux publics en installations électriques et de télécommunications|Ouvriers des travaux publics en installations éle +1|621e|Autres ouvriers qualifiés des travaux publics|Autres ouvriers qualifiés des travaux publics +1|621f|Ouvriers qualifiés des travaux publics (salariés de l'Etat et des collectivités locales)|Ouvriers qualifiés des travaux publics (salariés +1|621g|Mineurs de fond qualifiés et autres ouvriers qualifiés des industries d'extraction (carrières, pétrole, gaz...)|Mineurs de fond qualifiés et autres ouvriers qual +1|622a|Opérateurs qualifiés sur machines automatiques en production électrique ou électronique|Opérateurs qualifiés sur machines automatiques e +1|622c|Monteurs câbleurs qualifiés en électricité|Monteurs câbleurs qualifiés en électricité +1|622d|Câbleurs qualifiés en électronique (prototype, unité, petite série)|Câbleurs qualifiés en électronique (prototype, +1|622e|Autres monteurs câbleurs en électronique|Autres monteurs câbleurs en électronique +1|622f|Bobiniers qualifiés|Bobiniers qualifiés +1|622g|Plateformistes, contrôleurs qualifiés de matériel électrique ou électronique|Plateformistes, contrôleurs qualifiés de matéri +1|623a|Chaudronniers-tôliers industriels, opérateurs qualifiés du travail en forge, conducteurs qualifiés d'équipement de formage, traceurs qualifiés|Chaudronniers-tôliers industriels, opérateurs qu +1|623b|Tuyauteurs industriels qualifiés|Tuyauteurs industriels qualifiés +1|623d|Opérateurs qualifiés sur machine de soudage|Opérateurs qualifiés sur machine de soudage +1|623e|Soudeurs manuels|Soudeurs manuels +1|623f|Opérateurs qualifiés d'usinage des métaux travaillant à l'unité ou en petite série, moulistes qualifiés|Opérateurs qualifiés d'usinage des métaux trava +1|623g|Opérateurs qualifiés d'usinage des métaux sur autres machines (sauf moulistes)|Opérateurs qualifiés d'usinage des métaux sur a +1|624b|Monteurs, metteurs au point très qualifiés d'ensembles mécaniques travaillant à l'unité ou en petite série|Monteurs, metteurs au point très qualifiés d'ens +1|624c|Monteurs qualifiés d'ensembles mécaniques travaillant en moyenne ou en grande série|Monteurs qualifiés d'ensembles mécaniques travai +1|624d|Monteurs qualifiés en structures métalliques|Monteurs qualifiés en structures métalliques +1|624e|Ouvriers qualifiés de contrôle et d'essais en mécanique|Ouvriers qualifiés de contrôle et d'essais en m? +1|624f|Ouvriers qualifiés des traitements thermiques et de surface sur métaux|Ouvriers qualifiés des traitements thermiques et +1|624g|Autres mécaniciens ou ajusteurs qualifiés (ou spécialité non reconnue)|Autres mécaniciens ou ajusteurs qualifiés (ou sp +1|625a|Pilotes d'installation lourde des industries de transformation : agroalimentaire, chimie, plasturgie, énergie|Pilotes d'installation lourde des industries de tr +1|625b|Ouvriers qualifiés et agents qualifiés de laboratoire : agroalimentaire, chimie, biologie, pharmacie|Ouvriers qualifiés et agents qualifiés de labora +1|625c|Autres opérateurs et ouvriers qualifiés de la chimie (y.c. pharmacie) et de la plasturgie|Autres opérateurs et ouvriers qualifiés de la ch +1|625d|Opérateurs de la transformation des viandes|Opérateurs de la transformation des viandes +1|625f|Autres opérateurs travaillant sur installations ou machines : industrie agroalimentaire (hors transformation des viandes)|Autres opérateurs travaillant sur installations o +1|625g|Autres ouvriers de production qualifiés ne travaillant pas sur machine : industrie agroalimentaire (hors transformation des viandes)|Autres ouvriers de production qualifiés ne travai +1|625h|Ouvriers qualifiés des autres industries (eau, gaz, énergie, chauffage)|Ouvriers qualifiés des autres industries (eau, ga +1|626a|Pilotes d'installation lourde des industries de transformation : métallurgie, production verrière, matériaux de construction|Pilotes d'installation lourde des industries de tr +1|626b|Autres opérateurs et ouvriers qualifiés : métallurgie, production verrière, matériaux de construction|Autres opérateurs et ouvriers qualifiés : métal +1|626c|Opérateurs et ouvriers qualifiés des industries lourdes du bois et de la fabrication du papier-carton|Opérateurs et ouvriers qualifiés des industries +1|627a|Opérateurs qualifiés du textile et de la mégisserie|Opérateurs qualifiés du textile et de la mégiss +1|627b|Ouvriers qualifiés de la coupe des vêtements et de l'habillement, autres opérateurs de confection qualifiés|Ouvriers qualifiés de la coupe des vêtements et +1|627c|Ouvriers qualifiés du travail industriel du cuir|Ouvriers qualifiés du travail industriel du cuir +1|627d|Ouvriers qualifiés de scierie, de la menuiserie industrielle et de l'ameublement|Ouvriers qualifiés de scierie, de la menuiserie i +1|627e|Ouvriers de la photogravure et des laboratoires photographiques et cinématographiques|Ouvriers de la photogravure et des laboratoires ph +1|627f|Ouvriers de la composition et de l'impression, ouvriers qualifiés de la brochure, de la reliure et du façonnage du papier-carton|Ouvriers de la composition et de l'impression, ouv +1|628a|Mécaniciens qualifiés de maintenance, entretien : équipements industriels|Mécaniciens qualifiés de maintenance, entretien +1|628b|Electromécaniciens, électriciens qualifiés d'entretien : équipements industriels|Electromécaniciens, électriciens qualifiés d'en +1|628c|Régleurs qualifiés d'équipements de fabrication (travail des métaux, mécanique)|Régleurs qualifiés d'équipements de fabrication +1|628d|Régleurs qualifiés d'équipements de fabrication (hors travail des métaux et mécanique)|Régleurs qualifiés d'équipements de fabrication +1|628e|Ouvriers qualifiés de l'assainissement et du traitement des déchets|Ouvriers qualifiés de l'assainissement et du trai +1|628f|Agents qualifiés de laboratoire (sauf chimie, santé)|Agents qualifiés de laboratoire (sauf chimie, san +1|628g|Ouvriers qualifiés divers de type industriel|Ouvriers qualifiés divers de type industriel +1|631a|Jardiniers|Jardiniers +1|632a|Maçons qualifiés|Maçons qualifiés +1|632b|Ouvriers qualifiés du travail de la pierre|Ouvriers qualifiés du travail de la pierre +1|632c|Charpentiers en bois qualifiés|Charpentiers en bois qualifiés +1|632d|Menuisiers qualifiés du bâtiment|Menuisiers qualifiés du bâtiment +1|632e|Couvreurs qualifiés|Couvreurs qualifiés +1|632f|Plombiers et chauffagistes qualifiés|Plombiers et chauffagistes qualifiés +1|632g|Peintres et ouvriers qualifiés de pose de revêtements sur supports verticaux|Peintres et ouvriers qualifiés de pose de revête +1|632h|Soliers moquetteurs et ouvriers qualifiés de pose de revêtements souples sur supports horizontaux|Soliers moquetteurs et ouvriers qualifiés de pose +1|632j|Monteurs qualifiés en agencement, isolation|Monteurs qualifiés en agencement, isolation +1|632k|Ouvriers qualifiés d'entretien général des bâtiments|Ouvriers qualifiés d'entretien général des bât +1|633a|Electriciens qualifiés de type artisanal (y.c. bâtiment)|Electriciens qualifiés de type artisanal (y.c. b? +1|633b|Dépanneurs qualifiés en radiotélévision, électroménager, matériel électronique (salariés)|Dépanneurs qualifiés en radiotélévision, élec +1|633c|Electriciens, électroniciens qualifiés en maintenance entretien, réparation : automobile|Electriciens, électroniciens qualifiés en mainte +1|633d|Electriciens, électroniciens qualifiés en maintenance, entretien : équipements non industriels|Electriciens, électroniciens qualifiés en mainte +1|634a|Carrossiers d'automobiles qualifiés|Carrossiers d'automobiles qualifiés +1|634b|Métalliers, serruriers qualifiés|Métalliers, serruriers qualifiés +1|634c|Mécaniciens qualifiés en maintenance, entretien, réparation : automobile|Mécaniciens qualifiés en maintenance, entretien, +1|634d|Mécaniciens qualifiés de maintenance, entretien : équipements non industriels|Mécaniciens qualifiés de maintenance, entretien +1|635a|Tailleurs et couturières qualifiés, ouvriers qualifiés du travail des étoffes (sauf fabrication de vêtements), ouvriers qualifiés de type artisanal du travail du cuir|Tailleurs et couturières qualifiés, ouvriers qua +1|636a|Bouchers (sauf industrie de la viande)|Bouchers (sauf industrie de la viande) +1|636b|Charcutiers (sauf industrie de la viande)|Charcutiers (sauf industrie de la viande) +1|636c|Boulangers, pâtissiers (sauf activité industrielle)|Boulangers, pâtissiers (sauf activité industriel +1|636d|Cuisiniers et commis de cuisine|Cuisiniers et commis de cuisine +1|637a|Modeleurs (sauf modeleurs de métal), mouleurs-noyauteurs à la main, ouvriers qualifiés du travail du verre ou de la céramique à la main|Modeleurs (sauf modeleurs de métal), mouleurs-noy +1|637b|Ouvriers d'art|Ouvriers d'art +1|637c|Ouvriers et techniciens des spectacles vivants et audiovisuels|Ouvriers et techniciens des spectacles vivants et +1|637d|Ouvriers qualifiés divers de type artisanal|Ouvriers qualifiés divers de type artisanal +1|641a|Conducteurs routiers et grands routiers|Conducteurs routiers et grands routiers +1|641b|Conducteurs de véhicule routier de transport en commun|Conducteurs de véhicule routier de transport en c +1|642a|Conducteurs de taxi|Conducteurs de taxi +1|642b|Conducteurs de voiture particulière|Conducteurs de voiture particulière +1|643a|Conducteurs livreurs, coursiers|Conducteurs livreurs, coursiers +1|644a|Conducteurs de véhicule de ramassage des ordures ménagères|Conducteurs de véhicule de ramassage des ordures +1|651a|Conducteurs d'engin lourd de levage|Conducteurs d'engin lourd de levage +1|651b|Conducteurs d'engin lourd de manoeuvre|Conducteurs d'engin lourd de manoeuvre +1|652a|Ouvriers qualifiés de la manutention, conducteurs de chariots élévateurs, caristes|Ouvriers qualifiés de la manutention, conducteurs +1|652b|Dockers|Dockers +1|653a|Magasiniers qualifiés|Magasiniers qualifiés +1|654b|Conducteurs qualifiés d'engins de transport guidés (sauf remontées mécaniques)|Conducteurs qualifiés d'engins de transport guid? +1|654c|Conducteurs qualifiés de systèmes de remontées mécaniques|Conducteurs qualifiés de systèmes de remontées +1|655a|Autres agents et ouvriers qualifiés (sédentaires) des services d'exploitation des transports|Autres agents et ouvriers qualifiés (sédentaires +1|656b|Matelots de la marine marchande|Matelots de la marine marchande +1|656c|Capitaines et matelots timoniers de la navigation fluviale|Capitaines et matelots timoniers de la navigation +1|671a|Ouvriers non qualifiés des travaux publics de l'Etat et des collectivités locales|Ouvriers non qualifiés des travaux publics de l'E +1|671c|Ouvriers non qualifiés des travaux publics et du travail du béton|Ouvriers non qualifiés des travaux publics et du +1|671d|Aides-mineurs, ouvriers non qualifiés de l'extraction|Aides-mineurs, ouvriers non qualifiés de l'extrac +1|672a|Ouvriers non qualifiés de l'électricité et de l'électronique|Ouvriers non qualifiés de l'électricité et de l +1|673a|Ouvriers de production non qualifiés travaillant par enlèvement de métal|Ouvriers de production non qualifiés travaillant +1|673b|Ouvriers de production non qualifiés travaillant par formage de métal|Ouvriers de production non qualifiés travaillant +1|673c|Ouvriers non qualifiés de montage, contrôle en mécanique et travail des métaux|Ouvriers non qualifiés de montage, contrôle en m +1|674a|Ouvriers de production non qualifiés : chimie, pharmacie, plasturgie|Ouvriers de production non qualifiés : chimie, ph +1|674b|Ouvriers de production non qualifiés de la transformation des viandes|Ouvriers de production non qualifiés de la transf +1|674c|Autres ouvriers de production non qualifiés : industrie agroalimentaire|Autres ouvriers de production non qualifiés : ind +1|674d|Ouvriers de production non qualifiés : métallurgie, production verrière, céramique, matériaux de construction|Ouvriers de production non qualifiés : métallurg +1|674e|Ouvriers de production non qualifiés : industrie lourde du bois, fabrication des papiers et cartons|Ouvriers de production non qualifiés : industrie +1|675a|Ouvriers de production non qualifiés du textile et de la confection, de la tannerie-mégisserie et du travail du cuir|Ouvriers de production non qualifiés du textile e +1|675b|Ouvriers de production non qualifiés du travail du bois et de l'ameublement|Ouvriers de production non qualifiés du travail d +1|675c|Ouvriers de production non qualifiés de l'imprimerie, presse, édition|Ouvriers de production non qualifiés de l'imprime +1|676a|Manutentionnaires non qualifiés|Manutentionnaires non qualifiés +1|676b|Déménageurs (hors chauffeurs-déménageurs), non qualifiés|Déménageurs (hors chauffeurs-déménageurs), non +1|676c|Ouvriers du tri, de l'emballage, de l'expédition, non qualifiés|Ouvriers du tri, de l'emballage, de l'expédition, +1|676d|Agents non qualifiés des services d'exploitation des transports|Agents non qualifiés des services d'exploitation +1|676e|Ouvriers non qualifiés divers de type industriel|Ouvriers non qualifiés divers de type industriel +1|681a|Ouvriers non qualifiés du gros oeuvre du bâtiment|Ouvriers non qualifiés du gros oeuvre du bâtimen +1|681b|Ouvriers non qualifiés du second oeuvre du bâtiment|Ouvriers non qualifiés du second oeuvre du bâtim +1|682a|Métalliers, serruriers, réparateurs en mécanique non qualifiés|Métalliers, serruriers, réparateurs en mécaniqu +1|683a|Apprentis boulangers, bouchers, charcutiers|Apprentis boulangers, bouchers, charcutiers +1|684a|Nettoyeurs|Nettoyeurs +1|684b|Ouvriers non qualifiés de l'assainissement et du traitement des déchets|Ouvriers non qualifiés de l'assainissement et du +1|685a|Ouvriers non qualifiés divers de type artisanal|Ouvriers non qualifiés divers de type artisanal +1|691a|Conducteurs d'engin agricole ou forestier|Conducteurs d'engin agricole ou forestier +1|691b|Ouvriers de l'élevage|Ouvriers de l'élevage +1|691c|Ouvriers du maraîchage ou de l'horticulture|Ouvriers du maraîchage ou de l'horticulture +1|691d|Ouvriers de la viticulture ou de l'arboriculture fruitière|Ouvriers de la viticulture ou de l'arboriculture f +1|691e|Ouvriers agricoles sans spécialisation particulière|Ouvriers agricoles sans spécialisation particuli? +1|691f|Ouvriers de l'exploitation forestière ou de la sylviculture|Ouvriers de l'exploitation forestière ou de la sy +1|692a|Marins-pêcheurs et ouvriers de l'aquaculture|Marins-pêcheurs et ouvriers de l'aquaculture diff --git a/db/data2/dbdata_rh_t_chart.csv b/db/data2/dbdata_rh_t_chart.csv new file mode 100644 index 0000000..9799bbb --- /dev/null +++ b/db/data2/dbdata_rh_t_chart.csv @@ -0,0 +1,15 @@ +type|category|name|default_time_calc|label_view_code|code|serie_code +card|date|Carte effectifs|val|0|CTI_STATCAR|{CTI_FEMMES,CTI_HOMMES} +donut|CTI_TYPECONTRAT#LS#CTI_TCNT|Types de contrats|val|0|CTI_TYPECNT|{CTI_FEMMES,CTI_HOMMES} +spread|CTI_AGE#LS#CTI_AGE|Effectifs par tranches age|val|0|CTI_EFFAGE|{CTI_FEMMES,CTI_HOMMES} +spread|CTI_AGE#LS#CTI_AGE|Masse salariale par tranche d'age|val|0|CTI_MSAGE|{CTI_MSF,CTI_MSH} +spread|CTI_ANCIENNETE#LS#CTI_ANC|Effectifs par tranches anciente|val|0|CTI_EFFANC|{CTI_FEMMES,CTI_HOMMES} +spread|CTI_STATUT#LS#CTI_STATUT|Effectifs par statut|val|0|CTI_EFFSTAT|{CTI_FEMMES,CTI_HOMMES} +stacked|CTI_CSP#DT#|Masse salariale par CSP|val|1|CTI_MSCSP|{CTI_MSF,CTI_MSH} +stacked|date|Effectifs par genre|val|0|CTI_EFFGEN|{CTI_FEMMES,CTI_HOMMES} +stacked|date|Heures supplementaires|val|0|CTI_HSUPP|{CTI_HSUPF,CTI_HSUPH} +stackedPercent|date|Repartition par genre|val|0|CTI_REPGEN|{CTI_FEMMES,CTI_HOMMES} +table|date|Entrees sorties carte|val|0|CTI_ENTSORCAR|{CTI_DEPSALF,CTI_DEPSALH,CTI_EFFDF,CTI_EFFDH,CTI_ENTSORF,CTI_ENTSORH,CTI_NVSALF,CTI_NVSALH,CTI_TOF,CTI_TOH} +table2d|CTI_STATUT#LS#CTI_STATUT|Tableau statuts|val|0|CTI_STAT|{CTI_FEMMES,CTI_HOMMES,CTI_TOTSAL} +table2dTime|CTI_STATUT#LS#CTI_STATUT|Statuts temps|cum|0|CTI_STATTIME|{CTI_TAUXSTAT,CTI_TOTSAL,CTI_TOTSALF} +treemap|CTI_CSP#DT#|Masse salariale par CSP (MAP)|val|1|CTI_MSCSPMAP|{CTI_MS} diff --git a/db/data2/dbdata_rh_t_classes.csv b/db/data2/dbdata_rh_t_classes.csv new file mode 100644 index 0000000..f094cbc --- /dev/null +++ b/db/data2/dbdata_rh_t_classes.csv @@ -0,0 +1,18 @@ +table_code|classe_code|texte|is_cti|contenu_by_code|contenu_non_replicable_ailleurs +AGE|CTI_AGE|Tranche d'ages Bilan Social|1|0|0 +ANC|CTI_ANC|Tranche d'ancienneté Bilan Social|1|0|0 +MOA|CTI_ARRET|Arrêt de travail Bilan Social|1|0|0 +MTF|CTI_MFIN|Motif de fin Bilan Social|1|0|0 +NAT|CTI_NAT|Nationalité Bilan Social|1|0|0 +PSE|CTI_CONTRIBUTION_BLOC_OPERATOIRE|Services du bloc opératoire pour le calcul de la contribution|1|0|0 +QUA|CTI_QUAL|Qualifications personnels|1|0|0 +QUA|CTI_SAE_CATEGORIES_PERSONNEL|Catégories de personnel SAE|1|1|0 +QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL|Spécialités détaillées du personnel SAE|1|0|0 +QUA|CTI_SAE_SPECIALITES_PERSONNEL|Spécialités du personnel SAE|1|1|0 +QUA|CTI_SAE_TYPES_PERSONNEL|Types du personnel SAE|1|1|0 +RUP|ALM_HRS|ALM Détail des heures contrat, sup, abs, maintien|1|0|0 +RUP|CTI_RUB|Rubrique Bilan Social|1|0|0 +SER|CTI_SAE_GROUPES_DISCIPLINES|Groupes de disciplines SAE|1|0|0 +STA|CTI_STATUT|Statuts CTI|1|0|0 +TCN|CTI_TCNT|Type de contrat Bilan Social|1|0|0 +TTT|CTI_TTT|Type de temps de travail Bilan Social|1|0|0 diff --git a/db/data2/dbdata_rh_t_classes_sections.csv b/db/data2/dbdata_rh_t_classes_sections.csv new file mode 100644 index 0000000..8312a06 --- /dev/null +++ b/db/data2/dbdata_rh_t_classes_sections.csv @@ -0,0 +1,195 @@ +code|texte|condition|exclude_code|include_code|table_code|classe_code +S1|- 25 ans||||AGE|CTI_AGE +S2|De 25 à 35 ans||||AGE|CTI_AGE +S3|De 36 à 45 ans||||AGE|CTI_AGE +S4|De 46 à 55 ans||||AGE|CTI_AGE +S5|De 56 à 65 ans||||AGE|CTI_AGE +S6|+ de 65 ans||||AGE|CTI_AGE +S1|- 10 ans||||ANC|CTI_ANC +S2|De 10 à 20 ans||||ANC|CTI_ANC +S3|De 21 à 30 ans||||ANC|CTI_ANC +S4|+ de 30 ans||||ANC|CTI_ANC +ABS|Absence (hors divers congés, conflits et service national)||||MOA|CTI_ARRET +ACT|Accident du travail, de trajet ou maladie professionnelle||||MOA|CTI_ARRET +AUT|Autre||||MOA|CTI_ARRET +COA|Congé autorisé (événements familiaux, congés spéciaux pour les femmes...)||||MOA|CTI_ARRET +MAL|Maladie||||MOA|CTI_ARRET +MAT|Maternité||||MOA|CTI_ARRET +AUT|Autre||||MTF|CTI_MFIN +DEC|Décés||||MTF|CTI_MFIN +DEM|Démission||||MTF|CTI_MFIN +DPE|Départ en cours de période d'essai||||MTF|CTI_MFIN +FCD|Fin de CDD||||MTF|CTI_MFIN +LAC|Licenciement pour autres causes||||MTF|CTI_MFIN +LRP|Licenciement économique, dont départ en retraite et préretraite||||MTF|CTI_MFIN +MUT|Mutation inter entreprise||||MTF|CTI_MFIN +RPR|Départ volontaire en retraite et préretraite||||MTF|CTI_MFIN +ET|Etrangère||||NAT|CTI_NAT +FR|Française||||NAT|CTI_NAT +UE|Union Européenne||||NAT|CTI_NAT +S1|Bloc opératoire||||PSE|CTI_CONTRIBUTION_BLOC_OPERATOIRE +PA|Personnel administratif et autre||||QUA|CTI_QUAL +PM|Personnel médical||||QUA|CTI_QUAL +PS|Personnel soignant||||QUA|CTI_QUAL +M9000|Personnels médicaux|||[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:M*]|QUA|CTI_SAE_CATEGORIES_PERSONNEL +N1000|Personnels de direction|||[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N1*]|QUA|CTI_SAE_CATEGORIES_PERSONNEL +N2000|Personnels des services de soins|||[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N2*]|QUA|CTI_SAE_CATEGORIES_PERSONNEL +N3000|Personnels éducatifs et sociaux|||[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N3*]|QUA|CTI_SAE_CATEGORIES_PERSONNEL +N4000|Personnels médico-techniques|||[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N4*]|QUA|CTI_SAE_CATEGORIES_PERSONNEL +N5000|Personnels techniques et ouvriers|||[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:N5*]|QUA|CTI_SAE_CATEGORIES_PERSONNEL +X9000|Hors champ SAE|||[CLASSE:CTI_SAE_SPECIALITES_PERSONNEL:X*]|QUA|CTI_SAE_CATEGORIES_PERSONNEL +M1010|Médecine générale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1020|Anatomie et cytologie pathologiques||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1030|Anesthésie-réanimation||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1031|Réanimation médicale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1040|Cardiologie et maladies cardiovasculaires||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1050|Dermatologie - Vénérologie - Allergologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1070|Endocrinologie et maladies métaboliques||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1090|Gastro entérologie et hépatologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1100|Médecine interne etimmunologie clinique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1110|Néphrologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1120|Neurologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1130|Oncologie médicale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1140|Pédiatrie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1150|Pneumologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1160|Radiologie et imagerie médicale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1170|Oncologie radiothérapique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1180|Médecine physique et de réadaptation||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1190|Rhumatologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1200|Autres spécialités médicales||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1210|Médecine nucléaire||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1310|Génétique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1320|Gériatrie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1330|Hématologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1340|Médecine d'urgence||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2010|Chirurgie générale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2020|Chirurgie maxillo-faciale - Stomatologie et chirurgie orale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2030|Chirurgie orthopédique et traumatologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2040|Chirurgie plastique reconstructrice et esthétique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2050|Gynécologie - Obstétrique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2060|Neuro-chirurgie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2070|Ophtalmologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2080|Oto-rhino-laryngologie et cervico-faciale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2100|Chirurgie Urologique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2110|Autres spécialités chirurgicale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2120|Chirurgie viscérale et digestive||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2130|Chirurgie vasculaire||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2140|Chirurgie thoracique et cardiaque||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M2150|Chirurgie infantile||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3011|Médecins spécialisés en biologie médicale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3012|Pharmaciens spécialisés en biologie médicale||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3020|Psychiatrie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3030|Odontologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3040|Santé publique (y compris DIM)||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3050|Pharmacien (hors biologie médicale)||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3060|Médecins du travail||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M3070|Autres||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N1110|Personnel de direction||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N1210|Secrétaires médicaux et assistants médico-administratif||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N1220|Autres personnels administratifs||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N1310|Directeurs des soins (écoles paramédicales et soins non infirmiers)||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N1410|Directeur de soins infirmiers||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2120|Surveillants et autres personnels d'encadrement infirmiers||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2130|Surveillants des personnels de rééducation et autres personnels d'encadrement non infirmier||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2210|Infirmiers DE sans spécialisation (hors secteur psy)||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2220|Infirmiers DE en secteur psychiatrique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2310|Infirmiers DE anesthésistes||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2320|Infirmiers DE bloc opératoire||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2340|Puericultrices DE||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2350|Infirmiers en pratique avancée (IPA)||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2410|Masseurs kinésithérapeuthes||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2420|Pédicures - Podologues||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2430|Orthophonistes||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2440|Orthoptistes||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2450|Diététiciens||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2460|Ergothérapeuthes||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2470|Psychomotricien||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2480|Autres emplois des services de rééducation||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2510|Aides soignants||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2520|Aides médico-psychologique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2530|Auxilliaires de puériculture||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2610|Agents de service hospitalier||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2620|Autres personnels de service des services de soins||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2630|Fammilles d'accueil||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2710|Psychologues||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N2810|Sages-femmes y compris encadrement et écoles||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N3110|Personnels éducatifs||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N3111|Educateurs spécialisés||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N3120|Assistants de service social||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N3121|Cadres socio-éducatifs||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N3130|Autres personnels éducatifs et sociaux||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4110|Personnels des services de laboratoire||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N411B|Techniciens de laboratoire||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N411C|Autres personnels des services de laboratoire||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4120|Préparateurs en pharmacie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N412A|Autres personnels des services de pharmacie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4130|Manipulateurs d'électroradiologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4140|Autres personnels des services de radiologie||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4150|Autres personnels médico-technique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4160|Surveillants, cadres et autres personnels d'encadrement médico-technique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4170|Dosimétristes||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4180|Radiophysiciens - Physiciens médicaux||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N4190|Conseillers en génétique||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N5110|Ingénieurs||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N511A|Personnels des services techniques hors ingénieurs||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N5120|Personnel informatique et organisation hors ingénieur||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +N5130|Personnels des services techniques et des services intérieurs||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +X9190|Hors champ SAE Autres||||QUA|CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL +M1000|Spécialités médicales|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:M1*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +M2000|Spécialités chirurgicales|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:M2*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +M3000|Autres disciplines médicales|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:M3*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N1100|Personnels de direction|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N11*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N1200|Autres personnels administratifs|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N12*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N1300|Directeur de soins|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N13*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N1400|Directeur de soins infirmiers|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N14*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2100|Personnels d'encadrement du personnel des services de soins|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N21*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2200|Infirmiers DE sans spécialisation|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N22*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2300|Infirmiers DE avec spécialisation|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N23*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2400|Personnels de rééducation|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N24*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2500|Aides-soignants|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N25*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2600|Agents de services hospitaliers|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N26*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2700|Psychologues|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N27*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N2800|Sages-femmes y compris encadrement et écoles|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N28*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N3100|Personnels éducatifs et sociaux|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N31*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N4100|Personnels médico-techniques|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N41*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +N5100|Personnels techniques et ouvriers|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:N51*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +X9100|Hors champs SAE|||[CLASSE:CTI_SAE_SPECIALITES_DETAILLEES_PERSONNEL:X*]|QUA|CTI_SAE_SPECIALITES_PERSONNEL +M9999|Personnels médicaux|||[CLASSE:CTI_SAE_CATEGORIES_PERSONNEL:M*]|QUA|CTI_SAE_TYPES_PERSONNEL +N9999|Personnels non médicaux|||[CLASSE:CTI_SAE_CATEGORIES_PERSONNEL:N*]|QUA|CTI_SAE_TYPES_PERSONNEL +X9999|Hors champ SAE|||[CLASSE:CTI_SAE_CATEGORIES_PERSONNEL:X*]|QUA|CTI_SAE_TYPES_PERSONNEL +01|Absence maladie||||RUP|ALM_HRS +02|Absence maternité||||RUP|ALM_HRS +03|Absence CP||||RUP|ALM_HRS +04|Autres absences||||RUP|ALM_HRS +05|Heures contractuelles||||RUP|ALM_HRS +06|Heures sup. et comp.||||RUP|ALM_HRS +07|Absence AT et MP||||RUP|ALM_HRS +08|Absences congés parental||||RUP|ALM_HRS +09|Maintien Absence maladie||||RUP|ALM_HRS +10|Maintien Absence maternité||||RUP|ALM_HRS +11|Maintien Absence CP||||RUP|ALM_HRS +12|Maintien Autres absences||||RUP|ALM_HRS +13|Maintien AT et MP||||RUP|ALM_HRS +14|Maintien Absence congés parental||||RUP|ALM_HRS +15|Heures payées||||RUP|ALM_HRS +16|Absences payées non travaillées SAGE||||RUP|ALM_HRS +BRU|Brut||||RUP|CTI_RUB +CDE|Cotisations déductibles||||RUP|CTI_RUB +CND|Cotisations non déductibles||||RUP|CTI_RUB +EXO|Exonérations||||RUP|CTI_RUB +GAI|Gains non imposables||||RUP|CTI_RUB +NAT|Avantages en nature||||RUP|CTI_RUB +RET|Retenues non imposables||||RUP|CTI_RUB +1|MCO||||SER|CTI_SAE_GROUPES_DISCIPLINES +2|PSY||||SER|CTI_SAE_GROUPES_DISCIPLINES +3|HAD||||SER|CTI_SAE_GROUPES_DISCIPLINES +4|SSR||||SER|CTI_SAE_GROUPES_DISCIPLINES +S1|Ouvrier||||STA|CTI_STATUT +S2|Employé||||STA|CTI_STATUT +S3|Technicien||||STA|CTI_STATUT +S4|Agent de maitrise||||STA|CTI_STATUT +S5|Cadre||||STA|CTI_STATUT +CDD|Contrats à durée déterminée||||TCN|CTI_TCNT +CDI|Contrats à durée indéterminée||||TCN|CTI_TCNT +TC|Temps complet||||TTT|CTI_TTT +TP|Temps partiel||||TTT|CTI_TTT diff --git a/db/data2/dbdata_rh_t_classes_sections_elements_ages.csv b/db/data2/dbdata_rh_t_classes_sections_elements_ages.csv new file mode 100644 index 0000000..bf89fb6 --- /dev/null +++ b/db/data2/dbdata_rh_t_classes_sections_elements_ages.csv @@ -0,0 +1,111 @@ +section_code|to_code|table_code|classe_sequence +S1|001|AGE|9 +S1|002|AGE|9 +S1|003|AGE|9 +S1|004|AGE|9 +S1|005|AGE|9 +S1|006|AGE|9 +S1|007|AGE|9 +S1|008|AGE|9 +S1|009|AGE|9 +S1|010|AGE|9 +S1|011|AGE|9 +S1|012|AGE|9 +S1|013|AGE|9 +S1|014|AGE|9 +S1|015|AGE|9 +S1|016|AGE|9 +S1|017|AGE|9 +S1|018|AGE|9 +S1|019|AGE|9 +S1|020|AGE|9 +S1|021|AGE|9 +S1|022|AGE|9 +S1|023|AGE|9 +S1|024|AGE|9 +S2|025|AGE|9 +S2|026|AGE|9 +S2|027|AGE|9 +S2|028|AGE|9 +S2|029|AGE|9 +S2|030|AGE|9 +S2|031|AGE|9 +S2|032|AGE|9 +S2|033|AGE|9 +S2|034|AGE|9 +S2|035|AGE|9 +S3|036|AGE|9 +S3|037|AGE|9 +S3|038|AGE|9 +S3|039|AGE|9 +S3|040|AGE|9 +S3|041|AGE|9 +S3|042|AGE|9 +S3|043|AGE|9 +S3|044|AGE|9 +S3|045|AGE|9 +S4|046|AGE|9 +S4|047|AGE|9 +S4|048|AGE|9 +S4|049|AGE|9 +S4|050|AGE|9 +S4|051|AGE|9 +S4|052|AGE|9 +S4|053|AGE|9 +S4|054|AGE|9 +S4|055|AGE|9 +S5|056|AGE|9 +S5|057|AGE|9 +S5|058|AGE|9 +S5|059|AGE|9 +S5|060|AGE|9 +S5|061|AGE|9 +S5|062|AGE|9 +S5|063|AGE|9 +S5|064|AGE|9 +S5|065|AGE|9 +S6|066|AGE|9 +S6|067|AGE|9 +S6|068|AGE|9 +S6|069|AGE|9 +S6|070|AGE|9 +S6|071|AGE|9 +S6|072|AGE|9 +S6|073|AGE|9 +S6|074|AGE|9 +S6|075|AGE|9 +S6|076|AGE|9 +S6|077|AGE|9 +S6|078|AGE|9 +S6|079|AGE|9 +S6|080|AGE|9 +S6|081|AGE|9 +S6|082|AGE|9 +S6|083|AGE|9 +S6|084|AGE|9 +S6|085|AGE|9 +S6|086|AGE|9 +S6|087|AGE|9 +S6|088|AGE|9 +S6|089|AGE|9 +S6|090|AGE|9 +S6|091|AGE|9 +S6|092|AGE|9 +S6|093|AGE|9 +S6|094|AGE|9 +S6|095|AGE|9 +S6|096|AGE|9 +S6|097|AGE|9 +S6|098|AGE|9 +S6|099|AGE|9 +S6|100|AGE|9 +S6|101|AGE|9 +S6|102|AGE|9 +S6|103|AGE|9 +S6|104|AGE|9 +S6|105|AGE|9 +S6|106|AGE|9 +S6|107|AGE|9 +S6|108|AGE|9 +S6|109|AGE|9 +S6|110|AGE|9 diff --git a/db/data2/dbdata_rh_t_classes_sections_elements_anciennetes_annee.csv b/db/data2/dbdata_rh_t_classes_sections_elements_anciennetes_annee.csv new file mode 100644 index 0000000..d601635 --- /dev/null +++ b/db/data2/dbdata_rh_t_classes_sections_elements_anciennetes_annee.csv @@ -0,0 +1,52 @@ +section_code|to_code|table_code|classe_sequence +S1|00|ANC|9 +S1|01|ANC|9 +S1|02|ANC|9 +S1|03|ANC|9 +S1|04|ANC|9 +S1|05|ANC|9 +S1|06|ANC|9 +S1|07|ANC|9 +S1|08|ANC|9 +S1|09|ANC|9 +S2|10|ANC|9 +S2|11|ANC|9 +S2|12|ANC|9 +S2|13|ANC|9 +S2|14|ANC|9 +S2|15|ANC|9 +S2|16|ANC|9 +S2|17|ANC|9 +S2|18|ANC|9 +S2|19|ANC|9 +S2|20|ANC|9 +S3|21|ANC|9 +S3|22|ANC|9 +S3|23|ANC|9 +S3|24|ANC|9 +S3|25|ANC|9 +S3|26|ANC|9 +S3|27|ANC|9 +S3|28|ANC|9 +S3|29|ANC|9 +S3|30|ANC|9 +S4|31|ANC|9 +S4|32|ANC|9 +S4|33|ANC|9 +S4|34|ANC|9 +S4|35|ANC|9 +S4|36|ANC|9 +S4|37|ANC|9 +S4|38|ANC|9 +S4|39|ANC|9 +S4|40|ANC|9 +S4|41|ANC|9 +S4|42|ANC|9 +S4|43|ANC|9 +S4|44|ANC|9 +S4|45|ANC|9 +S4|46|ANC|9 +S4|47|ANC|9 +S4|48|ANC|9 +S4|49|ANC|9 +S4|50|ANC|9 diff --git a/db/data2/dbdata_rh_t_dashboard.csv b/db/data2/dbdata_rh_t_dashboard.csv new file mode 100644 index 0000000..2bf7890 --- /dev/null +++ b/db/data2/dbdata_rh_t_dashboard.csv @@ -0,0 +1,2 @@ +code|label +CTI_EGAPRO|Cockpit RH diff --git a/db/data2/dbdata_rh_t_dashboard_filter.csv b/db/data2/dbdata_rh_t_dashboard_filter.csv new file mode 100644 index 0000000..1e1664b --- /dev/null +++ b/db/data2/dbdata_rh_t_dashboard_filter.csv @@ -0,0 +1,6 @@ +oid|dashboard_code|external_code2 +1|CTI_EGAPRO|CTI_AGE#LS#AGE:CTI_AGE:S1 +1|CTI_EGAPRO|CTI_AGE#LS#AGE:CTI_AGE:S3 +1|CTI_EGAPRO|CTI_AGE#LS#AGE:CTI_AGE:S6 +1|CTI_EGAPRO|CTI_SEXE#DT#1 +1|CTI_EGAPRO|CTI_SEXE#DT#2 diff --git a/db/data2/dbdata_rh_t_dashboard_onglet.csv b/db/data2/dbdata_rh_t_dashboard_onglet.csv new file mode 100644 index 0000000..8b9a4b1 --- /dev/null +++ b/db/data2/dbdata_rh_t_dashboard_onglet.csv @@ -0,0 +1,3 @@ +oid|dashboard_code|name|index +1|CTI_EGAPRO|Effectif|0 +1|CTI_EGAPRO|Masse Salariale|1 diff --git a/db/data2/dbdata_rh_t_dashboard_widget.csv b/db/data2/dbdata_rh_t_dashboard_widget.csv new file mode 100644 index 0000000..1e3ee4d --- /dev/null +++ b/db/data2/dbdata_rh_t_dashboard_widget.csv @@ -0,0 +1,12 @@ +oid|chart_code|dashboard_code|deprecated +1|CTI_STATTIME|CTI_EGAPRO|t +1|CTI_TYPECNT|CTI_EGAPRO|f +1|CTI_STAT|CTI_EGAPRO|f +1|CTI_EFFANC|CTI_EGAPRO|f +1|CTI_ENTSORCAR|CTI_EGAPRO|f +1|CTI_MSCSPMAP|CTI_EGAPRO|f +1|CTI_MSAGE|CTI_EGAPRO|f +1|CTI_EFFGEN|CTI_EGAPRO|f +1|CTI_EFFAGE|CTI_EGAPRO|f +1|CTI_EFFSTAT|CTI_EGAPRO|f +1|CTI_MSCSP|CTI_EGAPRO|f diff --git a/db/data2/dbdata_rh_t_expert_controle.csv b/db/data2/dbdata_rh_t_expert_controle.csv new file mode 100644 index 0000000..ee5b0c8 --- /dev/null +++ b/db/data2/dbdata_rh_t_expert_controle.csv @@ -0,0 +1,40 @@ +oid|code|texte|description|is_cti|gravite_id|start_periode +0||||1|9|A1 +1|CTI_NIV1_C000|Présence de C000||1|9|A1 +1|CTI_NIV1_CAD_EMP_NR|Cadre d'emploi non renseigné||1|9|A1 +1|CTI_NIV1_CAT_STAT_NR|Catégorie statutaire non renseignée||1|9|A1 +1|CTI_NIV1_CE_NR|Code emploi non renseigné||1|9|A1 +1|CTI_NIV1_COD_POST_NR|Code postal non renseigné||1|9|A1 +1|CTI_NIV1_COM_PAR_NR|Commission paritaire non renseignée||1|9|A1 +1|CTI_NIV1_CSP_NR|Catégorie socio-professionnelle non renseignée||1|9|A1 +1|CTI_NIV1_CTRID_NULL|Contrat ID null en paie||1|9|A1 +1|CTI_NIV1_DAT_NAIS_NR|Date de naissance non renseignée||1|9|A1 +1|CTI_NIV1_DTEDEB_NR|Date de début de contrat non renseignée||1|9|A1 +1|CTI_NIV1_DTEFIN_NR|Date de fin de contrat non renseignée||1|9|A1 +1|CTI_NIV1_FIL_NR|Filière non renseignée||1|9|A1 +1|CTI_NIV1_GRI_NR|Grille non renseignée||1|9|A1 +1|CTI_NIV1_GROGRI_NR|Groupe Grille non renseigné||1|9|A1 +1|CTI_NIV1_GRO_COT_NR|Groupe de cotisant non renseigné||1|9|A1 +1|CTI_NIV1_MOTDEB_NR|Motif de début non renseigné|Contrats sans motif de début.|1|9|A1 +1|CTI_NIV1_MOTFIN_NR|Motif de Fin non renseigné||1|9|A1 +1|CTI_NIV1_NAT_NR|Nationalité non renseigné||1|9|A1 +1|CTI_NIV1_QUAL_NR|Qualification non renseignée||1|9|A1 +1|CTI_NIV1_SEX_NR|Sexe non renseigné||1|9|A1 +1|CTI_NIV1_SPE_NR|Spécialité non renseignée||1|9|A1 +1|CTI_NIV1_SRV_NR|Service non renseigné||1|9|A1 +1|CTI_NIV1_STT_NR|Statut non renseigné||1|9|A1 +1|CTI_NIV1_TC_NR|Type de contrat non renseigné||1|9|A1 +1|CTI_NIV1_TTT_NR|Type temps travail non renseigné||1|9|A1 +1|CTI_NIV1_UNI_FONC_NR|Unité fonctionnelle non renseignée||1|9|A1 +1|CTI_NIV2_C000_BRUT|Présence C000 BRUT||1|5|A1 +1|CTI_NIV2_C000_COT_PAT|Présence C000 Cotisation Patronale||1|5|A1 +1|CTI_NIV2_C000_COT_SAL|Présence C000 Cotisation Salariale||1|5|A1 +1|CTI_NIV2_C000_H_CONTRAT|Présence C000 Heures Contrat||1|5|A1 +1|CTI_NIV2_C000_H_PAYEES|Présence C000 Heures Payées||1|5|A1 +1|CTI_NIV2_C000_H_TRAVAILLEES|Présence C000 Heures Travaillées||1|5|A1 +1|CTI_NIV2_C000_MASSE_SALARIALE|Présence C000 Masse Salariale||1|5|A1 +1|CTI_NIV2_C000_NET_A_PAYE|Présence C000 Net A Payer Salarié||1|5|A1 +1|CTI_NIV2_C000_NET_IMP|Présence C000 Net Imposable Salarié||1|5|A1 +1|CTI_NIV2_HCSORTI|Salarié avec plus d'une paie avec heures contrat après sortie de l'établissement||1|5|A1 +1|CTI_NIV3_PRESENCE_PAIE_PAS_PLANNING|Liste des salariés présents en paie mais pas au planning|Liste des salariés présents en paie mais pas au planning|1|1|A2 +1|CTI_NIV3_PRESENCE_PLANNING_PAS_PAIE|Liste des personnes présentes au planning mais pas en planning|Liste des personnes présentes au planning mais pas en planning|1|1|A2 diff --git a/db/data2/dbdata_rh_t_expert_controle_rule.csv b/db/data2/dbdata_rh_t_expert_controle_rule.csv new file mode 100644 index 0000000..70a5ac6 --- /dev/null +++ b/db/data2/dbdata_rh_t_expert_controle_rule.csv @@ -0,0 +1,38 @@ +oid|expert_controle_code|data_type|indicateur_code|indicateur_condition_external_code_1|indicateur_condition_external_code_2|indicateur_condition_external_code_3|formula|indicateur_code_2|indicateur_condition_external_code_21|indicateur_condition_external_code_22|indicateur_condition_external_code_23|formula_2|indicateur_code_3|indicateur_condition_external_code_31|indicateur_condition_external_code_32|indicateur_condition_external_code_33|formula_3|expert_controle_id|expert_controle_rule_id|indicateur_id|indicateur_condition_id_1|indicateur_condition_id_2|indicateur_condition_id_3|indicateur_2_id|indicateur_condition_id_21|indicateur_condition_id_22|indicateur_condition_id_23|indicateur_3_id|indicateur_condition_id_31|indicateur_condition_id_32|indicateur_condition_id_33 +1|CTI_NIV1_C000|salarie|CTI_C000|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_CAD_EMP_NR|salarie|CTI_CDM|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_CAT_STAT_NR|salarie|CTI_CST|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_CE_NR|salarie|CTI_CEM|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_COD_POST_NR|salarie|CTI_CPO|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_COM_PAR_NR|salarie|CTI_CPA|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_CSP_NR|salarie|CTI_CSP|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_CTRID_NULL|salarie|CTI_CTRID_NULL|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_DAT_NAIS_NR|salarie|CTI_DNA|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_DTEDEB_NR|salarie|CTI_DTEDEB_NR|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_DTEFIN_NR|salarie|CTI_DTEFIN_NR|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_FIL_NR|salarie|CTI_FIL|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_GRI_NR|salarie|CTI_GRI|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_GROGRI_NR|salarie|CTI_GGR|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_GRO_COT_NR|salarie|CTI_GCO|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_MOTDEB_NR|salarie|CTI_MDD|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_MOTFIN_NR|salarie|CTI_MDF|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_NAT_NR|salarie|CTI_NAT|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_QUAL_NR|salarie|CTI_QUA|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_SEX_NR|salarie|CTI_SEX|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_SPE_NR|salarie|CTI_SPE|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_SRV_NR|salarie|CTI_SER|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_STT_NR|salarie|CTI_STA|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_TC_NR|salarie|CTI_TCNT|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_TTT_NR|salarie|CTI_TTT|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV1_UNI_FONC_NR|salarie|CTI_UFO|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_BRUT|salarie|CTI_C000_BRUT|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_COT_PAT|salarie|CTI_C000_COT_PAT|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_COT_SAL|salarie|CTI_C000_COT_SAL|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_H_CONTRAT|salarie|CTI_C000_H_CONTRAT|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_H_PAYEES|salarie|CTI_C000_H_PAYEES|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_H_TRAVAILLEES|salarie|CTI_C000_H_TRAVAILLES|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_MASSE_SALARIALE|salarie|CTI_C000_MASSE_SALARIALE|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_NET_A_PAYE|salarie|CTI_C000_NET_A_PAYE|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV2_C000_NET_IMP|salarie|CTINETIMPOS|CTI_RUBRIQUE#DT#C000||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV3_PRESENCE_PAIE_PAS_PLANNING|salarie|CTI_PRESENCE_PAIE_PAS_PLANNING|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 +1|CTI_NIV3_PRESENCE_PLANNING_PAS_PAIE|salarie|CTI_PRESENCE_PLANNING_PAS_PAIE|||||||||||||||0|0|0|0|0|0|0|0|0|0|0|0|0|0 diff --git a/db/data2/dbdata_rh_t_indicateur_serie.csv b/db/data2/dbdata_rh_t_indicateur_serie.csv new file mode 100644 index 0000000..e8a8fd0 --- /dev/null +++ b/db/data2/dbdata_rh_t_indicateur_serie.csv @@ -0,0 +1,21 @@ +code|indicateur_code|name|color|formula|calc|total|format|external_code2|serie_code +CTI_ENTSORF||Nombre entrees et sorties Femmes|#d19aed|[1] + [2]|t|f||{}|{1:CTI_NVSALF,2:CTI_DEPSALF} +CTI_ENTSORH||Nombre entrees et sorties Hommes|#7b53e8|[1] + [2]|t|f||{}|{1:CTI_NVSALH,2:CTI_DEPSALH} +CTI_HSUPF||Heures supplementaires Femmes|#d19aed||f|f||{CTI_SEXE#DT#2}| +CTI_HSUPH||Heures supplementaires Hommes|#7b53e8||f|f||{CTI_SEXE#DT#1}| +CTI_TAUXSTAT||Taux par statut||([1] / [2])|t|f|0.00%|{}|{1:CTI_TOTSAL,2:CTI_TOTSALF} +CTI_TOF||Turn Over Femmes|#d19aed|([1]/2) / [2]|t|f|0.00%|{}|{1:CTI_ENTSORF,2:CTI_EFFDF} +CTI_TOH||Turn Over Hommes|#7b53e8|([1]/2) / [2]|t|f|0.00%|{}|{1:CTI_ENTSORH,2:CTI_EFFDH} +CTI_MS|CTIMTMASSE|Masse salariale|#7b53e8||f|f||{}| +CTI_MSF|CTIMTMASSE|Masse salariale Femmes|#d19aed||f|f||{CTI_SEXE#DT#2}| +CTI_MSH|CTIMTMASSE|Masse salariale Hommes|#7b53e8||f|f||{CTI_SEXE#DT#1}| +CTI_EFFDF|CTI_EFFDJPER|Effectifs dernier jour Femmes|#d19aed||f|f||{CTI_SEXE#DT#2}| +CTI_EFFDH|CTI_EFFDJPER|Effectifs dernier jour Hommes|#7b53e8||f|f||{CTI_SEXE#DT#1}| +CTI_FEMMES|CTI_NBSALCNT|Femmes|#d19aed||f|f||{CTI_SEXE#DT#2}| +CTI_HOMMES|CTI_NBSALCNT|Hommes|#7b53e8||f|f||{CTI_SEXE#DT#1}| +CTI_TOTSAL|CTI_NBSALCNT|Total salaries|||f|f||{}| +CTI_TOTSALF|CTI_NBSALCNT|Total Salaries fin annee|||f|t||{}| +CTI_NVSALF|CTI_NOUVSALS|Nouveaux salaries Femmes|#d19aed||f|f||{CTI_SEXE#DT#2}| +CTI_NVSALH|CTI_NOUVSALS|Nouveaux salaries Hommes|#7b53e8||f|f||{CTI_SEXE#DT#1}| +CTI_DEPSALF|CTI_SALPARTISSP|Departs salaries Femmes|#d19aed||f|f||{CTI_SEXE#DT#2}| +CTI_DEPSALH|CTI_SALPARTISSP|Departs salaries Hommes|#7b53e8||f|f||{CTI_SEXE#DT#1}| diff --git a/db/data2/dbdata_rh_t_indicateurs.csv b/db/data2/dbdata_rh_t_indicateurs.csv new file mode 100644 index 0000000..ecd449f --- /dev/null +++ b/db/data2/dbdata_rh_t_indicateurs.csv @@ -0,0 +1,192 @@ +oid|code|texte|table_name|column_name|is_cti|entete|total_function|output_format|width|entete_etendue|dimension_date_1|dimension_date_2|dimension_date_3|dimension_date_4|dimension_date_5|dimension_date|indicateur_associe_1_code|indicateur_associe_2_code|indicateur_associe_3_code|indicateur_associe_4_code|indicateur_associe_5_code|indicateur_associe_6_code|indicateur_associe_7_code|indicateur_associe_8_code|indicateur_associe_9_code|indicateur_associe_10_code|indicateur_associe_11_code|indicateur_associe_12_code|indicateur_associe_13_code|indicateur_associe_14_code|indicateur_associe_15_code|indicateur_associe_16_code|indicateur_associe_17_code|indicateur_associe_18_code|indicateur_associe_19_code|indicateur_associe_20_code|indicateur_reference_code +1|CTIAN|Avantages en nature|v_historique_paie_1|montant_avantage_nature|1|Avantage nature|SUM|#E|80|Avantages nature|4| | | | |4||||||||||||||||||||| +1|CTICOTPAT|Cotisations patronales|v_historique_paie_1|montant_cotisation_patronale|1|Cotisations patronales|SUM|#E|80|Cotisations patronales|4| | | | |4||||||||||||||||||||| +1|CTICOTSAL |Cotisations salariales|v_historique_paie_1|montant_cotisation_salarie|1|Cotisations salariales|SUM|#E|80|Cotisations salariales|4| | | | |4||||||||||||||||||||| +1|CTIETPTHM|ETP travaillé moyen|*CALC|base.cti_division([1], [2])|1|ETP travaillé moyen|*CALC|#,00|0|ETP travaillé moyen| | | | | | |CTI_ETPW|CTI_NBMOIS||||||||||||||||||| +1|CTIHP|Heures payées|v_historique_paie_1|heures_payees|1|Heures payées|SUM||80|Heures payées|4| | | | |4||||||||||||||||||||| +1|CTIHT|Heures travaillées|v_historique_paie_1|heures_travaillees|1|Heures travaillées|SUM||80|Heures travaillées|4| | | | |4||||||||||||||||||||| +1|CTIMASSMOY|Masse salariale moyenne|*CALC|base.cti_division([1], [2])|1|Masse moyenne|*CALC|#E|80|Masse salariale moyenne| | | | | | |CTIMTMASSE|CTI_ETPPAYE||||||||||||||||||| +1|CTIMTBRUT|Montant brut|v_historique_paie_1|montant_brut|1|Brut|SUM|#E|80|Montant brut|4| | | | |4||||||||||||||||||||| +1|CTIMTMASSE|Masse salariale|v_historique_paie_1|montant_masse_salariale|1|Masse|SUM|#E|80|Masse salariale|4| | | | |4||||||||||||||||||||| +1|CTINBCNT|Nombre de contrats|v_contrats_mois_1|DISTINCT contrat_id|1|Contrats|COUNT||80|Nombre de contrats|1| | | | |1||||||||||||||||||||| +1|CTINBDSAL|Nombre de salariés distincts (Historique)|v_historique_paie_1|DISTINCT salarie_id|1|Salariés distincts|COUNT||80|Nombre de salariés distincts (Historique)|4| | | | |4||||||||||||||||||||| +1|CTINBHOMME|Nombre d'Hommes|v_historique_paie_1|DISTINCT (CASE WHEN sexe_code = 'M' THEN salarie_id ELSE null END)|1|NB d'Hommes|COUNT||0|Nombre d'Hommes|4| | | | |4||||||||||||||||||||| +1|CTINBJARRET|Jours d'arret de travail|v_arrets_travail_mois_1|nb_jours_arret|1|Arrets|SUM|#j|60|Jours d'arret de travail|1| | | | |1||||||||||||||||||||| +1|CTINBSAL|Nombre de salariés (Historique)|v_historique_paie_1|salarie_id|1|Salariés|COUNT||80|Nombre de salariés (Historique)|4| | | | |4||||||||||||||||||||| +1|CTINETAPAYER|Net à Payer|v_historique_paie_1|montant_net_a_payer_salarie|1|Net A Payer|SUM|#E|80|Net A Payer|4| | | | |4||||||||||||||||||||| +1|CTINETIMPOS|Net Imposable|v_historique_paie_1|montant_net_imposable_salarie|1|Net Imposable|SUM|#E|80|Net Imposable|4| | | | |4||||||||||||||||||||| +1|CTIODNET|OD sur Net|v_historique_paie_1|montant_od_net_salarie|1|OD sur Net|SUM|#E|80|OD sur Net|4| | | | |4||||||||||||||||||||| +1|CTISALCHGMOYH|Salaire Horaire Chargé|*CALC|[1] / [2]|1|Salaire Chargé Moyen|*CALC||0|Salaire Chargé Moyen| | | | | | |CTIMASSMOY|CTIHP||||||||||||||||||| +1|CTISEP|Séparateur|SEP||1||SUM||0||1| | | | |1||||||||||||||||||||| +1|CTITA|Base 4600 TA|v_historique_paie_1|CASE WHEN rubrique_code = '4600' THEN base ELSE 0 END|1|Base 4600 TA|SUM|#¤|80|Base 4600 TA|4| | | | |4||||||||||||||||||||| +1|CTITB|Base 4610 TB|v_historique_paie_1|CASE WHEN rubrique_code = '4610' THEN base ELSE 0 END|1|Base 4610 TB|SUM|#¤|80|Base 4610 TB|4| | | | |4||||||||||||||||||||| +1|CTI_ACTJPCT|Pourcentage de jours d'accident du travail|*CALC|base.cti_division([1], [2]) * 100|1|Pourcentage de jours d'accident du travail|*CALC|#,0%|0|Pourcentage de jours d'accident du travail| | | | | | |CTI_NBJARRET_ACT|CTINBJARRET||||||||||||||||||| +1|CTI_ACTPCT|Pourcentage d'accident du travail|*CALC|base.cti_division([1], [2]) * 100|1|Pourcentage d'accident du travail|*CALC|#,0%|0|Pourcentage d'accident du travail| | | | | | |CTI_NBARRET_ACT|CTI_NBARRET||||||||||||||||||| +1|CTI_AGEMOY|Age moyen|*CALC|base.cti_division([1]::numeric, [2]::numeric)|1|Age moyen|*CALC|#,0|0|Age moyen| | | | | | |CTI_SAGE|CTI_CAGE||||||||||||||||||| +1|CTI_AGESUM|Somme totale des ages|v_contrats_mois_1|rhp_age_id|1|Somme totale des ages|SUM||0|Somme totale des ages|1| | | | |1||||||||||||||||||||| +1|CTI_BRUTCPA1|Montant Brut CP A-1 ( rub 1981)|v_historique_paie_1|CASE WHEN rubrique_code = '1981' THEN montant_brut ELSE 0 END|1|Brut CP A-1|SUM|#E|80|Montant Brut CP A-1|4| | | | |4||||||||||||||||||||| +1|CTI_BRUTMOYEN|Brut moyen/ETP|*CALC|[1] / [2]|1|Brut Moyen(/ETP)|*CALC||0|Brut Moyen(/ETP)| | | | | | |CTIMTBRUT|||||||||||||||||||| +1|CTI_BRUTMOYENETP|Brut moyen/ETP|*CALC|base.cti_division([1], [2])|1|Brut Moyen(/ETP)|*CALC|#E|0|Brut Moyen(/ETP)| | | | | | |CTI_MTBRUT|CTI_ETPPAYE||||||||||||||||||| +1|CTI_CAGE|Comptage salariés pour Age moyen|v_contrats_mois_1|"DISTINCT salarie_id::text||'-'||age_id::text"|1|Comptage salariés pour Age moyen|COUNT|#,0|0|Comptage salariés pour Age moyen|1| | | | |1|CTI_AGESUM|CTI_NDSAL||||||||||||||||||| +1|CTI_CALNBJ_OUVRE|Nombre de jours ouvrés|CALENDRIER|nb_jour_ouvre|1|Jours ouvrés|SUM|#|80|Jours ouvrés|1| | | | |1||||||||||||||||||||| +1|CTI_CALNBJ_SEM|Nombre de jours semaine|CALENDRIER|nb_jour_semaine|1|Jours semaine|SUM|#|80|Jours semaine|1| | | | |1||||||||||||||||||||| +1|CTI_CCO|Qualité - Catégorie de congé|v_contrats_mois_1|DISTINCT CASE WHEN categorie_conge_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Catégorie de congé|COUNT||0|Catégorie de congé|1| | | | |1||||||||||||||||||||| +1|CTI_CDDSALP|Salarié en CDD : Nombre Moyen de contrats|*CALC|base.cti_division([1], [2])|1|Salarié en CDD : Nombre Moyen de contrats|*CALC|#,0|0|Salarié en CDD : Nombre Moyen de contrats| | | | | | |CTI_NBCONTRATCDD|CTI_NBSALCDD||||||||||||||||||| +1|CTI_CDM|Qualité - Cadre d'emploi|v_contrats_mois_1|DISTINCT CASE WHEN cadre_emploi_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Cadre d'emploi|COUNT||0|Cadre d'emploi|1| | | | |1||||||||||||||||||||| +1|CTI_CEM|Qualité - Code emploi|v_contrats_mois_1|DISTINCT CASE WHEN code_emploi_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Code emploi|COUNT||0|Code emploi|1| | | | |1||||||||||||||||||||| +1|CTI_CNTCMP|Contrats en temps complet|v_contrats_mois_1|CASE WHEN type_temps_travail_section_code[9] = 'TC' THEN contrat_id ELSE null END|1|Temps complet|COUNT||0|Contrats en temps complet|1| | | | |1||||||||||||||||||||| +1|CTI_CNTPAR|Contrats en temps partiel|v_contrats_mois_1|CASE WHEN type_temps_travail_section_code[9] = 'TP' THEN contrat_id ELSE null END|1|Temps partiel|COUNT||0|Contrats en temps partiel|1| | | | |1||||||||||||||||||||| +1|CTI_CPA|Qualité - Commission paritaire|v_contrats_mois_1|DISTINCT CASE WHEN commission_paritaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Commission paritaire|COUNT||0|Commission paritaire|1| | | | |1||||||||||||||||||||| +1|CTI_CPA1|Base CP Pris sur A-1 1981|v_historique_paie_1|CASE WHEN rubrique_code = '1981' THEN base ELSE 0 END|1|Base CP a-1|SUM|#j|80|Base CP A-1|4| | | | |4||||||||||||||||||||| +1|CTI_CPO|Qualité - Code postal|v_contrats_mois_1|DISTINCT CASE WHEN code_postal_id = 0 THEN salarie_id ELSE null END|1|Code postal|COUNT||0|Code postal|1| | | | |1||||||||||||||||||||| +1|CTI_CSA|Qualité - Compte salarié|v_contrats_mois_1|DISTINCT CASE WHEN compte_salarie_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Compte salarié|COUNT||0|Compte salarié|1| | | | |1||||||||||||||||||||| +1|CTI_CSP|Qualité - Catégorie socio-professionnelle|v_contrats_mois_1|DISTINCT CASE WHEN categorie_socio_professionnelle_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Catégorie socio-professionnelle|COUNT||0|Catégorie socio-professionnelle|1| | | | |1||||||||||||||||||||| +1|CTI_CST|Qualité - Catégorie statutaire|v_contrats_mois_1|DISTINCT CASE WHEN categorie_statutaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Catégorie statutaire|COUNT||0|Catégorie statutaire|1| | | | |1||||||||||||||||||||| +1|CTI_DBTCDD|Nombre débuts de CDD|v_contrats_mois_1|"DISTINCT (CASE WHEN 1=1 + AND nombre_debut_contrat > 0 + AND type_contrat_section_code[9] = 'CDD' + THEN contrat_id + ELSE null END)"|1|Débuts de CDD|COUNT||0|Nombre débuts de CDD|1| | | | |1||||||||||||||||||||| +1|CTI_DBTCDI|Nombre de début de CDI|v_contrats_mois_1|"DISTINCT (CASE WHEN 1=1 + AND nombre_debut_contrat > 0 + AND type_contrat_section_code[9] = 'CDI' + THEN contrat_id + ELSE null END)"|1|Débuts de CDI|COUNT||0|Nombre de début de CDI|1| | | | |1||||||||||||||||||||| +1|CTI_DNA|Qualité - Date de naissance|v_contrats_mois_1|DISTINCT CASE WHEN date_naissance <= '19200101'::date THEN salarie_id ELSE null END|1|Date de naissance|COUNT||0|Date de naissance|1| | | | |1||||||||||||||||||||| +1|CTI_DUREEMOYARRETS|Durée moyenne des arrêts|*CALC|base.cti_division([1], [2])|1|Durée moyenne des arrêts|*CALC|#,0|0|Durée moyenne des arrêts| | | | | | |CTINBJARRET|CTI_NBARRET||||||||||||||||||| +1|CTI_EFF1ERJANV|Effectif total au 1er janvier|v_contrats_mois_1|"DISTINCT CASE + WHEN 1=1 + AND present_debut_mois = 1 + AND date_part('month', date_debut_activite) = 1 + THEN salarie_id + ELSE null +END"|1|Effectif total au 1er janvier|COUNT||0|Effectif total au 1er janvier|1| | | | |1||||||||||||||||||||| +1|CTI_EFF31DEV|Effectif total au 31 décembre|v_contrats_mois_1|"DISTINCT CASE + WHEN 1=1 + AND present_fin_mois = 1 + AND date_part('month', date_debut_activite) = 12 + THEN salarie_id + ELSE null +END"|1|Effectif total au 31 décembre|COUNT||0|Effectif total au 31 décembre|1| | | | |1||||||||||||||||||||| +1|CTI_EFFDJPER|Effectif au dernier jour de la période|v_contrats_mois_1|"DISTINCT CASE +WHEN 1=1 +AND present_fin_mois = 1 +THEN salarie_id +ELSE null +END"|1|Effectif au dernier jour|COUNTLASTMONTH||0|Effectif au dernier jour de la période|1| | | | |1||||||||||||||||||||| +1|CTI_EFFPERM|Effectif permanent|v_contrats_mois_1|DISTINCT CASE WHEN effectif_permanent = 1 then salarie_id ELSE null END|1|Effectif permanent|COUNTLASTMONTH||0|Effectif permanent|1| | | | |1||||||||||||||||||||| +1|CTI_EFFPJPER|Effectif au premier jour de la période|v_contrats_mois_1|"DISTINCT CASE + WHEN 1=1 + AND present_debut_mois = 1 + AND to_char(date_debut_activite, 'YYYYMM') = to_char( periode::date, 'YYYYMM') + THEN salarie_id + ELSE null +END"|1|Effectif au premier jour|COUNT||0|Effectif au premier jour de la période|1| | | | |1||||||||||||||||||||| +1|CTI_EMBCDD|Nombre d'embauche en CDD|v_contrats_mois_1|"DISTINCT (CASE WHEN 1=1 + AND nombre_entrees = 1 + AND type_contrat_section_code[9] = 'CDD' + THEN salarie_id + ELSE null END)"|1|Embauche en CDD|COUNT||0|Nombre d'embauche en CDD|1| | | | |1||||||||||||||||||||| +1|CTI_EMBCDI|Nombre d'embauche en CDI|v_contrats_mois_1|"DISTINCT (CASE WHEN 1=1 + AND nombre_entrees = 1 + AND type_contrat_section_code[9] = 'CDI' + THEN salarie_id + ELSE null END)"|1|Embauche en CDI|COUNT||0|Nombre d'embauche en CDI|1| | | | |1||||||||||||||||||||| +1|CTI_EMBMS25|Nombre d'embauche de salariés de moins de 25 ans|v_contrats_mois_1|"DISTINCT (CASE WHEN 1=1 + AND nombre_entrees = 1 + AND rhp_age_id < 25 + THEN salarie_id + ELSE null END)"|1|Embauche < 25 ans|COUNT||0|Nombre d'embauche de salariés de moins de 25 ans|1| | | | |1||||||||||||||||||||| +1|CTI_ETPPAYE|ETP rémunéré|v_historique_paie_1|etp_paye|1|ETP rémunéré|SUM|#,00|80|ETP rémunéré|4| | | | |4|CTIHP|||||||||||||||||||| +1|CTI_ETPREMMOY|ETP rémunéré moyen|*CALC|base.cti_division([1], [2])|1|ETP rémunéré moyen|*CALC|#,00|0|ETP rémunéré moyen| | | | | | |CTI_ETPPAYE|CTI_NBMOIS||||||||||||||||||| +1|CTI_ETPW|ETP travaillé|v_historique_paie_1|etp_travaille|1|ETP travaillé|SUM|#,00|80|ETP travaillé|4| | | | |4||||||||||||||||||||| +1|CTI_FIL|Qualité - Filière|v_contrats_mois_1|DISTINCT CASE WHEN filiere_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Filière|COUNT||0|Filière|1| | | | |1||||||||||||||||||||| +1|CTI_FINCNT|Nombre de fin de contrats|v_contrats_mois_1|DISTINCT (CASE WHEN nombre_fin_contrat > 0 THEN contrat_id ELSE null END)|1|Fin de contrats|COUNT||0|Nombre de fin de contrats|1| | | | |1||||||||||||||||||||| +1|CTI_FINCNTCDD|Nombre de fin de CDD|v_contrats_mois_1|"DISTINCT ( +CASE WHEN 1=1 + AND nombre_fin_contrat > 0 + AND type_contrat_section_code[9] = 'CDD' + THEN contrat_id + ELSE null +END)"|1|Fin de CDD|COUNT||0|Nombre de fin de CDD|1| | | | |1||||||||||||||||||||| +1|CTI_FINCNTCDI|Nombre de fin de CDI|v_contrats_mois_1|"DISTINCT ( +CASE WHEN 1=1 + AND nombre_fin_contrat > 0 + AND type_contrat_section_code[9] = 'CDI' + THEN contrat_id + ELSE null +END)"|1|Fin de CDI|COUNT||0|Nombre de fin de CDI|1| | | | |1||||||||||||||||||||| +1|CTI_FRIMPOS|Frais Imposable|v_historique_paie_1|montant_frais_imposables|1|Frais Imposable|SUM|#E|80|Frais Imposable|4| | | | |4||||||||||||||||||||| +1|CTI_GCO|Qualité - Groupe de cotisant|v_contrats_mois_1|DISTINCT CASE WHEN groupe_cotisant_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Groupe de cotisant|COUNT||0|Groupe de cotisant|1| | | | |1||||||||||||||||||||| +1|CTI_GGR|Qualité - Groupe de grille|v_contrats_mois_1|DISTINCT CASE WHEN grille_groupe_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Groupe de grille|COUNT||0|Groupe de grille|1| | | | |1||||||||||||||||||||| +1|CTI_GRI|Qualité - Grille|v_contrats_mois_1|DISTINCT CASE WHEN grille_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Grille|COUNT||0|Grille|1| | | | |1||||||||||||||||||||| +1|CTI_LBU|Qualité - Lettre budgétaire|v_contrats_mois_1|DISTINCT CASE WHEN lettre_budgetaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Lettre budgétaire|COUNT||0|Lettre budgétaire|1| | | | |1||||||||||||||||||||| +1|CTI_MALJPCT|Pourcentage de jours de maladie|*CALC|base.cti_division([1], [2]) * 100|1|Pourcentage de jours de maladie|*CALC|#,0%|0|Pourcentage de jours de maladie| | | | | | |CTI_NBJARRET_MAL|CTINBJARRET||||||||||||||||||| +1|CTI_MALPCT|Pourcentage de maladie|*CALC|base.cti_division([1], [2]) * 100|1|Pourcentage de maladie|*CALC|#,0%|0|Pourcentage de maladie| | | | | | |CTI_NBARRET_MAL|CTI_NBARRET||||||||||||||||||| +1|CTI_MATJPCT|Pourcentage de jours de maternité|*CALC|base.cti_division([1], [2]) * 100|1|Pourcentage de jours de maternité|*CALC|#,0%|0|Pourcentage de jours de maternité| | | | | | |CTI_NBJARRET_MAT|CTINBJARRET||||||||||||||||||| +1|CTI_MATPCT|Pourcentage de maternité|*CALC|base.cti_division([1], [2]) * 100|1|Pourcentage de maternité|*CALC|#,0%|0|Pourcentage de maternité| | | | | | |CTI_NBARRET_MAT|CTI_NBARRET||||||||||||||||||| +1|CTI_MDD|Qualité - Motif de début de contrat|v_contrats_mois_1|DISTINCT CASE WHEN motif_debut_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Motif de début|COUNT||0|Motif de début|1| | | | |1||||||||||||||||||||| +1|CTI_MDF|Qualité - Motif de fin de contrat|v_contrats_mois_1|DISTINCT CASE WHEN motif_fin_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Motif de fin|COUNT||0|Motif de fin|1| | | | |1||||||||||||||||||||| +1|CTI_MHMC|Montant Horaire Moyen Chargé|*CALC|base.cti_division([1], [2])|1|Mnt H. Moy. Chargé|*CALC|#,0E|0|Montant Horaire Moyen Chargé| | | | | | |CTIMTMASSE|CTIHP||||||||||||||||||| +1|CTI_MTBRUT|Montant brut|v_historique_paie_1|montant_brut|1|Brut|SUM|#E|80|Montant brut|4| | | | |4||||||||||||||||||||| +1|CTI_MT_CNT|Montant rupture de contrat|v_historique_paie_1|CASE WHEN rubrique_id IN [LISTE:CTI_EXP_CNT] THEN montant_od_net_salarie ELSE 0 END|1|Montant rupture de contrat|SUM|#E|0|Montant rupture de contrat|4| | | | |4||||||||||||||||||||| +1|CTI_MT_IJ|Montant IJSS|v_historique_paie_1|CASE WHEN rubrique_id IN [LISTE:CTI_EXP_IJS] THEN montant_od_net_salarie ELSE 0 END|1|Montant IJSS|SUM|#E|0|Montant IJSS|4| | | | |4||||||||||||||||||||| +1|CTI_MT_PRE|Montant prime de précarité|v_historique_paie_1|CASE WHEN rubrique_id IN [LISTE:CTI_EXP_PRE] THEN montant_masse_salariale ELSE 0 END|1|Montant Prime de précarité|SUM|#E|0|Montant prime de précarité|4| | | | |4||||||||||||||||||||| +1|CTI_MT_RET|Montant départ à la retraite|v_historique_paie_1|CASE WHEN rubrique_id IN [LISTE:CTI_EXP_RET] THEN montant_masse_salariale ELSE 0 END|1|Montant retraite|SUM|#E|0|Montant départ à la retraite|4| | | | |4||||||||||||||||||||| +1|CTI_NAT|Qualité - Nationalité|v_contrats_mois_1|DISTINCT CASE WHEN nationalite_id = 0 THEN salarie_id ELSE null END|1|Nationalité|COUNT||0|Nationalité|1| | | | |1||||||||||||||||||||| +1|CTI_NBARRET|Nombre d'arrêts|v_arrets_travail_mois_1|DISTINCT CASE WHEN nb_arret = 1 THEN arret_travail_id ELSE null END|1|Nombre d'arrêts|COUNT||0|Nombre d'arrêts|1| | | | |1||||||||||||||||||||| +1|CTI_NBARRETMOY|Nombre d'arrêts moyen|*CALC|base.cti_division([1], [2])|1|Nb d'arrêts moyen|*CALC|#,0|0|Nombre d'arrêts moyen| | | | | | |CTI_NBARRET|CTI_NBSALCNT||||||||||||||||||| +1|CTI_NBARRET_ACT|Nombre d'arrêts pour accident du travail|v_arrets_travail_mois_1|DISTINCT CASE WHEN nb_arret = 1 AND motif_arret_section_code[9] = 'ACT' THEN arret_travail_id ELSE null END|1|Nb accident du travail|COUNT||0|Nombre d'arrêts pour accident du travail|1| | | | |1||||||||||||||||||||| +1|CTI_NBARRET_MAL|Nombre d'arrêts maladie|v_arrets_travail_mois_1|DISTINCT CASE WHEN nb_arret = 1 AND motif_arret_section_code[9] = 'MAL' THEN arret_travail_id ELSE null END|1|Nb maladies|COUNT||0|Nombre d'arrêts maladie|1| | | | |1||||||||||||||||||||| +1|CTI_NBARRET_MAT|Nombre d'arrêts maternité|v_arrets_travail_mois_1|DISTINCT CASE WHEN nb_arret = 1 AND motif_arret_section_code[9] = 'MAT' THEN arret_travail_id ELSE null END|1|Nb maternités|COUNT||0|Nombre d'arrêts maternité|1| | | | |1||||||||||||||||||||| +1|CTI_NBCNT|Nombre de contrats|v_contrats_mois_1|DISTINCT contrat_id|1|Contrats|COUNT||80|Nombre de contrats|1| | | | |1||||||||||||||||||||| +1|CTI_NBCONTRATCDD|Nombre de contrats en CDD|v_contrats_mois_1|DISTINCT (CASE WHEN type_contrat_section_code[9] = 'CDD' THEN contrat_id ELSE null END)|1|Contrats CDD|COUNT||80|Nombre de contrats en CDD|1| | | | |1||||||||||||||||||||| +1|CTI_NBCONTRATCDI|Nombre de contrats en CDI|v_contrats_mois_1|DISTINCT (CASE WHEN type_contrat_section_code[9] = 'CDI' THEN contrat_id ELSE null END)|1|Contrats CDI|COUNT||80|Nombre de contrats en CDI|1| | | | |1||||||||||||||||||||| +1|CTI_NBETRANGERS|Nombre d'étrangers|v_historique_paie_1|DISTINCT (CASE WHEN nationalite_section_code[9] != 'FR' THEN salarie_id ELSE null END)|1|NB d'étrangers|COUNT||0|Nombre d'étrangers|4| | | | |4||||||||||||||||||||| +1|CTI_NBFEMMECNT|Nombre de Femmes (Contrats)|v_contrats_mois_1|DISTINCT (CASE WHEN sexe_code = 'F' THEN salarie_id ELSE null END)|1|NB de Femmes|COUNT||0|Nombre de Femmes|1| | | | |1||||||||||||||||||||| +1|CTI_NBFEMMEPAIE|Nombre de Femmes (Paie)|v_historique_paie_1|DISTINCT (CASE WHEN sexe_code = 'F' THEN salarie_id ELSE null END)|1|NB de Femmes|COUNT||0|Nombre de Femmes|4| | | | |4||||||||||||||||||||| +1|CTI_NBHANDICAP|Nombre d'handicapés|v_historique_paie_1|DISTINCT (CASE WHEN handicap_id = '1' THEN salarie_id ELSE null END)|1|NB d'handicapés|COUNT||0|Nombre d'handicapés|4| | | | |4||||||||||||||||||||| +1|CTI_NBIJSS|Nombre d'IJSS|v_historique_paie_1|DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_IJS] THEN salarie_id ELSE null END|1|IJSS|COUNT||0|Nombre d'IJSS|4| | | | |4||||||||||||||||||||| +1|CTI_NBJARRET_ACT|Nombre de jours d'arrêt pour accident du travail|v_arrets_travail_mois_1|CASE WHEN motif_arret_section_code[9] = 'ACT' THEN nb_jours_arret ELSE 0 END|1|Nb jours accident du travail|SUM||0|Nombre de jours d'arrêt pour accident du travail|1| | | | |1||||||||||||||||||||| +1|CTI_NBJARRET_MAL|Nombre de jours d'arrêt maladie|v_arrets_travail_mois_1|CASE WHEN motif_arret_section_code[9] = 'MAL' THEN nb_jours_arret ELSE 0 END|1|Nb jours maladie|SUM||0|Nombre de jours d'arrêt maladie|1| | | | |1||||||||||||||||||||| +1|CTI_NBJARRET_MAT|Nombre de jours d'arrêt maternité|v_arrets_travail_mois_1|CASE WHEN motif_arret_section_code[9] = 'MAT' THEN nb_jours_arret ELSE 0 END|1|Nb jours maternité|SUM||0|Nombre de jours d'arrêt maternité|1| | | | |1||||||||||||||||||||| +1|CTI_NBJT|Nombre de journées théoriques travaillées|v_historique_paie_1|heures_travaillees / 7.0|1|Journées théoriques travaillées|SUM||0|Nombre de journées théoriques travaillées|4| | | | |4||||||||||||||||||||| +1|CTI_NBMOIS|Nombre de mois sur la période|v_contrats_mois_1|DISTINCT mois_activite_id|1|Mois /période|COUNT||0|Nombre de mois sur la période|1| | | | |1||||||||||||||||||||| +1|CTI_NBRUPT|Nombre de rupture de contrat|v_historique_paie_1|DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_CNT] THEN salarie_id ELSE null END|1|Rupture de contrat|COUNT||0|Nombre de rupture de contrat|4| | | | |4||||||||||||||||||||| +1|CTI_NBSAL|Nombre de salariés (Paie)|v_historique_paie_1|DISTINCT salarie_id|1|Salariés|COUNT||80|Nombre de salariés (Paie)|4| | | | |4||||||||||||||||||||| +1|CTI_NBSALCDD|Nombre de salariés en CDD|v_contrats_mois_1|DISTINCT (CASE WHEN type_contrat_section_code[9] = 'CDD' THEN salarie_id ELSE null END)|1|Salariés CDD|COUNT||80|Nombre de salariés en CDD|1| | | | |1||||||||||||||||||||| +1|CTI_NBSALCNT|Nombre de salariés (Contrats)|v_contrats_mois_1|DISTINCT salarie_id|1|Salariés|COUNT||80|Nombre de salariés|1| | | | |1||||||||||||||||||||| +1|CTI_NBSALCNTFR|Nombre de Français (Contrat)|v_contrats_mois_1|DISTINCT (CASE WHEN nationalite_section_code[9] = 'FR' THEN salarie_id ELSE null END)|1|NB de Français|COUNT||0|Nombre de Français|1| | | | |1||||||||||||||||||||| +1|CTI_NBSALPAIEFR|Nombre de Français (Paie)|v_historique_paie_1|DISTINCT (CASE WHEN nationalite_section_code[9] = 'FR' THEN salarie_id ELSE null END)|1|NB de Français|COUNT||0|Nombre de Français|4| | | | |4||||||||||||||||||||| +1|CTI_NB_PRE|Nombre de prime de précarité|v_historique_paie_1|DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_PRE] THEN salarie_id ELSE null END|1|Prime de précarité|COUNT||0|Nombre de prime de précarité|4| | | | |4||||||||||||||||||||| +1|CTI_NB_RET|Nombre de départ à la retraite|v_historique_paie_1|DISTINCT CASE WHEN rubrique_id IN [LISTE:CTI_EXP_RET] THEN salarie_id ELSE null END|1|Départ à la retraite|COUNT||0|Nombre de départ à la retraite|4| | | | |4||||||||||||||||||||| +1|CTI_NDSAL|Nombre NON DISTINCT de salariés|v_contrats_mois_1|salarie_id|1|Nombre NON DISTINCT de salariés|COUNT||0|Nombre NON DISTINCT de salariés|1| | | | |1||||||||||||||||||||| +1|CTI_NOUVSALS|Nouveaux salariés|v_contrats_mois_1|DISTINCT (CASE WHEN nombre_entrees = 1 THEN salarie_id ELSE null END)|1|Nouveaux salariés|COUNT||0|Nouveaux salariés|1| | | | |1||||||||||||||||||||| +1|CTI_NVXCNT|Nombre de nouveaux contrats|v_contrats_mois_1|DISTINCT (CASE WHEN nombre_debut_contrat > 0 THEN contrat_id ELSE null END)|1|Nouveaux contrats|COUNT||0|Nombre de nouveaux contrats|1| | | | |1||||||||||||||||||||| +1|CTI_PCDD|% de CDD|*CALC|base.cti_division([1], [2]) * 100|1|% CDD|*CALC|#,0%|0|% de CDD/nb de contrat| | | | | | |CTI_NBCONTRATCDD|CTI_NBCNT||||||||||||||||||| +1|CTI_PCDI|% de CDI|*CALC|base.cti_division([1], [2]) * 100|1|% CDI|*CALC|#,0%|0|% de CDI/nb de contrat| | | | | | |CTI_NBCONTRATCDI|CTI_NBCNT||||||||||||||||||| +1|CTI_PCTFEMMECNT|% de femmes|*CALC|base.cti_division([1], [2]) * 100|1|% de femmes|*CALC|#,0%|0|% de femmes| | | | | | |CTI_NBFEMMECNT|CTI_NBSALCNT||||||||||||||||||| +1|CTI_PRESENCE_PAIE_PAS_PLANNING|Liste des salariés présents en paie mais pas au planning|v_presence_salaries_1|CASE WHEN present_paie= true AND present_planning = false THEN 1 ELSE 0 END|1||SUM|#|0||4| | | | |4||||||||||||||||||||| +1|CTI_PRESENCE_PLANNING_PAS_PAIE|Liste des personnes présentes au planning mais pas en paie|v_presence_salaries_1|CASE WHEN present_paie= false AND present_planning = true THEN 1 ELSE 0 END|1||SUM|#|0||4| | | | |4||||||||||||||||||||| +1|CTI_QUA|Qualité - Qualification|v_contrats_mois_1|DISTINCT CASE WHEN qualification_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Qualification|COUNT||0|Qualification|1| | | | |1||||||||||||||||||||| +1|CTI_RAPPORTCALC|Calcul d'indicateurs dans le rapport|*RAPPORTCALC||1||sum|#|0||0| | | | |0||||||||||||||||||||| +1|CTI_ROTATIONEMP|Rotation de l'emploi|*CALC|base.cti_division((([1] + [2]) / 2), [3]) * 100|1|Rotation de l'emploi|*CALC|#,0%|0|Rotation de l'emploi| | | | | | |CTI_NOUVSALS|CTI_SALPARTISSP|CTI_EFFPJPER|||||||||||||||||| +1|CTI_SAC|Qualité - Section analytique comptable|v_contrats_mois_1|DISTINCT CASE WHEN section_analytique_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Section analytique comptable|COUNT||0|Section analytique comptable|1| | | | |1||||||||||||||||||||| +1|CTI_SAGE|Somme Ages pour Age moyen|v_contrats_mois_1|DISTINCT ARRAY[salarie_id::numeric, age_id::numeric]|1|Somme Ages pour Age moyen|base.cti_sum_distinct_on|#,0|0|Somme Ages pour Age moyen|1| | | | |1|CTI_AGESUM|CTI_NDSAL||||||||||||||||||| +1|CTI_SAL60|Nombre de salariés 60 ans et +|v_contrats_mois_1|DISTINCT CASE WHEN rhp_age_id >= 60 THEN salarie_id ELSE null END|1|Salariés 60 ans et +|COUNT||0|Nombre de salariés 60 ans et +|1| | | | |1||||||||||||||||||||| +1|CTI_SALCHGMOY|Salaire Moyen Chargé|*CALC|base.cti_division([1], [2])|1|Salaire Chargé Moyen|*CALC||0|Salaire Chargé Moyen| | | | | | |CTINETAPAYER|CTI_ETPPAYE||||||||||||||||||| +1|CTI_SALCHGMOYH|Salaire Horaire Chargé Moyen|*CALC|base.cti_division([1], [2])|1|Salaire Chargé Moyen|*CALC||0|Salaire Chargé Moyen| | | | | | |CTIMASSMOY|CTIHP||||||||||||||||||| +1|CTI_SALPARTISSP|Salarié partis sur la période|v_contrats_mois_1|DISTINCT (CASE WHEN nombre_departs = 1 THEN salarie_id ELSE null END)|1|Salarié partis /période|COUNT||0|Salarié partis sur la période|1| | | | |1||||||||||||||||||||| +1|CTI_SAP|Qualité - Section analytique paie|v_contrats_mois_1|DISTINCT CASE WHEN section_analytique_paie_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Section analytique paie|COUNT||0|Section analytique paie|1| | | | |1||||||||||||||||||||| +1|CTI_SEP|Séparateur|SEP||1||SUM||0||1| | | | |1||||||||||||||||||||| +1|CTI_SER|Qualité - Service|v_contrats_mois_1|DISTINCT CASE WHEN service_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Service|COUNT||0|Service|1| | | | |1||||||||||||||||||||| +1|CTI_SEX|Qualité - Sexe|v_contrats_mois_1|DISTINCT CASE WHEN sexe_id = 0 THEN salarie_id ELSE null END|1|Sexe|COUNT||0|Sexe|1| | | | |1||||||||||||||||||||| +1|CTI_SFA|Qualité - Situation de famille|v_contrats_mois_1|DISTINCT CASE WHEN situation_famille_id = 0 THEN salarie_id ELSE null END|1|Situation de famille|COUNT||0|Situation de famille|1| | | | |1||||||||||||||||||||| +1|CTI_SIN|Qualité - Société d'interim|v_contrats_mois_1|DISTINCT CASE WHEN societe_interim_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Société d'interim|COUNT||0|Société d'interim|1| | | | |1||||||||||||||||||||| +1|CTI_SPE|Qualité - Spécialité|v_contrats_mois_1|DISTINCT CASE WHEN specialite_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Spécialité|COUNT||0|Spécialité|1| | | | |1||||||||||||||||||||| +1|CTI_STA|Qualité - Statut|v_contrats_mois_1|DISTINCT CASE WHEN statut_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Statut|COUNT||0|Statut|1| | | | |1||||||||||||||||||||| +1|CTI_TCNT|Qualité - Type de contrat|v_contrats_mois_1|DISTINCT CASE WHEN type_contrat_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Type de contrat|COUNT||0|Type de contrat|1| | | | |1||||||||||||||||||||| +1|CTI_THO|Qualité - Type horaire|v_contrats_mois_1|DISTINCT CASE WHEN type_horaire_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Type horaire|COUNT||0|Type horaire|1| | | | |1||||||||||||||||||||| +1|CTI_TRACDI|Transformation CDI|v_contrats_mois_1|DISTINCT case when nombre_transformation_cdi = '1' then salarie_id else null end|1|Transformation CDI|COUNT||0|Transformation CDI|1| | | | |1||||||||||||||||||||| +1|CTI_TTT|Qualité - Type de temps de travail|v_contrats_mois_1|DISTINCT CASE WHEN type_temps_travail_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Type de temps de travail|COUNT||0|Type de temps de travail|1| | | | |1||||||||||||||||||||| +1|CTI_UFO|Qualité - Unité fonctionnelle|v_contrats_mois_1|DISTINCT CASE WHEN unite_fonctionnelle_id = 0 AND est_hors_periode = 0 THEN salarie_id ELSE null END|1|Unité fonctionnelle|COUNT||0|Unité fonctionnelle|1| | | | |1||||||||||||||||||||| diff --git a/db/data2/dbdata_rh_t_listes.csv b/db/data2/dbdata_rh_t_listes.csv new file mode 100644 index 0000000..b84d954 --- /dev/null +++ b/db/data2/dbdata_rh_t_listes.csv @@ -0,0 +1,9 @@ +oid|texte|chapitre|code|is_cti|show_omit|utilisateur_createur|est_partagee_modification|table_name +1|Primes à périodicité non mensuelle - Bilan Social||CTI_BS_PPNM|1|1|*CTI|1|t_rubriques +1|Eléments exceptionnels : Rupture de contrat : OD/Net.|Elements exceptionnels|CTI_EXP_CNT|1|1|*CTI|1|t_rubriques +1|IJSS : Payé SS / OD/Net.|Elements exceptionnels|CTI_EXP_IJS|1|1|*CTI|1|t_rubriques +1|Eléments exceptionnels : Prime de précarité|Elements exceptionnels|CTI_EXP_PRE|1|1|*CTI|1|t_rubriques +1|Eléments exceptionnels : Retraite|Elements exceptionnels|CTI_EXP_RET|1|1|*CTI|1|t_rubriques +1|Elements exceptionnels Retraite et rupture.|Elements exceptionnels|CTI_EXP_RRU|1|1|*CTI|1|t_rubriques +1|Heures contrat|Paramétrage|CTI_HCNT|1|0|*CTI|1|t_rubriques +1|Pegase forfaits jours|Paramétrage|CTI_PEGASE_FTJ|1|0|*CTI|1|t_rubriques diff --git a/db/data2/dbdata_rh_t_listes_tables.csv b/db/data2/dbdata_rh_t_listes_tables.csv new file mode 100644 index 0000000..3a5f50e --- /dev/null +++ b/db/data2/dbdata_rh_t_listes_tables.csv @@ -0,0 +1,431 @@ +oid|name|texte|select_cmd|code +1|t_ages|Age|"SELECT t_ages.oid, t_ages.code, t_ages.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_ages LEFT JOIN rh.p_oids ON (t_ages.oid = p_oids.oid AND code_table = 'ages') +WHERE t_ages.oid > 0 +ORDER BY t_ages.code"|AGE +1|t_section_analytique|Section analytique NG|"SELECT t_section_analytique.oid, + t_section_analytique.code, + t_section_analytique.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_section_analytique + LEFT JOIN rh.p_oids ON (t_section_analytique.oid = p_oids.oid AND code_table = 'section_analytique') +WHERE t_section_analytique.oid > 0 +ORDER BY t_section_analytique.code"|ANA +1|t_anciennetes_annee|Ancienneté|"SELECT t_anciennetes_annee.oid, t_anciennetes_annee.code, t_anciennetes_annee.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_anciennetes_annee LEFT JOIN rh.p_oids ON (t_anciennetes_annee.oid = p_oids.oid AND code_table = 'anciennete_annee') +ORDER BY t_anciennetes_annee.code"|ANC +1|t_accident_circonstance|[DICT.RH.CIRCONSTANCE] accident du travail|"SELECT t_accident_circonstance.oid, + t_accident_circonstance.code, + t_accident_circonstance.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_accident_circonstance + LEFT JOIN rh.p_oids ON (t_accident_circonstance.oid = p_oids.oid AND code_table = 'accident_circonstance') +WHERE t_accident_circonstance.oid > 0 +ORDER BY t_accident_circonstance.code"|ATC +1|t_accident_lieu|[DICT.RH.LIEU] accident du travail|"SELECT t_accident_lieu.oid, + t_accident_lieu.code, + t_accident_lieu.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_accident_lieu + LEFT JOIN rh.p_oids ON (t_accident_lieu.oid = p_oids.oid AND code_table = 'accident_lieu') +WHERE t_accident_lieu.oid > 0 +ORDER BY t_accident_lieu.code"|ATL +1|t_accident_nature|Nature accident du travail|"SELECT t_accident_nature.oid, + t_accident_nature.code, + t_accident_nature.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_accident_nature + LEFT JOIN rh.p_oids ON (t_accident_nature.oid = p_oids.oid AND code_table = 'accident_nature') +WHERE t_accident_nature.oid > 0 +ORDER BY t_accident_nature.code"|ATN +1|t_accident_siege|Siège accident du travail|"SELECT t_accident_siege.oid, + t_accident_siege.code, + t_accident_siege.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_accident_siege + LEFT JOIN rh.p_oids ON (t_accident_siege.oid = p_oids.oid AND code_table = 'accident_siege') +WHERE t_accident_siege.oid > 0 +ORDER BY t_accident_siege.code"|ATS +1|t_categorie_conge|Catégorie de congé|"SELECT t_categorie_conge.oid, + t_categorie_conge.code, + t_categorie_conge.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_categorie_conge + LEFT JOIN rh.p_oids ON (t_categorie_conge.oid = p_oids.oid AND code_table = 'categorie_conge') +WHERE t_categorie_conge.oid > 0 +ORDER BY t_categorie_conge.code"|CAC +1|t_cadre_emploi|Cadre d'emploi|"SELECT t_cadre_emploi.oid, + t_cadre_emploi.code, + t_cadre_emploi.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_cadre_emploi + LEFT JOIN rh.p_oids ON (t_cadre_emploi.oid = p_oids.oid AND code_table = 'cadre_emploi') +WHERE t_cadre_emploi.oid > 0 +ORDER BY t_cadre_emploi.code"|CAE +1|t_categorie_statutaire|Catégorie statutaire|"SELECT t_categorie_statutaire.oid, + t_categorie_statutaire.code, + t_categorie_statutaire.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_categorie_statutaire + LEFT JOIN rh.p_oids ON (t_categorie_statutaire.oid = p_oids.oid AND code_table = 'categorie_statutaire') +WHERE t_categorie_statutaire.oid > 0 +ORDER BY t_categorie_statutaire.code"|CAS +1|t_codes_emploi|[DICT.RH.CODE_EMPLOI]|"SELECT t_codes_emploi.oid, t_codes_emploi.code, t_codes_emploi.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_codes_emploi LEFT JOIN rh.p_oids ON (t_codes_emploi.oid = p_oids.oid AND code_table = 'codes_emploi') +WHERE t_codes_emploi.oid > 0 +ORDER BY t_codes_emploi.code"|CEM +1|t_compte_imputation|Compte d'imputation|"SELECT t_compte_imputation.oid, + t_compte_imputation.code, + t_compte_imputation.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_compte_imputation + LEFT JOIN rh.p_oids ON (t_compte_imputation.oid = p_oids.oid AND code_table = 'compte_imputation') +WHERE t_compte_imputation.oid > 0 +ORDER BY t_compte_imputation.code"|COI +1|t_code_cotisation|Code cotisation|"SELECT t_code_cotisation.oid, + t_code_cotisation.code, + t_code_cotisation.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_code_cotisation + LEFT JOIN rh.p_oids ON (t_code_cotisation.oid = p_oids.oid AND code_table = 'code_cotisation') +WHERE t_code_cotisation.oid > 0 +ORDER BY t_code_cotisation.code"|COT +1|t_codes_postaux|Code postal|"SELECT t_codes_postaux.oid, t_codes_postaux.code, t_codes_postaux.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_codes_postaux LEFT JOIN rh.p_oids ON (t_codes_postaux.oid = p_oids.oid AND code_table = 'codes_postaux') +WHERE t_codes_postaux.oid > 0 +ORDER BY t_codes_postaux.code"|CPO +1|t_compte|Compte|"SELECT t_compte.oid, + t_compte.code, + t_compte.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_compte + LEFT JOIN rh.p_oids ON (t_compte.oid = p_oids.oid AND code_table = 'compte') +WHERE t_compte.oid > 0 +ORDER BY t_compte.code"|CPT +1|t_categories_socio_professionnelles|[DICT.RH.CATEGORIE_SOC_PRO]|"SELECT t_categories_socio_professionnelle.oid, t_categories_socio_professionnelle.code, t_categories_socio_professionnelle.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_categories_socio_professionnelle LEFT JOIN rh.p_oids ON (t_categories_socio_professionnelle.oid = p_oids.oid AND code_table = 'categories_socio_professionnelle') +WHERE t_categories_socio_professionnelle.oid > 0 +ORDER BY t_categories_socio_professionnelle.code"|CSC +1|t_etablissements|Etablissement|"SELECT t_etablissements.oid, + t_etablissements.code, + t_etablissements.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_etablissements + LEFT JOIN rh.p_oids ON (t_etablissements.oid = p_oids.oid AND code_table = 'etablissements') +WHERE t_etablissements.oid > 0 +ORDER BY t_etablissements.code"|ETS +1|t_filiere|Filière|"SELECT t_filiere.oid, + t_filiere.code, + t_filiere.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_filiere + LEFT JOIN rh.p_oids ON (t_filiere.oid = p_oids.oid AND code_table = 'filiere') +WHERE t_filiere.oid > 0 +ORDER BY t_filiere.code"|FIL +1|t_liste_formations|Liste des formations|"SELECT t_liste_formations.oid, + t_liste_formations.code, + t_liste_formations.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_liste_formations + LEFT JOIN rh.p_oids ON (t_liste_visites.oid = p_oids.oid AND code_table = 'liste_formations') +WHERE t_liste_formations.oid > 0 +ORDER BY t_liste_formations.code"|FOR +1|t_commission_paritaire|Groupe de commission paritaire|"SELECT t_commission_paritaire.oid, + t_commission_paritaire.code, + t_commission_paritaire.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_commission_paritaire + LEFT JOIN rh.p_oids ON (t_commission_paritaire.oid = p_oids.oid AND code_table = 'commission_paritaire') +WHERE t_commission_paritaire.oid > 0 +ORDER BY t_commission_paritaire.code"|GCP +1|t_groupes_cotisant|[DICT.RH.GROUPE_COTISANT]|"SELECT t_groupes_cotisant.oid, t_groupes_cotisant.code, t_groupes_cotisant.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_groupes_cotisant LEFT JOIN rh.p_oids ON (t_groupes_cotisant.oid = p_oids.oid AND code_table = 'groupes_cotisant') +WHERE t_groupes_cotisant.oid > 0 +ORDER BY t_groupes_cotisant.code"|GCT +1|t_grilles_groupes|[DICT.RH.GROUPE_GRILLE]|"SELECT t_grilles_groupes.oid, + t_grilles_groupes.code, + t_grilles_groupes.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_grilles_groupes + LEFT JOIN rh.p_oids ON (t_grilles_groupes.oid = p_oids.oid AND code_table = 'grilles_groupes') +WHERE t_grilles_groupes.oid > 0 +ORDER BY t_grilles_groupes.code"|GRG +1|t_grilles|[DICT.RH.GRILLE]|"SELECT t_grilles.oid, + t_grilles.code, + t_grilles.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_grilles + LEFT JOIN rh.p_oids ON (t_grilles.oid = p_oids.oid AND code_table = 'grilles') +WHERE t_grilles.oid > 0 +ORDER BY t_grilles.code"|GRI +1|t_lettre_budgetaire|Lettre Budgétaire|"SELECT t_lettre_budgetaire.oid, + t_lettre_budgetaire.code, + t_lettre_budgetaire.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_lettre_budgetaire + LEFT JOIN rh.p_oids ON (t_lettre_budgetaire.oid = p_oids.oid AND code_table = 'lettre_budgetaire') +WHERE t_lettre_budgetaire.oid > 0 +ORDER BY t_lettre_budgetaire.code"|LEB +1|t_motifs_arret|Motif [DICT.RH.ARRET_TRAVAIL#2]|"SELECT t_motifs_arret.oid, + t_motifs_arret.code, + t_motifs_arret.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_motifs_arret + LEFT JOIN rh.p_oids ON (t_motifs_arret.oid = p_oids.oid AND code_table = 'motifs_arret') +WHERE t_motifs_arret.oid > 0 +ORDER BY t_motifs_arret.code"|MOA +1|t_motifs_debut_contrat|[DICT.RH.MOTIF_DEBUT#1] [DICT.RH.CONTRAT#2]|"SELECT t_motifs_debut_contrat.oid, t_motifs_debut_contrat.code, t_motifs_debut_contrat.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_motifs_debut_contrat LEFT JOIN rh.p_oids ON (t_motifs_debut_contrat.oid = p_oids.oid AND code_table = 'motifs_debut_contrat') +WHERE t_motifs_debut_contrat.oid > 0 +ORDER BY t_motifs_debut_contrat.code"|MTD +1|t_motifs_fin_contrat|Motif fin [DICT.RH.CONTRAT#2]|"SELECT t_motifs_fin_contrat.oid, t_motifs_fin_contrat.code, t_motifs_fin_contrat.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_motifs_fin_contrat LEFT JOIN rh.p_oids ON (t_motifs_fin_contrat.oid = p_oids.oid AND code_table = 'motifs_fin_contrat') +WHERE t_motifs_fin_contrat.oid > 0 +ORDER BY t_motifs_fin_contrat.code"|MTF +1|t_motifs_visite|Motif visite médicale|"SELECT t_motifs_visite.oid, + t_motifs_visite.code, + t_motifs_visite.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_motifs_visite + LEFT JOIN rh.p_oids ON (t_motifs_visite.oid = p_oids.oid AND code_table = 'motifs_visite') +WHERE t_motifs_visite.oid > 0 +ORDER BY t_motifs_visite.code"|MVM +1|t_nationalites|Nationalité|"SELECT t_nationalites.oid, + t_nationalites.code, + t_nationalites.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_nationalites + LEFT JOIN rh.p_oids ON (t_nationalites.oid = p_oids.oid AND code_table = 'nationalites') +WHERE t_nationalites.oid > 0 +ORDER BY t_nationalites.code"|NAT +1|t_organismes_cotisation|[DICT.RH.ORGANISME_COTISATION]|"SELECT t_organismes_cotisation.oid, t_organismes_cotisation.code, t_organismes_cotisation.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_organismes_cotisation LEFT JOIN rh.p_oids ON (t_organismes_cotisation.oid = p_oids.oid AND code_table = 'organismes_cotisation') +WHERE t_organismes_cotisation.oid > 0 +ORDER BY t_organismes_cotisation.code"|ORC +1|t_planning_type_absence|Type d'absences (planning)|"SELECT t_planning_type_absence.oid, + t_planning_type_absence.code, + t_planning_type_absence.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_planning_type_absence + LEFT JOIN rh.p_oids ON (t_planning_type_absence.oid = p_oids.oid AND code_table = 'planning_type_absence') +WHERE t_planning_type_absence.oid > 0 +ORDER BY t_planning_type_absence.code"|PAB +1|t_planning_code_horaire|Code Horaire (planning)|"SELECT t_planning_code_horaire.oid, + t_planning_code_horaire.code, + t_planning_code_horaire.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_planning_code_horaire + LEFT JOIN rh.p_oids ON (t_planning_code_horaire.oid = p_oids.oid AND code_table = 'planning_code_horaire') +WHERE t_planning_code_horaire.oid > 0 +ORDER BY t_planning_code_horaire.code"|PCH +1|t_planning_niveau|[DICT.RH.NIVEAU#3]|"SELECT t_planning_niveau.oid, + t_planning_niveau.code, + t_planning_niveau.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_planning_niveau + LEFT JOIN rh.p_oids ON (t_planning_niveau.oid = p_oids.oid AND code_table = 't_planning_niveau') +WHERE t_planning_niveau.oid > 0 +ORDER BY t_planning_niveau.code"|PNI +1|t_population|Population|"SELECT t_population.oid, + t_population.code, + t_population.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_population + LEFT JOIN rh.p_oids ON (t_population.oid = p_oids.oid AND code_table = 'population') +WHERE t_population.oid > 0 +ORDER BY t_population.code"|POP +1|t_planning_qualification|Qualifications (planning)|"SELECT t_planning_qualification.oid, + t_planning_qualification.code, + t_planning_qualification.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_planning_qualification + LEFT JOIN rh.p_oids ON (t_planning_qualification.oid = p_oids.oid AND code_table = 'planning_qualification') +WHERE t_planning_qualification.oid > 0 +ORDER BY t_planning_qualification.code"|PQU +1|t_planning_service|Services (planning)|"SELECT t_planning_service.oid, + t_planning_service.code, + t_planning_service.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_planning_service + LEFT JOIN rh.p_oids ON (t_planning_service.oid = p_oids.oid AND code_table = 'planning_service') +WHERE t_planning_service.oid > 0 +ORDER BY t_planning_service.code"|PSE +1|t_qualifications|Qualification|"SELECT t_qualifications.oid, t_qualifications.code, t_qualifications.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_qualifications LEFT JOIN rh.p_oids ON (t_qualifications.oid = p_oids.oid AND code_table = 'qualifications') +WHERE t_qualifications.oid > 0 +ORDER BY t_qualifications.code"|QUA +1|t_rubriques|Rubrique|"SELECT t_rubriques.oid, t_rubriques.code, t_rubriques.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_rubriques LEFT JOIN rh.p_oids ON (t_rubriques.oid = p_oids.oid AND code_table = 'rubriques') +WHERE t_rubriques.oid > 0 +ORDER BY t_rubriques.code"|RUP +1|t_sections_analytiques|[DICT.RH.SECTION_ANA_CPT#1]|"SELECT t_sections_analytiques.oid, t_sections_analytiques.code, t_sections_analytiques.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_sections_analytiques LEFT JOIN rh.p_oids ON (t_sections_analytiques.oid = p_oids.oid AND code_table = 'sections_analytiques') +WHERE t_sections_analytiques.oid > 0 +ORDER BY t_sections_analytiques.code"|SAC +1|p_salaries|[DICT.RH.SALARIE]|"SELECT v_salaries_1.salarie_id AS oid, v_salaries_1.salarie_code AS code, v_salaries_1.salarie_texte || CASE WHEN date_fin_contrat < '20991231' THEN ' (' || date_fin_contrat || ')' ELSE '' END AS texte, qualification_texte || ' - '|| service_texte as complement, 'O'::text as utilise +FROM rh.v_salaries_1 +ORDER BY v_salaries_1.salarie_code"|SAL +1|t_sections_analytiques_paie|[DICT.RH.SECTION_ANA_PAIE#1]|"SELECT t_sections_analytiques_paie.oid, t_sections_analytiques_paie.code, t_sections_analytiques_paie.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_sections_analytiques_paie LEFT JOIN rh.p_oids ON (t_sections_analytiques_paie.oid = p_oids.oid AND code_table = 'sections_analytiques_paie') +WHERE t_sections_analytiques_paie.oid > 0 +ORDER BY t_sections_analytiques_paie.code"|SAP +1|t_services|[DICT.RH.SERVICE]|"SELECT t_services.oid, t_services.code, t_services.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_services LEFT JOIN rh.p_oids ON (t_services.oid = p_oids.oid AND code_table = 'services') +WHERE t_services.oid > 0 +ORDER BY t_services.code"|SER +1|t_specialites|Spécialité|"SELECT t_specialites.oid, t_specialites.code, t_specialites.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_specialites LEFT JOIN rh.p_oids ON (t_specialites.oid = p_oids.oid AND code_table = 'specialites') +WHERE t_specialites.oid > 0 +ORDER BY t_specialites.code"|SPE +1|t_statuts|[DICT.RH.STATUT]|"SELECT t_statuts.oid, + t_statuts.code, + t_statuts.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_statuts + LEFT JOIN rh.p_oids ON (t_statuts.oid = p_oids.oid AND code_table = 'statuts') +WHERE t_statuts.oid > 0 +ORDER BY t_statuts.code"|STA +1|t_types_contrat|[DICT.RH.TYPE_CONTRAT]|"SELECT t_types_contrat.oid, t_types_contrat.code, t_types_contrat.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_types_contrat LEFT JOIN rh.p_oids ON (t_types_contrat.oid = p_oids.oid AND code_table = 'types_contrat') +WHERE t_types_contrat.oid > 0 +ORDER BY t_types_contrat.code"|TCN +1|t_types_horaire|Type horaire|"SELECT t_types_horaire.oid, t_types_horaire.code, t_types_horaire.texte, ''::text as complement, CASE WHEN p_oids.oid IS NOT NULL THEN 'O' ELSE 'N' END as utilise +FROM rh.t_types_horaire LEFT JOIN rh.p_oids ON (t_types_horaire.oid = p_oids.oid AND code_table = 'types_horaire') +WHERE t_types_horaire.oid > 0 +ORDER BY t_types_horaire.code"|THO +1|t_types_temps_travail|Type temps travail|"SELECT t_types_temps_travail.oid, + t_types_temps_travail.code, + t_types_temps_travail.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_types_temps_travail + LEFT JOIN rh.p_oids ON (t_types_temps_travail.oid = p_oids.oid AND code_table = 'types_temps_travail') +WHERE t_types_temps_travail.oid > 0 +ORDER BY t_types_temps_travail.code"|TTT +1|t_unite_fonctionnelle|Unité fonctionnelle|"SELECT t_unite_fonctionnelle.oid, + t_unite_fonctionnelle.code, + t_unite_fonctionnelle.texte, + ''::text AS complement, + CASE + WHEN p_oids.oid IS NOT NULL THEN 'O' + ELSE 'N' + END AS utilise +FROM rh.t_unite_fonctionnelle + LEFT JOIN rh.p_oids ON (t_unite_fonctionnelle.oid = p_oids.oid AND code_table = 'unite_fonctionnelle') +WHERE t_unite_fonctionnelle.oid > 0 +ORDER BY t_unite_fonctionnelle.code"|UNF diff --git a/db/data2/dbdata_rh_t_rapports.csv b/db/data2/dbdata_rh_t_rapports.csv new file mode 100644 index 0000000..f37e8c5 --- /dev/null +++ b/db/data2/dbdata_rh_t_rapports.csv @@ -0,0 +1,6 @@ +oid|code|texte|is_cti|is_essentiel +1|CTI_ESS_10|RH-Paie|1|1 +1|CTI_ESS_11|Rémunérations|1|1 +1|CTI_PF_AGG|CTI Portfolio|1|1 +1|CTI_QUA|Qualité des données|1|0 +1|RH1|Rapport personnalisé RH|1|0 diff --git a/db/data2/dbdata_rh_t_rapports_rubriques.csv b/db/data2/dbdata_rh_t_rapports_rubriques.csv new file mode 100644 index 0000000..5e7edba --- /dev/null +++ b/db/data2/dbdata_rh_t_rapports_rubriques.csv @@ -0,0 +1,105 @@ +rapport_code|indicateur_code|numero_rubrique|rapport_id|indicateur_id|entete|output_format|width|entete_etendue|periode_reference|row_height|padding|font_size|font_weight|border_thickness|color|background_color|base_nationale|base_nationale_qualifiee|viewlink|viewlink_label|viewlink_param|picto_enabled|positif_is_good|indicateur_associe_id|indicateur_associe_code +CTI_ESS_10|CTINBJARRET|30|1|1|||0|| |22|10|12| |0| | |0|0|RH000008|Analyse par code emploi et salarié|GROUPBY=CEM&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_AGEMOY|12|1|1|||0|| |22|10|12| |0| | |0|0|RH000023|Pyramide des âges par Age et salarié.|GROUPBY=AGE&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_CDDSALP|11|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par type de contrat et catégorie socio-professionnelle|GROUPBY=TCN&GROUPBY_2=CSC&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_DBTCDD|21|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par spécialité et salarié|GROUPBY=SPE&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#LSCDD&VIEWTAB=2|1|1|0| +CTI_ESS_10|CTI_DBTCDI|20|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par type de temps de travail et salarié|GROUPBY=TTT&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_DUREEMOYARRETS|34|1|1|||0|| |22|10|12| |0| | |0|0|RH000008|Analyse par code sexe et salarié|GROUPBY=SEX&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#DTCTI_CDD&VIEWTAB=2|1|1|0| +CTI_ESS_10|CTI_EFF1ERJANV|7|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par spécialité|GROUPBY=SPE|1|1|0| +CTI_ESS_10|CTI_EFF31DEV|8|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par code emploi|GROUPBY=CEM|1|1|0| +CTI_ESS_10|CTI_EFFPERM|6|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par type de temps de travail|GROUPBY=TTT|1|1|0| +CTI_ESS_10|CTI_EMBMS25|9|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Salarié de mois de 25 ans par qualification et par salarié|GROUPBY=QUA&GROUPBY_2=SAL&AGE=IN&AGE_INT=&AGE_INT2=25&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_FINCNT|22|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par code emploi et salarié|GROUPBY=CEM&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_FINCNTCDD|24|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse des CDD par indice et salarié|GROUPBY=GRI&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#LSCDD&VIEWTAB=2|1|1|0| +CTI_ESS_10|CTI_FINCNTCDI|23|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse des CDI par code emploi et salarié|GROUPBY=CEM&GROUPBY_2=SAL&GROUPBY_TAB=TAB&TYPE_CONTRAT=#LSCDI&VIEWTAB=2|1|1|0| +CTI_ESS_10|CTI_NBARRET|26|1|1|||0|| |22|10|12| |0| | |0|0|RH000008|Analyse par catégorie socio-professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBARRETMOY|35|1|1|Nombre d'arrêts moyen (sur total des salariés)||0|Nombre d'arrêts moyen (sur total des salariés)| |22|10|12| |0| | |0|0|RH000008|Analyse par catégorie socio-professionnelle|GROUPBY=CSC|1|1|0| +CTI_ESS_10|CTI_NBARRET_ACT|29|1|1|Dont accident du travail||0|Dont accident du travail| |22|20|12| |0| | |0|0|RH000008|Analyse par spécialité et salarié|GROUPBY=SPE&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBARRET_MAL|27|1|1|Dont maladie||0|Dont maladie| |22|20|12| |0| | |0|0|RH000008|Analyse par motif d'arrêt et salarié|GROUPBY=MOA&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBARRET_MAT|28|1|1|Dont maternité||0|Dont maternité| |22|20|12| |0| | |0|0|RH000008|Analyse par service et salarié|GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBCNT|16|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par catégorie socio-professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBCONTRATCDD|18|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par service et salarié|GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBCONTRATCDI|17|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par qualification et salarié|GROUPBY=QUA&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBJARRET_ACT|33|1|1|Dont accident du travail||0|Dont accident du travail| |22|20|12| |0| | |0|0|RH000008|Analyse par tranche d'age du bilan social et salarié|GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBJARRET_MAL|31|1|1|Dont maladie||0|Dont maladie| |22|20|12| |0| | |0|0|RH000008|Analyse par indice et salarié|GROUPBY=GRI&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBJARRET_MAT|32|1|1|Dont maternité||0|Dont maternité| |22|20|12| |0| | |0|0|RH000008|Analyse par qualification et salarié|GROUPBY=QUA&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NBSALCNT|2|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par catégorie socio-professionnelle|GROUPBY=CSC|1|1|0| +CTI_ESS_10|CTI_NBSALCNTFR|14|1|1|||0|| |22|10|12| |0| | |0|0|RH000023|Analyse par tranche d'âge du bilan social|GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_NOUVSALS|3|1|1|||0|Nouveaux salariés| |22|10|12| |0| | |0|0|RH000003|Analyse par qualification|GROUPBY=QUA|1|1|0| +CTI_ESS_10|CTI_NVXCNT|19|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par type de contrat et salarié|GROUPBY=TCN&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_PCTFEMMECNT|13|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par classe d'âge du bilan social et salarié|GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_ROTATIONEMP|5|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par type de contrat et qualification|GROUPBY=TCN|1|1|0| +CTI_ESS_10|CTI_SAL60|10|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Salariés de 60 ans et + par qualification et par salarié|GROUPBY=QUA&GROUPBY_2=SAL&AGE=IN&AGE_INT=60&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_10|CTI_SALPARTISSP|4|1|1|||0|| |22|10|12| |0| | |0|0|RH000003|Analyse par service|GROUPBY=SER|1|1|0| +CTI_ESS_10|CTI_SEP|1|1|1|||0|Salariés| |26|0|14|bold |2|#9B59B6 |0xCCCCCC |0|0|||| | |0| +CTI_ESS_10|CTI_SEP|15|1|1|||0|Contrats| |26|0|14|bold |2|#9B59B6 |0xCCCCCC |0|0|||| | |0| +CTI_ESS_10|CTI_SEP|25|1|1|||0|Arrêts de travail| |26|0|14|bold |2|#9B59B6 |0xCCCCCC |0|0|||| | |0| +CTI_ESS_11|CTIAN|12|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par Type de contrat et salarié|GROUPBY=TCN&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTICOTPAT|16|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par rubrique de paie|GROUPBY=RUPCLS|1|1|0| +CTI_ESS_11|CTICOTSAL |14|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par salarié|GROUPBY=SAL|1|1|0| +CTI_ESS_11|CTIETPTHM|6|1|1|ETP Travaillé||0|ETP Travaillé| |22|10|12| |0| | |0|0|RH000007|Analyse par spécialité|GROUPBY=SPE|0|0|0| +CTI_ESS_11|CTIHP|3|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par catégorie socio-professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTIHT|4|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par qualification|GROUPBY=QUA|1|1|0| +CTI_ESS_11|CTIMASSMOY|9|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par catégorie socio-professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTIMTMASSE|8|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par catégorie socio-professionnelle|GROUPBY=CSC|1|1|0| +CTI_ESS_11|CTINETAPAYER|18|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par catégorie socio-professionnelle et type de contrat bilan social|GROUPBY=CSC&GROUPBY_2=TCNCLS9|1|1|0| +CTI_ESS_11|CTINETIMPOS|17|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par type de temps de travail et salarié|GROUPBY=TTT&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTIODNET|15|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par contrat et section analytique comptable|GROUPBY=CNT&GROUPBY_2=SAC&GROUPBY_TAB=ARB|1|1|0| +CTI_ESS_11|CTI_BRUTMOYENETP|11|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par service et salarié|GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTI_ETPREMMOY|5|1|1|ETP Payé||0|ETP Payé| |22|10|12| |0| | |0|0|RH000007|Analyse par service|GROUPBY=SER|1|1|0| +CTI_ESS_11|CTI_FRIMPOS|13|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par spécialité et salarié|GROUPBY=SPE&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTI_MHMC|20|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par age bilan social et salarié|GROUPBY=AGECLS09&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTI_MTBRUT|10|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Analyse par qualification et salarié|GROUPBY=QUA&GROUPBY_2=SAL&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTI_MT_CNT|27|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Rupture de contrat par service et salarié|GROUPBY=SER&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_CNT|1|1|0| +CTI_ESS_11|CTI_MT_IJ|29|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|IJSS par service et salarié|GROUPBY=SER&GROUPBY_2=SAL&GROUPBY_TAB=TAB&RUBRIQUE=#LICTI_EXP_IJS|1|1|0| +CTI_ESS_11|CTI_MT_PRE|25|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Précarité par service et salarié|GROUPBY=SER&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_PRE&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTI_MT_RET|23|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Départ à la retraite par service et salarié|GROUPBY=SER&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_RET|1|1|0| +CTI_ESS_11|CTI_NBIJSS|28|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|IJSS par catégorie socio-professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&GROUPBY_TAB=TAB&RUBRIQUE=#LICTI_EXP_IJS|1|1|0| +CTI_ESS_11|CTI_NBRUPT|26|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Rupture de contrat par catégorie socio-professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_CNT|1|1|0| +CTI_ESS_11|CTI_NBSAL|2|1|1|Nombre de salariés||0|Nombre de salariés| |22|10|12| |0| | |0|0|RH000007|Analyse par catégorie socio-professionnelle|GROUPBY=CSC|1|1|0| +CTI_ESS_11|CTI_NB_PRE|24|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Précarité par catégorie socio-professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_PRE&GROUPBY_TAB=TAB|1|1|0| +CTI_ESS_11|CTI_NB_RET|22|1|1|||0|| |22|10|12| |0| | |0|0|RH000007|Départ à la retraite par catégorie socio--professionnelle et salarié|GROUPBY=CSC&GROUPBY_2=SAL&RUBRIQUE=#LICTI_EXP_RET|1|1|0| +CTI_ESS_11|CTI_SALCHGMOY|19|1|1|Net à Payer Moyen||0|Net à Payer Moyen| |22|10|12| |0| | |0|0|RH000007|Analyse par catégorie socio-professionnelle et type de temps de travail|GROUPBY=CSC&GROUPBY_2=TTTCLS9|1|1|0| +CTI_ESS_11|CTI_SEP|1|1|1|||0|Historique de Paie| |26|0|14|bold |2|#9B59B6 |0xcccccc |0|0|||| | |0| +CTI_ESS_11|CTI_SEP|7|1|1|||0|Masse Salariale| |26|0|14|bold |0|#9B59B6 |0xcccccc |0|0|||| | |0| +CTI_ESS_11|CTI_SEP|21|1|1|||0|Evènements exceptionnels| |26|0|14|bold |2|#9B59B6 |0xcccccc |0|0|||| | |0| +CTI_QUA|CTI_CEM|12|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_CPO|7|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_CSP|13|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_DNA|4|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_GCO|20|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_GGR|21|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_GRI|22|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_MDD|10|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_MDF|11|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_NAT|5|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_NBSALCNT|1|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_QUA|14|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_SAC|24|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_SAP|23|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_SEP|2|1|1|||0|Salarié| |0|0|12|bold |0|0xffffff |0x2c3e50 |0|0|||| | |0| +CTI_QUA|CTI_SEP|8|1|1|||0|Contrat| |0|0|0|bold |0|0xffffff |0x2c3e50 |0|0|||| | |0| +CTI_QUA|CTI_SER|15|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_SEX|3|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_SFA|6|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_SIN|25|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_SPE|16|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_STA|17|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_TCNT|9|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_THO|19|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +CTI_QUA|CTI_TTT|18|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +RH1|CTIHP|6|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTIMASSMOY|12|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTINBHOMME|1|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTINBJARRET|8|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTITA|14|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTITB|15|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTI_ETPW|5|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTI_MTBRUT|13|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTI_NBARRET|7|1|1|||0|| |0|0|0| |0| | |0|0||||0|0|0| +RH1|CTI_NBCNT|3|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTI_NBFEMMEPAIE|2|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTI_PCDD|10|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTI_PCDI|11|1|1|||0|| |0|0|0|normal |0| | |0|0||||0|0|0| +RH1|CTI_SEP|4|1|1|||0|| |0|0|0|normal |0| | |0|0|||| | |0| +RH1|CTI_SEP|9|1|1|||0|| |0|0|0|normal |0| | |0|0|||| | |0| diff --git a/db/data2/dbdata_rh_t_vue_parametre.csv b/db/data2/dbdata_rh_t_vue_parametre.csv new file mode 100644 index 0000000..a0172f8 --- /dev/null +++ b/db/data2/dbdata_rh_t_vue_parametre.csv @@ -0,0 +1,10 @@ +oid|code|texte|data_code|data_entete|data_format|data_description|position_ratio|rang +1|BS_LDATA_2|CTI : Bilan social|NSAL@CNTTOT@NCDI@NCDD@NSALH@NSALF@AGEMOYDJ@EFFPERM@0@0@0@0@0@0@0|Nombre Salariés@Contrats total@Nombre CDI@Nombre CDD@Nombre hommes@Nombre Femmes@Age moyen@Effectif permanent|#@#@#@#@#@#@#,0@#|Nombre de salarié total@Nombre de contrat total@Nombre contrats CDI@Nombre contrats CDD@Nombre salariés hommes@Nombre salariés femmes@Age moyen@Salariés titulaires d'un CDI à temps complet et présents sur l'ensemble de la période.|000000000000000|0 +1|CT_LDATA_1|CTI : Effectif|NSAL@EFFPERM@ROTEMP@NSALH@NSALF@AGEMOYDJ@0@0@0@0@0@0@0@0@0|NB Salariées@Effectif permanent@Rotation de l'emploi@NB hommes@NB Femmes@Age moyen|#@#@#%@#@#@#,0|Nombre de salarié total@Salariés titulaires d'un CDI à temps complet et présents sur l'ensemble de la période.@(nb d'entrées Ets. + nb de sorties Ets.) / 2 / nb de [DICT.RH.SALARIE#4] en début de période * 100@Nombre salariés hommes@Nombre salariés femmes@Age moyen|000000000000000|0 +1|CT_LDATA_3|CTI : Contrat|NSAL@CNTTOT@NCDI@NCDD@CNTTERM@NHCNT@ETPTH@0@0@0@0@0@0@0@0|NB Salariées@Contrats total@Nombre CDI@Nombre CDD@Contrats terminés@Heures contrat@ETP contrat|#@#@#@#@#@#,00@#,00|Nombre de salarié total@Nombre de contrat total@Nombre contrats CDI@Nombre contrats CDD@Contrats terminés@Nombre heures contrat@ETP Contrat|000000000000000|0 +1|HP_LDATA_1|CTI : Livre de paie|NBSAL@MTMASSE@NBHP@NBHT@MTBRUT@MTCOTSALARIE@MTCOTPATRONALE@MTNETIMPOSABLE@MTNETAPAYER@0@0@0@0@0@0|NB Salariés@Masse sal.@Heures Payées@Heures Travaillées@Brut@Cot. Salariales@Cot. Patronales@Net imposable@Net à payer|#@#E@#h@#h@#E@#E@#E@#E@#E|Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@Heures issues de la rubrique de paie paramétrée comme «Heures payées» dans la table des rubriques.@Heures paramétrées comme «travaillées» OU heures payées - heures paramétrées comme «Heures non travaillées».@Montant BRUT@Montant Cotisations Salariales@Montant Cotisations Patronales@Montant Net Imposable@Montant Net à payer@0@0@0@0@0@0|000000000000000|0 +1|HP_LDATA_2|CTI : Livre de paie ( Avec nombre et base )|NBSAL@MTMASSE@NBHP@NBHT@MTBRUT@MTCOTSALARIE@MTCOTPATRONALE@MTNETIMPOSABLE@MTNETAPAYER@NOMBRE@BASE@0@0@0@0|NB Salariés@Masse sal.@Heures Payées@Heures Travaillées@Brut@Cot. Salariales@Cot. Patronales@Net imposable@Net à payer@Nombre@Base|#@#E@#h@#h@#E@#E@#E@#E@#E@#,0@#,0|Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@Heures issues de la rubrique de paie paramétrée comme «Heures payées» dans la table des rubriques.@Heures paramétrées comme «travaillées» OU heures payées - heures paramétrées comme «Heures non travaillées».@Montant BRUT@Montant Cotisations Salariales@Montant Cotisations Patronales@Montant Net Imposable@Montant Net à payer@Nombre@Base@0@0@0@0|000000000000000|0 +1|HP_LDATA_3|CTI : Décomposition Masse Salariale|NBSAL@MTMASSE@MTMASSEMOY@NBHP@MTBRUT@MTBRUTMOY@MTBRUTAVANTAGE@MTFRAISIMPOS@MTCOTPATRONALE@MTODNETPATRONALE@MTHORMOYCHAR@0@0@0@0|NB Salariés@Masse sal.@Masse sal. moyen@Heures Payées@Brut@Brut moyen@A. N.@F.I.@Cot. Patronales@OD/NET Patronales@Mnt h. moy. chargé|#@#E@#E@#h@#E@#E@#E@#E@#E@#E@#,0E|Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@(Masse salariale ÷ ETP payé) ÷ Nb mois de la période.@Heures issues de la rubrique de paie paramétrée comme «Heures payées» dans la table des rubriques.@Montant BRUT@Montant BRUT Moyen@Montant Avantages en nature@Montant Frais imposables@Montant Cotisations Patronales@Montant OD NET Patronales@Montant horaire moyen chargé@0@0@0@0|000000000000000|0 +1|HP_LDATA_4|CTI : Décomposition ETP|NBSAL@MTMASSE@MTMASSEMOY@NBETP@NBETPT@0@0@0@0@0@0@0@0@0@0|NB Salariés@Masse sal.@Masse sal. moyen@ETP Rémunéré@ETP travaillé|#@#E@#E@#,00@#,00|Nombre de salarié @Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@(Masse salariale ÷ ETP payé) ÷ Nb mois de la période.@Equivalent temps plein basé sur les Heures payées. Heures payées ÷ Base de calcul de l'ETP (par défaut 151,67 h.) ÷ Nb mois de la période.@Equivalent temps plein basé sur les Heures travaillées. Heures travaillées ÷ Base de calcul de l'ETP (par défaut 151,67 h.) ÷ Nb mois de la période.@0@0@0@0@0@0@0@0@0@0|000000000000000|0 +1|HP_LDATA_5|CTI : Qualification|NBSAL@MTBRUT@MTCOTSALARIE@MTCOTPATRONALE@MTNETAPAYER@MTNETIMPOSABLE@MTMASSE@MTODNETSALARIE@0@0@0@0@0@0@0|NB Salariées@Montant Brut@Cotisations salariales@Cotisations patronales@Net à payer@Net imposable@Masse salariale@OD/net salariales|#@#@#@#@#@#@#@#|Nombre de salarié @Montant BRUT@Montant cotisations salariales@Montant cotisations patronales@Montant net à payer@Montant net imposable@Brut + Cotisations patronales + OD/Net patronales + Avantages en nature + Frais imposables@Montant OD/net salariales@0@0@0@0@0@0@0|000000000000000|0 +1|HP_LDATA_6|CTI : Brut / ETP Payé|NBSAL@MTBRUT@NBETP@0@0@0@0@0@0@0@0@0@0@0@0|NB Salariées@Montant Brut@ETP payé|#@#@#,00|Nombre de salarié @Montant BRUT@Equivalent temps plein basé sur les Heures payées Heures payées Base de calcul de l'ETP (par défaut 151,67 h.) Nb mois de la période.@0@0@0@0@0@0@0@0@0@0@0|000000000000000|0 diff --git a/db/data2/dbdata_rh_t_widget_user_parameter.csv b/db/data2/dbdata_rh_t_widget_user_parameter.csv new file mode 100644 index 0000000..5f64b50 --- /dev/null +++ b/db/data2/dbdata_rh_t_widget_user_parameter.csv @@ -0,0 +1,14 @@ +uuid|dashboard_widget_code|username|title|x|y|w|h|time_calc|visible|tab_code|max_cat|include_series_code +60a09a2f-1714-4903-8a48-e0c7c5d5597e|"CTI_EGAPRO|CTI_EFFAGE"|cti|Répartion par tranche d'âge|0|18|3|7|val|t|"CTI_EGAPRO|0"|0|{CTI_FEMMES,CTI_HOMMES} +2f166ff5-9eca-4a08-a72f-838cdc314385|"CTI_EGAPRO|CTI_EFFANC"|cti|Répartion par tranche d'ancienneté|3|18|3|7|val|t|"CTI_EGAPRO|0"|0|{CTI_FEMMES,CTI_HOMMES} +4629419f-a2c6-4627-86b3-786d03ec1db7|"CTI_EGAPRO|CTI_EFFGEN"|cti|Effectif |2|8|4|10|val|t|"CTI_EGAPRO|0"|0|{CTI_FEMMES,CTI_HOMMES} +54980aad-8b6b-43e5-8d86-b4b47d46ff66|"CTI_EGAPRO|CTI_EFFSTAT"|cti|Effectifs par statut|3|25|3|8|val|t|"CTI_EGAPRO|0"|0|{CTI_FEMMES,CTI_HOMMES} +fe63666a-69b0-4c35-8564-d243f605f520|"CTI_EGAPRO|CTI_ENTSORCAR"|cti|Hommes|0|8|2|5|val|t|"CTI_EGAPRO|0"|0|{CTI_DEPSALH,CTI_EFFDH,CTI_ENTSORH,CTI_NVSALH,CTI_TOH} +591c31d9-cf2a-4b9d-afd3-3605a476fc29|"CTI_EGAPRO|CTI_ENTSORCAR"|cti|Femmes|0|13|2|5|val|t|"CTI_EGAPRO|0"|0|{CTI_DEPSALF,CTI_EFFDF,CTI_ENTSORF,CTI_NVSALF,CTI_TOF} +da27e182-48ea-4c44-b874-4d3b860c875f|"CTI_EGAPRO|CTI_MSAGE"|cti|Masse salariale par tranche age|0|0|6|9|val|t|"CTI_EGAPRO|1"|0|{CTI_MSF,CTI_MSH} +8230cb17-4b23-4f64-b513-c1f20d8d91f0|"CTI_EGAPRO|CTI_MSCSP"|cti|Masse salariale par CSP|3|9|3|13|val|t|"CTI_EGAPRO|1"|0|{CTI_MSF,CTI_MSH} +7506a3e7-1b44-41e9-8727-e9fb1af75441|"CTI_EGAPRO|CTI_MSCSPMAP"|cti|Masse salariale par CSP (MAP)|0|9|3|13|val|t|"CTI_EGAPRO|1"|0|{CTI_MS} +1736e926-d668-4375-b042-95299d51b67c|"CTI_EGAPRO|CTI_STAT"|cti|Tableau statuts|4|0|2|8|val|t|"CTI_EGAPRO|0"|0|{CTI_FEMMES,CTI_HOMMES,CTI_TOTSAL} +1bf148e8-996a-4e64-b2b4-df19575c3368|"CTI_EGAPRO|CTI_STATTIME"|cti|Statuts|0|25|3|8|cum|t|"CTI_EGAPRO|0"|0|{CTI_TAUXSTAT,CTI_TOTSAL,CTI_TOTSALF} +732c7aad-a075-4ed8-a0b6-7a378af82d81|"CTI_EGAPRO|CTI_TYPECNT"|cti|Types de contrats - Femmes|0|0|2|8|val|t|"CTI_EGAPRO|0"|0|{CTI_FEMMES} +ac7b3909-8d3a-497e-9996-3b1111ded80e|"CTI_EGAPRO|CTI_TYPECNT"|cti|Types de contrats - Hommes|2|0|2|8|val|t|"CTI_EGAPRO|0"|0|{CTI_HOMMES} diff --git a/db/dbsetup_data_rh.XML b/db/dbsetup_data_rh.XML new file mode 100644 index 0000000..2b3eaf9 --- /dev/null +++ b/db/dbsetup_data_rh.XML @@ -0,0 +1,1496 @@ + + + + +
+
+
+
+
+ + +
+ +
+ + + +
+ + + +
+ + + 0 AND name NOT IN (SELECT name FROM rh.t_listes_tables) + ; + + ]]> +
+ + + +
+ + + '' GROUP BY 1 HAVING count(*) > 1 + ) subview + WHERE t_indicateurs.code = subview.code AND t_indicateurs.oid <> subview.minoid + ; + + UPDATE rh.t_indicateurs SET + texte = w_dbsetup.texte, + table_name = w_dbsetup.table_name, + column_name = w_dbsetup.column_name, + is_cti = w_dbsetup.is_cti, + entete = w_dbsetup.entete, + entete_etendue = w_dbsetup.entete_etendue, + total_function = w_dbsetup.total_function, + output_format = w_dbsetup.output_format, + width = w_dbsetup.width, + dimension_date_1 = w_dbsetup.dimension_date_1, + dimension_date_2 = w_dbsetup.dimension_date_2, + dimension_date_3 = w_dbsetup.dimension_date_3, + dimension_date_4 = w_dbsetup.dimension_date_4, + dimension_date_5 = w_dbsetup.dimension_date_5, + dimension_date = w_dbsetup.dimension_date + FROM w_dbsetup + WHERE t_indicateurs.code = w_dbsetup.code + ; + + INSERT INTO rh.t_indicateurs(texte, table_name, column_name, is_cti, entete, entete_etendue, code, total_function, output_format, width, + dimension_date_1, dimension_date_2, dimension_date_3, dimension_date_4, dimension_date_5, dimension_date) + SELECT texte, table_name, column_name, is_cti, entete, entete_etendue, code, total_function, output_format, width, + dimension_date_1, dimension_date_2, dimension_date_3, dimension_date_4, dimension_date_5, dimension_date + FROM w_dbsetup WHERE oid <> 0 AND code NOT IN (SELECT code FROM rh.t_indicateurs WHERE code IS NOT NULL) + ; + + UPDATE rh.t_indicateurs SET + indicateur_associe_1_id = COALESCE(t_indicateurs_1.oid,0), + indicateur_associe_2_id = COALESCE(t_indicateurs_2.oid,0), + indicateur_associe_3_id = COALESCE(t_indicateurs_3.oid,0), + indicateur_associe_4_id = COALESCE(t_indicateurs_4.oid,0), + indicateur_associe_5_id = COALESCE(t_indicateurs_5.oid,0), + indicateur_associe_6_id = COALESCE(t_indicateurs_6.oid,0), + indicateur_associe_7_id = COALESCE(t_indicateurs_7.oid,0), + indicateur_associe_8_id = COALESCE(t_indicateurs_8.oid,0), + indicateur_associe_9_id = COALESCE(t_indicateurs_9.oid,0), + indicateur_associe_10_id = COALESCE(t_indicateurs_10.oid,0), + indicateur_associe_11_id = COALESCE(t_indicateurs_11.oid,0), + indicateur_associe_12_id = COALESCE(t_indicateurs_12.oid,0), + indicateur_associe_13_id = COALESCE(t_indicateurs_13.oid,0), + indicateur_associe_14_id = COALESCE(t_indicateurs_14.oid,0), + indicateur_associe_15_id = COALESCE(t_indicateurs_15.oid,0), + indicateur_associe_16_id = COALESCE(t_indicateurs_16.oid,0), + indicateur_associe_17_id = COALESCE(t_indicateurs_17.oid,0), + indicateur_associe_18_id = COALESCE(t_indicateurs_18.oid,0), + indicateur_associe_19_id = COALESCE(t_indicateurs_19.oid,0), + indicateur_associe_20_id = COALESCE(t_indicateurs_20.oid,0), + indicateur_reference_id = COALESCE(t_indicateurs_reference.oid,0) + FROM w_dbsetup + LEFT JOIN rh.t_indicateurs t_indicateurs_1 ON (w_dbsetup.indicateur_associe_1_code = t_indicateurs_1.code AND w_dbsetup.indicateur_associe_1_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_2 ON (w_dbsetup.indicateur_associe_2_code = t_indicateurs_2.code AND w_dbsetup.indicateur_associe_2_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_3 ON (w_dbsetup.indicateur_associe_3_code = t_indicateurs_3.code AND w_dbsetup.indicateur_associe_3_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_4 ON (w_dbsetup.indicateur_associe_4_code = t_indicateurs_4.code AND w_dbsetup.indicateur_associe_4_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_5 ON (w_dbsetup.indicateur_associe_5_code = t_indicateurs_5.code AND w_dbsetup.indicateur_associe_5_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_6 ON (w_dbsetup.indicateur_associe_6_code = t_indicateurs_6.code AND w_dbsetup.indicateur_associe_6_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_7 ON (w_dbsetup.indicateur_associe_7_code = t_indicateurs_7.code AND w_dbsetup.indicateur_associe_7_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_8 ON (w_dbsetup.indicateur_associe_8_code = t_indicateurs_8.code AND w_dbsetup.indicateur_associe_8_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_9 ON (w_dbsetup.indicateur_associe_9_code = t_indicateurs_9.code AND w_dbsetup.indicateur_associe_9_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_10 ON (w_dbsetup.indicateur_associe_10_code = t_indicateurs_10.code AND w_dbsetup.indicateur_associe_10_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_11 ON (w_dbsetup.indicateur_associe_11_code = t_indicateurs_11.code AND w_dbsetup.indicateur_associe_11_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_12 ON (w_dbsetup.indicateur_associe_12_code = t_indicateurs_12.code AND w_dbsetup.indicateur_associe_12_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_13 ON (w_dbsetup.indicateur_associe_13_code = t_indicateurs_13.code AND w_dbsetup.indicateur_associe_13_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_14 ON (w_dbsetup.indicateur_associe_14_code = t_indicateurs_14.code AND w_dbsetup.indicateur_associe_14_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_15 ON (w_dbsetup.indicateur_associe_15_code = t_indicateurs_15.code AND w_dbsetup.indicateur_associe_15_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_16 ON (w_dbsetup.indicateur_associe_16_code = t_indicateurs_16.code AND w_dbsetup.indicateur_associe_16_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_17 ON (w_dbsetup.indicateur_associe_17_code = t_indicateurs_17.code AND w_dbsetup.indicateur_associe_17_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_18 ON (w_dbsetup.indicateur_associe_18_code = t_indicateurs_18.code AND w_dbsetup.indicateur_associe_18_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_19 ON (w_dbsetup.indicateur_associe_19_code = t_indicateurs_19.code AND w_dbsetup.indicateur_associe_19_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_20 ON (w_dbsetup.indicateur_associe_20_code = t_indicateurs_20.code AND w_dbsetup.indicateur_associe_20_code <> '') + LEFT JOIN rh.t_indicateurs t_indicateurs_reference ON (w_dbsetup.indicateur_reference_code = t_indicateurs_reference.code AND w_dbsetup.indicateur_reference_code <> '') + WHERE t_indicateurs.code = w_dbsetup.code + AND (indicateur_associe_1_code <> '' OR + indicateur_associe_2_code <> '' OR + indicateur_associe_3_code <> '' OR + indicateur_reference_code <> '') + ; + + SELECT base.cti_reorganize_indicateurs('rh') + ; + + ]]> +
+ + + 0 AND code NOT IN (SELECT code FROM rh.t_rapports) + ; + + ]]> +
+ + '' + AND t_rapports.is_cti = '1' + ORDER BY t_rapports.code, ind1.code, t_rapports_rubriques.numero_rubrique + ; + + ]]> + '' OR + w_specific_rapports_rubriques.specific_viewlink_label <> '' OR + w_specific_rapports_rubriques.specific_viewlink_param <> '' + ) + ; + ]]> +
+ + '' AND + (is_cti = '1' OR t_classes.code ilike 'CTI_%') AND is_cti = '1' + ORDER BY 1,2; + + ]]> + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + +
+ + + >'pos' as bigint) as position, + cast(jsonb_array_elements(replace('[' || serie_id || ']', '|', ',')::jsonb)->>'id' as bigint) as id + FROM rh.t_indicateur_serie + ORDER BY oid, position + ), + + flatCodes as (SELECT + flatSeries.oid, + array_agg(position::text || ':' || t_indicateur_serie.code::text) as codes + FROM flatSeries + LEFT JOIN rh.t_indicateur_serie on t_indicateur_serie.oid = id + GROUP BY 1) + + SELECT + t_indicateur_serie.code, + coalesce(t_indicateurs.code, '') as indicateur_code, + t_indicateur_serie.name, + t_indicateur_serie.color, + t_indicateur_serie.formula, + t_indicateur_serie.calc, + t_indicateur_serie.total, + t_indicateur_serie.format, + case when array_agg(DISTINCT t_indicateur_condition.external_code2) = ARRAY[null] then ARRAY[]::text[] else array_agg(DISTINCT t_indicateur_condition.external_code2) end as external_code2, + CASE WHEN flatCodes.codes = ARRAY[null] THEN '{}'::text[] ELSE flatCodes.codes::text[] END as serie_code + FROM rh.t_indicateur_serie + LEFT JOIN rh.t_indicateurs ON t_indicateurs.oid = indicateur_id + LEFT JOIN rh.t_indicateur_condition ON ARRAY[t_indicateur_condition.oid] <@ t_indicateur_serie.condition_id + LEFT JOIN flatCodes on flatCodes.oid = t_indicateur_serie.oid + GROUP BY 1,2,3,4,5,6,7,8, flatCodes.codes + ORDER BY 2,1; + + ]]> + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + 0 + AND rh.t_expert_controle.code = w_dbsetup.code + AND + ( + t_expert_controle.texte IS DISTINCT FROM w_dbsetup.texte OR + t_expert_controle.description IS DISTINCT FROM w_dbsetup.description OR + t_expert_controle.is_cti IS DISTINCT FROM w_dbsetup.is_cti OR + t_expert_controle.gravite_id IS DISTINCT FROM w_dbsetup.gravite_id OR + t_expert_controle.start_periode IS DISTINCT FROM w_dbsetup.start_periode + ) + ; + + INSERT INTO rh.t_expert_controle( + oid, + code, + texte, + description, + is_active, + is_hide, + alerte_id, + is_cti, + gravite_id, + start_periode + ) + SELECT + oid, + code, + texte, + description, + '1' AS is_active, + '0' AS is_hide, + 0::bigint AS alerte_id, + is_cti, + gravite_id, + start_periode + FROM w_dbsetup + WHERE 1=1 + AND w_dbsetup.oid = 0 + AND w_dbsetup.oid NOT IN (SELECT oid FROM rh.t_expert_controle) + ; + + INSERT INTO rh.t_expert_controle( + code, + texte, + description, + is_active, + is_hide, + alerte_id, + is_cti, + gravite_id, + start_periode + ) + SELECT + code, + texte, + description, + '1' AS is_active, + '0' AS is_hide, + 0::bigint AS alerte_id, + is_cti, + gravite_id, + start_periode + FROM w_dbsetup + WHERE 1=1 + AND w_dbsetup.oid <> 0 + AND w_dbsetup.code NOT IN (SELECT code FROM rh.t_expert_controle) + ; + + + ]]> +
+ + + 0 AND + t_expert_controle.is_cti = '1' + ORDER BY t_expert_controle.code, + t_indicateurs.code, + t_indicateur_condition_1.code, + t_indicateur_condition_2.code, + t_indicateur_condition_3.code + + ; + + ]]> + 0 + ; + + + ]]> +
+
diff --git a/db/dvp_data_apply.bat b/db/dvp_data_apply.bat new file mode 100644 index 0000000..03e79ff --- /dev/null +++ b/db/dvp_data_apply.bat @@ -0,0 +1,4 @@ +@ECHO Off +ECHO /!\ VOUS ETES SUR LE POINT DE PERDRE LES DONNEES DE VOTRE BASE /!\ +PAUSE +..\..\..\Sources\db\data\iCTI_svn_data_apply.exe -m rh \ No newline at end of file diff --git a/db/dvp_data_extract.bat b/db/dvp_data_extract.bat new file mode 100644 index 0000000..c0f836c --- /dev/null +++ b/db/dvp_data_extract.bat @@ -0,0 +1,2 @@ +@ECHO Off +..\..\..\Sources\db\data\iCTI_svn_data_extract.exe -m rh \ No newline at end of file diff --git a/db/expertDetailLevel.yaml b/db/expertDetailLevel.yaml new file mode 100644 index 0000000..b109eb8 --- /dev/null +++ b/db/expertDetailLevel.yaml @@ -0,0 +1,4 @@ +contrat: Contrat (item) +paie: Historique de Paie (item) +salarie: Salarie (item) +ITMTAB: Table normale Item \ No newline at end of file diff --git a/db/hooks/install_db_last_jobs.sql b/db/hooks/install_db_last_jobs.sql new file mode 100644 index 0000000..d3c5629 --- /dev/null +++ b/db/hooks/install_db_last_jobs.sql @@ -0,0 +1,10 @@ +-- ============================================================ +-- Derniers traitements +-- - Lancement de fonctions PGSQL +-- - Nettoyage installdb (éventuel) +-- ============================================================ + + +-- CrÈation des vues de ventilation de la paie; +SELECT rh.cti_hp_create_views() +; \ No newline at end of file diff --git a/db/hooks/post_install_data.sql b/db/hooks/post_install_data.sql new file mode 100644 index 0000000..2b499e5 --- /dev/null +++ b/db/hooks/post_install_data.sql @@ -0,0 +1,792 @@ +-- ===================================================================== +-- Divers traitements sur les données après l'installation des données +-- ===================================================================== + +-- Pas d'utilisation du masquage des indicateurs. +-- Forçage de l'affichage. +UPDATE rh.t_indicateurs +SET is_hide = 0 +; + +-- Initialisation du paramétre de rubrique "Heures payées" à 0. +UPDATE rh.t_rubriques +SET heures_payees = '0' +WHERE heures_payees IS NULL +; + +-- Initialisation des coefficients base/tx salarial/txpatronal lorsque null +UPDATE rh.t_rubriques +SET coefficient_base = 1 +WHERE coefficient_base IS NULL +; + +UPDATE rh.t_rubriques +SET coefficient_txs = 1 +WHERE coefficient_txs IS NULL +; + +UPDATE rh.t_rubriques +SET coefficient_txp = 1 +WHERE coefficient_txp IS NULL +; + +-- Initialisation du nombre d'heures mensuelles servant de base au calcul de l'ETP. +UPDATE rh.t_etablissements +SET base_calcul_etp = 151.67 +WHERE 1!=1 + OR base_calcul_etp IS NULL + OR base_calcul_etp = 0.0 +; + +-- Ajout des paramétrages. +DROP TABLE IF EXISTS w_divers +; +CREATE TEMP TABLE w_divers AS +SELECT + 'OCTIME_TPS_VALIDE' as code, + 'Compteur à utiliser pour le temps validé (5 ou 6).' as texte, + '5' as valeur, + NULL::date as valeur_date, + 'Compteur à utiliser pour le temps validé (5 ou 6).' as description +UNION +SELECT + 'OCTIME_TPS_VALIDE_A' as code, + 'Ajuster le temps validé.' as texte, + '0' as valeur, + NULL::date as valeur_date, + 'Ajuster le temps validé (0 désactivé par défaut).' as description +UNION +SELECT + 'OCTIME_VENTILATION', + 'Ventilation analytique Octime (0 désactivé).', + '0', + NULL::date, + 'Ventilation analytique Octime (0 désactivé).' +UNION +SELECT + 'OCTIME_SERVICE_ID', + 'Provenance du service Octime.', + '2', + NULL::date, + 'Provenance du service Octime.' +UNION +-- Paramétrage permettant de définir la provenance de la notion d'établissement Octime. +-- 0 = Manuel +-- 1-3 = niveaux Octime +-- 4 = cas Fondation Hopale où l'ent/ets est un préfixe du matricule. +SELECT + 'OCTIME_ETS_ID', + 'Provenance de l''établissement Octime.', + '0', + NULL::date, + 'Provenance de l''établissement Octime.' +UNION +-- Code établissement saisi à la main lorsque OCTIME_ETS_ID = 0. +-- Doit correspondre à t_entreprises.planning_code||t_etablissements.planning_code. +SELECT + 'OCTIME_ETS_MANUEL', + 'Code de l''établissement lorsque OCTIME_ETS_ID = 0.', + '', + NULL::date, + 'Code de l''établissement lorsque OCTIME_ETS_ID = 0' +UNION +SELECT + 'OCTIME_SALARIE', + 'Méthode de rapprochement salariés paie/planning.', + '1', + NULL::date, + 'Méthode de rapprochement salariés paie/planning.' +UNION +SELECT + 'OCTIME_INTERIM_STR', + 'Stratégie d''identification des intérimaires.', + '0', + NULL::date, + 'Stratégie d''identification des intérimaires.' +UNION +SELECT + 'OCTIME_INTERIM_PREFIXE', + 'Préfixe à ajouter aux matricules intérimaire.', + '', + NULL::date, + 'Préfixe à ajouter aux matricules intérimaire.' +UNION +SELECT + 'OCTIME_OLDMAT_PREFIXE', + 'Préfixe à ajouter aux matricules de l''ancien prestataire.', + '', + NULL::date, + 'Préfixe à ajouter aux matricules de l''ancien prestataire.' +UNION +SELECT + 'OCTIME_MAX_NIVEAU', + 'Niveau Octime maximum à importer.', + '3', + NULL::date, + 'Niveau Octime maximum à importer (3 par défaut, 4 maximum).' +UNION +SELECT + 'INTERIM_CNT_CODE', + 'Code du type de contrat intérim planning.', + 'INT', + NULL::date, + 'Code du type de contrat intérim planning.' +UNION +SELECT + 'IMP_EXC_MAR', + 'Exclusion de motifs d''arrêt lors de l''import.', + '', + NULL::date, + 'Exclure des motifs d''arrêt lors de l''import' +UNION +SELECT + 'IMP_INC_MAR', + 'Inclusion de motifs d''arrêt lors de l''import.', + '', + NULL::date, + 'Séparer les codes par des virgules.' +UNION +SELECT + 'OPT_STD_HP', + 'Historique de paie classique ou paramétré.', + '0', + NULL::date, + 'Historique de paie classique ou paramétré.' +UNION +SELECT + 'OPT_INTERIM_PLANNING', + 'Remonter les intérimaires depuis le planning.', + '0', + NULL::date, + 'Remonter les intérimaires depuis le planning.' +UNION +SELECT + 'OPT_HP_UP', + 'Historique de paie màj (pour fusion).', + '0', + NULL::date, + 'Historique de paie màj (pour fusion).' +UNION +SELECT + 'OPT_CNT_FIN_FUSION', + 'Fusion des contrats consécutifs ayant le(s) motif(s) de fin paramétré(s) ici.', + '', + NULL::date, + 'Vide (défaut) : pas de fusion. Un ou plusieurs motifs (séparés par des virgules) : activé.' +UNION +SELECT + 'OPT_VENT_PAIE', + 'Remonter la ventilation de paie.', + '1', + NULL::date, + '0 : pas de ventilation. 1 (défaut) : activé.' +UNION +SELECT + 'HEURES_W', + 'Heures Travaillées.', + '0', + NULL::date, + 'Calcul des Heures Travaillées (0 = Heures Payées - Heures NON Travaillées, 1 = Heures Travaillées)' +UNION +SELECT + 'SIGEMS_AUTO', + 'Sigems - Auto-détection du paramétrage des rubriques selon le compte.', + '0', + NULL::date, + '0 = Non (par défaut), 1 = Oui (stratégie 1), N = futures stratégies...' +UNION +SELECT + 'SIGEMS_TS', + 'Sigems - Taxe sur les Salaires.', + '0', + NULL::date, + 'Intégration de la Taxe sur les Salaires (0 = Non, 1 = Oui)' +UNION +SELECT + 'SAGE_STATUT', + 'Sage - Statut iCTI.', + 'CATEGORIE', + NULL::date, + 'Le statut iCTI doit être pris de la zone Sage "Catégorie" (CATEGORIE) ou "Niveau" (NIVEAU)' +UNION +SELECT + 'SAGE_GRILLE', + 'Sage - Grille iCTI.', + 'UNITE', + NULL::date, + 'La grille iCTI doit être prise de la zone Sage "Unité" (UNITE) ou "Coefficient" (COEFFICIENT)' +UNION +SELECT + 'SAGE_QUALIFICATION', + 'Sage - Qualification iCTI.', + 'UNITE', + NULL::date, + 'La qualification iCTI doit être pris de la zone Sage "Unité" (UNITE), "Département" (DEPARTEMENT), "Qualification" (QUALIFICATION) ou "Emploi" (EMPLOI)' +UNION +SELECT + 'SAGE_EMPLOI', + 'Sage - Code emploi iCTI.', + 'EMPLOI', + NULL::date, + 'Le code emploi iCTI doit être pris de la zone Sage "Emploi" (EMPLOI) ou "Qualification" (QUALIFICATION)' +UNION +SELECT + 'SAGE_TYPE_HORAIRE', + 'Sage - Type d''horaire iCTI.', + 'VALEURCUMUL_81', + NULL::date, + 'Le type d''horaire iCTI doit être pris de la zone Sage "Valeur cumul 81" (VALEURCUMUL_81) ou "Unité" (UNITE)' +UNION +SELECT + 'SAGE_SERVICE', + 'Sage - Service iCTI.', + 'SERVICE', + NULL::date, + 'Le service iCTI doit être pris de la zone Sage "Service" (SERVICE) ou "Département" (DEPARTEMENT)' +UNION +SELECT + 'SAGE_TEMPS_TRAVAIL', + 'Sage - Type de temps de travail.', + 'ETP', + NULL::date, + 'Privilégier l''ETP (ETP) ou l''Horaire (HORAIRE)' +UNION +SELECT + 'CEGID_SERVICE', + 'Cegid - Colonne où prendre les services iCTI.', + '3', + NULL::date, + '1, 2 ou 3 (déf.).' +UNION +SELECT + 'CEGID_TYPE_CONTRAT', + 'Cegid - Colonne où prendre les types de contrat iCTI.', + '1', + NULL::date, + '1 (déf.), 2, 3 ou 4.' +UNION +SELECT + 'CEGID_GRILLE', + 'Cegid - Colonne où prendre les grilles iCTI.', + 'GRILLE', + NULL::date, + 'GRILLE (déf.) ou QUALIFICATION.' +UNION +SELECT + 'CEGID_QUALIFICATION', + 'Cegid - Colonne où prendre les qualifications iCTI.', + 'QUALIFICATION', + NULL::date, + 'QUALIFICATION (déf.) ou EMPLOI.' +UNION +SELECT + 'CEGID_MOTIF_FIN', + 'Cegid - Colonne où prendre les motifs de fin iCTI.', + '0', + NULL::date, + 'O (déf.) ou 1.' +UNION +SELECT + 'CEGID_STATUT', + 'Cegid - Colonne où prendre les statuts iCTI.', + 'DADSCAT', + NULL::date, + 'DADSCAT (déf.), DADSPROF ou INDICE.' +UNION +SELECT + 'CEGI_CST_FJ', + 'Constante CEGI codant pour les Forfaits Jours', + 'DADSH', + NULL::date, + 'DADSH (défaut) ou autre.' +UNION +SELECT + 'CEGI_CODE_TTT', + 'Type de temps de travail tiré de la constante CEGI AAAAC', + 'AAAAC', + NULL::date, + 'AAAAC (défaut), AARM ou autre.' +UNION +SELECT + 'CEGI_SEXE', + 'Cegi - Code sexe masculin.', + '1', + NULL::date, + '1 par défaut (2 ou 3 sinon).' +UNION +SELECT + 'CEGI_GRILLE', + 'Cegi - Colonne où prendre les grilles iCTI.', + 'ECHELON', + NULL::date, + 'ECHELON (déf.) ou GRILLE.' +UNION +SELECT + 'CEGID_GRP_GRILLE', + 'Cegi - Colonne où prendre les groupes de grille iCTI.', + 'COEFF', + NULL::date, + 'COEFF (déf.), IND ou BUL.' +UNION +SELECT + 'CEGID_GRP_GRILLE_CST', + 'Cegi - Constante de paie où prendre le coefficient (CEGID_GRP_GRILLE = BUL).', + '54', + NULL::date, + '54 (déf.) ou autre constante de paie.' +UNION +SELECT + 'CEGI_QUALIFICATION', + 'Cegi - Colonne où prendre les qualifications iCTI.', + 'QUALCONV', + NULL::date, + 'QUALCONV (déf.), QUALIFICATION.' +UNION +SELECT + 'CEGI_CODE_EMPLOI', + 'Cegi - Colonne où prendre les codes emplois iCTI.', + 'MODCNT', + NULL::date, + 'MODCNT (déf.), QUALIFICATION.' +UNION +SELECT + 'CEGI_STATUT', + 'Cegi - Colonne où prendre les statuts iCTI.', + 'CATSOC', + NULL::date, + 'CATSOC (déf.), GRILLE.' +UNION +SELECT + 'CEGI_SITE_SERVICE', + 'Cegi Planning - Remonter la notion de site (=établissement).', + '0', + NULL::date, + '0 = non (par déf.), 1 = oui.' +UNION +SELECT + 'CEGI_ABS_VALIDE', + 'Cegi Planning - Remonter UNIQUEMENT les absences validées.', + '1', + NULL::date, + '1 = oui (par déf.), 0 = non.' +UNION +SELECT + 'CEGI_ABS_EXCL', + 'Cegi Planning - Codes absence à exclure.', + '', + NULL::date, + 'ex. : AMITH, JFCHO, ...' +UNION +SELECT + 'CEGI_PAUSE_EXCL', + 'Cegi Planning - Codes pauses à exclure.', + '', + NULL::date, + 'ex. : PAU, ...' +UNION +SELECT + 'CEGI_UNITE_HEURE', + 'Cegi Planning - Unités Cegi exprimées en heures.', + '102', + NULL::date, + '102 (par déf.), valeurs séparées par des virgules.' +UNION +SELECT + 'CEGI_FORFAIT_JOUR', + 'Alimenter la base de la rubrique 1052 de forfait jour à partir de AAAAC.', + '0', + NULL::date, + '0 (défaut) désactivé. Activé lorsqu''à 1.' +UNION +SELECT + 'CEGI_VENTILATION', + 'Remonter la ventilation analytique CEGI.', + '0', + NULL::date, + '0 (défaut) désactivé. Activé lorsqu''entre 1 et 3.' +UNION +SELECT + 'CEGI_TPA_ID', + 'Identifiant Cegi du plan analytique à remonter.', + '0', + NULL::date, + '0 (défaut) désactivé. Consulter la table prod_cegi.rhp_cmtyplana pour obtenir la valeur de TPA_ID.' +UNION +SELECT + 'SHS_ANCIENNETE', + 'SHS - Mode de calcul des anciennetés.', + '0', + NULL::date, + 'SHS - 0 = reprise du calcul SHS (défaut), 1 = calcul effectué par iCTI.' +UNION +SELECT + 'SHS_MOTIF', + 'SHS - Utiliser la précision à la place du motif d''arrêt.', + '0', + NULL::date, + 'Utiliser la précision à la place du motif d''arrêt (0 = Non par défaut, 1 = Oui)' +UNION +SELECT + 'PAIE_VENTILATION', + 'Remonter la ventilation analytique de paie.', + '0', + NULL::date, + '0 (défaut) désactivé. Activé lorsqu''entre 1 et 3.' +UNION +SELECT + 'PEGASE_VEN_PROV', + 'Provenance de la ventilation PEGASE.', + '1', + NULL::date, + 'Onglet n°1 par défaut. Peut être 2, 3 ou plus selon les établissements.' +UNION +SELECT + 'BS_CLA_AGE', + 'Classe d''âges du Bilan Social.', + 'CTI_AGE', + NULL::date, + 'Classe d''âges du Bilan Social.' +UNION +SELECT + 'BS_CLA_ANC', + 'Classe d''anciennetés du Bilan Social.', + 'CTI_ANC', + NULL::date, + 'Classe d''anciennetés du Bilan Social.' +UNION +SELECT + 'FUSION_STRATEGIE', + 'Stratégie de rapprochement des matricules ancien/nouveau prestataire.', + '0', + NULL::date, + 'Stratégie de rapprochement des matricules ancien/nouveau prestataire.' +UNION +SELECT + 'FUSION_IGNORE_ARRETS', + 'Ignorer les arrêts de travail lors d''une fusion.', + '0', + NULL::date, + 'Ignorer les arrêts de travail lors d''une fusion.' +UNION +SELECT + 'EXERCICE_DECALE', + 'L''exercice de paie commence au mois de janvier (0) ou décembre (1).', + '0', + NULL::date, + 'L''exercice de paie commence au mois de janvier (0) ou décembre (1).' +UNION +SELECT + 'CORRECTION_DE_ETS', + 'Corriger la date d''entrée établissement en se basant sur la date de début du premier contrat.', + '0', + NULL::date, + 'Corriger la date d''entrée établissement en se basant sur la date de début du premier contrat.' +UNION +SELECT + 'CORRECTION_DS_ETS', + 'Corriger la date de sortie établissement en se basant sur la date de fin du dernier contrat.', + '0', + NULL::date, + 'Corriger la date de sortie établissement en se basant sur la date de fin du dernier contrat.' +UNION +SELECT + 'VENTIL_JOUR', + 'Ventilation par jour', + '0', + NULL::date, + '(0) garder la ventilation du prestataire (1) Ventiler par jour (césure à minuit)' +UNION +SELECT + 'AGILETIME_PAUSE', + 'Id code(s) heure(s) de pause Agiletime', + '21,27', + NULL::date, + 'Définition du ou des id correspondant à des heures de pause à retrancher séparés par , sans espaces' +UNION +SELECT + 'AGILETIME_TODEL', + 'Id du code heure à ne pas prendre en compte', + '15', + NULL::date, + 'Définition du ou des id correspondant à des heures de pause à ignorer séparés par , sans espaces' +UNION +SELECT + 'QUALIF_ASSOC', + 'Association automatique des qualifications paie/planning', + '2', + NULL::date, + '0: désactivé, 1: code, 2:texte, 3:les deux' +UNION +SELECT + 'SERVICE_ASSOC', + 'Association automatique des services paie/planning', + '2', + NULL::date, + '0: désactivé, 1: code, 2:texte, 3:les deux' +UNION +SELECT + 'SENSPARAMETRE_CLASSE', + 'Sens consolidation classes/listes.', + '0', + NULL::date, + '0: désactivé, M: Montant, D: Descendant' +UNION +SELECT + 'OPT_IMP_QUALIF', + 'Option d''import de la Qualification', + '0', + NULL::date, + '0: valeur par défaut, 1: mise à jour du code et du texte' +UNION +SELECT + 'FUSIONSALARIE', + 'Fusion des salariés', + '0', + NULL::date, + '1 = Fusion des salariés activée' +UNION +SELECT + 'FUSIONENTREESALARIE', + 'Fusion des dates entrées salariés (quelque soit entreprise)', + '0', + NULL::date, + '1 = Fusion des dates entrée salariés activée' +UNION +SELECT + 'EXPERT_ACTIVE', + 'Contrôles EXPERT activés', + '1', + NULL::date, + '1=Activé' +UNION +SELECT + 'EIG_SERVICE', + 'Provenance du service EIG', + '0', + NULL::date, + '0: Service, 1: Section contrat, 2: Section contrat - Service' +UNION +SELECT + 'EIG_ETABLISSEMENT', + 'Provenance de l''établissement EIG', + '1', + NULL::date, + '0: Bulletin, 1: Contrat, 2: Personne' +UNION +SELECT + 'ADP_TYPE_CONTRAT', + 'Colonne pour type de contrat ', + '0', + NULL::date, + '0: Nature du contrat (cnlcnt), 1: Type de contrat (lnmcnt)' +UNION +SELECT + 'ADP_SERVICE_COLUMN', + 'Colonne pour service', + 'SACAFF', + NULL::date, + 'SACAFF, SACAFFEC01, SACAFFEC02, SACAFFEC05 (dft)' +UNION +SELECT + 'CEGI_PLANNING_FORCE_TYPE_HORAIRE_ABSENCE', + 'Cegi Planning - Pour forcer des codes de types horaires en temps d''absence', + '', + NULL::date, + 'Valeurs séparées par des virgules' +UNION +SELECT + 'CPP_COEF_VALORISATION_INTERIM', + 'Coefficient de valorisation des moyennes salariales pour les intérimaires', + '1.20', + NULL::date, + 'Coefficient de valorisation des moyennes salariales pour les intérimaires' +UNION +SELECT + 'CPP_JOUR_DEBUT_MOIS_PAIE', + 'Croisement Paie Planning : Date du premier jour d''affectation de la paie', + '1', + NULL::date, + 'Croisement Paie Planning : Date du premier jour d''affectation de la paie' +UNION +SELECT + 'CEGI_PLANNING_ABSENCE_HEURE', + 'Cegi Planning - Codes d''absences dont l''unité de temps utilisée est l''heure', + '', + NULL::date, + 'Valeurs séparées par des virgules' +UNION +SELECT + 'CEGI_PLANNING_TYPE_HORAIRE_TEMPS_VALIDE_VERS_TEMPS_DU', + 'Cegi Planning - Codes de types horaires à transférer du temps_validé vers le temps_du', + '', + NULL::date, + 'Valeurs séparées par des virgules' +; + +INSERT INTO rh.t_divers( + code, + texte, + valeur, + valeur_date, + description) +SELECT + code, + texte, + valeur, + valeur_date, + description +FROM w_divers +WHERE code NOT IN (SELECT code FROM rh.t_divers) +; + +UPDATE rh.t_divers SET + texte = w_divers.texte, + description = w_divers.description + FROM w_divers +WHERE 1=1 + AND t_divers.code = w_divers.code + AND (1!=1 + OR t_divers.texte != w_divers.texte + OR t_divers.description != w_divers.description) +; + +-- Màj du paramétre par défaut CEGID_STATUT qui passe de DADS à DADSCAT. +UPDATE rh.t_divers SET + valeur = 'DADSCAT' +WHERE 1=1 + AND code = 'CEGID_STATUT' + AND valeur = 'DADS' +; + +-- Maintenance de ce qui existe en prod (SALARIE_CORR => OCTIME_SALARIE). +UPDATE rh.t_divers +SET valeur = (SELECT valeur FROM rh.t_divers WHERE code = 'SALARIE_CORR') +WHERE 1=1 + AND code = 'OCTIME_SALARIE' + AND (SELECT count(*) FROM rh.t_divers WHERE code = 'SALARIE_CORR') > 0 +; + +DELETE FROM rh.t_divers +WHERE code = 'SALARIE_CORR' +; + +-- Création d'une liste CTI de rubrique(s) à paramétrer permettant d'identifier d'eventuelles rubriques d'heures contrat. +DROP TABLE IF EXISTS w_dbsetup +; + +CREATE TEMP TABLE w_dbsetup (oid text, texte text,chapitre text,code text, is_cti text, contenu_by_code text, include_code text, exclude_code text, show_omit text, utilisateur_createur text, est_partagee_modification text,table_code text) +; + +INSERT INTO w_dbsetup +VALUES('0', + 'Heures contrat', + 'Paramétrage', + 'CTI_HCNT', + '1', + '0', + '', + '', + '0', + '', + '1', + 'RUP') +; + +UPDATE rh.t_listes SET + texte = w_dbsetup.texte, + chapitre = w_dbsetup.chapitre, + table_id = t_listes_tables.oid, + is_cti = w_dbsetup.is_cti, + show_omit = w_dbsetup.show_omit, + contenu_by_code = w_dbsetup.contenu_by_code, + include_code = w_dbsetup.include_code, + exclude_code = w_dbsetup.exclude_code, + utilisateur_createur = + CASE + WHEN t_listes.utilisateur_createur = '' OR w_dbsetup.est_partagee_modification <> '1' THEN w_dbsetup.utilisateur_createur + ELSE t_listes.utilisateur_createur + END, + est_partagee_modification = w_dbsetup.est_partagee_modification + FROM w_dbsetup, rh.t_listes_tables +WHERE true + AND w_dbsetup.table_code = t_listes_tables.code + AND t_listes.code = w_dbsetup.code +; + +INSERT INTO rh.t_listes(code, texte, chapitre, table_id, is_cti, show_omit, contenu_by_code, include_code, exclude_code, utilisateur_createur, est_partagee_modification) +SELECT w_dbsetup.code, + w_dbsetup.texte, + w_dbsetup.chapitre, + t_listes_tables.oid, + w_dbsetup.is_cti, + w_dbsetup.show_omit, + w_dbsetup.contenu_by_code, + w_dbsetup.include_code, + w_dbsetup.exclude_code, + w_dbsetup.utilisateur_createur, + w_dbsetup.est_partagee_modification +FROM w_dbsetup, + rh.t_listes_tables +WHERE true + AND w_dbsetup.table_code = t_listes_tables.code + AND w_dbsetup.code NOT IN (SELECT code FROM rh.t_listes) +; + +-- Initialisation du code cotisation pour un salarié. +UPDATE rh.p_salaries +SET code_cotisation_id = 0 +WHERE code_cotisation_id IS NULL +; + +UPDATE rh.p_historique_paie +SET compte_id = 0 +WHERE compte_id IS NULL +; + +-- Màj des établissements dans p_contrats_mois lorsque non renseigné lors de l'import. +-- Doit aussi être effectué dans le SHARE à l'issu de chaque import. +UPDATE rh.p_contrats_mois SET + etablissement_id = p_contrats.etablissement_id + FROM rh.p_contrats +WHERE 1=1 + AND p_contrats_mois.contrat_id = p_contrats.oid + AND p_contrats_mois.etablissement_id IS NULL +; + +-- Màj de l'établissement pour chaque ligne de paie lorsque non renseigné. +-- Doit aussi être effectué dans le SHARE à l'issu de chaque import. +UPDATE rh.p_historique_paie SET + etablissement_id = p_contrats_mois.etablissement_id + FROM rh.p_contrats_mois +WHERE 1=1 + AND p_historique_paie.contrat_mois_id = p_contrats_mois.oid + AND p_historique_paie.etablissement_id IS NULL +; + +-- Alimentation des anciennetés en jours lorsque non renseigné lors de l'import. +-- (365 + 365 + 365 + 366) / (12 * 4) = 30.4375 +UPDATE rh.p_contrats +SET anciennete_anterieure_jours = anciennete_anterieure_calculee_mois * 30.4375 +WHERE 1!=1 + OR anciennete_anterieure_jours = 0 + OR anciennete_anterieure_jours IS NULL +; + +UPDATE rh.p_contrats_mois +SET anciennete_jours = anciennete_mois * 30.4375 +WHERE 1!=1 + OR anciennete_jours = 0 + OR anciennete_jours IS NULL +; + +-- Correction sur les rapports Essentiels passés à is_hide = 1 par erreur. +UPDATE rh.t_rapports SET + is_hide = '0' +WHERE 1=1 + AND code IN ('CTI_ESS_10', 'CTI_ESS_11') + AND is_hide = '1' +; + +-- Les Handicaps sont désactivés +TRUNCATE rh.p_handicap +; \ No newline at end of file diff --git a/db/hooks/pre_install_data.sql b/db/hooks/pre_install_data.sql new file mode 100644 index 0000000..cbd7e4b --- /dev/null +++ b/db/hooks/pre_install_data.sql @@ -0,0 +1,3 @@ +-- ===================================================================== +-- Divers traitements sur les données avant l'installation des données +-- ===================================================================== \ No newline at end of file diff --git a/db/hooks/pre_install_schema.sql b/db/hooks/pre_install_schema.sql new file mode 100644 index 0000000..af03729 --- /dev/null +++ b/db/hooks/pre_install_schema.sql @@ -0,0 +1,8 @@ +-- ============================================= +-- Nettoyage de la BDD avant installation. +-- (Supprimer le contenu au bout de 3 mois) +-- - Suppression de tables +-- - Suppression de champs +-- - Suppression de vues/fonctions SQL +-- - Suppression ou modification de séquences +-- ============================================= \ No newline at end of file diff --git a/db/schema2/functions/cti_budget_execute_rules.yaml b/db/schema2/functions/cti_budget_execute_rules.yaml new file mode 100644 index 0000000..fd550d3 --- /dev/null +++ b/db/schema2/functions/cti_budget_execute_rules.yaml @@ -0,0 +1,219 @@ +return: text +lang: plpgsql +src: | + DECLARE + result TEXT; + _module_pmsimco TEXT; + BEGIN + + RAISE NOTICE '%' , 'Initialisation budget_cles'; + -- Contenu table + INSERT INTO rh.t_budget_cle (oid, code, texte, texte_court) + SELECT 0, '**', 'Non renseigné', 'Non renseigné' + WHERE 0 NOT IN (SELECT oid FROM rh.t_budget_cle); + + + -- Oids des sections de classe + DROP TABLE IF EXISTS w_classe_section_to_id; + CREATE TEMP TABLE w_classe_section_to_id AS + SELECT '[CLASSE:'||t_classes.code||':'||t_classes_sections.code||']' AS classe_section_code, to_id AS classe_section_to_id + FROM rh.t_classes + JOIN rh.t_classes_sections ON classe_id = t_classes.oid + JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid + WHERE t_classes.code <> '' + GROUP BY 1,2 + ; + + -- Traduction des règles en oid + RAISE NOTICE '%' , 'Application des regles. Traduction en oid'; + DROP TABLE IF EXISTS w_budget_cle_rule; + CREATE TEMP TABLE w_budget_cle_rule AS + SELECT + t_budget_cle_rule.oid, + budget_cle_id, + + priorite, + CASE WHEN liste_finess <> '' THEN '1' ELSE '0' END AS a_liste_finess, + string_to_array(translate(liste_finess,'*,','% '),' ') AS liste_finess, + NULL::bigint[] AS liste_finess_id , + + CASE WHEN liste_etablissement <> '' THEN '1' ELSE '0' END AS a_liste_etablissement, + string_to_array(translate(liste_etablissement,'*,','% '),' ') AS liste_etablissement, + NULL::bigint[] AS liste_etablissement_id , + + CASE WHEN liste_service <> '' THEN '1' ELSE '0' END AS a_liste_service, + string_to_array(translate(liste_service,'*,','% '),' ') AS liste_service, + NULL::bigint[] AS liste_service_id , + + CASE WHEN liste_specialite <> '' THEN '1' ELSE '0' END AS a_liste_specialite, + string_to_array(translate(liste_specialite,'*,','% '),' ') AS liste_specialite, + NULL::bigint[] AS liste_specialite_id , + + CASE WHEN liste_section_analytique <> '' THEN '1' ELSE '0' END AS a_liste_section_analytique, + string_to_array(translate(liste_section_analytique,'*,','% '),' ') AS liste_section_analytique, + NULL::bigint[] AS liste_section_analytique_id , + + CASE WHEN liste_section_analytique_paie <> '' THEN '1' ELSE '0' END AS a_liste_section_analytique_paie, + string_to_array(translate(liste_section_analytique_paie,'*,','% '),' ') AS liste_section_analytique_paie, + NULL::bigint[] AS liste_section_analytique_paie_id , + + CASE WHEN liste_qualification <> '' THEN '1' ELSE '0' END AS a_liste_qualification, + string_to_array(translate(liste_qualification,'*,','% '),' ') AS liste_qualification, + NULL::bigint[] AS liste_qualification_id , + + CASE WHEN liste_grille <> '' THEN '1' ELSE '0' END AS a_liste_grille, + string_to_array(translate(liste_grille,'*,','% '),' ') AS liste_grille, + NULL::bigint[] AS liste_grille_id , + + CASE WHEN liste_code_emploi <> '' THEN '1' ELSE '0' END AS a_liste_code_emploi, + string_to_array(translate(liste_code_emploi,'*,','% '),' ') AS liste_code_emploi, + NULL::bigint[] AS liste_code_emploi_id , + + CASE WHEN liste_categorie_socio_professionnelle <> '' THEN '1' ELSE '0' END AS a_liste_categorie_socio_professionnelle, + string_to_array(translate(liste_categorie_socio_professionnelle,'*,','% '),' ') AS liste_categorie_socio_professionnelle, + NULL::bigint[] AS liste_categorie_socio_professionnelle_id + FROM rh.t_budget_cle_rule + JOIN rh.t_budget_cle ON budget_cle_id = t_budget_cle.oid + ORDER BY priorite, budget_cle_id; + + DELETE FROM w_budget_cle_rule + WHERE + (a_liste_finess::int + + a_liste_etablissement::int + + a_liste_service::int + + a_liste_specialite::int + + a_liste_section_analytique::int + + a_liste_section_analytique_paie::int + + a_liste_qualification::int + + a_liste_grille::int + + a_liste_code_emploi::int + + a_liste_categorie_socio_professionnelle::int) = 0 + ; + + UPDATE w_budget_cle_rule + SET liste_finess_id = (SELECT base.cti_group_array3(oid) FROM base.t_finess WHERE oid <> 0 AND code LIKE ANY (liste_finess)) + WHERE a_liste_finess = '1'; + + UPDATE w_budget_cle_rule + SET liste_etablissement_id = (SELECT base.cti_group_array3(oid) FROM rh.t_etablissements WHERE oid <> 0 AND code LIKE ANY (liste_etablissement)) + WHERE a_liste_etablissement = '1'; + + UPDATE w_budget_cle_rule + SET liste_service_id = (SELECT base.cti_group_array3(oid) FROM rh.t_services WHERE oid <> 0 AND code LIKE ANY (liste_service)) + WHERE a_liste_service = '1'; + + UPDATE w_budget_cle_rule + SET liste_specialite_id = (SELECT base.cti_group_array3(oid) FROM rh.t_specialites WHERE oid <> 0 AND code LIKE ANY (liste_specialite)) + WHERE a_liste_specialite = '1'; + + UPDATE w_budget_cle_rule + SET liste_section_analytique_id = (SELECT base.cti_group_array3(oid) FROM rh.t_sections_analytiques WHERE oid <> 0 AND code LIKE ANY (liste_section_analytique)) + WHERE a_liste_section_analytique = '1'; + + UPDATE w_budget_cle_rule + SET liste_section_analytique_paie_id = (SELECT base.cti_group_array3(oid) FROM rh.t_sections_analytiques_paie WHERE oid <> 0 AND code LIKE ANY (liste_section_analytique_paie)) + WHERE a_liste_section_analytique_paie = '1'; + + UPDATE w_budget_cle_rule + SET liste_qualification_id = (SELECT base.cti_group_array3(oid) FROM rh.t_qualifications WHERE oid <> 0 AND code LIKE ANY (liste_qualification)) + WHERE a_liste_qualification = '1'; + + UPDATE w_budget_cle_rule + SET liste_qualification_id = subview.liste_qualification_id + FROM + ( + SELECT w_budget_cle_rule.oid, + array_cat(MAX(liste_qualification_id),base.cti_group_array3(classe_section_to_id)) AS liste_qualification_id + FROM w_budget_cle_rule + JOIN w_classe_section_to_id ON classe_section_code = ANY(liste_qualification) + WHERE a_liste_qualification = '1' + GROUP BY 1 + ) subview + WHERE w_budget_cle_rule.oid = subview.oid + ; + + + UPDATE w_budget_cle_rule + SET liste_grille_id = (SELECT base.cti_group_array3(oid) FROM rh.t_grilles WHERE oid <> 0 AND code LIKE ANY (liste_grille)) + WHERE a_liste_grille = '1'; + + UPDATE w_budget_cle_rule + SET liste_code_emploi_id = (SELECT base.cti_group_array3(oid) FROM rh.t_codes_emploi WHERE oid <> 0 AND code LIKE ANY (liste_code_emploi)) + WHERE a_liste_code_emploi = '1'; + + UPDATE w_budget_cle_rule + SET liste_categorie_socio_professionnelle_id = (SELECT base.cti_group_array3(oid) FROM rh.t_categories_socio_professionnelle WHERE oid <> 0 AND code LIKE ANY (liste_categorie_socio_professionnelle)) + WHERE a_liste_categorie_socio_professionnelle = '1'; + + + RAISE NOTICE '%' , 'Application des regles.' + ; + DROP TABLE IF EXISTS w_profil_contrat_mois + ; + CREATE TEMP TABLE w_profil_contrat_mois AS + SELECT + p_profil_contrat_mois.oid, + COALESCE(MIN(priorite),999999999) AS budget_cle_priorite, + COALESCE((MIN(ARRAY[priorite,w_budget_cle_rule.budget_cle_id]))[2],0) AS budget_cle_id + FROM rh.p_profil_contrat_mois + JOIN rh.p_contrats_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.t_etablissements ON t_etablissements.oid = p_contrats_mois.etablissement_id + JOIN rh.p_profils ON p_profil_contrat_mois.profil_id = p_profils.oid + JOIN w_budget_cle_rule ON + (a_liste_finess = '0' OR finess_id = ANY (liste_finess_id)) AND + (a_liste_etablissement = '0' OR p_contrats_mois.etablissement_id = ANY (liste_etablissement_id)) AND + (a_liste_service = '0' OR p_profils.service_id = ANY (liste_service_id)) AND + (a_liste_specialite = '0' OR p_profils.specialite_id = ANY (liste_specialite_id)) AND + (a_liste_qualification = '0' OR p_profils.qualification_id = ANY (liste_qualification_id)) AND + (a_liste_section_analytique = '0' OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) AND + (a_liste_section_analytique_paie = '0' OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) AND + (a_liste_grille = '0' OR p_profils.grille_id = ANY (liste_grille_id)) AND + (a_liste_code_emploi = '0' OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) AND + (a_liste_categorie_socio_professionnelle = '0' OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + -- Pas de service planning. + WHERE + (a_liste_finess::int + + a_liste_etablissement::int + + a_liste_service::int + + a_liste_specialite::int + + a_liste_section_analytique::int + + a_liste_section_analytique_paie::int + + a_liste_qualification::int + + a_liste_grille::int + + a_liste_code_emploi::int + + a_liste_categorie_socio_professionnelle::int) > 0 + GROUP BY 1 + ORDER BY 2,1 + ; + + + RAISE NOTICE '%' , 'Application des regles. Validation des budget_cles'; + + UPDATE rh.p_profil_contrat_mois SET + budget_cle_id = w_profil_contrat_mois.budget_cle_id + FROM w_profil_contrat_mois + WHERE p_profil_contrat_mois.oid = w_profil_contrat_mois.oid AND + p_profil_contrat_mois.budget_cle_id IS DISTINCT FROM w_profil_contrat_mois.budget_cle_id + ; + + UPDATE rh.p_profil_contrat_mois SET + budget_cle_id = 0 + WHERE 1=1 + AND oid NOT IN (SELECT oid FROM w_profil_contrat_mois group by 1) + AND budget_cle_id IS DISTINCT FROM 0 + ; + + + + ANALYSE rh.p_profil_contrat_mois + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'budget_cle', budget_cle_id + FROM rh.p_profil_contrat_mois + WHERE budget_cle_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'budget_cle') + GROUP BY 2 + ; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_budget_generate_keys.yaml b/db/schema2/functions/cti_budget_generate_keys.yaml new file mode 100644 index 0000000..2834cad --- /dev/null +++ b/db/schema2/functions/cti_budget_generate_keys.yaml @@ -0,0 +1,19 @@ +return: text +lang: plpgsql +src: | + DECLARE + + + BEGIN + + -- Oid 0 = Non renseigné + INSERT INTO rh.t_budget_cle (oid, code, texte, texte_court) + SELECT + 0, '*NR', 'N/R', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_budget_cle) + ; + + + + RETURN 'OK' ; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_croisement_paie_planning_generate.yaml b/db/schema2/functions/cti_croisement_paie_planning_generate.yaml new file mode 100644 index 0000000..6fd5af1 --- /dev/null +++ b/db/schema2/functions/cti_croisement_paie_planning_generate.yaml @@ -0,0 +1,771 @@ +return: text +lang: plpgsql +src: | + DECLARE + min_month_to_get numeric; + closed_payroll_month numeric; + max_month_to_get numeric; + BEGIN + -- Date la plus ancienne à récupérer de la paie + min_month_to_get = (SELECT MIN(mois_paie) FROM rh.p_historique_paie); + + -- Date la plus récente à récupérer de la paie. Dernière paie cloturée + closed_payroll_month = (SELECT MAX(mois_paie) FROM rh.p_historique_paie); + + -- Pour l'instant, le calcul ne se fait que jusqu'au dernier mois de paie cloturé + max_month_to_get = closed_payroll_month; + + -- Vidage des tables + TRUNCATE rh.p_taux_horaires_mensuels; + TRUNCATE rh.p_croisement_paie_planning; + TRUNCATE rh.p_sommes_mensuelles_ventilees_paie; + TRUNCATE rh.p_sommes_mensuelles_ventilees_planning; + TRUNCATE rh.p_presence_salaries; + TRUNCATE rh.t_periode_paie; + + -- Génération des périodes de paie + DROP TABLE IF EXISTS periode_paie + ; + + CREATE TEMP TABLE periode_paie AS + SELECT + date AS date_debut, + ((date + interval '1 MONTH') - interval '1 DAY')::date AS date_fin, + (to_char(((date + interval '1 MONTH') - interval '1 DAY')::date, 'YYYYMM'))::int AS mois_paie + FROM base.p_calendrier + WHERE + date BETWEEN (SELECT MIN(p_historique_paie.date_debut) FROM rh.p_historique_paie) AND (SELECT MAX(p_historique_paie.date_fin) FROM rh.p_historique_paie) + AND date_part('DAY', date) = (SELECT valeur::numeric FROM rh.t_divers WHERE code = 'CPP_JOUR_DEBUT_MOIS_PAIE') + ORDER BY 1 + ; + + INSERT INTO rh.t_periode_paie ( + date_debut, + date_fin, + mois_paie + ) + SELECT + date_debut, + date_fin, + mois_paie + FROM periode_paie + ; + + -- Récupération des salariés présents en paie par mois + DROP TABLE IF EXISTS presence_histo_paie + ; + + CREATE TEMP TABLE presence_histo_paie AS + SELECT + p_historique_paie.salarie_id, + t_periode_paie.mois_paie + FROM rh.p_historique_paie + JOIN rh.t_periode_paie ON t_periode_paie.mois_paie = p_historique_paie.mois_paie + GROUP BY 1,2 + ; + + -- Récupération des salariés présents au planning par mois + DROP TABLE IF EXISTS presence_mouvements_planning + ; + + CREATE TEMP TABLE presence_mouvements_planning AS + SELECT + p_planning_mouvement.salarie_id, + t_periode_paie.mois_paie + FROM rh.p_planning_mouvement + JOIN rh.t_periode_paie ON true + WHERE p_planning_mouvement.date BETWEEN t_periode_paie.date_debut AND t_periode_paie.date_fin + GROUP BY 1,2 + ; + + -- Génération de la présence des salariés dans la paie et dans le planning par mois + DROP TABLE IF EXISTS presence_salaries + ; + + CREATE TEMP TABLE presence_salaries AS + SELECT + p_salaries.oid AS salarie_id, + t_periode_paie.mois_paie, + COUNT(presence_histo_paie.salarie_id) > 0 AS present_paie, + COUNT(presence_mouvements_planning.salarie_id) > 0 AS present_planning, + CASE WHEN p_salaries.matricule LIKE 'INTERIM-%' THEN true ELSE false END AS est_interimaire + FROM rh.p_salaries + JOIN rh.t_periode_paie ON true + LEFT JOIN presence_histo_paie ON + presence_histo_paie.salarie_id = p_salaries.oid AND + presence_histo_paie.mois_paie = t_periode_paie.mois_paie + LEFT JOIN presence_mouvements_planning ON + presence_mouvements_planning.salarie_id = p_salaries.oid AND + presence_mouvements_planning.mois_paie = t_periode_paie.mois_paie + GROUP BY 1,2 + ORDER BY 1,2 + ; + + + INSERT INTO rh.p_presence_salaries( + salarie_id, + mois_paie, + present_paie, + present_planning, + est_interimaire + ) + SELECT + salarie_id, + mois_paie, + present_paie, + present_planning, + est_interimaire + FROM presence_salaries + ; + + ANALYZE rh.p_presence_salaries + ; + + -- Aggrégation par salarié, mois, établissement, service et qualification des différents indicateurs de paie (montant_brut, montant_masse_salariale, etc) + DROP TABLE IF EXISTS sommes_mensuelles_ventilees_paie + ; + + CREATE TEMP TABLE sommes_mensuelles_ventilees_paie AS + SELECT + p_historique_paie.salarie_id, + p_historique_paie.mois_paie, + p_historique_paie.etablissement_id, + t_services.oid AS paie_service_id, + t_services.code AS paie_service_code, + t_services.texte AS paie_service_texte, + t_qualifications.oid AS paie_qualification_id, + t_qualifications.code AS paie_qualification_code, + t_qualifications.texte AS paie_qualification_texte, + sum(p_historique_paie.heure_contrat) AS heure_contrat, + sum(p_historique_paie.heure_payee) AS heure_payee, + sum(p_historique_paie.heure_travaillee) AS heure_travaillee, + sum(p_historique_paie.montant_brut) AS montant_brut, + sum(p_historique_paie.montant_masse_salariale) AS montant_masse_salariale, + sum(p_historique_paie.montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(p_historique_paie.montant_provisions) AS montant_provisions, + sum(p_historique_paie.montant_masse_salariale_provisionnee) AS montant_masse_salariale_provisionnee, + sum(base.cti_division(p_historique_paie.heure_contrat * p_profil_contrat_mois.ratio, t_etablissements.base_calcul_etp)) AS equivalent_temps_plein + FROM rh.p_historique_paie + JOIN rh.p_contrats_mois ON p_contrats_mois.oid = p_historique_paie.contrat_mois_id + JOIN rh.p_profils ON p_profils.oid = p_contrats_mois.profil_id + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid AND p_profil_contrat_mois.profil_id = p_contrats_mois.profil_id + JOIN rh.t_etablissements ON t_etablissements.oid = p_historique_paie.etablissement_id + JOIN rh.t_qualifications ON t_qualifications.oid = p_profils.qualification_id + JOIN rh.t_services ON t_services.oid = p_profils.service_id + WHERE p_historique_paie.mois_paie BETWEEN min_month_to_get AND closed_payroll_month + GROUP BY p_historique_paie.salarie_id, p_historique_paie.mois_paie, p_historique_paie.etablissement_id, t_services.oid, t_qualifications.oid + ; + + CREATE INDEX sommes_mensuelles_ventilees_paie_i1 ON sommes_mensuelles_ventilees_paie USING btree(salarie_id) + ; + + CREATE INDEX sommes_mensuelles_ventilees_paie_i2 ON sommes_mensuelles_ventilees_paie USING btree(mois_paie) + ; + + CREATE INDEX sommes_mensuelles_ventilees_paie_i3 ON sommes_mensuelles_ventilees_paie USING btree(etablissement_id) + ; + + ANALYZE sommes_mensuelles_ventilees_paie + ; + + -- Aggrégation par salarié et mois des différents indicateurs de paie (montant_brut, montant_masse_salariale, etc) + DROP TABLE IF EXISTS sommes_mensuelles_paie + ; + + CREATE TEMP TABLE sommes_mensuelles_paie AS + SELECT + salarie_id, + mois_paie, + sum(heure_contrat) AS heure_contrat, + sum(heure_payee) AS heure_payee, + sum(heure_travaillee) AS heure_travaillee, + sum(montant_brut) AS montant_brut, + sum(montant_masse_salariale) AS montant_masse_salariale, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_provisions) AS montant_provisions, + sum(montant_masse_salariale_provisionnee) AS montant_masse_salariale_provisionnee, + sum(equivalent_temps_plein) AS equivalent_temps_plein + FROM sommes_mensuelles_ventilees_paie + GROUP BY 1,2 + ; + + CREATE INDEX sommes_mensuelles_paie_i1 ON sommes_mensuelles_paie USING btree(salarie_id) + ; + + CREATE INDEX sommes_mensuelles_paie_i2 ON sommes_mensuelles_paie USING btree(mois_paie) + ; + + ANALYZE sommes_mensuelles_paie + ; + + -- Aggrégation par salarié, mois, établissement, service et qualification des différents indicateurs de planning (les 3 principaux indicateurs de temps : temps_du_initial, temps_du, temps_valide) + DROP TABLE IF EXISTS sommes_mensuelles_ventilees_planning + ; + + CREATE TEMP TABLE sommes_mensuelles_ventilees_planning AS + SELECT + p_planning_mouvement.salarie_id, + t_periode_paie.mois_paie, + p_planning_mouvement.etablissement_id, + t_planning_service.oid AS planning_service_id, + t_planning_service.code AS planning_service_code, + t_planning_service.texte AS planning_service_texte, + t_planning_qualification.oid AS planning_qualification_id, + t_planning_qualification.code AS planning_qualification_code, + t_planning_qualification.texte AS planning_qualification_texte, + sum(p_planning_mouvement.temps_du_initial) AS temps_du_initial, + sum(p_planning_mouvement.temps_du) AS temps_du, + sum(p_planning_mouvement.temps_valide) AS temps_valide + FROM rh.p_planning_mouvement + JOIN rh.t_periode_paie ON base.cti_overlaps(t_periode_paie.date_debut, t_periode_paie.date_fin, p_planning_mouvement.date, p_planning_mouvement.date) + LEFT JOIN rh.t_planning_service ON t_planning_service.oid = p_planning_mouvement.service_id + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.oid = p_planning_mouvement.qualification_id + WHERE p_planning_mouvement.mois BETWEEN min_month_to_get AND closed_payroll_month + GROUP BY p_planning_mouvement.salarie_id, t_periode_paie.mois_paie, p_planning_mouvement.etablissement_id, t_planning_service.oid, t_planning_service.code, t_planning_service.texte, t_planning_qualification.oid, t_planning_qualification.code, t_planning_qualification.texte + ; + + CREATE INDEX sommes_mensuelles_ventilees_planning_i1 ON sommes_mensuelles_ventilees_planning USING btree(salarie_id) + ; + + CREATE INDEX sommes_mensuelles_ventilees_planning_i2 ON sommes_mensuelles_ventilees_planning USING btree(mois_paie) + ; + + CREATE INDEX sommes_mensuelles_ventilees_planning_i3 ON sommes_mensuelles_ventilees_planning USING btree(etablissement_id) + ; + + ANALYZE sommes_mensuelles_ventilees_planning + ; + + -- Aggrégation par salarié, mois et établissement des différents indicateurs de planning (les 3 principaux indicateurs de temps : temps_du_initial, temps_du, temps_valide) + DROP TABLE IF EXISTS sommes_mensuelles_planning + ; + + CREATE TEMP TABLE sommes_mensuelles_planning AS + SELECT + salarie_id, + mois_paie, + etablissement_id, + sum(temps_du_initial) AS temps_du_initial, + sum(temps_du) AS temps_du, + sum(temps_valide) AS temps_valide + FROM sommes_mensuelles_ventilees_planning + GROUP BY 1,2,3 + ; + + CREATE INDEX sommes_mensuelles_planning_i1 ON sommes_mensuelles_planning USING btree(salarie_id) + ; + + CREATE INDEX sommes_mensuelles_planning_i2 ON sommes_mensuelles_planning USING btree(mois_paie) + ; + + CREATE INDEX sommes_mensuelles_planning_i3 ON sommes_mensuelles_planning USING btree(etablissement_id) + ; + + ANALYZE sommes_mensuelles_planning + ; + + INSERT INTO rh.p_sommes_mensuelles_ventilees_paie ( + salarie_id, + mois_paie, + etablissement_id, + paie_service_id, + paie_service_code, + paie_service_texte, + paie_qualification_id, + paie_qualification_code, + paie_qualification_texte, + heure_contrat, + heure_payee, + heure_travaillee, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_provisions, + montant_masse_salariale_provisionnee, + equivalent_temps_plein + ) + SELECT + salarie_id, + mois_paie, + etablissement_id, + paie_service_id, + paie_service_code, + paie_service_texte, + paie_qualification_id, + paie_qualification_code, + paie_qualification_texte, + heure_contrat, + heure_payee, + heure_travaillee, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_provisions, + montant_masse_salariale_provisionnee, + equivalent_temps_plein + FROM sommes_mensuelles_ventilees_paie + ; + + INSERT INTO rh.p_sommes_mensuelles_ventilees_planning ( + salarie_id, + mois_paie, + etablissement_id, + planning_service_id, + planning_service_code, + planning_service_texte, + planning_qualification_id, + planning_qualification_code, + planning_qualification_texte, + temps_du_initial, + temps_du, + temps_valide + ) + SELECT + salarie_id, + mois_paie, + etablissement_id, + planning_service_id, + planning_service_code, + planning_service_texte, + planning_qualification_id, + planning_qualification_code, + planning_qualification_texte, + temps_du_initial, + temps_du, + temps_valide + FROM sommes_mensuelles_ventilees_planning + ; + + -- Calcul du taux horaire mensuel pour chaque salarié + -- En rapport les différents indicateurs de paie (montant_brut, montant_masse_salariale, etc) au différents indicateur de planning (les 3 principaux indicateurs de temps : temps_du_initial, temps_du, temps_valide) + DROP TABLE IF EXISTS taux_horaires_mensuels + ; + + CREATE TEMP TABLE taux_horaires_mensuels AS + SELECT sommes_mensuelles_planning.salarie_id, + sommes_mensuelles_planning.mois_paie, + sommes_mensuelles_planning.temps_du_initial, + sommes_mensuelles_planning.temps_du, + sommes_mensuelles_planning.temps_valide, + sommes_mensuelles_paie.heure_contrat, + base.cti_division(sommes_mensuelles_paie.heure_contrat, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_heure_contrat_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.heure_contrat, sommes_mensuelles_planning.temps_du) AS taux_horaire_heure_contrat_temps_du, + base.cti_division(sommes_mensuelles_paie.heure_contrat, sommes_mensuelles_planning.temps_valide) AS taux_horaire_heure_contrat_temps_valide, + sommes_mensuelles_paie.heure_payee, + base.cti_division(sommes_mensuelles_paie.heure_payee, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_heure_payee_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.heure_payee, sommes_mensuelles_planning.temps_du) AS taux_horaire_heure_payee_temps_du, + base.cti_division(sommes_mensuelles_paie.heure_payee, sommes_mensuelles_planning.temps_valide) AS taux_horaire_heure_payee_temps_valide, + sommes_mensuelles_paie.heure_travaillee, + base.cti_division(sommes_mensuelles_paie.heure_travaillee, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_heure_travaillee_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.heure_travaillee, sommes_mensuelles_planning.temps_du) AS taux_horaire_heure_travaillee_temps_du, + base.cti_division(sommes_mensuelles_paie.heure_travaillee, sommes_mensuelles_planning.temps_valide) AS taux_horaire_heure_travaillee_temps_valide, + sommes_mensuelles_paie.montant_brut, + base.cti_division(sommes_mensuelles_paie.montant_brut, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_montant_brut_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.montant_brut, sommes_mensuelles_planning.temps_du) AS taux_horaire_montant_brut_temps_du, + base.cti_division(sommes_mensuelles_paie.montant_brut, sommes_mensuelles_planning.temps_valide) AS taux_horaire_montant_brut_temps_valide, + sommes_mensuelles_paie.montant_masse_salariale, + base.cti_division(sommes_mensuelles_paie.montant_masse_salariale, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_montant_masse_salariale_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.montant_masse_salariale, sommes_mensuelles_planning.temps_du) AS taux_horaire_montant_masse_salariale_temps_du, + base.cti_division(sommes_mensuelles_paie.montant_masse_salariale, sommes_mensuelles_planning.temps_valide) AS taux_horaire_montant_masse_salariale_temps_valide, + sommes_mensuelles_paie.montant_cotisation_patronale, + base.cti_division(sommes_mensuelles_paie.montant_cotisation_patronale, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_montant_cotisation_patronale_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.montant_cotisation_patronale, sommes_mensuelles_planning.temps_du) AS taux_horaire_montant_cotisation_patronale_temps_du, + base.cti_division(sommes_mensuelles_paie.montant_cotisation_patronale, sommes_mensuelles_planning.temps_valide) AS taux_horaire_montant_cotisation_patronale_temps_valide, + sommes_mensuelles_paie.montant_provisions, + base.cti_division(sommes_mensuelles_paie.montant_provisions, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_montant_provisions_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.montant_provisions, sommes_mensuelles_planning.temps_du) AS taux_horaire_montant_provisions_temps_du, + base.cti_division(sommes_mensuelles_paie.montant_provisions, sommes_mensuelles_planning.temps_valide) AS taux_horaire_montant_provisions_temps_valide, + sommes_mensuelles_paie.montant_masse_salariale_provisionnee, + base.cti_division(sommes_mensuelles_paie.montant_masse_salariale_provisionnee, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_montant_masse_salariale_provisionnee_temps_du_init, + base.cti_division(sommes_mensuelles_paie.montant_masse_salariale_provisionnee, sommes_mensuelles_planning.temps_du) AS taux_horaire_montant_masse_salariale_provisionnee_temps_du, + base.cti_division(sommes_mensuelles_paie.montant_masse_salariale_provisionnee, sommes_mensuelles_planning.temps_valide) AS taux_horaire_montant_masse_salariale_provisionnee_temps_valide, + sommes_mensuelles_paie.equivalent_temps_plein, + base.cti_division(sommes_mensuelles_paie.equivalent_temps_plein, sommes_mensuelles_planning.temps_du_initial) AS taux_horaire_equivalent_temps_plein_temps_du_initial, + base.cti_division(sommes_mensuelles_paie.equivalent_temps_plein, sommes_mensuelles_planning.temps_du) AS taux_horaire_equivalent_temps_plein_temps_du, + base.cti_division(sommes_mensuelles_paie.equivalent_temps_plein, sommes_mensuelles_planning.temps_valide) AS taux_horaire_equivalent_temps_plein_temps_valide + FROM rh.p_presence_salaries + JOIN sommes_mensuelles_planning ON + sommes_mensuelles_planning.salarie_id = p_presence_salaries.salarie_id AND + sommes_mensuelles_planning.mois_paie = p_presence_salaries.mois_paie + JOIN sommes_mensuelles_paie ON + sommes_mensuelles_paie.salarie_id = p_presence_salaries.salarie_id AND + sommes_mensuelles_paie.mois_paie = p_presence_salaries.mois_paie + WHERE p_presence_salaries.present_paie = true AND p_presence_salaries.present_planning = true AND p_presence_salaries.est_interimaire = false + ; + + CREATE INDEX taux_horaires_mensuels_i1 ON taux_horaires_mensuels USING btree(salarie_id) + ; + + CREATE INDEX taux_horaires_mensuels_i2 ON taux_horaires_mensuels USING btree(mois_paie) + ; + + ANALYZE taux_horaires_mensuels + ; + + INSERT INTO rh.p_taux_horaires_mensuels ( + salarie_id, + mois_paie, + temps_du_initial, + temps_du, + temps_valide, + heure_contrat, + taux_horaire_heure_contrat_temps_du_initial, + taux_horaire_heure_contrat_temps_du, + taux_horaire_heure_contrat_temps_valide, + heure_payee, + taux_horaire_heure_payee_temps_du_initial, + taux_horaire_heure_payee_temps_du, + taux_horaire_heure_payee_temps_valide, + heure_travaillee, + taux_horaire_heure_travaillee_temps_du_initial, + taux_horaire_heure_travaillee_temps_du, + taux_horaire_heure_travaillee_temps_valide, + montant_brut, + taux_horaire_montant_brut_temps_du_initial, + taux_horaire_montant_brut_temps_du, + taux_horaire_montant_brut_temps_valide, + montant_masse_salariale, + taux_horaire_montant_masse_salariale_temps_du_initial, + taux_horaire_montant_masse_salariale_temps_du, + taux_horaire_montant_masse_salariale_temps_valide, + montant_cotisation_patronale, + taux_horaire_montant_cotisation_patronale_temps_du_initial, + taux_horaire_montant_cotisation_patronale_temps_du, + taux_horaire_montant_cotisation_patronale_temps_valide, + montant_provisions, + taux_horaire_montant_provisions_temps_du_initial, + taux_horaire_montant_provisions_temps_du, + taux_horaire_montant_provisions_temps_valide, + montant_masse_salariale_provisionnee, + taux_horaire_montant_masse_salariale_provisionnee_temps_du_init, + taux_horaire_montant_masse_salariale_provisionnee_temps_du, + taux_horaire_montant_masse_salariale_provisionnee_temps_valide, + equivalent_temps_plein, + taux_horaire_equivalent_temps_plein_temps_du_initial, + taux_horaire_equivalent_temps_plein_temps_du, + taux_horaire_equivalent_temps_plein_temps_valide + ) + SELECT + salarie_id, + mois_paie, + temps_du_initial, + temps_du, + temps_valide, + heure_contrat, + taux_horaire_heure_contrat_temps_du_initial, + taux_horaire_heure_contrat_temps_du, + taux_horaire_heure_contrat_temps_valide, + heure_payee, + taux_horaire_heure_payee_temps_du_initial, + taux_horaire_heure_payee_temps_du, + taux_horaire_heure_payee_temps_valide, + heure_travaillee, + taux_horaire_heure_travaillee_temps_du_initial, + taux_horaire_heure_travaillee_temps_du, + taux_horaire_heure_travaillee_temps_valide, + montant_brut, + taux_horaire_montant_brut_temps_du_initial, + taux_horaire_montant_brut_temps_du, + taux_horaire_montant_brut_temps_valide, + montant_masse_salariale, + taux_horaire_montant_masse_salariale_temps_du_initial, + taux_horaire_montant_masse_salariale_temps_du, + taux_horaire_montant_masse_salariale_temps_valide, + montant_cotisation_patronale, + taux_horaire_montant_cotisation_patronale_temps_du_initial, + taux_horaire_montant_cotisation_patronale_temps_du, + taux_horaire_montant_cotisation_patronale_temps_valide, + montant_provisions, + taux_horaire_montant_provisions_temps_du_initial, + taux_horaire_montant_provisions_temps_du, + taux_horaire_montant_provisions_temps_valide, + montant_masse_salariale_provisionnee, + taux_horaire_montant_masse_salariale_provisionnee_temps_du_init, + taux_horaire_montant_masse_salariale_provisionnee_temps_du, + taux_horaire_montant_masse_salariale_provisionnee_temps_valide, + equivalent_temps_plein, + taux_horaire_equivalent_temps_plein_temps_du_initial, + taux_horaire_equivalent_temps_plein_temps_du, + taux_horaire_equivalent_temps_plein_temps_valide + FROM taux_horaires_mensuels + ; + + -- Calcul du taux horaire mensuel moyen par service et qualification pour chaque salarié + DROP TABLE IF EXISTS taux_horaires_mensuels_ventiles + ; + + CREATE TEMP TABLE taux_horaires_mensuels_ventiles AS + SELECT + p_taux_horaires_mensuels.mois_paie, + p_sommes_mensuelles_ventilees_planning.planning_service_id, + p_sommes_mensuelles_ventilees_planning.planning_qualification_id, + AVG(p_taux_horaires_mensuels.temps_du_initial) AS temps_du_initial, + AVG(p_taux_horaires_mensuels.temps_du) AS temps_du, + AVG(p_taux_horaires_mensuels.temps_valide) AS temps_valide, + AVG(p_taux_horaires_mensuels.heure_contrat) AS heure_contrat, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_contrat_temps_du_initial) AS taux_horaire_heure_contrat_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_contrat_temps_du) AS taux_horaire_heure_contrat_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_contrat_temps_valide) AS taux_horaire_heure_contrat_temps_valide, + AVG(p_taux_horaires_mensuels.heure_payee) AS heure_payee, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_payee_temps_du_initial) AS taux_horaire_heure_payee_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_payee_temps_du) AS taux_horaire_heure_payee_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_payee_temps_valide) AS taux_horaire_heure_payee_temps_valide, + AVG(p_taux_horaires_mensuels.heure_travaillee) AS heure_travaillee, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_travaillee_temps_du_initial) AS taux_horaire_heure_travaillee_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_travaillee_temps_du) AS taux_horaire_heure_travaillee_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_heure_travaillee_temps_valide) AS taux_horaire_heure_travaillee_temps_valide, + AVG(p_taux_horaires_mensuels.montant_brut) AS montant_brut, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_brut_temps_du_initial) AS taux_horaire_montant_brut_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_brut_temps_du) AS taux_horaire_montant_brut_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_brut_temps_valide) AS taux_horaire_montant_brut_temps_valide, + AVG(p_taux_horaires_mensuels.montant_masse_salariale) AS montant_masse_salariale, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_du_initial) AS taux_horaire_montant_masse_salariale_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_du) AS taux_horaire_montant_masse_salariale_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_valide) AS taux_horaire_montant_masse_salariale_temps_valide, + AVG(p_taux_horaires_mensuels.montant_cotisation_patronale) AS montant_cotisation_patronale, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_cotisation_patronale_temps_du_initial) AS taux_horaire_montant_cotisation_patronale_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_cotisation_patronale_temps_du) AS taux_horaire_montant_cotisation_patronale_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_cotisation_patronale_temps_valide) AS taux_horaire_montant_cotisation_patronale_temps_valide, + AVG(p_taux_horaires_mensuels.montant_provisions) AS montant_provisions, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_provisions_temps_du_initial) AS taux_horaire_montant_provisions_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_provisions_temps_du) AS taux_horaire_montant_provisions_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_provisions_temps_valide) AS taux_horaire_montant_provisions_temps_valide, + AVG(p_taux_horaires_mensuels.montant_masse_salariale_provisionnee) AS montant_masse_salariale_provisionnee, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_du_init) AS taux_horaire_montant_masse_salariale_provisionnee_temps_du_init, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_du) AS taux_horaire_montant_masse_salariale_provisionnee_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_valide) AS taux_horaire_montant_masse_salariale_provisionnee_temps_valide, + AVG(p_taux_horaires_mensuels.equivalent_temps_plein) AS equivalent_temps_plein, + AVG(p_taux_horaires_mensuels.taux_horaire_equivalent_temps_plein_temps_du_initial) AS taux_horaire_equivalent_temps_plein_temps_du_initial, + AVG(p_taux_horaires_mensuels.taux_horaire_equivalent_temps_plein_temps_du) AS taux_horaire_equivalent_temps_plein_temps_du, + AVG(p_taux_horaires_mensuels.taux_horaire_equivalent_temps_plein_temps_valide) AS taux_horaire_equivalent_temps_plein_temps_valide + FROM rh.p_sommes_mensuelles_ventilees_planning + JOIN rh.p_taux_horaires_mensuels ON + p_taux_horaires_mensuels.salarie_id = p_sommes_mensuelles_ventilees_planning.salarie_id AND + p_taux_horaires_mensuels.mois_paie = p_sommes_mensuelles_ventilees_planning.mois_paie + GROUP BY 1,2,3 + ; + + -- Génération du croisement + -- Récupération du planning quotidien de chaque salarié auquel on multiplie les différents temps par le taux horaire (précédemment calculé) du salarié + DROP TABLE IF EXISTS croisement_paie_planning + ; + + CREATE TEMP TABLE croisement_paie_planning AS + -- Cas des salariés (présents dans la paie et dans le planning) + SELECT + p_planning_mouvement.oid AS planning_id, + p_presence_salaries.salarie_id, + p_planning_mouvement.date, + t_periode_paie.mois_paie, + p_planning_mouvement.etablissement_id, + p_planning_mouvement.contrat_mois_id, + 'Salariés'::text AS presence_detail, + p_planning_mouvement.temps_du_initial, + p_planning_mouvement.temps_du, + p_planning_mouvement.temps_valide, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_heure_contrat_temps_du_initial, 2) AS HEUR_CONT_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_heure_contrat_temps_du, 2) AS HEUR_CONT_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_heure_contrat_temps_valide, 2) AS HEUR_CONT_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_heure_payee_temps_du_initial, 2) AS HEUR_PAYE_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_heure_payee_temps_du, 2) AS HEUR_PAYE_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_heure_payee_temps_valide, 2) AS HEUR_PAYE_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_heure_travaillee_temps_du_initial, 2) AS HEUR_TRAV_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_heure_travaillee_temps_du, 2) AS HEUR_TRAV_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_heure_travaillee_temps_valide, 2) AS HEUR_TRAV_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_montant_brut_temps_du_initial, 2) AS MONT_BRUT_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_montant_brut_temps_du, 2) AS MONT_BRUT_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_montant_brut_temps_valide, 2) AS MONT_BRUT_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_du_initial, 2) AS MONT_MASS_SALA_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_du, 2) AS MONT_MASS_SALA_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_valide, 2) AS MONT_MASS_SALA_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_montant_cotisation_patronale_temps_du_initial, 2) AS MONT_COTI_PATR_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_montant_cotisation_patronale_temps_du, 2) AS MONT_COTI_PATR_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_montant_cotisation_patronale_temps_valide, 2) AS MONT_COTI_PATR_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_montant_provisions_temps_du_initial, 2) AS MONT_PROV_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_montant_provisions_temps_du, 2) AS MONT_PROV_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_montant_provisions_temps_valide, 2) AS MONT_PROV_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_du_init, 2) AS MONT_MASS_SALA_PROV_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_du, 2) AS MONT_MASS_SALA_PROV_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_valide, 2) AS MONT_MASS_SALA_PROV_PROR_TEMP_VALI, + 0::numeric AS MONT_INTE_PROR_TEMP_DU_INIT, + 0::numeric AS MONT_INTE_PROR_TEMP_DU, + 0::numeric AS MONT_INTE_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_du_initial, 2) AS MONT_MASS_SALA_INTE_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_du, 2) AS MONT_MASS_SALA_INTE_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_temps_valide, 2) AS MONT_MASS_SALA_INTE_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_du_init, 2) AS MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_du, 2) AS MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * p_taux_horaires_mensuels.taux_horaire_montant_masse_salariale_provisionnee_temps_valide, 2) AS MONT_MASS_SALA_PROV_INTE_PROR_TEMP_VALI + FROM rh.p_presence_salaries + JOIN rh.t_periode_paie ON + t_periode_paie.mois_paie = p_presence_salaries.mois_paie AND + t_periode_paie.mois_paie BETWEEN min_month_to_get AND closed_payroll_month + JOIN rh.p_planning_mouvement ON + p_planning_mouvement.salarie_id = p_presence_salaries.salarie_id AND + p_planning_mouvement.date >= t_periode_paie.date_debut AND + p_planning_mouvement.date <= t_periode_paie.date_fin + JOIN rh.p_taux_horaires_mensuels ON + p_taux_horaires_mensuels.salarie_id = p_presence_salaries.salarie_id AND + p_taux_horaires_mensuels.mois_paie = p_presence_salaries.mois_paie + WHERE p_presence_salaries.present_paie = true AND p_presence_salaries.present_planning = true AND p_presence_salaries.est_interimaire = false + ; + + INSERT INTO croisement_paie_planning + -- Cas des intérimaires (présents au planning et ayant été détecté précédemment commes des intérimaires). Application du coefficient multiplicateur CPP_COEF_VALORISATION_INTERIM pour valoriser le coût de l'intérim + SELECT + p_planning_mouvement.oid AS planning_id, + p_presence_salaries.salarie_id, + p_planning_mouvement.date, + t_periode_paie.mois_paie, + p_planning_mouvement.etablissement_id, + p_planning_mouvement.contrat_mois_id AS contrat_mois_id, + 'Intérimaires'::text AS presence_detail, + p_planning_mouvement.temps_du_initial, + p_planning_mouvement.temps_du, + p_planning_mouvement.temps_valide, + round(p_planning_mouvement.temps_du_initial * taux_horaires_mensuels_ventiles.taux_horaire_heure_contrat_temps_du_initial, 2) * t_divers.valeur::numeric AS HEUR_CONT_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * taux_horaires_mensuels_ventiles.taux_horaire_heure_contrat_temps_du, 2) * t_divers.valeur::numeric AS HEUR_CONT_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * taux_horaires_mensuels_ventiles.taux_horaire_heure_contrat_temps_valide, 2) * t_divers.valeur::numeric AS HEUR_CONT_PROR_TEMP_VAL, + round(p_planning_mouvement.temps_du_initial * taux_horaires_mensuels_ventiles.taux_horaire_heure_payee_temps_du_initial, 2) * t_divers.valeur::numeric AS HEUR_PAYE_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * taux_horaires_mensuels_ventiles.taux_horaire_heure_payee_temps_du, 2) * t_divers.valeur::numeric AS HEUR_PAYE_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * taux_horaires_mensuels_ventiles.taux_horaire_heure_payee_temps_valide, 2) * t_divers.valeur::numeric AS HEUR_PAYE_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * taux_horaires_mensuels_ventiles.taux_horaire_heure_travaillee_temps_du_initial, 2) * t_divers.valeur::numeric AS HEUR_TRAV_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * taux_horaires_mensuels_ventiles.taux_horaire_heure_travaillee_temps_du, 2) * t_divers.valeur::numeric AS HEUR_TRAV_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * taux_horaires_mensuels_ventiles.taux_horaire_heure_travaillee_temps_valide, 2) * t_divers.valeur::numeric AS HEUR_TRAV_PROR_TEMP_VALI, + 0::numeric AS MONT_BRUT_PROR_TEMP_DU_INIT, + 0::numeric AS MONT_BRUT_PROR_TEMP_DU, + 0::numeric AS MONT_BRUT_PROR_TEMP_VALI, + 0::numeric AS MONT_MASS_SALA_PROR_TEMP_DU_INIT, + 0::numeric AS MONT_MASS_SALA_PROR_TEMP_DU, + 0::numeric AS MONT_MASS_SALA_PROR_TEMP_VALI, + 0::numeric AS MONT_COTI_PATR_PROR_TEMP_DU_INIT, + 0::numeric AS MONT_COTI_PATR_PROR_TEMP_DU, + 0::numeric AS MONT_COTI_PATR_PROR_TEMP_VALI, + 0::numeric AS MONT_PROV_PROR_TEMP_DU_INIT, + 0::numeric AS MONT_PROV_PROR_TEMP_DU, + 0::numeric AS MONT_PROV_PROR_TEMP_VALI, + 0::numeric AS MONT_MASS_SALA_PROV_PROR_TEMP_DU_INIT, + 0::numeric AS MONT_MASS_SALA_PROV_PROR_TEMP_DU, + 0::numeric AS MONT_MASS_SALA_PROV_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * taux_horaires_mensuels_ventiles.taux_horaire_montant_brut_temps_du_initial, 2) * t_divers.valeur::numeric AS MONT_INTE_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * taux_horaires_mensuels_ventiles.taux_horaire_montant_brut_temps_du, 2) * t_divers.valeur::numeric AS MONT_INTE_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * taux_horaires_mensuels_ventiles.taux_horaire_montant_brut_temps_valide, 2) * t_divers.valeur::numeric AS MONT_INTE_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * taux_horaires_mensuels_ventiles.taux_horaire_montant_brut_temps_du_initial, 2) * t_divers.valeur::numeric AS MONT_MASS_SALA_INTE_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * taux_horaires_mensuels_ventiles.taux_horaire_montant_brut_temps_du, 2) * t_divers.valeur::numeric AS MONT_MASS_SALA_INTE_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * taux_horaires_mensuels_ventiles.taux_horaire_montant_brut_temps_valide, 2) * t_divers.valeur::numeric AS MONT_MASS_SALA_INTE_PROR_TEMP_VALI, + round(p_planning_mouvement.temps_du_initial * taux_horaires_mensuels_ventiles.taux_horaire_montant_masse_salariale_provisionnee_temps_du_init, 2) * t_divers.valeur::numeric AS MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU_INIT, + round(p_planning_mouvement.temps_du * taux_horaires_mensuels_ventiles.taux_horaire_montant_masse_salariale_provisionnee_temps_du, 2) * t_divers.valeur::numeric AS MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU, + round(p_planning_mouvement.temps_valide * taux_horaires_mensuels_ventiles.taux_horaire_montant_masse_salariale_provisionnee_temps_valide, 2) * t_divers.valeur::numeric AS MONT_MASS_SALA_PROV_INTE_PROR_TEMP_VALI + FROM rh.p_presence_salaries + JOIN rh.t_periode_paie ON + t_periode_paie.mois_paie = p_presence_salaries.mois_paie + JOIN rh.p_planning_mouvement ON + p_planning_mouvement.salarie_id = p_presence_salaries.salarie_id AND + p_planning_mouvement.date >= t_periode_paie.date_debut AND + p_planning_mouvement.date <= t_periode_paie.date_fin + LEFT JOIN taux_horaires_mensuels_ventiles ON + taux_horaires_mensuels_ventiles.mois_paie = p_presence_salaries.mois_paie AND + taux_horaires_mensuels_ventiles.planning_service_id = p_planning_mouvement.service_id AND + taux_horaires_mensuels_ventiles.planning_qualification_id = p_planning_mouvement.qualification_id + JOIN rh.t_divers ON t_divers.code = 'CPP_COEF_VALORISATION_INTERIM' + WHERE p_presence_salaries.present_planning = true AND p_presence_salaries.est_interimaire = true + ; + + INSERT INTO rh.p_croisement_paie_planning ( + planning_id, + salarie_id, + date, + mois_paie, + etablissement_id, + contrat_mois_id, + presence_detail, + temps_du_initial, + temps_du, + temps_valide, + HEUR_CONT_PROR_TEMP_DU_INIT, + HEUR_CONT_PROR_TEMP_DU, + HEUR_CONT_PROR_TEMP_VALI, + HEUR_PAYE_PROR_TEMP_DU_INIT, + HEUR_PAYE_PROR_TEMP_DU, + HEUR_PAYE_PROR_TEMP_VALI, + HEUR_TRAV_PROR_TEMP_DU_INIT, + HEUR_TRAV_PROR_TEMP_DU, + HEUR_TRAV_PROR_TEMP_VALI, + MONT_BRUT_PROR_TEMP_DU_INIT, + MONT_BRUT_PROR_TEMP_DU, + MONT_BRUT_PROR_TEMP_VALI, + MONT_MASS_SALA_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_PROR_TEMP_DU, + MONT_MASS_SALA_PROR_TEMP_VALI, + MONT_COTI_PATR_PROR_TEMP_DU_INIT, + MONT_COTI_PATR_PROR_TEMP_DU, + MONT_COTI_PATR_PROR_TEMP_VALI, + MONT_PROV_PROR_TEMP_DU_INIT, + MONT_PROV_PROR_TEMP_DU, + MONT_PROV_PROR_TEMP_VALI, + MONT_MASS_SALA_PROV_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_PROV_PROR_TEMP_DU, + MONT_MASS_SALA_PROV_PROR_TEMP_VALI, + MONT_INTE_PROR_TEMP_DU_INIT, + MONT_INTE_PROR_TEMP_DU, + MONT_INTE_PROR_TEMP_VALI, + MONT_MASS_SALA_INTE_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_INTE_PROR_TEMP_DU, + MONT_MASS_SALA_INTE_PROR_TEMP_VALI, + MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU, + MONT_MASS_SALA_PROV_INTE_PROR_TEMP_VALI + ) + SELECT + planning_id, + salarie_id, + date, + mois_paie, + etablissement_id, + contrat_mois_id, + presence_detail, + temps_du_initial, + temps_du, + temps_valide, + HEUR_CONT_PROR_TEMP_DU_INIT, + HEUR_CONT_PROR_TEMP_DU, + HEUR_CONT_PROR_TEMP_VALI, + HEUR_PAYE_PROR_TEMP_DU_INIT, + HEUR_PAYE_PROR_TEMP_DU, + HEUR_PAYE_PROR_TEMP_VALI, + HEUR_TRAV_PROR_TEMP_DU_INIT, + HEUR_TRAV_PROR_TEMP_DU, + HEUR_TRAV_PROR_TEMP_VALI, + MONT_BRUT_PROR_TEMP_DU_INIT, + MONT_BRUT_PROR_TEMP_DU, + MONT_BRUT_PROR_TEMP_VALI, + MONT_MASS_SALA_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_PROR_TEMP_DU, + MONT_MASS_SALA_PROR_TEMP_VALI, + MONT_COTI_PATR_PROR_TEMP_DU_INIT, + MONT_COTI_PATR_PROR_TEMP_DU, + MONT_COTI_PATR_PROR_TEMP_VALI, + MONT_PROV_PROR_TEMP_DU_INIT, + MONT_PROV_PROR_TEMP_DU, + MONT_PROV_PROR_TEMP_VALI, + MONT_MASS_SALA_PROV_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_PROV_PROR_TEMP_DU, + MONT_MASS_SALA_PROV_PROR_TEMP_VALI, + MONT_INTE_PROR_TEMP_DU_INIT, + MONT_INTE_PROR_TEMP_DU, + MONT_INTE_PROR_TEMP_VALI, + MONT_MASS_SALA_INTE_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_INTE_PROR_TEMP_DU, + MONT_MASS_SALA_INTE_PROR_TEMP_VALI, + MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU_INIT, + MONT_MASS_SALA_PROV_INTE_PROR_TEMP_DU, + MONT_MASS_SALA_PROV_INTE_PROR_TEMP_VALI + FROM croisement_paie_planning + ; + + ANALYZE rh.p_croisement_paie_planning + ; + + RETURN 'OK'; + + END \ No newline at end of file diff --git a/db/schema2/functions/cti_execute_transform.yaml b/db/schema2/functions/cti_execute_transform.yaml new file mode 100644 index 0000000..45c3625 --- /dev/null +++ b/db/schema2/functions/cti_execute_transform.yaml @@ -0,0 +1,289 @@ +return: text +lang: plpgsql +src: | + DECLARE + result TEXT; + BEGIN + -- Transformations saisies ? + IF NOT EXISTS (SELECT * FROM rh.t_transformation) THEN + RETURN 'OK. Non concerné' ; + END IF; + + -- Stockage profil source + UPDATE rh.p_profil_contrat_mois + SET profil_avant_transformation_id = profil_id + WHERE profil_avant_transformation_id IS NULL OR + profil_avant_transformation_id = 0 + ; + -- Table de travail des profils par contrat peut être concernés + DROP TABLE IF EXISTS w_execute_transform_profils; + CREATE TEMP TABLE w_execute_transform_profils AS + SELECT p_profils.*, + salarie_id, + p_profil_contrat_mois.contrat_mois_id, + date(p_profil_contrat_mois.mois|| '01') AS date_contrat, + '0'::text AS with_transformation, + '0'::text AS est_doublon, + p_profils.oid AS from_profil_id + FROM rh.p_profils + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.profil_avant_transformation_id = p_profils.oid + WHERE + ( + service_id IN (SELECT from_service_id FROM rh.t_transformation) OR + qualification_id IN (SELECT from_qualification_id FROM rh.t_transformation) OR + salarie_id IN (SELECT salarie_id FROM rh.t_transformation) + ) + ; + -- execution des règles + -- Spécifiques salarié + UPDATE w_execute_transform_profils SET + with_transformation = '1', + service_id = CASE WHEN to_service_id = -1 THEN w_execute_transform_profils.service_id ELSE to_service_id END, + qualification_id = CASE WHEN to_qualification_id = -1 THEN w_execute_transform_profils.qualification_id ELSE to_qualification_id END, + oid = nextval('rh.s_profils'::regclass) + FROM rh.t_transformation + WHERE (w_execute_transform_profils.salarie_id = t_transformation.salarie_id AND t_transformation.salarie_id <> -1) AND + (w_execute_transform_profils.service_id = from_service_id OR from_service_id = -1) AND + (w_execute_transform_profils.qualification_id = from_qualification_id OR from_qualification_id = -1) AND + date_contrat BETWEEN t_transformation.date_debut AND t_transformation.date_fin AND + (to_service_id <> -1 OR to_qualification_id <> -1) + ; + -- Générales + UPDATE w_execute_transform_profils SET + with_transformation = '1', + service_id = CASE WHEN to_service_id = -1 THEN w_execute_transform_profils.service_id ELSE to_service_id END, + qualification_id = CASE WHEN to_qualification_id = -1 THEN w_execute_transform_profils.qualification_id ELSE to_qualification_id END, + oid = nextval('rh.s_profils'::regclass) + FROM rh.t_transformation + WHERE with_transformation <> '1' AND + (t_transformation.salarie_id = -1) AND + (w_execute_transform_profils.service_id = from_service_id OR from_service_id = -1) AND + (w_execute_transform_profils.qualification_id = from_qualification_id OR from_qualification_id = -1) AND + date_contrat BETWEEN t_transformation.date_debut AND t_transformation.date_fin AND + (to_service_id <> -1 OR to_qualification_id <> -1) + ; + + + -- Traitement des profils cibles en double + DROP TABLE IF EXISTS w_execute_transform_profils_uniques; + CREATE TEMP TABLE w_execute_transform_profils_uniques AS + SELECT + w_execute_transform_profils.from_profil_id, + MIN(oid) AS oid + FROM w_execute_transform_profils + WHERE with_transformation = '1' + GROUP BY 1 + HAVING count(distinct + ARRAY[type_contrat_id, + motif_debut_id, + motif_fin_id, + qualification_id, + service_id, + specialite_id, + type_temps_travail_id, + categorie_socio_professionnelle_id, + statut_id, + code_emploi_id, + societe_interim_id, + section_analytique_paie_id, + section_analytique_id, + grille_id, + grille_groupe_id, + type_horaire_id, + groupe_cotisant_id, + unite_fonctionnelle_id, + lettre_budgetaire_id, + commission_paritaire_id, + compte_salarie_id, + categorie_conge_id, + filiere_id, + cadre_emploi_id, + categorie_statutaire_id]) = 1 + ; + UPDATE w_execute_transform_profils + SET oid = w_execute_transform_profils_uniques.oid, + est_doublon = '1' + FROM w_execute_transform_profils_uniques + WHERE with_transformation = '1' AND + w_execute_transform_profils.from_profil_id = w_execute_transform_profils_uniques.from_profil_id AND + w_execute_transform_profils.oid <> w_execute_transform_profils_uniques.oid + ; + + -- Ajout des nouveaux profils + INSERT INTO rh.p_profils ( + oid, + type_contrat_id, + type_contrat_code_original, + motif_debut_id, + motif_debut_code_original, + motif_fin_id, + motif_fin_code_original, + qualification_id, + qualification_code_original, + service_id, + service_code_original, + specialite_id, + specialite_code_original, + type_temps_travail_id, + type_temps_travail_code_original, + categorie_socio_professionnelle_id, + categorie_socio_professionnelle_code_original, + statut_id, + statut_code_original, + code_emploi_id, + code_emploi_code_original, + societe_interim_id, + societe_interim_code_original, + section_analytique_paie_id, + section_analytique_paie_code_original, + section_analytique_id, + section_analytique_code_original, + grille_id, + grille_code_original, + grille_groupe_id, + grille_groupe_code_original, + type_horaire_id, + type_horaire_code_original, + groupe_cotisant_id, + groupe_cotisant_code_original, + unite_fonctionnelle_id, + unite_fonctionnelle_code_original, + lettre_budgetaire_id, + lettre_budgetaire_code_original, + commission_paritaire_id, + commission_paritaire_code_original, + compte_salarie_id, + compte_salarie_code_original, + categorie_conge_id, + categorie_conge_code_original, + filiere_id, + filiere_code_original, + cadre_emploi_id, + cadre_emploi_code_original, + categorie_statutaire_id, + categorie_statutaire_code_original + ) + + SELECT + w_execute_transform_profils.oid, + type_contrat_id, + type_contrat_code_original, + motif_debut_id, + motif_debut_code_original, + motif_fin_id, + motif_fin_code_original, + qualification_id, + t_qualifications.code_original AS qualification_code_original, + service_id, + t_services.code_original AS service_code_original, + specialite_id, + specialite_code_original, + type_temps_travail_id, + type_temps_travail_code_original, + categorie_socio_professionnelle_id, + categorie_socio_professionnelle_code_original, + statut_id, + statut_code_original, + code_emploi_id, + code_emploi_code_original, + societe_interim_id, + societe_interim_code_original, + section_analytique_paie_id, + section_analytique_paie_code_original, + section_analytique_id, + section_analytique_code_original, + grille_id, + grille_code_original, + grille_groupe_id, + grille_groupe_code_original, + type_horaire_id, + type_horaire_code_original, + groupe_cotisant_id, + groupe_cotisant_code_original, + unite_fonctionnelle_id, + unite_fonctionnelle_code_original, + lettre_budgetaire_id, + lettre_budgetaire_code_original, + commission_paritaire_id, + commission_paritaire_code_original, + compte_salarie_id, + compte_salarie_code_original, + categorie_conge_id, + categorie_conge_code_original, + filiere_id, + filiere_code_original, + cadre_emploi_id, + cadre_emploi_code_original, + categorie_statutaire_id, + categorie_statutaire_code_original + FROM w_execute_transform_profils + JOIN rh.t_services ON service_id = t_services.oid + JOIN rh.t_qualifications On qualification_id = t_qualifications.oid + WHERE with_transformation = '1' AND + est_doublon <> '1' + ; + + -- Mise à jour des profils par mois + UPDATE rh.p_profil_contrat_mois + SET profil_id = w_execute_transform_profils.oid + FROM w_execute_transform_profils + WHERE p_profil_contrat_mois.contrat_mois_id = w_execute_transform_profils.contrat_mois_id AND + p_profil_contrat_mois.profil_avant_transformation_id = w_execute_transform_profils.from_profil_id AND + with_transformation = '1' + ; + + -- Mise à jour des contrats avec dernière valeur des profils + UPDATE rh.p_contrats + SET profil_id = new_execute_transform_profil_id + FROM + ( + SELECT + p_contrats_mois.contrat_id, + (MAX(ARRAY[p_profil_contrat_mois.mois * 100 + p_profil_contrat_mois.ratio,p_profil_contrat_mois.profil_id]))[2] AS new_execute_transform_profil_id, + MAX(p_contrats.profil_id) AS old_profil_id + FROM rh.p_profil_contrat_mois + JOIN rh.p_contrats_mois ON contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid + GROUP BY 1 + HAVING (MAX(ARRAY[p_profil_contrat_mois.mois * 100 + p_profil_contrat_mois.ratio,p_profil_contrat_mois.profil_id]))[2] <> MAX(p_contrats.profil_id) + ) subview + WHERE subview.contrat_id = p_contrats.oid + ; + -- Mise à jour des salariés avec dernière valeur des profils + UPDATE rh.p_salaries + SET profil_id = new_execute_transform_profil_id + FROM + ( + SELECT + p_profil_contrat_mois.salarie_id, + (MAX(ARRAY[p_profil_contrat_mois.mois * 100 + p_profil_contrat_mois.ratio,p_profil_contrat_mois.profil_id]))[2] AS new_execute_transform_profil_id, + MAX(p_salaries.profil_id) AS old_profil_id + FROM rh.p_profil_contrat_mois + JOIN rh.p_salaries ON p_profil_contrat_mois.salarie_id = p_salaries.oid + GROUP BY 1 + HAVING (MAX(ARRAY[p_profil_contrat_mois.mois * 100 + p_profil_contrat_mois.ratio,p_profil_contrat_mois.profil_id]))[2] <> MAX(p_salaries.profil_id) + ) subview + WHERE subview.salarie_id = p_salaries.oid + ; + + -- Ajout des éventuels nouveaux oids + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'services', service_id + FROM rh.p_profils + WHERE service_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'services') + GROUP BY 1,2 + ; + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'qualifications', qualification_id + FROM rh.p_profils + WHERE qualification_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'qualifications') + GROUP BY 1,2 + ; + -- Réorganisation des nouveaux profils créés + PERFORM rh.cti_reorganize_profils(); + PERFORM rh.cti_update_schema_classes('QUA'); + PERFORM rh.cti_update_schema_classes('SER'); + + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_expert_controle_exec_rule~bi.yaml b/db/schema2/functions/cti_expert_controle_exec_rule~bi.yaml new file mode 100644 index 0000000..984fe1f --- /dev/null +++ b/db/schema2/functions/cti_expert_controle_exec_rule~bi.yaml @@ -0,0 +1,738 @@ +return: text +lang: plpgsql +parameters: + p0: + type: bigint + name: i_expert_controle_id +src: | + DECLARE + result TEXT; + + + BEGIN + RAISE NOTICE '%' , 'Recuperation OPTIMISER'; + + DROP TABLE IF EXISTS w_dboptimizer_line; + CREATE TEMP TABLE w_dboptimizer_line(in_data text) + ; + + BEGIN + PERFORM base.cti_execute( + 'COPY w_dboptimizer_line FROM ''' || t_settings.value || 'modules/rh/settings/RH_dboptimizer.xml'' WITH DELIMITER AS E''\02'' CSV HEADER QUOTE AS E''\01''' + ,1) + FROM base.t_settings + WHERE code = 'ENVIRONMENT/DIR' + ; + EXCEPTION + WHEN others THEN RETURN 'Dossier application non trouvé'; + END; + + + DROP TABLE IF EXISTS w_dboptimizer; + CREATE TEMP TABLE w_dboptimizer AS + SELECT array_to_string(base.cti_array_accum(translate(in_data,'éêè','e')),'') AS in_data_txt + FROM w_dboptimizer_line + WHERE in_data IS NOT NULL + ORDER BY row_number() OVER() + ; + + DROP TABLE IF EXISTS w_dboptimizer_xml; + CREATE TEMP TABLE w_dboptimizer_xml AS + SELECT xmlroot(xmlparse(document in_data_txt), version '1.0', standalone yes) AS in_data_xml + FROM w_dboptimizer + ; + + + DROP TABLE IF EXISTS w_dboptimizer_VIEWNAMEOPTIMIZER; + CREATE TEMP TABLE w_dboptimizer_VIEWNAMEOPTIMIZER AS + SELECT * + FROM + ( + SELECT i AS VIEWNAMEOPTIMIZER_index, + (xpath('/DBOPTIMIZER/VIEWNAMEOPTIMIZER['||i||']', in_data_xml))[1] AS VIEWNAMEOPTIMIZER_path, + (xpath('/DBOPTIMIZER/VIEWNAMEOPTIMIZER['||i||']/@viewName', in_data_xml))[1]::text AS viewName, + (xpath('/DBOPTIMIZER/VIEWNAMEOPTIMIZER['||i||']/@defaultViewName', in_data_xml))[1]::text AS defaultViewName + FROM w_dboptimizer_xml + JOIN generate_series(1,100) AS i ON 1=1 + ) subview + WHERE VIEWNAMEOPTIMIZER_path IS NOT NULL + ; + + + DROP TABLE IF EXISTS w_dboptimizer_LEFTJOININDICATOR; + CREATE TEMP TABLE w_dboptimizer_LEFTJOININDICATOR AS + SELECT * + FROM + ( + SELECT VIEWNAMEOPTIMIZER_index, + i AS LEFTJOININDICATOR_index, + (xpath('/VIEWNAMEOPTIMIZER/LEFTJOININDICATOR['||i||']', VIEWNAMEOPTIMIZER_path))[1] AS LEFTJOININDICATOR_path, + (xpath('/VIEWNAMEOPTIMIZER/LEFTJOININDICATOR['||i||']/@leftjoin', VIEWNAMEOPTIMIZER_path))[1]::text AS leftjoin + FROM w_dboptimizer_VIEWNAMEOPTIMIZER + JOIN generate_series(1,100) AS i ON 1=1 + ) subview + WHERE LEFTJOININDICATOR_path IS NOT NULL + ; + + + DROP TABLE IF EXISTS w_dboptimizer_FIELD; + CREATE TEMP TABLE w_dboptimizer_FIELD AS + SELECT * + FROM + ( + SELECT VIEWNAMEOPTIMIZER_index, + LEFTJOININDICATOR_index, + i AS FIELD_index, + (xpath('/LEFTJOININDICATOR/FIELD['||i||']', LEFTJOININDICATOR_path))[1] AS FIELD_path, + (xpath('/LEFTJOININDICATOR/FIELD['||i||']/@name', LEFTJOININDICATOR_path))[1]::text AS FIELD_name + FROM w_dboptimizer_LEFTJOININDICATOR + JOIN generate_series(1,100) AS i ON 1=1 + ) subview + WHERE FIELD_path IS NOT NULL + ; + + + + RAISE NOTICE '%' , 'Identification indicateurs'; + + + DROP TABLE IF EXISTS w_expert_controle_data; + CREATE TEMP TABLE w_expert_controle_data ( + expert_controle_id bigint, + expert_controle_rule_id bigint, + expert_controle_rule_index bigint, + data_type text, + data_id bigint, + expert_controle_code text, + contrat_mois_data text[], + indicateur_value numeric, + date_signalement date, + etat text, + date_correction date, + date_evenement date, + data_code_original text, + texte text) + ; + + UPDATE rh.t_expert_controle + SET date_validite_debut = + date( + CASE start_periode + WHEN 'A0' THEN date_trunc('year',now()) + WHEN 'A1' THEN date_trunc('year',now())-interval '1 year' + WHEN 'A2' THEN date_trunc('year',now())-interval '2 year' + WHEN 'M12' THEN date_trunc('month',now())-interval '12 month' + WHEN 'M24' THEN date_trunc('month',now())-interval '24 month' + ELSE date_trunc('year',now())-interval '1 year' END + ) + ; + + -- Période par défaut + UPDATE rh.t_expert_controle + SET start_periode = 'A1' + WHERE oid = 0 AND + start_periode = '' + ; + + UPDATE rh.t_expert_controle + SET date_validite_debut = t_expert_controle0.date_validite_debut + FROM rh.t_expert_controle t_expert_controle0 + WHERE t_expert_controle0.oid = 0 AND + t_expert_controle.oid <> 0 AND + t_expert_controle.start_periode = '' + ; + + DROP TABLE IF EXISTS w_indicateurs; + CREATE TEMP TABLE w_indicateurs AS + SELECT t_expert_controle.oid AS expert_controle_id, + t_expert_controle.code AS expert_controle_code, + -- GREATEST(COALESCE(t_expert_controle.date_validite_debut,'00010101'),COALESCE(t_expert_controle0.date_validite_debut,'00010101')) AS date_validite_debut, + COALESCE(t_expert_controle.date_validite_debut,'00010101') AS date_validite_debut, + t_expert_controle_rule.oid AS expert_controle_rule_id, + CASE WHEN indicateur_2_id <> 0 OR indicateur_3_id <> 0 THEN 1::bigint ELSE 0::bigint END AS expert_controle_rule_index, + t_expert_controle_rule.data_type, + CASE WHEN t_expert_controle_rule.formula <> '' THEN t_expert_controle_rule.formula ELSE '<> 0' END AS formula, + NULL::integer[] AS VIEWNAMEOPTIMIZER_index_array, + t_indicateurs.total_function, + t_indicateurs.table_name, + column_name, + t_expert_controle_rule.indicateur_condition_id, + t_expert_controle_rule.conditions_operateur AS conditions_operateur, + ''::text AS sqlcmd, + ''::text AS sqlresult + FROM rh.t_expert_controle + JOIN rh.t_expert_controle t_expert_controle0 ON + t_expert_controle0.oid = 0 AND + t_expert_controle0.is_active = '1' + JOIN rh.t_expert_controle_rule ON expert_controle_id = t_expert_controle.oid + JOIN rh.t_indicateurs On indicateur_id = t_indicateurs.oid + WHERE t_expert_controle.is_active = '1' AND + ( + i_expert_controle_id = 0 OR + t_expert_controle.oid = i_expert_controle_id + ) + ; + + + + + INSERT INTO w_indicateurs + SELECT t_expert_controle.oid AS expert_controle_id, + t_expert_controle.code AS expert_controle_code, + -- GREATEST(COALESCE(t_expert_controle.date_validite_debut,'00010101'),COALESCE(t_expert_controle0.date_validite_debut,'00010101')) AS date_validite_debut, + COALESCE(t_expert_controle.date_validite_debut,'00010101') AS date_validite_debut, + t_expert_controle_rule.oid AS expert_controle_rule_id, + 2::bigint AS expert_controle_rule_index, + t_expert_controle_rule.data_type, + CASE WHEN t_expert_controle_rule.formula_2 <> '' THEN t_expert_controle_rule.formula_2 ELSE '<> 0' END AS formula, + NULL::integer[] AS VIEWNAMEOPTIMIZER_index_array, + t_indicateurs.total_function, + t_indicateurs.table_name, + column_name, + t_expert_controle_rule.indicateur_condition_2_id, + t_expert_controle_rule.conditions_operateur_2 AS conditions_operateur, + ''::text AS sqlcmd, + ''::text AS sqlresult + FROM rh.t_expert_controle + JOIN rh.t_expert_controle t_expert_controle0 ON + t_expert_controle0.oid = 0 AND + t_expert_controle0.is_active = '1' + JOIN rh.t_expert_controle_rule ON expert_controle_id = t_expert_controle.oid + JOIN rh.t_indicateurs On indicateur_2_id = t_indicateurs.oid + WHERE t_expert_controle.is_active = '1' AND + indicateur_2_id <> 0 AND + ( + i_expert_controle_id = 0 OR + t_expert_controle.oid = i_expert_controle_id + ) + ; + + INSERT INTO w_indicateurs + SELECT t_expert_controle.oid AS expert_controle_id, + t_expert_controle.code AS expert_controle_code, + GREATEST(COALESCE(t_expert_controle.date_validite_debut,'00010101'),COALESCE(t_expert_controle0.date_validite_debut,'00010101')) AS date_validite_debut, + t_expert_controle_rule.oid AS expert_controle_rule_id, + 3::bigint AS expert_controle_rule_index, + t_expert_controle_rule.data_type, + CASE WHEN t_expert_controle_rule.formula_3 <> '' THEN t_expert_controle_rule.formula_3 ELSE '<> 0' END AS formula, + NULL::integer[] AS VIEWNAMEOPTIMIZER_index_array, + t_indicateurs.total_function, + t_indicateurs.table_name, + column_name, + t_expert_controle_rule.indicateur_condition_3_id, + t_expert_controle_rule.conditions_operateur_3 AS conditions_operateur, + ''::text AS sqlcmd, + ''::text AS sqlresult + FROM rh.t_expert_controle + JOIN rh.t_expert_controle t_expert_controle0 ON + t_expert_controle0.oid = 0 AND + t_expert_controle0.is_active = '1' + JOIN rh.t_expert_controle_rule ON expert_controle_id = t_expert_controle.oid + JOIN rh.t_indicateurs On indicateur_3_id = t_indicateurs.oid + WHERE t_expert_controle.is_active = '1' AND + indicateur_3_id <> 0 AND + ( + i_expert_controle_id = 0 OR + t_expert_controle.oid = i_expert_controle_id + ) + ; + + -- Constitution requete SQL + UPDATE w_indicateurs + SET column_name = 'CASE WHEN ' || condition_where || ' THEN ' || column_name || ' ELSE ' || CASE WHEN total_function <> 'COUNT' THEN '0' ELSE 'NULL' END || ' END' + FROM + ( + SELECT + expert_controle_rule_id, + expert_controle_rule_index, + array_to_string( + base.cti_array_accum('('||check_where||')'), + ' '||MAX(conditions_operateur)||' ' + ) AS condition_where + FROM w_indicateurs + JOIN rh.t_indicateur_condition ON t_indicateur_condition.oid = ANY(indicateur_condition_id) + JOIN rh.t_indicateur_condition_table ON t_indicateur_condition_table.indicateur_condition_id = t_indicateur_condition.oid + WHERE check_where <> '' AND t_indicateur_condition_table.table_name NOT IN ('CALENDRIER', 'BUDGET_RH') + GROUP BY 1,2 + ) subview + WHERE w_indicateurs.expert_controle_rule_id = subview.expert_controle_rule_id AND + w_indicateurs.expert_controle_rule_index = subview.expert_controle_rule_index + ; + + UPDATE w_indicateurs + SET column_name = trim(replace('CASE WHEN (' || column_name ||') IS NOT NULL THEN 1 ELSE 0 END','DISTINCT','')) + WHERE total_function = 'COUNT' + ; + + UPDATE rh.t_expert_controle SET + last_execution_ok = '0', + last_execution_timestamp = now(), + last_execution_count = 0 + WHERE is_active = '1' AND + ( + i_expert_controle_id = 0 OR + t_expert_controle.oid = i_expert_controle_id + ) + ; + + + UPDATE w_indicateurs + SET sqlcmd = + '@INSERT INTO w_expert_controle_data + SELECT ' || expert_controle_id::text || '::bigint AS expert_controle_id, ' || + expert_controle_rule_id::text || '::bigint AS expert_controle_rule_id, ' || + expert_controle_rule_index::text || '::bigint AS expert_controle_rule_index, + ''' || + CASE + WHEN data_type = '' THEN table_name || 'ITM' + + WHEN data_type = 'ITM' THEN table_name + WHEN data_type = 'ITMTAB' THEN table_name + ELSE data_type + END || '''::text AS data_type,' + || + CASE + WHEN data_type = '' THEN 'source_id' + WHEN data_type = 'contrat' THEN 'contrat_id' + WHEN data_type = 'paie' THEN 'contrat_mois_id' + WHEN data_type = 'ITM' AND table_name = 'v_contrats_mois_1' THEN 'contrat_mois_id' + WHEN data_type = 'ITMTAB' THEN table_name + WHEN data_type = 'salarie' THEN 'salarie_id' + ELSE '0' END || + '::bigint AS data_id, ' || + '''' || expert_controle_code || '''::text AS expert_controle_code, + MIN(ARRAY[date_debut_activite::text, date_fin_activite::text, contrat_code::text]) AS contrat_mois_data, + SUM(' || column_name || ')::numeric AS indicateur_value, + MAX(date(now())) AS date_signalement, + ''''::text AS etat, + ''20991231'' AS date_correction, + MIN(' || v_schema_settings_1.property_array[2] || ' ) AS date_evenement, + ''''::text AS data_code_original, + ''''::text AS texte + FROM ' || v_schema_settings_1.property_array[1] || ' + #LEFTJOIN# + WHERE ' || v_schema_settings_1.property_array[2] || ' >= ''' || date_validite_debut || ''' AND ' || + CASE WHEN formula <> '=0' THEN '( ' || column_name || ' ) ' || replace(formula,'''','''''') ELSE '1=1' END || ' + GROUP BY 1,2,3,4,5 ' || + CASE WHEN formula <> '=0' THEN 'HAVING SUM( ' || column_name || ' ) ' || replace(formula,'''','''''') ELSE '' END || ' + ; + ' + FROM rh.v_schema_settings_1 + WHERE table_name||'#1' = v_schema_settings_1.code AND + v_schema_settings_1.setting_type = 'FROM' + ; + + PERFORM base.cti_execute(' + UPDATE w_indicateurs SET + sqlcmd = replace(sqlcmd , ''#''||viewName||''#'', defaultViewName), + VIEWNAMEOPTIMIZER_index_array = array_append(VIEWNAMEOPTIMIZER_index_array,VIEWNAMEOPTIMIZER_index) + FROM w_dboptimizer_VIEWNAMEOPTIMIZER + WHERE w_indicateurs.sqlcmd LIKE ''%#''||viewName||''#%'' + ',50) + ; + + UPDATE w_indicateurs + SET sqlcmd = replace(sqlcmd,'#LEFTJOIN#',leftjoin) + FROM + ( + SELECT expert_controle_rule_id, array_to_string(base.cti_array_accum(leftjoin),chr(10)) AS leftjoin + FROM + ( + SELECT expert_controle_rule_id, w_dboptimizer_LEFTJOININDICATOR.VIEWNAMEOPTIMIZER_index, w_dboptimizer_LEFTJOININDICATOR.LEFTJOININDICATOR_index, + MAX(leftjoin) AS leftjoin + FROM w_indicateurs + JOIN w_dboptimizer_LEFTJOININDICATOR ON w_dboptimizer_LEFTJOININDICATOR.VIEWNAMEOPTIMIZER_index = ANY(VIEWNAMEOPTIMIZER_index_array) + JOIN w_dboptimizer_FIELD ON + w_dboptimizer_FIELD.VIEWNAMEOPTIMIZER_index = w_dboptimizer_LEFTJOININDICATOR.VIEWNAMEOPTIMIZER_index AND + w_dboptimizer_FIELD.LEFTJOININDICATOR_index = w_dboptimizer_LEFTJOININDICATOR.LEFTJOININDICATOR_index AND + w_indicateurs.sqlcmd LIKE '% ' || field_name|| '%' + GROUP BY 1,2,3 + ORDER BY 1,2,3 + ) subview + GROUP BY 1 + ) subview + WHERE w_indicateurs.expert_controle_rule_id = subview.expert_controle_rule_id + ; + + UPDATE w_indicateurs + SET sqlcmd = replace(sqlcmd,'#LEFTJOIN#','') + WHERE sqlcmd LIKE '%#LEFTJOIN#%' + ; + + RAISE NOTICE '%' , (SELECT array_to_string(base.cti_array_accum(sqlcmd),'; ') FROM w_indicateurs); + + RAISE NOTICE '%' , 'Extraction donnees'; + + + UPDATE w_indicateurs + SET sqlresult = base.cti_execute(sqlcmd,1) + ; + + ANALYSE w_expert_controle_data + ; + + RAISE NOTICE '%' , (SELECT array_to_string(base.cti_array_accum('INSERT INTO w_expert_controle_data + SELECT ' || t_expert_controle_rule.expert_controle_id || ', ' || + t_expert_controle_rule.oid || ', + 0::numeric, + data_type, + data_id, + contrat_mois_data, + expert_controle_code, + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 1 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula <> '' THEN formula ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 2 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_2 <> '' THEN formula_2 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 3 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_3 <> '' THEN formula_3 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + , + date_signalement, + etat, + date_correction, + date_evenement, + data_code_original, + texte + FROM w_expert_controle_data + GROUP BY 1,2,3,4,5,6,7,9,10,11,12,13,14 + HAVING + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 1 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula <> '' THEN formula ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 2 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_2 <> '' THEN formula_2 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 3 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_3 <> '' THEN formula_3 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + = ' || (1 + CASE WHEN indicateur_2_id <> 0 THEN 1 ELSE 0 END + CASE WHEN indicateur_3_id <> 0 THEN 1 ELSE 0 END)::text ||' + '),'; ') + FROM rh.t_expert_controle_rule + WHERE oid IN (SELECT expert_controle_rule_id FROM w_expert_controle_data) AND + ( + t_expert_controle_rule.indicateur_2_id <> 0 OR + t_expert_controle_rule.indicateur_3_id <> 0 + )) ; + + + + + + -- Plusieurs indicateurs dans condition ? + PERFORM base.cti_execute( + 'INSERT INTO w_expert_controle_data + SELECT ' || t_expert_controle_rule.expert_controle_id || ', ' || + t_expert_controle_rule.oid || ', + 0::numeric, + data_type, + data_id, + contrat_mois_data, + expert_controle_code, + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 1 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula <> '' THEN formula ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 2 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_2 <> '' THEN formula_2 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 3 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_3 <> '' THEN formula_3 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + , + date_signalement, + etat, + date_correction, + date_evenement, + data_code_original, + texte + FROM w_expert_controle_data + GROUP BY 1,2,3,4,5,6,7,9,10,11,12,13,14 + HAVING + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 1 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula <> '' THEN formula ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 2 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_2 <> '' THEN formula_2 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + + CASE WHEN MAX(CASE WHEN expert_controle_rule_index = 3 THEN COALESCE(indicateur_value,0) ELSE 0 END) ' || replace(CASE WHEN formula_3 <> '' THEN formula_3 ELSE '<>0' END,'''','''''') || ' THEN 1 ELSE 0 END + = ' || (1 + CASE WHEN indicateur_2_id <> 0 THEN 1 ELSE 0 END + CASE WHEN indicateur_3_id <> 0 THEN 1 ELSE 0 END)::text ||' + ',1) + FROM rh.t_expert_controle_rule + WHERE oid IN (SELECT expert_controle_rule_id FROM w_expert_controle_data) AND + ( + t_expert_controle_rule.indicateur_2_id <> 0 OR + t_expert_controle_rule.indicateur_3_id <> 0 + ) + ; + + DELETE FROM w_expert_controle_data + WHERE expert_controle_rule_index > 0 + ; + + UPDATE rh.t_expert_controle_rule + SET last_execution_result = CASE WHEN sqlresult NOT LIKE 'OK%' THEN sqlresult ELSE 'OK' END + FROM w_indicateurs + WHERE w_indicateurs.expert_controle_rule_id = t_expert_controle_rule.oid + ; + + UPDATE rh.t_expert_controle + SET last_execution_ok = subview.execution_ok + FROM + ( + SELECT expert_controle_id, + MIN(CASE WHEN last_execution_result LIKE 'KO%' THEN '0' ELSE '1' END) AS execution_ok + FROM rh.t_expert_controle_rule + WHERE indicateur_id <> 0 + GROUP BY 1 + ) subview + WHERE expert_controle_id = t_expert_controle.oid + ; + + UPDATE rh.t_expert_controle + SET last_execution_count = subview.nb + FROM + ( + SELECT expert_controle_id, + count(*) AS nb + FROM w_expert_controle_data + GROUP BY 1 + ) subview + WHERE expert_controle_id = t_expert_controle.oid + ; + + ANALYSE w_expert_controle_data + ; + + + + -- Identifiants des tables + if 1<>1 then + PERFORM base.cti_execute('@UPDATE w_expert_controle_data SET + data_code_original = t_source.code_original, texte = ''' || t_listes_tables.texte || ' '' || t_source.texte || '' ('' || t_source.code || '')'' + FROM rh.' || t_listes_tables.name || ' t_source + WHERE data_type = ''' || t_listes_tables.code || ''' AND t_source.oid = data_id + ',1) + FROM rh.t_listes_tables + WHERE t_listes_tables.code <> 'salarie' AND + t_listes_tables.code IN (SELECT data_type FROM w_expert_controle_data) + ; + PERFORM base.cti_execute('@UPDATE w_expert_controle_data SET + data_code_original = t_source.code_original, texte = ''Séjour '' || t_source.no_salarie + FROM rh.' || t_listes_tables.name || ' t_source + WHERE data_type = ''' || t_listes_tables.code || ''' AND t_source.oid = data_id + ',1) + FROM rh.t_listes_tables + WHERE t_listes_tables.code = 'salarie' AND + t_listes_tables.code IN (SELECT data_type FROM w_expert_controle_data) + ; + end if; + + + -- Identifiants des items + UPDATE w_expert_controle_data SET + data_code_original = p_contrats.code_original, + texte = 'Contrat ' || + numero_contrat || + ' du ' || to_char(p_contrats.date_debut,'DD/MM/YYYY') || + ' au ' || to_char(p_contrats.date_fin,'DD/MM/YYYY') + FROM rh.p_contrats_mois + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid + WHERE data_type IN ('contrat', 'salarie') AND + p_contrats_mois.date_debut = w_expert_controle_data.contrat_mois_data[1] AND + p_contrats_mois.date_fin = w_expert_controle_data.contrat_mois_data[2] AND + p_contrats.numero_contrat = w_expert_controle_data.contrat_mois_data[3] + ; + UPDATE w_expert_controle_data SET + data_code_original = p_contrats.code_original || to_char(p_contrats_mois.date_fin,'YYYYMMDD'), + texte = 'Contrat ' || + p_contrats.numero_contrat || + 'Paie du ' || to_char(p_contrats_mois.date_debut,'DD/MM/YYYY') || + ' au ' || to_char(p_contrats_mois.date_fin,'DD/MM/YYYY') + FROM rh.p_contrats_mois + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid + WHERE data_type = 'paie' AND + p_contrats_mois.date_debut = w_expert_controle_data.contrat_mois_data[1] AND + p_contrats_mois.date_fin = w_expert_controle_data.contrat_mois_data[2] AND + p_contrats.numero_contrat = w_expert_controle_data.contrat_mois_data[3] + ; + + + -- Actualisation des oid des tables + if 1<>1 then + PERFORM base.cti_execute('@UPDATE rh.p_expert_controle_data SET + data_id = t_source.oid + FROM rh.' || t_listes_tables.name || ' t_source + WHERE data_type = ''' || t_listes_tables.code || ''' AND + data_code_original = t_source.code_original AND + data_id <> t_source.oid + ',1) + FROM rh.t_listes_tables + WHERE t_listes_tables.code IN (SELECT data_type FROM rh.p_expert_controle_data) + ; + end if; + + + -- Corrigé si erreur a disparu + UPDATE rh.p_expert_controle_data SET + etat = 'T', + date_correction = date(now()) + WHERE etat = '' AND + expert_controle_id NOT IN (SELECT t_expert_controle.oid FROM rh.t_expert_controle WHERE t_expert_controle.oid > 0 AND last_execution_ok <> '1') AND + ( + i_expert_controle_id = 0 OR + p_expert_controle_data.expert_controle_id = i_expert_controle_id + ) AND + p_expert_controle_data.expert_controle_id::text||'#'||p_expert_controle_data.data_type||'#'||p_expert_controle_data.data_id::text + NOT IN (SELECT w_expert_controle_data.expert_controle_id::text||'#'||w_expert_controle_data.data_type||'#'||w_expert_controle_data.data_id FROM w_expert_controle_data) + ; + + -- L'erreur réapparait aprés avoir disparu, réactivation + UPDATE rh.p_expert_controle_data SET + etat = '', + date_correction = '20991231' + WHERE etat = 'T' AND + ( + i_expert_controle_id = 0 OR + p_expert_controle_data.expert_controle_id = i_expert_controle_id + ) AND + p_expert_controle_data.expert_controle_id::text||'#'||p_expert_controle_data.data_type||'#'||p_expert_controle_data.data_id::text + IN (SELECT w_expert_controle_data.expert_controle_id::text||'#'||w_expert_controle_data.data_type||'#'||w_expert_controle_data.data_id FROM w_expert_controle_data) + ; + + INSERT INTO rh.p_expert_controle_data( + expert_controle_id, + date_item, + date_signalement, + etat, + date_evenement, + date_correction, + contrat_mois_data, + data_type, + data_id, + data_code_original, + texte, + nb_cree, + nb_portee, + nb_cloture + ) + SELECT + expert_controle_id, + date_signalement AS date_item, + date_signalement, + etat, + date_evenement, + date_correction, + contrat_mois_data, + data_type, + data_id, + data_code_original, + texte, + 1::numeric AS nb_cree, + 0::numeric AS nb_portee, + 0::numeric AS nb_cloture + FROM w_expert_controle_data + WHERE (w_expert_controle_data.expert_controle_id::text||'#'||w_expert_controle_data.data_type||'#'||w_expert_controle_data.data_id) + NOT IN (SELECT p_expert_controle_data.expert_controle_id::text||'#'||p_expert_controle_data.data_type||'#'||p_expert_controle_data.data_id FROM rh.p_expert_controle_data) + ; + + ANALYSE rh.p_expert_controle_data + ; + + DELETE FROM rh.p_expert_controle_data + WHERE expert_controle_id IN (SELECT oid FROM rh.t_expert_controle WHERE is_active <> '1') + ; + + DELETE FROM rh.p_expert_controle_data + WHERE nb_cree = 0 + ; + + + UPDATE rh.p_expert_controle_data + SET expert_controle_data_id = oid + WHERE expert_controle_data_id <> oid + ; + + + INSERT INTO rh.p_expert_controle_data + ( + oid, + expert_controle_data_id, + expert_controle_id, + date_item, + date_signalement, + etat, + date_evenement, + date_correction, + contrat_mois_data, + data_type, + data_id, + data_code_original, + texte, + nb_cree, + nb_portee, + nb_cloture + ) + SELECT + 0::bigint AS oid, + expert_controle_data_id, + expert_controle_id, + date_evenement AS date_item, + date_signalement, + etat, + date_evenement, + date_correction, + contrat_mois_data, + data_type, + data_id, + data_code_original, + texte, + 0::bigint AS nb_cree, + 1::bigint AS nb_portee, + 0::bigint AS nb_cloture + FROM rh.p_expert_controle_data + WHERE nb_cree = 1 AND + date_evenement <> '20991231' + ; + + INSERT INTO rh.p_expert_controle_data + ( + oid, + expert_controle_data_id, + expert_controle_id, + date_item, + date_signalement, + etat, + date_evenement, + date_correction, + contrat_mois_data, + data_type, + data_id, + data_code_original, + texte, + nb_cree, + nb_portee, + nb_cloture + ) + SELECT + 0::bigint AS oid, + expert_controle_data_id, + expert_controle_id, + date_correction AS date_item, + date_signalement, + etat, + date_evenement, + date_correction, + contrat_mois_data, + data_type, + data_id, + data_code_original, + texte, + 0::bigint AS nb_cree, + 0::bigint AS nb_portee, + 1::bigint AS nb_cloture + FROM rh.p_expert_controle_data + WHERE nb_cree = 1 AND + date_correction <> '20991231' + ; + + ANALYSE rh.p_expert_controle_data + ; + + UPDATE rh.t_expert_controle + SET last_execution_count = subview.nb + FROM + ( + SELECT t_expert_controle.oid, + count(p_expert_controle_data.expert_controle_id) AS nb + FROM rh.t_expert_controle + LEFT JOIN rh.p_expert_controle_data ON + expert_controle_id = t_expert_controle.oid AND + nb_cree = 1 AND + date_correction = '20991231' + GROUP BY 1 + ) subview + WHERE t_expert_controle.oid = subview.oid AND + last_execution_count <> subview.nb + ; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_fusion_salaries.yaml b/db/schema2/functions/cti_fusion_salaries.yaml new file mode 100644 index 0000000..bc5a07b --- /dev/null +++ b/db/schema2/functions/cti_fusion_salaries.yaml @@ -0,0 +1,256 @@ +return: text +lang: plpgsql +src: | + DECLARE + _sqlcmd TEXT; + result TEXT; + BEGIN + -- Initialisation du nouveau champ + UPDATE rh.p_salaries + SET salarie_fusionne_id = 0 + WHERE salarie_fusionne_id IS NULL; + UPDATE rh.p_salaries + SET salarie_fusionne_id = 0 + WHERE salarie_fusionne_id <> 0 AND + salarie_fusionne_id NOT IN (SELECT oid FROM rh.p_salaries); + + -- Paramétrés + INSERT INTO rh.t_divers (code, texte, valeur, description) + SELECT + 'FUSIONSALARIE', + 'Fusion des salariés', + '0', + '1 = Fusion des salariés activée' + WHERE 'FUSIONSALARIE' NOT IN (SELECT code FROM rh.t_divers); + IF NOT EXISTS (SELECT * + FROM rh.t_divers + WHERE t_divers.code = 'FUSIONSALARIE' AND + t_divers.valeur = '1' + LIMIT 1) THEN + return 'Fusion non activée'; + END IF; + -- Stockage des salaries par nom + DROP TABLE IF EXISTS w_fusion_salaries; + CREATE TEMP TABLE w_fusion_salaries AS + SELECT *, + '0'::text AS origine, + base.cti_soundex_nom(nom) AS nom_soundex, + base.cti_soundex_prenom(prenom) AS prenom_soundex + FROM rh.p_salaries + WHERE nom <> '' AND + (nom_naissance = nom OR nom_naissance = '') AND + oid IN (SELECT salarie_id FROM rh.p_contrats); + -- Stockage des salaries par nom de naissance + INSERT INTO w_fusion_salaries + SELECT *, + '1'::text AS origine, + base.cti_soundex_nom(nom_naissance) AS nom_soundex, + base.cti_soundex_prenom(prenom) AS prenom_soundex + FROM rh.p_salaries + WHERE nom <> '' AND + nom_naissance <> '' AND + nom_naissance <> nom AND + oid IN (SELECT salarie_id FROM rh.p_contrats); + + -- Détection salariés à regrouper et regrouper sur le plus récent + UPDATE rh.p_salaries + SET salarie_fusionne_id = CASE WHEN p_salaries.oid <> subview.salarie_fusionne_id THEN subview.salarie_fusionne_id ELSE 0 END + FROM + ( + SELECT + w_fusion_salaries.oid, + subview.salarie_fusionne_id, + w_fusion_salaries.entreprise_id, + w_fusion_salaries.nom_soundex, + w_fusion_salaries.prenom_soundex, + w_fusion_salaries.date_naissance, + w_fusion_salaries.sexe + FROM w_fusion_salaries + JOIN + ( + SELECT + entreprise_id, + nom_soundex, + prenom_soundex, + date_naissance, + sexe, + count(*) AS nb, + (MAX(ARRAY[date_debut::text,oid::text]))[2]::bigint AS salarie_fusionne_id, + base.cti_array_accum(w_fusion_salaries.oid) AS salaries_array + FROM w_fusion_salaries + GROUP BY 1,2,3,4,5 + HAVING count(*) > 1 + ) subview ON + w_fusion_salaries.oid = ANY(salaries_array) + ORDER BY 1,2,3,4,5,6 + ) subview + WHERE subview.oid = p_salaries.oid + ; + + -- Mise à jour du salarié cible + UPDATE rh.p_salaries SET + date_debut = subview.date_debut, + date_fin = subview.date_fin, + date_entree_ets = subview.date_entree_ets, + date_entree_fp = subview.date_entree_fp, + date_entree_fph = subview.date_entree_fph, + date_sortie_ets = subview.date_sortie_ets + FROM + ( + SELECT + CASE WHEN salarie_fusionne_id <> 0 THEN salarie_fusionne_id ELSE oid END, + MIN(date_debut) AS date_debut, + MAX(date_fin) AS date_fin, + MIN(date_entree_ets) AS date_entree_ets, + MIN(date_entree_fp) AS date_entree_fp, + MIN(date_entree_fph) AS date_entree_fph, + MAX(date_sortie_ets) AS date_sortie_ets + FROM rh.p_salaries + GROUP BY 1 + HAVING COUNT(*) > 1 + ) subview + WHERE p_salaries.oid = subview.oid; + -- Mise à jour référence salarié dans contrats + UPDATE rh.p_contrats + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_contrats.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> salarie_id; + UPDATE rh.p_contrats + SET salarie_remplace_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_contrats.salarie_remplace_id <> 0 AND + p_contrats.salarie_remplace_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> salarie_remplace_id; + --fusion ancienneté sans prendre en compte l'entreprise + INSERT INTO rh.t_divers (code, texte, valeur, description) + SELECT + 'FUSIONENTREESALARIE', + 'Fusion des dates entrées salariés (quelque soit entreprise)', + '0', + '1 = Fusion des dates entrée salariés activée' + WHERE 'FUSIONENTREESALARIE' NOT IN (SELECT code FROM rh.t_divers); + -- Mise à jour du salarié cible + UPDATE rh.p_salaries SET + date_entree_ets = subview.date_entree_ets + FROM + ( + SELECT + w_fusion_salaries.nom_soundex, + w_fusion_salaries.prenom_soundex, + w_fusion_salaries.date_naissance, + w_fusion_salaries.sexe, + (MAX(ARRAY[date_debut::text,oid::text]))[2]::bigint AS salarie_fusionne_id, + base.cti_array_accum(w_fusion_salaries.oid) AS salaries_array, + MIN(date_debut) AS date_debut, + MAX(date_fin) AS date_fin, + MIN(date_entree_ets) AS date_entree_ets, + MIN(date_entree_fp) AS date_entree_fp, + MIN(date_entree_fph) AS date_entree_fph, + MAX(date_sortie_ets) AS date_sortie_ets + FROM w_fusion_salaries + GROUP BY 1,2,3,4 + HAVING COUNT(*) > 1 + ) subview + WHERE p_salaries.oid = ANY(salaries_array) + AND (SELECT valeur = 1 FROM rh.t_divers WHERE code = 'FUSIONENTREESALARIE'); + + UPDATE rh.p_contrats SET + anciennete_anterieure_jours = subview.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subview.anciennete_anterieure_calculee_mois + FROM + ( + SELECT p_contrats.oid, + SUM(p_contrats_anterieurs.date_fin-p_contrats_anterieurs.date_debut+1) AS anciennete_anterieure_jours, + floor(SUM(p_contrats_anterieurs.date_fin-p_contrats_anterieurs.date_debut+1)/30.00) AS anciennete_anterieure_calculee_mois + FROM rh.p_contrats + JOIN rh.p_contrats p_contrats_anterieurs ON + p_contrats_anterieurs.salarie_id = p_contrats.salarie_id AND + p_contrats_anterieurs.etablissement_id = p_contrats.etablissement_id AND + p_contrats_anterieurs.date_debut < p_contrats.date_debut + WHERE p_contrats.salarie_id <> 0 AND + p_contrats.salarie_id IN (SELECT salarie_fusionne_id FROM rh.p_salaries) + + GROUP BY 1 + ) subview + WHERE p_contrats.oid = subview.oid; + -- Mise à jour référence salarié dans contrats mois + UPDATE rh.p_contrats_mois + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_contrats_mois.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_contrats_mois.salarie_id; + UPDATE rh.p_contrats_mois SET + anciennete_jours = p_contrats_mois.date_fin - p_contrats.date_debut + 1 + p_contrats.anciennete_anterieure_jours, + anciennete_mois = floor((p_contrats_mois.date_fin - p_contrats.date_debut + 1 + p_contrats.anciennete_anterieure_jours)/30.00), + anciennete_annee_id = floor((p_contrats_mois.date_fin - p_contrats.date_debut + 1 + p_contrats.anciennete_anterieure_jours)/365.25), + nombre_entrees = CASE WHEN date_entree_ets BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END + FROM rh.p_contrats + JOIN rh.p_salaries ON p_contrats.salarie_id = p_salaries.oid + WHERE p_contrats_mois.contrat_id = p_contrats.oid AND + p_contrats.salarie_id IN (SELECT salarie_fusionne_id FROM rh.p_salaries) + ; + UPDATE rh.p_contrats_mois + SET nombre_entrees = 0 + FROM + (SELECT salarie_id, (MIN(Array[date_debut::text, oid::text]))[2] AS oid_ok FROM rh.p_contrats_mois WHERE nombre_entrees = 1 GROUP BY 1 HAVING count(*) > 1) subview + WHERE p_contrats_mois.salarie_id = subview.salarie_id AND + p_contrats_mois.nombre_entrees = 1 AND + p_contrats_mois.oid <> oid_ok + ; + + UPDATE rh.p_profil_contrat_mois + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_profil_contrat_mois.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_profil_contrat_mois.salarie_id; + -- Mise à jour référence salarié dans autres tables + UPDATE rh.p_historique_paie + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_historique_paie.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_historique_paie.salarie_id; + UPDATE rh.p_accident_travail + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_accident_travail.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_accident_travail.salarie_id; + UPDATE rh.p_arrets_travail + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_arrets_travail.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_arrets_travail.salarie_id; + UPDATE rh.p_arrets_travail_mois + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_arrets_travail_mois.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_arrets_travail_mois.salarie_id; + UPDATE rh.p_formations + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_formations.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_formations.salarie_id; + UPDATE rh.p_handicap + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_handicap.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_handicap.salarie_id; + UPDATE rh.p_visites_medicales + SET salarie_id = p_salaries.salarie_fusionne_id + FROM rh.p_salaries + WHERE p_visites_medicales.salarie_id = p_salaries.oid AND + salarie_fusionne_id <> 0 AND + salarie_fusionne_id <> p_visites_medicales.salarie_id; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_gen_data_profile_views.yaml b/db/schema2/functions/cti_gen_data_profile_views.yaml new file mode 100644 index 0000000..925acd3 --- /dev/null +++ b/db/schema2/functions/cti_gen_data_profile_views.yaml @@ -0,0 +1,53 @@ +return: text +lang: plpgsql +src: | + DECLARE + _cursor refcursor; + _sqlcmd text; + _todataprofile text; + _schema text; + result TEXT; + BEGIN + + -- Suppression des profils inexistants + _sqlcmd = 'SELECT substr(nspname,17) + FROM pg_namespace + WHERE substr(nspname,1,16) = ''rh_data_profile_'' AND + LOWER(substr(nspname,17)) NOT IN (SELECT LOWER(t_data_profile.code) FROM rh.t_data_profile) ' + ; + OPEN _cursor FOR EXECUTE _sqlcmd; + FETCH _cursor INTO _todataprofile; + WHILE FOUND LOOP + BEGIN + RAISE NOTICE 'Suppression du data_profile %', _todataprofile; + EXECUTE 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')'; + EXCEPTION + WHEN others THEN RAISE NOTICE 'Erreur %' , 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')'; + END; + FETCH _cursor INTO _todataprofile; + END LOOP; + CLOSE _cursor; + + -- Pour chaque data_profile défini, appeler rh.cti_gen_data_profile_views(_in_data_profile_code) + + -- Lister les _in_data_profile_code + _sqlcmd = 'SELECT t_data_profile.code + FROM rh.t_data_profile + WHERE t_data_profile.code <> '''' ' + ; + + OPEN _cursor FOR EXECUTE _sqlcmd; + FETCH _cursor INTO _todataprofile; + WHILE FOUND LOOP + BEGIN + RAISE NOTICE 'Traitement du data_profile %', _todataprofile; + EXECUTE 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')'; + EXCEPTION + WHEN others THEN RAISE NOTICE 'Erreur %' , 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')'; + END; + FETCH _cursor INTO _todataprofile; + END LOOP; + CLOSE _cursor; + + return 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_gen_data_profile_views~tx.yaml b/db/schema2/functions/cti_gen_data_profile_views~tx.yaml new file mode 100644 index 0000000..274f4a2 --- /dev/null +++ b/db/schema2/functions/cti_gen_data_profile_views~tx.yaml @@ -0,0 +1,410 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: _in_data_profile_code +src: | + DECLARE + + _cursor refcursor; + _toschema text; + _sqlcmd text; + _sqlobject text; + _data_profile_code text; + _tosqlcmd text; + _tosqlcmd_deja text; + _tosqlcmd_base text; + result TEXT; + + BEGIN + -- Suppression si inexistant + IF _in_data_profile_code <> '' AND + EXISTS (SELECT nspname + FROM pg_namespace + WHERE LOWER(nspname) = LOWER('rh_data_profile_' || _in_data_profile_code) AND + LOWER(substr(nspname,17)) NOT IN (SELECT LOWER(t_data_profile.code) FROM rh.t_data_profile) + ) + THEN + + RAISE NOTICE 'Suppression %', 'rh_data_profile_' || _in_data_profile_code; + + BEGIN + EXECUTE 'DROP SCHEMA rh_data_profile_' || _in_data_profile_code || ' CASCADE'; + EXCEPTION + WHEN others THEN RAISE NOTICE 'Erreur %' , 'DROP SCHEMA ' || 'rh_data_profile_' || _in_data_profile_code || ' CASCADE'; + END; + return 'OK'; + END IF; + + -- Traitement des listes pour être bien interprétées par string_to_array + UPDATE rh.t_data_profile + SET etablissement_inclus = trim(etablissement_inclus); + UPDATE rh.t_data_profile + SET etablissement_inclus = replace(etablissement_inclus,' ,',',') + WHERE etablissement_inclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET etablissement_inclus = replace(etablissement_inclus,' ,',',') + WHERE etablissement_inclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET etablissement_inclus = replace(etablissement_inclus,', ',',') + WHERE etablissement_inclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET etablissement_inclus = replace(etablissement_inclus,', ',',') + WHERE etablissement_inclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET etablissement_exclus = trim(etablissement_exclus); + UPDATE rh.t_data_profile + SET etablissement_exclus = replace(etablissement_exclus,' ,',',') + WHERE etablissement_exclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET etablissement_exclus = replace(etablissement_exclus,' ,',',') + WHERE etablissement_exclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET etablissement_exclus = replace(etablissement_exclus,', ',',') + WHERE etablissement_exclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET etablissement_exclus = replace(etablissement_exclus,', ',',') + WHERE etablissement_exclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET service_inclus = trim(service_inclus); + UPDATE rh.t_data_profile + SET service_inclus = replace(service_inclus,' ,',',') + WHERE service_inclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET service_inclus = replace(service_inclus,' ,',',') + WHERE service_inclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET service_inclus = replace(service_inclus,', ',',') + WHERE service_inclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET service_inclus = replace(service_inclus,', ',',') + WHERE service_inclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET service_exclus = trim(service_exclus); + UPDATE rh.t_data_profile + SET service_exclus = replace(service_exclus,' ,',',') + WHERE service_exclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET service_exclus = replace(service_exclus,' ,',',') + WHERE service_exclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET service_exclus = replace(service_exclus,', ',',') + WHERE service_exclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET service_exclus = replace(service_exclus,', ',',') + WHERE service_exclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET statut_inclus = trim(statut_inclus); + UPDATE rh.t_data_profile + SET statut_inclus = replace(statut_inclus,' ,',',') + WHERE statut_inclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET statut_inclus = replace(statut_inclus,' ,',',') + WHERE statut_inclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET statut_inclus = replace(statut_inclus,', ',',') + WHERE statut_inclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET statut_inclus = replace(statut_inclus,', ',',') + WHERE statut_inclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET statut_exclus = trim(statut_exclus); + UPDATE rh.t_data_profile + SET statut_exclus = replace(statut_exclus,' ,',',') + WHERE statut_exclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET statut_exclus = replace(statut_exclus,' ,',',') + WHERE statut_exclus LIKE '% ,%'; + UPDATE rh.t_data_profile + SET statut_exclus = replace(statut_exclus,', ',',') + WHERE statut_exclus LIKE '%, %'; + UPDATE rh.t_data_profile + SET statut_exclus = replace(statut_exclus,', ',',') + WHERE statut_exclus LIKE '%, %'; + + -- Génération des oids sur les profils + UPDATE rh.t_data_profile + SET service_id_array = subview.service_id_array + FROM + ( + SELECT + t_data_profile.oid, + base.cti_array_accum(t_services.oid) AS service_id_array + FROM rh.t_data_profile + LEFT JOIN rh.t_services ON (t_services.code LIKE ANY(string_to_array(replace(t_data_profile.service_inclus,'*','%'),',')) OR t_data_profile.service_inclus = '' OR t_data_profile.service_inclus IS NULL) + LEFT JOIN rh.t_services t_services_exclus ON t_data_profile.service_exclus <> '' AND + t_services_exclus.code LIKE ANY(string_to_array(replace(t_data_profile.service_exclus,'*','%'),',')) AND + t_services.oid = t_services_exclus.oid + WHERE t_services_exclus.oid IS NULL + GROUP BY 1 + )subview + WHERE subview.oid = t_data_profile.oid + ; + UPDATE rh.t_data_profile + SET statut_id_array = subview.statut_id_array + FROM + ( + SELECT + t_data_profile.oid, + base.cti_array_accum(t_statuts.oid) AS statut_id_array + FROM rh.t_data_profile + LEFT JOIN rh.t_statuts ON (t_statuts.code LIKE ANY(string_to_array(replace(t_data_profile.statut_inclus,'*','%'),',')) OR t_data_profile.statut_inclus = '' OR t_data_profile.statut_inclus IS NULL) + LEFT JOIN rh.t_statuts t_statuts_exclus ON t_data_profile.statut_exclus <> '' AND + t_statuts_exclus.code LIKE ANY(string_to_array(replace(t_data_profile.statut_exclus,'*','%'),',')) AND + t_statuts.oid = t_statuts_exclus.oid + WHERE t_statuts_exclus.oid IS NULL + GROUP BY 1 + )subview + WHERE subview.oid = t_data_profile.oid + ; + UPDATE rh.t_data_profile + SET etablissement_id_array = subview.etablissement_id_array + FROM + ( + SELECT + t_data_profile.oid, + base.cti_array_accum(t_etablissements.oid) AS etablissement_id_array + FROM rh.t_data_profile + LEFT JOIN rh.t_etablissements ON (t_etablissements.code LIKE ANY(string_to_array(replace(t_data_profile.etablissement_inclus,'*','%'),',')) OR t_data_profile.etablissement_inclus = '' OR t_data_profile.etablissement_inclus IS NULL) + LEFT JOIN rh.t_etablissements t_etablissements_exclus ON t_data_profile.etablissement_exclus <> '' AND + t_etablissements_exclus.code LIKE ANY(string_to_array(replace(t_data_profile.etablissement_exclus,'*','%'),',')) AND + t_etablissements.oid = t_etablissements_exclus.oid + WHERE t_etablissements_exclus.oid IS NULL + GROUP BY 1 + )subview + WHERE subview.oid = t_data_profile.oid + ; + -- Actualisation des schémas + DROP TABLE IF EXISTS w_tables; + CREATE TEMP TABLE w_tables AS + SELECT schemaname, tablename + FROM pg_tables + WHERE schemaname LIKE 'rh%' AND + tablename IN ('p_oids','p_indicateurs_cumules'); + DROP TABLE IF EXISTS w_views; + CREATE TEMP TABLE w_views AS + SELECT schemaname, viewname, definition + FROM pg_views + WHERE schemaname LIKE 'rh%'; + -- création des schémas + _sqlcmd = 'SELECT t_data_profile.code, + ''CREATE SCHEMA IF NOT EXISTS rh_DATA_PROFILE_'' || t_data_profile.code + FROM rh.t_data_profile + WHERE 1=1 + AND CASE WHEN trim('''||_in_data_profile_code||''') = '''' THEN true ELSE t_data_profile.code = trim('''||_in_data_profile_code||''') END + AND t_data_profile.code <> '''''; + OPEN _cursor FOR + EXECUTE _sqlcmd; + FETCH _cursor INTO _sqlobject, _tosqlcmd; + WHILE FOUND LOOP + + BEGIN + --RAISE NOTICE 'Schema = %',_sqlobject; + --RAISE NOTICE 'SQL %' , substr(_tosqlcmd,1,100); + EXECUTE _tosqlcmd; + + EXCEPTION + WHEN others THEN RAISE NOTICE 'Erreur %' , _tosqlcmd; + END; + + FETCH _cursor INTO _sqlobject, _tosqlcmd; + END LOOP; + CLOSE _cursor; + -- création des fichiers OIDS + _sqlcmd = 'SELECT from_tablename, + ''CREATE TABLE rh_DATA_PROFILE_'' || dataprofile_code || ''.'' || from_tablename || '' AS + SELECT * + FROM rh.'' || from_tablename || '' + LIMIT 0'' + FROM + ( + SELECT ''p_oids'' AS from_tablename, t_data_profile.code AS dataprofile_code FROM rh.t_data_profile + UNION + SELECT ''p_indicateurs_cumules'' AS from_tablename, t_data_profile.code AS dataprofile_code FROM rh.t_data_profile + ) subview + LEFT JOIN w_tables ON tablename = from_tablename AND + schemaname ILIKE ''rh_DATA_PROFILE_'' || dataprofile_code + WHERE tablename IS NULL'; + OPEN _cursor FOR + EXECUTE _sqlcmd; + FETCH _cursor INTO _sqlobject, _tosqlcmd; + WHILE FOUND LOOP + + BEGIN + --RAISE NOTICE 'Schema = %',_sqlobject; + --RAISE NOTICE 'SQL %' , substr(_tosqlcmd,1,100); + EXECUTE _tosqlcmd; + + EXCEPTION + WHEN others THEN RAISE NOTICE 'Erreur %' , _tosqlcmd; + END; + + FETCH _cursor INTO _sqlobject, _tosqlcmd; + END LOOP; + CLOSE _cursor; + -- recréation des vues dans un schema utilisateur + _sqlcmd = 'SELECT w_views.viewname, + t_data_profile.code, + ''DROP VIEW IF EXISTS '' || w_views.schemaname || ''_DATA_PROFILE_'' || t_data_profile.code || ''.'' || w_views.viewname || ''; '' || + ''CREATE VIEW '' || w_views.schemaname || ''_DATA_PROFILE_'' || t_data_profile.code || ''.'' || w_views.viewname || '' AS '' || w_views.definition, + COALESCE(''DROP VIEW IF EXISTS '' || w_views_deja.schemaname || ''.'' || w_views_deja.viewname || ''; '' || + ''CREATE VIEW '' || w_views_deja.schemaname || ''.'' || w_views_deja.viewname || '' AS '' || w_views_deja.definition,'''') + FROM w_views + JOIN rh.t_data_profile ON t_data_profile.code <> '''' + LEFT JOIN w_views w_views_deja ON w_views.viewname = w_views_deja.viewname AND + w_views_deja.schemaname ILIKE (''rh_DATA_PROFILE_'' || t_data_profile.code) + WHERE w_views.schemaname = ''rh'''; + --RAISE NOTICE 'SQL %' , _sqlcmd; + OPEN _cursor FOR + EXECUTE _sqlcmd; + FETCH _cursor INTO _sqlobject, _data_profile_code, _tosqlcmd, _tosqlcmd_deja; + WHILE FOUND LOOP + + BEGIN + -- Remplacement accès table p_indicateurs_cumules + _tosqlcmd = replace(_tosqlcmd, 'rh.p_indicateurs_cumules', + 'rh_data_profile_' || _data_profile_code || '.p_indicateurs_cumules' + ); + -- Remplacement accès table t_data_profile + _tosqlcmd = replace(_tosqlcmd, 'rh.t_data_profile', + '(rh.t_data_profile + JOIN rh.t_data_profile t_data_profile_2 ON t_data_profile_2.oid = t_data_profile.oid AND t_data_profile_2.code::text = ''' || _data_profile_code || '''::text)' + ); + -- Remplacement accès table t_services + _tosqlcmd = replace(_tosqlcmd, 'rh.t_services', + '(rh.t_services + JOIN rh.t_data_profile t_data_profile_service ON t_data_profile_service.code::text = ''' || _data_profile_code || '''::text AND t_services.oid = ANY (t_data_profile_service.service_id_array))' + ); + -- Remplacement accès table t_statuts + _tosqlcmd = replace(_tosqlcmd, 'rh.t_statuts', + '(rh.t_statuts + JOIN rh.t_data_profile t_data_profile_statut ON t_data_profile_statut.code::text = ''' || _data_profile_code || '''::text AND t_statuts.oid = ANY (t_data_profile_statut.statut_id_array))' + ); + -- Remplacement accès table t_etablissements + _tosqlcmd = replace(_tosqlcmd, 'rh.t_etablissements', + '(rh.t_etablissements + JOIN rh.t_data_profile t_data_profile_etablissement ON t_data_profile_etablissement.code::text = ''' || _data_profile_code || '''::text AND t_etablissements.oid = ANY (t_data_profile_etablissement.etablissement_id_array))' + ); + -- Remplacement accès table p_profils + _tosqlcmd = replace(_tosqlcmd, 'rh.p_profils', + '(rh.p_profils + JOIN rh.t_data_profile t_data_profile_profil ON t_data_profile_profil.code::text = ''' || _data_profile_code || '''::text AND + p_profils.service_id = ANY (t_data_profile_profil.service_id_array) AND + p_profils.statut_id = ANY (t_data_profile_profil.statut_id_array) + )' + ); + -- Remplacement accès table p_oids + _tosqlcmd = replace(_tosqlcmd, 'rh.p_oids', + 'rh_DATA_PROFILE_' || _data_profile_code || '.p_oids' + ); + IF lower(_tosqlcmd) <> lower(_tosqlcmd_deja) THEN + --RAISE NOTICE 'Vue = %',_sqlobject || ' (' || _data_profile_code || ')'; + --RAISE NOTICE 'SQL %' , _tosqlcmd; + --RAISE NOTICE 'SQL %' , _tosqlcmd_deja; + EXECUTE _tosqlcmd; + END IF; + + EXCEPTION + WHEN others THEN RAISE NOTICE 'Erreur %' , substr(_tosqlcmd,1,100); + END; + + FETCH _cursor INTO _sqlobject, _data_profile_code, _tosqlcmd, _tosqlcmd_deja; + END LOOP; + CLOSE _cursor; + -- Alimentation des oids par profil + _tosqlcmd_base = 'TRUNCATE rh.p_oids; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''anciennetes_annee''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''situations_famille''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''nationalites''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''codes_postaux''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''departements''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''motifs_arret''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''precisions_motif_arret''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''rubriques''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''organismes_cotisation''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''motifs_visite''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''accident_circonstance''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''accident_lieu''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''accident_nature''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''accident_siege''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''formations''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''compte''; + INSERT INTO rh.p_oids (code_table, oid) SELECT code_table, oid FROM rh.p_oids WHERE code_table = ''planning_type_absence''; + + INSERT INTO rh.p_oids (code_table, oid) SELECT ''salaries'', p_profil_contrat_mois.salarie_id FROM rh.p_profil_contrat_mois JOIN rh.p_profils ON p_profil_contrat_mois.profil_id = p_profils.oid GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''services'', p_profils.service_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''qualifications'', p_profils.qualification_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''types_temps_travail'', p_profils.type_temps_travail_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''types_contrat'', p_profils.type_contrat_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''specialites'', p_profils.specialite_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''categories_socio_professionnelle'', p_profils.categorie_socio_professionnelle_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''statuts'', p_profils.statut_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''codes_emploi'', p_profils.code_emploi_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''motifs_debut_contrat'', p_profils.motif_debut_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''motifs_fin_contrat'', p_profils.motif_fin_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''sections_analytiques_paie'', p_profils.section_analytique_paie_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''sections_analytiques'', p_profils.section_analytique_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''grilles'', p_profils.grille_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''grilles_groupes'', p_profils.grille_groupe_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''groupes_cotisant'', p_profils.groupe_cotisant_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''societes_interim'', p_profils.societe_interim_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''lettre_budgetaire'', p_profils.lettre_budgetaire_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''compte_salarie'', p_profils.compte_salarie_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''categorie_conge'', p_profils.categorie_conge_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''commission_paritaire'', p_profils.commission_paritaire_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''filiere'', p_profils.filiere_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''cadre_emploi'', p_profils.cadre_emploi_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''categorie_statutaire'', p_profils.categorie_statutaire_id FROM rh.p_profils GROUP BY 1,2; + INSERT INTO rh.p_oids (code_table, oid) SELECT ''unite_fonctionnelle'', p_profils.unite_fonctionnelle_id FROM rh.p_profils GROUP BY 1,2; + '; + -- recréation des vues dans un schema utilisateur + _sqlcmd = 'SELECT t_data_profile.code + FROM rh.t_data_profile + WHERE t_data_profile.code <> '''''; + --RAISE NOTICE 'SQL %' , _sqlcmd; + OPEN _cursor FOR + EXECUTE _sqlcmd; + FETCH _cursor INTO _data_profile_code; + WHILE FOUND LOOP + + BEGIN + --RAISE NOTICE 'SQL %' , _data_profile_code; + --RAISE NOTICE 'SQL %' , _tosqlcmd_base; + -- Remplacement accès table p_oids + _tosqlcmd = replace(_tosqlcmd_base, 'INSERT INTO rh.p_oids', + 'INSERT INTO rh_DATA_PROFILE_' || _data_profile_code || '.p_oids' + ); + _tosqlcmd = replace(_tosqlcmd, 'TRUNCATE rh.p_oids', + 'TRUNCATE rh_DATA_PROFILE_' || _data_profile_code || '.p_oids' + ); + + + -- Remplacement accès table p_profils + _tosqlcmd = replace(_tosqlcmd, 'rh.p_profils', + '(rh.p_profils + JOIN rh.t_data_profile ON t_data_profile.code::text = ''' || _data_profile_code || '''::text AND + p_profils.service_id = ANY (t_data_profile.service_id_array) AND + p_profils.statut_id = ANY (t_data_profile.statut_id_array) + )' + ); + -- Remplacement accès table t_etablissements + _tosqlcmd = replace(_tosqlcmd, 'rh.t_etablissements', + '(rh.t_etablissements + JOIN rh.t_data_profile ON t_data_profile.code::text = ''' || _data_profile_code || '''::text AND t_etablissements.oid = ANY (t_data_profile.etablissement_id_array))' + ); + --RAISE NOTICE 'SQL %' , _tosqlcmd; + EXECUTE _tosqlcmd; + + + EXCEPTION + WHEN others THEN RAISE NOTICE 'Erreur %' , substr(_tosqlcmd,1,100); + END; + + FETCH _cursor INTO _data_profile_code; + END LOOP; + CLOSE _cursor; + + + return 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_gen_od.yaml b/db/schema2/functions/cti_gen_od.yaml new file mode 100644 index 0000000..53aef5d --- /dev/null +++ b/db/schema2/functions/cti_gen_od.yaml @@ -0,0 +1,122 @@ +return: text +lang: plpgsql +src: | + DECLARE + result TEXT; + BEGIN + INSERT INTO rh.t_divers (code, texte, valeur, description) + SELECT + 'ODETP_SALARIE', + 'OD ETP. Liste des salaries', + ''::text, + 'Format MATRICULE:HEURES|MATRICULE:HEURES|MATRICULE:HEURES' + WHERE 'ODETP_SALARIE' NOT IN (SELECT code FROM rh.t_divers); + + INSERT INTO rh.t_divers (code, texte, valeur, description) + SELECT + 'ODETP_RUBRIQUE_BRUT', + 'OD ETP. Rubrique identifiant la presence', + ''::text, + 'Code de la rubrique' + WHERE 'ODETP_RUBRIQUE_BRUT' NOT IN (SELECT code FROM rh.t_divers); + + INSERT INTO rh.t_divers (code, texte, valeur, description) + SELECT + 'ODETP_RUBRIQUE_HEURE', + 'OD ETP. Rubrique d''heure pour generation OD', + ''::text, + 'Code de la rubrique' + WHERE 'ODETP_RUBRIQUE_HEURE' NOT IN (SELECT code FROM rh.t_divers); + + DROP TABLE IF EXISTS w_divers_odetp; + CREATE TEMP TABLE w_divers_odetp AS + SELECT p_salaries.oid AS odetp_salarie_id, + CASE WHEN ((string_to_array((string_to_array(replace(t_divers_odetp_salaries.valeur,',','.'),'|'))[i],':'))[2])::text <> '*' THEN base.cti_to_number((string_to_array((string_to_array(replace(t_divers_odetp_salaries.valeur,',','.'),'|'))[i],':'))[2]::text) + ELSE -1 END AS odetp_nb_heures, + t_rubriques_brut.oid AS odetp_rubrique_brut_id, + t_rubriques_heure.oid AS odetp_rubrique_heure_id + FROM rh.p_salaries + JOIN rh.t_divers t_divers_odetp_salaries ON t_divers_odetp_salaries.code = 'ODETP_SALARIE' + JOIN generate_series(1,100) i ON (string_to_array(t_divers_odetp_salaries.valeur,'|'))[i] <> '' + JOIN rh.t_divers t_divers_odetp_rubrique_brut ON t_divers_odetp_rubrique_brut.code = 'ODETP_RUBRIQUE_BRUT' + JOIN rh.t_divers t_divers_odetp_rubrique_heure ON t_divers_odetp_rubrique_heure.code = 'ODETP_RUBRIQUE_HEURE' + JOIN rh.t_rubriques t_rubriques_brut ON t_divers_odetp_rubrique_brut.valeur = t_rubriques_brut.code + JOIN rh.t_rubriques t_rubriques_heure ON t_divers_odetp_rubrique_heure.valeur = t_rubriques_heure.code + WHERE matricule = (string_to_array((string_to_array(t_divers_odetp_salaries.valeur,'|'))[i],':'))[1] + ; + DROP TABLE IF EXISTS w_odetp_mois; + CREATE TEMP TABLE w_odetp_mois AS + SELECT p_historique_paie.salarie_id, + p_historique_paie.contrat_mois_id, + mois_paie, + CASE WHEN MAX(odetp_nb_heures) >= 0 THEN MAX(odetp_nb_heures) ELSE 0 END AS odetp_heure_contrat, + CASE WHEN MAX(odetp_nb_heures) >= 0 THEN MAX(odetp_nb_heures) ELSE SUM(heure_contrat) END AS odetp_heure_payee, + MAX(odetp_rubrique_brut_id) AS odetp_rubrique_brut_id, + MAX(odetp_rubrique_heure_id) AS odetp_rubrique_heure_id + FROM rh.p_historique_paie + JOIN w_divers_odetp ON salarie_id = odetp_salarie_id + WHERE rubrique_id = odetp_rubrique_brut_id OR + rubrique_id = odetp_rubrique_heure_id OR + heure_contrat <> 0 AND odetp_nb_heures = -1 + GROUP BY 1,2,3 + HAVING MAX(CASE WHEN rubrique_id = odetp_rubrique_heure_id THEN rubrique_id ELSE 0 END) = 0 AND + MAX(CASE WHEN rubrique_id = odetp_rubrique_brut_id THEN rubrique_id ELSE 0 END) <> 0 + ; + DROP TABLE IF EXISTS w_odetp_historique; + CREATE TEMP TABLE w_odetp_historique AS + SELECT p_historique_paie.* + FROM rh.p_historique_paie + JOIN w_odetp_mois ON + p_historique_paie.salarie_id = w_odetp_mois.salarie_id AND + p_historique_paie.mois_paie = w_odetp_mois.mois_paie AND + p_historique_paie.contrat_mois_id = w_odetp_mois.contrat_mois_id AND + p_historique_paie.rubrique_id = odetp_rubrique_brut_id; + UPDATE w_odetp_historique SET + rubrique_id = odetp_rubrique_heure_id, + base = odetp_heure_payee, + heure_payee = odetp_heure_payee, + heure_travaillee = odetp_heure_payee, + heure_contrat = odetp_heure_contrat, + montant_brut = 0, + taux_cotisation_salarie = 0, + montant_cotisation_salarie = 0, + taux_cotisation_patronale = 0, + montant_cotisation_patronale = 0, + montant_net_imposable_salarie = 0, + montant_net_a_payer_salarie = 0, + montant_avantage_nature = 0, + montant_frais_imposables = 0, + montant_masse_salariale = 0, + montant_od_net_salarie = 0 + FROM w_odetp_mois + WHERE w_odetp_mois.salarie_id = w_odetp_historique.salarie_id AND + w_odetp_mois.contrat_mois_id = w_odetp_historique.contrat_mois_id AND + w_odetp_mois.mois_paie = w_odetp_historique.mois_paie + ; + INSERT INTO rh.p_historique_paie + SELECT * + FROM w_odetp_historique; + + UPDATE rh.p_chiffrier_production + SET nombre_heures_od = 0 + WHERE nombre_heures_od IS NULL; + + UPDATE rh.p_chiffrier_production + SET nombre_heures_od = p_chiffrier_production.nombre_heures_od + subview.nombre_heures_od + FROM + ( + SELECT t_etablissements.entreprise_id, + p_contrats.etablissement_id, + mois_paie, + SUM(base) AS nombre_heures_od + FROM w_odetp_historique + JOIN rh.p_contrats ON contrat_id = p_contrats.oid + JOIN rh.t_etablissements ON p_contrats.etablissement_id = t_etablissements.oid + GROUP BY 1,2,3 + ) subview + WHERE p_chiffrier_production.entreprise_id = subview.entreprise_id AND + p_chiffrier_production.etablissement_id = subview.etablissement_id AND + p_chiffrier_production.mois = subview.mois_paie; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_get_sae_contracts.yaml b/db/schema2/functions/cti_get_sae_contracts.yaml new file mode 100644 index 0000000..776ae5a --- /dev/null +++ b/db/schema2/functions/cti_get_sae_contracts.yaml @@ -0,0 +1,88 @@ +return: text +lang: plpgsql +src: | + DECLARE + year int; + tableToCheck text; + maxYearInserted int; + yearsToDo int[]; + tablesToCheck text[]; + request text; + canDoYear bool; + startDate date; + endDate date; + targetTable text; + + BEGIN + startDate = (COALESCE((SELECT MAX(annee) FROM rh.p_sae_contrats) + 1, 2017)|| '-01-01')::date; + endDate = (date_part('YEAR', NOW())::text || '-01-01')::date - interval '1 year'; + yearsToDo = (SELECT array_agg(date_part) FROM (SELECT date_part('YEAR', (generate_series(startDate, endDate, '1 year'::interval)))::int) AS sub); + tablesToCheck = ARRAY['t_#YEAR#_sae_contrat', 't_#YEAR#_sae_groupe_discipline']; + + -- Si une des 2 tables nécessaires n'existent pas + IF yearsToDo IS NULL THEN RETURN 'Aucune année à traiter'; END IF; + + FOREACH year IN ARRAY yearsToDo LOOP + -- Vérification de l'existence des tables requises pour l'année de la boucle + FOREACH tableToCheck IN ARRAY tablesToCheck LOOP + + IF year = 2017 THEN + tableToCheck = REPLACE(tableToCheck, '_#YEAR#_', '_'); + END IF; + + IF year > 2017 THEN + tableToCheck = REPLACE(tableToCheck, '#YEAR#', year); + END IF; + + canDoYear = ((SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'ssae' AND table_name = tableToCheck) = 1); + END LOOP; + + -- Si une des 2 tables nécessaires n'existent pas + IF NOT canDoYear THEN RETURN 'Une table nécessaire n''existe pas'; END IF; + + request = ' + INSERT INTO rh.p_sae_contrats ( + annee, + mois_activite_debut_id, + mois_activite_fin_id, + salarie_id, + contrat_code, + contrat_id, + groupe_discipline_texte, + qualification_texte, + filiere_texte + ) + SELECT + #YEAR# AS annee, + saec.mois_activite_debut_id, + saec.mois_activite_fin_id, + saec.salarie_id, + saec.contrat_code, + saec.contrat_id, + saegd.texte AS groupe_discipline_texte, + saec.qualification_texte, + CASE filiere_code + WHEN ''01'' THEN ''MEDECIN SOIGNANT'' + WHEN ''11'' THEN ''SOIGNANT'' + WHEN ''21'' THEN ''NON SOIGNANT'' + WHEN ''91'' THEN ''Hors champ SAE'' + ELSE ''???'' END AS filiere_texte + FROM ssae.t_#YEAR#_sae_contrat AS saec + LEFT JOIN ssae.t_#YEAR#_sae_groupe_discipline AS saegd ON saegd.oid = saec.groupe_discipline_id[1]' + ; + + IF year = 2017 THEN + request = replace(request, '_#YEAR#_', '_'); + request = replace(request, '#YEAR#', year); + END IF; + + IF year > 2017 THEN + request = replace(request, '#YEAR#', year); + END IF; + + EXECUTE request; + RAISE NOTICE 'Année % traitée', year; + + END LOOP; + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_hp_create_views.yaml b/db/schema2/functions/cti_hp_create_views.yaml new file mode 100644 index 0000000..49399e7 --- /dev/null +++ b/db/schema2/functions/cti_hp_create_views.yaml @@ -0,0 +1,75 @@ +return: text +lang: plpgsql +src: | + DECLARE + _nbPlanAna integer; -- Nb de plans analytiques possibles. + _templateName text; -- Nom de la vue SQL template. + _template text; -- source SQL template à compléter par cette fonction. + _opt_mode text; -- Option t_divers définissant quelle vue SQL source est à prendre + _viewName text; -- Nom de la vue à créer. + _sqlView text; -- SQL de la vue à créer. + _tmpRatio text; -- Ratio à appliquer. + _tmpSelectId text[]; -- Colonnes à ajouter. + _tmpSelectCode text[]; -- Colonnes à ajouter. + _tmpSelectTexte text[]; -- Colonnes à ajouter. + _tmpJoin text; -- Jointure à utiliser. + result text; + BEGIN + _nbPlanAna = 3; -- Actuellement on gère 3 plans analytiques maximum. + _templateName = 'v_historique_paie_0'; -- Par défaut, le template SQL à récupérer est situé dans cette vue. + _opt_mode = ''; -- Par défaut, on prend la vue standard. + + -- Récupération de l'option. + SELECT CASE WHEN valeur != '0' THEN '_1' ELSE '' END INTO _opt_mode FROM rh.t_divers WHERE code = 'OPT_STD_HP'; + + -- Récupération du template. + SELECT pg_get_viewdef(c.oid, true) INTO _template FROM pg_class c JOIN pg_namespace as n on n.oid = c.relnamespace WHERE n.nspname = 'rh' AND c.relname = _templateName||coalesce(_opt_mode, ''::text); + + -- La vue v_historique_paie_0 est un template dans lequel il faut remplace "* 999" et "JOIN ( SELECT 1) subq ON 1 = 1" par les bonnes valeurs. + FOR i IN 1..2^_nbPlanAna LOOP + _tmpRatio = ''; + _tmpSelectId = null; + _tmpSelectCode = null; + _tmpSelectTexte = null; + _tmpJoin = ''; + _sqlView = ''; + + IF (i::bit(3) = 0::bit(3)) THEN + _viewName = 'rh.v_historique_paie_1'; + ELSE + _viewName = 'rh.v_historique_paie_1_' || i::bit(3)::text; + END IF; + + FOR j IN 1.._nbPlanAna LOOP + IF (substr(i::bit(3)::text, j, 1) = '1') THEN + _tmpRatio = _tmpRatio || ' * v' || j::text || '.ratio'; + _tmpSelectId[j] = 'v' || j::text || '.section_analytique_id as ng_section_analytique_' || j::text || '_id, v' || j::text || '.section_analytique_section_id as ng_section_analytique_' || j::text || '_section_id'; + _tmpSelectCode[j] = 'v' || j::text || '.section_analytique_code as ng_section_analytique_' || j::text || '_code, v' || j::text || '.section_analytique_section_code as ng_section_analytique_' || j::text || '_section_code'; + _tmpSelectTexte[j] = 'v' || j::text || '.section_analytique_texte as ng_section_analytique_' || j::text || '_texte, v' || j::text || '.section_analytique_section_texte as ng_section_analytique_' || j::text || '_section_texte'; + _tmpJoin = _tmpJoin || ' JOIN rh.p_ventilation_section AS v' || j::text || ' ON v' || j::text || '.ventilation_id = p_historique_paie.ventilation_'|| j::text ||'_id'; + ELSE + _tmpSelectId[j] = 'null::bigint as ng_section_analytique_' || j::text || '_id'; + _tmpSelectCode[j] = 'null::text as ng_section_analytique_' || j::text || '_code'; + _tmpSelectTexte[j] = 'null::text as ng_section_analytique_' || j::text || '_texte'; + END IF; + END LOOP; + + -- Remplacements + _sqlView = replace (_template, '* 999', _tmpRatio); + _sqlView = replace (_sqlView, '999::bigint', array_to_string(_tmpSelectId, ', ', 'null::bigint')); + _sqlView = replace (_sqlView, '''section_analytique_ng_code''::text', array_to_string(_tmpSelectCode, ', ', 'null::text')); + _sqlView = replace (_sqlView, '''section_analytique_ng_texte''::text', array_to_string(_tmpSelectTexte, ', ', 'null::text')); + _sqlView = replace (_sqlView, 'JOIN ( SELECT 1) subq ON 1 = 1', _tmpJoin); + _sqlView = replace (_sqlView, ' AS to_replace_id', ''); + _sqlView = replace (_sqlView, ' AS to_replace_code', ''); + _sqlView = replace (_sqlView, ' AS to_replace_texte', ''); + + -- Suppression de la vue si elle existe. + EXECUTE 'DROP VIEW IF EXISTS ' || _viewName; + + -- Création de la vue. + EXECUTE 'CREATE VIEW ' || _viewName || ' AS ' || _sqlView; + END LOOP; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_now~tx,tx.yaml b/db/schema2/functions/cti_now~tx,tx.yaml new file mode 100644 index 0000000..c5192b3 --- /dev/null +++ b/db/schema2/functions/cti_now~tx,tx.yaml @@ -0,0 +1,67 @@ +return: date +lang: plpgsql +parameters: + p0: + type: text + name: i_code + p1: + type: text + name: i_option +src: | + DECLARE + _code text; + _option text; + _now date; + BEGIN + _code = i_code; + IF _code NOT IN ('NOW', 'NOWCLOTURE') THEN + _code = 'NOW'; + END IF; + _option = i_option; + IF NOT EXISTS (SELECT * FROM rh.t_divers WHERE code = _code) THEN + _option = 'FORCE'; + END IF; + IF _option = 'FORCE' THEN + _now = + CASE _code + WHEN 'NOW' THEN + (SELECT MAX(date_fin) FROM rh.p_contrats WHERE date_fin <= date(now()) ) + WHEN 'NOWCLOTURE' THEN + (SELECT CASE WHEN date(date_trunc('month',MAX(date_paie)) + interval '1 month' - interval '1 day') <= date(date_trunc('month',now() - interval '5 days')) THEN + date(date_trunc('month',MAX(date_paie)) + interval '1 month' - interval '1 day') + ELSE + date(date_trunc('month',MAX(date_paie)) - interval '1 day') + END + FROM rh.p_historique_paie WHERE date_paie <= date(date_trunc('month',now()) + interval '1 month' - interval '1 day') + ) + ELSE date(now()) + END; + UPDATE rh.t_divers SET + texte = CASE _code + WHEN 'NOW' THEN 'Date en-cours' + WHEN 'NOWCLOTURE' THEN 'Date clôture' + ELSE 'Date en-cours' + END, + valeur = to_char(_now, 'YYYYMM'), + valeur_date = _now, + show_info_module = true + WHERE code = _code; + INSERT INTO rh.t_divers (code, texte, valeur, valeur_date, description, show_info_module) + SELECT + _code, + CASE _code + WHEN 'NOW' THEN 'Date en-cours' + WHEN 'NOWCLOTURE' THEN 'Date clôture' + ELSE 'Date en-cours' + END, + to_char(_now, 'YYYYMM'), + _now, + 'Date non modifiable', + true + WHERE _code NOT IN (SELECT code FROM rh.t_divers); + ELSE + _now = (SELECT valeur_date FROM rh.t_divers WHERE code = _code); + END IF; + + RETURN _now; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport_calc_indicator~tx,tx,in,bi,bi,bi,bi,bi,bi.yaml b/db/schema2/functions/cti_prepare_rapport_calc_indicator~tx,tx,in,bi,bi,bi,bi,bi,bi.yaml new file mode 100644 index 0000000..bc03b79 --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport_calc_indicator~tx,tx,in,bi,bi,bi,bi,bi,bi.yaml @@ -0,0 +1,71 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: i_column_name + p1: + type: text + name: i_table_name + p2: + type: integer + name: i_array_index + p3: + type: bigint + name: i_indicateur_id + p4: + type: bigint + name: i_indicateur_associe_1_id + p5: + type: bigint + name: i_indicateur_associe_2_id + p6: + type: bigint + name: i_indicateur_associe_3_id + p7: + type: bigint + name: i_indicateur_associe_4_id + p8: + type: bigint + name: i_indicateur_associe_5_id + p9: + type: bigint + name: i_indicateur_associe_6_id + p10: + type: bigint + name: i_indicateur_associe_7_id + p11: + type: bigint + name: i_indicateur_associe_8_id + p12: + type: bigint + name: i_indicateur_associe_9_id + p13: + type: bigint + name: i_indicateur_associe_10_id +src: | + DECLARE + column_name text; + array_index text; + BEGIN + array_index = ''; + if i_array_index > 0 THEN + array_index = '[0000' || i_array_index || ']'; + END IF; + if i_table_name <> '*CALC' THEN + column_name = 'SUM(indicateurs[000' || i_indicateur_id || ']' || array_index ||')'; + ELSE + column_name = replace(i_column_name, '[1]', 'SUM(indicateurs[000' || i_indicateur_associe_1_id || ']' || array_index ||')'); + column_name = replace(column_name, '[2]', 'SUM(indicateurs[000' || i_indicateur_associe_2_id || ']' || array_index ||')'); + column_name = replace(column_name, '[3]', 'SUM(indicateurs[000' || i_indicateur_associe_3_id || ']' || array_index ||')'); + column_name = replace(column_name, '[4]', 'SUM(indicateurs[000' || i_indicateur_associe_4_id || ']' || array_index ||')'); + column_name = replace(column_name, '[5]', 'SUM(indicateurs[000' || i_indicateur_associe_5_id || ']' || array_index ||')'); + column_name = replace(column_name, '[6]', 'SUM(indicateurs[000' || i_indicateur_associe_6_id || ']' || array_index ||')'); + column_name = replace(column_name, '[7]', 'SUM(indicateurs[000' || i_indicateur_associe_7_id || ']' || array_index ||')'); + column_name = replace(column_name, '[8]', 'SUM(indicateurs[000' || i_indicateur_associe_8_id || ']' || array_index ||')'); + column_name = replace(column_name, '[9]', 'SUM(indicateurs[000' || i_indicateur_associe_9_id || ']' || array_index ||')'); + column_name = replace(column_name, '[10]', 'SUM(indicateurs[000' || i_indicateur_associe_10_id || ']' || array_index ||')'); + END IF; + + RETURN column_name; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport_comp~bi.yaml b/db/schema2/functions/cti_prepare_rapport_comp~bi.yaml new file mode 100644 index 0000000..2dbaaa1 --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport_comp~bi.yaml @@ -0,0 +1,78 @@ +return: SETOF record +lang: plpgsql +parameters: + p0: + type: bigint + name: i_rapport_id +src: | + DECLARE + sqlcmd text; + + + temp_cursor refcursor; + _oid integer; + _maxind integer; + + row RECORD; + BEGIN + + -- Selection des rubriques et ajout des conditions + PERFORM rh.cti_prepare_rapport_init(i_rapport_id) + ; + + FOR row IN + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_contrats_mois_1', 'COMP') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_historique_paie_1', 'COMP') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_arrets_travail_mois_1', 'COMP') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'PLANNING_MOUVEMENT', 'COMP') AS (name text, value text) + UNION + SELECT 'RUBRIQUES_RAPPORT', + + + base.cti_group_concat( + 'ARRAY[' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 3, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + + '(' || rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ' - ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 3, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ') ' || + ', ' || + + 'CASE WHEN ' || rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ' > 0 AND ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 3, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || '> 0 THEN ' || + 'base.cti_division((' || rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ' - ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 3, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || '), ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 3, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ') * 100 ' || + 'ELSE 0 END, ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 1, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + + '(' || rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 1, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ' - ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ') ' || + ', ' || + + + 'CASE WHEN ' || rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 1, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ' > 0 AND ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || '> 0 THEN ' || + 'base.cti_division((' || rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 1, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ' - ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || '), ' || + rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ') * 100 ' || + 'ELSE 0 END ' || + ']' + ) + + FROM (SELECT * FROM w_VP_rapports_rubriques t_rapports_rubriques + JOIN w_VP_indicateurs t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid + WHERE rapport_id = i_rapport_id ORDER BY numero_rubrique + ) subview + + LOOP + + + RETURN NEXT row; + END LOOP; + RETURN ; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport_get_column~tx,tx.yaml b/db/schema2/functions/cti_prepare_rapport_get_column~tx,tx.yaml new file mode 100644 index 0000000..ca6b97c --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport_get_column~tx,tx.yaml @@ -0,0 +1,109 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: i_column_name + p1: + type: text + name: i_option +src: | + DECLARE + to_column_name text; + listeString text; + listeCode text; + d int; + f int; + l int; + BEGIN + to_column_name = i_column_name; + IF (i_option = 'MONTH') THEN + IF to_column_name NOT ILIKE 'DISTINCT%' THEN + to_column_name = 'CASE WHEN COLUMNCHECKSEQUENCE THEN ' || to_column_name || ' ELSE NULL END'; + ELSE + to_column_name = 'DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN ' || substr(to_column_name,9) || ' ELSE NULL END'; + END IF; + END IF; + d = strpos(to_column_name,'[LISTE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 8, length(listeString) - 8); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_listes JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id WHERE t_listes.code = ''' || listeCode || ''')'); + END IF; + END IF; + d = strpos(to_column_name,'[LISTE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 8, length(listeString) - 8); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_listes JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id WHERE t_listes.code = ''' || listeCode || ''')'); + END IF; + END IF; + d = strpos(to_column_name,'[LISTE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 8, length(listeString) - 8); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_listes JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id WHERE t_listes.code = ''' || listeCode || ''')'); + END IF; + END IF; + d = strpos(to_column_name,'[LISTE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 8, length(listeString) - 8); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_listes JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id WHERE t_listes.code = ''' || listeCode || ''')'); + END IF; + END IF; + d = strpos(to_column_name,'[LISTE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 8, length(listeString) - 8); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_listes JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id WHERE t_listes.code = ''' || listeCode || ''')'); + END IF; + END IF; + d = strpos(to_column_name,'[CLASSE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 9, length(listeString) - 9); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_classes JOIN rh.t_classes_sections ON classe_id = t_classes.oid JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid WHERE t_classes.code || '':'' || t_classes_sections.code = ''' || listeCode || ''')'); + END IF; + END IF; + d = strpos(to_column_name,'[CLASSE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 9, length(listeString) - 9); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_classes JOIN rh.t_classes_sections ON classe_id = t_classes.oid JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid WHERE t_classes.code || '':'' || t_classes_sections.code = ''' || listeCode || ''')'); + END IF; + END IF; + d = strpos(to_column_name,'[CLASSE:'); + IF (d > 0) THEN + f = strpos(to_column_name,']'); + IF (f > 0) THEN + l = f - d + 1; + listeString = substr(to_column_name, d, l); + listeCode = substr(listeString, 9, length(listeString) - 9); + to_column_name = replace(to_column_name, listeString, '(SELECT to_id FROM rh.t_classes JOIN rh.t_classes_sections ON classe_id = t_classes.oid JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid WHERE t_classes.code || '':'' || t_classes_sections.code = ''' || listeCode || ''')'); + END IF; + END IF; + + RETURN to_column_name; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport_get_column~tx.yaml b/db/schema2/functions/cti_prepare_rapport_get_column~tx.yaml new file mode 100644 index 0000000..13b39e0 --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport_get_column~tx.yaml @@ -0,0 +1,17 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: i_column_name +src: | + DECLARE + to_column_name text; + BEGIN + to_column_name = i_column_name; + + to_column_name = regexp_replace(to_column_name, '\[LISTE:(.*?)\]', '(SELECT to_id FROM rh.t_listes JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id WHERE t_listes.code = ''\1'')', 'g'); + to_column_name = regexp_replace(to_column_name, '\[CLASSE:(.*?)\]', '(SELECT to_id FROM rh.t_classes JOIN rh.t_classes_sections ON classe_id = t_classes.oid JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid WHERE t_classes.code || '':'' || t_classes_sections.code = ''\1'')', 'g'); + + RETURN to_column_name; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport_indicateurs~bi,tx,tx.yaml b/db/schema2/functions/cti_prepare_rapport_indicateurs~bi,tx,tx.yaml new file mode 100644 index 0000000..20f48fc --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport_indicateurs~bi,tx,tx.yaml @@ -0,0 +1,215 @@ +return: SETOF record +lang: plpgsql +parameters: + p0: + type: bigint + name: i_rapport_id + p1: + type: text + name: i_table_name + p2: + type: text + name: i_option +src: | + DECLARE + sqlcmd text; + + + temp_cursor refcursor; + _oid integer; + _count integer; + _table_count integer; + _maxind integer; + _indicateur_name text; + + row RECORD; + BEGIN + + _maxind = 100; + _table_count = 0; + + OPEN temp_cursor FOR + SELECT MAX(oid), SUM(CASE WHEN i_table_name = table_name THEN 1 ELSE 0 END) + FROM w_VP_indicateurs t_indicateurs + WHERE oid IN ( + SELECT base.cti_unnest( + ARRAY[ + indicateur_id, + indicateur_associe_1_id, + indicateur_associe_2_id, + indicateur_associe_3_id, + indicateur_associe_4_id, + indicateur_associe_5_id, + indicateur_associe_6_id, + indicateur_associe_7_id, + indicateur_associe_8_id, + indicateur_associe_9_id, + indicateur_associe_10_id + ]) + FROM rh.t_rapports + JOIN w_VP_rapports_rubriques t_rapports_rubriques ON t_rapports.oid = t_rapports_rubriques.rapport_id AND rapport_id = i_rapport_id + JOIN w_VP_indicateurs t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid); + + FETCH temp_cursor INTO _oid,_count; + WHILE FOUND LOOP + _maxind = _oid; + _table_count = _count; + FETCH temp_cursor INTO _oid, _count; + END LOOP; + CLOSE temp_cursor; + _indicateur_name = CASE i_table_name WHEN 'v_contrats_mois_1' THEN 'INDICATEURS_CONTRAT' + WHEN 'v_historique_paie_1' THEN 'INDICATEURS_PAIE' + WHEN 'v_arrets_travail_mois_1' THEN 'INDICATEURS_ARRET' + WHEN 'PLANNING_MOUVEMENT' THEN 'INDICATEURS_PLANNING' + WHEN 'CALENDRIER' THEN 'INDICATEURS_CALENDRIER' + ELSE 'INDICATEURS_OTHERS' END; + IF (_table_count = 0) THEN + FOR row IN SELECT _indicateur_name::text, ''::text + LOOP + RETURN NEXT row; + END LOOP; + END IF; + + IF (i_option <> 'MONTH' AND i_option <> 'COMP' AND _table_count > 0) THEN + FOR row IN + SELECT + _indicateur_name::text, base.cti_group_concat(CASE WHEN subview.oid IS NOT NULL THEN total_function || '(' || rh.cti_prepare_rapport_get_column(column_name) || ')' ELSE 'NULL::numeric' END) + FROM generate_series(1, _maxind) + LEFT JOIN + ( + SELECT * + FROM w_VP_indicateurs t_indicateurs + WHERE oid IN ( + SELECT base.cti_unnest( + ARRAY[ + indicateur_id, + indicateur_associe_1_id, + indicateur_associe_2_id, + indicateur_associe_3_id, + indicateur_associe_4_id, + indicateur_associe_5_id, + indicateur_associe_6_id, + indicateur_associe_7_id, + indicateur_associe_8_id, + indicateur_associe_9_id, + indicateur_associe_10_id + ]) + FROM rh.t_rapports + JOIN w_VP_rapports_rubriques t_rapports_rubriques ON t_rapports.oid = t_rapports_rubriques.rapport_id AND rapport_id = i_rapport_id + JOIN w_VP_indicateurs t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid) + ) subview ON generate_series = subview.oid AND subview.table_name = i_table_name + + + + LOOP + RETURN NEXT row; + END LOOP; + + END IF; + IF (i_option = 'MONTH' AND _table_count > 0) THEN + FOR row IN + SELECT + _indicateur_name::text, + base.cti_group_concat( + CASE WHEN subview.oid IS NOT NULL THEN + 'ARRAY[' + || '(' || total_function || '(' || rh.cti_prepare_rapport_get_column(column_name) || ')::numeric),' + || replace(month_formula, '#SEQ#', '< 1') || ',' + || replace(month_formula, '#SEQ#', '= 1') || ',' + || replace(month_formula, '#SEQ#', '= 2') || ',' + || replace(month_formula, '#SEQ#', '= 3') || ',' + || replace(month_formula, '#SEQ#', '= 4') || ',' + || replace(month_formula, '#SEQ#', '= 5') || ',' + || replace(month_formula, '#SEQ#', '= 6') || ',' + || replace(month_formula, '#SEQ#', '= 7') || ',' + || replace(month_formula, '#SEQ#', '= 8') || ',' + || replace(month_formula, '#SEQ#', '= 9') || ',' + || replace(month_formula, '#SEQ#', '= 10') || ',' + || replace(month_formula, '#SEQ#', '= 11') || ',' + || replace(month_formula, '#SEQ#', '= 12') || '' + || ']' + ELSE 'ARRAY[NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric,NULL::numeric]' END) + FROM generate_series(1, _maxind) + LEFT JOIN + ( + SELECT *, + CASE WHEN column_name ILIKE '%DISTINCT%' + THEN total_function || '(DISTINCT CASE WHEN columnby_sequence #SEQ# THEN ' || replace(rh.cti_prepare_rapport_get_column(column_name),'DISTINCT','') || ' ELSE NULL END)' + ELSE total_function || '(CASE WHEN columnby_sequence #SEQ# THEN ' || rh.cti_prepare_rapport_get_column(column_name) || ' ELSE NULL END)' END AS month_formula + FROM w_VP_indicateurs t_indicateurs + WHERE oid IN ( + SELECT base.cti_unnest( + ARRAY[ + indicateur_id, + indicateur_associe_1_id, + indicateur_associe_2_id, + indicateur_associe_3_id, + indicateur_associe_4_id, + indicateur_associe_5_id, + indicateur_associe_6_id, + indicateur_associe_7_id, + indicateur_associe_8_id, + indicateur_associe_9_id, + indicateur_associe_10_id + ]) + FROM rh.t_rapports + JOIN w_VP_rapports_rubriques t_rapports_rubriques ON t_rapports.oid = t_rapports_rubriques.rapport_id AND rapport_id = i_rapport_id + JOIN w_VP_indicateurs t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid) + ) subview ON generate_series = subview.oid AND subview.table_name = i_table_name + + + + LOOP + RETURN NEXT row; + END LOOP; + + END IF; + IF (i_option = 'COMP' AND _table_count > 0) THEN + FOR row IN + SELECT + _indicateur_name::text, + base.cti_group_concat( + CASE WHEN subview.oid IS NOT NULL THEN + 'ARRAY[' + || replace(month_formula, '#SEQ#', '= 1') || '::numeric,' + || replace(month_formula, '#SEQ#', '= 2') || '::numeric,' + || replace(month_formula, '#SEQ#', '= 3') || '::numeric' + || ']' + ELSE 'ARRAY[NULL::numeric,NULL::numeric,NULL::numeric]' END) + FROM generate_series(1, _maxind) + LEFT JOIN + ( + SELECT *, + CASE WHEN column_name ILIKE '%DISTINCT%' + THEN total_function || '(DISTINCT CASE WHEN columnby_sequence #SEQ# THEN ' || replace(rh.cti_prepare_rapport_get_column(column_name),'DISTINCT','') || ' ELSE NULL END)' + ELSE total_function || '(CASE WHEN columnby_sequence #SEQ# THEN ' || rh.cti_prepare_rapport_get_column(column_name) || ' ELSE NULL END)' END AS month_formula + FROM w_VP_indicateurs t_indicateurs + WHERE oid IN ( + SELECT base.cti_unnest( + ARRAY[ + indicateur_id, + indicateur_associe_1_id, + indicateur_associe_2_id, + indicateur_associe_3_id, + indicateur_associe_4_id, + indicateur_associe_5_id, + indicateur_associe_6_id, + indicateur_associe_7_id, + indicateur_associe_8_id, + indicateur_associe_9_id, + indicateur_associe_10_id + ]) + FROM rh.t_rapports + JOIN w_VP_rapports_rubriques t_rapports_rubriques ON t_rapports.oid = t_rapports_rubriques.rapport_id AND rapport_id = i_rapport_id + JOIN w_VP_indicateurs t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid) + ) subview ON generate_series = subview.oid AND subview.table_name = i_table_name + + + + LOOP + RETURN NEXT row; + END LOOP; + + END IF; + RETURN ; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport_init~bi.yaml b/db/schema2/functions/cti_prepare_rapport_init~bi.yaml new file mode 100644 index 0000000..c38e513 --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport_init~bi.yaml @@ -0,0 +1,158 @@ +return: text +lang: plpgsql +parameters: + p0: + type: bigint + name: i_rapport_id +src: | + DECLARE + + BEGIN + + DROP TABLE IF EXISTS w_VP_rapports_rubriques; + CREATE TEMP TABLE w_VP_rapports_rubriques AS + SELECT t_rapports_rubriques.*, + array_cat(CASE WHEN erase_rapport_indicateur_condition IS DISTINCT FROM '1' THEN t_rapports.rapport_indicateur_condition_id ELSE NULL END,indicateur_condition_id) AS vp_indicateur_condition_id + FROM rh.t_rapports_rubriques + JOIN rh.t_rapports ON rapport_id = t_rapports.oid + WHERE rapport_id = i_rapport_id + ; + + + DROP TABLE IF EXISTS w_VP_indicateurs; + CREATE TEMP TABLE w_VP_indicateurs AS + SELECT t_indicateurs_target.*, + numero_rubrique AS vp_numero_rubrique, + vp_indicateur_condition_id AS indicateur_condition_id, + ''::text AS indicateur_condition_where, + row_number() OVER(ORDER BY numero_rubrique, indicateur_id) AS vp_oid + FROM rh.t_indicateurs + JOIN rh.t_indicateurs t_indicateurs_target ON + ( + t_indicateurs.total_function = '*CALC' AND + t_indicateurs_target.oid = ANY( + ARRAY[ + t_indicateurs.indicateur_associe_1_id, + t_indicateurs.indicateur_associe_2_id, + t_indicateurs.indicateur_associe_3_id, + t_indicateurs.indicateur_associe_4_id, + t_indicateurs.indicateur_associe_5_id, + t_indicateurs.indicateur_associe_6_id, + t_indicateurs.indicateur_associe_7_id, + t_indicateurs.indicateur_associe_8_id, + t_indicateurs.indicateur_associe_9_id, + t_indicateurs.indicateur_associe_10_id + ]) OR + t_indicateurs.oid = t_indicateurs_target.oid + ) + JOIN w_VP_rapports_rubriques t_rapports_rubriques ON + t_indicateurs.oid = t_rapports_rubriques.indicateur_id + ORDER BY numero_rubrique, indicateur_id + ; + + + UPDATE w_VP_rapports_rubriques + SET indicateur_id = w_VP_indicateurs.vp_oid + FROM w_VP_indicateurs + WHERE w_VP_rapports_rubriques.numero_rubrique = w_VP_indicateurs.vp_numero_rubrique AND + w_VP_rapports_rubriques.indicateur_id = w_VP_indicateurs.oid + ; + + UPDATE w_VP_indicateurs + SET indicateur_associe_1_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_1_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_2_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_2_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_3_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_3_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_4_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_4_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_5_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_5_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_6_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_6_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_7_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_7_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_8_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_8_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_9_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_9_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + UPDATE w_VP_indicateurs + SET indicateur_associe_10_id = w_VP_indicateurs_f.vp_oid + FROM w_VP_indicateurs w_VP_indicateurs_f + WHERE w_VP_indicateurs.indicateur_associe_10_id = w_VP_indicateurs_f.oid AND + w_VP_indicateurs.vp_numero_rubrique = w_VP_indicateurs_f.vp_numero_rubrique + ; + + UPDATE w_VP_indicateurs SET + oid = vp_oid + ; + + UPDATE w_VP_indicateurs SET + indicateur_condition_where = condition_where + FROM + ( + SELECT w_VP_indicateurs.oid, array_to_string(array_agg('('||COALESCE(t_indicateur_condition_table_spec.check_where,t_indicateur_condition_table.check_where)||')'),' AND ') AS condition_where + FROM w_VP_indicateurs + JOIN rh.t_indicateur_condition ON t_indicateur_condition.oid = ANY(indicateur_condition_id) + JOIN rh.t_indicateur_condition_table ON + t_indicateur_condition_table.indicateur_condition_id = t_indicateur_condition.oid AND + t_indicateur_condition_table.table_name = '' + LEFT JOIN rh.t_indicateur_condition_table t_indicateur_condition_table_spec ON + t_indicateur_condition_table_spec.indicateur_condition_id = t_indicateur_condition.oid AND + t_indicateur_condition_table_spec.table_name = w_VP_indicateurs.table_name + WHERE COALESCE(t_indicateur_condition_table_spec.check_where,t_indicateur_condition_table.check_where) <> '' + GROUP BY 1 + ) subview + WHERE w_VP_indicateurs.oid = subview.oid + ; + + UPDATE w_VP_indicateurs + SET column_name = + CASE WHEN column_name ILIKE 'DISTINCT%' THEN 'DISTINCT ' ELSE '' END || + 'CASE WHEN ' || indicateur_condition_where || + ' THEN ' || CASE WHEN column_name ILIKE 'DISTINCT%' THEN substr(column_name,9) ELSE column_name END || + ' ELSE ' || + CASE WHEN total_function = 'SUM' THEN '0' ELSE 'NULL' END || ' END' + WHERE indicateur_condition_where <> '' AND + total_function In('SUM','COUNT') + ; + + RETURN 'OK'; + + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport_month~bi.yaml b/db/schema2/functions/cti_prepare_rapport_month~bi.yaml new file mode 100644 index 0000000..1db62c7 --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport_month~bi.yaml @@ -0,0 +1,65 @@ +return: SETOF record +lang: plpgsql +parameters: + p0: + type: bigint + name: i_rapport_id +src: | + DECLARE + sqlcmd text; + + + temp_cursor refcursor; + _oid integer; + _maxind integer; + + row RECORD; + BEGIN + + -- Selection des rubriques et ajout des conditions + PERFORM rh.cti_prepare_rapport_init(i_rapport_id) + ; + + FOR row IN + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_contrats_mois_1', 'MONTH') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_historique_paie_1', 'MONTH') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_arrets_travail_mois_1', 'MONTH') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'PLANNING_MOUVEMENT', 'MONTH') AS (name text, value text) + UNION + SELECT 'RUBRIQUES_RAPPORT', + + + base.cti_group_concat( + 'ARRAY[' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 1, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 2, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 3, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 4, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 5, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 6, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 7, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 8, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 9, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 10, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 11, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 12, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 13, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) || ', ' || + rh.cti_prepare_rapport_calc_indicator(rh.cti_prepare_rapport_get_column(column_name), table_name, 14, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id) + || ']' + ) + + FROM (SELECT * FROM w_VP_rapports_rubriques t_rapports_rubriques + JOIN w_VP_indicateurs t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid + WHERE rapport_id = i_rapport_id ORDER BY numero_rubrique + ) subview + + LOOP + + + RETURN NEXT row; + END LOOP; + RETURN ; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_prepare_rapport~bi.yaml b/db/schema2/functions/cti_prepare_rapport~bi.yaml new file mode 100644 index 0000000..27264ec --- /dev/null +++ b/db/schema2/functions/cti_prepare_rapport~bi.yaml @@ -0,0 +1,83 @@ +return: SETOF record +lang: plpgsql +parameters: + p0: + type: bigint + name: i_rapport_id +src: | + DECLARE + sqlcmd text; + + temp_cursor refcursor; + _oid integer; + _maxind integer; + + row RECORD; + BEGIN + + -- Selection des rubriques et ajout des conditions + PERFORM rh.cti_prepare_rapport_init(i_rapport_id) + ; + + FOR row IN + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_contrats_mois_1', '') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_historique_paie_1', '') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_arrets_travail_mois_1', '') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'PLANNING_MOUVEMENT', '') AS (name text, value text) + UNION + SELECT * FROM rh.cti_prepare_rapport_indicateurs(i_rapport_id, 'CALENDRIER', '') AS (name text, value text) + UNION + + + SELECT 'RUBRIQUES_RAPPORT', + base.cti_group_concat(rh.cti_prepare_rapport_calc_indicator(column_name, table_name, 0, indicateur_id, indicateur_associe_1_id , indicateur_associe_2_id , indicateur_associe_3_id ,indicateur_associe_4_id ,indicateur_associe_5_id ,indicateur_associe_6_id ,indicateur_associe_7_id, indicateur_associe_8_id, indicateur_associe_9_id, indicateur_associe_10_id)) + FROM (SELECT * FROM w_VP_rapports_rubriques t_rapports_rubriques + JOIN w_VP_indicateurs t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid + WHERE rapport_id = i_rapport_id ORDER BY numero_rubrique + ) subview + UNION + + + SELECT 'IC' || numero_rubrique, t_indicateurs.oid::text FROM w_VP_rapports_rubriques t_rapports_rubriques, w_VP_indicateurs t_indicateurs + WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid + + UNION + + SELECT 'IH' || numero_rubrique, CASE WHEN t_rapports_rubriques.entete <> '' THEN t_rapports_rubriques.entete ELSE t_indicateurs.entete END FROM w_VP_rapports_rubriques t_rapports_rubriques, w_VP_indicateurs t_indicateurs + WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid + + UNION + + SELECT 'IW' || numero_rubrique, + CASE + WHEN t_indicateurs.table_name = 'SEP' THEN '2' + WHEN t_rapports_rubriques.width > 0 THEN t_rapports_rubriques.width::text + WHEN t_indicateurs.width > 0 THEN t_indicateurs.width::text + ELSE '80' + END + FROM w_VP_rapports_rubriques t_rapports_rubriques, w_VP_indicateurs t_indicateurs + WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid + + UNION + + SELECT 'IO' || numero_rubrique, + CASE WHEN t_rapports_rubriques.output_format <> '' THEN t_rapports_rubriques.output_format + WHEN t_indicateurs.output_format <> '' THEN t_indicateurs.output_format + ELSE '#' END + FROM w_VP_rapports_rubriques t_rapports_rubriques, w_VP_indicateurs t_indicateurs + WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid + + UNION + + SELECT 'IT' || numero_rubrique, t_indicateurs.table_name::text FROM w_VP_rapports_rubriques t_rapports_rubriques, w_VP_indicateurs t_indicateurs + WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid + LOOP + + + RETURN NEXT row; + END LOOP; + RETURN ; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_reorganize_indicateur_condition.yaml b/db/schema2/functions/cti_reorganize_indicateur_condition.yaml new file mode 100644 index 0000000..b52b442 --- /dev/null +++ b/db/schema2/functions/cti_reorganize_indicateur_condition.yaml @@ -0,0 +1,1796 @@ +return: text +lang: plpgsql +src: | + DECLARE + + sqlcmd text; + def_cursor refcursor; + _schemaname text; + result TEXT; + BEGIN + + -- Entreprises + DROP TABLE IF EXISTS w_indicateur_condition; + CREATE TEMP TABLE w_indicateur_condition AS + SELECT + 'CTI_ENTREPRISE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_ENTREPRISE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Entreprise. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_entreprise_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'ETABLISSEMENT='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'D2%' THEN COALESCE('D2#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ]::text[] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + + ]::text[] AS arbre_texte + FROM rh.v_etablissements_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_entreprises t_source ON v_source.oid LIKE 'D2%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid LIKE 'D2%' AND + v_source.oid <> '-1' + ; + + -- Etablissement + INSERT INTO w_indicateur_condition + SELECT + 'CTI_ETABLISSEMENT#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_ETABLISSEMENT#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Etablissement. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_etablissement_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'ETABLISSEMENT='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + + ] AS arbre_texte + FROM rh.v_etablissements_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_etablissements t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid NOT LIKE 'D2%' AND + v_source.oid <> '-1' + ; + + -- Service + INSERT INTO w_indicateur_condition + SELECT + 'CTI_SERVICE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_SERVICE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Service. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'service_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'SERVICE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_services_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_services t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Groupe de grille + INSERT INTO w_indicateur_condition + SELECT + 'CTI_GRILLE_GROUPE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_GRILLE_GROUPE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Grille groupe. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'grille_groupe_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'GRILLE GROUPE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_grilles_groupes_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_grilles_groupes t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Grille + INSERT INTO w_indicateur_condition + SELECT + 'CTI_GRILLE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_GRILLE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Grille. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'grille_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'GRILLE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_grilles_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_grilles t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Population + INSERT INTO w_indicateur_condition + SELECT + 'CTI_POPULATION#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_POPULATION#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Population. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'population_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'POPULATION='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_population_2 v_source + LEFT JOIN rh.t_classes_sections ON true + AND v_source.oid LIKE 'LS%' + AND t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON true + AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') + AND t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables AS t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_population t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE true + AND v_source.oid NOT LIKE 'LC%' + AND (false + OR v_source.oid NOT LIKE 'LS%' + OR substr(v_source.oid,5) <> '0') + AND v_source.oid <> '-1' + + ; + + -- Service + INSERT INTO w_indicateur_condition + SELECT + 'CTI_POLE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_POLE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Pole. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_pole_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'POLE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_pole_2 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_pole t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Clé budget + INSERT INTO w_indicateur_condition + SELECT + 'CTI_BUD#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_BUD#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Clé budgetaire. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_budget_cle_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'BUD='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_budget_cle_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_budget_cle t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + + + -- Service planning + INSERT INTO w_indicateur_condition + SELECT + 'CTI_PLANNINGSERVICESOURCE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_PLANNINGSERVICESOURCE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Service source Planning. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_planning_service_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'PLANNING_SERVICE_SOURCE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_planning_service_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_planning_service t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Qualifications + INSERT INTO w_indicateur_condition + SELECT + 'CTI_QUALIFICATION#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_QUALIFICATION#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Qualification. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'qualification_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'QUALIFICATION='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_qualifications_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_qualifications t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Qualifications planning + INSERT INTO w_indicateur_condition + SELECT + 'CTI_PLANNINGQUALIFICATIONSOURCE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_PLANNINGQUALIFICATIONSOURCE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Service source Planning. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_planning_qualification_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'PLANNING_SERVICE_SOURCE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_planning_qualification_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_planning_qualification t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- PLANNING - Type d'absence. + INSERT INTO w_indicateur_condition + SELECT + 'CTI_PLANNINGTYPEABSENCE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_PLANNINGTYPEABSENCE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Type absence Planning. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_planning_type_absence_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'PLANNING_TYPE_ABSENCE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_planning_type_absence_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_motifs_debut_contrat t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Types de contrat + INSERT INTO w_indicateur_condition + SELECT + 'CTI_TYPECONTRAT#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_TYPECONTRAT#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Type contrat. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'type_contrat_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'TYPE_CONTRAT='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_types_contrat_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_types_contrat t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Codes emploi + INSERT INTO w_indicateur_condition + SELECT + 'CTI_CODEEMPLOI#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_CODEEMPLOI#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Code emploi. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'code_emploi_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'CODE_EMPLOI='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_codes_emploi_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_codes_emploi t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Type temps de travail. + INSERT INTO w_indicateur_condition + SELECT + 'CTI_TYPETEMPSW#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_TYPETEMPSW#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Type tps trav.. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'type_temps_travail_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'TYPE_TEMPS_TRAVAIL='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_types_temps_travail_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_types_temps_travail t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Types horaire + INSERT INTO w_indicateur_condition + SELECT + 'CTI_TYPEHORAIRE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_TYPEHORAIRE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Type horaire. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'type_horaire_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'TYPE_HORAIRE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_types_horaire_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_types_horaire t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Spécialités + INSERT INTO w_indicateur_condition + SELECT + 'CTI_SPECIALITE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_SPECIALITE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Spécialité. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'specialite_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'SPECIALITE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_specialites_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_specialites t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Salarié + INSERT INTO w_indicateur_condition + SELECT + 'CTI_SALARIE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_SALARIE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Salarié. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'salarie_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'SALARIE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN COALESCE('LI#'||t_listes.code,v_source.oid) + WHEN v_source.oid LIKE 'SL%' THEN COALESCE('SL#'||t_listes.code,v_source.oid) + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_salaries_2 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) AND + t_listes.code <> '' + LEFT JOIN rh.p_salaries t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE 1=1 + AND v_source.oid NOT LIKE 'LC%' + AND v_source.oid NOT LIKE 'DT%' + AND (1!=1 + OR v_source.oid NOT LIKE 'LS%' + OR substr(v_source.oid, 5) != '0') + AND v_source.oid != '-1' + ; + + -- Sexe + INSERT INTO w_indicateur_condition + SELECT + 'CTI_SEXE#DT1'::text AS code, + 'CTI_SEXE#DT1'::text AS condition_code, + 'CTI_SEXE#'::text AS category_id, + 'Sexe masculin' AS texte, + 'Sexe masculin'::text AS texte_court, + 'sexe_id'::text AS column_name, + ''::text AS rule, + 'DT1'::text AS value, + 'SEXE=DT1' AS view_select_rule, + ARRAY[ + '9' , + 'DT#1' + ] AS arbre_code, + ARRAY[ + 'Valeurs', + 'Sexe masculin' + ] AS arbre_texte + + ; + INSERT INTO w_indicateur_condition + SELECT + 'CTI_SEXE#DT2'::text AS code, + 'CTI_SEXE#DT2'::text AS condition_code, + 'CTI_SEXE#'::text AS category_id, + 'Sexe féminin' AS texte, + 'Sexe féminin'::text AS texte_court, + 'sexe_id'::text AS column_name, + ''::text AS rule, + 'DT2'::text AS value, + 'SEXE=DT2' AS view_select_rule, + ARRAY[ + '9' , + 'DT#2' + ] AS arbre_code, + ARRAY[ + 'Valeurs', + 'Sexe féminin' + ] AS arbre_texte + + ; + + -- Ages + INSERT INTO w_indicateur_condition + SELECT + 'CTI_AGE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_AGE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Age. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'age_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'AGE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_ages_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN base.t_ages t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Ancienneté + INSERT INTO w_indicateur_condition + SELECT + 'CTI_ANCIENNETE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_ANCIENNETE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Ancienneté. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rhp_anciennete_annee_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'ANCIENNETE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_anciennetes_annee_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_anciennetes_annee t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- nationalité + INSERT INTO w_indicateur_condition + SELECT + 'CTI_NATIONALITE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_NATIONALITE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Nationalité. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'nationalite_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'NATIONALITE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_nationalites_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_nationalites t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Motif début + INSERT INTO w_indicateur_condition + SELECT + 'CTI_MOTIFDEBUTCONTRAT#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_MOTIFDEBUTCONTRAT#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Motif début de contrat. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'motif_debut_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'MOTIF_DEBUT_CONTRAT='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_motifs_debut_contrat_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_motifs_debut_contrat t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Motif fin + INSERT INTO w_indicateur_condition + SELECT + 'CTI_MOTIFFINCONTRAT#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_MOTIFFINCONTRAT#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Motif fin de contrat. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'motif_fin_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'MOTIF_FIN_CONTRAT='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_motifs_fin_contrat_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_motifs_fin_contrat t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Rubriques + INSERT INTO w_indicateur_condition + SELECT + 'CTI_RUBRIQUE#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_RUBRIQUE#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Rubrique. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'rubrique_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'RUBRIQUE='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + v_source.texte + ] AS arbre_texte + FROM rh.v_rubriques_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_rubriques t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + + -- motifs arret + INSERT INTO w_indicateur_condition + SELECT + 'CTI_MOTIF_ARRET#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_MOTIF_ARRET#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Motif. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'motif_arret_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'MOTIF_ARRET='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + v_source.texte + ] AS arbre_texte + FROM rh.v_motifs_arret_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_motifs_arret t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- Statuts + INSERT INTO w_indicateur_condition + SELECT + 'CTI_STATUT#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_STATUT#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'Statut. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'statut_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'STATUT='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_statuts_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_statuts t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + -- CSP + + INSERT INTO w_indicateur_condition + SELECT + 'CTI_CSP#' || v_source.oid::text AS code, + v_source.code as condition_code, + 'CTI_CSP#' || + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN 'DT#' + ELSE '###' END AS category_id, + COALESCE(t_classes.texte || '. ' || t_classes_sections.texte,'CSP. ' || v_source.texte::text) AS texte, + v_source.texte AS texte_court, + 'categorie_socio_professionnelle_id'::text AS column_name, + ''::text AS rule, + v_source.oid::text AS value, + 'CSP='||v_source.oid AS view_select_rule, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN '1-Classe' || substr(v_source.oid,3,2) + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '2-Liste CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN '3-Liste CTI' + ELSE '9' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN 'LS#'||t_listes_tables_classes.code||':'||CASE WHEN t_classes.code <> '' THEN t_classes.code ELSE '*CLS'||to_char(t_classes.sequence,'FM00') END||':'||t_classes_sections.code + WHEN v_source.oid LIKE 'LI%' THEN 'LI#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'SL%' THEN 'SL#'||t_listes_tables_listes.code||':'||CASE WHEN t_listes.code <> '' THEN t_listes.code ELSE '*TXT:'||upper(t_listes.texte) END + WHEN v_source.oid LIKE 'DT%' THEN COALESCE('DT#'||t_source.code,v_source.oid) + ELSE '###'||v_source.oid END + + ] AS arbre_code, + ARRAY[ + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes.texte + WHEN v_source.is_cti = '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes CTI' + WHEN v_source.is_cti <> '1' AND (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') THEN 'Listes Etablissement' + ELSE 'Valeurs' END, + CASE + WHEN v_source.oid LIKE 'LS%' THEN t_classes_sections.texte + ELSE v_source.texte END + ] AS arbre_texte + FROM rh.v_categories_socio_professionnelle_1 v_source + LEFT JOIN rh.t_classes_sections ON v_source.oid LIKE 'LS%' AND + t_classes_sections.oid::text = substr(v_source.oid,5) + LEFT JOIN rh.t_classes ON t_classes.oid = t_classes_sections.classe_id + LEFT JOIN rh.t_listes_tables t_listes_tables_classes ON t_classes.table_id = t_listes_tables_classes.oid + LEFT JOIN rh.t_listes ON (v_source.oid LIKE 'LI%' OR v_source.oid LIKE 'SL%') AND + t_listes.oid::text = substr(v_source.oid,3) + LEFT JOIN rh.t_listes_tables t_listes_tables_listes ON t_listes.table_id = t_listes_tables_listes.oid + LEFT JOIN rh.t_categories_socio_professionnelle t_source ON v_source.oid LIKE 'DT%' AND t_source.oid = substr(v_source.oid,3) + WHERE v_source.oid NOT LIKE 'LC%' AND + (v_source.oid NOT LIKE 'LS%' OR substr(v_source.oid,5) <> '0') AND + v_source.oid <> '-1' + ; + + INSERT INTO rh.t_indicateur_condition(code, texte,texte_court,column_name,rule,value,view_select_rule, arbre_code, arbre_texte, condition_code, category_id) + SELECT code, texte,texte_court,column_name,rule,value,view_select_rule, arbre_code, arbre_texte, condition_code, category_id + FROM w_indicateur_condition + WHERE code NOT IN (SELECT code FROM rh.t_indicateur_condition WHERE code IS NOT NULL) + ; + + UPDATE rh.t_indicateur_condition SET + texte = w_indicateur_condition.texte, + texte_court = w_indicateur_condition.texte_court, + column_name = w_indicateur_condition.column_name, + rule = w_indicateur_condition.rule, + value = w_indicateur_condition.value, + view_select_rule = w_indicateur_condition.view_select_rule, + arbre_code = w_indicateur_condition.arbre_code, + arbre_texte = w_indicateur_condition.arbre_texte, + condition_code = w_indicateur_condition.condition_code, + category_id = w_indicateur_condition.category_id + FROM w_indicateur_condition + WHERE w_indicateur_condition.code = t_indicateur_condition.code AND + ( + t_indicateur_condition.texte IS DISTINCT FROM w_indicateur_condition.texte OR + t_indicateur_condition.texte_court IS DISTINCT FROM w_indicateur_condition.texte_court OR + t_indicateur_condition.column_name IS DISTINCT FROM w_indicateur_condition.column_name OR + t_indicateur_condition.rule IS DISTINCT FROM w_indicateur_condition.rule OR + t_indicateur_condition.value IS DISTINCT FROM w_indicateur_condition.value OR + t_indicateur_condition.view_select_rule IS DISTINCT FROM w_indicateur_condition.view_select_rule OR + t_indicateur_condition.arbre_code IS DISTINCT FROM w_indicateur_condition.arbre_code OR + t_indicateur_condition.arbre_texte IS DISTINCT FROM w_indicateur_condition.arbre_texte OR + t_indicateur_condition.condition_code IS DISTINCT FROM w_indicateur_condition.condition_code OR + t_indicateur_condition.category_id IS DISTINCT FROM w_indicateur_condition.category_id + ) + ; + + WITH toto as ( + SELECT + oid, + split_part(code, '#', 1) + ||'#' + ||arbre_code[2] + as new_external_code + FROM rh.t_indicateur_condition + ) + UPDATE rh.t_indicateur_condition SET + external_code = new_external_code + FROM toto + WHERE 1=1 + and t_indicateur_condition.oid = toto.oid + and external_code IS DISTINCT FROM new_external_code + ; + + WITH external_code2 as ( + SELECT + oid, + split_part(code, '#', 1) + ||'#' + ||arbre_code[2] + as new_external_code2 + FROM rh.t_indicateur_condition + ) + UPDATE rh.t_indicateur_condition SET + external_code2 = new_external_code2 + FROM external_code2 + WHERE 1=1 + and t_indicateur_condition.oid = external_code2.oid + and external_code2 IS DISTINCT FROM new_external_code2 + ; + + DELETE FROM rh.t_indicateur_condition + WHERE code LIKE 'CTI%' AND + code NOT IN (SELECT code FROM w_indicateur_condition) + ; + + UPDATE rh.t_indicateur_condition SET + column_texte = CASE column_name + WHEN 'rhp_entreprise_id' THEN 'Entreprise' + WHEN 'rhp_etablissement_id' THEN 'Etablissement' + ELSE replace(Upper(substr(split_part(column_name,'_id',1),1,1)) || substr(split_part(column_name,'_id',1),2),'_',' ') END + WHERE + column_texte IS DISTINCT FROM + CASE column_name + WHEN 'rhp_entreprise_id' THEN 'Entreprise' + WHEN 'rhp_etablissement_id' THEN 'Etablissement' + ELSE replace(Upper(substr(split_part(column_name,'_id',1),1,1)) || substr(split_part(column_name,'_id',1),2),'_',' ') END + ; + + DROP TABLE IF EXISTS w_indicateur_condition_table; + CREATE TEMP TABLE w_indicateur_condition_table AS + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + ''::text As table_name, + t_indicateur_condition.column_name || ' ' || + CASE + WHEN t_indicateur_condition.value LIKE 'LS%' THEN '= ANY(ARRAY' + WHEN t_indicateur_condition.value LIKE 'LI%' THEN '= ANY(ARRAY' + WHEN t_indicateur_condition.value LIKE 'SL%' THEN '<> ALL(ARRAY' + WHEN t_indicateur_condition.value LIKE 'DT%' THEN '=' + ELSE '=' + END || ' ' || + CASE + WHEN t_indicateur_condition.value LIKE 'LS%' THEN + '(SELECT to_id FROM rh.t_classes_sections_elements WHERE section_id = ' || substr(value,5) || ')' + WHEN t_indicateur_condition.value LIKE 'LI%' THEN + '(SELECT to_id FROM rh.t_listes_contenu WHERE liste_id = ' || substr(value,3) || ')' + WHEN t_indicateur_condition.value LIKE 'SL%' THEN + '(SELECT to_id FROM rh.t_listes_contenu WHERE liste_id = ' || substr(value,3) || ')' + WHEN t_indicateur_condition.value LIKE 'DT%' THEN + substr(value,3) + ELSE substr(value,3) + END || ' ' || + CASE + WHEN t_indicateur_condition.value LIKE 'LS%' THEN ')' + WHEN t_indicateur_condition.value LIKE 'LI%' THEN ')' + WHEN t_indicateur_condition.value LIKE 'SL%' THEN ')' + ELSE '' + END AS check_where + FROM rh.t_indicateur_condition + WHERE t_indicateur_condition.code LIKE 'CTI%' + ; + + INSERT INTO w_indicateur_condition_table + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + 'v_arrets_travail_mois_1'::text As table_name, + ''::text AS check_where + FROM rh.t_indicateur_condition + WHERE t_indicateur_condition.code LIKE 'CTI%' AND + column_name IN ('rubrique_id') + ; + INSERT INTO w_indicateur_condition_table + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + 'v_contrats_mois_1'::text As table_name, + ''::text AS check_where + FROM rh.t_indicateur_condition + WHERE t_indicateur_condition.code LIKE 'CTI%' AND + column_name IN ('rubrique_id') + ; + INSERT INTO w_indicateur_condition_table + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + 'v_contrats_mois_1'::text As table_name, + ''::text AS check_where + FROM rh.t_indicateur_condition + WHERE t_indicateur_condition.code LIKE 'CTI%' AND + column_name IN ('rhp_planning_qualification_id', 'rhp_planning_service_id') + ; + INSERT INTO w_indicateur_condition_table + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + 'v_arrets_travail_mois_1'::text As table_name, + ''::text AS check_where + FROM rh.t_indicateur_condition + WHERE t_indicateur_condition.code LIKE 'CTI%' AND + column_name IN ('rhp_planning_qualification_id', 'rhp_planning_service_id') + ; + INSERT INTO w_indicateur_condition_table + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + 'v_historique_paie_1'::text As table_name, + ''::text AS check_where + FROM rh.t_indicateur_condition + WHERE t_indicateur_condition.code LIKE 'CTI%' AND + column_name IN ('rhp_planning_qualification_id', 'rhp_planning_service_id') + ; + INSERT INTO w_indicateur_condition_table + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + 'CALENDRIER'::text As table_name, + ''::text AS check_where + FROM rh.t_indicateur_condition + ; + INSERT INTO w_indicateur_condition_table + SELECT t_indicateur_condition.oid AS indicateur_condition_id, + 'BUDGET_RH'::text As table_name, + '1<>1' AS check_where + FROM rh.t_indicateur_condition + WHERE t_indicateur_condition.code LIKE 'CTI%' AND + column_name NOT IN ('rhp_budget_cle_id') + ; + + ANALYSE w_indicateur_condition_table + ; + + + INSERT INTO rh.t_indicateur_condition_table(indicateur_condition_id, table_name, check_where) + SELECT w_indicateur_condition_table.indicateur_condition_id, w_indicateur_condition_table.table_name, w_indicateur_condition_table.check_where + FROM w_indicateur_condition_table + LEFT JOIN rh.t_indicateur_condition_table ON + w_indicateur_condition_table.indicateur_condition_id = t_indicateur_condition_table.indicateur_condition_id AND + w_indicateur_condition_table.table_name = t_indicateur_condition_table.table_name + WHERE t_indicateur_condition_table.indicateur_condition_id IS NULL + ; + + + UPDATE rh.t_indicateur_condition_table SET + check_where = w_indicateur_condition_table.check_where + FROM w_indicateur_condition_table + WHERE t_indicateur_condition_table.indicateur_condition_id = w_indicateur_condition_table.indicateur_condition_id AND + t_indicateur_condition_table.table_name = w_indicateur_condition_table.table_name AND + ( + t_indicateur_condition_table.check_where IS DISTINCT FROM w_indicateur_condition_table.check_where + ) + ; + + DELETE FROM rh.t_indicateur_condition_table + USING + ( + SELECT t_indicateur_condition_table.indicateur_condition_id, t_indicateur_condition_table.table_name, t_indicateur_condition_table.check_where + FROM rh.t_indicateur_condition_table + LEFT JOIN w_indicateur_condition_table ON + w_indicateur_condition_table.indicateur_condition_id = t_indicateur_condition_table.indicateur_condition_id AND + w_indicateur_condition_table.table_name = t_indicateur_condition_table.table_name + WHERE w_indicateur_condition_table.indicateur_condition_id IS NULL + ) subview + WHERE t_indicateur_condition_table.indicateur_condition_id = subview.indicateur_condition_id AND + t_indicateur_condition_table.table_name = subview.table_name + ; + + + + RETURN 'OK'; + + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_reorganize_personne.yaml b/db/schema2/functions/cti_reorganize_personne.yaml new file mode 100644 index 0000000..0849749 --- /dev/null +++ b/db/schema2/functions/cti_reorganize_personne.yaml @@ -0,0 +1,120 @@ +return: text +lang: plpgsql +src: | + DECLARE + _sqlcmd TEXT; + result TEXT; + BEGIN + -- Le nom_naissance dans certains prestataires est récupéré sous le format NULL pour indiquer la non saisie de ce champ + -- Historiquement dans les prestataires, le nom_naissance non renseigné était enregistré au format chaîne vide ('') + -- Les requêtes suivantes et la table p_personne attendent que la colonne nom_naissance soit au format chaîne lorsque vide + UPDATE rh.p_salaries + SET nom_naissance = '' + WHERE nom_naissance IS NULL + ; + + -- Extraction par nom + DROP TABLE IF EXISTS w_fusion_salaries; + CREATE TEMP TABLE w_fusion_salaries AS + SELECT *, + '0'::text AS origine, + base.cti_soundex_nom(nom) AS nom_soundex, + base.cti_soundex_prenom(prenom) AS prenom_soundex + FROM rh.p_salaries + WHERE nom <> '' AND + (nom_naissance = nom OR nom_naissance = '') AND + oid IN (SELECT salarie_id FROM rh.p_contrats); + -- Extraction par nom de naissance + INSERT INTO w_fusion_salaries + SELECT *, + '1'::text AS origine, + base.cti_soundex_nom(nom_naissance) AS nom_soundex, + base.cti_soundex_prenom(prenom) AS prenom_soundex + FROM rh.p_salaries + WHERE nom <> '' AND + nom_naissance <> '' AND + nom_naissance <> nom AND + oid IN (SELECT salarie_id FROM rh.p_contrats); + + -- Table temporaire des personnes avec + -- regroupement par nom/nom_naissance, prénom, date_naissance, sexe + -- identifiant md5 (clé de la personne) utilisant nom de naissance + DROP TABLE IF EXISTS w_personne; + CREATE TEMP TABLE w_personne AS + SELECT COALESCE(salarie_courant_id, w_fusion_salaries.oid) AS salarie_courant_id, + md5( + MAX( + CASE WHEN w_fusion_salaries.oid = salarie_courant_id OR subview.salarie_courant_id IS NULL + THEN base.cti_soundex_nom(CASE WHEN nom_naissance <> '' THEN nom_naissance ELSE nom END) + || base.cti_soundex_prenom(prenom) + || w_fusion_salaries.date_naissance + || w_fusion_salaries.sexe + ELSE NULL END) + ) AS cle_interne, + MAX(CASE WHEN w_fusion_salaries.oid = salarie_courant_id OR subview.salarie_courant_id IS NULL THEN w_fusion_salaries.nom ELSE NULL END) AS nom, + MAX(CASE WHEN w_fusion_salaries.oid = salarie_courant_id OR subview.salarie_courant_id IS NULL THEN w_fusion_salaries.nom_naissance ELSE NULL END) AS nom_naissance, + MAX(CASE WHEN w_fusion_salaries.oid = salarie_courant_id OR subview.salarie_courant_id IS NULL THEN w_fusion_salaries.prenom ELSE NULL END) AS prenom, + MAX(w_fusion_salaries.date_naissance) AS date_naissance, + MAX(w_fusion_salaries.sexe) AS sexe, + MAX(CASE WHEN w_fusion_salaries.oid = salarie_courant_id OR subview.salarie_courant_id IS NULL THEN w_fusion_salaries.matricule ELSE NULL END) AS matricule_courant, + MAX( + CASE + WHEN w_fusion_salaries.oid = subview.salarie_courant_id THEN salarie_array_id + WHEN subview.salarie_courant_id IS NULL THEN Array[w_fusion_salaries.oid] + ELSE NULL END + ) AS salarie_array_id + FROM w_fusion_salaries + LEFT JOIN + ( + SELECT + nom_soundex, + prenom_soundex, + date_naissance, + sexe, + count(*) AS nb, + (MAX(ARRAY[date_debut::text,oid::text]))[2]::bigint AS salarie_courant_id, + base.cti_array_accum(w_fusion_salaries.oid) AS salarie_array_id + FROM w_fusion_salaries + GROUP BY 1,2,3,4 + HAVING count(*) > 1 + ) subview ON + w_fusion_salaries.oid = ANY(salarie_array_id) + GROUP BY 1 + ; + + -- Mise à jour table p_personnes + UPDATE rh.p_personne SET + nom = w_personne.nom, + nom_naissance = w_personne.nom_naissance, + prenom = w_personne.prenom, + salarie_courant_id = w_personne.salarie_courant_id, + salarie_array_id = w_personne.salarie_array_id, + matricule_courant = w_personne.matricule_courant + FROM w_personne + WHERE p_personne.cle_interne = w_personne.cle_interne AND + ( + p_personne.nom IS DISTINCT FROM w_personne.nom OR + p_personne.nom_naissance IS DISTINCT FROM w_personne.nom_naissance OR + p_personne.prenom IS DISTINCT FROM w_personne.prenom OR + p_personne.salarie_courant_id IS DISTINCT FROM w_personne.salarie_courant_id OR + p_personne.salarie_array_id IS DISTINCT FROM w_personne.salarie_array_id OR + p_personne.matricule_courant IS DISTINCT FROM w_personne.matricule_courant + ) + ; + + INSERT INTO rh.p_personne (cle_interne, nom, nom_naissance, prenom, date_naissance, sexe, salarie_courant_id, salarie_array_id, matricule_courant) + SELECT cle_interne, nom, nom_naissance, prenom, date_naissance, sexe, salarie_courant_id, salarie_array_id, matricule_courant + FROm w_personne + WHERE cle_interne NOT IN + (SELECT cle_interne FROM rh.p_personne) + ; + + -- Mise à jour table p_salaries + UPDATE rh.p_salaries SET + personne_id = p_personne.oid + FROM rh.p_personne + WHERE p_salaries.oid = ANY(p_personne.salarie_array_id) + ; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_reorganize_pole.yaml b/db/schema2/functions/cti_reorganize_pole.yaml new file mode 100644 index 0000000..928d11d --- /dev/null +++ b/db/schema2/functions/cti_reorganize_pole.yaml @@ -0,0 +1,332 @@ +return: text +lang: plpgsql +src: | + DECLARE + result TEXT; + _module_pmsimco TEXT; + BEGIN + + RAISE NOTICE '%' , 'Initialisation poles'; + -- Contenu table + INSERT INTO base.t_pole (oid, code, texte, texte_court) + SELECT 0, '**', 'Non renseigné', 'Non renseigné' + WHERE 0 NOT IN (SELECT oid FROM base.t_pole); + + -- replication dans rh + TRUNCATE rh.t_pole; + INSERT INTO rh.t_pole (oid, code, texte, texte_court, section_id, section_code, section_texte) + SELECT oid, code, texte, texte_court, section_id, section_code, section_texte + FROM base.t_pole + ; + + -- Traduction des règles en oid + RAISE NOTICE '%' , 'Application des regles. Traduction en oid'; + DROP TABLE IF EXISTS w_pole_rule; + CREATE TEMP TABLE w_pole_rule AS + SELECT + t_pole_rule.oid, + pole_id, + + priorite, + CASE WHEN liste_finess <> '' THEN '1' ELSE '0' END AS a_liste_finess, + string_to_array(translate(liste_finess,'*,','% '),' ') AS liste_finess, + NULL::bigint[] AS liste_finess_id , + + CASE WHEN liste_etablissement <> '' THEN '1' ELSE '0' END AS a_liste_etablissement, + string_to_array(translate(liste_etablissement,'*,','% '),' ') AS liste_etablissement, + NULL::bigint[] AS liste_etablissement_id , + + CASE WHEN liste_service <> '' THEN '1' ELSE '0' END AS a_liste_service, + string_to_array(translate(liste_service,'*,','% '),' ') AS liste_service, + NULL::bigint[] AS liste_service_id , + + CASE WHEN liste_specialite <> '' THEN '1' ELSE '0' END AS a_liste_specialite, + string_to_array(translate(liste_specialite,'*,','% '),' ') AS liste_specialite, + NULL::bigint[] AS liste_specialite_id , + + CASE WHEN liste_section_analytique <> '' THEN '1' ELSE '0' END AS a_liste_section_analytique, + string_to_array(translate(liste_section_analytique,'*,','% '),' ') AS liste_section_analytique, + NULL::bigint[] AS liste_section_analytique_id , + + CASE WHEN liste_section_analytique_paie <> '' THEN '1' ELSE '0' END AS a_liste_section_analytique_paie, + string_to_array(translate(liste_section_analytique_paie,'*,','% '),' ') AS liste_section_analytique_paie, + NULL::bigint[] AS liste_section_analytique_paie_id , + + CASE WHEN liste_qualification <> '' THEN '1' ELSE '0' END AS a_liste_qualification, + string_to_array(translate(liste_qualification,'*,','% '),' ') AS liste_qualification, + NULL::bigint[] AS liste_qualification_id , + + CASE WHEN liste_grille <> '' THEN '1' ELSE '0' END AS a_liste_grille, + string_to_array(translate(liste_grille,'*,','% '),' ') AS liste_grille, + NULL::bigint[] AS liste_grille_id , + + CASE WHEN liste_code_emploi <> '' THEN '1' ELSE '0' END AS a_liste_code_emploi, + string_to_array(translate(liste_code_emploi,'*,','% '),' ') AS liste_code_emploi, + NULL::bigint[] AS liste_code_emploi_id , + + CASE WHEN liste_categorie_socio_professionnelle <> '' THEN '1' ELSE '0' END AS a_liste_categorie_socio_professionnelle, + string_to_array(translate(liste_categorie_socio_professionnelle,'*,','% '),' ') AS liste_categorie_socio_professionnelle, + NULL::bigint[] AS liste_categorie_socio_professionnelle_id , + + CASE WHEN liste_service_planning <> '' THEN '1' ELSE '0' END AS a_liste_service_planning, + string_to_array(translate(liste_service_planning,'*,','% '),' ') AS liste_service_planning, + NULL::bigint[] AS liste_service_planning_id + FROM rh.t_pole_rule + JOIN rh.t_pole ON pole_id = t_pole.oid + ORDER BY priorite, pole_id; + + DELETE FROM w_pole_rule + WHERE + (a_liste_finess::int + + a_liste_etablissement::int + + a_liste_service::int + + a_liste_specialite::int + + a_liste_section_analytique::int + + a_liste_section_analytique_paie::int + + a_liste_qualification::int + + a_liste_grille::int + + a_liste_code_emploi::int + + a_liste_categorie_socio_professionnelle::int + + a_liste_service_planning::int) = 0 + ; + + UPDATE w_pole_rule + SET liste_finess_id = (SELECT base.cti_group_array3(oid) FROM base.t_finess WHERE oid <> 0 AND code LIKE ANY (liste_finess)) + WHERE a_liste_finess = '1'; + + UPDATE w_pole_rule + SET liste_etablissement_id = (SELECT base.cti_group_array3(oid) FROM rh.t_etablissements WHERE oid <> 0 AND code LIKE ANY (liste_etablissement)) + WHERE a_liste_etablissement = '1'; + + UPDATE w_pole_rule + SET liste_service_id = (SELECT base.cti_group_array3(oid) FROM rh.t_services WHERE oid <> 0 AND code LIKE ANY (liste_service)) + WHERE a_liste_service = '1'; + + UPDATE w_pole_rule + SET liste_specialite_id = (SELECT base.cti_group_array3(oid) FROM rh.t_specialites WHERE oid <> 0 AND code LIKE ANY (liste_specialite)) + WHERE a_liste_specialite = '1'; + + UPDATE w_pole_rule + SET liste_section_analytique_id = (SELECT base.cti_group_array3(oid) FROM rh.t_sections_analytiques WHERE oid <> 0 AND code LIKE ANY (liste_section_analytique)) + WHERE a_liste_section_analytique = '1'; + + UPDATE w_pole_rule + SET liste_section_analytique_paie_id = (SELECT base.cti_group_array3(oid) FROM rh.t_sections_analytiques_paie WHERE oid <> 0 AND code LIKE ANY (liste_section_analytique_paie)) + WHERE a_liste_section_analytique_paie = '1'; + + UPDATE w_pole_rule + SET liste_qualification_id = (SELECT base.cti_group_array3(oid) FROM rh.t_qualifications WHERE oid <> 0 AND code LIKE ANY (liste_qualification)) + WHERE a_liste_qualification = '1'; + + UPDATE w_pole_rule + SET liste_grille_id = (SELECT base.cti_group_array3(oid) FROM rh.t_grilles WHERE oid <> 0 AND code LIKE ANY (liste_grille)) + WHERE a_liste_grille = '1'; + + UPDATE w_pole_rule + SET liste_code_emploi_id = (SELECT base.cti_group_array3(oid) FROM rh.t_codes_emploi WHERE oid <> 0 AND code LIKE ANY (liste_code_emploi)) + WHERE a_liste_code_emploi = '1'; + + UPDATE w_pole_rule + SET liste_categorie_socio_professionnelle_id = (SELECT base.cti_group_array3(oid) FROM rh.t_categories_socio_professionnelle WHERE oid <> 0 AND code LIKE ANY (liste_categorie_socio_professionnelle)) + WHERE a_liste_categorie_socio_professionnelle = '1'; + + UPDATE w_pole_rule + SET liste_service_planning_id = (SELECT base.cti_group_array3(oid) FROM rh.t_planning_service WHERE oid <> 0 AND code LIKE ANY (liste_service_planning)) + WHERE a_liste_service_planning = '1'; + + RAISE NOTICE '%' , 'Application des regles.' + ; + DROP TABLE IF EXISTS w_profil_contrat_mois + ; + CREATE TEMP TABLE w_profil_contrat_mois AS + SELECT + p_profil_contrat_mois.oid, + COALESCE(MIN(priorite),999999999) AS pole_priorite, + COALESCE((MIN(ARRAY[priorite,w_pole_rule.pole_id]))[2],0) AS pole_id + FROM rh.p_profil_contrat_mois + JOIN rh.p_contrats_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.t_etablissements ON t_etablissements.oid = p_contrats_mois.etablissement_id + JOIN rh.p_profils ON p_profil_contrat_mois.profil_id = p_profils.oid + JOIN w_pole_rule ON + (a_liste_finess = '0' OR finess_id = ANY (liste_finess_id)) AND + (a_liste_etablissement = '0' OR p_contrats_mois.etablissement_id = ANY (liste_etablissement_id)) AND + (a_liste_service = '0' OR p_profils.service_id = ANY (liste_service_id)) AND + (a_liste_specialite = '0' OR p_profils.specialite_id = ANY (liste_specialite_id)) AND + (a_liste_qualification = '0' OR p_profils.qualification_id = ANY (liste_qualification_id)) AND + (a_liste_section_analytique = '0' OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) AND + (a_liste_section_analytique_paie = '0' OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) AND + (a_liste_grille = '0' OR p_profils.grille_id = ANY (liste_grille_id)) AND + (a_liste_code_emploi = '0' OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) AND + (a_liste_categorie_socio_professionnelle = '0' OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + -- Pas de service planning. + WHERE + (a_liste_finess::int + + a_liste_etablissement::int + + a_liste_service::int + + a_liste_specialite::int + + a_liste_section_analytique::int + + a_liste_section_analytique_paie::int + + a_liste_qualification::int + + a_liste_grille::int + + a_liste_code_emploi::int + + a_liste_categorie_socio_professionnelle::int) > 0 OR + a_liste_service_planning::int = 0 + GROUP BY 1 + ORDER BY 2,1 + ; + + DROP TABLE IF EXISTS w_contrats_mois + ; + CREATE TEMP TABLE w_contrats_mois AS + SELECT + p_contrats_mois.oid, + COALESCE(MIN(priorite),999999999) AS pole_priorite, + COALESCE((MIN(ARRAY[priorite,w_pole_rule.pole_id]))[2],0) AS pole_id + FROM rh.p_contrats_mois + JOIN rh.t_etablissements ON t_etablissements.oid = p_contrats_mois.etablissement_id + JOIN rh.p_profils ON p_contrats_mois.profil_id = p_profils.oid + JOIN w_pole_rule ON + (a_liste_finess = '0' OR finess_id = ANY (liste_finess_id)) AND + (a_liste_etablissement = '0' OR p_contrats_mois.etablissement_id = ANY (liste_etablissement_id)) AND + (a_liste_service = '0' OR p_profils.service_id = ANY (liste_service_id)) AND + (a_liste_specialite = '0' OR p_profils.specialite_id = ANY (liste_specialite_id)) AND + (a_liste_qualification = '0' OR p_profils.qualification_id = ANY (liste_qualification_id)) AND + (a_liste_section_analytique = '0' OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) AND + (a_liste_section_analytique_paie = '0' OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) AND + (a_liste_grille = '0' OR p_profils.grille_id = ANY (liste_grille_id)) AND + (a_liste_code_emploi = '0' OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) AND + (a_liste_categorie_socio_professionnelle = '0' OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + -- Pas de service planning. + GROUP BY 1 + ORDER BY 1 + ; + + DROP TABLE IF EXISTS w_contrats + ; + CREATE TEMP TABLE w_contrats AS + SELECT p_contrats.oid, + COALESCE(MIN(priorite),999999999) AS pole_priorite, + COALESCE((MIN(ARRAY[priorite,w_pole_rule.pole_id]))[2],0) AS pole_id + FROM rh.p_contrats + LEFT JOIN rh.t_etablissements ON t_etablissements.oid = etablissement_id + LEFT JOIN rh.p_profils ON p_contrats.profil_id = p_profils.oid + JOIN w_pole_rule ON + (a_liste_finess = '0' OR finess_id = ANY (liste_finess_id)) AND + (a_liste_etablissement = '0' OR p_contrats.etablissement_id = ANY (liste_etablissement_id)) AND + (a_liste_service = '0' OR p_profils.service_id = ANY (liste_service_id)) AND + (a_liste_specialite = '0' OR p_profils.specialite_id = ANY (liste_specialite_id)) AND + (a_liste_qualification = '0' OR p_profils.qualification_id = ANY (liste_qualification_id)) AND + (a_liste_section_analytique = '0' OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) AND + (a_liste_section_analytique_paie = '0' OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) AND + (a_liste_grille = '0' OR p_profils.grille_id = ANY (liste_grille_id)) AND + (a_liste_code_emploi = '0' OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) AND + (a_liste_categorie_socio_professionnelle = '0' OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + -- Pas de service planning. + GROUP BY 1 + ORDER BY 1 + ; + + DROP TABLE IF EXISTS w_planning_mouvement + ; + CREATE TEMP TABLE w_planning_mouvement AS + SELECT + p_planning_mouvement.ctid as pm_ctid, + COALESCE(MIN(priorite),999999999) AS pole_priorite, + COALESCE((MIN(ARRAY[priorite,w_pole_rule.pole_id]))[2],0) AS pole_id + FROM rh.p_planning_mouvement + JOIN rh.p_contrats ON p_planning_mouvement.contrat_id = p_contrats.oid + JOIN rh.p_contrats_mois ON p_planning_mouvement.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profils ON p_profil_contrat_mois.profil_id = p_profils.oid + JOIN rh.t_etablissements ON t_etablissements.oid = p_planning_mouvement.etablissement_id + JOIN w_pole_rule ON 1=1 + AND (a_liste_finess = '0' OR finess_id = ANY (liste_finess_id)) + AND (a_liste_etablissement = '0' OR p_planning_mouvement.etablissement_id = ANY (liste_etablissement_id)) + AND (a_liste_service = '0' OR p_profils.service_id = ANY (liste_service_id)) + AND (a_liste_specialite = '0' OR p_profils.specialite_id = ANY (liste_specialite_id)) + AND (a_liste_qualification = '0' OR p_profils.qualification_id = ANY (liste_qualification_id)) + AND (a_liste_section_analytique = '0' OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) + AND (a_liste_section_analytique_paie = '0' OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) + AND (a_liste_grille = '0' OR p_profils.grille_id = ANY (liste_grille_id)) + AND (a_liste_code_emploi = '0' OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) + AND (a_liste_categorie_socio_professionnelle = '0' OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + AND (a_liste_service_planning = '0' OR p_planning_mouvement.service_id = ANY (liste_service_planning_id)) + GROUP BY 1 + ORDER BY 1 + ; + + RAISE NOTICE '%' , 'Application des regles. Validation des poles'; + + UPDATE rh.p_profil_contrat_mois SET + pole_id = w_profil_contrat_mois.pole_id + FROM w_profil_contrat_mois + WHERE p_profil_contrat_mois.oid = w_profil_contrat_mois.oid AND + p_profil_contrat_mois.pole_id IS DISTINCT FROM w_profil_contrat_mois.pole_id + ; + + UPDATE rh.p_profil_contrat_mois SET + pole_id = 0 + WHERE 1=1 + AND oid NOT IN (SELECT oid FROM w_profil_contrat_mois group by 1) + AND pole_id IS DISTINCT FROM 0 + ; + + UPDATE rh.p_contrats_mois SET + pole_id = w_contrats_mois.pole_id + FROM w_contrats_mois + WHERE p_contrats_mois.oid = w_contrats_mois.oid AND + p_contrats_mois.pole_id IS DISTINCT FROM w_contrats_mois.pole_id + ; + + UPDATE rh.p_contrats_mois SET + pole_id = 0 + WHERE 1=1 + AND oid NOT IN (SELECT oid FROM w_contrats_mois group by 1) + AND pole_id IS DISTINCT FROM 0 + ; + + UPDATE rh.p_contrats SET + pole_id = w_contrats.pole_id + FROM w_contrats + WHERE p_contrats.oid = w_contrats.oid AND + p_contrats.pole_id IS DISTINCT FROM w_contrats.pole_id + ; + + UPDATE rh.p_contrats SET + pole_id = 0 + WHERE 1=1 + AND oid NOT IN (SELECT oid FROM w_contrats group by 1) + AND pole_id IS DISTINCT FROM 0 + ; + + with asso as ( + select + p_planning_mouvement.ctid as pm_ctid, + coalesce(w_planning_mouvement.pole_id, 0) as pole_id + from rh.p_planning_mouvement + left join w_planning_mouvement on w_planning_mouvement.pm_ctid = p_planning_mouvement.ctid + ) + UPDATE rh.p_planning_mouvement SET + pole_id = asso.pole_id + FROM asso + WHERE 1=1 + AND p_planning_mouvement.ctid = asso.pm_ctid + AND p_planning_mouvement.pole_id IS DISTINCT FROM asso.pole_id + ; + + ANALYSE rh.p_profil_contrat_mois + ; + ANALYSE rh.p_contrats_mois + ; + ANALYSE rh.p_contrats + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'pole', pole_id + FROM rh.p_profil_contrat_mois + WHERE pole_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'pole') + GROUP BY 2 + ; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_reorganize_population.yaml b/db/schema2/functions/cti_reorganize_population.yaml new file mode 100644 index 0000000..a384e6f --- /dev/null +++ b/db/schema2/functions/cti_reorganize_population.yaml @@ -0,0 +1,338 @@ +return: text +lang: plpgsql +src: | + DECLARE + result TEXT; + domains RECORD; + tmpSchema TEXT; + tmpTable TEXT; + tmpListe TEXT; + tmpReq TEXT; + BEGIN + RAISE NOTICE '%' , 'Initialisation Populations' + ; + -- Contenu table + INSERT INTO rh.t_population(oid, code, texte, texte_court) + SELECT 0, chr(127) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_population) + ; + + DROP TABLE IF EXISTS w_domains + ; + CREATE TEMP TABLE w_domains AS + SELECT + domain + FROM unnest(ARRAY[ + 'base|t_finess|finess', + 'rh|t_etablissements|etablissement', + 'rh|t_services|service', + 'rh|t_specialites|specialite', + 'rh|t_sections_analytiques|section_analytique', + 'rh|t_sections_analytiques_paie|section_analytique_paie', + 'rh|t_qualifications|qualification', + 'rh|t_grilles|grille', + 'rh|t_codes_emploi|code_emploi', + 'rh|t_categories_socio_professionnelle|categorie_socio_professionnelle', + 'rh|t_statuts|statut' + ]) as domain + ; + + tmpReq = ''; + FOR domains IN SELECT * FROM w_domains LOOP + tmpSchema = split_part(domains.domain, '|', 1); + tmpTable = split_part(domains.domain, '|', 2); + tmpListe = split_part(domains.domain, '|', 3); + + tmpReq = concat_ws(', ', tmpReq, + format(' + (select coalesce(min(position (''^'' in token)) = 0, false) + from unnest(string_to_array(replace(liste_%s, '','', ''''), '' '')) as token + where length(trim(token)) > 0 + ) as has_liste_%s, + (select + array_agg(coalesce(table_liste.oid, listes.oid, classes.oid)) + from unnest(string_to_array(replace(liste_%s, '','', ''''), '' '')) as token + left join %s.t_listes_tables on t_listes_tables.name = ''%s'' + left join %s.%s as table_liste on table_liste.code like replace(trim(token), ''*'', ''%%'') + left join listes on listes.code like ''{''||t_listes_tables.code||''}''||replace(trim(token), ''*'', ''%%'') + left join classes on classes.code like ''{''||t_listes_tables.code||''}''||replace(trim(token), ''*'', ''%%'') + where 1=1 + and token != '''' + and coalesce(table_liste.oid, listes.oid, classes.oid) is distinct from null + ) as liste_%s_id', tmpListe, tmpListe, tmpListe, tmpSchema, tmpTable, tmpSchema, tmpTable, tmpListe), + format(' + (select coalesce(max(position (''^'' in token)) > 0, false) + from unnest(string_to_array(replace(liste_%s, '','', ''''), '' '')) as token + where length(trim(token)) > 0 + ) as has_exc_liste_%s, + (select + array_agg(coalesce(table_liste.oid, listes_exc.oid, classes_exc.oid)) + from unnest(string_to_array(replace(liste_%s, '','', ''''), '' '')) as token + left join %s.t_listes_tables on t_listes_tables.name = ''%s'' + left join %s.%s as table_liste on ''^''||table_liste.code like replace(trim(token), ''*'', ''%%'') + left join listes_exc on listes_exc.code like ''{''||t_listes_tables.code||''}''||replace(trim(token), ''*'', ''%%'') + left join classes_exc on classes_exc.code like ''{''||t_listes_tables.code||''}''||replace(trim(token), ''*'', ''%%'') + where 1=1 + and token != '''' + and coalesce(table_liste.oid, listes_exc.oid, classes_exc.oid) is distinct from null + ) as liste_exc_%s_id', tmpListe, tmpListe, tmpListe, tmpSchema, tmpTable, tmpSchema, tmpTable, tmpListe)); + + END LOOP; + + -- Traduction des règles en oid + RAISE NOTICE '%' , 'Application des regles. Traduction en oid' + ; + DROP TABLE IF EXISTS w_population_regle + ; + EXECUTE format(' + CREATE TEMP TABLE w_population_regle AS + with listes as ( + select + ''{''||t_listes_tables.code||''}[LISTE:''||t_listes.code||'']'' as code, + t_listes_contenu.to_id as oid + from rh.t_listes + join rh.t_listes_tables on t_listes_tables.oid = t_listes.table_id + join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + UNION ALL + select + ''{''||t_listes_tables.code||''}[LISTE:''||t_listes.code||'']'' as code, + t_listes_contenu.to_id as oid + from base.t_listes + join base.t_listes_tables on t_listes_tables.oid = t_listes.table_id + join base.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + ) + , classes as ( + select + ''{''||t_listes_tables.code||''}[CLASSE:''||t_classes.code||'':''||t_classes_sections.code||'']'' as code, + t_classes_sections_elements.to_id as oid + from rh.t_classes + join rh.t_listes_tables on t_listes_tables.oid = t_classes.table_id + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join rh.t_classes_sections_elements on t_classes_sections_elements.section_id = t_classes_sections.oid + UNION ALL + select + ''{''||t_listes_tables.code||''}[CLASSE:''||t_classes.code||'':''||t_classes_sections.code||'']'' as code, + t_classes_sections_elements.to_id as oid + from base.t_classes + join base.t_listes_tables on t_listes_tables.oid = t_classes.table_id + join base.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join base.t_classes_sections_elements on t_classes_sections_elements.section_id = t_classes_sections.oid + ) + , listes_exc as ( + select + ''{''||t_listes_tables.code||''}^[LISTE:''||t_listes.code||'']'' as code, + t_listes_contenu.to_id as oid + from rh.t_listes + join rh.t_listes_tables on t_listes_tables.oid = t_listes.table_id + join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + UNION ALL + select + ''{''||t_listes_tables.code||''}^[LISTE:''||t_listes.code||'']'' as code, + t_listes_contenu.to_id as oid + from base.t_listes + join base.t_listes_tables on t_listes_tables.oid = t_listes.table_id + join base.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + ) + , classes_exc as ( + select + ''{''||t_listes_tables.code||''}^[CLASSE:''||t_classes.code||'':''||t_classes_sections.code||'']'' as code, + t_classes_sections_elements.to_id as oid + from rh.t_classes + join rh.t_listes_tables on t_listes_tables.oid = t_classes.table_id + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join rh.t_classes_sections_elements on t_classes_sections_elements.section_id = t_classes_sections.oid + UNION ALL + select + ''{''||t_listes_tables.code||''}^[CLASSE:''||t_classes.code||'':''||t_classes_sections.code||'']'' as code, + t_classes_sections_elements.to_id as oid + from base.t_classes + join base.t_listes_tables on t_listes_tables.oid = t_classes.table_id + join base.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join base.t_classes_sections_elements on t_classes_sections_elements.section_id = t_classes_sections.oid + ) + select + t_population_regle.oid, + population_id, + priorite + %s + from rh.t_population_regle + JOIN rh.t_population ON t_population.oid = t_population_regle.population_id + ORDER BY priorite, population_id + ', tmpReq); + + + + DROP TABLE IF EXISTS temp.toto + ; + CREATE TABLE temp.toto AS + select * from w_population_regle + ; + + RAISE NOTICE '%' , tmpReq + ; + + + RAISE NOTICE '%' , 'Application des regles.' + ; + DROP TABLE IF EXISTS w_profil_contrat_mois + ; + CREATE TEMP TABLE w_profil_contrat_mois AS + SELECT + p_profil_contrat_mois.oid, + COALESCE(MIN(priorite), 999999999) AS population_priorite, + COALESCE((MIN(ARRAY[priorite, w_population_regle.population_id]))[2], 0) AS population_id + FROM rh.p_profil_contrat_mois + JOIN rh.p_contrats_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.t_etablissements ON t_etablissements.oid = etablissement_id + JOIN rh.p_profils ON p_profil_contrat_mois.profil_id = p_profils.oid + JOIN w_population_regle ON true + AND (NOT has_liste_finess OR finess_id = ANY (liste_finess_id)) + AND (NOT (has_exc_liste_finess AND liste_exc_finess_id IS NOT NULL) OR NOT (finess_id = ANY (liste_exc_finess_id))) + AND (NOT has_liste_etablissement OR etablissement_id = ANY (liste_etablissement_id)) + AND (NOT (has_exc_liste_etablissement AND liste_exc_etablissement_id IS NOT NULL) OR NOT (etablissement_id = ANY (liste_exc_etablissement_id))) + AND (NOT has_liste_service OR p_profils.service_id = ANY (liste_service_id)) + AND (NOT (has_exc_liste_service AND liste_exc_service_id IS NOT NULL) OR NOT (p_profils.service_id = ANY (liste_exc_service_id))) + AND (NOT has_liste_specialite OR p_profils.specialite_id = ANY (liste_specialite_id)) + AND (NOT (has_exc_liste_specialite AND liste_exc_specialite_id IS NOT NULL) OR NOT (p_profils.specialite_id = ANY (liste_exc_specialite_id))) + AND (NOT has_liste_qualification OR p_profils.qualification_id = ANY (liste_qualification_id)) + AND (NOT (has_exc_liste_qualification AND liste_exc_qualification_id IS NOT NULL) OR NOT (p_profils.qualification_id = ANY (liste_exc_qualification_id))) + AND (NOT has_liste_section_analytique OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) + AND (NOT (has_exc_liste_section_analytique AND liste_exc_section_analytique_id IS NOT NULL) OR NOT (p_profils.section_analytique_id = ANY (liste_exc_section_analytique_id))) + AND (NOT has_liste_section_analytique_paie OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) + AND (NOT (has_exc_liste_section_analytique_paie AND liste_exc_section_analytique_paie_id IS NOT NULL) OR NOT (p_profils.section_analytique_paie_id = ANY (liste_exc_section_analytique_paie_id))) + AND (NOT has_liste_grille OR p_profils.grille_id = ANY (liste_grille_id)) + AND (NOT (has_exc_liste_grille AND liste_exc_grille_id IS NOT NULL) OR NOT (p_profils.grille_id = ANY (liste_exc_grille_id))) + AND (NOT has_liste_code_emploi OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) + AND (NOT (has_exc_liste_code_emploi AND liste_exc_code_emploi_id IS NOT NULL) OR NOT (p_profils.code_emploi_id = ANY (liste_exc_code_emploi_id))) + AND (NOT has_liste_categorie_socio_professionnelle OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + AND (NOT (has_exc_liste_categorie_socio_professionnelle AND liste_exc_categorie_socio_professionnelle_id IS NOT NULL) OR NOT (p_profils.categorie_socio_professionnelle_id = ANY (liste_exc_categorie_socio_professionnelle_id))) + AND (NOT has_liste_statut OR p_profils.statut_id = ANY (liste_statut_id)) + AND (NOT (has_exc_liste_statut AND liste_exc_statut_id IS NOT NULL) OR NOT (p_profils.statut_id = ANY (liste_exc_statut_id))) + GROUP BY 1 + ORDER BY 2,1 + ; + + DROP TABLE IF EXISTS w_contrats_mois + ; + CREATE TEMP TABLE w_contrats_mois AS + SELECT + p_contrats_mois.oid, + COALESCE(MIN(priorite), 999999999) AS population_priorite, + COALESCE((MIN(ARRAY[priorite, w_population_regle.population_id]))[2], 0) AS population_id + FROM rh.p_contrats_mois + LEFT JOIN rh.t_etablissements ON t_etablissements.oid = etablissement_id + LEFT JOIN rh.p_profils ON p_contrats_mois.profil_id = p_profils.oid + JOIN w_population_regle ON true + AND (NOT has_liste_finess OR finess_id = ANY (liste_finess_id)) + AND (NOT (has_exc_liste_finess AND liste_exc_finess_id IS NOT NULL) OR NOT (finess_id = ANY (liste_exc_finess_id))) + AND (NOT has_liste_etablissement OR etablissement_id = ANY (liste_etablissement_id)) + AND (NOT (has_exc_liste_etablissement AND liste_exc_etablissement_id IS NOT NULL) OR NOT (etablissement_id = ANY (liste_exc_etablissement_id))) + AND (NOT has_liste_service OR p_profils.service_id = ANY (liste_service_id)) + AND (NOT (has_exc_liste_service AND liste_exc_service_id IS NOT NULL) OR NOT (p_profils.service_id = ANY (liste_exc_service_id))) + AND (NOT has_liste_specialite OR p_profils.specialite_id = ANY (liste_specialite_id)) + AND (NOT (has_exc_liste_specialite AND liste_exc_specialite_id IS NOT NULL) OR NOT (p_profils.specialite_id = ANY (liste_exc_specialite_id))) + AND (NOT has_liste_qualification OR p_profils.qualification_id = ANY (liste_qualification_id)) + AND (NOT (has_exc_liste_qualification AND liste_exc_qualification_id IS NOT NULL) OR NOT (p_profils.qualification_id = ANY (liste_exc_qualification_id))) + AND (NOT has_liste_section_analytique OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) + AND (NOT (has_exc_liste_section_analytique AND liste_exc_section_analytique_id IS NOT NULL) OR NOT (p_profils.section_analytique_id = ANY (liste_exc_section_analytique_id))) + AND (NOT has_liste_section_analytique_paie OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) + AND (NOT (has_exc_liste_section_analytique_paie AND liste_exc_section_analytique_paie_id IS NOT NULL) OR NOT (p_profils.section_analytique_paie_id = ANY (liste_exc_section_analytique_paie_id))) + AND (NOT has_liste_grille OR p_profils.grille_id = ANY (liste_grille_id)) + AND (NOT (has_exc_liste_grille AND liste_exc_grille_id IS NOT NULL) OR NOT (p_profils.grille_id = ANY (liste_exc_grille_id))) + AND (NOT has_liste_code_emploi OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) + AND (NOT (has_exc_liste_code_emploi AND liste_exc_code_emploi_id IS NOT NULL) OR NOT (p_profils.code_emploi_id = ANY (liste_exc_code_emploi_id))) + AND (NOT has_liste_categorie_socio_professionnelle OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + AND (NOT (has_exc_liste_categorie_socio_professionnelle AND liste_exc_categorie_socio_professionnelle_id IS NOT NULL) OR NOT (p_profils.categorie_socio_professionnelle_id = ANY (liste_exc_categorie_socio_professionnelle_id))) + AND (NOT has_liste_statut OR p_profils.statut_id = ANY (liste_statut_id)) + AND (NOT (has_exc_liste_statut AND liste_exc_statut_id IS NOT NULL) OR NOT (p_profils.statut_id = ANY (liste_exc_statut_id))) + GROUP BY 1 + ORDER BY 1 + ; + + DROP TABLE IF EXISTS w_contrats + ; + CREATE TEMP TABLE w_contrats AS + SELECT + p_contrats.oid, + COALESCE(MIN(priorite), 999999999) AS population_priorite, + COALESCE((MIN(ARRAY[priorite, w_population_regle.population_id]))[2], 0) AS population_id + FROM rh.p_contrats + LEFT JOIN rh.t_etablissements ON t_etablissements.oid = etablissement_id + LEFT JOIN rh.p_profils ON p_contrats.profil_id = p_profils.oid + JOIN w_population_regle ON true + AND (NOT has_liste_finess OR finess_id = ANY (liste_finess_id)) + AND (NOT (has_exc_liste_finess AND liste_exc_finess_id IS NOT NULL) OR NOT (finess_id = ANY (liste_exc_finess_id))) + AND (NOT has_liste_etablissement OR etablissement_id = ANY (liste_etablissement_id)) + AND (NOT (has_exc_liste_etablissement AND liste_exc_etablissement_id IS NOT NULL) OR NOT (etablissement_id = ANY (liste_exc_etablissement_id))) + AND (NOT has_liste_service OR p_profils.service_id = ANY (liste_service_id)) + AND (NOT (has_exc_liste_service AND liste_exc_service_id IS NOT NULL) OR NOT (p_profils.service_id = ANY (liste_exc_service_id))) + AND (NOT has_liste_specialite OR p_profils.specialite_id = ANY (liste_specialite_id)) + AND (NOT (has_exc_liste_specialite AND liste_exc_specialite_id IS NOT NULL) OR NOT (p_profils.specialite_id = ANY (liste_exc_specialite_id))) + AND (NOT has_liste_qualification OR p_profils.qualification_id = ANY (liste_qualification_id)) + AND (NOT (has_exc_liste_qualification AND liste_exc_qualification_id IS NOT NULL) OR NOT (p_profils.qualification_id = ANY (liste_exc_qualification_id))) + AND (NOT has_liste_section_analytique OR p_profils.section_analytique_id = ANY (liste_section_analytique_id)) + AND (NOT (has_exc_liste_section_analytique AND liste_exc_section_analytique_id IS NOT NULL) OR NOT (p_profils.section_analytique_id = ANY (liste_exc_section_analytique_id))) + AND (NOT has_liste_section_analytique_paie OR p_profils.section_analytique_paie_id = ANY (liste_section_analytique_paie_id)) + AND (NOT (has_exc_liste_section_analytique_paie AND liste_exc_section_analytique_paie_id IS NOT NULL) OR NOT (p_profils.section_analytique_paie_id = ANY (liste_exc_section_analytique_paie_id))) + AND (NOT has_liste_grille OR p_profils.grille_id = ANY (liste_grille_id)) + AND (NOT (has_exc_liste_grille AND liste_exc_grille_id IS NOT NULL) OR NOT (p_profils.grille_id = ANY (liste_exc_grille_id))) + AND (NOT has_liste_code_emploi OR p_profils.code_emploi_id = ANY (liste_code_emploi_id)) + AND (NOT (has_exc_liste_code_emploi AND liste_exc_code_emploi_id IS NOT NULL) OR NOT (p_profils.code_emploi_id = ANY (liste_exc_code_emploi_id))) + AND (NOT has_liste_categorie_socio_professionnelle OR p_profils.categorie_socio_professionnelle_id = ANY (liste_categorie_socio_professionnelle_id)) + AND (NOT (has_exc_liste_categorie_socio_professionnelle AND liste_exc_categorie_socio_professionnelle_id IS NOT NULL) OR NOT (p_profils.categorie_socio_professionnelle_id = ANY (liste_exc_categorie_socio_professionnelle_id))) + AND (NOT has_liste_statut OR p_profils.statut_id = ANY (liste_statut_id)) + AND (NOT (has_exc_liste_statut AND liste_exc_statut_id IS NOT NULL) OR NOT (p_profils.statut_id = ANY (liste_exc_statut_id))) + GROUP BY 1 + ORDER BY 1 + ; + + RAISE NOTICE '%' , 'Application des regles. Validation des Populations' + ; + + UPDATE rh.p_profil_contrat_mois SET + population_id[1] = w_profil_contrat_mois.population_id + FROM w_profil_contrat_mois + WHERE true + AND p_profil_contrat_mois.oid = w_profil_contrat_mois.oid + AND p_profil_contrat_mois.population_id[1] IS DISTINCT FROM w_profil_contrat_mois.population_id + ; + + UPDATE rh.p_profil_contrat_mois SET + population_id[1] = 0 + WHERE true + AND oid NOT IN (SELECT oid FROM w_profil_contrat_mois) + AND population_id[1] IS DISTINCT FROM 0 + ; + + UPDATE rh.p_contrats_mois SET + population_id[1] = w_contrats_mois.population_id + FROM w_contrats_mois + WHERE true + AND p_contrats_mois.oid = w_contrats_mois.oid + AND p_contrats_mois.population_id[1] IS DISTINCT FROM w_contrats_mois.population_id + ; + + UPDATE rh.p_contrats SET + population_id[1] = w_contrats.population_id + FROM w_contrats + WHERE true + AND p_contrats.oid = w_contrats.oid + AND p_contrats.population_id[1] IS DISTINCT FROM w_contrats.population_id + ; + + ANALYSE rh.p_profil_contrat_mois + ; + ANALYSE rh.p_contrats_mois + ; + ANALYSE rh.p_contrats + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'population', population_id[1] + FROM rh.p_profil_contrat_mois + WHERE population_id[1] NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'population') + GROUP BY 2 + ; + RETURN 'OK' + ; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_reorganize_profils.yaml b/db/schema2/functions/cti_reorganize_profils.yaml new file mode 100644 index 0000000..6ebe588 --- /dev/null +++ b/db/schema2/functions/cti_reorganize_profils.yaml @@ -0,0 +1,102 @@ +return: text +lang: plpgsql +src: | + DECLARE + result TEXT; + _champs TEXT[]; + _i INTEGER; + _table TEXT; + _champ TEXT; + _affectations TEXT; + _selects TEXT; + _tests TEXT; + _joins TEXT; + _sqlcmd TEXT; + _affected_rows bigint; + BEGIN + + -- Salariés sans profil + UPDATE rh.p_salaries + SET profil_id = 0 + WHERE profil_id IS NULL; + + INSERT INTO rh.p_profils(oid) + SELECT 0 + WHERE 0 NOT IN (SELECT oid FROM rh.p_profils) AND + 0 IN (SELECT profil_id FROM rh.p_salaries WHERE profil_id = 0); + -- Initialisation des champs + _champs = Array[ + 't_types_contrat', 'type_contrat', + 't_motifs_debut_contrat', 'motif_debut', + 't_motifs_fin_contrat', 'motif_fin', + 't_qualifications', 'qualification', + 't_services', 'service', + 't_specialites', 'specialite', + 't_types_temps_travail', 'type_temps_travail', + 't_categories_socio_professionnelle', 'categorie_socio_professionnelle', + 't_statuts', 'statut', + 't_codes_emploi', 'code_emploi', + 't_societes_interim', 'societe_interim', + 't_sections_analytiques_paie', 'section_analytique_paie', + 't_sections_analytiques', 'section_analytique', + 't_grilles', 'grille', + 't_grilles_groupes', 'grille_groupe', + 't_types_horaire', 'type_horaire', + 't_groupes_cotisant', 'groupe_cotisant', + 't_cadre_emploi', 'cadre_emploi', + 't_categorie_conge', 'categorie_conge', + 't_categorie_statutaire', 'categorie_statutaire', + 't_commission_paritaire', 'commission_paritaire', + 't_compte', 'compte_salarie', + 't_filiere', 'filiere', + 't_lettre_budgetaire', 'lettre_budgetaire', + 't_unite_fonctionnelle', 'unite_fonctionnelle' + ]; + _i = 0; + _affectations = ''; + _selects = ''; + _joins = ''; + _tests = ''; + WHILE _i <= 48 LOOP + _i = _i + 1; + _table = _champs[_i]; + _i = _i + 1; + _champ = _champs[_i]; + IF _affectations <> '' THEN + _affectations = _affectations || ', ' || chr(10); + END IF; + IF _selects <> '' THEN + _selects = _selects || ', ' || chr(10); + END IF; + IF _tests <> '' THEN + _tests = _tests || ' OR ' || chr(10); + END IF; + _affectations = _affectations || _champ || '_id = new_' || _champ || '_id, ' || chr(10); + _affectations = _affectations || _champ || '_code = new_' || _champ || '_code, ' || chr(10); + _affectations = _affectations || _champ || '_texte = new_' || _champ || '_texte'; + _selects = _selects || 'COALESCE(' || _table || '.oid,0) AS new_' || _champ || '_id, ' || chr(10); + _selects = _selects || 'COALESCE(' || _table || '.code,' || _table || '_0.code) AS new_' || _champ || '_code, ' || chr(10); + _selects = _selects || 'COALESCE(' || _table || '.texte,' || _table || '_0.texte) AS new_' || _champ || '_texte'; + _joins = _joins || chr(10) || 'LEFT JOIN rh.' || _table || ' ' || _table || '_0 ON ' || _table || '_0.oid = 0'; + _joins = _joins || chr(10) || 'LEFT JOIN rh.' || _table || ' ON ' || _table || '.code_original = ' || _champ || '_code_original'; + _tests = _tests || _champ || '_id IS DISTINCT FROM new_' || _champ || '_id OR ' || chr(10); + _tests = _tests || _champ || '_code IS DISTINCT FROM new_' || _champ || '_code OR ' || chr(10); + _tests = _tests || _champ || '_texte IS DISTINCT FROM new_' || _champ || '_texte'; + + END LOOP; + _sqlcmd = 'UPDATE rh.p_profils SET' || chr(10); + _sqlcmd = _sqlcmd || _affectations || chr(10); + _sqlcmd = _sqlcmd || 'FROM (' || chr(10); + _sqlcmd = _sqlcmd || 'SELECT' || chr(10); + _sqlcmd = _sqlcmd || 'p_profils.oid AS new_profil_id,' || chr(10); + _sqlcmd = _sqlcmd || _selects || chr(10); + _sqlcmd = _sqlcmd || 'FROM rh.p_profils' || chr(10); + _sqlcmd = _sqlcmd || _joins || chr(10); + _sqlcmd = _sqlcmd || ') subview' || chr(10); + _sqlcmd = _sqlcmd || 'WHERE p_profils.oid = new_profil_id AND' || chr(10); + _sqlcmd = _sqlcmd || '(' || _tests || ')'; + EXECUTE _sqlcmd; + GET DIAGNOSTICS _affected_rows = ROW_COUNT; + + return (_affected_rows::text || ' ligne(s) modifiée(s)')::text; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_reorganize_profils_table~tx,tx.yaml b/db/schema2/functions/cti_reorganize_profils_table~tx,tx.yaml new file mode 100644 index 0000000..698e3b7 --- /dev/null +++ b/db/schema2/functions/cti_reorganize_profils_table~tx,tx.yaml @@ -0,0 +1,52 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: tablename + p1: + type: text + name: field_prefix +src: | + DECLARE + w_tablename TEXT; + w_field_prefix TEXT; + result TEXT; + t0 timestamp; + t1 timestamp; + t2 timestamp; + t3 timestamp; + BEGIN + w_tablename = tablename; + IF w_tablename = '' THEN + w_tablename = 't_codes_emploi'; + END IF; + + w_field_prefix = field_prefix; + IF w_field_prefix = '' THEN + w_field_prefix = 'code_emploi'; + END IF; + + RAISE NOTICE 'Traitement de %', w_tablename; + t0 = clock_timestamp(); + EXECUTE 'UPDATE rh.p_profils + SET ' || w_field_prefix || '_id = ' || w_tablename || '.oid + FROM rh.' || w_tablename || ' + WHERE ' || w_tablename || '.code_original = p_profils.' || w_field_prefix || '_code_original + AND ' || w_field_prefix || '_id IS DISTINCT FROM ' || w_tablename || '.oid;'; + t1 = clock_timestamp(); + EXECUTE 'UPDATE rh.p_profils SET ' || w_field_prefix || '_id = 0 WHERE ' || w_field_prefix || '_id IS NULL;'; + t2 = clock_timestamp(); + EXECUTE 'UPDATE rh.p_profils + SET + ' || w_field_prefix || '_code = ' || w_tablename || '.code, + ' || w_field_prefix || '_texte = ' || w_tablename || '.texte + FROM rh.' || w_tablename || ' + WHERE ' || w_tablename || '.oid = p_profils.' || w_field_prefix || '_id + AND (' || w_field_prefix || '_code IS DISTINCT FROM ' || w_tablename || '.code OR + ' || w_field_prefix || '_texte IS DISTINCT FROM ' || w_tablename || '.texte);'; + t3 = clock_timestamp(); + + RAISE NOTICE 'Total % (1 : %; 2 : %; 3 : %)', t3 - t0, t1 - t0, t2 - t1, t3 - t2; + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_shs_multicode~tx,tx.yaml b/db/schema2/functions/cti_shs_multicode~tx,tx.yaml new file mode 100644 index 0000000..e1a0dbe --- /dev/null +++ b/db/schema2/functions/cti_shs_multicode~tx,tx.yaml @@ -0,0 +1,82 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: i_from_table + p1: + type: text + name: i_to_table +src: | + DECLARE + _sqlcmd TEXT; + result TEXT; + BEGIN + IF NOT EXISTS (SELECT * FROM pg_class WHERE relnamespace = pg_my_temp_schema() AND relname = i_to_table) THEN + _sqlcmd = ' + CREATE TEMP TABLE ' || i_to_table || ' + ( + XXCENT numeric, + XXCETS numeric, + XXCODO text, + XXCODE text, + in_code text, + in_code_original text, + in_texte text, + in_id bigint + ); + CREATE INDEX ' || i_to_table || '_i1 ON ' || i_to_table || ' USING btree(XXCODO) + ' + ; + EXECUTE _sqlcmd; + END IF; + + + -- Table de correspondance + _sqlcmd = ' + TRUNCATE ' || i_to_table || ' + ; + INSERT INTO ' || i_to_table || ' + SELECT + XXCENT, + XXCETS, + XXCODO, + XXCODE, + XXCODE || + CASE WHEN base.cti_soundex_nom(replace(XXTEXT,''.'','''')) <> XXTEXT_STD_soundex THEN + ''('' || XXCENT || ''.'' || XXCETS || '')'' + ELSE '''' END + AS in_code, + XXCODO || + CASE WHEN base.cti_soundex_nom(replace(XXTEXT,''.'','''')) <> XXTEXT_STD_soundex THEN + ''_'' || to_char(XXCENT,''FM000'') || to_char(XXCETS,''FM000'') + ELSE '''' END + AS in_code_original, + CASE WHEN base.cti_soundex_nom(replace(XXTEXT,''.'','''')) <> XXTEXT_STD_soundex THEN XXTEXT ELSE XXTEXT_STD END AS in_texte, + 0::bigint AS in_id + FROM + ' || i_from_table || ' + JOIN + ( + SELECT XXCODE AS XXCODE_STD, + (MAX(Array[key, XXTEXT_soundex]))[2] AS XXTEXT_STD_soundex, + (MAX(Array[key, XXTEXT_STD]))[2] AS XXTEXT_STD + FROM + ( + SELECT XXCODE, + base.cti_soundex_nom(replace(XXTEXT,''.'','''')) AS XXTEXT_soundex, + MIN(XXTEXT) AS XXTEXT_STD, + to_char(count(*),''FM0000000000'') || MIN(to_char(XXCENT,''FM000'') || to_char(XXCETS,''FM000'')) AS key + FROM ' || i_from_table || ' + GROUP BY 1,2 + ) subview + GROUP BY 1 + ) cti_shs_multicode_std + ON XXCODE = XXCODE_STD + ORDER BY 3,5 + ;' + ; + EXECUTE _sqlcmd; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_to_date~ae,ae,ae.yaml b/db/schema2/functions/cti_to_date~ae,ae,ae.yaml new file mode 100644 index 0000000..5a0101c --- /dev/null +++ b/db/schema2/functions/cti_to_date~ae,ae,ae.yaml @@ -0,0 +1,23 @@ +return: date +lang: plpgsql +parameters: + p0: + type: anyelement + p1: + type: anyelement + p2: + type: anyelement +strict: STRICT +src: | + DECLARE + i_year text; + i_month text; + i_day text; + return_date date; + BEGIN + i_year = $1; + i_month = $2; + i_day = $3; + return_date = to_date(lpad(i_year, 4, '0') || lpad(i_month, 2, '0') || lpad(i_day, 2, '0'), 'YYYYMMDD'); + return return_date; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_update_effectif_permanent.yaml b/db/schema2/functions/cti_update_effectif_permanent.yaml new file mode 100644 index 0000000..5c63db0 --- /dev/null +++ b/db/schema2/functions/cti_update_effectif_permanent.yaml @@ -0,0 +1,49 @@ +return: text +lang: plpgsql +src: | + DECLARE + result TEXT; + BEGIN + with eff_perm_0 as ( + select + p_contrats_mois.oid, + p_contrats_mois.salarie_id, + p_contrats_mois.mois_activite, + sum(case when bool_and(p_profils.type_contrat_section_code[9] = 'CDI' and p_profils.type_temps_travail_section_code[9] = 'TC') + then + case when to_char(p_contrats_mois.date_fin, 'YYYYMM') != p_contrats_mois.mois_activite then base.cti_last_day((p_contrats_mois.mois_activite||'01')::date) else p_contrats_mois.date_fin end + - case when to_char(p_contrats_mois.date_debut, 'YYYYMM') != p_contrats_mois.mois_activite then base.cti_first_day((p_contrats_mois.mois_activite||'01')::date) else p_contrats_mois.date_debut end + + 1 + else 0 end + ) + over (partition by p_contrats_mois.salarie_id, substr(p_contrats_mois.mois_activite, 1, 4) order by p_contrats_mois.date_debut) as duree + from rh.p_contrats_mois + join rh.p_profil_contrat_mois on p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + join rh.p_profils on p_profils.oid = p_profil_contrat_mois.profil_id + group by 1,2,3, p_contrats_mois.date_debut, p_contrats_mois.date_fin, p_contrats_mois.mois_activite + window w as (partition by p_contrats_mois.salarie_id, p_contrats_mois.mois_activite)) + , eff_perm_1 as ( + select + array_agg(oid) as arr_oid, + salarie_id, + mois_activite, + case when sum(base.cti_last_day((mois_activite||'01')::date) - base.cti_first_day((substr(mois_activite, 1, 4)||'0101')::date)) + 1 = duree + then 1 else 0 end as effectif_permanent + from eff_perm_0 + GROUP BY salarie_id, mois_activite, duree + ) + , eff_perm as ( + select + unnest(arr_oid) as oid, + effectif_permanent + from eff_perm_1 + ) + update rh.p_contrats_mois set + effectif_permanent = eff_perm.effectif_permanent + from eff_perm + where true + and p_contrats_mois.oid = eff_perm.oid + and p_contrats_mois.effectif_permanent is distinct from eff_perm.effectif_permanent + ; + return 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_update_schema_classes~tx.yaml b/db/schema2/functions/cti_update_schema_classes~tx.yaml new file mode 100644 index 0000000..0378ed9 --- /dev/null +++ b/db/schema2/functions/cti_update_schema_classes~tx.yaml @@ -0,0 +1,165 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: i_table_code +src: | + DECLARE + result TEXT; + BEGIN + + -- Si Toutes les tables, mettre à jour oid par codes + IF (i_table_code = '*ALL') THEN + PERFORM base.cti_initialize_classes_by_code('rh'); + PERFORM base.cti_initialize_listes_by_code('rh'); + END IF; + + IF (i_table_code = 'ANA' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_section_analytique'', ''ANA'','''');'; + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_ventilation_section'', ''ANA'',''section_analytique_section'');'; + END IF; + IF (i_table_code = 'AGE' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_ages'', ''AGE'','''');'; + END IF; + IF (i_table_code = 'ANC' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_anciennetes_annee'', ''ANC'','''');'; + END IF; + IF (i_table_code = 'CPO' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_codes_postaux'', ''CPO'','''');'; + END IF; + IF (i_table_code = 'CPT' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_compte'', ''CPT'','''');'; + END IF; + IF (i_table_code = 'ETS' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_etablissements'', ''ETS'','''');'; + END IF; + IF (i_table_code = 'COM' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_compte'', ''COM'','''');'; + END IF; + IF (i_table_code = 'MOA' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_motifs_arret'', ''MOA'','''');'; + END IF; + IF (i_table_code = 'NAT' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_nationalites'', ''NAT'','''');'; + END IF; + IF (i_table_code = 'ORC' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_organismes_cotisation'', ''ORC'','''');'; + END IF; + IF (i_table_code = 'CAE' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''CAE'',''cadre_emploi_section'');'; + END IF; + IF (i_table_code = 'CAC' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''CAC'',''categorie_conge_section'');'; + END IF; + IF (i_table_code = 'CSC' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''CSC'',''categorie_socio_professionnelle_section'');'; + END IF; + IF (i_table_code = 'CAS' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''CAS'',''categorie_statutaire_section'');'; + END IF; + IF (i_table_code = 'CEM' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''CEM'',''code_emploi_section'');'; + END IF; + IF (i_table_code = 'GCP' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''GCP'',''commission_paritaire_section'');'; + END IF; + IF (i_table_code = 'COI' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''COI'',''compte_salarie_section'');'; + END IF; + IF (i_table_code = 'FIL' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''FIL'',''filiere_section'');'; + END IF; + IF (i_table_code = 'GCT' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''GCT'',''groupe_cotisant_section'');'; + END IF; + IF (i_table_code = 'GRG' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''GRG'',''grille_groupe_section'');'; + END IF; + IF (i_table_code = 'GRI' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''GRI'',''grille_section'');'; + END IF; + IF (i_table_code = 'LEB' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''LEB'',''lettre_budgetaire_section'');'; + END IF; + IF (i_table_code = 'MTD' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''MTD'',''motif_debut_section'');'; + END IF; + IF (i_table_code = 'MTF' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''MTF'',''motif_fin_section'');'; + END IF; + IF (i_table_code = 'PNI' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_planning_niveau'', ''PNI'','''');'; + END IF; + IF (i_table_code = 'SER' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''SER'',''service_section'');'; + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_planning_service'', ''SER'',''service_section'');'; + END IF; + IF (i_table_code = 'QUA' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''QUA'',''qualification_section'');'; + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_planning_qualification'', ''QUA'',''qualification_section'');'; + END IF; + IF (i_table_code = 'SAC' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''SAC'',''section_analytique_section'');'; + END IF; + IF (i_table_code = 'SAP' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''SAP'',''section_analytique_paie_section'');'; + END IF; + IF (i_table_code = 'SPE' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''SPE'',''specialite_section'');'; + END IF; + IF (i_table_code = 'STA' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''STA'',''statut_section'');'; + END IF; + IF (i_table_code = 'TCN' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''TCN'',''type_contrat_section'');'; + END IF; + IF (i_table_code = 'THO' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''THO'',''type_horaire_section'');'; + END IF; + IF (i_table_code = 'TTT' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''TTT'',''type_temps_travail_section'');'; + END IF; + IF (i_table_code = 'UNF' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_profils'', ''UNF'',''unite_fonctionnelle_section'');'; + END IF; + IF (i_table_code = 'RUP' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_rubriques'', ''RUP'','''');'; + END IF; + IF (i_table_code = 'SAL' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''p_salaries'', ''SAL'','''');'; + END IF; + IF (i_table_code = 'PQU' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_planning_qualification'', ''PQU'','''');'; + END IF; + IF (i_table_code = 'PSE' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_planning_service'', ''PSE'','''');'; + END IF; + IF (i_table_code = 'PAB' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_planning_type_absence'', ''PAB'','''');'; + END IF; + IF (i_table_code = 'PCH' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT base.cti_update_classes(''rh'', ''t_planning_code_horaire'', ''PCH'','''');'; + END IF; + + IF (i_table_code = 'TCN' OR i_table_code = 'TTT' OR i_table_code = '*ALL') THEN + EXECUTE 'SELECT rh.cti_update_effectif_permanent();'; + END IF; + IF (i_table_code = 'POLE' OR i_table_code = '*ALL') THEN + PERFORM base.cti_update_classes('base', 't_pole', 'POLE',''); + UPDATE rh.t_pole SET + section_id = t_pole.section_id, + section_code = t_pole.section_code, + section_texte = t_pole.section_texte + FROM base.t_pole as t_pole_base + WHERE t_pole.oid = t_pole_base.oid AND + ( + t_pole.section_id IS DISTINCT FROM t_pole_base.section_id OR + t_pole.section_code IS DISTINCT FROM t_pole_base.section_code OR + t_pole.section_texte IS DISTINCT FROM t_pole_base.section_texte + ) + ; + END IF; + + RETURN 'OK'; + END; \ No newline at end of file diff --git a/db/schema2/functions/cti_util_translate_list~tx.yaml b/db/schema2/functions/cti_util_translate_list~tx.yaml new file mode 100644 index 0000000..9dd6af1 --- /dev/null +++ b/db/schema2/functions/cti_util_translate_list~tx.yaml @@ -0,0 +1,23 @@ +return: text +lang: plpgsql +parameters: + p0: + type: text + name: i_liste +src: | + DECLARE + _liste text; + + BEGIN + _liste = i_liste; + _liste = trim(translate(COALESCE(_liste,''),'"' || chr(9) || chr(10) || chr(13),' ')); + _liste = replace(_liste,' ',' '); + _liste = replace(_liste,' ',' '); + _liste = replace(_liste,' ',' '); + _liste = replace(_liste,' ',' '); + _liste = (SELECT coalesce(base.cti_group_concat_without_sep(code || ' '), '') + FROM + (SELECT code FROM base.cti_unnest(string_to_array(_liste,' ')) AS code ORDER BY 1) subview + ); + RETURN _liste ; + END; \ No newline at end of file diff --git a/db/schema2/sequences/s_accident_circonstance.yaml b/db/schema2/sequences/s_accident_circonstance.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_accident_circonstance.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_accident_lieu.yaml b/db/schema2/sequences/s_accident_lieu.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_accident_lieu.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_accident_nature.yaml b/db/schema2/sequences/s_accident_nature.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_accident_nature.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_accident_siege.yaml b/db/schema2/sequences/s_accident_siege.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_accident_siege.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_accident_travail.yaml b/db/schema2/sequences/s_accident_travail.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_accident_travail.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_arrets_travail.yaml b/db/schema2/sequences/s_arrets_travail.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_arrets_travail.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_budget_cle.yaml b/db/schema2/sequences/s_budget_cle.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_budget_cle.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_budget_cle_rule.yaml b/db/schema2/sequences/s_budget_cle_rule.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_budget_cle_rule.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_cadre_emploi.yaml b/db/schema2/sequences/s_cadre_emploi.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_cadre_emploi.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_categorie_conge.yaml b/db/schema2/sequences/s_categorie_conge.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_categorie_conge.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_categorie_statutaire.yaml b/db/schema2/sequences/s_categorie_statutaire.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_categorie_statutaire.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_categories_socio_professionnelles.yaml b/db/schema2/sequences/s_categories_socio_professionnelles.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_categories_socio_professionnelles.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_chart.yaml b/db/schema2/sequences/s_chart.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_chart.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_classes.yaml b/db/schema2/sequences/s_classes.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_classes.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_classes_sections.yaml b/db/schema2/sequences/s_classes_sections.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_classes_sections.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_code_cotisation.yaml b/db/schema2/sequences/s_code_cotisation.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_code_cotisation.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_codes_emploi.yaml b/db/schema2/sequences/s_codes_emploi.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_codes_emploi.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_commission_paritaire.yaml b/db/schema2/sequences/s_commission_paritaire.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_commission_paritaire.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_compte.yaml b/db/schema2/sequences/s_compte.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_compte.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_contrats.yaml b/db/schema2/sequences/s_contrats.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_contrats.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_contrats_mois.yaml b/db/schema2/sequences/s_contrats_mois.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_contrats_mois.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_dashboard.yaml b/db/schema2/sequences/s_dashboard.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_dashboard.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_dashboard_filter.yaml b/db/schema2/sequences/s_dashboard_filter.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_dashboard_filter.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_dashboard_onglet.yaml b/db/schema2/sequences/s_dashboard_onglet.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_dashboard_onglet.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_dashboard_widget.yaml b/db/schema2/sequences/s_dashboard_widget.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_dashboard_widget.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_data_profile.yaml b/db/schema2/sequences/s_data_profile.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_data_profile.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_entreprises.yaml b/db/schema2/sequences/s_entreprises.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_entreprises.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_etablissements.yaml b/db/schema2/sequences/s_etablissements.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_etablissements.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_expert_controle.yaml b/db/schema2/sequences/s_expert_controle.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_expert_controle.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_expert_controle_data.yaml b/db/schema2/sequences/s_expert_controle_data.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_expert_controle_data.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_expert_controle_rule.yaml b/db/schema2/sequences/s_expert_controle_rule.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_expert_controle_rule.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_filiere.yaml b/db/schema2/sequences/s_filiere.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_filiere.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_formations.yaml b/db/schema2/sequences/s_formations.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_formations.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_grilles.yaml b/db/schema2/sequences/s_grilles.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_grilles.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_grilles_groupes.yaml b/db/schema2/sequences/s_grilles_groupes.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_grilles_groupes.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_groupes_cotisant.yaml b/db/schema2/sequences/s_groupes_cotisant.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_groupes_cotisant.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_handicap.yaml b/db/schema2/sequences/s_handicap.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_handicap.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_historique_paie.yaml b/db/schema2/sequences/s_historique_paie.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_historique_paie.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_indicateur_condition.yaml b/db/schema2/sequences/s_indicateur_condition.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_indicateur_condition.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_indicateur_condition_table.yaml b/db/schema2/sequences/s_indicateur_condition_table.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_indicateur_condition_table.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_indicateur_externe.yaml b/db/schema2/sequences/s_indicateur_externe.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_indicateur_externe.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_indicateur_externe_import.yaml b/db/schema2/sequences/s_indicateur_externe_import.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_indicateur_externe_import.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_indicateur_serie.yaml b/db/schema2/sequences/s_indicateur_serie.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_indicateur_serie.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_indicateur_theme.yaml b/db/schema2/sequences/s_indicateur_theme.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_indicateur_theme.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_indicateurs.yaml b/db/schema2/sequences/s_indicateurs.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_indicateurs.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_lettre_budgetaire.yaml b/db/schema2/sequences/s_lettre_budgetaire.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_lettre_budgetaire.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_liste_formations.yaml b/db/schema2/sequences/s_liste_formations.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_liste_formations.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_listes.yaml b/db/schema2/sequences/s_listes.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_listes.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_listes_tables.yaml b/db/schema2/sequences/s_listes_tables.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_listes_tables.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_motifs_arret.yaml b/db/schema2/sequences/s_motifs_arret.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_motifs_arret.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_motifs_debut_contrat.yaml b/db/schema2/sequences/s_motifs_debut_contrat.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_motifs_debut_contrat.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_motifs_fin_contrat.yaml b/db/schema2/sequences/s_motifs_fin_contrat.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_motifs_fin_contrat.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_motifs_visite.yaml b/db/schema2/sequences/s_motifs_visite.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_motifs_visite.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_nationalites.yaml b/db/schema2/sequences/s_nationalites.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_nationalites.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_organismes_cotisation.yaml b/db/schema2/sequences/s_organismes_cotisation.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_organismes_cotisation.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_personne.yaml b/db/schema2/sequences/s_personne.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_personne.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_plan_analytique.yaml b/db/schema2/sequences/s_plan_analytique.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_plan_analytique.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_planning_code_horaire.yaml b/db/schema2/sequences/s_planning_code_horaire.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_planning_code_horaire.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_planning_mouvement.yaml b/db/schema2/sequences/s_planning_mouvement.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_planning_mouvement.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_planning_niveau.yaml b/db/schema2/sequences/s_planning_niveau.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_planning_niveau.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_planning_qualification.yaml b/db/schema2/sequences/s_planning_qualification.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_planning_qualification.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_planning_service.yaml b/db/schema2/sequences/s_planning_service.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_planning_service.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_planning_type_absence.yaml b/db/schema2/sequences/s_planning_type_absence.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_planning_type_absence.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_pole_rule.yaml b/db/schema2/sequences/s_pole_rule.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_pole_rule.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_population.yaml b/db/schema2/sequences/s_population.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_population.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_population_regle.yaml b/db/schema2/sequences/s_population_regle.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_population_regle.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_precisions_motif_arret.yaml b/db/schema2/sequences/s_precisions_motif_arret.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_precisions_motif_arret.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_profil_contrat_mois.yaml b/db/schema2/sequences/s_profil_contrat_mois.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_profil_contrat_mois.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_profils.yaml b/db/schema2/sequences/s_profils.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_profils.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_qualifications.yaml b/db/schema2/sequences/s_qualifications.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_qualifications.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_rapports.yaml b/db/schema2/sequences/s_rapports.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_rapports.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_rubriques.yaml b/db/schema2/sequences/s_rubriques.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_rubriques.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_salaries.yaml b/db/schema2/sequences/s_salaries.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_salaries.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_salaries_handicapes.yaml b/db/schema2/sequences/s_salaries_handicapes.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_salaries_handicapes.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_section_analytique.yaml b/db/schema2/sequences/s_section_analytique.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_section_analytique.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_sections_analytiques.yaml b/db/schema2/sequences/s_sections_analytiques.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_sections_analytiques.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_sections_analytiques_paie.yaml b/db/schema2/sequences/s_sections_analytiques_paie.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_sections_analytiques_paie.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_services.yaml b/db/schema2/sequences/s_services.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_services.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_situations_famille.yaml b/db/schema2/sequences/s_situations_famille.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_situations_famille.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_societes_interim.yaml b/db/schema2/sequences/s_societes_interim.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_societes_interim.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_specialites.yaml b/db/schema2/sequences/s_specialites.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_specialites.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_statuts.yaml b/db/schema2/sequences/s_statuts.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_statuts.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_transformation.yaml b/db/schema2/sequences/s_transformation.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_transformation.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_types_contrat.yaml b/db/schema2/sequences/s_types_contrat.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_types_contrat.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_types_horaire.yaml b/db/schema2/sequences/s_types_horaire.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_types_horaire.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_types_temps_travail.yaml b/db/schema2/sequences/s_types_temps_travail.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_types_temps_travail.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_unite_fonctionnelle.yaml b/db/schema2/sequences/s_unite_fonctionnelle.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_unite_fonctionnelle.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_validation_parametre.yaml b/db/schema2/sequences/s_validation_parametre.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_validation_parametre.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_ventilation.yaml b/db/schema2/sequences/s_ventilation.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_ventilation.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_visites_medicales.yaml b/db/schema2/sequences/s_visites_medicales.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_visites_medicales.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/sequences/s_vue_parametre.yaml b/db/schema2/sequences/s_vue_parametre.yaml new file mode 100644 index 0000000..e63c2f9 --- /dev/null +++ b/db/schema2/sequences/s_vue_parametre.yaml @@ -0,0 +1,5 @@ +min: NO MINVALUE +max: NO MAXVALUE +start: 1 +increment: 1 +cache: 1 \ No newline at end of file diff --git a/db/schema2/tables/p_accident_travail.yaml b/db/schema2/tables/p_accident_travail.yaml new file mode 100644 index 0000000..193488c --- /dev/null +++ b/db/schema2/tables/p_accident_travail.yaml @@ -0,0 +1,48 @@ +columns: + accident_circonstance_id: + type: bigint + accident_lieu_id: + type: bigint + accident_nature_id: + type: bigint + accident_siege_id: + type: bigint + contrat_id: + type: bigint + contrat_mois_id: + type: bigint + date: + type: date + mois_activite: + type: numeric(6,0) + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_accident_travail'::regclass)" + salarie_id: + type: bigint +indexes: + i_accident_travail_1: + column: contrat_id + method: btree + i_accident_travail_2: + column: mois_activite + method: btree + i_accident_travail_3: + column: date + method: btree + i_accident_travail_4: + column: salarie_id + method: btree + i_accident_travail_5: + column: accident_circonstance_id + method: btree + i_accident_travail_6: + column: accident_lieu_id + method: btree + i_accident_travail_7: + column: accident_nature_id + method: btree + i_accident_travail_8: + column: accident_siege_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_arrets_travail.yaml b/db/schema2/tables/p_arrets_travail.yaml new file mode 100644 index 0000000..830c9da --- /dev/null +++ b/db/schema2/tables/p_arrets_travail.yaml @@ -0,0 +1,41 @@ +columns: + contrat_id: + type: bigint + date_debut: + type: date + date_fin: + type: date + date_reprise: + type: date + mois_activite: + type: numeric(6,0) + motif_arret_id: + type: bigint + nb_heures: + type: numeric + nb_jours: + type: numeric + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_arrets_travail'::regclass)" + precision_motif_arret_id: + type: bigint + salarie_id: + type: bigint +indexes: + i_arrets_travail_1: + column: contrat_id + method: btree + i_arrets_travail_2: + column: mois_activite + method: btree + i_arrets_travail_4: + column: motif_arret_id + method: btree + i_arrets_travail_5: + column: precision_motif_arret_id + method: btree + i_arrets_travail_9: + column: salarie_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_arrets_travail_mois.yaml b/db/schema2/tables/p_arrets_travail_mois.yaml new file mode 100644 index 0000000..15a6979 --- /dev/null +++ b/db/schema2/tables/p_arrets_travail_mois.yaml @@ -0,0 +1,44 @@ +columns: + arret_travail_id: + type: bigint + contrat_id: + type: bigint + contrat_mois_id: + type: bigint + date_debut: + type: date + date_fin: + type: date + mois_activite: + type: numeric(6,0) + nb_arret: + type: numeric(1,0) + nb_debut_arret: + type: numeric(1,0) + nb_fin_arret: + type: numeric(1,0) + nb_heures: + type: numeric + nb_jours: + type: numeric + nb_reprise_apres_arret: + type: numeric(1,0) + salarie_id: + type: bigint +constraints: + p_arrets_travail_mois_ukey: + type: UNIQUE + column: arret_travail_id, contrat_mois_id +indexes: + i_arrets_travail_mois_1: + column: arret_travail_id + method: btree + i_arrets_travail_mois_2: + column: mois_activite + method: btree + i_arrets_travail_mois_3: + column: contrat_id + method: btree + i_arrets_travail_mois_4: + column: salarie_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_chiffrier_production.yaml b/db/schema2/tables/p_chiffrier_production.yaml new file mode 100644 index 0000000..7dd328a --- /dev/null +++ b/db/schema2/tables/p_chiffrier_production.yaml @@ -0,0 +1,20 @@ +columns: + entreprise_id: + type: bigint + etablissement_id: + type: bigint + mois: + type: numeric(6,0) + montant_brut: + type: numeric(13,2) + nombre_heures: + type: numeric(11,2) + nombre_heures_od: + type: numeric(11,2) + default: "0" + nombre_salaries: + type: numeric(5,0) +constraints: + p_chiffrier_production_ukey: + type: UNIQUE + column: entreprise_id, etablissement_id, mois \ No newline at end of file diff --git a/db/schema2/tables/p_consolidation_translation.yaml b/db/schema2/tables/p_consolidation_translation.yaml new file mode 100644 index 0000000..3ca5ada --- /dev/null +++ b/db/schema2/tables/p_consolidation_translation.yaml @@ -0,0 +1,30 @@ +columns: + from_code: + type: text + default: "''::text" + from_database: + type: text + from_id: + type: bigint + default: "0" + table_code: + type: text + to_code: + type: text + default: "''::text" + to_id: + type: bigint + default: "0" +indexes: + i_consolidation_translation_1: + column: from_database + method: btree + i_consolidation_translation_2: + column: table_code + method: btree + i_consolidation_translation_3: + column: from_id + method: btree + i_consolidation_translation_4: + column: to_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_contrats.yaml b/db/schema2/tables/p_contrats.yaml new file mode 100644 index 0000000..0be4d0c --- /dev/null +++ b/db/schema2/tables/p_contrats.yaml @@ -0,0 +1,63 @@ +columns: + anciennete_anterieure_calculee_jours: + type: bigint + default: "0" + anciennete_anterieure_calculee_mois: + type: bigint + default: "0" + anciennete_anterieure_jours: + type: numeric + default: "0" + anciennete_anterieure_mois: + type: bigint + default: "0" + anciennete_reprise_anterieure_jours: + type: numeric + default: "0" + anciennete_reprise_anterieure_calculee_mois: + type: bigint + default: "0" + code_original: + type: text + not_null: NOT NULL + date_debut: + type: date + date_fin: + type: date + etablissement_id: + type: bigint + comment: | + Etablissement principal. + Le salarié peut être affecté à plusieurs établissements de manière simultanée ou séquentielle tout en ayant un seul et même contrat de travail. + numero_contrat: + type: text + default: "''::character varying" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_contrats'::regclass)" + pole_id: + type: bigint + default: "0" + population_id: + type: 'bigint[]' + profil_id: + type: bigint + salarie_id: + type: bigint + salarie_remplace_id: + type: bigint +constraints: + p_contrats_pkey: + type: PRIMARY KEY + column: oid + p_contrats_ukey: + type: UNIQUE + column: code_original +indexes: + i_contrats_1: + column: salarie_id + method: btree + i_contrats_2: + column: etablissement_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_contrats_mois.yaml b/db/schema2/tables/p_contrats_mois.yaml new file mode 100644 index 0000000..b4b4ff9 --- /dev/null +++ b/db/schema2/tables/p_contrats_mois.yaml @@ -0,0 +1,171 @@ +columns: + age_id: + type: bigint + age_jours: + type: numeric(9,0) + default: "0" + anciennete_annee_id: + type: bigint + default: "0" + comment: "Ancienneté dans l''établissement en années" + anciennete_reprise_annee_id: + type: bigint + default: "0" + comment: "Ancienneté reprise dans l''établissement en années" + anciennete_fp_annee_id: + type: bigint + default: "0" + comment: Ancienneté dans la fonction publique en années + anciennete_fp_mois: + type: bigint + default: "0" + comment: Ancienneté dans la fonction publique en mois + anciennete_fph_annee_id: + type: bigint + default: "0" + comment: Ancienneté dans la fonction publique hospitalière en années + anciennete_fph_mois: + type: bigint + default: "0" + comment: Ancienneté dans la fonction publique hospitalière en mois + anciennete_grade_annee_id: + type: bigint + default: "0" + comment: Ancienneté dans le grade en années + anciennete_grade_mois: + type: bigint + default: "0" + comment: Ancienneté dans le grade en mois + anciennete_jours: + type: numeric + default: "0" + comment: "Ancienneté dans l''établissement en jours" + anciennete_reprise_jours: + type: numeric + default: "0" + comment: "Ancienneté reprise dans l''établissement en jours" + anciennete_mois: + type: bigint + default: "0" + comment: "Ancienneté dans l''établissement en mois" + anciennete_reprise_mois: + type: bigint + default: "0" + comment: "Ancienneté reprise dans l''établissement en mois" + code_original: + type: text + contrat_id: + type: bigint + date_debut: + type: date + comment: | + Date de début du contrat sur le mois. + Correspond au 1er du mois si contrat en cours. + date_fin: + type: date + comment: | + Date de fin du contrat sur le mois. + Correspond au dernier jour du mois si contrat en cours. + effectif_permanent: + type: numeric + default: "0" + comment: | + Toujours calculé depuis le 1er janvier. + Pour savoir si un salarié fait partie de l''effectif permanent, il faut regarder cet indicateur sur le dernier mois de la période analysée. + 0 = non + 1 = oui + equivalent_temps_plein: + type: numeric + comment: "Nombre d''heures théorique du contrat / Nombre d''heures travaillées dans l''établissement (basé sur t_etablissements.base_calcul_etp)" + est_hors_periode: + type: character(1) + default: "'0'::bpchar" + comment: | + Ce champ aurait pu s''appeler "paie_hors_periode_de_contrat". + 0 = cas standard : un contrat est présent sur ce mois + 1 = cas particulier : aucun contrat ne couvre ce mois. Un lien est effectué avec le dernier contrat. Cela permet par ex. d''associer un rappel de paye effectué a posteriori hors contrat. + etablissement_id: + type: bigint + comment: Le salarié peut être affecté à plusieurs établissements de manière simultanée ou séquentielle tout en ayant un seul et même contrat de travail. + fictif: + type: character(1) + default: "0" + mois_activite: + type: numeric(6,0) + nombre_debut_contrat: + type: numeric(5,0) + comment: | + Nombre de début de contrat. + 0 si contrat ne commence pas sur le mois ou hors période = 1 + 1 si contrat commencé sur le mois + nombre_departs: + type: numeric(5,0) + default: "0" + comment: | + Dernier contrat avant sortie de l''établissement (basé sur p_salaries.date_sortie_ets) ? + 0 = non + 1 = oui + nombre_entrees: + type: numeric + default: "0" + comment: | + Premier contrat à l''entrée de l''établissement (basé sur p_salaries.date_entree_ets) ? + 0 = non + 1 = oui + nombre_fin_contrat: + type: numeric(5,0) + comment: | + Nombre de fin de contrat. + 0 si contrat ne se termine pas sur le mois ou hors période = 1 + 1 si contrat terminé sur le mois + nombre_heures: + type: numeric + nombre_transformation_cdi: + type: numeric(5,0) + comment: | + Nombre de transformation d''un CDD (ou autre hors CDI) en CDI. + 0 si pas de transformation + 1 si transformation + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_contrats_mois'::regclass)" + pole_id: + type: bigint + default: "0" + population_id: + type: 'bigint[]' + present_debut_mois: + type: numeric + default: "0" + comment: | + Le contrat couvre-t-il le 1er du mois ? + 0 = non + 1 = oui + present_fin_mois: + type: numeric(5,0) + default: "0" + comment: | + Le contrat couvre-t-il le dernier jour du mois ? + 0 = non + 1 = oui + profil_id: + type: bigint + ratio_temps_travail: + type: numeric + salarie_id: + type: bigint +constraints: + p_contrats_mois_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_contrats_mois_1: + column: contrat_id + method: btree + i_contrats_mois_2: + column: date_fin + method: btree + i_contrats_mois_4: + column: age_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_croisement_paie_planning.yaml b/db/schema2/tables/p_croisement_paie_planning.yaml new file mode 100644 index 0000000..6339626 --- /dev/null +++ b/db/schema2/tables/p_croisement_paie_planning.yaml @@ -0,0 +1,106 @@ +columns: + contrat_mois_id: + type: bigint + date: + type: date + etablissement_id: + type: bigint + heur_cont_pror_temp_du: + type: numeric + heur_cont_pror_temp_du_init: + type: numeric + heur_cont_pror_temp_vali: + type: numeric + heur_paye_pror_temp_du: + type: numeric + heur_paye_pror_temp_du_init: + type: numeric + heur_paye_pror_temp_vali: + type: numeric + heur_trav_pror_temp_du: + type: numeric + heur_trav_pror_temp_du_init: + type: numeric + heur_trav_pror_temp_vali: + type: numeric + mois_paie: + type: integer + mont_brut_pror_temp_du: + type: numeric + mont_brut_pror_temp_du_init: + type: numeric + mont_brut_pror_temp_vali: + type: numeric + mont_coti_patr_pror_temp_du: + type: numeric + mont_coti_patr_pror_temp_du_init: + type: numeric + mont_coti_patr_pror_temp_vali: + type: numeric + mont_inte_pror_temp_du: + type: numeric + mont_inte_pror_temp_du_init: + type: numeric + mont_inte_pror_temp_vali: + type: numeric + mont_mass_sala_inte_pror_temp_du: + type: numeric + mont_mass_sala_inte_pror_temp_du_init: + type: numeric + mont_mass_sala_inte_pror_temp_vali: + type: numeric + mont_mass_sala_pror_temp_du: + type: numeric + mont_mass_sala_pror_temp_du_init: + type: numeric + mont_mass_sala_pror_temp_vali: + type: numeric + mont_mass_sala_prov_inte_pror_temp_du: + type: numeric + mont_mass_sala_prov_inte_pror_temp_du_init: + type: numeric + mont_mass_sala_prov_inte_pror_temp_vali: + type: numeric + mont_mass_sala_prov_pror_temp_du: + type: numeric + mont_mass_sala_prov_pror_temp_du_init: + type: numeric + mont_mass_sala_prov_pror_temp_vali: + type: numeric + mont_prov_pror_temp_du: + type: numeric + mont_prov_pror_temp_du_init: + type: numeric + mont_prov_pror_temp_vali: + type: numeric + planning_id: + type: bigint + presence_detail: + type: text + salarie_id: + type: bigint + temps_du: + type: numeric + temps_du_initial: + type: numeric + temps_valide: + type: numeric +indexes: + i_croisement_paie_planning_1: + column: planning_id + method: btree + i_croisement_paie_planning_2: + column: salarie_id + method: btree + i_croisement_paie_planning_3: + column: date + method: btree + i_croisement_paie_planning_4: + column: mois_paie + method: btree + i_croisement_paie_planning_5: + column: etablissement_id + method: btree + i_croisement_paie_planning_6: + column: contrat_mois_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_expert_controle.yaml b/db/schema2/tables/p_expert_controle.yaml new file mode 100644 index 0000000..a3e2fa4 --- /dev/null +++ b/db/schema2/tables/p_expert_controle.yaml @@ -0,0 +1,45 @@ +columns: + arret_travail_id: + type: bigint + borne_alerte: + type: numeric + default: "0" + code_groupe: + type: text + default: "''::text" + code_justificatif: + type: text + default: "''::text" + coefficient_attendu: + type: numeric + default: "0" + contrat_mois_id: + type: bigint + controle_id: + type: bigint + default: "0" + cumul_attendu: + type: numeric + default: "0" + cumul_base: + type: numeric + default: "0" + cumul_realise: + type: numeric + default: "0" + date_correction: + type: date + default: "'2099-12-31'::date" + date_donnee: + type: date + date_signalement: + type: date + etat: + type: text + default: "''::text" + historique_paie_id: + type: bigint + numero_editeur: + type: bigint + salarie_id: + type: bigint \ No newline at end of file diff --git a/db/schema2/tables/p_expert_controle_data.yaml b/db/schema2/tables/p_expert_controle_data.yaml new file mode 100644 index 0000000..d18929b --- /dev/null +++ b/db/schema2/tables/p_expert_controle_data.yaml @@ -0,0 +1,64 @@ +columns: + contrat_mois_data: + type: 'text[]' + comment: "[1]: date_debut_contrat_mois, [2]: date_fin_contrat_mois, [3]: numero_contrat" + data_code_original: + type: text + default: "''::text" + data_id: + type: bigint + default: "0" + data_type: + type: text + default: "''::text" + date_correction: + type: date + default: "'2099-12-31'::date" + date_evenement: + type: date + date_item: + type: date + date_signalement: + type: date + etat: + type: text + default: "''::text" + comment: "''''=Atypie signalée, ''I''=Ignoré, ''T''=Traité" + expert_controle_data_id: + type: bigint + default: "0" + expert_controle_id: + type: bigint + default: "0" + nb_cloture: + type: numeric + default: "0" + nb_cree: + type: numeric + default: "0" + nb_portee: + type: numeric + default: "0" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_expert_controle_data'::regclass)" + texte: + type: text + default: "''::text" +indexes: + i_expert_controle_data_data_id: + column: data_id + method: btree + i_expert_controle_data_date_correction: + column: date_correction + method: btree + i_expert_controle_data_date_signalement: + column: date_signalement + method: btree + i_expert_controle_data_etat: + column: etat + method: btree + i_expert_controle_data_expert_controle_id: + column: expert_controle_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_formations.yaml b/db/schema2/tables/p_formations.yaml new file mode 100644 index 0000000..6c41ee8 --- /dev/null +++ b/db/schema2/tables/p_formations.yaml @@ -0,0 +1,42 @@ +columns: + contrat_id: + type: bigint + contrat_mois_id: + type: bigint + formation_date: + type: date + formation_id: + type: bigint + mois_activite: + type: numeric(6,0) + nb_heures: + type: numeric(6,2) + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_formations'::regclass)" + organisateur: + type: text + default: "''::character varying" + salarie_id: + type: bigint +constraints: + p_formations_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_formations_1: + column: salarie_id + method: btree + i_formations_2: + column: contrat_id + method: btree + i_formations_3: + column: formation_id + method: btree + i_formations_4: + column: formation_date + method: btree + i_formations_5: + column: contrat_mois_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_handicap.yaml b/db/schema2/tables/p_handicap.yaml new file mode 100644 index 0000000..c010ed4 --- /dev/null +++ b/db/schema2/tables/p_handicap.yaml @@ -0,0 +1,64 @@ +columns: + annee_embauche: + type: numeric(4,0) + comment: Année d embauche valable pour les 3 dernières unités + annee_form_prof: + type: numeric(4,0) + assimile_mutile_guerre: + type: character(1) + beneficiaire_aah: + type: character(1) + carte_invalidite: + type: character(1) + categorie_cotorep: + type: character(1) + code_protection: + type: character(2) + date_echeance: + type: date + date_effet: + type: date + emb_1er_handicap: + type: character(1) + comment: Unité + emb_chom_long: + type: character(1) + comment: Unité 1 embauche handicapé chômeur longue durée + emb_ea_cdtd_esat: + type: character(1) + comment: Unité 1 embauche handicapé sorti EA CDTD ESAT + form_prof_500h: + type: character(1) + invalide_pensionne: + type: character(1) + lourd_handicap: + type: character(1) + comment: Unité 1 reconnu lourdeur handicap + maladie_p_at: + type: character(1) + mutile_guerre: + type: character(1) + nature_contrat: + type: character(1) + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_handicap'::regclass)" + placement_anterieur: + type: character(1) + pompier_volontaire: + type: character(1) + rqth: + type: character(1) + salarie_id: + type: bigint + taux_incapacite: + type: character varying(6) + default: "''::character varying" + taux_ipp: + type: numeric(5,2) + type_handicap: + type: character(1) + unite_age_26_51: + type: character(1) + comment: 'Unité 0,5 sal= ou>51 ou <26 ans' \ No newline at end of file diff --git a/db/schema2/tables/p_handicap2.yaml b/db/schema2/tables/p_handicap2.yaml new file mode 100644 index 0000000..517f5ed --- /dev/null +++ b/db/schema2/tables/p_handicap2.yaml @@ -0,0 +1,29 @@ +columns: + cat_invalide_pension: + type: character varying(2) + deb_pension: + type: date + deb_validite: + type: date + decision: + type: date + fin_validite: + type: date + lib_boeth: + type: text + lib_reco: + type: text + lourd_handicap: + type: text + placement_anterieur: + type: character(1) + salarie_id: + type: bigint + statut_boeth: + type: character varying(2) + taux_incapacite: + type: numeric(5,2) + taux_ipp: + type: numeric(5,2) + type_reco: + type: character varying(2) \ No newline at end of file diff --git a/db/schema2/tables/p_historique_paie.yaml b/db/schema2/tables/p_historique_paie.yaml new file mode 100644 index 0000000..8cf2010 --- /dev/null +++ b/db/schema2/tables/p_historique_paie.yaml @@ -0,0 +1,132 @@ +columns: + age_id: + type: bigint + base: + type: numeric(11,2) + code_original: + type: text + compte_id: + type: bigint + default: "0" + contrat_id: + type: bigint + contrat_mois_id: + type: bigint + date_debut: + type: date + date_fin: + type: date + date_paie: + type: date + etablissement_id: + type: bigint + heure_contrat: + type: numeric + heure_payee: + type: numeric + heure_travaillee: + type: numeric + mois_activite: + type: numeric(6,0) + mois_paie: + type: numeric(6,0) + montant_avantage_nature: + type: numeric(11,2) + montant_brut: + type: numeric(11,2) + montant_brut_mensuel_moyen: + type: numeric(11,2) + montant_brut_annuel: + type: numeric(11,2) + montant_cotisation_patronale: + type: numeric(11,2) + montant_cotisation_salarie: + type: numeric(11,2) + montant_frais_imposables: + type: numeric(11,2) + montant_masse_salariale: + type: numeric(11,2) + montant_masse_salariale_provisionnee: + type: numeric(11,2) + montant_net_a_payer_salarie: + type: numeric(11,2) + montant_net_imposable_salarie: + type: numeric(11,2) + montant_od_net_patronale: + type: numeric(11,2) + default: "0" + montant_od_net_salarie: + type: numeric(11,2) + montant_patronal: + type: numeric + montant_provisions: + type: numeric(11,2) + montant_salarial: + type: numeric + nombre: + type: numeric + nombre_provisions: + type: numeric(11,2) + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_historique_paie'::regclass)" + organisme_cotisation_id: + type: bigint + profil_id: + type: bigint + comment: @deprecated + rubrique_id: + type: bigint + salarie_id: + type: bigint + taux_cotisation_patronale: + type: numeric + taux_cotisation_salarie: + type: numeric + ventilation_1_id: + type: bigint + default: "0" + ventilation_2_id: + type: bigint + default: "0" + ventilation_3_id: + type: bigint + default: "0" +indexes: + i_historique_paie_1: + column: contrat_id + method: btree + i_historique_paie_2: + column: mois_activite + method: btree + i_historique_paie_3: + column: mois_paie + method: btree + i_historique_paie_4: + column: rubrique_id + method: btree + i_historique_paie_5: + column: organisme_cotisation_id + method: btree + i_historique_paie_6: + column: date_paie + method: btree + i_historique_paie_7: + column: age_id + method: btree + i_historique_paie_8: + column: contrat_mois_id + method: btree + i_historique_paie_9: + column: salarie_id + method: btree + i_historique_paie_ventilation_1_id: + column: ventilation_1_id + method: btree + i_historique_paie_ventilation_2_id: + column: ventilation_2_id + method: btree + i_historique_paie_ventilation_3_id: + column: ventilation_3_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_indicateur_externe.yaml b/db/schema2/tables/p_indicateur_externe.yaml new file mode 100644 index 0000000..d584b49 --- /dev/null +++ b/db/schema2/tables/p_indicateur_externe.yaml @@ -0,0 +1,24 @@ +columns: + date_reference: + type: date + finess_id: + type: bigint + default: "0" + import_id: + type: bigint + indicateur_code: + type: text + oid: + type: bigint + default: "nextval('s_indicateur_externe'::regclass)" + pole_id: + type: bigint + default: "0" + qualification_id: + type: bigint + default: "0" + service_id: + type: bigint + default: "0" + value: + type: numeric \ No newline at end of file diff --git a/db/schema2/tables/p_indicateurs_cumules.yaml b/db/schema2/tables/p_indicateurs_cumules.yaml new file mode 100644 index 0000000..ad0f45b --- /dev/null +++ b/db/schema2/tables/p_indicateurs_cumules.yaml @@ -0,0 +1,40 @@ +columns: + date_reference: + type: date + finess_id: + type: bigint + default: "0" + indicateur_condition_id: + type: 'bigint[]' + indicateur_id: + type: bigint + periode_type: + type: text + pole_id: + type: bigint + default: "0" + population_id: + type: bigint + default: "0" + value: + type: numeric + value_cum: + type: numeric + value_cum12: + type: numeric + value_cum4t: + type: numeric + default: "0" + value_exercice: + type: numeric + default: "0" + value_trimestre: + type: numeric + default: "0" +indexes: + i_indicateurs_cumules_1: + column: indicateur_id + method: btree + i_indicateurs_cumules_2: + column: date_reference + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_oids.yaml b/db/schema2/tables/p_oids.yaml new file mode 100644 index 0000000..0371279 --- /dev/null +++ b/db/schema2/tables/p_oids.yaml @@ -0,0 +1,24 @@ +columns: + code: + type: character varying(10) + not_null: NOT NULL + default: "''::character varying" + code_table: + type: character varying(255) + oid: + type: bigint + default: "0" +constraints: + p_oids_code_table_key: + type: UNIQUE + column: code, code_table, oid +indexes: + i_oids_1: + column: code_table + method: btree + i_oids_2: + column: oid + method: btree + i_oids_3: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_personne.yaml b/db/schema2/tables/p_personne.yaml new file mode 100644 index 0000000..f6cbd31 --- /dev/null +++ b/db/schema2/tables/p_personne.yaml @@ -0,0 +1,38 @@ +columns: + cle_interne: + type: text + date_naissance: + type: date + matricule_courant: + type: text + nom: + type: text + nom_naissance: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_personne'::regclass)" + prenom: + type: character varying(255) + default: "''::character varying" + salarie_array_id: + type: 'bigint[]' + salarie_courant_id: + type: bigint + sexe: + type: text +constraints: + p_personne_pkey: + type: PRIMARY KEY + column: oid + p_personne_ukey: + type: UNIQUE + column: cle_interne +indexes: + i_personne_cle_interne_nom: + column: cle_interne + method: btree + i_personne_salarie_courant_id: + column: salarie_courant_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_planning_mouvement.yaml b/db/schema2/tables/p_planning_mouvement.yaml new file mode 100644 index 0000000..b37f2fd --- /dev/null +++ b/db/schema2/tables/p_planning_mouvement.yaml @@ -0,0 +1,89 @@ +columns: + absence_id: + type: bigint + absence_nb_jours: + type: numeric + code_horaire_id: + type: bigint + default: "0" + contrat_id: + type: bigint + contrat_mois_id: + type: bigint + date: + type: date + etablissement_id: + type: bigint + mois: + type: numeric + niveau_id: + type: bigint + comment: "Correspond au niveau 3 d''Octime (le plus fin)." + oid: + type: bigint + default: "nextval('s_planning_mouvement'::regclass)" + pole_id: + type: bigint + default: "0" + qualification_id: + type: bigint + salarie_id: + type: bigint + semaine: + type: numeric + service_id: + type: bigint + temps_absence: + type: numeric + temps_absence_ajuste: + type: numeric + default: "0" + temps_du: + type: numeric + temps_du_ajuste: + type: numeric + default: "0" + temps_du_initial: + type: numeric + temps_hc: + type: numeric + comment: Heures complémentaires. + temps_hs: + type: numeric + comment: Heures supplémentaires. + temps_presence: + type: numeric + temps_presence_ajuste: + type: numeric + temps_valide: + type: numeric + temps_valide_ajuste: + type: numeric + default: "0" + type_absence_id: + type: bigint +indexes: + i_planning_mouvement_1: + column: salarie_id + method: btree + i_planning_mouvement_2: + column: date + method: btree + i_planning_mouvement_3: + column: contrat_id + method: btree + i_planning_mouvement_4: + column: contrat_mois_id + method: btree + i_planning_mouvement_5: + column: service_id + method: btree + i_planning_mouvement_6: + column: qualification_id + method: btree + i_planning_mouvement_7: + column: type_absence_id + method: btree + i_planning_mouvement_8: + column: code_horaire_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_presence_salaries.yaml b/db/schema2/tables/p_presence_salaries.yaml new file mode 100644 index 0000000..822f03d --- /dev/null +++ b/db/schema2/tables/p_presence_salaries.yaml @@ -0,0 +1,15 @@ +columns: + est_interimaire: + type: boolean + etablissement_id: + type: bigint + mois_paie: + type: integer + presence_contrat: + type: boolean + present_paie: + type: boolean + present_planning: + type: boolean + salarie_id: + type: bigint \ No newline at end of file diff --git a/db/schema2/tables/p_profil_contrat_mois.yaml b/db/schema2/tables/p_profil_contrat_mois.yaml new file mode 100644 index 0000000..885ae5f --- /dev/null +++ b/db/schema2/tables/p_profil_contrat_mois.yaml @@ -0,0 +1,46 @@ +comment: Associe un ou plusieurs profils à un contrat (ventilé sur un mois donné) selon un pourcentage. +columns: + budget_cle_id: + type: bigint + default: "0" + contrat_mois_id: + type: bigint + not_null: NOT NULL + mois: + type: numeric(6,0) + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_profil_contrat_mois'::regclass)" + pole_id: + type: bigint + default: "0" + population_id: + type: 'bigint[]' + profil_avant_transformation_id: + type: bigint + default: "0" + profil_id: + type: bigint + not_null: NOT NULL + ratio: + type: numeric + salarie_id: + type: bigint +constraints: + p_profil_contrat_mois_pkey: + type: PRIMARY KEY + column: contrat_mois_id, profil_id +indexes: + i_profil_contrat_mois_1: + column: contrat_mois_id + method: btree + i_profil_contrat_mois_2: + column: profil_id + method: btree + i_profil_contrat_mois_3: + column: profil_avant_transformation_id + method: btree + i_profil_contrat_mois_4: + column: pole_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_profils.yaml b/db/schema2/tables/p_profils.yaml new file mode 100644 index 0000000..c0af768 --- /dev/null +++ b/db/schema2/tables/p_profils.yaml @@ -0,0 +1,435 @@ +columns: + cadre_emploi_code: + type: text + cadre_emploi_code_original: + type: text + cadre_emploi_id: + type: bigint + cadre_emploi_section_code: + type: 'text[]' + cadre_emploi_section_id: + type: 'bigint[]' + cadre_emploi_section_texte: + type: 'text[]' + cadre_emploi_texte: + type: text + categorie_conge_code: + type: text + categorie_conge_code_original: + type: text + categorie_conge_id: + type: bigint + categorie_conge_section_code: + type: 'text[]' + categorie_conge_section_id: + type: 'bigint[]' + categorie_conge_section_texte: + type: 'text[]' + categorie_conge_texte: + type: text + categorie_socio_professionnelle_code: + type: text + categorie_socio_professionnelle_code_original: + type: text + categorie_socio_professionnelle_id: + type: bigint + categorie_socio_professionnelle_section_code: + type: 'text[]' + categorie_socio_professionnelle_section_id: + type: 'bigint[]' + categorie_socio_professionnelle_section_texte: + type: 'text[]' + categorie_socio_professionnelle_texte: + type: text + categorie_statutaire_code: + type: text + categorie_statutaire_code_original: + type: text + categorie_statutaire_id: + type: bigint + categorie_statutaire_section_code: + type: 'text[]' + categorie_statutaire_section_id: + type: 'bigint[]' + categorie_statutaire_section_texte: + type: 'text[]' + categorie_statutaire_texte: + type: text + code_emploi_code: + type: text + code_emploi_code_original: + type: text + code_emploi_id: + type: bigint + code_emploi_section_code: + type: 'text[]' + code_emploi_section_id: + type: 'bigint[]' + code_emploi_section_texte: + type: 'text[]' + code_emploi_texte: + type: text + commission_paritaire_code: + type: text + commission_paritaire_code_original: + type: text + commission_paritaire_id: + type: bigint + commission_paritaire_section_code: + type: 'text[]' + commission_paritaire_section_id: + type: 'bigint[]' + commission_paritaire_section_texte: + type: 'text[]' + commission_paritaire_texte: + type: text + compte_salarie_code: + type: text + compte_salarie_code_original: + type: text + compte_salarie_id: + type: bigint + compte_salarie_section_code: + type: 'text[]' + compte_salarie_section_id: + type: 'bigint[]' + compte_salarie_section_texte: + type: 'text[]' + compte_salarie_texte: + type: text + filiere_code: + type: text + filiere_code_original: + type: text + filiere_id: + type: bigint + filiere_section_code: + type: 'text[]' + filiere_section_id: + type: 'bigint[]' + filiere_section_texte: + type: 'text[]' + filiere_texte: + type: text + grille_code: + type: text + grille_code_original: + type: text + grille_groupe_code: + type: text + grille_groupe_code_original: + type: text + grille_groupe_id: + type: bigint + grille_groupe_section_code: + type: 'text[]' + grille_groupe_section_id: + type: 'bigint[]' + grille_groupe_section_texte: + type: 'text[]' + grille_groupe_texte: + type: text + grille_id: + type: bigint + grille_section_code: + type: 'text[]' + grille_section_id: + type: 'bigint[]' + grille_section_texte: + type: 'text[]' + grille_texte: + type: text + groupe_cotisant_code: + type: text + groupe_cotisant_code_original: + type: text + groupe_cotisant_id: + type: bigint + groupe_cotisant_section_code: + type: 'text[]' + groupe_cotisant_section_id: + type: 'bigint[]' + groupe_cotisant_section_texte: + type: 'text[]' + groupe_cotisant_texte: + type: text + lettre_budgetaire_code: + type: text + lettre_budgetaire_code_original: + type: text + lettre_budgetaire_id: + type: bigint + lettre_budgetaire_section_code: + type: 'text[]' + lettre_budgetaire_section_id: + type: 'bigint[]' + lettre_budgetaire_section_texte: + type: 'text[]' + lettre_budgetaire_texte: + type: text + motif_debut_code: + type: text + motif_debut_code_original: + type: text + motif_debut_id: + type: bigint + motif_debut_section_code: + type: 'text[]' + motif_debut_section_id: + type: 'bigint[]' + motif_debut_section_texte: + type: 'text[]' + motif_debut_texte: + type: text + motif_fin_code: + type: text + motif_fin_code_original: + type: text + motif_fin_id: + type: bigint + motif_fin_section_code: + type: 'text[]' + motif_fin_section_id: + type: 'bigint[]' + motif_fin_section_texte: + type: 'text[]' + motif_fin_texte: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_profils'::regclass)" + qualification_code: + type: text + qualification_code_original: + type: text + qualification_id: + type: bigint + qualification_section_code: + type: 'text[]' + qualification_section_id: + type: 'bigint[]' + qualification_section_texte: + type: 'text[]' + qualification_texte: + type: text + section_analytique_code: + type: text + section_analytique_code_original: + type: text + section_analytique_id: + type: bigint + section_analytique_paie_code: + type: text + section_analytique_paie_code_original: + type: text + section_analytique_paie_id: + type: bigint + section_analytique_paie_section_code: + type: 'text[]' + section_analytique_paie_section_id: + type: 'bigint[]' + section_analytique_paie_section_texte: + type: 'text[]' + section_analytique_paie_texte: + type: text + section_analytique_section_code: + type: 'text[]' + section_analytique_section_id: + type: 'bigint[]' + section_analytique_section_texte: + type: 'text[]' + section_analytique_texte: + type: text + service_code: + type: text + service_code_original: + type: text + service_id: + type: bigint + service_section_code: + type: 'text[]' + service_section_id: + type: 'bigint[]' + service_section_texte: + type: 'text[]' + service_texte: + type: text + societe_interim_code: + type: text + societe_interim_code_original: + type: text + societe_interim_id: + type: bigint + societe_interim_section_code: + type: 'text[]' + societe_interim_section_id: + type: 'bigint[]' + societe_interim_section_texte: + type: 'text[]' + societe_interim_texte: + type: text + specialite_code: + type: text + specialite_code_original: + type: text + specialite_id: + type: bigint + specialite_section_code: + type: 'text[]' + specialite_section_id: + type: 'bigint[]' + specialite_section_texte: + type: 'text[]' + specialite_texte: + type: text + statut_code: + type: text + statut_code_original: + type: text + statut_id: + type: bigint + statut_section_code: + type: 'text[]' + statut_section_id: + type: 'bigint[]' + statut_section_texte: + type: 'text[]' + statut_texte: + type: text + type_contrat_code: + type: text + type_contrat_code_original: + type: text + type_contrat_id: + type: bigint + type_contrat_section_code: + type: 'text[]' + type_contrat_section_id: + type: 'bigint[]' + type_contrat_section_texte: + type: 'text[]' + type_contrat_texte: + type: text + type_horaire_code: + type: text + type_horaire_code_original: + type: text + type_horaire_id: + type: bigint + type_horaire_section_code: + type: 'text[]' + type_horaire_section_id: + type: 'bigint[]' + type_horaire_section_texte: + type: 'text[]' + type_horaire_texte: + type: text + type_temps_travail_code: + type: text + type_temps_travail_code_original: + type: text + type_temps_travail_id: + type: bigint + type_temps_travail_section_code: + type: 'text[]' + type_temps_travail_section_id: + type: 'bigint[]' + type_temps_travail_section_texte: + type: 'text[]' + type_temps_travail_texte: + type: text + unite_fonctionnelle_code: + type: text + unite_fonctionnelle_code_original: + type: text + unite_fonctionnelle_id: + type: bigint + unite_fonctionnelle_section_code: + type: 'text[]' + unite_fonctionnelle_section_id: + type: 'bigint[]' + unite_fonctionnelle_section_texte: + type: 'text[]' + unite_fonctionnelle_texte: + type: text +constraints: + p_profils_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_profils_1: + column: unite_fonctionnelle_id + method: btree + i_profils_10: + column: categorie_socio_professionnelle_id + method: btree + i_profils_11: + column: statut_id + method: btree + i_profils_12: + column: code_emploi_id + method: btree + i_profils_13: + column: societe_interim_id + method: btree + i_profils_14: + column: section_analytique_paie_id + method: btree + i_profils_15: + column: section_analytique_id + method: btree + i_profils_16: + column: grille_id + method: btree + i_profils_17: + column: grille_groupe_id + method: btree + i_profils_18: + column: commission_paritaire_id + method: btree + i_profils_19: + column: compte_salarie_id + method: btree + i_profils_2: + column: lettre_budgetaire_id + method: btree + i_profils_20: + column: categorie_conge_id + method: btree + i_profils_21: + column: filiere_id + method: btree + i_profils_22: + column: cadre_emploi_id + method: btree + i_profils_23: + column: categorie_statutaire_id + method: btree + i_profils_24: + column: type_horaire_id + method: btree + i_profils_25: + column: groupe_cotisant_id + method: btree + i_profils_3: + column: type_contrat_id + method: btree + i_profils_4: + column: motif_debut_id + method: btree + i_profils_5: + column: motif_fin_id + method: btree + i_profils_6: + column: qualification_id + method: btree + i_profils_7: + column: service_id + method: btree + i_profils_8: + column: specialite_id + method: btree + i_profils_9: + column: type_temps_travail_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_sae_contrats.yaml b/db/schema2/tables/p_sae_contrats.yaml new file mode 100644 index 0000000..b329942 --- /dev/null +++ b/db/schema2/tables/p_sae_contrats.yaml @@ -0,0 +1,19 @@ +columns: + annee: + type: numeric + contrat_code: + type: text + contrat_id: + type: bigint + filiere_texte: + type: text + groupe_discipline_texte: + type: text + mois_activite_debut_id: + type: bigint + mois_activite_fin_id: + type: bigint + qualification_texte: + type: text + salarie_id: + type: bigint \ No newline at end of file diff --git a/db/schema2/tables/p_salaries.yaml b/db/schema2/tables/p_salaries.yaml new file mode 100644 index 0000000..c57692f --- /dev/null +++ b/db/schema2/tables/p_salaries.yaml @@ -0,0 +1,104 @@ +columns: + adresse1: + type: text + adresse2: + type: text + code: + type: text + code_cotisation_id: + type: bigint + default: "0" + code_original: + type: text + not_null: NOT NULL + code_postal_id: + type: bigint + date_anciennete: + type: date + date_debut: + type: date + comment: Date de début du dernier contrat + date_entree_ets: + type: date + comment: "Date d''entrée dans l''établissement." + date_entree_fp: + type: date + comment: "Date d''entrée dans la fonction publique." + date_entree_fph: + type: date + comment: "Date d''entrée dans la fonction publique hospitaliere." + date_fin: + type: date + comment: Date de fin du dernier contrat + date_naissance: + type: date + date_sortie_ets: + type: date + comment: "Date de sortie de l''établissement." + entreprise_id: + type: bigint + finess: + type: character(9) + default: "''::bpchar" + matricule: + type: text + matricule_planning: + type: text + matricule_retraite: + type: text + nationalite_id: + type: bigint + nir: + type: text + no_adeli: + type: text + comment: Numéro ADELI lorsque médecin. + nom: + type: character varying(255) + default: "''::character varying" + nom_naissance: + type: character varying(255) + default: "''::character varying" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_salaries'::regclass)" + personne_id: + type: bigint + not_null: NOT NULL + default: "0" + prenom: + type: character varying(255) + default: "''::character varying" + profil_id: + type: bigint + salarie_fusionne_id: + type: bigint + default: "0" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + sexe: + type: character(1) + situation_famille_id: + type: bigint +constraints: + p_salaries_pkey: + type: PRIMARY KEY + column: oid + p_salaries_ukey: + type: UNIQUE + column: code_original +indexes: + i_salaries_1: + column: nationalite_id + method: btree + i_salaries_2: + column: entreprise_id + method: btree + i_salaries_3: + column: code_postal_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_sommes_mensuelles_ventilees_paie.yaml b/db/schema2/tables/p_sommes_mensuelles_ventilees_paie.yaml new file mode 100644 index 0000000..2ec8fc0 --- /dev/null +++ b/db/schema2/tables/p_sommes_mensuelles_ventilees_paie.yaml @@ -0,0 +1,37 @@ +columns: + equivalent_temps_plein: + type: numeric + etablissement_id: + type: bigint + heure_contrat: + type: numeric + heure_payee: + type: numeric + heure_travaillee: + type: numeric + mois_paie: + type: numeric(6,0) + montant_brut: + type: numeric + montant_cotisation_patronale: + type: numeric + montant_masse_salariale: + type: numeric + montant_masse_salariale_provisionnee: + type: numeric + montant_provisions: + type: numeric + paie_qualification_code: + type: text + paie_qualification_id: + type: bigint + paie_qualification_texte: + type: text + paie_service_code: + type: text + paie_service_id: + type: bigint + paie_service_texte: + type: text + salarie_id: + type: bigint \ No newline at end of file diff --git a/db/schema2/tables/p_sommes_mensuelles_ventilees_planning.yaml b/db/schema2/tables/p_sommes_mensuelles_ventilees_planning.yaml new file mode 100644 index 0000000..496b44c --- /dev/null +++ b/db/schema2/tables/p_sommes_mensuelles_ventilees_planning.yaml @@ -0,0 +1,25 @@ +columns: + etablissement_id: + type: bigint + mois_paie: + type: integer + planning_qualification_code: + type: character varying(30) + planning_qualification_id: + type: bigint + planning_qualification_texte: + type: character varying(255) + planning_service_code: + type: character varying(30) + planning_service_id: + type: bigint + planning_service_texte: + type: character varying(255) + salarie_id: + type: bigint + temps_du: + type: numeric + temps_du_initial: + type: numeric + temps_valide: + type: numeric \ No newline at end of file diff --git a/db/schema2/tables/p_taux_horaires_mensuels.yaml b/db/schema2/tables/p_taux_horaires_mensuels.yaml new file mode 100644 index 0000000..f60935a --- /dev/null +++ b/db/schema2/tables/p_taux_horaires_mensuels.yaml @@ -0,0 +1,85 @@ +columns: + equivalent_temps_plein: + type: numeric + etablissement_id: + type: bigint + heure_contrat: + type: numeric + heure_payee: + type: numeric + heure_travaillee: + type: numeric + mois_paie: + type: integer + montant_brut: + type: numeric + montant_cotisation_patronale: + type: numeric + montant_masse_salariale: + type: numeric + montant_masse_salariale_provisionnee: + type: numeric + montant_provisions: + type: numeric + salarie_id: + type: bigint + taux_horaire_equivalent_temps_plein_temps_du: + type: numeric + taux_horaire_equivalent_temps_plein_temps_du_initial: + type: numeric + taux_horaire_equivalent_temps_plein_temps_valide: + type: numeric + taux_horaire_heure_contrat_temps_du: + type: numeric + taux_horaire_heure_contrat_temps_du_initial: + type: numeric + taux_horaire_heure_contrat_temps_valide: + type: numeric + taux_horaire_heure_payee_temps_du: + type: numeric + taux_horaire_heure_payee_temps_du_initial: + type: numeric + taux_horaire_heure_payee_temps_valide: + type: numeric + taux_horaire_heure_travaillee_temps_du: + type: numeric + taux_horaire_heure_travaillee_temps_du_initial: + type: numeric + taux_horaire_heure_travaillee_temps_valide: + type: numeric + taux_horaire_montant_brut_temps_du: + type: numeric + taux_horaire_montant_brut_temps_du_initial: + type: numeric + taux_horaire_montant_brut_temps_valide: + type: numeric + taux_horaire_montant_cotisation_patronale_temps_du: + type: numeric + taux_horaire_montant_cotisation_patronale_temps_du_initial: + type: numeric + taux_horaire_montant_cotisation_patronale_temps_valide: + type: numeric + taux_horaire_montant_masse_salariale_provisionnee_temps_du: + type: numeric + taux_horaire_montant_masse_salariale_provisionnee_temps_du_init: + type: numeric + taux_horaire_montant_masse_salariale_provisionnee_temps_valide: + type: numeric + taux_horaire_montant_masse_salariale_temps_du: + type: numeric + taux_horaire_montant_masse_salariale_temps_du_initial: + type: numeric + taux_horaire_montant_masse_salariale_temps_valide: + type: numeric + taux_horaire_montant_provisions_temps_du: + type: numeric + taux_horaire_montant_provisions_temps_du_initial: + type: numeric + taux_horaire_montant_provisions_temps_valide: + type: numeric + temps_du: + type: numeric + temps_du_initial: + type: numeric + temps_valide: + type: numeric \ No newline at end of file diff --git a/db/schema2/tables/p_ventilation.yaml b/db/schema2/tables/p_ventilation.yaml new file mode 100644 index 0000000..e308b4d --- /dev/null +++ b/db/schema2/tables/p_ventilation.yaml @@ -0,0 +1,12 @@ +comment: Contient les différents modèles de ventilation pour un plan analytique donné. +columns: + code: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_ventilation'::regclass)" + plan_analytique_id: + type: bigint + texte: + type: text \ No newline at end of file diff --git a/db/schema2/tables/p_ventilation_capsante.yaml b/db/schema2/tables/p_ventilation_capsante.yaml new file mode 100644 index 0000000..dbe2335 --- /dev/null +++ b/db/schema2/tables/p_ventilation_capsante.yaml @@ -0,0 +1,21 @@ +columns: + etablissement_id: + type: bigint + mois_paie: + type: numeric + ratio: + type: integer + salarie_id: + type: bigint + updated_at: + type: timestamp with time zone + user_modified: + type: boolean +constraints: + p_ventilation_capsante_ukey: + type: UNIQUE + column: etablissement_id, mois_paie, salarie_id +indexes: + i_ventilation_capsante_1: + column: mois_paie, salarie_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_ventilation_section.yaml b/db/schema2/tables/p_ventilation_section.yaml new file mode 100644 index 0000000..64c32f1 --- /dev/null +++ b/db/schema2/tables/p_ventilation_section.yaml @@ -0,0 +1,32 @@ +comment: | + Ventilation par section analytique avec ratio pour chaque modèle de ventilation. + Les code et texte de la section sont remontés dans cette table pour des raisons de #performances. +columns: + ratio: + type: numeric + section_analytique_code: + type: text + comment: '#performance' + section_analytique_id: + type: bigint + section_analytique_section_code: + type: 'text[]' + comment: '#performance' + section_analytique_section_id: + type: 'bigint[]' + comment: '#performance' + section_analytique_section_texte: + type: 'text[]' + comment: '#performance' + section_analytique_texte: + type: text + comment: '#performance' + ventilation_id: + type: bigint +indexes: + i_ventilation_section_1: + column: ventilation_id + method: btree + i_ventilation_section_2: + column: section_analytique_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/p_visites_medicales.yaml b/db/schema2/tables/p_visites_medicales.yaml new file mode 100644 index 0000000..a2bdf3b --- /dev/null +++ b/db/schema2/tables/p_visites_medicales.yaml @@ -0,0 +1,33 @@ +columns: + contrat_id: + type: bigint + contrat_mois_id: + type: bigint + date: + type: date + mois_activite: + type: numeric(6,0) + motif_visite_id: + type: bigint + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_visites_medicales'::regclass)" + salarie_id: + type: bigint +indexes: + i_visites_medicales_1: + column: contrat_id + method: btree + i_visites_medicales_2: + column: mois_activite + method: btree + i_visites_medicales_4: + column: motif_visite_id + method: btree + i_visites_medicales_5: + column: date + method: btree + i_visites_medicales_9: + column: salarie_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_accident_circonstance.yaml b/db/schema2/tables/t_accident_circonstance.yaml new file mode 100644 index 0000000..2bb70a5 --- /dev/null +++ b/db/schema2/tables/t_accident_circonstance.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_accident_circonstance'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_accident_circonstance_pkey: + type: PRIMARY KEY + column: oid + t_accident_circonstance_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_accident_lieu.yaml b/db/schema2/tables/t_accident_lieu.yaml new file mode 100644 index 0000000..32f0b05 --- /dev/null +++ b/db/schema2/tables/t_accident_lieu.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_accident_lieu'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_accident_lieu_pkey: + type: PRIMARY KEY + column: oid + t_accident_lieu_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_accident_nature.yaml b/db/schema2/tables/t_accident_nature.yaml new file mode 100644 index 0000000..b2e49e3 --- /dev/null +++ b/db/schema2/tables/t_accident_nature.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_accident_nature'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_accident_nature_pkey: + type: PRIMARY KEY + column: oid + t_accident_nature_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_accident_siege.yaml b/db/schema2/tables/t_accident_siege.yaml new file mode 100644 index 0000000..fbc3155 --- /dev/null +++ b/db/schema2/tables/t_accident_siege.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_accident_siege'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_accident_siege_pkey: + type: PRIMARY KEY + column: oid + t_accident_siege_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_ages.yaml b/db/schema2/tables/t_ages.yaml new file mode 100644 index 0000000..7fbfad9 --- /dev/null +++ b/db/schema2/tables/t_ages.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + oid: + type: bigint + not_null: NOT NULL + default: "0" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" +constraints: + t_ages_pkey: + type: PRIMARY KEY + column: oid + t_ages_ukey1: + type: UNIQUE + column: code +indexes: + i_ages_1: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_anciennetes_annee.yaml b/db/schema2/tables/t_anciennetes_annee.yaml new file mode 100644 index 0000000..4978357 --- /dev/null +++ b/db/schema2/tables/t_anciennetes_annee.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + oid: + type: bigint + not_null: NOT NULL + default: "0" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" +constraints: + t_anciennete_annees_pkey: + type: PRIMARY KEY + column: oid + t_anciennete_annees_ukey1: + type: UNIQUE + column: code +indexes: + i_anciennete_annees_1: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_budget_cle.yaml b/db/schema2/tables/t_budget_cle.yaml new file mode 100644 index 0000000..00aab6b --- /dev/null +++ b/db/schema2/tables/t_budget_cle.yaml @@ -0,0 +1,23 @@ +columns: + code: + type: text + code_original: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_budget_cle'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: text +constraints: + t_budget_cle_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_budget_cle_budget.yaml b/db/schema2/tables/t_budget_cle_budget.yaml new file mode 100644 index 0000000..8631fd6 --- /dev/null +++ b/db/schema2/tables/t_budget_cle_budget.yaml @@ -0,0 +1,24 @@ +columns: + budget: + type: numeric + budget_cle_id: + type: bigint + not_null: NOT NULL + default: "0" + budget_id: + type: bigint + budget_indicateur_id: + type: bigint + date: + type: date + finess_id: + type: bigint + default: "0" + indicateur_id: + type: bigint + indicateur_module: + type: text + default: "'iCTI_rh'::text" + pole_id: + type: bigint + default: "0" \ No newline at end of file diff --git a/db/schema2/tables/t_budget_cle_rule.yaml b/db/schema2/tables/t_budget_cle_rule.yaml new file mode 100644 index 0000000..89aceb3 --- /dev/null +++ b/db/schema2/tables/t_budget_cle_rule.yaml @@ -0,0 +1,43 @@ +columns: + budget_cle_id: + type: bigint + not_null: NOT NULL + default: "0" + budget_id: + type: bigint + not_null: NOT NULL + default: "0" + code: + type: text + liste_categorie_socio_professionnelle: + type: text + liste_code_emploi: + type: text + liste_etablissement: + type: text + liste_finess: + type: text + liste_grille: + type: text + liste_qualification: + type: text + liste_section_analytique: + type: text + liste_section_analytique_paie: + type: text + liste_service: + type: text + liste_specialite: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_budget_cle_rule'::regclass)" + priorite: + type: numeric(5,0) + texte: + type: text +constraints: + t_budget_cle_rule_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_cadre_emploi.yaml b/db/schema2/tables/t_cadre_emploi.yaml new file mode 100644 index 0000000..63cafc6 --- /dev/null +++ b/db/schema2/tables/t_cadre_emploi.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: text + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_cadre_emploi'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + default: "''::character varying" + texte_court: + type: character varying(50) +constraints: + t_cadre_emploi_pkey: + type: PRIMARY KEY + column: oid + t_cadre_emploi_ukey1: + type: UNIQUE + column: code +indexes: + i_cadre_emploi_1: + column: code + method: btree + i_cadre_emploi_2: + column: code_original + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_categorie_conge.yaml b/db/schema2/tables/t_categorie_conge.yaml new file mode 100644 index 0000000..833c18e --- /dev/null +++ b/db/schema2/tables/t_categorie_conge.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_categorie_conge'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" + texte_court: + type: character varying(50) +constraints: + t_categorie_conge_pkey: + type: PRIMARY KEY + column: oid + t_categorie_conge_ukey1: + type: UNIQUE + column: code +indexes: + i_categorie_conge_1: + column: code + method: btree + i_categorie_conge_2: + column: code_original + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_categorie_statutaire.yaml b/db/schema2/tables/t_categorie_statutaire.yaml new file mode 100644 index 0000000..10c2a1d --- /dev/null +++ b/db/schema2/tables/t_categorie_statutaire.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_categorie_statutaire'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" + texte_court: + type: character varying(50) +constraints: + t_categorie_statutaire_pkey: + type: PRIMARY KEY + column: oid + t_categorie_statutaire_ukey1: + type: UNIQUE + column: code +indexes: + i_categorie_statutaire_1: + column: code + method: btree + i_categorie_statutaire_2: + column: code_original + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_categories_socio_professionnelle.yaml b/db/schema2/tables/t_categories_socio_professionnelle.yaml new file mode 100644 index 0000000..998a852 --- /dev/null +++ b/db/schema2/tables/t_categories_socio_professionnelle.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_categories_socio_professionnelles'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_categories_socio_professionnelles_pkey: + type: PRIMARY KEY + column: oid + t_categories_socio_professionnelle_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_chart.yaml b/db/schema2/tables/t_chart.yaml new file mode 100644 index 0000000..b4cfac5 --- /dev/null +++ b/db/schema2/tables/t_chart.yaml @@ -0,0 +1,26 @@ +columns: + category: + type: text + code: + type: text + default_time_calc: + type: text + drilldown: + type: jsonb + label_view_code: + type: numeric + default: "0" + name: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_chart'::regclass)" + serie_id: + type: 'bigint[]' + type: + type: text +constraints: + t_chart_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_classes.yaml b/db/schema2/tables/t_classes.yaml new file mode 100644 index 0000000..36ee41a --- /dev/null +++ b/db/schema2/tables/t_classes.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: text + contenu_by_code: + type: text + default: "'0'::text" + contenu_non_replicable_ailleurs: + type: character(1) + default: "'0'::bpchar" + is_cti: + type: character(1) + default: "0" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_classes'::regclass)" + sequence: + type: integer + default: "1" + table_id: + type: bigint + not_null: NOT NULL + default: "0" + texte: + type: text +constraints: + t_classes_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_classes_1: + column: code + method: btree + i_classes_classes_1: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_classes_sections.yaml b/db/schema2/tables/t_classes_sections.yaml new file mode 100644 index 0000000..f425923 --- /dev/null +++ b/db/schema2/tables/t_classes_sections.yaml @@ -0,0 +1,25 @@ +columns: + classe_id: + type: bigint + not_null: NOT NULL + default: "0" + code: + type: text + condition: + type: text + exclude_code: + type: text + default: "''::text" + include_code: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_classes_sections'::regclass)" + texte: + type: text +constraints: + t_classes_sections_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_classes_sections_elements.yaml b/db/schema2/tables/t_classes_sections_elements.yaml new file mode 100644 index 0000000..f336934 --- /dev/null +++ b/db/schema2/tables/t_classes_sections_elements.yaml @@ -0,0 +1,20 @@ +columns: + section_id: + type: bigint + not_null: NOT NULL + default: "0" + to_id: + type: bigint + not_null: NOT NULL + default: "0" +constraints: + t_classes_sections_elements_ukey: + type: UNIQUE + column: section_id, to_id +indexes: + i_classes_sections_elements_1: + column: section_id + method: btree + i_classes_sections_elements_2: + column: to_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_code_cotisation.yaml b/db/schema2/tables/t_code_cotisation.yaml new file mode 100644 index 0000000..89aa175 --- /dev/null +++ b/db/schema2/tables/t_code_cotisation.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_code_cotisation'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_code_cotisation_pkey: + type: PRIMARY KEY + column: oid + t_code_cotisation_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_codes_emploi.yaml b/db/schema2/tables/t_codes_emploi.yaml new file mode 100644 index 0000000..78d97ae --- /dev/null +++ b/db/schema2/tables/t_codes_emploi.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_codes_emploi'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_codes_emploi_pkey: + type: PRIMARY KEY + column: oid + t_codes_emploi_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_codes_postaux.yaml b/db/schema2/tables/t_codes_postaux.yaml new file mode 100644 index 0000000..42cf25f --- /dev/null +++ b/db/schema2/tables/t_codes_postaux.yaml @@ -0,0 +1,48 @@ +columns: + code: + type: character varying(10) + code_geographique_pmsi_population: + type: numeric(7,0) + default: "0" + departement_code: + type: character varying(10) + default: "''::character varying" + departement_id: + type: bigint + default: "0" + departement_texte: + type: character varying(255) + default: "''::character varying" + latitude: + type: double precision + default: "0" + longitude: + type: double precision + default: "0" + oid: + type: bigint + not_null: NOT NULL + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(255) +constraints: + t_codes_postaux_pkey: + type: PRIMARY KEY + column: oid + t_codes_postaux_ukey: + type: UNIQUE + column: code +indexes: + i_codes_postaux_1: + column: code + method: btree + i_codes_postaux_2: + column: departement_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_commission_paritaire.yaml b/db/schema2/tables/t_commission_paritaire.yaml new file mode 100644 index 0000000..788ceb8 --- /dev/null +++ b/db/schema2/tables/t_commission_paritaire.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_commission_paritaire'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" + texte_court: + type: character varying(50) +constraints: + t_commission_paritaire_pkey: + type: PRIMARY KEY + column: oid + t_commission_paritaire_ukey1: + type: UNIQUE + column: code +indexes: + i_commission_paritaire_1: + column: code + method: btree + i_commission_paritaire_2: + column: code_original + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_compte.yaml b/db/schema2/tables/t_compte.yaml new file mode 100644 index 0000000..c7805f2 --- /dev/null +++ b/db/schema2/tables/t_compte.yaml @@ -0,0 +1,26 @@ +columns: + code: + type: character varying(20) + code_original: + type: character varying(30) + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_compte'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(255) +constraints: + t_compte_pkey: + type: PRIMARY KEY + column: oid + t_compte_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_dashboard.yaml b/db/schema2/tables/t_dashboard.yaml new file mode 100644 index 0000000..4b47a3c --- /dev/null +++ b/db/schema2/tables/t_dashboard.yaml @@ -0,0 +1,14 @@ +columns: + code: + type: text + label: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_dashboard'::regclass)" +constraints: + t_dashboard_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_dashboard_filter.yaml b/db/schema2/tables/t_dashboard_filter.yaml new file mode 100644 index 0000000..380d3e7 --- /dev/null +++ b/db/schema2/tables/t_dashboard_filter.yaml @@ -0,0 +1,13 @@ +columns: + condition_id: + type: bigint + dashboard_id: + type: bigint + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_dashboard_filter'::regclass)" +constraints: + t_dashboard_filter_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_dashboard_onglet.yaml b/db/schema2/tables/t_dashboard_onglet.yaml new file mode 100644 index 0000000..f2771ed --- /dev/null +++ b/db/schema2/tables/t_dashboard_onglet.yaml @@ -0,0 +1,15 @@ +columns: + dashboard_id: + type: bigint + index: + type: bigint + name: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_dashboard_onglet'::regclass)" +constraints: + t_dashboard_onglet_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_dashboard_widget.yaml b/db/schema2/tables/t_dashboard_widget.yaml new file mode 100644 index 0000000..602ad66 --- /dev/null +++ b/db/schema2/tables/t_dashboard_widget.yaml @@ -0,0 +1,15 @@ +columns: + chart_id: + type: bigint + dashboard_id: + type: bigint + deprecated: + type: boolean + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_dashboard_widget'::regclass)" +constraints: + t_dashboard_widget_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_data_profile.yaml b/db/schema2/tables/t_data_profile.yaml new file mode 100644 index 0000000..a2e70b2 --- /dev/null +++ b/db/schema2/tables/t_data_profile.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: text + etablissement_exclus: + type: text + etablissement_id_array: + type: 'bigint[]' + etablissement_inclus: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_data_profile'::regclass)" + service_exclus: + type: text + service_id_array: + type: 'bigint[]' + service_inclus: + type: text + statut_exclus: + type: text + statut_id_array: + type: 'bigint[]' + statut_inclus: + type: text + texte: + type: text + texte_court: + type: text +constraints: + t_data_profile_pkey: + type: PRIMARY KEY + column: oid + t_data_profile_ukey: + type: UNIQUE + column: code \ No newline at end of file diff --git a/db/schema2/tables/t_departements.yaml b/db/schema2/tables/t_departements.yaml new file mode 100644 index 0000000..2f79739 --- /dev/null +++ b/db/schema2/tables/t_departements.yaml @@ -0,0 +1,21 @@ +columns: + code: + type: character varying(10) + oid: + type: bigint + not_null: NOT NULL + texte: + type: character varying(255) + texte_court: + type: character varying(255) +constraints: + t_departements_pkey: + type: PRIMARY KEY + column: oid + t_departements_ukey1: + type: UNIQUE + column: code +indexes: + i_departements_1: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_divers.yaml b/db/schema2/tables/t_divers.yaml new file mode 100644 index 0000000..2a1d292 --- /dev/null +++ b/db/schema2/tables/t_divers.yaml @@ -0,0 +1,19 @@ +columns: + code: + type: text + not_null: NOT NULL + description: + type: text + show_info_module: + type: boolean + default: 'false' + texte: + type: text + valeur: + type: text + valeur_date: + type: date +constraints: + t_divers_pkey: + type: PRIMARY KEY + column: code \ No newline at end of file diff --git a/db/schema2/tables/t_entreprises.yaml b/db/schema2/tables/t_entreprises.yaml new file mode 100644 index 0000000..ec75066 --- /dev/null +++ b/db/schema2/tables/t_entreprises.yaml @@ -0,0 +1,34 @@ +columns: + code: + type: text + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_entreprises'::regclass)" + planning_code: + type: text + default: "''::character varying" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + siren: + type: character varying(9) + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_entreprises_pkey: + type: PRIMARY KEY + column: oid + t_entreprises_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_etablissements.yaml b/db/schema2/tables/t_etablissements.yaml new file mode 100644 index 0000000..2bfcd4a --- /dev/null +++ b/db/schema2/tables/t_etablissements.yaml @@ -0,0 +1,62 @@ +columns: + base_calcul_etp: + type: numeric(5,2) + default: "151.67" + code: + type: text + default: "''::character varying" + code_etablissement: + type: text + code_original: + type: text + not_null: NOT NULL + entreprise_id: + type: bigint + default: "0" + finess_code: + type: text + default: "''::text" + finess_id: + type: bigint + default: "0" + finess_section_code: + type: 'text[]' + finess_section_id: + type: 'bigint[]' + finess_section_texte: + type: 'text[]' + finess_texte: + type: text + default: "''::text" + mode_calcul_etp_paye: + type: character varying(30) + default: "'0'::character varying" + comment: | + * 0 : classique + * 1 : 30eme (PPUB) + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_etablissements'::regclass)" + planning_code: + type: text + default: "''::character varying" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + siret: + type: character varying(14) + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_etablissements_pkey: + type: PRIMARY KEY + column: oid + t_etablissements_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_expert_controle.yaml b/db/schema2/tables/t_expert_controle.yaml new file mode 100644 index 0000000..825089e --- /dev/null +++ b/db/schema2/tables/t_expert_controle.yaml @@ -0,0 +1,72 @@ +columns: + alert_exp: + type: text + not_null: NOT NULL + default: "'0'::text" + alerte_id: + type: bigint + default: "0" + code: + type: text + date_validite_debut: + type: date + date_validite_fin: + type: date + description: + type: text + default: "''::text" + gravite_id: + type: bigint + default: "5" + comment: 0=Information, 5=Avertissement, 9=Erreur + is_active: + type: character(1) + default: "'1'::bpchar" + is_cti: + type: character(1) + default: "'0'::bpchar" + is_global: + type: character(1) + default: "'0'::bpchar" + is_hide: + type: character(1) + default: "'0'::bpchar" + last_execution_count: + type: numeric + default: "0" + last_execution_date: + type: date + last_execution_ok: + type: character(1) + last_execution_timestamp: + type: timestamp without time zone + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_expert_controle'::regclass)" + prestataire_id: + type: bigint + default: "'-1'::integer" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + start_periode: + type: text + default: "''::text" + texte: + type: text + default: "''::text" + texte_abrege: + type: text + texte_court: + type: text +constraints: + t_expert_controle_pkey: + type: PRIMARY KEY + column: oid + t_expert_controle_ukey: + type: UNIQUE + column: code \ No newline at end of file diff --git a/db/schema2/tables/t_expert_controle_rule.yaml b/db/schema2/tables/t_expert_controle_rule.yaml new file mode 100644 index 0000000..1955516 --- /dev/null +++ b/db/schema2/tables/t_expert_controle_rule.yaml @@ -0,0 +1,52 @@ +columns: + data_type: + type: text + default: "''::text" + expert_controle_id: + type: bigint + formula: + type: text + default: "''::text" + formula_2: + type: text + default: "''::text" + formula_3: + type: text + default: "''::text" + indicateur_2_id: + type: bigint + default: "0" + indicateur_3_id: + type: bigint + default: "0" + indicateur_condition_2_id: + type: 'bigint[]' + indicateur_condition_3_id: + type: 'bigint[]' + indicateur_condition_id: + type: 'bigint[]' + conditions_operateur_2: + type: text + default: "'AND'::text" + conditions_operateur_3: + type: text + default: "'AND'::text" + conditions_operateur: + type: text + default: "'AND'::text" + indicateur_id: + type: bigint + is_cti: + type: text + default: "'0'::text" + last_execution_result: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_expert_controle_rule'::regclass)" +constraints: + t_expert_controle_rule_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_filiere.yaml b/db/schema2/tables/t_filiere.yaml new file mode 100644 index 0000000..d637060 --- /dev/null +++ b/db/schema2/tables/t_filiere.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_filiere'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" + texte_court: + type: character varying(50) +constraints: + t_filiere_pkey: + type: PRIMARY KEY + column: oid + t_filiere_ukey1: + type: UNIQUE + column: code +indexes: + i_filiere_1: + column: code + method: btree + i_filiere_2: + column: code_original + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_grilles.yaml b/db/schema2/tables/t_grilles.yaml new file mode 100644 index 0000000..cf0f20d --- /dev/null +++ b/db/schema2/tables/t_grilles.yaml @@ -0,0 +1,25 @@ +columns: + code: + type: text + default: "''::text" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_grilles'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_grilles_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_grilles_groupes.yaml b/db/schema2/tables/t_grilles_groupes.yaml new file mode 100644 index 0000000..73a3db6 --- /dev/null +++ b/db/schema2/tables/t_grilles_groupes.yaml @@ -0,0 +1,25 @@ +columns: + code: + type: text + default: "''::text" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_grilles_groupes'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: text +constraints: + t_grilles_groupes_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_groupes_cotisant.yaml b/db/schema2/tables/t_groupes_cotisant.yaml new file mode 100644 index 0000000..0ac61e9 --- /dev/null +++ b/db/schema2/tables/t_groupes_cotisant.yaml @@ -0,0 +1,25 @@ +columns: + code: + type: text + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_groupes_cotisant'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_groupes_cotisant_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_indicateur_condition.yaml b/db/schema2/tables/t_indicateur_condition.yaml new file mode 100644 index 0000000..1eb2d5f --- /dev/null +++ b/db/schema2/tables/t_indicateur_condition.yaml @@ -0,0 +1,45 @@ +columns: + arbre_code: + type: 'text[]' + arbre_texte: + type: 'text[]' + category_id: + type: text + code: + type: text + default: "''::text" + column_name: + type: text + default: "''::text" + column_texte: + type: text + default: "''::text" + condition_code: + type: text + external_code: + type: text + external_code2: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_indicateur_condition'::regclass)" + rule: + type: text + default: "''::text" + texte: + type: text + default: "''::text" + texte_court: + type: text + default: "''::text" + value: + type: text + default: "''::text" + view_select_rule: + type: text + default: "''::text" +constraints: + t_indicateur_condition_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_indicateur_condition_table.yaml b/db/schema2/tables/t_indicateur_condition_table.yaml new file mode 100644 index 0000000..7fcbfa5 --- /dev/null +++ b/db/schema2/tables/t_indicateur_condition_table.yaml @@ -0,0 +1,17 @@ +columns: + check_where: + type: text + default: "''::text" + indicateur_condition_id: + type: bigint + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_indicateur_condition_table'::regclass)" + table_name: + type: text + default: "''::text" +constraints: + t_indicateur_condition_table_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_indicateur_externe_import.yaml b/db/schema2/tables/t_indicateur_externe_import.yaml new file mode 100644 index 0000000..6c5b074 --- /dev/null +++ b/db/schema2/tables/t_indicateur_externe_import.yaml @@ -0,0 +1,30 @@ +columns: + code: + type: text + default: "''::character varying" + data_data: + type: text + default: "''::text" + data_filepath: + type: text + default: "''::text" + data_type: + type: text + default: "''::text" + data_view: + type: text + default: "''::text" + finess_id: + type: bigint + default: "0" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_indicateur_externe_import'::regclass)" + texte: + type: text + default: "''::character varying" +constraints: + t_indicateur_externe_import_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_indicateur_serie.yaml b/db/schema2/tables/t_indicateur_serie.yaml new file mode 100644 index 0000000..e5c74d3 --- /dev/null +++ b/db/schema2/tables/t_indicateur_serie.yaml @@ -0,0 +1,33 @@ +columns: + calc: + type: boolean + code: + type: text + color: + type: text + condition_id: + type: 'bigint[]' + drilldown: + type: jsonb + format: + type: text + formula: + type: text + indicateur_id: + type: bigint + name: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_indicateur_serie'::regclass)" + serie_id: + type: text + default: "''::text" + total: + type: boolean + default: 'false' +constraints: + t_indicateur_serie_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_indicateur_theme.yaml b/db/schema2/tables/t_indicateur_theme.yaml new file mode 100644 index 0000000..1bca744 --- /dev/null +++ b/db/schema2/tables/t_indicateur_theme.yaml @@ -0,0 +1,29 @@ +columns: + children_id: + type: 'bigint[]' + code: + type: text + default: "''::text" + level: + type: numeric + default: "1" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_indicateur_theme'::regclass)" + parent_id: + type: bigint + default: "0" + parent_tree_code: + type: 'text[]' + parent_tree_id: + type: 'bigint[]' + parent_tree_texte: + type: 'text[]' + texte: + type: text + default: "''::text" +constraints: + t_indicateur_theme_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_indicateurs.yaml b/db/schema2/tables/t_indicateurs.yaml new file mode 100644 index 0000000..332ef2f --- /dev/null +++ b/db/schema2/tables/t_indicateurs.yaml @@ -0,0 +1,137 @@ +columns: + code: + type: text + column_name: + type: text + default: "''::character varying" + description: + type: text + default: "''::text" + dimension_date: + type: character(1) + default: "''::bpchar" + dimension_date_1: + type: character(1) + default: "'0'::bpchar" + dimension_date_2: + type: character(1) + default: "''::bpchar" + dimension_date_3: + type: character(1) + default: "''::bpchar" + dimension_date_4: + type: character(1) + default: "''::bpchar" + dimension_date_5: + type: character(1) + default: "''::bpchar" + entete: + type: character varying(255) + entete_etendue: + type: character varying(255) + indicateur_associe_10_id: + type: bigint + default: "0" + indicateur_associe_11_id: + type: bigint + default: "0" + indicateur_associe_12_id: + type: bigint + default: "0" + indicateur_associe_13_id: + type: bigint + default: "0" + indicateur_associe_14_id: + type: bigint + default: "0" + indicateur_associe_15_id: + type: bigint + default: "0" + indicateur_associe_16_id: + type: bigint + default: "0" + indicateur_associe_17_id: + type: bigint + default: "0" + indicateur_associe_18_id: + type: bigint + default: "0" + indicateur_associe_19_id: + type: bigint + default: "0" + indicateur_associe_1_id: + type: bigint + default: "0" + indicateur_associe_20_id: + type: bigint + default: "0" + indicateur_associe_2_id: + type: bigint + default: "0" + indicateur_associe_3_id: + type: bigint + default: "0" + indicateur_associe_4_id: + type: bigint + default: "0" + indicateur_associe_5_id: + type: bigint + default: "0" + indicateur_associe_6_id: + type: bigint + default: "0" + indicateur_associe_7_id: + type: bigint + default: "0" + indicateur_associe_8_id: + type: bigint + default: "0" + indicateur_associe_9_id: + type: bigint + default: "0" + indicateur_reference_id: + type: bigint + default: "0" + indicateur_template_id: + type: bigint + default: "0" + is_cti: + type: character(1) + default: "0" + is_hide: + type: character(1) + is_template: + type: text + default: "'0'::text" + last_error: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_indicateurs'::regclass)" + output_format: + type: character varying(10) + default: "'#'::character varying" + table_name: + type: character varying(255) + texte: + type: character varying(255) + theme_id: + type: 'bigint[]' + total_function: + type: text + default: "'sum'::character varying" + variable_definition: + type: 'text[]' + variable_value: + type: 'text[]' + variable_value_text: + type: 'text[]' + width: + type: numeric(3,0) + default: "0" +constraints: + t_indicateurs_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_lettre_budgetaire.yaml b/db/schema2/tables/t_lettre_budgetaire.yaml new file mode 100644 index 0000000..9c9ef5b --- /dev/null +++ b/db/schema2/tables/t_lettre_budgetaire.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_lettre_budgetaire'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" + texte_court: + type: character varying(50) +constraints: + t_lettre_budgetaire_pkey: + type: PRIMARY KEY + column: oid + t_lettre_budgetaire_ukey1: + type: UNIQUE + column: code +indexes: + i_lettre_budgetaire_1: + column: code + method: btree + i_lettre_budgetaire_2: + column: code_original + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_liste_formations.yaml b/db/schema2/tables/t_liste_formations.yaml new file mode 100644 index 0000000..10178df --- /dev/null +++ b/db/schema2/tables/t_liste_formations.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_liste_formations'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_liste_formations_pkey: + type: PRIMARY KEY + column: oid + t_liste_formations_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_listes.yaml b/db/schema2/tables/t_listes.yaml new file mode 100644 index 0000000..febdd35 --- /dev/null +++ b/db/schema2/tables/t_listes.yaml @@ -0,0 +1,48 @@ +columns: + chapitre: + type: text + default: "''::text" + code: + type: text + contenu_by_code: + type: text + default: "'0'::text" + contenu_non_replicable_ailleurs: + type: character(1) + default: "'0'::bpchar" + est_partagee_modification: + type: character(1) + default: "'1'::bpchar" + exclude_code: + type: text + default: "''::text" + include_code: + type: text + default: "''::text" + is_cti: + type: character(1) + default: "0" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_listes'::regclass)" + show_omit: + type: character(1) + default: "'1'::bpchar" + table_id: + type: bigint + not_null: NOT NULL + default: "0" + texte: + type: text + utilisateur_createur: + type: text + default: "''::text" +constraints: + t_listes_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_listes_1: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_listes_contenu.yaml b/db/schema2/tables/t_listes_contenu.yaml new file mode 100644 index 0000000..450c5ee --- /dev/null +++ b/db/schema2/tables/t_listes_contenu.yaml @@ -0,0 +1,20 @@ +columns: + liste_id: + type: bigint + not_null: NOT NULL + default: "0" + to_id: + type: bigint + not_null: NOT NULL + default: "0" +constraints: + t_listes_contenu_ukey: + type: UNIQUE + column: liste_id, to_id +indexes: + i_listes_contenu_1: + column: liste_id + method: btree + i_listes_contenu_2: + column: to_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_listes_tables.yaml b/db/schema2/tables/t_listes_tables.yaml new file mode 100644 index 0000000..2e1f86f --- /dev/null +++ b/db/schema2/tables/t_listes_tables.yaml @@ -0,0 +1,21 @@ +columns: + code: + type: text + default: "''::text" + name: + type: text + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_listes_tables'::regclass)" + select_cmd: + type: text + texte: + type: text +constraints: + t_listes_tables_pkey: + type: PRIMARY KEY + column: oid + t_listes_tables_ukey: + type: UNIQUE + column: name \ No newline at end of file diff --git a/db/schema2/tables/t_motifs_arret.yaml b/db/schema2/tables/t_motifs_arret.yaml new file mode 100644 index 0000000..6bbe27c --- /dev/null +++ b/db/schema2/tables/t_motifs_arret.yaml @@ -0,0 +1,30 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_motifs_arret'::regclass)" + rang_edition: + type: numeric(9,0) + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_motifs_arret_pkey: + type: PRIMARY KEY + column: oid + t_motifs_arret_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_motifs_debut_contrat.yaml b/db/schema2/tables/t_motifs_debut_contrat.yaml new file mode 100644 index 0000000..b0a30e5 --- /dev/null +++ b/db/schema2/tables/t_motifs_debut_contrat.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_motifs_debut_contrat'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_motifs_debut_contrat_pkey: + type: PRIMARY KEY + column: oid + t_motifs_debut_contrat_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_motifs_fin_contrat.yaml b/db/schema2/tables/t_motifs_fin_contrat.yaml new file mode 100644 index 0000000..957083b --- /dev/null +++ b/db/schema2/tables/t_motifs_fin_contrat.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_motifs_fin_contrat'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_motifs_fin_contrat_pkey: + type: PRIMARY KEY + column: oid + t_motifs_fin_contrat_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_motifs_visite.yaml b/db/schema2/tables/t_motifs_visite.yaml new file mode 100644 index 0000000..239fc6a --- /dev/null +++ b/db/schema2/tables/t_motifs_visite.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_motifs_visite'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_motifs_visite_pkey: + type: PRIMARY KEY + column: oid + t_motifs_visite_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_nationalites.yaml b/db/schema2/tables/t_nationalites.yaml new file mode 100644 index 0000000..b07df4a --- /dev/null +++ b/db/schema2/tables/t_nationalites.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_nationalites'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_nationalites_pkey: + type: PRIMARY KEY + column: oid + t_nationalites_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_organismes_cotisation.yaml b/db/schema2/tables/t_organismes_cotisation.yaml new file mode 100644 index 0000000..90b6e47 --- /dev/null +++ b/db/schema2/tables/t_organismes_cotisation.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_organismes_cotisation'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_organismes_cotisation_pkey: + type: PRIMARY KEY + column: oid + t_organismes_cotisation_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_periode_paie.yaml b/db/schema2/tables/t_periode_paie.yaml new file mode 100644 index 0000000..aeef191 --- /dev/null +++ b/db/schema2/tables/t_periode_paie.yaml @@ -0,0 +1,17 @@ +columns: + date_debut: + type: date + date_fin: + type: date + mois_paie: + type: integer +indexes: + i_periode_paie_1: + column: date_debut + method: btree + i_periode_paie_2: + column: date_fin + method: btree + i_periode_paie_3: + column: mois_paie + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_plan_analytique.yaml b/db/schema2/tables/t_plan_analytique.yaml new file mode 100644 index 0000000..2232731 --- /dev/null +++ b/db/schema2/tables/t_plan_analytique.yaml @@ -0,0 +1,17 @@ +columns: + code: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_plan_analytique'::regclass)" + texte: + type: text +constraints: + t_plan_analytique_pkey: + type: PRIMARY KEY + column: oid + t_plan_analytique_ukey: + type: UNIQUE + column: code \ No newline at end of file diff --git a/db/schema2/tables/t_planning_code_horaire.yaml b/db/schema2/tables/t_planning_code_horaire.yaml new file mode 100644 index 0000000..6c6536f --- /dev/null +++ b/db/schema2/tables/t_planning_code_horaire.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_planning_code_horaire'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_planning_code_horaire_pkey: + type: PRIMARY KEY + column: oid + t_planning_code_horaire_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_planning_niveau.yaml b/db/schema2/tables/t_planning_niveau.yaml new file mode 100644 index 0000000..8b7ba8e --- /dev/null +++ b/db/schema2/tables/t_planning_niveau.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_planning_niveau'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_planning_niveau_pkey: + type: PRIMARY KEY + column: oid + t_planning_niveau_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_planning_qualification.yaml b/db/schema2/tables/t_planning_qualification.yaml new file mode 100644 index 0000000..8f20f5d --- /dev/null +++ b/db/schema2/tables/t_planning_qualification.yaml @@ -0,0 +1,41 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_planning_qualification'::regclass)" + qualification_code: + type: text + qualification_id: + type: bigint + default: "0" + qualification_section_code: + type: 'text[]' + qualification_section_id: + type: 'bigint[]' + qualification_section_texte: + type: 'text[]' + qualification_texte: + type: text + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(255) +constraints: + t_planning_qualification_pkey: + type: PRIMARY KEY + column: oid + t_planning_qualification_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_planning_service.yaml b/db/schema2/tables/t_planning_service.yaml new file mode 100644 index 0000000..1f607c5 --- /dev/null +++ b/db/schema2/tables/t_planning_service.yaml @@ -0,0 +1,41 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_planning_service'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + service_code: + type: text + service_id: + type: bigint + default: "0" + service_section_code: + type: 'text[]' + service_section_id: + type: 'bigint[]' + service_section_texte: + type: 'text[]' + service_texte: + type: text + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_planning_service_pkey: + type: PRIMARY KEY + column: oid + t_planning_service_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_planning_type_absence.yaml b/db/schema2/tables/t_planning_type_absence.yaml new file mode 100644 index 0000000..b6f7ee5 --- /dev/null +++ b/db/schema2/tables/t_planning_type_absence.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_planning_type_absence'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_planning_type_absence_pkey: + type: PRIMARY KEY + column: oid + t_planning_type_absence_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_pole.yaml b/db/schema2/tables/t_pole.yaml new file mode 100644 index 0000000..c15e0db --- /dev/null +++ b/db/schema2/tables/t_pole.yaml @@ -0,0 +1,23 @@ +columns: + code: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + default: "''::text" + texte_court: + type: text + default: "''::text" +constraints: + t_pole_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_pole_rule.yaml b/db/schema2/tables/t_pole_rule.yaml new file mode 100644 index 0000000..34b6855 --- /dev/null +++ b/db/schema2/tables/t_pole_rule.yaml @@ -0,0 +1,52 @@ +columns: + code: + type: text + liste_categorie_socio_professionnelle: + type: text + default: "''::text" + liste_code_emploi: + type: text + default: "''::text" + liste_etablissement: + type: text + default: "''::text" + liste_finess: + type: text + default: "''::text" + liste_grille: + type: text + default: "''::text" + liste_qualification: + type: text + default: "''::text" + liste_section_analytique: + type: text + default: "''::text" + liste_section_analytique_paie: + type: text + default: "''::text" + liste_service: + type: text + default: "''::text" + liste_service_planning: + type: text + default: "''::text" + liste_specialite: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_pole_rule'::regclass)" + pole_id: + type: bigint + not_null: NOT NULL + default: "0" + priorite: + type: numeric(5,0) + texte: + type: text +constraints: + t_pole_rule_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_population.yaml b/db/schema2/tables/t_population.yaml new file mode 100644 index 0000000..e0fa5f8 --- /dev/null +++ b/db/schema2/tables/t_population.yaml @@ -0,0 +1,24 @@ +columns: + code: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_population'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + default: "''::text" + texte_court: + type: text + default: "''::text" +constraints: + t_population_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_population_regle.yaml b/db/schema2/tables/t_population_regle.yaml new file mode 100644 index 0000000..44e1cbd --- /dev/null +++ b/db/schema2/tables/t_population_regle.yaml @@ -0,0 +1,52 @@ +columns: + code: + type: text + liste_categorie_socio_professionnelle: + type: text + default: "''::text" + liste_code_emploi: + type: text + default: "''::text" + liste_etablissement: + type: text + default: "''::text" + liste_finess: + type: text + default: "''::text" + liste_grille: + type: text + default: "''::text" + liste_qualification: + type: text + default: "''::text" + liste_section_analytique: + type: text + default: "''::text" + liste_section_analytique_paie: + type: text + default: "''::text" + liste_service: + type: text + default: "''::text" + liste_specialite: + type: text + default: "''::text" + liste_statut: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_population_regle'::regclass)" + population_id: + type: bigint + not_null: NOT NULL + default: "0" + priorite: + type: numeric(5,0) + texte: + type: text +constraints: + t_population_regle_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_precisions_motif_arret.yaml b/db/schema2/tables/t_precisions_motif_arret.yaml new file mode 100644 index 0000000..6fa677e --- /dev/null +++ b/db/schema2/tables/t_precisions_motif_arret.yaml @@ -0,0 +1,30 @@ +columns: + code: + type: text + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_precisions_motif_arret'::regclass)" + rang_edition: + type: numeric(9,0) + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_precisions_motif_arret_pkey: + type: PRIMARY KEY + column: oid + t_precisions_motif_arret_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_qualifications.yaml b/db/schema2/tables/t_qualifications.yaml new file mode 100644 index 0000000..0e86b51 --- /dev/null +++ b/db/schema2/tables/t_qualifications.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::text" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_qualifications'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_qualifications_pkey: + type: PRIMARY KEY + column: oid + t_qualifications_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_rapport_group.yaml b/db/schema2/tables/t_rapport_group.yaml new file mode 100644 index 0000000..7dd9942 --- /dev/null +++ b/db/schema2/tables/t_rapport_group.yaml @@ -0,0 +1,15 @@ +columns: + code: + type: text + oid: + type: bigint + not_null: NOT NULL + one_click: + type: text + default: "''::text" + texte: + type: text +constraints: + t_rapport_group_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_rapports.yaml b/db/schema2/tables/t_rapports.yaml new file mode 100644 index 0000000..f8ff2b4 --- /dev/null +++ b/db/schema2/tables/t_rapports.yaml @@ -0,0 +1,65 @@ +columns: + code: + type: character varying(10) + colonnes_essentiel: + type: text + default: "''::text" + colonnes_essentiel_style: + type: text + default: "''::text" + contexte: + type: text + default: "''::text" + entete: + type: text + default: "''::text" + entete_2: + type: text + default: "''::text" + essentiel_date_level: + type: character(1) + default: "'M'::bpchar" + group_id: + type: bigint + default: "0" + is_cti: + type: character(1) + default: "0" + is_essentiel: + type: character(1) + default: "'0'::bpchar" + is_hide: + type: text + default: "'0'::text" + is_template_updatable: + type: text + default: "'0'::text" + label: + type: text + default: "''::text" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_rapports'::regclass)" + rapport_indicateur_condition_id: + type: 'bigint[]' + rapport_lie_id: + type: 'bigint[]' + rapport_template_id: + type: bigint + default: "0" + serie_entete: + type: 'text[]' + texte: + type: character varying(255) + type_rapport: + type: text + default: "''::text" +constraints: + t_rapports_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_rapports_1: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_rapports_rubriques.yaml b/db/schema2/tables/t_rapports_rubriques.yaml new file mode 100644 index 0000000..4565059 --- /dev/null +++ b/db/schema2/tables/t_rapports_rubriques.yaml @@ -0,0 +1,147 @@ +columns: + background_color: + type: character(10) + default: "''::bpchar" + base_nationale: + type: character(1) + default: "'0'::bpchar" + base_nationale_qualifiee: + type: character(1) + default: "'0'::bpchar" + border_thickness: + type: integer + default: "0" + calc_formula: + type: text + default: "''::text" + color: + type: character(10) + default: "''::bpchar" + compared_indicator_id: + type: bigint + default: "0" + description: + type: text + default: "''::text" + description_2: + type: text + default: "''::text" + entete: + type: character varying(255) + default: "''::character varying" + entete_etendue: + type: character varying(255) + default: "''::character varying" + entete_etendue_2: + type: text + default: "''::text" + erase_rapport_indicateur_condition: + type: text + default: "'0'::text" + field_tag: + type: text + default: "''::text" + font_size: + type: integer + default: "0" + font_weight: + type: character(10) + default: "'normal'::bpchar" + hide_on_zero_field: + type: text + default: "''::text" + indicateur_associe_id: + type: bigint + default: "0" + indicateur_condition_id: + type: 'bigint[]' + indicateur_id: + type: bigint + default: "0" + is_hide: + type: text + default: "'0'::text" + last_sql: + type: text + default: "''::text" + last_sql_error: + type: text + default: "''::text" + numero_rubrique: + type: integer + not_null: NOT NULL + option: + type: text + default: "''::text" + output_format: + type: text + default: "''::text" + output_format_2: + type: text + default: "''::text" + padding: + type: integer + default: "0" + periode_reference: + type: character(3) + picto_enabled: + type: character(1) + default: "'1'::bpchar" + comment: "Affiche ou non le pictogramme selon la tendance de l''indicateur (par défaut oui)" + picto_enabled_2: + type: text + default: "''::text" + positif_is_good: + type: character(1) + default: "'1'::bpchar" + comment: Indique si une tendance positive est une bonne chose ou non (par défaut oui) + positif_is_good_2: + type: text + default: "''::text" + rapport_id: + type: bigint + not_null: NOT NULL + default: "0" + row_height: + type: integer + default: "0" + serie_description: + type: 'text[]' + serie_entete_etendue: + type: 'text[]' + serie_indicateur_id: + type: 'bigint[]' + serie_output_format: + type: 'text[]' + serie_picto_enabled: + type: 'text[]' + serie_positif_is_good: + type: 'text[]' + specific_viewlink: + type: text + default: "''::text" + specific_viewlink_label: + type: text + default: "''::text" + specific_viewlink_param: + type: text + default: "''::text" + viewlink: + type: text + default: "''::text" + comment: "Nom de la vue à ouvrir à partir des Essentiels pour l''accès aux détails de l''indicateur" + viewlink_label: + type: text + default: "''::text" + comment: Texte du lien vers la vue de détails + viewlink_param: + type: text + default: "''::text" + comment: Paramétrage des regroupements et des filtres pour les Viewlinks des Essentiels + width: + type: numeric(3,0) + default: "0" +constraints: + t_rapports_rubriques_pkey: + type: PRIMARY KEY + column: numero_rubrique, rapport_id \ No newline at end of file diff --git a/db/schema2/tables/t_rubriques.yaml b/db/schema2/tables/t_rubriques.yaml new file mode 100644 index 0000000..1cb904f --- /dev/null +++ b/db/schema2/tables/t_rubriques.yaml @@ -0,0 +1,240 @@ +columns: + c_avantage_nature: + type: numeric + default: "1" + c_base: + type: numeric + default: "1" + c_brut: + type: numeric + default: "1" + c_cotisation_patronale: + type: numeric + default: "1" + c_cotisation_salarie: + type: numeric + default: "1" + c_frais_imposables: + type: numeric + default: "1" + c_heures_contrat: + type: numeric + default: "1" + c_heures_payees: + type: numeric + default: "1" + c_heures_travaillees: + type: numeric + default: "1" + c_masse_salariale: + type: numeric + default: "1" + c_masse_salariale_provisionnee: + type: numeric + default: "1" + c_montant_provisions: + type: numeric + default: "1" + c_net_a_payer: + type: numeric + default: "1" + c_net_imposable: + type: numeric + default: "1" + c_nombre: + type: numeric + default: "1" + c_nombre_provisions: + type: numeric + default: "1" + c_od_net_patronale: + type: numeric + default: "1" + c_od_net_salarie: + type: numeric + default: "1" + chapitre_bulletin: + type: character(1) + code: + type: character varying(30) + default: "''::character varying" + code_calcul: + type: character(2) + default: "0" + comment: | + * 0 : par défaut + * 1 : heures payées + * 2 : heures non travaillées + code_original: + type: text + not_null: NOT NULL + coefficient: + type: numeric(5,2) + default: "1" + comment: Lorsque la rubrique est exprimé dans une autre unité que les heures, coefficient à appliquer à la rubrique pour obtenir des heures. + coefficient_base: + type: numeric + default: "1" + coefficient_nombre: + type: numeric + default: "1" + coefficient_txp: + type: numeric + default: "1" + coefficient_txs: + type: numeric + default: "1" + heures_payees: + type: character(1) + default: "0" + comment: "1" si rubrique correspondant à des heures payées, "0" sinon (par défaut). + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_rubriques'::regclass)" + p_avantage_nature: + type: boolean + default: 'false' + p_base: + type: boolean + default: 'false' + p_brut: + type: boolean + default: 'false' + p_cotisation_patronale: + type: boolean + default: 'false' + p_cotisation_salarie: + type: boolean + default: 'false' + p_cumul: + type: boolean + default: 'false' + p_detail: + type: boolean + default: 'false' + p_frais_imposables: + type: boolean + default: 'false' + p_heures_contrat: + type: boolean + default: 'false' + p_heures_payees: + type: boolean + default: 'false' + p_heures_travaillees: + type: boolean + default: 'false' + p_masse_salariale: + type: boolean + default: 'false' + p_masse_salariale_provisionnee: + type: boolean + default: 'false' + p_montant_provisions: + type: boolean + default: 'false' + p_net_a_payer: + type: boolean + default: 'false' + p_net_imposable: + type: boolean + default: 'false' + p_nombre: + type: boolean + default: 'false' + p_nombre_provisions: + type: boolean + default: 'false' + p_od_net_patronale: + type: boolean + default: 'false' + p_od_net_salarie: + type: boolean + default: 'false' + proratiser_conversion: + type: boolean + default: 'true' + comment: Proratiser la conversion jour vers heures selon le type de temps de travail. + rang_edition: + type: numeric(9,0) + s_avantage_nature: + type: smallint + default: "3" + s_base: + type: smallint + default: "1" + s_brut: + type: smallint + default: "3" + s_cotisation_patronale: + type: smallint + default: "5" + s_cotisation_salarie: + type: smallint + default: "3" + s_frais_imposables: + type: smallint + default: "3" + s_heures_contrat: + type: smallint + default: "0" + s_heures_payees: + type: smallint + default: "0" + s_heures_travaillees: + type: smallint + default: "0" + s_masse_salariale: + type: smallint + default: "5" + s_masse_salariale_provisionnee: + type: smallint + default: "0" + s_montant_provisions: + type: smallint + default: "0" + s_net_a_payer: + type: smallint + default: "3" + s_net_imposable: + type: smallint + default: "3" + s_nombre: + type: smallint + default: "0" + s_nombre_provisions: + type: smallint + default: "0" + s_od_net_patronale: + type: smallint + default: "5" + s_od_net_salarie: + type: smallint + default: "3" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) + unite: + type: character(1) + default: "0" + comment: | + * 0 : heures (par défaut) + * 1 : autre (jours, mois, ...) + user_modified: + type: boolean + default: 'false' +constraints: + t_rubriques_pkey: + type: PRIMARY KEY + column: oid + t_rubriques_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_section_analytique.yaml b/db/schema2/tables/t_section_analytique.yaml new file mode 100644 index 0000000..2b21909 --- /dev/null +++ b/db/schema2/tables/t_section_analytique.yaml @@ -0,0 +1,29 @@ +columns: + code: + type: text + not_null: NOT NULL + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_section_analytique'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: text + not_null: NOT NULL +constraints: + t_section_analytique_pkey: + type: PRIMARY KEY + column: oid + t_section_analytique_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_sections_analytiques.yaml b/db/schema2/tables/t_sections_analytiques.yaml new file mode 100644 index 0000000..e32f86a --- /dev/null +++ b/db/schema2/tables/t_sections_analytiques.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::text" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_sections_analytiques'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: text +constraints: + t_sections_analytiques_pkey: + type: PRIMARY KEY + column: oid + t_sections_analytiques_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_sections_analytiques_paie.yaml b/db/schema2/tables/t_sections_analytiques_paie.yaml new file mode 100644 index 0000000..09b8467 --- /dev/null +++ b/db/schema2/tables/t_sections_analytiques_paie.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::text" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_sections_analytiques_paie'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: text +constraints: + t_sections_analytiques_paie_pkey: + type: PRIMARY KEY + column: oid + t_sections_analytiques_paie_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_services.yaml b/db/schema2/tables/t_services.yaml new file mode 100644 index 0000000..6c5db28 --- /dev/null +++ b/db/schema2/tables/t_services.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::text" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_services'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: text +constraints: + t_services_pkey: + type: PRIMARY KEY + column: oid + t_services_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_situations_famille.yaml b/db/schema2/tables/t_situations_famille.yaml new file mode 100644 index 0000000..d9cc479 --- /dev/null +++ b/db/schema2/tables/t_situations_famille.yaml @@ -0,0 +1,25 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_situations_famille'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_situations_famille_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_societes_interim.yaml b/db/schema2/tables/t_societes_interim.yaml new file mode 100644 index 0000000..dd9bd5d --- /dev/null +++ b/db/schema2/tables/t_societes_interim.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_societes_interim'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_societes_interim_pkey: + type: PRIMARY KEY + column: oid + t_societes_interim_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_specialites.yaml b/db/schema2/tables/t_specialites.yaml new file mode 100644 index 0000000..9ec0cb1 --- /dev/null +++ b/db/schema2/tables/t_specialites.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_specialites'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_specialites_pkey: + type: PRIMARY KEY + column: oid + t_specialites_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_statuts.yaml b/db/schema2/tables/t_statuts.yaml new file mode 100644 index 0000000..018e6ba --- /dev/null +++ b/db/schema2/tables/t_statuts.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_statuts'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_statuts_pkey: + type: PRIMARY KEY + column: oid + t_statuts_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_transformation.yaml b/db/schema2/tables/t_transformation.yaml new file mode 100644 index 0000000..d75fd8d --- /dev/null +++ b/db/schema2/tables/t_transformation.yaml @@ -0,0 +1,32 @@ +columns: + date_debut: + type: date + default: "'0001-01-01'::date" + date_fin: + type: date + default: "'2099-12-31'::date" + from_qualification_id: + type: bigint + default: "'-1'::integer" + from_service_id: + type: bigint + default: "'-1'::integer" + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_transformation'::regclass)" + salarie_id: + type: bigint + default: "'-1'::integer" + texte: + type: text + to_qualification_id: + type: bigint + default: "'-1'::integer" + to_service_id: + type: bigint + default: "'-1'::integer" +constraints: + t_transformation_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_types_contrat.yaml b/db/schema2/tables/t_types_contrat.yaml new file mode 100644 index 0000000..9498c7b --- /dev/null +++ b/db/schema2/tables/t_types_contrat.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: text + default: "''::text" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_types_contrat'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: text + texte_court: + type: character varying(50) +constraints: + t_types_contrat_pkey: + type: PRIMARY KEY + column: oid + t_types_contrat_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_types_horaire.yaml b/db/schema2/tables/t_types_horaire.yaml new file mode 100644 index 0000000..3cba562 --- /dev/null +++ b/db/schema2/tables/t_types_horaire.yaml @@ -0,0 +1,25 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_types_horaire'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_types_horaire_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/tables/t_types_temps_travail.yaml b/db/schema2/tables/t_types_temps_travail.yaml new file mode 100644 index 0000000..649af28 --- /dev/null +++ b/db/schema2/tables/t_types_temps_travail.yaml @@ -0,0 +1,28 @@ +columns: + code: + type: character varying(30) + default: "''::character varying" + code_original: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_types_temps_travail'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + texte_court: + type: character varying(50) +constraints: + t_types_temps_travail_pkey: + type: PRIMARY KEY + column: oid + t_types_temps_travail_ukey: + type: UNIQUE + column: code_original \ No newline at end of file diff --git a/db/schema2/tables/t_unite_fonctionnelle.yaml b/db/schema2/tables/t_unite_fonctionnelle.yaml new file mode 100644 index 0000000..f0fe01f --- /dev/null +++ b/db/schema2/tables/t_unite_fonctionnelle.yaml @@ -0,0 +1,36 @@ +columns: + code: + type: character varying(10) + default: "''::character varying" + code_original: + type: character varying(10) + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_unite_fonctionnelle'::regclass)" + section_code: + type: 'text[]' + section_id: + type: 'bigint[]' + section_texte: + type: 'text[]' + texte: + type: character varying(255) + default: "''::character varying" + texte_court: + type: character varying(50) +constraints: + t_unite_fonctionnelle_pkey: + type: PRIMARY KEY + column: oid + t_unite_fonctionnelle_ukey1: + type: UNIQUE + column: code +indexes: + i_unite_fonctionnelle_1: + column: code + method: btree + i_unite_fonctionnelle_2: + column: code_original + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_validation_parametre.yaml b/db/schema2/tables/t_validation_parametre.yaml new file mode 100644 index 0000000..1a777c3 --- /dev/null +++ b/db/schema2/tables/t_validation_parametre.yaml @@ -0,0 +1,30 @@ +columns: + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_validation_parametre'::regclass)" + parametre_code: + type: text + parametre_date: + type: date + default: now() + parametre_id: + type: bigint + default: "0" + parametre_texte: + type: text + parametre_valide: + type: text + default: "'0'::text" + table_id: + type: bigint + not_null: NOT NULL + default: "0" +constraints: + t_validation_parametre_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_validation_parametre_table_id: + column: table_id + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_ventilation.yaml b/db/schema2/tables/t_ventilation.yaml new file mode 100644 index 0000000..92d3039 --- /dev/null +++ b/db/schema2/tables/t_ventilation.yaml @@ -0,0 +1,17 @@ +columns: + code: + type: text + not_null: NOT NULL + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_ventilation'::regclass)" + texte: + type: text +constraints: + t_ventilation_pkey: + type: PRIMARY KEY + column: oid + t_ventilation_ukey: + type: UNIQUE + column: code \ No newline at end of file diff --git a/db/schema2/tables/t_vue_parametre.yaml b/db/schema2/tables/t_vue_parametre.yaml new file mode 100644 index 0000000..3a69be2 --- /dev/null +++ b/db/schema2/tables/t_vue_parametre.yaml @@ -0,0 +1,30 @@ +columns: + code: + type: text + data_code: + type: 'text[]' + data_description: + type: 'text[]' + data_entete: + type: 'text[]' + data_format: + type: 'text[]' + oid: + type: bigint + not_null: NOT NULL + default: "nextval('s_vue_parametre'::regclass)" + position_ratio: + type: character(15) + default: "'000000000000000'::character varying" + rang: + type: integer + texte: + type: text +constraints: + t_vue_parametre_pkey: + type: PRIMARY KEY + column: oid +indexes: + i_vue_parametre: + column: code + method: btree \ No newline at end of file diff --git a/db/schema2/tables/t_widget_user_parameter.yaml b/db/schema2/tables/t_widget_user_parameter.yaml new file mode 100644 index 0000000..402e2c2 --- /dev/null +++ b/db/schema2/tables/t_widget_user_parameter.yaml @@ -0,0 +1,34 @@ +columns: + dashboard_widget_id: + type: bigint + h: + type: numeric + include_series_id: + type: 'bigint[]' + max_cat: + type: bigint + default: "0" + oid: + type: text + not_null: NOT NULL + tab_id: + type: bigint + time_calc: + type: text + title: + type: text + username: + type: text + visible: + type: boolean + default: 'false' + w: + type: numeric + x: + type: numeric + y: + type: numeric +constraints: + _widget_user_parameter_pkey: + type: PRIMARY KEY + column: oid \ No newline at end of file diff --git a/db/schema2/views/v_accident_circonstance_1.yaml b/db/schema2/views/v_accident_circonstance_1.yaml new file mode 100644 index 0000000..91060ec --- /dev/null +++ b/db/schema2/views/v_accident_circonstance_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ATC'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ATC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATC'::text + UNION ALL + SELECT 'DT'::text || t_accident_circonstance.oid::text AS oid, + (t_accident_circonstance.code::text || ' '::text) || t_accident_circonstance.texte_court::text AS texte, + t_accident_circonstance.code, + '1'::text AS level, + '9'::text || t_accident_circonstance.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_accident_circonstance + WHERE (t_accident_circonstance.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'accident_circonstance'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_accident_circonstance_2.yaml b/db/schema2/views/v_accident_circonstance_2.yaml new file mode 100644 index 0000000..5e94df7 --- /dev/null +++ b/db/schema2/views/v_accident_circonstance_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_accident_circonstance.oid AS accident_circonstance_id, + t_accident_circonstance.code AS accident_circonstance_code, + t_accident_circonstance.texte AS accident_circonstance_texte, + t_accident_circonstance.section_id AS accident_circonstance_section_id, + t_accident_circonstance.section_code AS accident_circonstance_section_code, + t_accident_circonstance.section_texte AS accident_circonstance_section_texte + FROM rh.t_accident_circonstance; \ No newline at end of file diff --git a/db/schema2/views/v_accident_lieu_1.yaml b/db/schema2/views/v_accident_lieu_1.yaml new file mode 100644 index 0000000..d18f066 --- /dev/null +++ b/db/schema2/views/v_accident_lieu_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ATL'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ATL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATL'::text + UNION ALL + SELECT 'DT'::text || t_accident_lieu.oid::text AS oid, + (t_accident_lieu.code::text || ' '::text) || t_accident_lieu.texte_court::text AS texte, + t_accident_lieu.code, + '1'::text AS level, + '9'::text || t_accident_lieu.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_accident_lieu + WHERE (t_accident_lieu.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'accident_lieu'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_accident_lieu_2.yaml b/db/schema2/views/v_accident_lieu_2.yaml new file mode 100644 index 0000000..ccd3b76 --- /dev/null +++ b/db/schema2/views/v_accident_lieu_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_accident_lieu.oid AS accident_lieu_id, + t_accident_lieu.code AS accident_lieu_code, + t_accident_lieu.texte AS accident_lieu_texte, + t_accident_lieu.section_id AS accident_lieu_section_id, + t_accident_lieu.section_code AS accident_lieu_section_code, + t_accident_lieu.section_texte AS accident_lieu_section_texte + FROM rh.t_accident_lieu; \ No newline at end of file diff --git a/db/schema2/views/v_accident_nature_1.yaml b/db/schema2/views/v_accident_nature_1.yaml new file mode 100644 index 0000000..f36b8d5 --- /dev/null +++ b/db/schema2/views/v_accident_nature_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ATN'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATN'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ATN'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATN'::text + UNION ALL + SELECT 'DT'::text || t_accident_nature.oid::text AS oid, + (t_accident_nature.code::text || ' '::text) || t_accident_nature.texte_court::text AS texte, + t_accident_nature.code, + '1'::text AS level, + '9'::text || t_accident_nature.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_accident_nature + WHERE (t_accident_nature.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'accident_nature'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_accident_nature_2.yaml b/db/schema2/views/v_accident_nature_2.yaml new file mode 100644 index 0000000..674706f --- /dev/null +++ b/db/schema2/views/v_accident_nature_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_accident_nature.oid AS accident_nature_id, + t_accident_nature.code AS accident_nature_code, + t_accident_nature.texte AS accident_nature_texte, + t_accident_nature.section_id AS accident_nature_section_id, + t_accident_nature.section_code AS accident_nature_section_code, + t_accident_nature.section_texte AS accident_nature_section_texte + FROM rh.t_accident_nature; \ No newline at end of file diff --git a/db/schema2/views/v_accident_siege_1.yaml b/db/schema2/views/v_accident_siege_1.yaml new file mode 100644 index 0000000..c6ea867 --- /dev/null +++ b/db/schema2/views/v_accident_siege_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ATS'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATS'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ATS'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ATS'::text + ) UNION + SELECT 'DT'::text || t_accident_siege.oid::text AS oid, + (t_accident_siege.code::text || ' '::text) || t_accident_siege.texte_court::text AS texte, + t_accident_siege.code, + '1'::text AS level, + '9'::text || t_accident_siege.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_accident_siege + WHERE (t_accident_siege.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'accident_siege'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_accident_siege_2.yaml b/db/schema2/views/v_accident_siege_2.yaml new file mode 100644 index 0000000..6e68ee2 --- /dev/null +++ b/db/schema2/views/v_accident_siege_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_accident_siege.oid AS accident_siege_id, + t_accident_siege.code AS accident_siege_code, + t_accident_siege.texte AS accident_siege_texte, + t_accident_siege.section_id AS accident_siege_section_id, + t_accident_siege.section_code AS accident_siege_section_code, + t_accident_siege.section_texte AS accident_siege_section_texte + FROM rh.t_accident_siege; \ No newline at end of file diff --git a/db/schema2/views/v_accident_travail_1.yaml b/db/schema2/views/v_accident_travail_1.yaml new file mode 100644 index 0000000..eb4f8dc --- /dev/null +++ b/db/schema2/views/v_accident_travail_1.yaml @@ -0,0 +1,107 @@ +src: | + SELECT p_accident_travail.oid AS accident_travail_id, + p_accident_travail.oid AS accident_travail_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS accident_travail_texte, + p_accident_travail.mois_activite AS mois_accident_travail, + p_accident_travail.date AS date_accident_travail, + p_accident_travail.accident_circonstance_id AS rhp_accident_circonstance_id, + p_accident_travail.accident_lieu_id AS rhp_accident_lieu_id, + p_accident_travail.accident_nature_id AS rhp_accident_nature_id, + p_accident_travail.accident_siege_id AS rhp_accident_siege_id, + p_salaries.finess, + p_contrats_mois.etablissement_id AS rhp_etablissement_id, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.code_original, + p_salaries.entreprise_id AS rhp_entreprise_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_reprise_mois, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_contrats_mois.age_id AS rhp_age_id, + p_contrats_mois.age_jours, + p_contrats_mois.mois_activite::bigint AS annee_mois_activite_id, + p_contrats_mois.mois_activite::text AS annee_mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_mois_activite_texte, + (substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text)::bigint AS annee_trimestre_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_contrats_mois.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_contrats_mois.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, p_contrats_mois.date_fin)::bigint AS trimestre_activite_id, + date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_texte, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.mois_activite AS mois_activite_id, + p_contrats_mois.mois_activite AS mois_activite_code, + ( + CASE + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 1::double precision THEN 'Janvier'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 2::double precision THEN 'Février'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 3::double precision THEN 'Mars'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 4::double precision THEN 'Avril'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 5::double precision THEN 'Mai'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 6::double precision THEN 'Juin'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 7::double precision THEN 'Juillet'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 8::double precision THEN 'Aout'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 9::double precision THEN 'Septembre'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 10::double precision THEN 'Octobre'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 11::double precision THEN 'Novembre'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 12::double precision THEN 'Décembre'::text + ELSE date_part('month'::text, p_contrats_mois.date_fin)::text + END || ' '::text) || date_part('year'::text, p_contrats_mois.date_fin)::text AS mois_activite_texte, + date_part('year'::text, p_contrats_mois.date_fin) AS annee_activite_id, + date_part('year'::text, p_contrats_mois.date_fin) AS annee_activite_code, + date_part('year'::text, p_contrats_mois.date_fin) AS annee_activite_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_profil_contrat_mois.pole_id AS rhp_pole_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_salaries + JOIN rh.p_accident_travail ON p_accident_travail.salarie_id = p_salaries.oid + JOIN rh.p_contrats ON p_contrats.oid = p_accident_travail.contrat_id + JOIN rh.p_contrats_mois ON p_contrats_mois.oid = p_accident_travail.contrat_mois_id + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/db/schema2/views/v_ages_1.yaml b/db/schema2/views/v_ages_1.yaml new file mode 100644 index 0000000..10a349a --- /dev/null +++ b/db/schema2/views/v_ages_1.yaml @@ -0,0 +1,72 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + '#LI'::text || v_listes_1.code AS alias, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'AGE'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '#LC'::text || t_classes.code AS alias, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'AGE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '#LS'::text || t_classes_sections.code AS alias, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'AGE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '#LS'::text || chr(255) AS alias, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'AGE'::text + ) UNION + SELECT 'DT'::text || t_ages.oid::text AS oid, + t_ages.texte::text AS texte, + t_ages.code, + '1'::text AS level, + '#DT'::text || t_ages.code::text AS alias, + '9'::text || t_ages.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_ages + WHERE (t_ages.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'ages'::text)) + ORDER BY 6; \ No newline at end of file diff --git a/db/schema2/views/v_ages_2.yaml b/db/schema2/views/v_ages_2.yaml new file mode 100644 index 0000000..be2d88e --- /dev/null +++ b/db/schema2/views/v_ages_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_ages.oid AS age_id, + t_ages.code AS age_code, + t_ages.texte AS age_texte, + t_ages.section_id AS age_section_id, + t_ages.section_code AS age_section_code, + t_ages.section_texte AS age_section_texte + FROM rh.t_ages; \ No newline at end of file diff --git a/db/schema2/views/v_alias_periode_1.yaml b/db/schema2/views/v_alias_periode_1.yaml new file mode 100644 index 0000000..6b9b7f7 --- /dev/null +++ b/db/schema2/views/v_alias_periode_1.yaml @@ -0,0 +1,873 @@ +src: | + WITH ctl_dates AS ( + SELECT subq.now, + to_char(subq.now::timestamp with time zone, 'DD/MM/YYYY'::text) AS now_l, + subq.nowcloture, + (subq.now - '6 days'::interval)::date AS now_7, + date_trunc('YEAR'::text, subq.nowcloture::timestamp with time zone)::date AS first_day_current_year, + CASE subq.nowcloture + WHEN (date_trunc('MONTH'::text, subq.nowcloture::timestamp with time zone)::date + '1 mon -1 days'::interval)::date THEN subq.nowcloture + ELSE (date_trunc('MONTH'::text, subq.nowcloture::timestamp with time zone)::date - '1 day'::interval)::date + END AS last_day_of_last_month, + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN subq.nowcloture::timestamp without time zone + ELSE to_date(to_char(subq.nowcloture::timestamp with time zone, 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text) - '7 days'::interval + END::date AS last_day_of_last_week, + to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '-1'::text + ELSE '0'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text) AS last_day_of_week_0, + to_char(to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '-1'::text + ELSE '0'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS last_day_of_weekn_0, + to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '0'::text + ELSE '1'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text) AS last_day_of_week_1, + to_char(to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '0'::text + ELSE '1'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS last_day_of_weekn_1, + to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '1'::text + ELSE '2'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text) AS last_day_of_week_2, + to_char(to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '1'::text + ELSE '2'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS last_day_of_weekn_2, + to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '2'::text + ELSE '3'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text) AS last_day_of_week_3, + to_char(to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '2'::text + ELSE '3'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS last_day_of_weekn_3, + to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '3'::text + ELSE '4'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text) AS last_day_of_week_4, + to_char(to_date(to_char(subq.nowcloture - (( + CASE to_char(subq.nowcloture::timestamp with time zone, 'ID'::text) + WHEN '7'::text THEN '3'::text + ELSE '4'::text + END || ' week'::text)::interval), 'IYYYIW'::text) || '7'::text, 'IYYYIWID'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS last_day_of_weekn_4, + CASE + WHEN to_char(subq.nowcloture::timestamp with time zone, 'DD'::text) = base.cti_last_day(subq.nowcloture)::text THEN subq.nowcloture + WHEN to_char(subq.nowcloture::timestamp with time zone, 'DD'::text) >= 20::text THEN to_date(to_char(subq.nowcloture::timestamp with time zone, 'YYYYMM'::text) || '20'::text, 'YYYYMMDD'::text) + WHEN to_char(subq.nowcloture::timestamp with time zone, 'DD'::text) >= 10::text THEN to_date(to_char(subq.nowcloture::timestamp with time zone, 'YYYYMM'::text) || '10'::text, 'YYYYMMDD'::text) + ELSE base.cti_last_day((subq.nowcloture - '1 mon'::interval)::date) + END AS decade_last, + base.cti_last_day(subq.nowcloture) AS decade_0, + to_date(to_char(subq.nowcloture::timestamp with time zone, 'YYYYMM'::text) || '20'::text, 'YYYYMMDD'::text) AS decade_1, + to_date(to_char(subq.nowcloture::timestamp with time zone, 'YYYYMM'::text) || '10'::text, 'YYYYMMDD'::text) AS decade_2, + base.cti_last_day((subq.nowcloture - '1 mon'::interval)::date) AS decade_3, + to_date(to_char(subq.nowcloture - '1 mon'::interval, 'YYYYMM'::text) || '20'::text, 'YYYYMMDD'::text) AS decade_4, + to_date(to_char(subq.nowcloture - '1 mon'::interval, 'YYYYMM'::text) || '10'::text, 'YYYYMMDD'::text) AS decade_5, + base.cti_last_day((subq.nowcloture - '2 mons'::interval)::date) AS decade_6, + to_char(base.cti_last_day(subq.nowcloture)::timestamp with time zone, 'DD/MM/YYYY'::text) AS decade_0_l, + to_char(to_date(to_char(subq.nowcloture::timestamp with time zone, 'YYYYMM'::text) || '20'::text, 'YYYYMMDD'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS decade_1_l, + to_char(to_date(to_char(subq.nowcloture::timestamp with time zone, 'YYYYMM'::text) || '10'::text, 'YYYYMMDD'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS decade_2_l, + to_char(base.cti_last_day((subq.nowcloture - '1 mon'::interval)::date)::timestamp with time zone, 'DD/MM/YYYY'::text) AS decade_3_l, + to_char(to_date(to_char(subq.nowcloture - '1 mon'::interval, 'YYYYMM'::text) || '20'::text, 'YYYYMMDD'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS decade_4_l, + to_char(to_date(to_char(subq.nowcloture - '1 mon'::interval, 'YYYYMM'::text) || '10'::text, 'YYYYMMDD'::text)::timestamp with time zone, 'DD/MM/YYYY'::text) AS decade_5_l, + to_char(base.cti_last_day((subq.nowcloture - '2 mons'::interval)::date)::timestamp with time zone, 'DD/MM/YYYY'::text) AS decade_6_l + FROM ( SELECT max( + CASE + WHEN t_divers.code = 'NOW'::text THEN t_divers.valeur_date + ELSE NULL::date + END) AS now, + max( + CASE + WHEN t_divers.code = 'NOWCLOTURE'::text THEN t_divers.valeur_date + ELSE NULL::date + END) AS nowcloture + FROM rh.t_divers + WHERE t_divers.code = ANY (ARRAY['NOW'::text, 'NOWCLOTURE'::text])) subq + ) + SELECT 1000 AS tri, + 1 AS lvl, + 'Cumul au dernier mois'::text AS txt, + 'CUM_LAST_MONTH'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.last_day_of_last_month AS fin + FROM ctl_dates + UNION + SELECT 1001 AS tri, + 2 AS lvl, + ('Janvier à décembre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '12'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '12'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_DEC'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1201'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1002 AS tri, + 2 AS lvl, + ('Janvier à novembre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '11'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '11'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_NOV'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1101'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1003 AS tri, + 2 AS lvl, + ('Janvier à octobre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '10'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '10'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_OCT'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1001'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1004 AS tri, + 2 AS lvl, + ('Janvier à septembre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '09'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '09'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_SEP'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0901'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1005 AS tri, + 2 AS lvl, + ('Janvier à août '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '08'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '08'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_AUG'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0801'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1006 AS tri, + 2 AS lvl, + ('Janvier à juillet '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '07'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '07'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_JUL'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0701'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1007 AS tri, + 2 AS lvl, + ('Janvier à juin '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '06'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '06'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_JUN'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0601'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1008 AS tri, + 2 AS lvl, + ('Janvier à mai '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '05'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '05'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_MAY'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0501'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1009 AS tri, + 2 AS lvl, + ('Janvier à avril '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '04'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '04'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_APR'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0401'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1010 AS tri, + 2 AS lvl, + ('Janvier à mars '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '03'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '03'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_MAR'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0301'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1011 AS tri, + 2 AS lvl, + ('Janvier à février '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '02'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '02'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_FEB'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0201'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 1012 AS tri, + 2 AS lvl, + ('Janvier à janvier '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '01'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '01'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'CURRENT_YEAR_JAN'::text AS cod, + ctl_dates.first_day_current_year AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0101'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 2000 AS tri, + 1 AS lvl, + 'Cumul à dernière décade'::text AS txt, + 'CUM_LAST_DECADE'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_last AS fin + FROM ctl_dates + UNION + SELECT 2001 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.decade_0_l AS txt, + 'CUM_LAST_DECADE_0'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_0 AS fin + FROM ctl_dates + UNION + SELECT 2002 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.decade_1_l AS txt, + 'CUM_LAST_DECADE_1'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_1 AS fin + FROM ctl_dates + UNION + SELECT 2003 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.decade_2_l AS txt, + 'CUM_LAST_DECADE_2'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_2 AS fin + FROM ctl_dates + UNION + SELECT 2004 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.decade_3_l AS txt, + 'CUM_LAST_DECADE_3'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_3 AS fin + FROM ctl_dates + UNION + SELECT 2005 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.decade_4_l AS txt, + 'CUM_LAST_DECADE_4'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_4 AS fin + FROM ctl_dates + UNION + SELECT 2006 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.decade_5_l AS txt, + 'CUM_LAST_DECADE_5'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_5 AS fin + FROM ctl_dates + UNION + SELECT 2007 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.decade_6_l AS txt, + 'CUM_LAST_DECADE_6'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.decade_6 AS fin + FROM ctl_dates + UNION + SELECT 3000 AS tri, + 1 AS lvl, + 'Cumul à dernière semaine'::text AS txt, + 'CUM_LAST_WEEK'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.last_day_of_last_week AS fin + FROM ctl_dates + UNION + SELECT 3001 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.last_day_of_weekn_0 AS txt, + 'CUM_LAST_MONTH_W0'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.last_day_of_week_0 AS fin + FROM ctl_dates + UNION + SELECT 3002 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.last_day_of_weekn_1 AS txt, + 'CUM_LAST_MONTH_W1'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.last_day_of_week_1 AS fin + FROM ctl_dates + UNION + SELECT 3003 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.last_day_of_weekn_2 AS txt, + 'CUM_LAST_MONTH_W2'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.last_day_of_week_2 AS fin + FROM ctl_dates + UNION + SELECT 3004 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.last_day_of_weekn_3 AS txt, + 'CUM_LAST_MONTH_W3'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.last_day_of_week_3 AS fin + FROM ctl_dates + UNION + SELECT 3005 AS tri, + 2 AS lvl, + 'Cumul au '::text || ctl_dates.last_day_of_weekn_4 AS txt, + 'CUM_LAST_MONTH_W4'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.last_day_of_week_4 AS fin + FROM ctl_dates + UNION + SELECT 4000 AS tri, + 1 AS lvl, + 'Cumul au '::text || ctl_dates.now_l AS txt, + 'CUM_NOW'::text AS cod, + ctl_dates.first_day_current_year AS deb, + ctl_dates.now AS fin + FROM ctl_dates + UNION + SELECT 4500 AS tri, + 1 AS lvl, + '12 derniers mois glissants'::text AS txt, + 'CUM_LAST_12_MONTH'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.last_day_of_last_month - '11 mons'::interval)::date AS deb, + ctl_dates.last_day_of_last_month AS fin + FROM ctl_dates + UNION + SELECT 4501 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '11 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(ctl_dates.now::timestamp with time zone, 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_0'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '11 mons'::interval)::date AS deb, + base.cti_last_day(ctl_dates.now) AS fin + FROM ctl_dates + UNION + SELECT 4502 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 mon'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_1'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '1 mon'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4503 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 1 mon'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '2 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_2'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 1 mon'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '2 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4504 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 2 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '3 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_3'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 2 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '3 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4505 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 3 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '4 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_4'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 3 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '4 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4506 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 4 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '5 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_5'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 4 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '5 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4507 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 5 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '6 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_6'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 5 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '6 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4508 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 6 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '7 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_7'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 6 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '7 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4509 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 7 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '8 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_8'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 7 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '8 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4510 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 8 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '9 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_9'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 8 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '9 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4511 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 9 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '10 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_10'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 9 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '10 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 4512 AS tri, + 2 AS lvl, + (base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '1 year 10 mons'::interval), 'Month'::text)) || ' à '::text) || base.cti_to_french(to_char(date_trunc('MONTH'::text, ctl_dates.now - '11 mons'::interval), 'Month YYYY'::text)) AS txt, + 'CUM_LAST_12_MONTH_11'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.now - '1 year 10 mons'::interval)::date AS deb, + base.cti_last_day(date_trunc('MONTH'::text, ctl_dates.now - '11 mons'::interval)::date) AS fin + FROM ctl_dates + UNION + SELECT 5000 AS tri, + 1 AS lvl, + '7 derniers jours'::text AS txt, + 'LAST_7_DAYS'::text AS cod, + ctl_dates.now_7 AS deb, + ctl_dates.now AS fin + FROM ctl_dates + UNION + SELECT 7000 AS tri, + 1 AS lvl, + 'Cumul année précédente'::text AS txt, + 'LAST_YEAR'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1201'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7001 AS tri, + 2 AS lvl, + 'Janvier à décembre '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_DEC'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1201'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7002 AS tri, + 2 AS lvl, + 'Janvier à novembre '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_NOV'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1101'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7003 AS tri, + 2 AS lvl, + 'Janvier à octobre '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_OCT'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1001'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7004 AS tri, + 2 AS lvl, + 'Janvier à septembre '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_SEP'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0901'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7005 AS tri, + 2 AS lvl, + 'Janvier à août '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_AUG'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0801'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7006 AS tri, + 2 AS lvl, + 'Janvier à juillet '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_JUL'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0701'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7007 AS tri, + 2 AS lvl, + 'Janvier à juin '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_JUN'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0601'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7008 AS tri, + 2 AS lvl, + 'Janvier à mai '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_MAY'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0501'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7009 AS tri, + 2 AS lvl, + 'Janvier à avril '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_APR'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0401'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7010 AS tri, + 2 AS lvl, + 'Janvier à mars '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_MAR'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0301'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7011 AS tri, + 2 AS lvl, + 'Janvier à février '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_FEB'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0201'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 7012 AS tri, + 2 AS lvl, + 'Janvier à janvier '::text || to_char(ctl_dates.first_day_current_year - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_JAN'::text AS cod, + (ctl_dates.first_day_current_year - '1 year'::interval)::date AS deb, + (base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0101'::text)::date) - '1 year'::interval)::date AS fin + FROM ctl_dates + UNION + SELECT 8000 AS tri, + 1 AS lvl, + 'Dernier semestre'::text AS txt, + 'LAST_HALF'::text AS cod, + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text)::integer >= 7 THEN ctl_dates.first_day_current_year + ELSE (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0701'::text)::date + END AS deb, + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text)::integer >= 7 THEN (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0630'::text)::date + ELSE (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '1231'::text)::date + END AS fin + FROM ctl_dates + UNION + SELECT 8001 AS tri, + 2 AS lvl, + '1ème semestre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) AS txt, + 'HALF_1'::text AS cod, + ctl_dates.first_day_current_year AS deb, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0630'::text)::date AS fin + FROM ctl_dates + WHERE to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text)::integer >= 7 + UNION + SELECT 8002 AS tri, + 2 AS lvl, + '2ème semestre '::text || to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_HALF_2'::text AS cod, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0701'::text)::date AS deb, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '1231'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 8003 AS tri, + 2 AS lvl, + '1er semestre '::text || to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_HALF_1'::text AS cod, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0101'::text)::date AS deb, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0630'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 9000 AS tri, + 1 AS lvl, + 'Dernier trimestre'::text AS txt, + 'LAST_QUARTER'::text AS cod, + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text)::integer >= 10 THEN (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0701'::text)::date + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text)::integer >= 7 THEN (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0401'::text)::date + ELSE ctl_dates.first_day_current_year + END AS deb, + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text)::integer >= 10 THEN (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0930'::text)::date + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text)::integer >= 7 THEN (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0630'::text)::date + ELSE (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0331'::text)::date + END AS fin + FROM ctl_dates + UNION + SELECT 9002 AS tri, + 2 AS lvl, + '3ème trimestre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) AS txt, + 'QUARTER_3'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0701'::text)::date AS deb, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0930'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 9003 AS tri, + 2 AS lvl, + '2ème trimestre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) AS txt, + 'QUARTER_2'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0401'::text)::date AS deb, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0630'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 9004 AS tri, + 2 AS lvl, + '1er trimestre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) AS txt, + 'QUARTER_1'::text AS cod, + ctl_dates.first_day_current_year AS deb, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0331'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 9011 AS tri, + 2 AS lvl, + '4ème trimestre '::text || to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_QUARTER_4'::text AS cod, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '1001'::text)::date AS deb, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '1231'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 9012 AS tri, + 2 AS lvl, + '3ème trimestre '::text || to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_QUARTER_3'::text AS cod, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0701'::text)::date AS deb, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0930'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 9013 AS tri, + 2 AS lvl, + '2ème trimestre '::text || to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_QUARTER_2'::text AS cod, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0401'::text)::date AS deb, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0630'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 9014 AS tri, + 2 AS lvl, + '1er trimestre '::text || to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) AS txt, + 'LAST_YEAR_QUARTER_1'::text AS cod, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0101'::text)::date AS deb, + (to_char(ctl_dates.nowcloture - '1 year'::interval, 'YYYY'::text) || '0331'::text)::date AS fin + FROM ctl_dates + UNION + SELECT 10000 AS tri, + 1 AS lvl, + 'Dernier mois'::text AS txt, + 'LAST_MONTH'::text AS cod, + date_trunc('MONTH'::text, ctl_dates.last_day_of_last_month::timestamp with time zone)::date AS deb, + ctl_dates.last_day_of_last_month AS fin + FROM ctl_dates + UNION + SELECT 10001 AS tri, + 2 AS lvl, + ('Décembre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '12'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '12'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_DEC'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1201'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1201'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10002 AS tri, + 2 AS lvl, + ('Novembre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '11'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '11'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_NOV'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1101'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1101'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10003 AS tri, + 2 AS lvl, + ('Octobre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '10'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '10'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_OCT'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1001'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '1001'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10004 AS tri, + 2 AS lvl, + ('Septembre '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '09'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '09'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_SEP'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0901'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0901'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10005 AS tri, + 2 AS lvl, + ('Août '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '08'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '08'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_AUG'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0801'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0801'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10006 AS tri, + 2 AS lvl, + ('Juillet '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '07'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '07'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_JUL'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0701'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0701'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10007 AS tri, + 2 AS lvl, + ('Juin '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '06'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '06'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_JUN'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0601'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0601'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10008 AS tri, + 2 AS lvl, + ('Mai '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '05'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '05'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_MAY'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0501'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0501'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10009 AS tri, + 2 AS lvl, + ('Avril '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '04'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '04'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_APR'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0401'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0401'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10010 AS tri, + 2 AS lvl, + ('Mars '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '03'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '03'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_MAR'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0301'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0301'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10011 AS tri, + 2 AS lvl, + ('Février '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '02'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '02'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_FEB'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0201'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0201'::text)::date) AS fin + FROM ctl_dates + UNION + SELECT 10012 AS tri, + 2 AS lvl, + ('Janvier '::text || to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text)) || + CASE + WHEN to_char(ctl_dates.nowcloture::timestamp with time zone, 'MM'::text) = '01'::text THEN ' - Mois clôturé'::text + WHEN to_char(ctl_dates.now::timestamp with time zone, 'YYYYMM'::text) = (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '01'::text) THEN ' - Mois en cours'::text + ELSE ''::text + END AS txt, + 'MONTH_JAN'::text AS cod, + (to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0101'::text)::date AS deb, + base.cti_last_day((to_char(ctl_dates.nowcloture::timestamp with time zone, 'YYYY'::text) || '0101'::text)::date) AS fin + FROM ctl_dates + ORDER BY 1; \ No newline at end of file diff --git a/db/schema2/views/v_anciennetes_annee_1.yaml b/db/schema2/views/v_anciennetes_annee_1.yaml new file mode 100644 index 0000000..0fc17a0 --- /dev/null +++ b/db/schema2/views/v_anciennetes_annee_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ANC'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ANC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ANC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ANC'::text + ) UNION + SELECT 'DT'::text || t_anciennetes_annee.oid::text AS oid, + t_anciennetes_annee.texte::text AS texte, + t_anciennetes_annee.code, + '1'::text AS level, + '9'::text || t_anciennetes_annee.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_anciennetes_annee + WHERE (t_anciennetes_annee.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'anciennetes_annee'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_anciennetes_annee_2.yaml b/db/schema2/views/v_anciennetes_annee_2.yaml new file mode 100644 index 0000000..00d5eb0 --- /dev/null +++ b/db/schema2/views/v_anciennetes_annee_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_anciennetes_annee.oid AS anciennete_annee_id, + t_anciennetes_annee.code AS anciennete_annee_code, + t_anciennetes_annee.texte AS anciennete_annee_texte, + t_anciennetes_annee.section_id AS anciennete_annee_section_id, + t_anciennetes_annee.section_code AS anciennete_annee_section_code, + t_anciennetes_annee.section_texte AS anciennete_annee_section_texte + FROM rh.t_anciennetes_annee; \ No newline at end of file diff --git a/db/schema2/views/v_arrets_travail_mois_1.yaml b/db/schema2/views/v_arrets_travail_mois_1.yaml new file mode 100644 index 0000000..2669c6a --- /dev/null +++ b/db/schema2/views/v_arrets_travail_mois_1.yaml @@ -0,0 +1,101 @@ +src: | + SELECT p_salaries.finess, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.code_original, + p_salaries.entreprise_id AS rhp_entreprise_id, + p_contrats_mois.etablissement_id AS rhp_etablissement_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.mois_activite::bigint AS mois_activite_id, + p_contrats_mois.mois_activite::text AS mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS mois_activite_texte, + p_contrats_mois.mois_activite::bigint AS annee_mois_activite_id, + p_contrats_mois.mois_activite::text AS annee_mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_mois_activite_texte, + (substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text)::bigint AS annee_trimestre_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_contrats_mois.mois_activite::text, 1, 4)::bigint AS annee_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_code, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_texte, + substr(p_contrats_mois.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_contrats_mois.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, p_contrats_mois.date_fin)::bigint AS trimestre_activite_id, + date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_arrets_travail_mois.arret_travail_id, + p_salaries.matricule AS arret_travail_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS arret_travail_texte, + p_arrets_travail.date_debut AS date_debut_arret, + p_arrets_travail.date_fin AS date_fin_arret, + p_arrets_travail.date_reprise AS date_reprise_apres_arret, + p_arrets_travail_mois.nb_arret, + p_arrets_travail_mois.nb_debut_arret, + p_arrets_travail_mois.nb_fin_arret, + p_arrets_travail_mois.nb_reprise_apres_arret, + p_arrets_travail_mois.nb_jours * p_profil_contrat_mois.ratio AS nb_jours_arret, + p_arrets_travail_mois.nb_heures * p_profil_contrat_mois.ratio AS nb_heures_arret, + p_arrets_travail.nb_jours AS nb_jours_total, + p_arrets_travail.nb_heures AS nb_heures_total, + p_contrats_mois.age_jours, + p_arrets_travail.motif_arret_id AS rhp_motif_arret_id, + p_arrets_travail.precision_motif_arret_id AS rhp_precision_motif_arret_id, + p_contrats_mois.age_id AS rhp_age_id, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_reprise_mois, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_profil_contrat_mois.profil_id AS rhp_p_profil_id, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id AS rhp_anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id AS rhp_anciennete_fph_annee_id, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_profil_contrat_mois.pole_id AS rhp_pole_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_arrets_travail_mois + JOIN rh.p_arrets_travail ON p_arrets_travail_mois.arret_travail_id = p_arrets_travail.oid + JOIN rh.p_salaries ON p_arrets_travail_mois.salarie_id = p_salaries.oid + JOIN rh.p_contrats ON p_arrets_travail_mois.contrat_id = p_contrats.oid + JOIN rh.p_contrats_mois ON p_arrets_travail_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/db/schema2/views/v_budget_cle_1.yaml b/db/schema2/views/v_budget_cle_1.yaml new file mode 100644 index 0000000..17d5974 --- /dev/null +++ b/db/schema2/views/v_budget_cle_1.yaml @@ -0,0 +1,69 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + '#LI'::text || v_listes_1.code AS alias, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'BUD'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '#LC'::text || t_classes.code AS alias, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'BUD'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '#LS'::text || t_classes_sections.code AS alias, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'BUD'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '#LS'::text || chr(255) AS alias, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'BUD'::text + ) UNION + SELECT 'DT'::text || t_budget_cle.oid::text AS oid, + t_budget_cle.texte, + t_budget_cle.code, + '1'::text AS level, + '#DT'::text || t_budget_cle.code AS alias, + '9'::text || t_budget_cle.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_budget_cle + ORDER BY 6; \ No newline at end of file diff --git a/db/schema2/views/v_budget_cle_2.yaml b/db/schema2/views/v_budget_cle_2.yaml new file mode 100644 index 0000000..cd6bc0e --- /dev/null +++ b/db/schema2/views/v_budget_cle_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_budget_cle.oid AS budget_cle_id, + t_budget_cle.code AS budget_cle_code, + t_budget_cle.texte AS budget_cle_texte, + t_budget_cle.section_id AS budget_cle_section_id, + t_budget_cle.section_code AS budget_cle_section_code, + t_budget_cle.section_texte AS budget_cle_section_texte + FROM rh.t_budget_cle; \ No newline at end of file diff --git a/db/schema2/views/v_budget_cle_budget_r_1.yaml b/db/schema2/views/v_budget_cle_budget_r_1.yaml new file mode 100644 index 0000000..884de7d --- /dev/null +++ b/db/schema2/views/v_budget_cle_budget_r_1.yaml @@ -0,0 +1,16 @@ +src: | + SELECT 0::bigint AS finess_id, + t_budget_cle_budget.budget_id, + t_budget_cle_budget.date AS date_reference, + t_budget_cle_budget.budget_cle_id AS rhp_budget_cle_id, + t_budget_cle.code AS budget_cle_code, + t_budget_cle.texte AS budget_cle_texte, + t_budget_cle.section_id AS budget_cle_section_id, + t_budget_cle.section_code AS budget_cle_section_code, + t_budget_cle.section_texte AS budget_cle_section_texte, + t_budget_cle_budget.indicateur_module, + t_budget_cle_budget.indicateur_id, + t_budget_cle_budget.budget, + 0::bigint AS rhp_pole_id + FROM rh.t_budget_cle_budget + JOIN rh.t_budget_cle ON t_budget_cle_budget.budget_cle_id = t_budget_cle.oid; \ No newline at end of file diff --git a/db/schema2/views/v_cadre_emploi_1.yaml b/db/schema2/views/v_cadre_emploi_1.yaml new file mode 100644 index 0000000..c9fa793 --- /dev/null +++ b/db/schema2/views/v_cadre_emploi_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'CAE'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CAE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'CAE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CAE'::text + UNION ALL + SELECT 'DT'::text || t_cadre_emploi.oid::text AS oid, + (t_cadre_emploi.code || ' '::text) || t_cadre_emploi.texte_court::text AS texte, + t_cadre_emploi.code, + '1'::text AS level, + '9'::text || t_cadre_emploi.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_cadre_emploi + WHERE (t_cadre_emploi.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'cadre_emploi'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_categorie_conge_1.yaml b/db/schema2/views/v_categorie_conge_1.yaml new file mode 100644 index 0000000..33c7eee --- /dev/null +++ b/db/schema2/views/v_categorie_conge_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'CAC'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CAC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'CAC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CAC'::text + UNION ALL + SELECT 'DT'::text || t_categorie_conge.oid::text AS oid, + (t_categorie_conge.code::text || ' '::text) || t_categorie_conge.texte_court::text AS texte, + t_categorie_conge.code, + '1'::text AS level, + '9'::text || t_categorie_conge.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_categorie_conge + WHERE (t_categorie_conge.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'categorie_conge'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_categorie_statutaire_1.yaml b/db/schema2/views/v_categorie_statutaire_1.yaml new file mode 100644 index 0000000..f291389 --- /dev/null +++ b/db/schema2/views/v_categorie_statutaire_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'CAS'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CAS'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'CAS'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CAS'::text + UNION ALL + SELECT 'DT'::text || t_categorie_statutaire.oid::text AS oid, + (t_categorie_statutaire.code::text || ' '::text) || t_categorie_statutaire.texte_court::text AS texte, + t_categorie_statutaire.code, + '1'::text AS level, + '9'::text || t_categorie_statutaire.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_categorie_statutaire + WHERE (t_categorie_statutaire.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'categorie_statutaire'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_categories_socio_professionnelle_1.yaml b/db/schema2/views/v_categories_socio_professionnelle_1.yaml new file mode 100644 index 0000000..945206a --- /dev/null +++ b/db/schema2/views/v_categories_socio_professionnelle_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'CSC'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CSC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'CSC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CSC'::text + UNION ALL + SELECT 'DT'::text || t_categories_socio_professionnelle.oid::text AS oid, + (t_categories_socio_professionnelle.code::text || ' '::text) || t_categories_socio_professionnelle.texte_court::text AS texte, + t_categories_socio_professionnelle.code, + '1'::text AS level, + '9'::text || t_categories_socio_professionnelle.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_categories_socio_professionnelle + WHERE t_categories_socio_professionnelle.oid = 0 OR (t_categories_socio_professionnelle.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'categories_socio_professionnelle'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_classes_1.yaml b/db/schema2/views/v_classes_1.yaml new file mode 100755 index 0000000..92f39e7 --- /dev/null +++ b/db/schema2/views/v_classes_1.yaml @@ -0,0 +1,81 @@ +src: | + SELECT t_listes_tables.oid AS table_id, + 0 AS sequence, + t_listes_tables.texte || + CASE + WHEN count(DISTINCT t_classes.oid) > 0 THEN (' ('::text || count(DISTINCT t_classes.oid)::text) || ')'::text + ELSE ''::text + END AS texte, + t_listes_tables.texte AS sort_1, + '-1'::integer AS sort_2, + 0::bigint AS classe_id, + '1'::text AS lvl, + ''::text AS code, + 'rh'::text AS schema + FROM rh.t_listes_tables + LEFT JOIN rh.t_classes ON t_classes.table_id = t_listes_tables.oid + WHERE t_listes_tables.code = ANY (ARRAY['PNI'::text, 'ANA'::text, 'SER'::text, 'QUA'::text, 'AGE'::text, 'CSC'::text, 'CEM'::text, 'ORC'::text, 'GCT'::text, 'MTD'::text, 'MTF'::text, 'MOA'::text, 'RUP'::text, 'SAP'::text, 'SAC'::text, 'SPE'::text, 'TCN'::text, 'THO'::text, 'CPO'::text, 'ANC'::text, 'SALXXX'::text, 'MVM'::text, 'ATC'::text, 'ATL'::text, 'ATN'::text, 'ATS'::text, 'FOR'::text, 'ETS'::text, 'CAE'::text, 'CAC'::text, 'CAS'::text, 'GCP'::text, 'COI'::text, 'FIL'::text, 'LEB'::text, 'UNF'::text, 'COT'::text, 'GRI'::text, 'GRG'::text, 'SAL'::text, 'STA'::text, 'CPT'::text, 'TTT'::text, 'NAT'::text, 'PSE'::text, 'PQU'::text, 'PAB'::text, 'POP'::text, 'PCH'::text]) + GROUP BY t_listes_tables.oid, t_listes_tables.texte + UNION + SELECT t_classes.table_id, + t_classes.sequence, + t_classes.texte, + t_listes_tables.texte AS sort_1, + t_classes.sequence AS sort_2, + t_classes.oid AS classe_id, + '2'::text AS lvl, + t_classes.code, + 'rh'::text AS schema + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND (t_listes_tables.code = ANY (ARRAY['PNI'::text, 'ANA'::text, 'SER'::text, 'QUA'::text, 'AGE'::text, 'CSC'::text, 'CEM'::text, 'ORC'::text, 'GCT'::text, 'MTD'::text, 'MTF'::text, 'MOA'::text, 'RUP'::text, 'SAP'::text, 'SAC'::text, 'SPE'::text, 'TCN'::text, 'THO'::text, 'CPO'::text, 'ANC'::text, 'SALXXX'::text, 'MVM'::text, 'ATC'::text, 'ATL'::text, 'ATN'::text, 'ATS'::text, 'FOR'::text, 'ETS'::text, 'CAE'::text, 'CAC'::text, 'CAS'::text, 'GCP'::text, 'COI'::text, 'FIL'::text, 'LEB'::text, 'UNF'::text, 'COT'::text, 'GRI'::text, 'GRG'::text, 'SAL'::text, 'STA'::text, 'CPT'::text, 'TTT'::text, 'NAT'::text, 'PSE'::text, 'PQU'::text, 'PAB'::text, 'POP'::text, 'PCH'::text])) AND t_classes.sequence >= 1 + UNION + SELECT t_listes_tables.oid AS table_id, + '-1'::integer AS sequence, + 'Nouvelle classe'::text AS texte, + t_listes_tables.texte AS sort_1, + 0 AS sort_2, + '-1'::integer::bigint AS classe_id, + '2'::text AS lvl, + ''::text AS code, + 'rh'::text AS schema + FROM rh.t_listes_tables + WHERE t_listes_tables.code = ANY (ARRAY['PNI'::text, 'ANA'::text, 'SER'::text, 'QUA'::text, 'AGE'::text, 'CSC'::text, 'CEM'::text, 'ORC'::text, 'GCT'::text, 'MTD'::text, 'MTF'::text, 'MOA'::text, 'RUP'::text, 'SAP'::text, 'SAC'::text, 'SPE'::text, 'TCN'::text, 'THO'::text, 'CPO'::text, 'ANC'::text, 'SALXXX'::text, 'MVM'::text, 'ATC'::text, 'ATL'::text, 'ATN'::text, 'ATS'::text, 'FOR'::text, 'ETS'::text, 'CAE'::text, 'CAC'::text, 'CAS'::text, 'GCP'::text, 'COI'::text, 'FIL'::text, 'LEB'::text, 'UNF'::text, 'COT'::text, 'GRI'::text, 'GRG'::text, 'SAL'::text, 'STA'::text, 'CPT'::text, 'TTT'::text, 'NAT'::text, 'PSE'::text, 'PQU'::text, 'PAB'::text, 'POP'::text, 'PCH'::text]) + UNION + SELECT t_listes_tables.oid AS table_id, + 0 AS sequence, + t_listes_tables.texte, + t_listes_tables.texte AS sort_1, + '-1'::integer AS sort_2, + 0::bigint AS classe_id, + '1'::text AS lvl, + ''::text AS code, + 'base'::text AS schema + FROM base.t_listes_tables + WHERE t_listes_tables.code = ANY (ARRAY['POLE'::text]) + UNION + SELECT t_classes.table_id, + t_classes.sequence, + t_classes.texte, + t_listes_tables.texte AS sort_1, + t_classes.sequence AS sort_2, + t_classes.oid AS classe_id, + '2'::text AS lvl, + t_classes.code, + 'base'::text AS schema + FROM base.t_classes, + base.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND (t_listes_tables.code = ANY (ARRAY['POLE'::text])) AND t_classes.sequence >= 1 + UNION + SELECT t_listes_tables.oid AS table_id, + '-1'::integer AS sequence, + 'Nouvelle classe'::text AS texte, + t_listes_tables.texte AS sort_1, + 0 AS sort_2, + '-1'::integer::bigint AS classe_id, + '2'::text AS lvl, + ''::text AS code, + 'base'::text AS schema + FROM base.t_listes_tables + WHERE t_listes_tables.code = ANY (ARRAY['POLE'::text]) + ORDER BY 4, 5; \ No newline at end of file diff --git a/db/schema2/views/v_code_cotisation_1.yaml b/db/schema2/views/v_code_cotisation_1.yaml new file mode 100644 index 0000000..535549a --- /dev/null +++ b/db/schema2/views/v_code_cotisation_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + ''::text AS code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'COT'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + ''::text AS code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'COT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'COT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'COT'::text + UNION ALL + SELECT 'DT'::text || t_code_cotisation.oid::text AS oid, + (t_code_cotisation.code::text || ' '::text) || t_code_cotisation.texte_court::text AS texte, + t_code_cotisation.code, + '1'::text AS level, + '9'::text || t_code_cotisation.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_code_cotisation + WHERE (t_code_cotisation.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'code_cotisation'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_codes_emploi_1.yaml b/db/schema2/views/v_codes_emploi_1.yaml new file mode 100644 index 0000000..04c235b --- /dev/null +++ b/db/schema2/views/v_codes_emploi_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'CEM'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CEM'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'CEM'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CEM'::text + UNION ALL + SELECT 'DT'::text || t_codes_emploi.oid::text AS oid, + (t_codes_emploi.code::text || ' '::text) || t_codes_emploi.texte::text AS texte, + t_codes_emploi.code, + '1'::text AS level, + '9'::text || t_codes_emploi.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_codes_emploi + WHERE (t_codes_emploi.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'codes_emploi'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_codes_postaux_1.yaml b/db/schema2/views/v_codes_postaux_1.yaml new file mode 100644 index 0000000..a9dc0b4 --- /dev/null +++ b/db/schema2/views/v_codes_postaux_1.yaml @@ -0,0 +1,78 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'CPO'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CPO'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'CPO'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CPO'::text + ) UNION + SELECT 'D2'::text || t_departements.oid::text AS oid, + (t_departements.code::text || ' '::text) || t_departements.texte_court::text AS texte, + t_departements.code, + '1'::text AS level, + ('9'::text || t_departements.code::text) || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM rh.t_departements + WHERE (t_departements.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'departements'::text)) + UNION + SELECT 'DT'::text || t_codes_postaux.oid::text AS oid, + (t_codes_postaux.code::text || ' '::text) || t_codes_postaux.texte_court::text AS texte, + t_codes_postaux.code, + '2'::text AS level, + ('9'::text || t_codes_postaux.departement_code::text) || t_codes_postaux.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_codes_postaux + WHERE (t_codes_postaux.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'codes_postaux'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_codes_postaux_2.yaml b/db/schema2/views/v_codes_postaux_2.yaml new file mode 100644 index 0000000..a25bcdd --- /dev/null +++ b/db/schema2/views/v_codes_postaux_2.yaml @@ -0,0 +1,11 @@ +src: | + SELECT t_codes_postaux.oid AS code_postal_id, + t_codes_postaux.code AS code_postal_code, + t_codes_postaux.texte AS code_postal_texte, + t_codes_postaux.section_id AS code_postal_section_id, + t_codes_postaux.section_code AS code_postal_section_code, + t_codes_postaux.section_texte AS code_postal_section_texte, + t_codes_postaux.departement_id, + t_codes_postaux.departement_code, + t_codes_postaux.departement_texte + FROM rh.t_codes_postaux; \ No newline at end of file diff --git a/db/schema2/views/v_commission_paritaire_1.yaml b/db/schema2/views/v_commission_paritaire_1.yaml new file mode 100644 index 0000000..9b953df --- /dev/null +++ b/db/schema2/views/v_commission_paritaire_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'GCP'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GCP'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'GCP'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GCP'::text + UNION ALL + SELECT 'DT'::text || t_commission_paritaire.oid::text AS oid, + (t_commission_paritaire.code::text || ' '::text) || t_commission_paritaire.texte_court::text AS texte, + t_commission_paritaire.code, + '1'::text AS level, + '9'::text || t_commission_paritaire.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_commission_paritaire + WHERE (t_commission_paritaire.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'commission_paritaire'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_compte_1.yaml b/db/schema2/views/v_compte_1.yaml new file mode 100644 index 0000000..77a92b9 --- /dev/null +++ b/db/schema2/views/v_compte_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'CPT'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CPT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'CPT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'CPT'::text + UNION ALL + SELECT 'DT'::text || t_compte.oid::text AS oid, + (t_compte.code::text || ' '::text) || t_compte.texte_court::text AS texte, + t_compte.code, + '1'::text AS level, + '9'::text || t_compte.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_compte + WHERE (t_compte.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'compte'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_compte_2.yaml b/db/schema2/views/v_compte_2.yaml new file mode 100644 index 0000000..578842f --- /dev/null +++ b/db/schema2/views/v_compte_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_compte.oid AS compte_id, + t_compte.code AS compte_code, + t_compte.texte AS compte_texte, + t_compte.section_id AS compte_section_id, + t_compte.section_code AS compte_section_code, + t_compte.section_texte AS compte_section_texte + FROM rh.t_compte; \ No newline at end of file diff --git a/db/schema2/views/v_contrats_1.yaml b/db/schema2/views/v_contrats_1.yaml new file mode 100644 index 0000000..21a1b46 --- /dev/null +++ b/db/schema2/views/v_contrats_1.yaml @@ -0,0 +1,292 @@ +src: | + SELECT p_salaries.finess, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + p_salaries.oid AS nir_id, + p_salaries.nir AS nir_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS nir_texte, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + CASE + WHEN p_handicap.salarie_id IS NULL THEN 0 + ELSE 1 + END AS handicap_id, + CASE + WHEN p_handicap.salarie_id IS NULL THEN 'N'::bpchar + ELSE 'O'::bpchar + END AS handicap_code, + CASE + WHEN p_handicap.salarie_id IS NULL THEN 'Non'::text + ELSE 'Oui'::text + END AS handicap_texte, + p_salaries.situation_famille_id, + t_situations_famille.code AS situation_famille_code, + t_situations_famille.texte_court AS situation_famille_texte, + p_salaries.code_original, + p_salaries.entreprise_id, + t_entreprises.code AS entreprise_code, + t_entreprises.texte_court AS entreprise_texte, + t_entreprises.section_id AS entreprise_section_id, + t_entreprises.section_code AS entreprise_section_code, + t_entreprises.section_texte AS entreprise_section_texte, + p_contrats.etablissement_id, + t_etablissements.code AS etablissement_code, + t_etablissements.texte_court AS etablissement_texte, + t_etablissements.section_id AS etablissement_section_id, + t_etablissements.section_code AS etablissement_section_code, + t_etablissements.section_texte AS etablissement_section_texte, + p_salaries.nationalite_id, + t_nationalites.code AS nationalite_code, + t_nationalites.texte_court AS nationalite_texte, + t_nationalites.section_id AS nationalite_section_id, + t_nationalites.section_code AS nationalite_section_code, + t_nationalites.section_texte AS nationalite_section_texte, + t_codes_postaux.departement_id, + t_codes_postaux.departement_code, + t_codes_postaux.departement_texte, + p_salaries.code_postal_id, + t_codes_postaux.code AS code_postal_code, + t_codes_postaux.texte_court AS code_postal_texte, + t_codes_postaux.section_id AS code_postal_section_id, + t_codes_postaux.section_code AS code_postal_section_code, + t_codes_postaux.section_texte AS code_postal_section_texte, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats.anciennete_anterieure_jours, + p_contrats.anciennete_reprise_anterieure_jours, + p_contrats.anciennete_anterieure_jours + ( + CASE + WHEN p_contrats.date_fin < '2099-12-31'::date THEN p_contrats.date_fin + ELSE GREATEST('now'::text::date, (p_contrats.date_debut - '1 day'::interval)::date) + END - p_contrats.date_debut)::numeric + 1::numeric AS anciennete_jours, + p_contrats.anciennete_reprise_anterieure_jours + ( + CASE + WHEN p_contrats.date_fin < '2099-12-31'::date THEN p_contrats.date_fin + ELSE GREATEST('now'::text::date, (p_contrats.date_debut - '1 day'::interval)::date) + END - p_contrats.date_debut)::numeric + 1::numeric AS anciennete_reprise_jours, + ( + CASE + WHEN p_contrats.date_fin < '2099-12-31'::date THEN p_contrats.date_fin + ELSE GREATEST('now'::text::date, (p_contrats.date_debut - '1 day'::interval)::date) + END - p_contrats.date_debut)::numeric + 1::numeric AS duree, + p_profils.oid AS profil_id, + p_profils.type_contrat_id, + p_profils.type_contrat_code_original, + p_profils.type_contrat_code, + p_profils.type_contrat_texte, + p_profils.type_contrat_section_id, + p_profils.type_contrat_section_code, + p_profils.type_contrat_section_texte, + p_profils.motif_debut_id, + p_profils.motif_debut_code_original, + p_profils.motif_debut_code, + p_profils.motif_debut_texte, + p_profils.motif_debut_section_id, + p_profils.motif_debut_section_code, + p_profils.motif_debut_section_texte, + p_profils.motif_fin_id, + p_profils.motif_fin_code_original, + p_profils.motif_fin_code, + p_profils.motif_fin_texte, + p_profils.motif_fin_section_id, + p_profils.motif_fin_section_code, + p_profils.motif_fin_section_texte, + p_profils.qualification_id, + p_profils.qualification_code_original, + p_profils.qualification_code, + p_profils.qualification_texte, + p_profils.qualification_section_id, + p_profils.qualification_section_code, + p_profils.qualification_section_texte, + p_profils.service_id, + p_profils.service_code_original, + p_profils.service_code, + p_profils.service_texte, + p_profils.service_section_id, + p_profils.service_section_code, + p_profils.service_section_texte, + p_profils.specialite_id, + p_profils.specialite_code_original, + p_profils.specialite_code, + p_profils.specialite_texte, + p_profils.specialite_section_id, + p_profils.specialite_section_code, + p_profils.specialite_section_texte, + p_profils.type_temps_travail_id, + p_profils.type_temps_travail_code_original, + p_profils.type_temps_travail_code, + p_profils.type_temps_travail_texte, + p_profils.type_temps_travail_section_id, + p_profils.type_temps_travail_section_code, + p_profils.type_temps_travail_section_texte, + p_profils.categorie_socio_professionnelle_id, + p_profils.categorie_socio_professionnelle_code_original, + p_profils.categorie_socio_professionnelle_code, + p_profils.categorie_socio_professionnelle_texte, + p_profils.categorie_socio_professionnelle_section_id, + p_profils.categorie_socio_professionnelle_section_code, + p_profils.categorie_socio_professionnelle_section_texte, + p_profils.statut_id, + p_profils.statut_code_original, + p_profils.statut_code, + p_profils.statut_texte, + p_profils.statut_section_id, + p_profils.statut_section_code, + p_profils.statut_section_texte, + p_profils.code_emploi_id, + p_profils.code_emploi_code_original, + p_profils.code_emploi_code, + p_profils.code_emploi_texte, + p_profils.code_emploi_section_id, + p_profils.code_emploi_section_code, + p_profils.code_emploi_section_texte, + p_profils.societe_interim_id, + p_profils.societe_interim_code_original, + p_profils.societe_interim_code, + p_profils.societe_interim_texte, + p_profils.societe_interim_section_id, + p_profils.societe_interim_section_code, + p_profils.societe_interim_section_texte, + p_profils.section_analytique_paie_id, + p_profils.section_analytique_paie_code_original, + p_profils.section_analytique_paie_code, + p_profils.section_analytique_paie_texte, + p_profils.section_analytique_paie_section_id, + p_profils.section_analytique_paie_section_code, + p_profils.section_analytique_paie_section_texte, + p_profils.section_analytique_id, + p_profils.section_analytique_code_original, + p_profils.section_analytique_code, + p_profils.section_analytique_texte, + p_profils.section_analytique_section_id, + p_profils.section_analytique_section_code, + p_profils.section_analytique_section_texte, + p_profils.grille_id, + p_profils.grille_code_original, + p_profils.grille_code, + p_profils.grille_texte, + p_profils.grille_section_id, + p_profils.grille_section_code, + p_profils.grille_section_texte, + p_profils.grille_groupe_id, + p_profils.grille_groupe_code_original, + p_profils.grille_groupe_code, + p_profils.grille_groupe_texte, + p_profils.grille_groupe_section_id, + p_profils.grille_groupe_section_code, + p_profils.grille_groupe_section_texte, + p_profils.type_horaire_id, + p_profils.type_horaire_code_original, + p_profils.type_horaire_code, + p_profils.type_horaire_texte, + p_profils.type_horaire_section_id, + p_profils.type_horaire_section_code, + p_profils.type_horaire_section_texte, + p_profils.groupe_cotisant_id, + p_profils.groupe_cotisant_code_original, + p_profils.groupe_cotisant_code, + p_profils.groupe_cotisant_texte, + p_profils.groupe_cotisant_section_id, + p_profils.groupe_cotisant_section_code, + p_profils.groupe_cotisant_section_texte, + p_salaries_remplaces.oid AS salarie_remplace_id, + p_salaries_remplaces.matricule AS salarie_remplace_code, + (p_salaries_remplaces.nom::text || ' '::text) || p_salaries_remplaces.prenom::text AS salarie_remplace_texte, + p_profils.unite_fonctionnelle_id, + p_profils.unite_fonctionnelle_code_original, + p_profils.unite_fonctionnelle_code, + p_profils.unite_fonctionnelle_texte, + p_profils.unite_fonctionnelle_section_id, + p_profils.unite_fonctionnelle_section_code, + p_profils.unite_fonctionnelle_section_texte, + p_profils.lettre_budgetaire_id, + p_profils.lettre_budgetaire_code_original, + p_profils.lettre_budgetaire_code, + p_profils.lettre_budgetaire_texte, + p_profils.lettre_budgetaire_section_id, + p_profils.lettre_budgetaire_section_code, + p_profils.lettre_budgetaire_section_texte, + p_profils.commission_paritaire_id, + p_profils.commission_paritaire_code_original, + p_profils.commission_paritaire_code, + p_profils.commission_paritaire_texte, + p_profils.commission_paritaire_section_id, + p_profils.commission_paritaire_section_code, + p_profils.commission_paritaire_section_texte, + p_profils.compte_salarie_id, + p_profils.compte_salarie_code_original, + p_profils.compte_salarie_code, + p_profils.compte_salarie_texte, + p_profils.compte_salarie_section_id, + p_profils.compte_salarie_section_code, + p_profils.compte_salarie_section_texte, + p_profils.categorie_conge_id, + p_profils.categorie_conge_code_original, + p_profils.categorie_conge_code, + p_profils.categorie_conge_texte, + p_profils.categorie_conge_section_id, + p_profils.categorie_conge_section_code, + p_profils.categorie_conge_section_texte, + p_profils.filiere_id, + p_profils.filiere_code_original, + p_profils.filiere_code, + p_profils.filiere_texte, + p_profils.filiere_section_id, + p_profils.filiere_section_code, + p_profils.filiere_section_texte, + p_profils.cadre_emploi_id, + p_profils.cadre_emploi_code_original, + p_profils.cadre_emploi_code, + p_profils.cadre_emploi_texte, + p_profils.cadre_emploi_section_id, + p_profils.cadre_emploi_section_code, + p_profils.cadre_emploi_section_texte, + p_profils.categorie_statutaire_id, + p_profils.categorie_statutaire_code_original, + p_profils.categorie_statutaire_code, + p_profils.categorie_statutaire_texte, + p_profils.categorie_statutaire_section_id, + p_profils.categorie_statutaire_section_code, + p_profils.categorie_statutaire_section_texte, + p_salaries.date_anciennete, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + t_code_cotisation.oid AS code_cotisation_id, + t_code_cotisation.code_original AS code_cotisation_code_original, + t_code_cotisation.code AS code_cotisation_code, + t_code_cotisation.texte AS code_cotisation_texte, + t_code_cotisation.section_id AS code_cotisation_section_id, + t_code_cotisation.section_code AS code_cotisation_section_code, + t_code_cotisation.section_texte AS code_cotisation_section_texte, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte + FROM rh.p_salaries + JOIN rh.p_contrats ON p_contrats.salarie_id = p_salaries.oid + JOIN rh.t_entreprises ON p_salaries.entreprise_id = t_entreprises.oid + JOIN rh.t_codes_postaux ON p_salaries.code_postal_id = t_codes_postaux.oid + JOIN rh.t_nationalites ON p_salaries.nationalite_id = t_nationalites.oid + JOIN rh.t_situations_famille ON p_salaries.situation_famille_id = t_situations_famille.oid + JOIN rh.t_etablissements ON p_contrats.etablissement_id = t_etablissements.oid + JOIN rh.p_profils ON p_contrats.profil_id = p_profils.oid + JOIN rh.t_code_cotisation ON t_code_cotisation.oid = p_salaries.code_cotisation_id + LEFT JOIN rh.p_salaries p_salaries_remplaces ON p_salaries_remplaces.oid = p_contrats.salarie_remplace_id + LEFT JOIN rh.p_handicap ON p_salaries.oid = p_handicap.salarie_id; \ No newline at end of file diff --git a/db/schema2/views/v_contrats_mois_1.yaml b/db/schema2/views/v_contrats_mois_1.yaml new file mode 100644 index 0000000..49587aa --- /dev/null +++ b/db/schema2/views/v_contrats_mois_1.yaml @@ -0,0 +1,99 @@ +src: | + SELECT p_salaries.finess, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + p_salaries.oid AS nir_id, + p_salaries.nir AS nir_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS nir_texte, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.code_original, + p_salaries.entreprise_id AS rhp_entreprise_id, + p_contrats_mois.etablissement_id AS rhp_etablissement_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.fictif, + p_contrats_mois.mois_activite::bigint AS mois_activite_id, + p_contrats_mois.mois_activite::text AS mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS mois_activite_texte, + p_contrats_mois.mois_activite::bigint AS annee_mois_activite_id, + p_contrats_mois.mois_activite::text AS annee_mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_mois_activite_texte, + (substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text)::bigint AS annee_trimestre_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_contrats_mois.mois_activite::text, 1, 4)::bigint AS annee_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_code, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_texte, + substr(p_contrats_mois.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_contrats_mois.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, p_contrats_mois.date_fin)::bigint AS trimestre_activite_id, + date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats_mois.est_hors_periode, + p_contrats_mois.nombre_debut_contrat, + p_contrats_mois.nombre_fin_contrat, + p_contrats_mois.nombre_entrees, + p_contrats_mois.nombre_departs, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_contrats_mois.nombre_transformation_cdi, + p_contrats_mois.nombre_heures, + p_profil_contrat_mois.ratio, + p_contrats_mois.equivalent_temps_plein * p_profil_contrat_mois.ratio AS equivalent_temps_plein, + p_contrats_mois.age_jours, + p_contrats_mois.age_id AS rhp_age_id, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_contrats_mois.anciennete_jours, + p_contrats_mois.anciennete_reprise_jours, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_salaries.date_anciennete, + p_salaries.date_entree_ets, + p_salaries.date_sortie_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_reprise_mois, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_profil_contrat_mois.pole_id AS rhp_pole_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_salaries + JOIN rh.p_contrats ON p_contrats.salarie_id = p_salaries.oid + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/db/schema2/views/v_croisement_paie_planning_1.yaml b/db/schema2/views/v_croisement_paie_planning_1.yaml new file mode 100644 index 0000000..2a136e4 --- /dev/null +++ b/db/schema2/views/v_croisement_paie_planning_1.yaml @@ -0,0 +1,167 @@ +src: | + SELECT p_croisement_paie_planning.planning_id, + p_croisement_paie_planning.salarie_id, + p_croisement_paie_planning.date, + p_croisement_paie_planning.mois_paie, + p_croisement_paie_planning.etablissement_id AS rhp_etablissement_id, + p_croisement_paie_planning.contrat_mois_id, + p_croisement_paie_planning.presence_detail, + p_croisement_paie_planning.temps_du_initial AS temps_du_init, + p_croisement_paie_planning.temps_du, + p_croisement_paie_planning.temps_valide, + p_croisement_paie_planning.heur_cont_pror_temp_du_init, + p_croisement_paie_planning.heur_cont_pror_temp_du, + p_croisement_paie_planning.heur_cont_pror_temp_vali, + p_croisement_paie_planning.heur_paye_pror_temp_du_init, + p_croisement_paie_planning.heur_paye_pror_temp_du, + p_croisement_paie_planning.heur_paye_pror_temp_vali, + p_croisement_paie_planning.heur_trav_pror_temp_du_init, + p_croisement_paie_planning.heur_trav_pror_temp_du, + p_croisement_paie_planning.heur_trav_pror_temp_vali, + p_croisement_paie_planning.mont_brut_pror_temp_du_init, + p_croisement_paie_planning.mont_brut_pror_temp_du, + p_croisement_paie_planning.mont_brut_pror_temp_vali, + p_croisement_paie_planning.mont_mass_sala_pror_temp_du_init, + p_croisement_paie_planning.mont_mass_sala_pror_temp_du, + p_croisement_paie_planning.mont_mass_sala_pror_temp_vali, + p_croisement_paie_planning.mont_coti_patr_pror_temp_du_init, + p_croisement_paie_planning.mont_coti_patr_pror_temp_du, + p_croisement_paie_planning.mont_coti_patr_pror_temp_vali, + p_croisement_paie_planning.mont_prov_pror_temp_du_init, + p_croisement_paie_planning.mont_prov_pror_temp_du, + p_croisement_paie_planning.mont_prov_pror_temp_vali, + p_croisement_paie_planning.mont_mass_sala_prov_pror_temp_du_init, + p_croisement_paie_planning.mont_mass_sala_prov_pror_temp_du, + p_croisement_paie_planning.mont_mass_sala_prov_pror_temp_vali, + p_croisement_paie_planning.mont_inte_pror_temp_du_init, + p_croisement_paie_planning.mont_inte_pror_temp_du, + p_croisement_paie_planning.mont_inte_pror_temp_vali, + p_croisement_paie_planning.mont_mass_sala_inte_pror_temp_du_init, + p_croisement_paie_planning.mont_mass_sala_inte_pror_temp_du, + p_croisement_paie_planning.mont_mass_sala_inte_pror_temp_vali, + p_croisement_paie_planning.mont_mass_sala_prov_inte_pror_temp_du_init, + p_croisement_paie_planning.mont_mass_sala_prov_inte_pror_temp_du, + p_croisement_paie_planning.mont_mass_sala_prov_inte_pror_temp_vali, + p_croisement_paie_planning.mois_paie::bigint AS mois_activite_id, + p_croisement_paie_planning.mois_paie::text AS mois_activite_code, + (base.cti_to_french(to_char((p_croisement_paie_planning.mois_paie::text || '01'::text)::timestamp without time zone, 'Month'::text)) || ' '::text) || substr(p_croisement_paie_planning.mois_paie::text, 1, 4) AS mois_activite_texte, + p_croisement_paie_planning.mois_paie AS annee_mois_activite_id, + p_croisement_paie_planning.mois_paie AS annee_mois_activite_code, + ( + CASE + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 1::double precision THEN 'Janvier'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 2::double precision THEN 'Février'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 3::double precision THEN 'Mars'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 4::double precision THEN 'Avril'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 5::double precision THEN 'Mai'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 6::double precision THEN 'Juin'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 7::double precision THEN 'Juillet'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 8::double precision THEN 'Aout'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 9::double precision THEN 'Septembre'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 10::double precision THEN 'Octobre'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 11::double precision THEN 'Novembre'::text + WHEN date_part('month'::text, p_croisement_paie_planning.date) = 12::double precision THEN 'Décembre'::text + ELSE date_part('month'::text, p_croisement_paie_planning.date)::text + END || ' '::text) || date_part('year'::text, p_croisement_paie_planning.date)::text AS annee_mois_activite_texte, + date_part('year'::text, p_croisement_paie_planning.date) AS annee_activite_id, + date_part('year'::text, p_croisement_paie_planning.date) AS annee_activite_code, + date_part('year'::text, p_croisement_paie_planning.date) AS annee_activite_texte, + (substr(p_croisement_paie_planning.mois_paie::text, 1, 4) || date_part('quarter'::text, p_croisement_paie_planning.date)::text)::bigint AS annee_trimestre_activite_id, + substr(p_croisement_paie_planning.mois_paie::text, 1, 4) || date_part('quarter'::text, p_croisement_paie_planning.date)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, p_croisement_paie_planning.date)::text) || ' '::text) || substr(p_croisement_paie_planning.mois_paie::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_croisement_paie_planning.mois_paie::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_croisement_paie_planning.mois_paie::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char(p_croisement_paie_planning.date::timestamp with time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, p_croisement_paie_planning.date)::bigint AS trimestre_activite_id, + date_part('quarter'::text, p_croisement_paie_planning.date)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, p_croisement_paie_planning.date)::text AS trimestre_activite_texte, + to_char(p_croisement_paie_planning.date::timestamp with time zone, 'IYYYIW'::text) AS semaine_activite_id, + to_char(p_croisement_paie_planning.date::timestamp with time zone, 'IYYY-IW'::text) AS semaine_activite_code, + 'Semaine '::text || base.cti_to_french(to_char(p_croisement_paie_planning.date::timestamp with time zone, 'IW IYYY'::text)) AS semaine_activite_texte, + to_char(p_croisement_paie_planning.date::timestamp with time zone, 'YYYYMMDD'::text) AS jour_activite_id, + to_char(p_croisement_paie_planning.date::timestamp with time zone, 'YYYY-MM-DD'::text) AS jour_activite_code, + base.cti_to_french(to_char(p_croisement_paie_planning.date::timestamp with time zone, 'Day DD month YYYY'::text)) AS jour_activite_texte, + p_croisement_paie_planning.date AS date_debut_activite, + p_croisement_paie_planning.date AS date_fin_activite, + p_planning_mouvement.service_id AS rhp_planning_service_id, + p_planning_mouvement.qualification_id AS rhp_planning_qualification_id, + p_planning_mouvement.type_absence_id AS rhp_planning_type_absence_id, + p_planning_mouvement.etablissement_id AS rhp_planning_etablissement_id, + p_planning_mouvement.code_horaire_id AS rhp_planning_code_horaire_id, + p_planning_mouvement.niveau_id AS rhp_planning_niveau_id, + p_planning_mouvement.pole_id AS rhp_pole_id, + p_planning_mouvement.absence_id AS planning_absence_id, + p_planning_mouvement.absence_nb_jours AS planning_absence_nb_jours, + p_salaries.finess, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + p_salaries.oid AS nir_id, + p_salaries.nir AS nir_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS nir_texte, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.code_original, + p_salaries.entreprise_id AS rhp_entreprise_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_salaries.date_anciennete, + p_salaries.date_entree_ets, + p_salaries.date_sortie_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_contrats_mois.fictif, + p_contrats_mois.est_hors_periode, + p_contrats_mois.nombre_debut_contrat, + p_contrats_mois.nombre_fin_contrat, + p_contrats_mois.nombre_entrees, + p_contrats_mois.nombre_departs, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_contrats_mois.nombre_transformation_cdi, + p_contrats_mois.nombre_heures, + p_contrats_mois.equivalent_temps_plein * p_profil_contrat_mois.ratio AS equivalent_temps_plein, + p_contrats_mois.age_jours, + p_contrats_mois.age_id AS rhp_age_id, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_contrats_mois.anciennete_jours, + p_contrats_mois.anciennete_reprise_jours, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_reprise_mois, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id, + p_contrats.numero_contrat AS contrat_code, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_profil_contrat_mois.ratio, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_croisement_paie_planning + LEFT JOIN rh.p_planning_mouvement ON p_planning_mouvement.oid = p_croisement_paie_planning.planning_id + JOIN rh.p_salaries ON p_salaries.oid = p_croisement_paie_planning.salarie_id + JOIN rh.p_contrats_mois ON p_contrats_mois.oid = p_croisement_paie_planning.contrat_mois_id + JOIN rh.p_contrats ON p_contrats.oid = p_contrats_mois.contrat_id + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid AND p_profil_contrat_mois.profil_id = p_contrats_mois.profil_id; \ No newline at end of file diff --git a/db/schema2/views/v_data_profile_1.yaml b/db/schema2/views/v_data_profile_1.yaml new file mode 100644 index 0000000..7f8170c --- /dev/null +++ b/db/schema2/views/v_data_profile_1.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_data_profile.code AS oid, + ((t_data_profile.texte || '('::text) || t_data_profile.code) || ')'::text AS texte, + t_data_profile.code, + '1'::text AS level, + '9'::text || t_data_profile.texte AS tri + FROM rh.t_data_profile + ORDER BY ('9'::text || t_data_profile.texte); \ No newline at end of file diff --git a/db/schema2/views/v_entreprises_2.yaml b/db/schema2/views/v_entreprises_2.yaml new file mode 100644 index 0000000..f950051 --- /dev/null +++ b/db/schema2/views/v_entreprises_2.yaml @@ -0,0 +1,11 @@ +src: | + SELECT t_entreprises.oid AS entreprise_id, + t_entreprises.code AS entreprise_code, + t_entreprises.texte AS entreprise_texte, + t_entreprises.section_id AS entreprise_section_id, + t_entreprises.section_code AS entreprise_section_code, + t_entreprises.section_texte AS entreprise_section_texte + FROM rh.t_entreprises + JOIN rh.t_etablissements ON t_etablissements.entreprise_id = t_entreprises.oid + GROUP BY t_entreprises.oid, t_entreprises.code, t_entreprises.texte, t_entreprises.section_id, t_entreprises.section_code, t_entreprises.section_texte; +comment: La jointure sur les établissements, bien que superflue au premier abord, est nécessaire pour que la mécanique de data_profile puisse fonctionner. \ No newline at end of file diff --git a/db/schema2/views/v_etablissements_1.yaml b/db/schema2/views/v_etablissements_1.yaml new file mode 100644 index 0000000..5d7fe6f --- /dev/null +++ b/db/schema2/views/v_etablissements_1.yaml @@ -0,0 +1,250 @@ +src: | + ( + ( + SELECT '-8'::text AS oid, + 'Listes paramétrées établissement'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '0'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM rh.t_listes_tables + WHERE t_listes_tables.code = 'ETS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM rh.t_listes + WHERE t_listes.is_cti::text <> 1::text AND (substr(t_listes.code, 1, 4) <> ALL (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text])))) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + ''::text AS code, + '2'::text AS level, + '0I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND (substr(t_listes.code, 1, 4) <> ALL (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text])) + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '0S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND (substr(t_listes.code, 1, 4) <> ALL (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text])) AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées VITALIA'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '1'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM rh.t_listes_tables + WHERE t_listes_tables.code = 'ETS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM rh.t_listes + WHERE t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VIT_'::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + ''::text AS code, + '2'::text AS level, + '1I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VIT_'::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '1S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VIT_'::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées VEDICI'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '1'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM rh.t_listes_tables + WHERE t_listes_tables.code = 'ETS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM rh.t_listes + WHERE t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VED_'::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + ''::text AS code, + '2'::text AS level, + '1I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VED_'::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '1S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VED_'::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées HPM'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '1'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM rh.t_listes_tables + WHERE t_listes_tables.code = 'ETS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM rh.t_listes + WHERE t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'HPM_'::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + t_listes.code, + '2'::text AS level, + '1I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'HPM_'::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '1S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'HPM_'::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées CTI'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '3'::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_listes_tables + WHERE t_listes_tables.code = 'ETS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM rh.t_listes + WHERE t_listes.is_cti::text = 1::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + t_listes.code, + '2'::text AS level, + '3I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text = 1::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '3S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_listes, + rh.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text AND t_listes.is_cti::text = 1::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text + ) UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ETS'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ETS'::text + ) UNION + SELECT 'DT'::text || t_entreprises.oid::text AS oid, + (t_entreprises.code || ' '::text) || t_entreprises.texte_court::text AS texte, + t_entreprises.code, + '1'::text AS level, + ('9'::text || t_entreprises.code) || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM rh.t_entreprises + JOIN rh.t_etablissements ON t_etablissements.entreprise_id = t_entreprises.oid + WHERE t_entreprises.oid <> 0 + GROUP BY ('DT'::text || t_entreprises.oid::text), ((t_entreprises.code || ' '::text) || t_entreprises.texte_court::text), t_entreprises.code, '1'::text, (('9'::text || t_entreprises.code) || chr(1)) + UNION + SELECT 'D2'::text || t_etablissements.oid::text AS oid, + (t_etablissements.code || ' '::text) || t_etablissements.texte_court::text AS texte, + t_entreprises.code, + '2'::text AS level, + (('9'::text || t_entreprises.code) || chr(1)) || t_etablissements.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_etablissements + JOIN rh.t_entreprises ON t_etablissements.entreprise_id = t_entreprises.oid + WHERE t_etablissements.oid <> 0 AND t_entreprises.oid <> 0 + ORDER BY 5; +comment: La jointure sur les établissements pour la partie sur les entreprises, bien que superflue au premier abord, est nécessaire pour que la mécanique de data_profile puisse fonctionner. \ No newline at end of file diff --git a/db/schema2/views/v_etablissements_2.yaml b/db/schema2/views/v_etablissements_2.yaml new file mode 100644 index 0000000..1b9c0df --- /dev/null +++ b/db/schema2/views/v_etablissements_2.yaml @@ -0,0 +1,21 @@ +src: | + SELECT t_etablissements.oid AS etablissement_id, + t_etablissements.code AS etablissement_code, + t_etablissements.texte AS etablissement_texte, + t_etablissements.section_id AS etablissement_section_id, + t_etablissements.section_code AS etablissement_section_code, + t_etablissements.section_texte AS etablissement_section_texte, + t_etablissements.finess_id, + t_etablissements.finess_code, + t_etablissements.finess_texte, + t_etablissements.finess_section_id, + t_etablissements.finess_section_code, + t_etablissements.finess_section_texte, + t_entreprises.oid AS entreprise_id, + t_entreprises.code AS entreprise_code, + t_entreprises.texte AS entreprise_texte, + t_entreprises.section_id AS entreprise_section_id, + t_entreprises.section_code AS entreprise_section_code, + t_entreprises.section_texte AS entreprise_section_texte + FROM rh.t_etablissements + JOIN rh.t_entreprises ON t_entreprises.oid = t_etablissements.entreprise_id; \ No newline at end of file diff --git a/db/schema2/views/v_expert_controle_1.yaml b/db/schema2/views/v_expert_controle_1.yaml new file mode 100644 index 0000000..88455d7 --- /dev/null +++ b/db/schema2/views/v_expert_controle_1.yaml @@ -0,0 +1,61 @@ +src: | + SELECT t_expert_controle.oid AS expert_controle_id, + t_expert_controle.code AS expert_controle_code, + t_expert_controle.texte AS expert_controle_texte, + COALESCE(t_expert_controle.texte_abrege, t_expert_controle.texte_court) AS expert_controle_texte_abrege, + t_expert_controle.gravite_id AS expert_controle_gravite_id, + to_char(t_expert_controle.gravite_id, 'FM0'::text) AS expert_controle_gravite_code, + CASE + WHEN t_expert_controle.gravite_id = 0 THEN 'INFO'::text + WHEN t_expert_controle.gravite_id >= 1 AND t_expert_controle.gravite_id <= 5 THEN 'ATT'::text + WHEN t_expert_controle.gravite_id >= 6 AND t_expert_controle.gravite_id <= 9 THEN 'ERREUR'::text + ELSE 'ATT'::text + END AS expert_controle_gravite_texte, + t_expert_controle.date_validite_debut AS expert_controle_date_validite_debut, + t_expert_controle.date_validite_fin AS expert_controle_date_validite_fin, + t_expert_controle.section_id AS expert_controle_section_id, + t_expert_controle.section_code AS expert_controle_section_code, + t_expert_controle.section_texte AS expert_controle_section_texte, + t_expert_controle.alert_exp, + p_expert_controle_data.date_signalement, + date_part('epoch'::text, p_expert_controle_data.date_signalement) AS date_signalement_id, + p_expert_controle_data.date_signalement::text AS date_signalement_code, + p_calendrier_s.texte_court AS date_signalement_texte, + p_calendrier_s.mois AS date_signalement_mois_id, + to_char(p_calendrier_s.mois, 'FM000000'::text) AS date_signalement_mois_code, + (p_calendrier_s.mois_texte || ' '::text) || to_char(p_calendrier_s.iso_annee, 'FM0000'::text) AS date_signalement_mois_texte, + p_calendrier_s.semaine AS date_signalement_semaine_id, + to_char(p_calendrier_s.semaine, 'FM000000'::text) AS date_signalement_semaine_code, + (('Semaine '::text || to_char(p_calendrier_s.iso_semaine, 'FM00'::text)) || ' '::text) || to_char(p_calendrier_s.iso_annee, 'FM0000'::text) AS date_signalement_semaine_texte, + p_expert_controle_data.date_correction, + date_part('epoch'::text, p_expert_controle_data.date_correction) AS date_correction_id, + p_expert_controle_data.date_correction::text AS date_correction_code, + p_calendrier_c.texte_court AS date_correction_texte, + p_calendrier_c.mois AS date_correction_mois_id, + to_char(p_calendrier_c.mois, 'FM000000'::text) AS date_correction_mois_code, + (p_calendrier_c.mois_texte || ' '::text) || to_char(p_calendrier_c.iso_annee, 'FM0000'::text) AS date_correction_mois_texte, + p_calendrier_c.semaine AS date_correction_semaine_id, + to_char(p_calendrier_c.semaine, 'FM000000'::text) AS date_correction_semaine_code, + (('Semaine '::text || to_char(p_calendrier_c.iso_semaine, 'FM00'::text)) || ' '::text) || to_char(p_calendrier_c.iso_annee, 'FM0000'::text) AS date_correction_semaine_texte, + p_expert_controle_data.etat, + CASE p_expert_controle_data.etat + WHEN ''::text THEN ''::text + WHEN 'I'::text THEN 'Ignoré'::text + WHEN 'T'::text THEN 'Traité'::text + ELSE p_expert_controle_data.etat + END AS etat_texte, + p_expert_controle_data.data_type, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats.oid AS contrat_id, + p_contrats.salarie_id AS salarie_id, + t_expert_controle.is_active AS expert_controle_is_active, + p_expert_controle_data.texte AS justificatif + FROM rh.t_expert_controle + JOIN rh.p_expert_controle_data ON p_expert_controle_data.expert_controle_id = t_expert_controle.oid + JOIN rh.p_contrats ON p_contrats.numero_contrat = p_expert_controle_data.contrat_mois_data[3] + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid AND p_contrats_mois.date_debut::text = p_expert_controle_data.contrat_mois_data[1] AND p_contrats_mois.date_fin::text = p_expert_controle_data.contrat_mois_data[2] + JOIN base.p_calendrier p_calendrier_s ON p_expert_controle_data.date_signalement = p_calendrier_s.date + JOIN base.p_calendrier p_calendrier_c ON p_expert_controle_data.date_signalement = p_calendrier_c.date + WHERE t_expert_controle.is_hide IS DISTINCT FROM '1'::bpchar AND t_expert_controle.is_global IS DISTINCT FROM '1'::bpchar AND p_expert_controle_data.nb_cree = 1::numeric; \ No newline at end of file diff --git a/db/schema2/views/v_expert_controle_2.yaml b/db/schema2/views/v_expert_controle_2.yaml new file mode 100644 index 0000000..4ad4ebe --- /dev/null +++ b/db/schema2/views/v_expert_controle_2.yaml @@ -0,0 +1,69 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.liste_id_combo AS alias, + v_listes_1.texte, + ''::text AS code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'EXPERTCTL'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + ''::text AS alias, + t_classes.texte, + ''::text AS code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'EXPERTCTL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + ('#LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.code AS alias, + t_classes_sections.texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'EXPERTCTL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + ''::text AS alias, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'EXPERTCTL'::text + UNION ALL + SELECT 'DT'::text || t_expert_controle.oid::text AS oid, + '#LP'::text || t_expert_controle.code AS alias, + (t_expert_controle.code || ' '::text) || t_expert_controle.texte AS texte, + t_expert_controle.code, + '1'::text AS level, + '9'::text || t_expert_controle.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_expert_controle + WHERE t_expert_controle.is_global IS DISTINCT FROM '1'::bpchar + ORDER BY 6; \ No newline at end of file diff --git a/db/schema2/views/v_filiere_1.yaml b/db/schema2/views/v_filiere_1.yaml new file mode 100644 index 0000000..766b1a2 --- /dev/null +++ b/db/schema2/views/v_filiere_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'FIL'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FIL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'FIL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FIL'::text + UNION ALL + SELECT 'DT'::text || t_filiere.oid::text AS oid, + (t_filiere.code::text || ' '::text) || t_filiere.texte_court::text AS texte, + t_filiere.code, + '1'::text AS level, + '9'::text || t_filiere.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_filiere + WHERE (t_filiere.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'filiere'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_finess_1.yaml b/db/schema2/views/v_finess_1.yaml new file mode 100644 index 0000000..0520e3d --- /dev/null +++ b/db/schema2/views/v_finess_1.yaml @@ -0,0 +1,240 @@ +src: | + ( + ( + SELECT '-8'::text AS oid, + 'Listes paramétrées établissement'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '0'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM base.t_listes_tables + WHERE t_listes_tables.code = 'FINESS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM base.t_listes + WHERE t_listes.is_cti::text <> 1::text AND (substr(t_listes.code, 1, 4) <> ALL (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text])))) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + ''::text AS code, + '2'::text AS level, + '0I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND (substr(t_listes.code, 1, 4) <> ALL (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text])) + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '0S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND (substr(t_listes.code, 1, 4) <> ALL (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text])) AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées VITALIA'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '1'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM base.t_listes_tables + WHERE t_listes_tables.code = 'FINESS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM base.t_listes + WHERE t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VIT_'::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + ''::text AS code, + '2'::text AS level, + '1I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VIT_'::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '1S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VIT_'::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées VEDICI'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '1'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM base.t_listes_tables + WHERE t_listes_tables.code = 'FINESS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM base.t_listes + WHERE t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VED_'::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + ''::text AS code, + '2'::text AS level, + '1I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VED_'::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '1S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'VED_'::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées HPM'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '1'::text || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM base.t_listes_tables + WHERE t_listes_tables.code = 'FINESS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM base.t_listes + WHERE t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'HPM_'::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + t_listes.code, + '2'::text AS level, + '1I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'HPM_'::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '1S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text <> 1::text AND substr(t_listes.code, 1, 4) = 'HPM_'::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT '-8'::text AS oid, + 'Listes paramétrées CTI'::character varying AS texte, + ''::text AS code, + '1'::text AS level, + '3'::text AS tri, + '0'::character(1) AS is_cti + FROM base.t_listes_tables + WHERE t_listes_tables.code = 'FINESS'::text AND (t_listes_tables.oid IN ( SELECT t_listes.table_id + FROM base.t_listes + WHERE t_listes.is_cti::text = 1::text)) + UNION + SELECT 'LI'::text || t_listes.oid::text AS oid, + t_listes.texte, + t_listes.code, + '2'::text AS level, + '3I'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text = 1::text + UNION + SELECT 'SL'::text || t_listes.oid::text AS oid, + 'Sauf '::text || t_listes.texte AS texte, + ''::text AS code, + '2'::text AS level, + '3S'::text || t_listes.texte AS tri, + CASE + WHEN t_listes.is_cti::text = '1'::text OR t_listes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_listes, + base.t_listes_tables + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text AND t_listes.is_cti::text = 1::text AND (t_listes.show_omit::text <> '0'::text OR t_listes.show_omit::text IS NULL) + UNION + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_classes, + base.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text + ) UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_classes, + base.t_classes_sections, + base.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'FINESS'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM base.t_classes, + base.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text + ) UNION + SELECT 'DT'::text || t_finess.oid::text AS oid, + t_finess.texte_court AS texte, + t_finess.code, + '1'::text AS level, + ('9'::text || t_finess.code) || chr(1) AS tri, + '0'::character(1) AS is_cti + FROM base.t_finess + WHERE t_finess.oid <> 0 AND (t_finess.oid IN ( SELECT t_etablissements.finess_id + FROM rh.t_etablissements + WHERE t_etablissements.finess_id IS NOT NULL)) + GROUP BY ('DT'::text || t_finess.oid::text), t_finess.texte_court, t_finess.code, '1'::text, (('9'::text || t_finess.code) || chr(1)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_finess_2.yaml b/db/schema2/views/v_finess_2.yaml new file mode 100644 index 0000000..e3bcf39 --- /dev/null +++ b/db/schema2/views/v_finess_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_finess.oid AS finess_id, + t_finess.code AS finess_code, + t_finess.texte AS finess_texte, + t_finess.section_id AS finess_section_id, + t_finess.section_code AS finess_section_code, + t_finess.section_texte AS finess_section_texte + FROM base.t_finess; \ No newline at end of file diff --git a/db/schema2/views/v_formations_1.yaml b/db/schema2/views/v_formations_1.yaml new file mode 100644 index 0000000..489159c --- /dev/null +++ b/db/schema2/views/v_formations_1.yaml @@ -0,0 +1,91 @@ +src: | + SELECT p_formations.oid AS formation_id, + p_salaries.matricule AS formation_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS formation_texte, + p_formations.mois_activite AS formation_mois, + p_formations.formation_date, + p_formations.nb_heures, + p_formations.organisateur, + p_formations.formation_id AS rhp_liste_formation_id, + p_salaries.finess, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.code_original, + p_salaries.entreprise_id AS rhp_entreprise_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_reprise_mois, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_contrats_mois.age_id AS rhp_age_id, + p_contrats_mois.age_jours, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.mois_activite::bigint AS mois_activite_id, + p_contrats_mois.mois_activite::text AS mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS mois_activite_texte, + p_contrats_mois.mois_activite::bigint AS annee_mois_activite_id, + p_contrats_mois.mois_activite::text AS annee_mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_mois_activite_texte, + (substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text)::bigint AS annee_trimestre_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_contrats_mois.mois_activite::text, 1, 4)::bigint AS annee_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_code, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_texte, + substr(p_contrats_mois.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_contrats_mois.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, p_contrats_mois.date_fin)::bigint AS trimestre_activite_id, + date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id AS rhp_anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id AS rhp_anciennete_fph_annee_id, + p_contrats_mois.etablissement_id AS rhp_etablissement_id, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_profil_contrat_mois.pole_id AS rhp_pole_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_salaries + JOIN rh.p_formations ON p_formations.salarie_id = p_salaries.oid + JOIN rh.p_contrats ON p_contrats.oid = p_formations.contrat_id + JOIN rh.p_contrats_mois ON p_contrats_mois.oid = p_formations.contrat_mois_id + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/db/schema2/views/v_grilles_1.yaml b/db/schema2/views/v_grilles_1.yaml new file mode 100644 index 0000000..fcc7b38 --- /dev/null +++ b/db/schema2/views/v_grilles_1.yaml @@ -0,0 +1,69 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'GRI'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GRI'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'GRI'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GRI'::text + UNION ALL + SELECT 'DT'::text || t_grilles.oid::text AS oid, + CASE + WHEN t_grilles.code <> t_grilles.texte_court::text THEN ((t_grilles.code || ' '::text) || t_grilles.texte_court::text)::character varying + ELSE t_grilles.texte_court + END AS texte, + t_grilles.code, + '1'::text AS level, + '9'::text || t_grilles.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_grilles + WHERE t_grilles.oid <> 0 OR (t_grilles.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'grilles'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_grilles_groupes_1.yaml b/db/schema2/views/v_grilles_groupes_1.yaml new file mode 100644 index 0000000..c459926 --- /dev/null +++ b/db/schema2/views/v_grilles_groupes_1.yaml @@ -0,0 +1,69 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'GRG'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GRG'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'GRG'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GRG'::text + UNION ALL + SELECT 'DT'::text || t_grilles_groupes.oid::text AS oid, + CASE + WHEN t_grilles_groupes.code <> t_grilles_groupes.texte_court THEN (((t_grilles_groupes.code || ' '::text) || t_grilles_groupes.texte_court)::character varying)::text + ELSE t_grilles_groupes.texte_court + END AS texte, + t_grilles_groupes.code, + '1'::text AS level, + '9'::text || t_grilles_groupes.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_grilles_groupes + WHERE (t_grilles_groupes.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'grilles_groupes'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_groupes_cotisant_1.yaml b/db/schema2/views/v_groupes_cotisant_1.yaml new file mode 100644 index 0000000..1ca2409 --- /dev/null +++ b/db/schema2/views/v_groupes_cotisant_1.yaml @@ -0,0 +1,69 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'GCT'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GCT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'GCT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'GCT'::text + UNION ALL + SELECT 'DT'::text || t_groupes_cotisant.oid::text AS oid, + CASE + WHEN t_groupes_cotisant.code <> t_groupes_cotisant.texte_court::text THEN ((t_groupes_cotisant.code || ' '::text) || t_groupes_cotisant.texte_court::text)::character varying + ELSE t_groupes_cotisant.texte_court + END AS texte, + t_groupes_cotisant.code, + '1'::text AS level, + '9'::text || t_groupes_cotisant.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_groupes_cotisant + WHERE (t_groupes_cotisant.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'groupes_cotisant'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_handicap_1.yaml b/db/schema2/views/v_handicap_1.yaml new file mode 100644 index 0000000..96e0831 --- /dev/null +++ b/db/schema2/views/v_handicap_1.yaml @@ -0,0 +1,337 @@ +src: | + SELECT p_handicap.oid AS handicap_id, + p_salaries.matricule AS handicap_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS handicap_texte, + p_handicap.taux_incapacite, + p_handicap.date_effet, + p_handicap.type_handicap, + p_handicap.categorie_cotorep, + p_handicap.form_prof_500h, + p_handicap.annee_form_prof, + p_handicap.placement_anterieur, + p_handicap.taux_ipp, + p_handicap.date_echeance, + p_handicap.code_protection, + p_handicap.nature_contrat, + p_handicap.rqth, + p_handicap.beneficiaire_aah, + p_handicap.carte_invalidite, + p_handicap.maladie_p_at, + p_handicap.invalide_pensionne, + p_handicap.mutile_guerre, + p_handicap.assimile_mutile_guerre, + p_handicap.pompier_volontaire, + p_handicap.unite_age_26_51, + p_handicap.lourd_handicap, + p_handicap.emb_1er_handicap, + p_handicap.emb_chom_long, + p_handicap.emb_ea_cdtd_esat, + p_handicap.annee_embauche, + p_salaries.finess, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id, + t_situations_famille.code AS situation_famille_code, + t_situations_famille.texte_court AS situation_famille_texte, + p_salaries.code_original, + p_salaries.entreprise_id, + t_entreprises.code AS entreprise_code, + t_entreprises.texte_court AS entreprise_texte, + t_entreprises.section_id AS entreprise_section_id, + t_entreprises.section_code AS entreprise_section_code, + t_entreprises.section_texte AS entreprise_section_texte, + p_salaries.nationalite_id, + t_nationalites.code AS nationalite_code, + t_nationalites.texte_court AS nationalite_texte, + t_nationalites.section_id AS nationalite_section_id, + t_nationalites.section_code AS nationalite_section_code, + t_nationalites.section_texte AS nationalite_section_texte, + t_codes_postaux.departement_id, + t_codes_postaux.departement_code, + t_codes_postaux.departement_texte, + p_salaries.code_postal_id, + t_codes_postaux.code AS code_postal_code, + t_codes_postaux.texte_court AS code_postal_texte, + t_codes_postaux.section_id AS code_postal_section_id, + t_codes_postaux.section_code AS code_postal_section_code, + t_codes_postaux.section_texte AS code_postal_section_texte, + p_profils.oid, + p_profils.type_contrat_id, + p_profils.type_contrat_code_original, + p_profils.type_contrat_code, + p_profils.type_contrat_texte, + p_profils.type_contrat_section_id, + p_profils.type_contrat_section_code, + p_profils.type_contrat_section_texte, + p_profils.motif_debut_id, + p_profils.motif_debut_code_original, + p_profils.motif_debut_code, + p_profils.motif_debut_texte, + p_profils.motif_debut_section_id, + p_profils.motif_debut_section_code, + p_profils.motif_debut_section_texte, + p_profils.motif_fin_id, + p_profils.motif_fin_code_original, + p_profils.motif_fin_code, + p_profils.motif_fin_texte, + p_profils.motif_fin_section_id, + p_profils.motif_fin_section_code, + p_profils.motif_fin_section_texte, + p_profils.qualification_id, + p_profils.qualification_code_original, + p_profils.qualification_code, + p_profils.qualification_texte, + p_profils.qualification_section_id, + p_profils.qualification_section_code, + p_profils.qualification_section_texte, + p_profils.service_id, + p_profils.service_code_original, + p_profils.service_code, + p_profils.service_texte, + p_profils.service_section_id, + p_profils.service_section_code, + p_profils.service_section_texte, + p_profils.specialite_id, + p_profils.specialite_code_original, + p_profils.specialite_code, + p_profils.specialite_texte, + p_profils.specialite_section_id, + p_profils.specialite_section_code, + p_profils.specialite_section_texte, + p_profils.type_temps_travail_id, + p_profils.type_temps_travail_code_original, + p_profils.type_temps_travail_code, + p_profils.type_temps_travail_texte, + p_profils.type_temps_travail_section_id, + p_profils.type_temps_travail_section_code, + p_profils.type_temps_travail_section_texte, + p_profils.categorie_socio_professionnelle_id, + p_profils.categorie_socio_professionnelle_code_original, + p_profils.categorie_socio_professionnelle_code, + p_profils.categorie_socio_professionnelle_texte, + p_profils.categorie_socio_professionnelle_section_id, + p_profils.categorie_socio_professionnelle_section_code, + p_profils.categorie_socio_professionnelle_section_texte, + p_profils.statut_id, + p_profils.statut_code_original, + p_profils.statut_code, + p_profils.statut_texte, + p_profils.statut_section_id, + p_profils.statut_section_code, + p_profils.statut_section_texte, + p_profils.code_emploi_id, + p_profils.code_emploi_code_original, + p_profils.code_emploi_code, + p_profils.code_emploi_texte, + p_profils.code_emploi_section_id, + p_profils.code_emploi_section_code, + p_profils.code_emploi_section_texte, + p_profils.societe_interim_id, + p_profils.societe_interim_code_original, + p_profils.societe_interim_code, + p_profils.societe_interim_texte, + p_profils.societe_interim_section_id, + p_profils.societe_interim_section_code, + p_profils.societe_interim_section_texte, + p_profils.section_analytique_paie_id, + p_profils.section_analytique_paie_code_original, + p_profils.section_analytique_paie_code, + p_profils.section_analytique_paie_texte, + p_profils.section_analytique_paie_section_id, + p_profils.section_analytique_paie_section_code, + p_profils.section_analytique_paie_section_texte, + p_profils.section_analytique_id, + p_profils.section_analytique_code_original, + p_profils.section_analytique_code, + p_profils.section_analytique_texte, + p_profils.section_analytique_section_id, + p_profils.section_analytique_section_code, + p_profils.section_analytique_section_texte, + p_profils.grille_id, + p_profils.grille_code_original, + p_profils.grille_code, + p_profils.grille_texte, + p_profils.grille_section_id, + p_profils.grille_section_code, + p_profils.grille_section_texte, + p_profils.grille_groupe_id, + p_profils.grille_groupe_code_original, + p_profils.grille_groupe_code, + p_profils.grille_groupe_texte, + p_profils.grille_groupe_section_id, + p_profils.grille_groupe_section_code, + p_profils.grille_groupe_section_texte, + p_profils.type_horaire_id, + p_profils.type_horaire_code_original, + p_profils.type_horaire_code, + p_profils.type_horaire_texte, + p_profils.type_horaire_section_id, + p_profils.type_horaire_section_code, + p_profils.type_horaire_section_texte, + p_profils.groupe_cotisant_id, + p_profils.groupe_cotisant_code_original, + p_profils.groupe_cotisant_code, + p_profils.groupe_cotisant_texte, + p_profils.groupe_cotisant_section_id, + p_profils.groupe_cotisant_section_code, + p_profils.groupe_cotisant_section_texte, + t_anciennetes_annee.code AS anciennete_annee_code, + t_anciennetes_annee.texte AS anciennete_annee_texte, + t_anciennetes_annee.section_id AS anciennete_annee_section_id, + t_anciennetes_annee.section_code AS anciennete_annee_section_code, + t_anciennetes_annee.section_texte AS anciennete_annee_section_texte, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_annee_id, + p_contrats_mois.age_id, + p_contrats_mois.age_jours, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.mois_activite AS mois_activite_id, + p_contrats_mois.mois_activite AS mois_activite_code, + ( + CASE + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 1::double precision THEN 'Janvier'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 2::double precision THEN 'Février'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 3::double precision THEN 'Mars'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 4::double precision THEN 'Avril'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 5::double precision THEN 'Mai'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 6::double precision THEN 'Juin'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 7::double precision THEN 'Juillet'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 8::double precision THEN 'Aout'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 9::double precision THEN 'Septembre'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 10::double precision THEN 'Octobre'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 11::double precision THEN 'Novembre'::text + WHEN date_part('month'::text, p_contrats_mois.date_fin) = 12::double precision THEN 'Décembre'::text + ELSE date_part('month'::text, p_contrats_mois.date_fin)::text + END || ' '::text) || date_part('year'::text, p_contrats_mois.date_fin)::text AS mois_activite_texte, + date_part('year'::text, p_contrats_mois.date_fin) AS annee_activite_id, + date_part('year'::text, p_contrats_mois.date_fin) AS annee_activite_code, + date_part('year'::text, p_contrats_mois.date_fin) AS annee_activite_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + t_etablissements.code AS etablissement_code, + t_etablissements.texte_court AS etablissement_texte, + t_etablissements.section_id AS etablissement_section_id, + t_etablissements.section_code AS etablissement_section_code, + t_etablissements.section_texte AS etablissement_section_texte, + p_contrats_mois.age_id AS age_code, + p_contrats_mois.age_id::text || ' ans'::text AS age_texte, + p_profils.unite_fonctionnelle_id, + p_profils.unite_fonctionnelle_code_original, + p_profils.unite_fonctionnelle_code, + p_profils.unite_fonctionnelle_texte, + p_profils.unite_fonctionnelle_section_id, + p_profils.unite_fonctionnelle_section_code, + p_profils.unite_fonctionnelle_section_texte, + p_profils.lettre_budgetaire_id, + p_profils.lettre_budgetaire_code_original, + p_profils.lettre_budgetaire_code, + p_profils.lettre_budgetaire_texte, + p_profils.lettre_budgetaire_section_id, + p_profils.lettre_budgetaire_section_code, + p_profils.lettre_budgetaire_section_texte, + p_profils.commission_paritaire_id, + p_profils.commission_paritaire_code_original, + p_profils.commission_paritaire_code, + p_profils.commission_paritaire_texte, + p_profils.commission_paritaire_section_id, + p_profils.commission_paritaire_section_code, + p_profils.commission_paritaire_section_texte, + p_profils.compte_salarie_id AS compte_imputation_id, + p_profils.compte_salarie_code_original AS compte_imputation_code_original, + p_profils.compte_salarie_code AS compte_imputation_code, + p_profils.compte_salarie_texte AS compte_imputation_texte, + p_profils.compte_salarie_section_id AS compte_imputation_section_id, + p_profils.compte_salarie_section_code AS compte_imputation_section_code, + p_profils.compte_salarie_section_texte AS compte_imputation_section_texte, + p_profils.categorie_conge_id, + p_profils.categorie_conge_code_original, + p_profils.categorie_conge_code, + p_profils.categorie_conge_texte, + p_profils.categorie_conge_section_id, + p_profils.categorie_conge_section_code, + p_profils.categorie_conge_section_texte, + p_profils.filiere_id, + p_profils.filiere_code_original, + p_profils.filiere_code, + p_profils.filiere_texte, + p_profils.filiere_section_id, + p_profils.filiere_section_code, + p_profils.filiere_section_texte, + p_profils.cadre_emploi_id, + p_profils.cadre_emploi_code_original, + p_profils.cadre_emploi_code, + p_profils.cadre_emploi_texte, + p_profils.cadre_emploi_section_id, + p_profils.cadre_emploi_section_code, + p_profils.cadre_emploi_section_texte, + p_profils.categorie_statutaire_id, + p_profils.categorie_statutaire_code_original, + p_profils.categorie_statutaire_code, + p_profils.categorie_statutaire_texte, + p_profils.categorie_statutaire_section_id, + p_profils.categorie_statutaire_section_code, + p_profils.categorie_statutaire_section_texte, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id, + anciennete_fp.code AS anciennete_fp_code, + anciennete_fp.texte AS anciennete_fp_texte, + anciennete_fp.section_id AS anciennete_fp_section_id, + anciennete_fp.section_code AS anciennete_fp_section_code, + anciennete_fp.section_texte AS anciennete_fp_section_texte, + anciennete_fph.code AS anciennete_fph_code, + anciennete_fph.texte AS anciennete_fph_texte, + anciennete_fph.section_id AS anciennete_fph_section_id, + anciennete_fph.section_code AS anciennete_fph_section_code, + anciennete_fph.section_texte AS anciennete_fph_section_texte, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + t_code_cotisation.oid AS code_cotisation_id, + t_code_cotisation.code_original AS code_cotisation_code_original, + t_code_cotisation.code AS code_cotisation_code, + t_code_cotisation.texte AS code_cotisation_texte, + t_code_cotisation.section_id AS code_cotisation_section_id, + t_code_cotisation.section_code AS code_cotisation_section_code, + t_code_cotisation.section_texte AS code_cotisation_section_texte, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_profil_contrat_mois.pole_id AS rhp_pole_id + FROM rh.p_handicap + LEFT JOIN rh.p_salaries ON p_handicap.salarie_id = p_salaries.oid + LEFT JOIN rh.p_contrats ON p_contrats.salarie_id = p_salaries.oid + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + JOIN rh.t_etablissements ON p_contrats_mois.etablissement_id = t_etablissements.oid + JOIN rh.t_entreprises ON p_salaries.entreprise_id = t_entreprises.oid + JOIN rh.t_codes_postaux ON p_salaries.code_postal_id = t_codes_postaux.oid + JOIN rh.t_nationalites ON p_salaries.nationalite_id = t_nationalites.oid + JOIN rh.t_situations_famille ON p_salaries.situation_famille_id = t_situations_famille.oid + JOIN rh.t_anciennetes_annee ON p_contrats_mois.anciennete_annee_id = t_anciennetes_annee.oid + JOIN rh.t_anciennetes_annee anciennete_fp ON p_contrats_mois.anciennete_annee_id = anciennete_fp.oid + JOIN rh.t_anciennetes_annee anciennete_fph ON p_contrats_mois.anciennete_annee_id = anciennete_fph.oid + JOIN rh.t_code_cotisation ON t_code_cotisation.oid = p_salaries.code_cotisation_id + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profils ON p_profils.oid = p_profil_contrat_mois.profil_id; \ No newline at end of file diff --git a/db/schema2/views/v_historique_paie_0.yaml b/db/schema2/views/v_historique_paie_0.yaml new file mode 100644 index 0000000..209c2cf --- /dev/null +++ b/db/schema2/views/v_historique_paie_0.yaml @@ -0,0 +1,290 @@ +src: | + SELECT p_historique_paie.ctid, + p_historique_paie.ctid AS rhp_ctid, + p_historique_paie.etablissement_id AS rhp_etablissement_id, + p_historique_paie.salarie_id, + p_salaries.code_original AS salarie_code_original, + p_salaries.code AS salarie_code, + p_salaries.matricule, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + p_salaries.oid AS nir_id, + p_salaries.nir AS nir_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS nir_texte, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.date_debut AS date_debut_salarie, + p_salaries.date_fin AS date_fin_salarie, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_salaries.date_sortie_ets, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_historique_paie.contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.est_hors_periode, + p_contrats_mois.nombre_debut_contrat, + p_contrats_mois.nombre_fin_contrat, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_contrats_mois.age_id AS rhp_age_id, + p_salaries.date_anciennete, + p_contrats_mois.anciennete_jours, + p_contrats_mois.anciennete_reprise_jours, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_contrats_mois.anciennete_fp_annee_id AS rhp_anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_annee_id AS rhp_anciennete_fph_annee_id, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_historique_paie.compte_id AS rhp_compte_id, + p_historique_paie.organisme_cotisation_id AS rhp_organisme_cotisation_id, + p_historique_paie.mois_activite::bigint AS mois_activite_id, + p_historique_paie.mois_activite::text AS mois_activite_code, + (base.cti_to_french(to_char((p_historique_paie.mois_activite::text || '01'::text)::timestamp without time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_activite::text, 1, 4) AS mois_activite_texte, + p_historique_paie.mois_activite::bigint AS annee_mois_activite_id, + p_historique_paie.mois_activite::text AS annee_mois_activite_code, + (base.cti_to_french(to_char((p_historique_paie.mois_activite::text || '01'::text)::timestamp without time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_mois_activite_texte, + (substr(p_historique_paie.mois_activite::text, 1, 4) || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text)::bigint AS annee_trimestre_activite_id, + substr(p_historique_paie.mois_activite::text, 1, 4) || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text) || ' '::text) || substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_historique_paie.mois_activite::text, 1, 4)::bigint AS annee_activite_id, + substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_activite_code, + substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_activite_texte, + substr(p_historique_paie.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_historique_paie.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char((p_historique_paie.mois_activite::text || '01'::text)::timestamp without time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::bigint AS trimestre_activite_id, + date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text AS trimestre_activite_texte, + p_historique_paie.mois_paie::bigint AS mois_paie_id, + p_historique_paie.mois_paie::text AS mois_paie_code, + (base.cti_to_french(to_char(p_historique_paie.date_paie::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_paie::text, 1, 4) AS mois_paie_texte, + p_historique_paie.mois_paie::bigint AS annee_mois_paie_id, + p_historique_paie.mois_paie::text AS annee_mois_paie_code, + (base.cti_to_french(to_char(p_historique_paie.date_paie::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_mois_paie_texte, + (substr(p_historique_paie.mois_paie::text, 1, 4) || date_part('quarter'::text, p_historique_paie.date_paie)::text)::bigint AS annee_trimestre_paie_id, + substr(p_historique_paie.mois_paie::text, 1, 4) || date_part('quarter'::text, p_historique_paie.date_paie)::text AS annee_trimestre_paie_code, + (('T'::text || date_part('quarter'::text, p_historique_paie.date_paie)::text) || ' '::text) || substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_trimestre_paie_texte, + substr(p_historique_paie.mois_paie::text, 1, 4)::bigint AS annee_paie_id, + substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_paie_code, + substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_paie_texte, + substr(p_historique_paie.mois_paie::text, 5, 2)::bigint AS mois_only_paie_id, + substr(p_historique_paie.mois_paie::text, 5, 2) AS mois_only_paie_code, + base.cti_to_french(to_char(p_historique_paie.date_paie::timestamp with time zone, 'Month'::text)) AS mois_only_paie_texte, + date_part('quarter'::text, p_historique_paie.date_paie)::bigint AS trimestre_paie_id, + date_part('quarter'::text, p_historique_paie.date_paie)::text AS trimestre_paie_code, + 'T'::text || date_part('quarter'::text, p_historique_paie.date_paie)::text AS trimestre_paie_texte, + p_historique_paie.mois_activite AS mois_activite_paie_id, + p_historique_paie.mois_activite AS mois_activite_paie_code, + ( + CASE date_part('month'::text, p_historique_paie.date_fin) + WHEN 1::double precision THEN 'Janvier'::text + WHEN 2::double precision THEN 'Février'::text + WHEN 3::double precision THEN 'Mars'::text + WHEN 4::double precision THEN 'Avril'::text + WHEN 5::double precision THEN 'Mai'::text + WHEN 6::double precision THEN 'Juin'::text + WHEN 7::double precision THEN 'Juillet'::text + WHEN 8::double precision THEN 'Aout'::text + WHEN 9::double precision THEN 'Septembre'::text + WHEN 10::double precision THEN 'Octobre'::text + WHEN 11::double precision THEN 'Novembre'::text + WHEN 12::double precision THEN 'Décembre'::text + ELSE date_part('month'::text, p_historique_paie.date_fin)::text + END || ' '::text) || date_part('year'::text, p_historique_paie.date_fin)::text AS mois_activite_paie_texte, + p_historique_paie.date_debut AS date_debut_paie, + p_historique_paie.date_fin AS date_fin_paie, + p_historique_paie.date_paie, + p_historique_paie.rubrique_id, + t_rubriques.code AS rubrique_code, + t_rubriques.texte AS rubrique_texte, + t_rubriques.rang_edition AS rubrique_rang_edition, + t_rubriques.section_id AS rubrique_section_id, + t_rubriques.section_code AS rubrique_section_code, + t_rubriques.section_texte AS rubrique_section_texte, + p_profil_contrat_mois.ratio * 999::numeric AS ratio, + p_contrats_mois.equivalent_temps_plein * p_profil_contrat_mois.ratio * 999::numeric AS equivalent_temps_plein, + p_historique_paie.base * p_profil_contrat_mois.ratio * + CASE + WHEN (@ t_rubriques.coefficient_base) = 1::numeric THEN 1::numeric + ELSE + CASE + WHEN t_rubriques.proratiser_conversion THEN p_contrats_mois.ratio_temps_travail + ELSE 1::numeric + END + END * t_rubriques.coefficient_base * 999::numeric AS base, + CASE + WHEN (@ t_rubriques.coefficient_base) = 1::numeric THEN p_historique_paie.nombre * t_rubriques.coefficient_nombre + ELSE p_historique_paie.base + END * p_profil_contrat_mois.ratio * 999::numeric AS nombre, + p_historique_paie.montant_brut * p_profil_contrat_mois.ratio * 999::numeric AS montant_brut, + p_historique_paie.montant_avantage_nature * p_profil_contrat_mois.ratio * 999::numeric AS montant_avantage_nature, + p_historique_paie.montant_frais_imposables * p_profil_contrat_mois.ratio * 999::numeric AS montant_frais_imposables, + p_historique_paie.taux_cotisation_salarie * p_profil_contrat_mois.ratio * t_rubriques.coefficient_txs * 999::numeric AS taux_cotisation_salarie, + p_historique_paie.montant_cotisation_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_cotisation_salarie, + p_historique_paie.montant_od_net_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_od_net_salarie, + p_historique_paie.montant_od_net_patronale * p_profil_contrat_mois.ratio * 999::numeric AS montant_od_net_patronale, + p_historique_paie.taux_cotisation_patronale * p_profil_contrat_mois.ratio * t_rubriques.coefficient_txp * 999::numeric AS taux_cotisation_patronale, + p_historique_paie.montant_cotisation_patronale * p_profil_contrat_mois.ratio * 999::numeric AS montant_cotisation_patronale, + p_historique_paie.montant_net_imposable_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_net_imposable_salarie, + p_historique_paie.montant_net_a_payer_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_net_a_payer_salarie, + (p_historique_paie.montant_brut + p_historique_paie.montant_avantage_nature + p_historique_paie.montant_frais_imposables + p_historique_paie.montant_cotisation_patronale + p_historique_paie.montant_od_net_patronale) * p_profil_contrat_mois.ratio * 999::numeric AS montant_masse_salariale, + CASE + WHEN t_rubriques.code_calcul::text = 10::text OR t_rubriques.code_calcul::text = 11::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END * p_profil_contrat_mois.ratio * 999::numeric AS heures_contrat, + base.cti_division( + CASE + WHEN t_rubriques.code_calcul::text = 10::text OR t_rubriques.code_calcul::text = 11::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) AS etp_contrat, + CASE + WHEN t_rubriques.code_calcul::text = 1::text OR t_rubriques.code_calcul::text = 11::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END * p_profil_contrat_mois.ratio * 999::numeric AS heures_payees, + CASE + WHEN t_divers.valeur = '0'::text THEN + CASE + WHEN t_rubriques.code_calcul::text = 1::text OR t_rubriques.code_calcul::text = 11::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END - + CASE + WHEN t_rubriques.code_calcul::text = 2::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END + ELSE + CASE + WHEN t_rubriques.code_calcul::text = 2::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END + END * p_profil_contrat_mois.ratio * 999::numeric AS heures_travaillees, + t_etablissements.base_calcul_etp, + CASE + WHEN t_rubriques.code::text = 'EFF1'::text THEN p_historique_paie.base * p_profil_contrat_mois.ratio * 999::numeric / 30::numeric + ELSE 0::numeric + END AS etp_30_paye, + base.cti_division( + CASE + WHEN t_rubriques.code_calcul::text = 1::text OR t_rubriques.code_calcul::text = 11::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) AS etp_heures_paye, + CASE + WHEN t_etablissements.mode_calcul_etp_paye::text = '1'::text THEN + CASE + WHEN t_rubriques.code::text = 'EFF1'::text THEN p_historique_paie.base * p_profil_contrat_mois.ratio * 999::numeric / 30::numeric + ELSE 0::numeric + END + ELSE base.cti_division( + CASE + WHEN t_rubriques.code_calcul::text = 1::text OR t_rubriques.code_calcul::text = 11::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) + END AS etp_paye, + base.cti_division( + CASE + WHEN t_divers.valeur = '0'::text THEN + CASE + WHEN t_rubriques.code_calcul::text = 1::text OR t_rubriques.code_calcul::text = 11::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END - + CASE + WHEN t_rubriques.code_calcul::text = 2::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END + ELSE + CASE + WHEN t_rubriques.code_calcul::text = 2::text THEN + CASE + WHEN t_rubriques.unite::text = 0::text THEN 1::numeric + ELSE t_rubriques.coefficient + END * p_historique_paie.base + ELSE 0::numeric + END + END * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) AS etp_travaille, + p_historique_paie.montant_brut_annuel AS montant_brut_annuel, + p_historique_paie.montant_brut_mensuel_moyen AS montant_brut_mensuel_moyen, + p_historique_paie.nombre_provisions * p_profil_contrat_mois.ratio AS nombre_provisions, + p_historique_paie.montant_provisions * p_profil_contrat_mois.ratio AS montant_provisions, + p_historique_paie.montant_masse_salariale_provisionnee * p_profil_contrat_mois.ratio AS montant_masse_salariale_provisionnee, + 999::bigint AS to_replace_id, + 'section_analytique_ng_code'::text AS to_replace_code, + 'section_analytique_ng_texte'::text AS to_replace_texte, + p_profil_contrat_mois.pole_id AS rhp_pole_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_historique_paie + JOIN ( SELECT 1) subq ON 1 = 1 + JOIN rh.t_divers ON t_divers.code = 'HEURES_W'::text + JOIN rh.p_salaries ON p_historique_paie.salarie_id = p_salaries.oid + JOIN rh.p_contrats_mois ON p_historique_paie.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid + JOIN rh.t_rubriques ON p_historique_paie.rubrique_id = t_rubriques.oid + JOIN rh.t_etablissements ON p_contrats_mois.etablissement_id = t_etablissements.oid + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/db/schema2/views/v_historique_paie_0_1.yaml b/db/schema2/views/v_historique_paie_0_1.yaml new file mode 100644 index 0000000..dfd18ff --- /dev/null +++ b/db/schema2/views/v_historique_paie_0_1.yaml @@ -0,0 +1,186 @@ +src: | + SELECT p_historique_paie.ctid, + p_historique_paie.ctid AS rhp_ctid, + p_historique_paie.etablissement_id AS rhp_etablissement_id, + p_historique_paie.salarie_id, + p_salaries.code_original AS salarie_code_original, + p_salaries.code AS salarie_code, + p_salaries.matricule, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + p_salaries.oid AS nir_id, + p_salaries.nir AS nir_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS nir_texte, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.date_debut AS date_debut_salarie, + p_salaries.date_fin AS date_fin_salarie, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_salaries.date_sortie_ets, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_historique_paie.contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.est_hors_periode, + p_contrats_mois.nombre_debut_contrat, + p_contrats_mois.nombre_fin_contrat, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_contrats_mois.age_id AS rhp_age_id, + p_salaries.date_anciennete, + p_contrats_mois.anciennete_jours, + p_contrats_mois.anciennete_reprise_jours, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_contrats_mois.anciennete_fp_annee_id AS rhp_anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_annee_id AS rhp_anciennete_fph_annee_id, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_historique_paie.compte_id AS rhp_compte_id, + p_historique_paie.organisme_cotisation_id AS rhp_organisme_cotisation_id, + p_historique_paie.mois_activite::bigint AS mois_activite_id, + p_historique_paie.mois_activite::text AS mois_activite_code, + (base.cti_to_french(to_char((p_historique_paie.mois_activite::text || '01'::text)::timestamp without time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_activite::text, 1, 4) AS mois_activite_texte, + p_historique_paie.mois_activite::bigint AS annee_mois_activite_id, + p_historique_paie.mois_activite::text AS annee_mois_activite_code, + (base.cti_to_french(to_char((p_historique_paie.mois_activite::text || '01'::text)::timestamp without time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_mois_activite_texte, + (substr(p_historique_paie.mois_activite::text, 1, 4) || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text)::bigint AS annee_trimestre_activite_id, + substr(p_historique_paie.mois_activite::text, 1, 4) || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text) || ' '::text) || substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_historique_paie.mois_activite::text, 1, 4)::bigint AS annee_activite_id, + substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_activite_code, + substr(p_historique_paie.mois_activite::text, 1, 4) AS annee_activite_texte, + substr(p_historique_paie.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_historique_paie.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char((p_historique_paie.mois_activite::text || '01'::text)::timestamp without time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::bigint AS trimestre_activite_id, + date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, (p_historique_paie.mois_activite::text || '01'::text)::date)::text AS trimestre_activite_texte, + p_historique_paie.mois_paie::bigint AS mois_paie_id, + p_historique_paie.mois_paie::text AS mois_paie_code, + (base.cti_to_french(to_char(p_historique_paie.date_paie::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_paie::text, 1, 4) AS mois_paie_texte, + p_historique_paie.mois_paie::bigint AS annee_mois_paie_id, + p_historique_paie.mois_paie::text AS annee_mois_paie_code, + (base.cti_to_french(to_char(p_historique_paie.date_paie::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_mois_paie_texte, + (substr(p_historique_paie.mois_paie::text, 1, 4) || date_part('quarter'::text, p_historique_paie.date_paie)::text)::bigint AS annee_trimestre_paie_id, + substr(p_historique_paie.mois_paie::text, 1, 4) || date_part('quarter'::text, p_historique_paie.date_paie)::text AS annee_trimestre_paie_code, + (('T'::text || date_part('quarter'::text, p_historique_paie.date_paie)::text) || ' '::text) || substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_trimestre_paie_texte, + substr(p_historique_paie.mois_paie::text, 1, 4)::bigint AS annee_paie_id, + substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_paie_code, + substr(p_historique_paie.mois_paie::text, 1, 4) AS annee_paie_texte, + substr(p_historique_paie.mois_paie::text, 5, 2)::bigint AS mois_only_paie_id, + substr(p_historique_paie.mois_paie::text, 5, 2) AS mois_only_paie_code, + base.cti_to_french(to_char(p_historique_paie.date_paie::timestamp with time zone, 'Month'::text)) AS mois_only_paie_texte, + date_part('quarter'::text, p_historique_paie.date_paie)::bigint AS trimestre_paie_id, + date_part('quarter'::text, p_historique_paie.date_paie)::text AS trimestre_paie_code, + 'T'::text || date_part('quarter'::text, p_historique_paie.date_paie)::text AS trimestre_paie_texte, + p_historique_paie.mois_activite AS mois_activite_paie_id, + p_historique_paie.mois_activite AS mois_activite_paie_code, + ( + CASE date_part('month'::text, p_historique_paie.date_fin) + WHEN 1::double precision THEN 'Janvier'::text + WHEN 2::double precision THEN 'Février'::text + WHEN 3::double precision THEN 'Mars'::text + WHEN 4::double precision THEN 'Avril'::text + WHEN 5::double precision THEN 'Mai'::text + WHEN 6::double precision THEN 'Juin'::text + WHEN 7::double precision THEN 'Juillet'::text + WHEN 8::double precision THEN 'Aout'::text + WHEN 9::double precision THEN 'Septembre'::text + WHEN 10::double precision THEN 'Octobre'::text + WHEN 11::double precision THEN 'Novembre'::text + WHEN 12::double precision THEN 'Décembre'::text + ELSE date_part('month'::text, p_historique_paie.date_fin)::text + END || ' '::text) || date_part('year'::text, p_historique_paie.date_fin)::text AS mois_activite_paie_texte, + p_historique_paie.date_debut AS date_debut_paie, + p_historique_paie.date_fin AS date_fin_paie, + p_historique_paie.date_paie, + p_historique_paie.rubrique_id, + t_rubriques.code AS rubrique_code, + t_rubriques.texte AS rubrique_texte, + t_rubriques.rang_edition AS rubrique_rang_edition, + t_rubriques.section_id AS rubrique_section_id, + t_rubriques.section_code AS rubrique_section_code, + t_rubriques.section_texte AS rubrique_section_texte, + p_profil_contrat_mois.ratio * 999::numeric AS ratio, + p_contrats_mois.equivalent_temps_plein * p_profil_contrat_mois.ratio * 999::numeric AS equivalent_temps_plein, + p_historique_paie.base * p_profil_contrat_mois.ratio * 999::numeric AS base, + p_historique_paie.nombre * p_profil_contrat_mois.ratio * 999::numeric AS nombre, + p_historique_paie.montant_brut * p_profil_contrat_mois.ratio * 999::numeric AS montant_brut, + p_historique_paie.montant_avantage_nature * p_profil_contrat_mois.ratio * 999::numeric AS montant_avantage_nature, + p_historique_paie.montant_frais_imposables * p_profil_contrat_mois.ratio * 999::numeric AS montant_frais_imposables, + p_historique_paie.taux_cotisation_salarie * p_profil_contrat_mois.ratio * 999::numeric AS taux_cotisation_salarie, + p_historique_paie.montant_cotisation_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_cotisation_salarie, + p_historique_paie.montant_od_net_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_od_net_salarie, + p_historique_paie.montant_od_net_patronale * p_profil_contrat_mois.ratio * 999::numeric AS montant_od_net_patronale, + p_historique_paie.taux_cotisation_patronale * p_profil_contrat_mois.ratio * 999::numeric AS taux_cotisation_patronale, + p_historique_paie.montant_cotisation_patronale * p_profil_contrat_mois.ratio * 999::numeric AS montant_cotisation_patronale, + p_historique_paie.montant_net_imposable_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_net_imposable_salarie, + p_historique_paie.montant_net_a_payer_salarie * p_profil_contrat_mois.ratio * 999::numeric AS montant_net_a_payer_salarie, + (p_historique_paie.montant_brut + p_historique_paie.montant_avantage_nature + p_historique_paie.montant_frais_imposables + p_historique_paie.montant_cotisation_patronale + p_historique_paie.montant_od_net_patronale) * p_profil_contrat_mois.ratio * 999::numeric AS montant_masse_salariale, + p_historique_paie.heure_contrat * p_profil_contrat_mois.ratio * 999::numeric AS heures_contrat, + p_historique_paie.heure_payee * p_profil_contrat_mois.ratio * 999::numeric AS heures_payees, + p_historique_paie.heure_travaillee * p_profil_contrat_mois.ratio * 999::numeric AS heures_travaillees, + base.cti_division(p_historique_paie.heure_contrat * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) AS etp_contrat, + t_etablissements.base_calcul_etp, + CASE + WHEN t_rubriques.code::text = 'EFF1'::text THEN p_historique_paie.base * p_profil_contrat_mois.ratio * 999::numeric / 30::numeric + ELSE 0::numeric + END AS etp_30_paye, + base.cti_division(p_historique_paie.heure_payee * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) AS etp_heures_paye, + CASE + WHEN t_etablissements.mode_calcul_etp_paye::text = '1'::text THEN + CASE + WHEN t_rubriques.code::text = 'EFF1'::text THEN p_historique_paie.base * p_profil_contrat_mois.ratio * 999::numeric / 30::numeric + ELSE 0::numeric + END + ELSE base.cti_division(p_historique_paie.heure_payee * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) + END AS etp_paye, + base.cti_division(p_historique_paie.heure_travaillee * p_profil_contrat_mois.ratio * 999::numeric, t_etablissements.base_calcul_etp) AS etp_travaille, + p_historique_paie.montant_brut_annuel AS montant_brut_annuel, + p_historique_paie.montant_brut_mensuel_moyen AS montant_brut_mensuel_moyen, + p_historique_paie.nombre_provisions * p_profil_contrat_mois.ratio AS nombre_provisions, + p_historique_paie.montant_provisions * p_profil_contrat_mois.ratio AS montant_provisions, + p_historique_paie.montant_masse_salariale_provisionnee * p_profil_contrat_mois.ratio AS montant_masse_salariale_provisionnee, + 999::bigint AS to_replace_id, + 'section_analytique_ng_code'::text AS to_replace_code, + 'section_analytique_ng_texte'::text AS to_replace_texte, + p_profil_contrat_mois.pole_id AS rhp_pole_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_historique_paie + JOIN ( SELECT 1) subq ON 1 = 1 + JOIN rh.t_divers ON t_divers.code = 'HEURES_W'::text + JOIN rh.p_salaries ON p_historique_paie.salarie_id = p_salaries.oid + JOIN rh.p_contrats_mois ON p_historique_paie.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid + JOIN rh.t_rubriques ON p_historique_paie.rubrique_id = t_rubriques.oid + JOIN rh.t_etablissements ON p_contrats_mois.etablissement_id = t_etablissements.oid + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/db/schema2/views/v_indicateur_externe_1.yaml b/db/schema2/views/v_indicateur_externe_1.yaml new file mode 100644 index 0000000..583891a --- /dev/null +++ b/db/schema2/views/v_indicateur_externe_1.yaml @@ -0,0 +1,21 @@ +src: | + SELECT p_indicateur_externe.import_id, + p_indicateur_externe.indicateur_code, + p_indicateur_externe.finess_id, + t_finess.code AS finess_code, + t_finess.texte AS finess_texte, + t_finess.section_id AS finess_section_id, + t_finess.section_code AS finess_section_code, + t_finess.section_texte AS finess_section_texte, + p_indicateur_externe.pole_id AS rhp_pole_id, + p_indicateur_externe.service_id, + t_services.code AS services_code, + t_services.texte AS services_texte, + t_services.section_id AS services_section_id, + t_services.section_code AS services_section_code, + t_services.section_texte AS services_section_texte, + p_indicateur_externe.date_reference, + p_indicateur_externe.value + FROM rh.p_indicateur_externe + JOIN rh.t_services ON p_indicateur_externe.service_id = t_services.oid + LEFT JOIN base.t_finess ON p_indicateur_externe.finess_id = t_finess.oid; \ No newline at end of file diff --git a/db/schema2/views/v_indicateurs_cumules_1.yaml b/db/schema2/views/v_indicateurs_cumules_1.yaml new file mode 100644 index 0000000..ab18679 --- /dev/null +++ b/db/schema2/views/v_indicateurs_cumules_1.yaml @@ -0,0 +1,6 @@ +src: | + SELECT p_indicateurs_cumules.date_reference AS jour_now, + date(date_trunc('month'::text, p_indicateurs_cumules.date_reference::timestamp with time zone) + '1 mon'::interval - '1 day'::interval) AS mois_now, + date(date_trunc('year'::text, p_indicateurs_cumules.date_reference::timestamp with time zone) + '1 year'::interval - '1 day'::interval) AS annee_now + FROM rh.p_indicateurs_cumules + WHERE p_indicateurs_cumules.periode_type = 'NOW'::text; \ No newline at end of file diff --git a/db/schema2/views/v_indicateurs_cumules_2.yaml b/db/schema2/views/v_indicateurs_cumules_2.yaml new file mode 100644 index 0000000..d2f732f --- /dev/null +++ b/db/schema2/views/v_indicateurs_cumules_2.yaml @@ -0,0 +1,26 @@ +src: | + SELECT p_indicateurs_cumules.indicateur_id, + 'rh.'::text || t_indicateurs.code AS indicateur_code, + date_part('month'::text, p_indicateurs_cumules.date_reference) AS mois, + p_indicateurs_cumules.date_reference, + CASE date_part('month'::text, p_indicateurs_cumules.date_reference) + WHEN 1 THEN 'Jan'::text + WHEN 2 THEN 'Fev'::text + WHEN 3 THEN 'Mars'::text + WHEN 4 THEN 'Avr'::text + WHEN 5 THEN 'Mai'::text + WHEN 6 THEN 'Juin'::text + WHEN 7 THEN 'Juil'::text + WHEN 8 THEN 'Aout'::text + WHEN 9 THEN 'Sep'::text + WHEN 10 THEN 'Oct'::text + WHEN 11 THEN 'Nov'::text + WHEN 12 THEN 'Dec'::text + ELSE date_part('month'::text, p_indicateurs_cumules.date_reference)::text + END AS mois_texte, + p_indicateurs_cumules.value, + p_indicateurs_cumules.value_cum, + p_indicateurs_cumules.value_cum12 + FROM rh.p_indicateurs_cumules + JOIN rh.t_indicateurs ON p_indicateurs_cumules.indicateur_id = t_indicateurs.oid + WHERE p_indicateurs_cumules.periode_type = 'M'::text; \ No newline at end of file diff --git a/db/schema2/views/v_indicateurs_cumules_2c.yaml b/db/schema2/views/v_indicateurs_cumules_2c.yaml new file mode 100644 index 0000000..3925a25 --- /dev/null +++ b/db/schema2/views/v_indicateurs_cumules_2c.yaml @@ -0,0 +1,24 @@ +src: | + SELECT 0 AS indicateur_id, + ''::text AS indicateur_code, + date_part('month'::text, p_calendrier_mois.date_debut) AS mois, + p_calendrier_mois.date_debut AS date_reference, + CASE date_part('month'::text, p_calendrier_mois.date_debut) + WHEN 1 THEN 'Jan'::text + WHEN 2 THEN 'Fev'::text + WHEN 3 THEN 'Mars'::text + WHEN 4 THEN 'Avr'::text + WHEN 5 THEN 'Mai'::text + WHEN 6 THEN 'Juin'::text + WHEN 7 THEN 'Juil'::text + WHEN 8 THEN 'Aout'::text + WHEN 9 THEN 'Sep'::text + WHEN 10 THEN 'Oct'::text + WHEN 11 THEN 'Nov'::text + WHEN 12 THEN 'Dec'::text + ELSE date_part('month'::text, p_calendrier_mois.date_debut)::text + END AS mois_texte, + 0 AS value, + 0 AS value_cum, + 0 AS value_cum12 + FROM base.p_calendrier_mois; \ No newline at end of file diff --git a/db/schema2/views/v_indicateurs_cumules_3.yaml b/db/schema2/views/v_indicateurs_cumules_3.yaml new file mode 100644 index 0000000..9ed6523 --- /dev/null +++ b/db/schema2/views/v_indicateurs_cumules_3.yaml @@ -0,0 +1,27 @@ +src: | + SELECT p_indicateurs_cumules.indicateur_id, + 'rh.'::text || t_indicateurs.code AS indicateur_code, + to_char(p_indicateurs_cumules.date_reference::timestamp with time zone, 'YYYYMMDD'::text) AS jour, + p_indicateurs_cumules.date_reference, + (date_part('day'::text, p_indicateurs_cumules.date_reference)::text || ' '::text) || + CASE date_part('month'::text, p_indicateurs_cumules.date_reference) + WHEN 1 THEN 'Jan'::text + WHEN 2 THEN 'Fev'::text + WHEN 3 THEN 'Mars'::text + WHEN 4 THEN 'Avr'::text + WHEN 5 THEN 'Mai'::text + WHEN 6 THEN 'Juin'::text + WHEN 7 THEN 'Juil'::text + WHEN 8 THEN 'Aout'::text + WHEN 9 THEN 'Sep'::text + WHEN 10 THEN 'Oct'::text + WHEN 11 THEN 'Nov'::text + WHEN 12 THEN 'Dec'::text + ELSE date_part('month'::text, p_indicateurs_cumules.date_reference)::text + END AS jour_texte, + p_indicateurs_cumules.value, + p_indicateurs_cumules.value_cum, + p_indicateurs_cumules.value_cum12 + FROM rh.p_indicateurs_cumules + JOIN rh.t_indicateurs ON p_indicateurs_cumules.indicateur_id = t_indicateurs.oid + WHERE p_indicateurs_cumules.periode_type = 'D'::text; \ No newline at end of file diff --git a/db/schema2/views/v_indicateurs_cumules_3c.yaml b/db/schema2/views/v_indicateurs_cumules_3c.yaml new file mode 100644 index 0000000..abacbbc --- /dev/null +++ b/db/schema2/views/v_indicateurs_cumules_3c.yaml @@ -0,0 +1,25 @@ +src: | + SELECT 0 AS indicateur_id, + ''::text AS indicateur_code, + to_char(p_calendrier.date::timestamp with time zone, 'YYYYMMDD'::text) AS jour, + p_calendrier.date AS date_reference, + (date_part('day'::text, p_calendrier.date)::text || ' '::text) || + CASE date_part('month'::text, p_calendrier.date) + WHEN 1 THEN 'Jan'::text + WHEN 2 THEN 'Fev'::text + WHEN 3 THEN 'Mars'::text + WHEN 4 THEN 'Avr'::text + WHEN 5 THEN 'Mai'::text + WHEN 6 THEN 'Juin'::text + WHEN 7 THEN 'Juil'::text + WHEN 8 THEN 'Aout'::text + WHEN 9 THEN 'Sep'::text + WHEN 10 THEN 'Oct'::text + WHEN 11 THEN 'Nov'::text + WHEN 12 THEN 'Dec'::text + ELSE date_part('month'::text, p_calendrier.date)::text + END AS jour_texte, + 0 AS value, + 0 AS value_cum, + 0 AS value_cum12 + FROM base.p_calendrier; \ No newline at end of file diff --git a/db/schema2/views/v_indicateurs_cumules_4.yaml b/db/schema2/views/v_indicateurs_cumules_4.yaml new file mode 100644 index 0000000..7025432 --- /dev/null +++ b/db/schema2/views/v_indicateurs_cumules_4.yaml @@ -0,0 +1,8 @@ +src: | + SELECT p_indicateurs_cumules.indicateur_id, + p_indicateurs_cumules.periode_type, + p_indicateurs_cumules.date_reference, + p_indicateurs_cumules.value, + p_indicateurs_cumules.value_cum, + p_indicateurs_cumules.value_cum12 + FROM rh.p_indicateurs_cumules; \ No newline at end of file diff --git a/db/schema2/views/v_lettre_budgetaire_1.yaml b/db/schema2/views/v_lettre_budgetaire_1.yaml new file mode 100644 index 0000000..35c4d38 --- /dev/null +++ b/db/schema2/views/v_lettre_budgetaire_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'LEB'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'LEB'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'LEB'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'LEB'::text + UNION ALL + SELECT 'DT'::text || t_lettre_budgetaire.oid::text AS oid, + (t_lettre_budgetaire.code::text || ' '::text) || t_lettre_budgetaire.texte_court::text AS texte, + t_lettre_budgetaire.code, + '1'::text AS level, + '9'::text || t_lettre_budgetaire.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_lettre_budgetaire + WHERE (t_lettre_budgetaire.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'lettre_budgetaire'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_liste_formations_1.yaml b/db/schema2/views/v_liste_formations_1.yaml new file mode 100644 index 0000000..a949e1e --- /dev/null +++ b/db/schema2/views/v_liste_formations_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'FOR'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FOR'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'FOR'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FOR'::text + UNION ALL + SELECT 'DT'::text || t_liste_formations.oid::text AS oid, + (t_liste_formations.code::text || ' '::text) || t_liste_formations.texte_court::text AS texte, + t_liste_formations.code, + '1'::text AS level, + '9'::text || t_liste_formations.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_liste_formations + WHERE (t_liste_formations.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'formations'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_liste_formations_2.yaml b/db/schema2/views/v_liste_formations_2.yaml new file mode 100644 index 0000000..fc783ce --- /dev/null +++ b/db/schema2/views/v_liste_formations_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_liste_formations.oid AS liste_formation_id, + t_liste_formations.code AS liste_formation_code, + t_liste_formations.texte AS liste_formation_texte, + t_liste_formations.section_id AS liste_formation_section_id, + t_liste_formations.section_code AS liste_formation_section_code, + t_liste_formations.section_texte AS liste_formation_section_texte + FROM rh.t_liste_formations; \ No newline at end of file diff --git a/db/schema2/views/v_listes_1.yaml b/db/schema2/views/v_listes_1.yaml new file mode 100644 index 0000000..e4a6091 --- /dev/null +++ b/db/schema2/views/v_listes_1.yaml @@ -0,0 +1,134 @@ +dep: + - v_listes_4 +src: | + SELECT v_listes_4.table_texte || chr(1) AS sort, + v_listes_4.table_id, + v_listes_4.table_code, + (v_listes_4.table_texte || + CASE + WHEN count(DISTINCT + CASE + WHEN v_listes_4.liste_id <> 0 THEN v_listes_4.liste_id + ELSE NULL::bigint + END) > 0 THEN (' ('::text || count(DISTINCT + CASE + WHEN v_listes_4.liste_id <> 0 THEN v_listes_4.liste_id + ELSE NULL::bigint + END)::text) || ')'::text + ELSE ''::text + END)::character varying AS texte, + 0 AS liste_id, + '0'::text AS lvl, + ''::text AS code, + '0'::text AS is_cti, + '0'::text AS is_groupe, + v_listes_4.table_schema AS schema, + ''::text AS utilisateur_createur, + ''::text AS est_partagee_modification, + '0'::text AS liste_show_omit, + '0'::text AS liste_is_omit, + ''::text AS chapitre, + ''::text AS sous_chapitre, + '-8'::text AS liste_id_combo, + ''::text AS liste_alias_combo + FROM rh.v_listes_4 + GROUP BY v_listes_4.table_id, v_listes_4.table_code, v_listes_4.table_texte, v_listes_4.table_schema + UNION ALL + SELECT (((v_listes_4.table_texte || chr(1)) || v_listes_4.liste_chapitre_sortkey) || v_listes_4.liste_chapitre) || chr(1) AS sort, + v_listes_4.table_id, + v_listes_4.table_code, + (v_listes_4.liste_chapitre || + CASE + WHEN count(DISTINCT v_listes_4.liste_id) > 0 THEN (' ('::text || count(DISTINCT v_listes_4.liste_id)::text) || ')'::text + ELSE ''::text + END)::character varying AS texte, + 0 AS liste_id, + '1'::text AS lvl, + ''::text AS code, + '0'::text AS is_cti, + '0'::text AS is_groupe, + v_listes_4.table_schema AS schema, + ''::text AS utilisateur_createur, + ''::text AS est_partagee_modification, + '0'::text AS liste_show_omit, + '0'::text AS liste_is_omit, + (v_listes_4.liste_chapitre || + CASE + WHEN count(DISTINCT v_listes_4.liste_id) > 0 THEN (' ('::text || count(DISTINCT v_listes_4.liste_id)::text) || ')'::text + ELSE ''::text + END)::character varying AS chapitre, + ''::text AS sous_chapitre, + '-8'::text AS liste_id_combo, + ''::text AS liste_alias_combo + FROM rh.v_listes_4 + WHERE v_listes_4.liste_id <> 0 AND v_listes_4.liste_chapitre <> ''::text + GROUP BY v_listes_4.table_id, v_listes_4.table_code, v_listes_4.table_texte, v_listes_4.liste_chapitre, v_listes_4.liste_chapitre_sortkey, v_listes_4.table_schema + UNION ALL + SELECT (((((v_listes_4.table_texte || chr(1)) || v_listes_4.liste_chapitre_sortkey) || v_listes_4.liste_chapitre) || chr(1)) || v_listes_4.liste_sous_chapitre) || chr(1) AS sort, + v_listes_4.table_id, + v_listes_4.table_code, + (v_listes_4.liste_sous_chapitre || + CASE + WHEN count(DISTINCT v_listes_4.liste_id) > 0 THEN (' ('::text || count(DISTINCT v_listes_4.liste_id)::text) || ')'::text + ELSE ''::text + END)::character varying AS texte, + 0 AS liste_id, + '2'::text AS lvl, + ''::text AS code, + '0'::text AS is_cti, + '0'::text AS is_groupe, + v_listes_4.table_schema AS schema, + ''::text AS utilisateur_createur, + ''::text AS est_partagee_modification, + '0'::text AS liste_show_omit, + '0'::text AS liste_is_omit, + (v_listes_4.liste_chapitre || + CASE + WHEN count(DISTINCT v_listes_4.liste_id) > 0 THEN (' ('::text || count(DISTINCT v_listes_4.liste_id)::text) || ')'::text + ELSE ''::text + END)::character varying AS chapitre, + (v_listes_4.liste_sous_chapitre || + CASE + WHEN count(DISTINCT v_listes_4.liste_id) > 0 THEN (' ('::text || count(DISTINCT v_listes_4.liste_id)::text) || ')'::text + ELSE ''::text + END)::character varying AS sous_chapitre, + '-8'::text AS liste_id_combo, + ''::text AS liste_alias_combo + FROM rh.v_listes_4 + WHERE v_listes_4.liste_id <> 0 AND v_listes_4.liste_sous_chapitre <> ''::text + GROUP BY v_listes_4.table_id, v_listes_4.table_code, v_listes_4.table_texte, v_listes_4.liste_chapitre, v_listes_4.liste_chapitre_sortkey, v_listes_4.liste_sous_chapitre, v_listes_4.table_schema + UNION ALL + SELECT (((((((v_listes_4.table_texte || chr(1)) || v_listes_4.liste_chapitre_sortkey) || v_listes_4.liste_chapitre) || chr(1)) || v_listes_4.liste_sous_chapitre) || chr(1)) || v_listes_4.liste_is_omit) || v_listes_4.liste_texte AS sort, + v_listes_4.table_id, + v_listes_4.table_code, + v_listes_4.liste_texte AS texte, + v_listes_4.liste_id, + CASE + WHEN v_listes_4.liste_chapitre = ''::text THEN '1'::text + WHEN v_listes_4.liste_sous_chapitre = ''::text THEN '2'::text + ELSE '3'::text + END AS lvl, + v_listes_4.liste_code AS code, + v_listes_4.liste_is_cti AS is_cti, + v_listes_4.liste_is_groupe AS is_groupe, + v_listes_4.table_schema AS schema, + v_listes_4.liste_utilisateur_createur AS utilisateur_createur, + v_listes_4.liste_est_partagee_modification AS est_partagee_modification, + v_listes_4.liste_show_omit, + v_listes_4.liste_is_omit, + v_listes_4.liste_chapitre AS chapitre, + v_listes_4.liste_sous_chapitre AS sous_chapitre, + CASE + WHEN v_listes_4.liste_id = 0 THEN '-8'::text + WHEN v_listes_4.liste_is_omit = '1'::text THEN 'SL'::text || v_listes_4.liste_id::text + ELSE 'LI'::text || v_listes_4.liste_id::text + END AS liste_id_combo, + CASE + WHEN v_listes_4.liste_id = 0 THEN ''::text + WHEN v_listes_4.liste_code = ''::text THEN ''::text + WHEN v_listes_4.liste_is_omit = '1'::text THEN '#SL'::text || v_listes_4.liste_code + ELSE '#LI'::text || v_listes_4.liste_code + END AS liste_alias_combo + FROM rh.v_listes_4 + WHERE v_listes_4.liste_id <> 0 + ORDER BY 1; \ No newline at end of file diff --git a/db/schema2/views/v_listes_2.yaml b/db/schema2/views/v_listes_2.yaml new file mode 100644 index 0000000..38350a8 --- /dev/null +++ b/db/schema2/views/v_listes_2.yaml @@ -0,0 +1,10 @@ +src: | + SELECT t_listes_tables.name AS table_name, + t_listes_tables.texte AS table_texte, + t_listes.oid AS liste_id, + t_listes.texte AS liste_texte, + t_listes_contenu.to_id + FROM rh.t_listes, + rh.t_listes_tables, + rh.t_listes_contenu + WHERE t_listes.table_id = t_listes_tables.oid AND t_listes.oid = t_listes_contenu.liste_id; \ No newline at end of file diff --git a/db/schema2/views/v_listes_3.yaml b/db/schema2/views/v_listes_3.yaml new file mode 100644 index 0000000..3dc6512 --- /dev/null +++ b/db/schema2/views/v_listes_3.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_listes.oid AS liste_id, + t_listes.code AS liste_code, + t_listes.texte AS liste_texte, + t_listes_contenu.to_id + FROM rh.t_listes, + rh.t_listes_contenu + WHERE t_listes.oid = t_listes_contenu.liste_id; \ No newline at end of file diff --git a/db/schema2/views/v_listes_4.yaml b/db/schema2/views/v_listes_4.yaml new file mode 100644 index 0000000..f584929 --- /dev/null +++ b/db/schema2/views/v_listes_4.yaml @@ -0,0 +1,163 @@ +src: | + SELECT 'rh'::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::text) AS liste_code, + COALESCE(t_listes.texte, ''::character varying::text) AS liste_texte, + COALESCE(t_listes.is_cti, '0'::bpchar) AS liste_is_cti, + CASE + WHEN substr(t_listes.code, 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::text) 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, 1, 4) = 'CTI_'::text THEN 'Listes CTI'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 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, 1, 4) = 'CTI_'::text THEN '3'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'HPM_'::text THEN '2'::text + ELSE '1'::text + END AS liste_chapitre_sortkey, + COALESCE(t_listes.chapitre, ''::character varying::text) AS liste_sous_chapitre + FROM rh.t_listes_tables + LEFT JOIN rh.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 'rh'::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::text) AS liste_code, + COALESCE('Sauf '::text || t_listes.texte, ''::character varying::text) AS liste_texte, + COALESCE(t_listes.is_cti, '0'::bpchar) AS liste_is_cti, + CASE + WHEN substr(t_listes.code, 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::text) 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, 1, 4) = 'CTI_'::text THEN 'Listes CTI'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 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, 1, 4) = 'CTI_'::text THEN '3'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'HPM_'::text THEN '2'::text + ELSE '1'::text + END AS liste_chapitre_sortkey, + COALESCE(t_listes.chapitre, ''::character varying::text) AS liste_sous_chapitre + FROM rh.t_listes_tables + LEFT JOIN rh.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 + UNION ALL + SELECT 'base'::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, ''::text) AS liste_code, + COALESCE(t_listes.texte, ''::text) AS liste_texte, + COALESCE(t_listes.is_cti, '0'::bpchar) AS liste_is_cti, + CASE + WHEN substr(t_listes.code, 1, 4) = ANY (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text]) THEN '1'::text + ELSE '0'::text + END AS liste_is_groupe, + COALESCE(t_listes.utilisateur_createur, ''::text) 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, 1, 4) = 'CTI_'::text THEN 'Listes CTI'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 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, 1, 4) = 'CTI_'::text THEN '3'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'HPM_'::text THEN '2'::text + ELSE '1'::text + END AS liste_chapitre_sortkey, + COALESCE(t_listes.chapitre, ''::text) AS liste_sous_chapitre + FROM base.t_listes_tables + LEFT JOIN base.t_settings ON t_settings.code = 'REFSETTINGS/PREFIX'::text + LEFT JOIN base.t_listes ON t_listes.table_id = t_listes_tables.oid + WHERE t_listes_tables.code = ANY (ARRAY['POLE'::text]) + UNION ALL + SELECT 'base'::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, ''::text) AS liste_code, + COALESCE('Sauf '::text || t_listes.texte, ''::text) AS liste_texte, + COALESCE(t_listes.is_cti, '0'::bpchar) AS liste_is_cti, + CASE + WHEN substr(t_listes.code, 1, 4) = ANY (ARRAY['VIT_'::text, 'VED_'::text, 'HPM_'::text]) THEN '1'::text + ELSE '0'::text + END AS liste_is_groupe, + COALESCE(t_listes.utilisateur_createur, ''::text) 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, 1, 4) = 'CTI_'::text THEN 'Listes CTI'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN 'Listes Groupe'::text + WHEN substr(t_listes.code, 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, 1, 4) = 'CTI_'::text THEN '3'::text + WHEN t_settings.value <> ''::text AND substr(t_listes.code, 1, 4) = (t_settings.value || '_'::text) THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VIT_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'VED_'::text THEN '2'::text + WHEN substr(t_listes.code, 1, 4) = 'HPM_'::text THEN '2'::text + ELSE '1'::text + END AS liste_chapitre_sortkey, + COALESCE(t_listes.chapitre, ''::text) AS liste_sous_chapitre + FROM base.t_listes_tables + LEFT JOIN base.t_settings ON t_settings.code = 'REFSETTINGS/PREFIX'::text + LEFT JOIN base.t_listes ON t_listes.table_id = t_listes_tables.oid + WHERE (t_listes_tables.code = ANY (ARRAY['POLE'::text])) AND t_listes.show_omit = '1'::bpchar; \ No newline at end of file diff --git a/db/schema2/views/v_motifs_arret_1.yaml b/db/schema2/views/v_motifs_arret_1.yaml new file mode 100644 index 0000000..898ce4f --- /dev/null +++ b/db/schema2/views/v_motifs_arret_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'MOA'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MOA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'MOA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MOA'::text + UNION ALL + SELECT 'DT'::text || t_motifs_arret.oid::text AS oid, + (t_motifs_arret.code::text || ' '::text) || t_motifs_arret.texte::text AS texte, + t_motifs_arret.code, + '1'::text AS level, + '9'::text || t_motifs_arret.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_motifs_arret + WHERE (t_motifs_arret.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'motifs_arret'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_motifs_arret_2.yaml b/db/schema2/views/v_motifs_arret_2.yaml new file mode 100644 index 0000000..d5337ce --- /dev/null +++ b/db/schema2/views/v_motifs_arret_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_motifs_arret.oid AS motif_arret_id, + t_motifs_arret.code AS motif_arret_code, + t_motifs_arret.texte AS motif_arret_texte, + t_motifs_arret.section_id AS motif_arret_section_id, + t_motifs_arret.section_code AS motif_arret_section_code, + t_motifs_arret.section_texte AS motif_arret_section_texte + FROM rh.t_motifs_arret; \ No newline at end of file diff --git a/db/schema2/views/v_motifs_debut_contrat_1.yaml b/db/schema2/views/v_motifs_debut_contrat_1.yaml new file mode 100644 index 0000000..54bda95 --- /dev/null +++ b/db/schema2/views/v_motifs_debut_contrat_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'MTD'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MTD'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'MTD'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MTD'::text + UNION ALL + SELECT 'DT'::text || t_motifs_debut_contrat.oid::text AS oid, + (t_motifs_debut_contrat.code::text || ' '::text) || t_motifs_debut_contrat.texte_court::text AS texte, + t_motifs_debut_contrat.code, + '1'::text AS level, + '9'::text || t_motifs_debut_contrat.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_motifs_debut_contrat + WHERE (t_motifs_debut_contrat.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'motifs_debut_contrat'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_motifs_fin_contrat_1.yaml b/db/schema2/views/v_motifs_fin_contrat_1.yaml new file mode 100644 index 0000000..e27ba96 --- /dev/null +++ b/db/schema2/views/v_motifs_fin_contrat_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'MTF'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MTF'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'MTF'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MTF'::text + ) UNION + SELECT 'DT'::text || t_motifs_fin_contrat.oid::text AS oid, + (t_motifs_fin_contrat.code::text || ' '::text) || t_motifs_fin_contrat.texte_court::text AS texte, + t_motifs_fin_contrat.code, + '1'::text AS level, + '9'::text || t_motifs_fin_contrat.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_motifs_fin_contrat + WHERE (t_motifs_fin_contrat.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'motifs_fin_contrat'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_motifs_visite_1.yaml b/db/schema2/views/v_motifs_visite_1.yaml new file mode 100644 index 0000000..473a809 --- /dev/null +++ b/db/schema2/views/v_motifs_visite_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'MVM'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MVM'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'MVM'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MVM'::text + UNION ALL + SELECT 'DT'::text || t_motifs_visite.oid::text AS oid, + (t_motifs_visite.code::text || ' '::text) || t_motifs_visite.texte_court::text AS texte, + t_motifs_visite.code, + '1'::text AS level, + '9'::text || t_motifs_visite.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_motifs_visite + WHERE (t_motifs_visite.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'motifs_visite'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_motifs_visite_2.yaml b/db/schema2/views/v_motifs_visite_2.yaml new file mode 100644 index 0000000..d0d69be --- /dev/null +++ b/db/schema2/views/v_motifs_visite_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_motifs_visite.oid AS motif_visite_id, + t_motifs_visite.code AS motif_visite_code, + t_motifs_visite.texte AS motif_visite_texte, + t_motifs_visite.section_id AS motif_visite_section_id, + t_motifs_visite.section_code AS motif_visite_section_code, + t_motifs_visite.section_texte AS motif_visite_section_texte + FROM rh.t_motifs_visite; \ No newline at end of file diff --git a/db/schema2/views/v_nationalites_1.yaml b/db/schema2/views/v_nationalites_1.yaml new file mode 100644 index 0000000..18d3476 --- /dev/null +++ b/db/schema2/views/v_nationalites_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ATC'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'NAT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'NAT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'NAT'::text + UNION ALL + SELECT 'DT'::text || t_nationalites.oid::text AS oid, + (t_nationalites.code::text || ' '::text) || t_nationalites.texte_court::text AS texte, + t_nationalites.code, + '1'::text AS level, + '9'::text || t_nationalites.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_nationalites + WHERE (t_nationalites.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'nationalites'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_nationalites_2.yaml b/db/schema2/views/v_nationalites_2.yaml new file mode 100644 index 0000000..553f344 --- /dev/null +++ b/db/schema2/views/v_nationalites_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_nationalites.oid AS nationalite_id, + t_nationalites.code AS nationalite_code, + t_nationalites.texte AS nationalite_texte, + t_nationalites.section_id AS nationalite_section_id, + t_nationalites.section_code AS nationalite_section_code, + t_nationalites.section_texte AS nationalite_section_texte + FROM rh.t_nationalites; \ No newline at end of file diff --git a/db/schema2/views/v_organismes_cotisation_1.yaml b/db/schema2/views/v_organismes_cotisation_1.yaml new file mode 100644 index 0000000..8d7d0ff --- /dev/null +++ b/db/schema2/views/v_organismes_cotisation_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ORC'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ORC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ORC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ORC'::text + UNION ALL + SELECT 'DT'::text || t_organismes_cotisation.oid::text AS oid, + (t_organismes_cotisation.code || ' '::text) || t_organismes_cotisation.texte_court::text AS texte, + t_organismes_cotisation.code, + '1'::text AS level, + '9'::text || t_organismes_cotisation.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_organismes_cotisation + WHERE (t_organismes_cotisation.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'organismes_cotisation'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_organismes_cotisation_2.yaml b/db/schema2/views/v_organismes_cotisation_2.yaml new file mode 100644 index 0000000..3fb548c --- /dev/null +++ b/db/schema2/views/v_organismes_cotisation_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_organismes_cotisation.oid AS organisme_cotisation_id, + t_organismes_cotisation.code AS organisme_cotisation_code, + t_organismes_cotisation.texte AS organisme_cotisation_texte, + t_organismes_cotisation.section_id AS organisme_cotisation_section_id, + t_organismes_cotisation.section_code AS organisme_cotisation_section_code, + t_organismes_cotisation.section_texte AS organisme_cotisation_section_texte + FROM rh.t_organismes_cotisation; \ No newline at end of file diff --git a/db/schema2/views/v_personne_2.yaml b/db/schema2/views/v_personne_2.yaml new file mode 100644 index 0000000..0e51297 --- /dev/null +++ b/db/schema2/views/v_personne_2.yaml @@ -0,0 +1,9 @@ +src: | + SELECT p_personne.oid AS personne_id, + p_personne.matricule_courant AS personne_code, + ((p_personne.nom || ' '::text) || p_personne.prenom::text) || + CASE + WHEN p_personne.nom_naissance = ''::text THEN ''::text + ELSE (' (née '::text || p_personne.nom_naissance) || ')'::text + END AS personne_texte + FROM rh.p_personne; \ No newline at end of file diff --git a/db/schema2/views/v_planning_code_horaire_1.yaml b/db/schema2/views/v_planning_code_horaire_1.yaml new file mode 100644 index 0000000..b9e89ab --- /dev/null +++ b/db/schema2/views/v_planning_code_horaire_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'PCH'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PCH'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'PCH'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PCH'::text + ) UNION + SELECT 'DT'::text || t_planning_code_horaire.oid::text AS oid, + (t_planning_code_horaire.code::text || ' '::text) || t_planning_code_horaire.texte_court::text AS texte, + t_planning_code_horaire.code, + '1'::text AS level, + '9'::text || t_planning_code_horaire.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_planning_code_horaire + WHERE (t_planning_code_horaire.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'planning_code_horaire'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_planning_code_horaire_2.yaml b/db/schema2/views/v_planning_code_horaire_2.yaml new file mode 100644 index 0000000..026a13a --- /dev/null +++ b/db/schema2/views/v_planning_code_horaire_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_planning_code_horaire.oid AS planning_code_horaire_id, + t_planning_code_horaire.code AS planning_code_horaire_code, + t_planning_code_horaire.texte AS planning_code_horaire_texte, + t_planning_code_horaire.section_id AS planning_code_horaire_section_id, + t_planning_code_horaire.section_code AS planning_code_horaire_section_code, + t_planning_code_horaire.section_texte AS planning_code_horaire_section_texte + FROM rh.t_planning_code_horaire; \ No newline at end of file diff --git a/db/schema2/views/v_planning_etablissement_2.yaml b/db/schema2/views/v_planning_etablissement_2.yaml new file mode 100644 index 0000000..45a398c --- /dev/null +++ b/db/schema2/views/v_planning_etablissement_2.yaml @@ -0,0 +1,15 @@ +src: | + SELECT t_etablissements.oid AS planning_etablissement_id, + t_etablissements.code AS planning_etablissement_code, + t_etablissements.texte AS planning_etablissement_texte, + t_etablissements.section_id AS planning_etablissement_section_id, + t_etablissements.section_code AS planning_etablissement_section_code, + t_etablissements.section_texte AS planning_etablissement_section_texte, + t_entreprises.oid AS planning_entreprise_id, + t_entreprises.code AS planning_entreprise_code, + t_entreprises.texte AS planning_entreprise_texte, + t_entreprises.section_id AS planning_entreprise_section_id, + t_entreprises.section_code AS planning_entreprise_section_code, + t_entreprises.section_texte AS planning_entreprise_section_texte + FROM rh.t_etablissements + JOIN rh.t_entreprises ON t_entreprises.oid = t_etablissements.entreprise_id; \ No newline at end of file diff --git a/db/schema2/views/v_planning_mouvement_1.yaml b/db/schema2/views/v_planning_mouvement_1.yaml new file mode 100644 index 0000000..14685a6 --- /dev/null +++ b/db/schema2/views/v_planning_mouvement_1.yaml @@ -0,0 +1,122 @@ +src: | + SELECT p_planning_mouvement.ctid, + p_salaries.finess, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.code_original, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_contrats_mois.etablissement_id AS rhp_etablissement_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.oid AS contrat_mois_id, + p_planning_mouvement.mois::bigint AS mois_activite_id, + p_planning_mouvement.mois::text AS mois_activite_code, + (base.cti_to_french(to_char((p_planning_mouvement.mois::text || '01'::text)::timestamp without time zone, 'Month'::text)) || ' '::text) || substr(p_planning_mouvement.mois::text, 1, 4) AS mois_activite_texte, + p_planning_mouvement.mois AS annee_mois_activite_id, + p_planning_mouvement.mois AS annee_mois_activite_code, + ( + CASE + WHEN date_part('month'::text, p_planning_mouvement.date) = 1::double precision THEN 'Janvier'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 2::double precision THEN 'Février'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 3::double precision THEN 'Mars'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 4::double precision THEN 'Avril'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 5::double precision THEN 'Mai'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 6::double precision THEN 'Juin'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 7::double precision THEN 'Juillet'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 8::double precision THEN 'Aout'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 9::double precision THEN 'Septembre'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 10::double precision THEN 'Octobre'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 11::double precision THEN 'Novembre'::text + WHEN date_part('month'::text, p_planning_mouvement.date) = 12::double precision THEN 'Décembre'::text + ELSE date_part('month'::text, p_planning_mouvement.date)::text + END || ' '::text) || date_part('year'::text, p_planning_mouvement.date)::text AS annee_mois_activite_texte, + date_part('year'::text, p_planning_mouvement.date) AS annee_activite_id, + date_part('year'::text, p_planning_mouvement.date) AS annee_activite_code, + date_part('year'::text, p_planning_mouvement.date) AS annee_activite_texte, + (substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text)::bigint AS annee_trimestre_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_contrats_mois.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_contrats_mois.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, p_contrats_mois.date_fin)::bigint AS trimestre_activite_id, + date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_texte, + to_char(p_planning_mouvement.date::timestamp with time zone, 'IYYYIW'::text) AS semaine_activite_id, + to_char(p_planning_mouvement.date::timestamp with time zone, 'IYYY-IW'::text) AS semaine_activite_code, + 'Semaine '::text || base.cti_to_french(to_char(p_planning_mouvement.date::timestamp with time zone, 'IW IYYY'::text)) AS semaine_activite_texte, + to_char(p_planning_mouvement.date::timestamp with time zone, 'YYYYMMDD'::text) AS jour_activite_id, + to_char(p_planning_mouvement.date::timestamp with time zone, 'YYYY-MM-DD'::text) AS jour_activite_code, + base.cti_to_french(to_char(p_planning_mouvement.date::timestamp with time zone, 'Day DD month YYYY'::text)) AS jour_activite_texte, + p_planning_mouvement.date AS date_debut_activite, + p_planning_mouvement.date AS date_fin_activite, + p_contrats_mois.age_id AS rhp_age_id, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_reprise_mois, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id AS rhp_anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id AS rhp_anciennete_fph_annee_id, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_planning_mouvement.service_id AS rhp_planning_service_id, + p_planning_mouvement.qualification_id AS rhp_planning_qualification_id, + p_planning_mouvement.type_absence_id AS rhp_planning_type_absence_id, + p_planning_mouvement.etablissement_id AS rhp_planning_etablissement_id, + p_planning_mouvement.code_horaire_id AS rhp_planning_code_horaire_id, + p_planning_mouvement.niveau_id AS rhp_planning_niveau_id, + p_planning_mouvement.temps_du * p_profil_contrat_mois.ratio AS temps_du, + p_planning_mouvement.temps_du_initial * p_profil_contrat_mois.ratio AS temps_du_initial, + p_planning_mouvement.temps_valide * p_profil_contrat_mois.ratio AS temps_valide, + p_planning_mouvement.temps_presence * p_profil_contrat_mois.ratio AS temps_presence, + p_planning_mouvement.temps_absence * p_profil_contrat_mois.ratio AS temps_absence, + p_planning_mouvement.temps_hs * p_profil_contrat_mois.ratio AS temps_hs, + p_planning_mouvement.temps_hc * p_profil_contrat_mois.ratio AS temps_hc, + p_planning_mouvement.pole_id AS rhp_pole_id, + p_planning_mouvement.temps_du_ajuste * p_profil_contrat_mois.ratio AS temps_du_ajuste, + p_planning_mouvement.temps_valide_ajuste * p_profil_contrat_mois.ratio AS temps_valide_ajuste, + p_planning_mouvement.temps_presence_ajuste * p_profil_contrat_mois.ratio AS temps_presence_ajuste, + p_planning_mouvement.temps_absence_ajuste * p_profil_contrat_mois.ratio AS temps_absence_ajuste, + p_planning_mouvement.absence_id AS planning_absence_id, + p_planning_mouvement.absence_nb_jours AS planning_absence_nb_jours, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_planning_mouvement + JOIN rh.p_salaries ON p_planning_mouvement.salarie_id = p_salaries.oid + JOIN rh.p_contrats ON p_planning_mouvement.contrat_id = p_contrats.oid + JOIN rh.p_contrats_mois ON p_planning_mouvement.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/db/schema2/views/v_planning_niveau_1.yaml b/db/schema2/views/v_planning_niveau_1.yaml new file mode 100755 index 0000000..2b124b9 --- /dev/null +++ b/db/schema2/views/v_planning_niveau_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'PNI'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PNI'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'PNI'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PNI'::text + ) UNION + SELECT 'DT'::text || t_planning_niveau.oid::text AS oid, + (t_planning_niveau.code || ' '::text) || t_planning_niveau.texte_court::text AS texte, + t_planning_niveau.code, + '1'::text AS level, + '9'::text || t_planning_niveau.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_planning_niveau + WHERE (t_planning_niveau.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'planning_niveau'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_planning_niveau_2.yaml b/db/schema2/views/v_planning_niveau_2.yaml new file mode 100644 index 0000000..b6270a5 --- /dev/null +++ b/db/schema2/views/v_planning_niveau_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_planning_niveau.oid AS planning_niveau_id, + t_planning_niveau.code AS planning_niveau_code, + t_planning_niveau.texte AS planning_niveau_texte, + t_planning_niveau.section_id AS planning_niveau_section_id, + t_planning_niveau.section_code AS planning_niveau_section_code, + t_planning_niveau.section_texte AS planning_niveau_section_texte + FROM rh.t_planning_niveau; \ No newline at end of file diff --git a/db/schema2/views/v_planning_qualification_1.yaml b/db/schema2/views/v_planning_qualification_1.yaml new file mode 100644 index 0000000..db8c1db --- /dev/null +++ b/db/schema2/views/v_planning_qualification_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'PQU'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PQU'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'PQU'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PQU'::text + UNION ALL + SELECT 'DT'::text || t_planning_qualification.oid::text AS oid, + (t_planning_qualification.code::text || ' '::text) || t_planning_qualification.texte_court::text AS texte, + t_planning_qualification.code, + '1'::text AS level, + '9'::text || t_planning_qualification.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_planning_qualification + WHERE (t_planning_qualification.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'planning_qualification'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_planning_qualification_2.yaml b/db/schema2/views/v_planning_qualification_2.yaml new file mode 100644 index 0000000..a06d941 --- /dev/null +++ b/db/schema2/views/v_planning_qualification_2.yaml @@ -0,0 +1,14 @@ +src: | + SELECT t_planning_qualification.oid AS planning_qualification_source_id, + t_planning_qualification.code AS planning_qualification_source_code, + t_planning_qualification.texte AS planning_qualification_source_texte, + t_planning_qualification.section_id AS planning_qualification_source_section_id, + t_planning_qualification.section_code AS planning_qualification_source_section_code, + t_planning_qualification.section_texte AS planning_qualification_source_section_texte, + t_planning_qualification.qualification_id AS planning_qualification_id, + t_planning_qualification.qualification_code AS planning_qualification_code, + t_planning_qualification.qualification_texte AS planning_qualification_texte, + t_planning_qualification.qualification_section_id AS planning_qualification_section_id, + t_planning_qualification.qualification_section_code AS planning_qualification_section_code, + t_planning_qualification.qualification_section_texte AS planning_qualification_section_texte + FROM rh.t_planning_qualification; \ No newline at end of file diff --git a/db/schema2/views/v_planning_service_1.yaml b/db/schema2/views/v_planning_service_1.yaml new file mode 100644 index 0000000..2d7b065 --- /dev/null +++ b/db/schema2/views/v_planning_service_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'PSE'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PSE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'PSE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PSE'::text + ) UNION + SELECT 'DT'::text || t_planning_service.oid::text AS oid, + (t_planning_service.code::text || ' '::text) || t_planning_service.texte_court::text AS texte, + t_planning_service.code, + '1'::text AS level, + '9'::text || t_planning_service.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_planning_service + WHERE (t_planning_service.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'planning_service'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_planning_service_2.yaml b/db/schema2/views/v_planning_service_2.yaml new file mode 100644 index 0000000..456472e --- /dev/null +++ b/db/schema2/views/v_planning_service_2.yaml @@ -0,0 +1,14 @@ +src: | + SELECT t_planning_service.oid AS planning_service_source_id, + t_planning_service.code AS planning_service_source_code, + t_planning_service.texte AS planning_service_source_texte, + t_planning_service.section_id AS planning_service_source_section_id, + t_planning_service.section_code AS planning_service_source_section_code, + t_planning_service.section_texte AS planning_service_source_section_texte, + t_planning_service.service_id AS planning_service_id, + t_planning_service.service_code AS planning_service_code, + t_planning_service.service_texte AS planning_service_texte, + t_planning_service.service_section_id AS planning_service_section_id, + t_planning_service.service_section_code AS planning_service_section_code, + t_planning_service.service_section_texte AS planning_service_section_texte + FROM rh.t_planning_service; \ No newline at end of file diff --git a/db/schema2/views/v_planning_type_absence_1.yaml b/db/schema2/views/v_planning_type_absence_1.yaml new file mode 100644 index 0000000..ab73c48 --- /dev/null +++ b/db/schema2/views/v_planning_type_absence_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'PAB'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PAB'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'PAB'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'PAB'::text + UNION ALL + SELECT 'DT'::text || t_planning_type_absence.oid::text AS oid, + (t_planning_type_absence.code::text || ' '::text) || t_planning_type_absence.texte_court::text AS texte, + t_planning_type_absence.code, + '1'::text AS level, + '9'::text || t_planning_type_absence.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_planning_type_absence + WHERE (t_planning_type_absence.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'planning_type_absence'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_planning_type_absence_2.yaml b/db/schema2/views/v_planning_type_absence_2.yaml new file mode 100644 index 0000000..b21eb3e --- /dev/null +++ b/db/schema2/views/v_planning_type_absence_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_planning_type_absence.oid AS planning_type_absence_id, + t_planning_type_absence.code AS planning_type_absence_code, + t_planning_type_absence.texte AS planning_type_absence_texte, + t_planning_type_absence.section_id AS planning_type_absence_section_id, + t_planning_type_absence.section_code AS planning_type_absence_section_code, + t_planning_type_absence.section_texte AS planning_type_absence_section_texte + FROM rh.t_planning_type_absence; \ No newline at end of file diff --git a/db/schema2/views/v_pole_1.yaml b/db/schema2/views/v_pole_1.yaml new file mode 100644 index 0000000..7208f73 --- /dev/null +++ b/db/schema2/views/v_pole_1.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_pole.oid AS pole_id, + t_pole.code AS pole_code, + t_pole.texte AS pole_texte, + t_pole.section_id AS pole_section_id, + t_pole.section_code AS pole_section_code, + t_pole.section_texte AS pole_section_texte + FROM rh.t_pole; \ No newline at end of file diff --git a/db/schema2/views/v_pole_2.yaml b/db/schema2/views/v_pole_2.yaml new file mode 100644 index 0000000..a0a8f18 --- /dev/null +++ b/db/schema2/views/v_pole_2.yaml @@ -0,0 +1,65 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.liste_alias_combo AS alias, + v_listes_1.texte, + ('0'::text || v_listes_1.sort) || chr(1) AS code, + v_listes_1.lvl AS level, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'POLE'::text AND v_listes_1.lvl <> '0'::text + UNION ALL ( + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + ''::text AS alias, + t_classes.texte, + '2'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS code, + '1'::text AS level, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'POLE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + ('#LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.code AS alias, + t_classes_sections.texte, + '2'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS code, + '2'::text AS level, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'POLE'::text + ) + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + ''::text AS alias, + 'Section non attribuée'::character varying AS texte, + '2'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS code, + '2'::text AS level, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'POLE'::text + ) UNION + SELECT 'DT'::text || t_pole.oid::text AS oid, + '#DT'::text || t_pole.code AS alias, + (t_pole.code || ' '::text) || t_pole.texte_court AS texte, + '9'::text || t_pole.code AS code, + '1'::text AS level, + '0'::character(1) AS is_cti + FROM rh.t_pole + ORDER BY 4, 1, 3; \ No newline at end of file diff --git a/db/schema2/views/v_population_1.yaml b/db/schema2/views/v_population_1.yaml new file mode 100644 index 0000000..dbb1eba --- /dev/null +++ b/db/schema2/views/v_population_1.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_population.oid AS population_id, + t_population.code AS population_code, + t_population.texte AS population_texte, + t_population.section_id AS population_section_id, + t_population.section_code AS population_section_code, + t_population.section_texte AS population_section_texte + FROM rh.t_population; \ No newline at end of file diff --git a/db/schema2/views/v_population_2.yaml b/db/schema2/views/v_population_2.yaml new file mode 100644 index 0000000..b7ceb9d --- /dev/null +++ b/db/schema2/views/v_population_2.yaml @@ -0,0 +1,68 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.liste_alias_combo AS alias, + v_listes_1.texte, + ('0'::text || v_listes_1.sort) || chr(1) AS code, + v_listes_1.lvl AS level, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'POPULATION'::text AND v_listes_1.lvl <> '0'::text + UNION ALL ( + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + ''::text AS alias, + t_classes.texte, + '2'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS code, + '1'::text AS level, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'POPULATION'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + ('#LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.code AS alias, + t_classes_sections.texte, + '2'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS code, + '2'::text AS level, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'POPULATION'::text + ) + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + ''::text AS alias, + 'Section non attribuée'::character varying AS texte, + '2'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS code, + '2'::text AS level, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'POPULATION'::text + ) UNION + SELECT 'DT'::text || t_population.oid::text AS oid, + '#DT'::text || t_population.code AS alias, + (t_population.code || ' '::text) || t_population.texte_court AS texte, + '9'::text || t_population.code AS code, + '1'::text AS level, + '0'::character(1) AS is_cti + FROM rh.t_population + WHERE (t_population.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'population'::text)) + ORDER BY 4, 1, 3; \ No newline at end of file diff --git a/db/schema2/views/v_precisions_motif_arret_1.yaml b/db/schema2/views/v_precisions_motif_arret_1.yaml new file mode 100644 index 0000000..10eba8a --- /dev/null +++ b/db/schema2/views/v_precisions_motif_arret_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'MPA'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MPA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'MPA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MPA'::text + UNION ALL + SELECT 'DT'::text || t_precisions_motif_arret.oid::text AS oid, + (t_precisions_motif_arret.code || ' '::text) || t_precisions_motif_arret.texte_court::text AS texte, + t_precisions_motif_arret.code, + '1'::text AS level, + '9'::text || t_precisions_motif_arret.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_precisions_motif_arret + WHERE (t_precisions_motif_arret.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'precisions_motif_arret'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_precisions_motif_arret_2.yaml b/db/schema2/views/v_precisions_motif_arret_2.yaml new file mode 100644 index 0000000..b5203c1 --- /dev/null +++ b/db/schema2/views/v_precisions_motif_arret_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_precisions_motif_arret.oid AS precision_motif_arret_id, + t_precisions_motif_arret.code AS precision_motif_arret_code, + t_precisions_motif_arret.texte AS precision_motif_arret_texte, + t_precisions_motif_arret.section_id AS precision_motif_arret_section_id, + t_precisions_motif_arret.section_code AS precision_motif_arret_section_code, + t_precisions_motif_arret.section_texte AS precision_motif_arret_section_texte + FROM rh.t_precisions_motif_arret; \ No newline at end of file diff --git a/db/schema2/views/v_presence_salaries_1.yaml b/db/schema2/views/v_presence_salaries_1.yaml new file mode 100644 index 0000000..541ba0c --- /dev/null +++ b/db/schema2/views/v_presence_salaries_1.yaml @@ -0,0 +1,25 @@ +src: | + SELECT p_presence_salaries.salarie_id, + p_presence_salaries.mois_paie, + p_presence_salaries.etablissement_id AS rhp_etablissement_id, + p_presence_salaries.present_paie, + p_presence_salaries.present_planning, + p_presence_salaries.presence_contrat, + p_presence_salaries.est_interimaire, + base.cti_last_day(to_date(p_presence_salaries.mois_paie::text, 'YYYYMM'::text)) AS date_paie, + 0::bigint AS rhp_pole_id, + p_contrats.oid AS contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats.numero_contrat AS contrat_code, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_contrats_mois.age_id AS rhp_age_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.situation_famille_id AS rhp_situation_famille_id + FROM rh.p_presence_salaries + JOIN rh.p_contrats_mois ON p_contrats_mois.salarie_id = p_presence_salaries.salarie_id AND p_contrats_mois.mois_activite = p_presence_salaries.mois_paie::numeric + JOIN rh.p_contrats ON p_contrats.oid = p_contrats_mois.contrat_id + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_salaries ON p_salaries.oid = p_presence_salaries.salarie_id; \ No newline at end of file diff --git a/db/schema2/views/v_profils_1.yaml b/db/schema2/views/v_profils_1.yaml new file mode 100644 index 0000000..c7963fb --- /dev/null +++ b/db/schema2/views/v_profils_1.yaml @@ -0,0 +1,178 @@ +src: | + SELECT p_profils.oid AS profil_id, + p_profils.type_contrat_id, + p_profils.type_contrat_code_original, + p_profils.type_contrat_code, + p_profils.type_contrat_texte, + p_profils.type_contrat_section_id, + p_profils.type_contrat_section_code, + p_profils.type_contrat_section_texte, + p_profils.motif_debut_id, + p_profils.motif_debut_code_original, + p_profils.motif_debut_code, + p_profils.motif_debut_texte, + p_profils.motif_debut_section_id, + p_profils.motif_debut_section_code, + p_profils.motif_debut_section_texte, + p_profils.motif_fin_id, + p_profils.motif_fin_code_original, + p_profils.motif_fin_code, + p_profils.motif_fin_texte, + p_profils.motif_fin_section_id, + p_profils.motif_fin_section_code, + p_profils.motif_fin_section_texte, + p_profils.qualification_id, + p_profils.qualification_code_original, + p_profils.qualification_code, + p_profils.qualification_texte, + p_profils.qualification_section_id, + p_profils.qualification_section_code, + p_profils.qualification_section_texte, + p_profils.service_id, + p_profils.service_code_original, + p_profils.service_code, + p_profils.service_texte, + p_profils.service_section_id, + p_profils.service_section_code, + p_profils.service_section_texte, + p_profils.specialite_id, + p_profils.specialite_code_original, + p_profils.specialite_code, + p_profils.specialite_texte, + p_profils.specialite_section_id, + p_profils.specialite_section_code, + p_profils.specialite_section_texte, + p_profils.type_temps_travail_id, + p_profils.type_temps_travail_code_original, + p_profils.type_temps_travail_code, + p_profils.type_temps_travail_texte, + p_profils.type_temps_travail_section_id, + p_profils.type_temps_travail_section_code, + p_profils.type_temps_travail_section_texte, + p_profils.categorie_socio_professionnelle_id, + p_profils.categorie_socio_professionnelle_code_original, + p_profils.categorie_socio_professionnelle_code, + p_profils.categorie_socio_professionnelle_texte, + p_profils.categorie_socio_professionnelle_section_id, + p_profils.categorie_socio_professionnelle_section_code, + p_profils.categorie_socio_professionnelle_section_texte, + p_profils.statut_id, + p_profils.statut_code_original, + p_profils.statut_code, + p_profils.statut_texte, + p_profils.statut_section_id, + p_profils.statut_section_code, + p_profils.statut_section_texte, + p_profils.code_emploi_id, + p_profils.code_emploi_code_original, + p_profils.code_emploi_code, + p_profils.code_emploi_texte, + p_profils.code_emploi_section_id, + p_profils.code_emploi_section_code, + p_profils.code_emploi_section_texte, + p_profils.societe_interim_id, + p_profils.societe_interim_code_original, + p_profils.societe_interim_code, + p_profils.societe_interim_texte, + p_profils.societe_interim_section_id, + p_profils.societe_interim_section_code, + p_profils.societe_interim_section_texte, + p_profils.section_analytique_paie_id, + p_profils.section_analytique_paie_code_original, + p_profils.section_analytique_paie_code, + p_profils.section_analytique_paie_texte, + p_profils.section_analytique_paie_section_id, + p_profils.section_analytique_paie_section_code, + p_profils.section_analytique_paie_section_texte, + p_profils.section_analytique_id, + p_profils.section_analytique_code_original, + p_profils.section_analytique_code, + p_profils.section_analytique_texte, + p_profils.section_analytique_section_id, + p_profils.section_analytique_section_code, + p_profils.section_analytique_section_texte, + p_profils.grille_id, + p_profils.grille_code_original, + p_profils.grille_code, + p_profils.grille_texte, + p_profils.grille_section_id, + p_profils.grille_section_code, + p_profils.grille_section_texte, + p_profils.grille_groupe_id, + p_profils.grille_groupe_code_original, + p_profils.grille_groupe_code, + p_profils.grille_groupe_texte, + p_profils.grille_groupe_section_id, + p_profils.grille_groupe_section_code, + p_profils.grille_groupe_section_texte, + p_profils.type_horaire_id, + p_profils.type_horaire_code_original, + p_profils.type_horaire_code, + p_profils.type_horaire_texte, + p_profils.type_horaire_section_id, + p_profils.type_horaire_section_code, + p_profils.type_horaire_section_texte, + p_profils.groupe_cotisant_id, + p_profils.groupe_cotisant_code_original, + p_profils.groupe_cotisant_code, + p_profils.groupe_cotisant_texte, + p_profils.groupe_cotisant_section_id, + p_profils.groupe_cotisant_section_code, + p_profils.groupe_cotisant_section_texte, + p_profils.unite_fonctionnelle_id, + p_profils.unite_fonctionnelle_code_original, + p_profils.unite_fonctionnelle_code, + p_profils.unite_fonctionnelle_texte, + p_profils.unite_fonctionnelle_section_id, + p_profils.unite_fonctionnelle_section_code, + p_profils.unite_fonctionnelle_section_texte, + p_profils.lettre_budgetaire_id, + p_profils.lettre_budgetaire_code_original, + p_profils.lettre_budgetaire_code, + p_profils.lettre_budgetaire_texte, + p_profils.lettre_budgetaire_section_id, + p_profils.lettre_budgetaire_section_code, + p_profils.lettre_budgetaire_section_texte, + p_profils.commission_paritaire_id, + p_profils.commission_paritaire_code_original, + p_profils.commission_paritaire_code, + p_profils.commission_paritaire_texte, + p_profils.commission_paritaire_section_id, + p_profils.commission_paritaire_section_code, + p_profils.commission_paritaire_section_texte, + p_profils.compte_salarie_id, + p_profils.compte_salarie_code_original, + p_profils.compte_salarie_code, + p_profils.compte_salarie_texte, + p_profils.compte_salarie_section_id, + p_profils.compte_salarie_section_code, + p_profils.compte_salarie_section_texte, + p_profils.categorie_conge_id, + p_profils.categorie_conge_code_original, + p_profils.categorie_conge_code, + p_profils.categorie_conge_texte, + p_profils.categorie_conge_section_id, + p_profils.categorie_conge_section_code, + p_profils.categorie_conge_section_texte, + p_profils.filiere_id, + p_profils.filiere_code_original, + p_profils.filiere_code, + p_profils.filiere_texte, + p_profils.filiere_section_id, + p_profils.filiere_section_code, + p_profils.filiere_section_texte, + p_profils.cadre_emploi_id, + p_profils.cadre_emploi_code_original, + p_profils.cadre_emploi_code, + p_profils.cadre_emploi_texte, + p_profils.cadre_emploi_section_id, + p_profils.cadre_emploi_section_code, + p_profils.cadre_emploi_section_texte, + p_profils.categorie_statutaire_id, + p_profils.categorie_statutaire_code_original, + p_profils.categorie_statutaire_code, + p_profils.categorie_statutaire_texte, + p_profils.categorie_statutaire_section_id, + p_profils.categorie_statutaire_section_code, + p_profils.categorie_statutaire_section_texte + FROM rh.p_profils; \ No newline at end of file diff --git a/db/schema2/views/v_qualifications_1.yaml b/db/schema2/views/v_qualifications_1.yaml new file mode 100644 index 0000000..3b14f48 --- /dev/null +++ b/db/schema2/views/v_qualifications_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'QUA'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'QUA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'QUA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'QUA'::text + UNION ALL + SELECT 'DT'::text || t_qualifications.oid::text AS oid, + (t_qualifications.code || ' '::text) || t_qualifications.texte_court::text AS texte, + t_qualifications.code, + '1'::text AS level, + '9'::text || t_qualifications.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_qualifications + WHERE (t_qualifications.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'qualifications'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_rapports_tables_indicateurs_1.yaml b/db/schema2/views/v_rapports_tables_indicateurs_1.yaml new file mode 100644 index 0000000..8132393 --- /dev/null +++ b/db/schema2/views/v_rapports_tables_indicateurs_1.yaml @@ -0,0 +1,43 @@ +src: | + SELECT 1::bigint AS oid, + 'v_historique_paie_1'::text AS code, + 'Historique de paie'::text AS texte, + '4'::text AS dimensions_date, + ARRAY[''::text, ''::text, ''::text, 'paie'::text, ''::text] AS dimensions_date_texte + UNION + SELECT 2::bigint AS oid, + 'v_contrats_mois_1'::text AS code, + 'Salariés et contrats'::text AS texte, + '1'::text AS dimensions_date, + ARRAY['mouvement'::text, ''::text, ''::text, ''::text, ''::text] AS dimensions_date_texte + UNION + SELECT 3::bigint AS oid, + 'v_arrets_travail_mois_1'::text AS code, + 'Arrêts de travail'::text AS texte, + '1'::text AS dimensions_date, + ARRAY['mouvement'::text, ''::text, ''::text, ''::text, ''::text] AS dimensions_date_texte + UNION + SELECT 4::bigint AS oid, + 'PLANNING_MOUVEMENT'::text AS code, + 'Planning'::text AS texte, + '1'::text AS dimensions_date, + ARRAY['mouvement'::text, ''::text, ''::text, ''::text, ''::text] AS dimensions_date_texte + UNION + SELECT 96::bigint AS oid, + 'INDICATEUR_EXTERNE_RH'::text AS code, + 'Indicateurs externes'::text AS texte, + '1'::text AS dimensions_date, + ARRAY['date'::text, ''::text, ''::text, ''::text, ''::text] AS dimensions_date_texte + UNION + SELECT 97::bigint AS oid, + 'CALENDRIER'::text AS code, + 'Calendrier'::text AS texte, + '1'::text AS dimensions_date, + ARRAY['jour'::text, ''::text, ''::text, ''::text, ''::text] AS dimensions_date_texte + UNION + SELECT 98::bigint AS oid, + '*CALC'::text AS code, + 'Calcul entre indicateurs'::text AS texte, + ''::text AS dimensions_date, + ARRAY[''::text, ''::text, ''::text, ''::text, ''::text] AS dimensions_date_texte + ORDER BY 1; \ No newline at end of file diff --git a/db/schema2/views/v_referentiel_sae_1.yaml b/db/schema2/views/v_referentiel_sae_1.yaml new file mode 100644 index 0000000..236355c --- /dev/null +++ b/db/schema2/views/v_referentiel_sae_1.yaml @@ -0,0 +1,15 @@ +src: | + SELECT t_classes.oid AS classe_id, + t_classes.code AS classe_code, + t_classes.texte AS classe_texte, + t_listes_tables.code AS liste_code, + (t_listes_tables.code || 'CLS'::text) || lpad(t_classes.sequence::text, 2, '0'::text) AS liste_classe_code, + t_classes.sequence, + t_classes_sections.oid AS section_id, + ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS section_code, + (t_classes_sections.code || ' '::text) || t_classes_sections.texte AS section_texte + FROM rh.t_classes + JOIN rh.t_classes_sections ON t_classes_sections.classe_id = t_classes.oid + JOIN rh.t_listes_tables ON t_classes.table_id = t_listes_tables.oid + WHERE t_classes.code ~~ 'CTI_SAE_%'::text AND t_classes.is_cti = 1 + ORDER BY t_classes_sections.code; \ No newline at end of file diff --git a/db/schema2/views/v_rubriques_1.yaml b/db/schema2/views/v_rubriques_1.yaml new file mode 100644 index 0000000..afdfaf9 --- /dev/null +++ b/db/schema2/views/v_rubriques_1.yaml @@ -0,0 +1,71 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + '#LI'::text || v_listes_1.code AS alias, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'RUP'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '#LC'::text || t_classes.code AS alias, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'RUP'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '#LS'::text || t_classes_sections.code AS alias, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'RUP'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + chr(255) AS code, + '#LS'::text || chr(255) AS alias, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'RUP'::text + UNION ALL + SELECT 'DT'::text || t_rubriques.oid::text AS oid, + (t_rubriques.code::text || ' '::text) || t_rubriques.texte_court::text AS texte, + t_rubriques.code, + '#DT'::text || t_rubriques.code::text AS alias, + '1'::text AS level, + '9'::text || t_rubriques.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_rubriques + WHERE (t_rubriques.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'rubriques'::text)) + ORDER BY 6; \ No newline at end of file diff --git a/db/schema2/views/v_salaries_1.yaml b/db/schema2/views/v_salaries_1.yaml new file mode 100644 index 0000000..47b956f --- /dev/null +++ b/db/schema2/views/v_salaries_1.yaml @@ -0,0 +1,260 @@ +src: | + SELECT p_salaries.finess, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + p_salaries.oid AS nir_id, + p_salaries.nir AS nir_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS nir_texte, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + CASE + WHEN p_handicap.salarie_id IS NULL THEN 0 + ELSE 1 + END AS handicap_id, + CASE + WHEN p_handicap.salarie_id IS NULL THEN 'N'::bpchar + ELSE 'O'::bpchar + END AS handicap_code, + CASE + WHEN p_handicap.salarie_id IS NULL THEN 'Non'::text + ELSE 'Oui'::text + END AS handicap_texte, + p_salaries.situation_famille_id, + t_situations_famille.code AS situation_famille_code, + t_situations_famille.texte_court AS situation_famille_texte, + p_salaries.code_original, + p_salaries.nationalite_id, + t_nationalites.code AS nationalite_code, + t_nationalites.texte_court AS nationalite_texte, + t_nationalites.section_id AS nationalite_section_id, + t_nationalites.section_code AS nationalite_section_code, + t_nationalites.section_texte AS nationalite_section_texte, + t_codes_postaux.departement_id, + t_codes_postaux.departement_code, + t_codes_postaux.departement_texte, + p_salaries.code_postal_id, + t_codes_postaux.code AS code_postal_code, + t_codes_postaux.texte_court AS code_postal_texte, + t_codes_postaux.section_id AS code_postal_section_id, + t_codes_postaux.section_code AS code_postal_section_code, + t_codes_postaux.section_texte AS code_postal_section_texte, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_salaries.entreprise_id, + t_entreprises.code AS entreprise_code, + t_entreprises.texte_court AS entreprise_texte, + p_salaries.date_debut AS date_debut_contrat, + p_salaries.date_fin AS date_fin_contrat, + p_profils.oid AS profil_id, + p_profils.type_contrat_id, + p_profils.type_contrat_code_original, + p_profils.type_contrat_code, + p_profils.type_contrat_texte, + p_profils.type_contrat_section_id, + p_profils.type_contrat_section_code, + p_profils.type_contrat_section_texte, + p_profils.motif_debut_id, + p_profils.motif_debut_code_original, + p_profils.motif_debut_code, + p_profils.motif_debut_texte, + p_profils.motif_debut_section_id, + p_profils.motif_debut_section_code, + p_profils.motif_debut_section_texte, + p_profils.motif_fin_id, + p_profils.motif_fin_code_original, + p_profils.motif_fin_code, + p_profils.motif_fin_texte, + p_profils.motif_fin_section_id, + p_profils.motif_fin_section_code, + p_profils.motif_fin_section_texte, + p_profils.qualification_id, + p_profils.qualification_code_original, + p_profils.qualification_code, + p_profils.qualification_texte, + p_profils.qualification_section_id, + p_profils.qualification_section_code, + p_profils.qualification_section_texte, + p_profils.service_id, + p_profils.service_code_original, + p_profils.service_code, + p_profils.service_texte, + p_profils.service_section_id, + p_profils.service_section_code, + p_profils.service_section_texte, + p_profils.specialite_id, + p_profils.specialite_code_original, + p_profils.specialite_code, + p_profils.specialite_texte, + p_profils.specialite_section_id, + p_profils.specialite_section_code, + p_profils.specialite_section_texte, + p_profils.type_temps_travail_id, + p_profils.type_temps_travail_code_original, + p_profils.type_temps_travail_code, + p_profils.type_temps_travail_texte, + p_profils.type_temps_travail_section_id, + p_profils.type_temps_travail_section_code, + p_profils.type_temps_travail_section_texte, + p_profils.categorie_socio_professionnelle_id, + p_profils.categorie_socio_professionnelle_code_original, + p_profils.categorie_socio_professionnelle_code, + p_profils.categorie_socio_professionnelle_texte, + p_profils.categorie_socio_professionnelle_section_id, + p_profils.categorie_socio_professionnelle_section_code, + p_profils.categorie_socio_professionnelle_section_texte, + p_profils.statut_id, + p_profils.statut_code_original, + p_profils.statut_code, + p_profils.statut_texte, + p_profils.statut_section_id, + p_profils.statut_section_code, + p_profils.statut_section_texte, + p_profils.code_emploi_id, + p_profils.code_emploi_code_original, + p_profils.code_emploi_code, + p_profils.code_emploi_texte, + p_profils.code_emploi_section_id, + p_profils.code_emploi_section_code, + p_profils.code_emploi_section_texte, + p_profils.societe_interim_id, + p_profils.societe_interim_code_original, + p_profils.societe_interim_code, + p_profils.societe_interim_texte, + p_profils.societe_interim_section_id, + p_profils.societe_interim_section_code, + p_profils.societe_interim_section_texte, + p_profils.section_analytique_paie_id, + p_profils.section_analytique_paie_code_original, + p_profils.section_analytique_paie_code, + p_profils.section_analytique_paie_texte, + p_profils.section_analytique_paie_section_id, + p_profils.section_analytique_paie_section_code, + p_profils.section_analytique_paie_section_texte, + p_profils.section_analytique_id, + p_profils.section_analytique_code_original, + p_profils.section_analytique_code, + p_profils.section_analytique_texte, + p_profils.section_analytique_section_id, + p_profils.section_analytique_section_code, + p_profils.section_analytique_section_texte, + p_profils.grille_id, + p_profils.grille_code_original, + p_profils.grille_code, + p_profils.grille_texte, + p_profils.grille_section_id, + p_profils.grille_section_code, + p_profils.grille_section_texte, + p_profils.grille_groupe_id, + p_profils.grille_groupe_code_original, + p_profils.grille_groupe_code, + p_profils.grille_groupe_texte, + p_profils.grille_groupe_section_id, + p_profils.grille_groupe_section_code, + p_profils.grille_groupe_section_texte, + p_profils.type_horaire_id, + p_profils.type_horaire_code_original, + p_profils.type_horaire_code, + p_profils.type_horaire_texte, + p_profils.type_horaire_section_id, + p_profils.type_horaire_section_code, + p_profils.type_horaire_section_texte, + p_profils.groupe_cotisant_id, + p_profils.groupe_cotisant_code_original, + p_profils.groupe_cotisant_code, + p_profils.groupe_cotisant_texte, + p_profils.groupe_cotisant_section_id, + p_profils.groupe_cotisant_section_code, + p_profils.groupe_cotisant_section_texte, + p_profils.unite_fonctionnelle_id, + p_profils.unite_fonctionnelle_code_original, + p_profils.unite_fonctionnelle_code, + p_profils.unite_fonctionnelle_texte, + p_profils.unite_fonctionnelle_section_id, + p_profils.unite_fonctionnelle_section_code, + p_profils.unite_fonctionnelle_section_texte, + p_profils.lettre_budgetaire_id, + p_profils.lettre_budgetaire_code_original, + p_profils.lettre_budgetaire_code, + p_profils.lettre_budgetaire_texte, + p_profils.lettre_budgetaire_section_id, + p_profils.lettre_budgetaire_section_code, + p_profils.lettre_budgetaire_section_texte, + p_profils.commission_paritaire_id, + p_profils.commission_paritaire_code_original, + p_profils.commission_paritaire_code, + p_profils.commission_paritaire_texte, + p_profils.commission_paritaire_section_id, + p_profils.commission_paritaire_section_code, + p_profils.commission_paritaire_section_texte, + p_profils.compte_salarie_id, + p_profils.compte_salarie_code_original, + p_profils.compte_salarie_code, + p_profils.compte_salarie_texte, + p_profils.compte_salarie_section_id, + p_profils.compte_salarie_section_code, + p_profils.compte_salarie_section_texte, + p_profils.categorie_conge_id, + p_profils.categorie_conge_code_original, + p_profils.categorie_conge_code, + p_profils.categorie_conge_texte, + p_profils.categorie_conge_section_id, + p_profils.categorie_conge_section_code, + p_profils.categorie_conge_section_texte, + p_profils.filiere_id, + p_profils.filiere_code_original, + p_profils.filiere_code, + p_profils.filiere_texte, + p_profils.filiere_section_id, + p_profils.filiere_section_code, + p_profils.filiere_section_texte, + p_profils.cadre_emploi_id, + p_profils.cadre_emploi_code_original, + p_profils.cadre_emploi_code, + p_profils.cadre_emploi_texte, + p_profils.cadre_emploi_section_id, + p_profils.cadre_emploi_section_code, + p_profils.cadre_emploi_section_texte, + p_profils.categorie_statutaire_id, + p_profils.categorie_statutaire_code_original, + p_profils.categorie_statutaire_code, + p_profils.categorie_statutaire_texte, + p_profils.categorie_statutaire_section_id, + p_profils.categorie_statutaire_section_code, + p_profils.categorie_statutaire_section_texte, + p_salaries.date_anciennete, + p_salaries.date_entree_ets, + p_salaries.date_sortie_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + t_code_cotisation.oid AS code_cotisation_id, + t_code_cotisation.code_original AS code_cotisation_code_original, + t_code_cotisation.code AS code_cotisation_code, + t_code_cotisation.texte AS code_cotisation_texte, + t_code_cotisation.section_id AS code_cotisation_section_id, + t_code_cotisation.section_code AS code_cotisation_section_code, + t_code_cotisation.section_texte AS code_cotisation_section_texte, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_salaries.salarie_fusionne_id + FROM rh.p_salaries + JOIN rh.t_entreprises ON p_salaries.entreprise_id = t_entreprises.oid + JOIN rh.t_codes_postaux ON p_salaries.code_postal_id = t_codes_postaux.oid + JOIN rh.t_nationalites ON p_salaries.nationalite_id = t_nationalites.oid + JOIN rh.t_situations_famille ON p_salaries.situation_famille_id = t_situations_famille.oid + JOIN rh.p_profils ON p_salaries.profil_id = p_profils.oid + JOIN rh.t_code_cotisation ON t_code_cotisation.oid = p_salaries.code_cotisation_id + LEFT JOIN rh.p_handicap ON p_salaries.oid = p_handicap.salarie_id; \ No newline at end of file diff --git a/db/schema2/views/v_salaries_2.yaml b/db/schema2/views/v_salaries_2.yaml new file mode 100644 index 0000000..6e7884a --- /dev/null +++ b/db/schema2/views/v_salaries_2.yaml @@ -0,0 +1,63 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'SAL'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SAL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'SAL'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SAL'::text + UNION ALL + SELECT 'DT'::text || p_salaries.oid::text AS oid, + ((((p_salaries.nom::text || ' '::text) || p_salaries.prenom::text) || '('::text) || p_salaries.matricule) || ')'::text AS texte, + p_salaries.matricule AS code, + '1'::text AS level, + ('9'::text || p_salaries.nom::text) || p_salaries.prenom::text AS tri, + '0'::character(1) AS is_cti + FROM rh.p_salaries + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_salaries_remplaces_1.yaml b/db/schema2/views/v_salaries_remplaces_1.yaml new file mode 100644 index 0000000..31e9b05 --- /dev/null +++ b/db/schema2/views/v_salaries_remplaces_1.yaml @@ -0,0 +1,10 @@ +src: | + SELECT 'DT'::text || p_salaries.oid::text AS oid, + (((p_salaries.matricule || ' '::text) || p_salaries.nom::text) || ' '::text) || p_salaries.prenom::text AS texte, + p_salaries.matricule, + '1'::text AS level, + '9'::text || p_salaries.matricule AS tri + FROM rh.p_contrats + JOIN rh.p_salaries ON p_salaries.oid = p_contrats.salarie_remplace_id + GROUP BY ('9'::text || p_salaries.matricule), ('DT'::text || p_salaries.oid::text), ((((p_salaries.matricule || ' '::text) || p_salaries.nom::text) || ' '::text) || p_salaries.prenom::text), p_salaries.matricule, '1'::text + ORDER BY ('9'::text || p_salaries.matricule); \ No newline at end of file diff --git a/db/schema2/views/v_salaries_remplaces_2.yaml b/db/schema2/views/v_salaries_remplaces_2.yaml new file mode 100644 index 0000000..f00ee46 --- /dev/null +++ b/db/schema2/views/v_salaries_remplaces_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT p_salaries.oid AS salarie_remplace_id, + p_salaries.code AS salarie_remplace_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_remplace_texte, + p_salaries.section_id AS salarie_remplace_section_id, + p_salaries.section_code AS salarie_remplace_section_code, + p_salaries.section_texte AS salarie_remplace_section_texte + FROM rh.p_salaries; \ No newline at end of file diff --git a/db/schema2/views/v_schema_settings_1.yaml b/db/schema2/views/v_schema_settings_1.yaml new file mode 100644 index 0000000..fc799e7 --- /dev/null +++ b/db/schema2/views/v_schema_settings_1.yaml @@ -0,0 +1,9 @@ +src: | + SELECT 'FROM'::text AS setting_type, + 'v_contrats_mois_1#1'::text AS code, + ARRAY['#V_CNT_X##V_ALL_X#'::text, 'v_rh_view_1.date_fin_activite'::text] AS property_array + UNION + SELECT 'FROM'::text AS setting_type, + 'v_historique_paie_1#1'::text AS code, + ARRAY['#V_HP_X##V_ALL_X#'::text, 'v_rh_view_1.date_paie'::text] AS property_array + ORDER BY 1, 2; \ No newline at end of file diff --git a/db/schema2/views/v_section_analytique_1.yaml b/db/schema2/views/v_section_analytique_1.yaml new file mode 100644 index 0000000..8ffa941 --- /dev/null +++ b/db/schema2/views/v_section_analytique_1.yaml @@ -0,0 +1,47 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + ''::text AS code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'ANA'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + ''::text AS code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ANA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'ANA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ANA'::text + UNION ALL + SELECT 'DT'::text || t_section_analytique.oid::text AS oid, + (t_section_analytique.code || ' '::text) || t_section_analytique.texte_court AS texte, + t_section_analytique.code, + '1'::text AS level, + '9'::text || t_section_analytique.code AS tri + FROM rh.t_section_analytique + JOIN rh.p_oids ON 1 = 1 AND p_oids.oid = t_section_analytique.oid AND p_oids.code_table::text = 'section_analytique'::text + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_sections_analytiques_1.yaml b/db/schema2/views/v_sections_analytiques_1.yaml new file mode 100644 index 0000000..27d08b8 --- /dev/null +++ b/db/schema2/views/v_sections_analytiques_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'SAC'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SAC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'SAC'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SAC'::text + UNION ALL + SELECT 'DT'::text || t_sections_analytiques.oid::text AS oid, + (t_sections_analytiques.code || ' '::text) || t_sections_analytiques.texte_court AS texte, + t_sections_analytiques.code, + '1'::text AS level, + '9'::text || t_sections_analytiques.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_sections_analytiques + WHERE (t_sections_analytiques.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'sections_analytiques'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_sections_analytiques_paie_1.yaml b/db/schema2/views/v_sections_analytiques_paie_1.yaml new file mode 100644 index 0000000..48582f0 --- /dev/null +++ b/db/schema2/views/v_sections_analytiques_paie_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'SAP'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SAP'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'SAP'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SAP'::text + ) UNION + SELECT 'DT'::text || t_sections_analytiques_paie.oid::text AS oid, + (t_sections_analytiques_paie.code || ' '::text) || t_sections_analytiques_paie.texte_court AS texte, + t_sections_analytiques_paie.code, + '1'::text AS level, + '9'::text || t_sections_analytiques_paie.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_sections_analytiques_paie + WHERE (t_sections_analytiques_paie.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'sections_analytiques_paie'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_services_1.yaml b/db/schema2/views/v_services_1.yaml new file mode 100644 index 0000000..5d5f620 --- /dev/null +++ b/db/schema2/views/v_services_1.yaml @@ -0,0 +1,67 @@ +dep: + - v_listes_1 +src: | + ( + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'SER'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SER'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'SER'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SER'::text + ) UNION + SELECT 'DT'::text || t_services.oid::text AS oid, + (t_services.code || ' '::text) || t_services.texte_court AS texte, + t_services.code, + '1'::text AS level, + '9'::text || t_services.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_services + WHERE (t_services.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'services'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_situations_famille_1.yaml b/db/schema2/views/v_situations_famille_1.yaml new file mode 100644 index 0000000..c8e445d --- /dev/null +++ b/db/schema2/views/v_situations_famille_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'SFA'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SFA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'SFA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SFA'::text + UNION ALL + SELECT 'DT'::text || t_situations_famille.oid::text AS oid, + (t_situations_famille.code::text || ' '::text) || t_situations_famille.texte_court::text AS texte, + t_situations_famille.code, + '1'::text AS level, + '9'::text || t_situations_famille.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_situations_famille + WHERE (t_situations_famille.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'situations_famille'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_situations_famille_2.yaml b/db/schema2/views/v_situations_famille_2.yaml new file mode 100644 index 0000000..ccd99b0 --- /dev/null +++ b/db/schema2/views/v_situations_famille_2.yaml @@ -0,0 +1,8 @@ +src: | + SELECT t_situations_famille.oid AS situation_famille_id, + t_situations_famille.code AS situation_famille_code, + t_situations_famille.texte AS situation_famille_texte, + t_situations_famille.section_id AS situation_famille_section_id, + t_situations_famille.section_code AS situation_famille_section_code, + t_situations_famille.section_texte AS situation_famille_section_texte + FROM rh.t_situations_famille; \ No newline at end of file diff --git a/db/schema2/views/v_societes_interim_1.yaml b/db/schema2/views/v_societes_interim_1.yaml new file mode 100644 index 0000000..188412c --- /dev/null +++ b/db/schema2/views/v_societes_interim_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'SIN'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SIN'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'SIN'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SIN'::text + UNION ALL + SELECT 'DT'::text || t_societes_interim.oid::text AS oid, + (t_societes_interim.code::text || ' '::text) || t_societes_interim.texte_court::text AS texte, + t_societes_interim.code, + '1'::text AS level, + '9'::text || t_societes_interim.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_societes_interim + WHERE (t_societes_interim.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'societes_interim'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_specialites_1.yaml b/db/schema2/views/v_specialites_1.yaml new file mode 100644 index 0000000..56e291f --- /dev/null +++ b/db/schema2/views/v_specialites_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'SPE'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SPE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'SPE'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'SPE'::text + UNION ALL + SELECT 'DT'::text || t_specialites.oid::text AS oid, + (t_specialites.code::text || ' '::text) || t_specialites.texte_court::text AS texte, + t_specialites.code, + '1'::text AS level, + '9'::text || t_specialites.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_specialites + WHERE (t_specialites.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'specialites'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_statuts_1.yaml b/db/schema2/views/v_statuts_1.yaml new file mode 100644 index 0000000..3982fc9 --- /dev/null +++ b/db/schema2/views/v_statuts_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'STA'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'STA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'STA'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'STA'::text + UNION ALL + SELECT 'DT'::text || t_statuts.oid::text AS oid, + (t_statuts.code || ' '::text) || t_statuts.texte_court::text AS texte, + t_statuts.code, + '1'::text AS level, + '9'::text || t_statuts.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_statuts + WHERE (t_statuts.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'statuts'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_types_contrat_1.yaml b/db/schema2/views/v_types_contrat_1.yaml new file mode 100644 index 0000000..fea9062 --- /dev/null +++ b/db/schema2/views/v_types_contrat_1.yaml @@ -0,0 +1,71 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + '#LI'::text || v_listes_1.code AS alias, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'TCN'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '#LC'::text || t_classes.code AS alias, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'TCN'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '#LS'::text || t_classes_sections.code AS alias, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'TCN'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + chr(255) AS code, + '#LS'::text || chr(255) AS alias, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'TCN'::text + UNION ALL + SELECT 'DT'::text || t_types_contrat.oid::text AS oid, + (t_types_contrat.code || ' '::text) || t_types_contrat.texte_court::text AS texte, + t_types_contrat.code, + '#DT'::text || t_types_contrat.code AS alias, + '1'::text AS level, + '9'::text || t_types_contrat.code AS tri, + '0'::character(1) AS is_cti + FROM rh.t_types_contrat + WHERE (t_types_contrat.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'types_contrat'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_types_horaire_1.yaml b/db/schema2/views/v_types_horaire_1.yaml new file mode 100644 index 0000000..597a98b --- /dev/null +++ b/db/schema2/views/v_types_horaire_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'THO'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'THO'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'THO'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'THO'::text + UNION ALL + SELECT 'DT'::text || t_types_horaire.oid::text AS oid, + CASE + WHEN t_types_horaire.code::text <> t_types_horaire.texte_court::text THEN ((t_types_horaire.code::text || ' '::text) || t_types_horaire.texte_court::text)::character varying + ELSE t_types_horaire.texte_court + END AS texte, + t_types_horaire.code, + '1'::text AS level, + '9'::text || t_types_horaire.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_types_horaire + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_types_temps_travail_1.yaml b/db/schema2/views/v_types_temps_travail_1.yaml new file mode 100644 index 0000000..8a19e66 --- /dev/null +++ b/db/schema2/views/v_types_temps_travail_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE v_listes_1.table_code = 'TTT'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'TTT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'TTT'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'TTT'::text + UNION ALL + SELECT 'DT'::text || t_types_temps_travail.oid::text AS oid, + (t_types_temps_travail.code::text || ' '::text) || t_types_temps_travail.texte_court::text AS texte, + t_types_temps_travail.code, + '1'::text AS level, + '9'::text || t_types_temps_travail.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_types_temps_travail + WHERE (t_types_temps_travail.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'types_temps_travail'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_unite_fonctionnelle_1.yaml b/db/schema2/views/v_unite_fonctionnelle_1.yaml new file mode 100644 index 0000000..07d814a --- /dev/null +++ b/db/schema2/views/v_unite_fonctionnelle_1.yaml @@ -0,0 +1,66 @@ +dep: + - v_listes_1 +src: | + SELECT v_listes_1.liste_id_combo AS oid, + v_listes_1.texte, + v_listes_1.code, + v_listes_1.lvl AS level, + ('0'::text || v_listes_1.sort) || chr(1) AS tri, + CASE + WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.v_listes_1 + WHERE 1 = 1 AND v_listes_1.table_code = 'UNF'::text AND v_listes_1.lvl <> '0'::text + UNION ALL + SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid, + t_classes.texte, + t_classes.code, + '1'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'UNF'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid, + t_classes_sections.texte, + t_classes_sections.code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_classes_sections, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'UNF'::text + UNION ALL + SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid, + 'Section non attribuée'::character varying AS texte, + ''::text AS code, + '2'::text AS level, + '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri, + CASE + WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1) + ELSE '0'::character(1) + END AS is_cti + FROM rh.t_classes, + rh.t_listes_tables + WHERE 1 = 1 AND t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'UNF'::text + UNION ALL + SELECT 'DT'::text || t_unite_fonctionnelle.oid::text AS oid, + (t_unite_fonctionnelle.code::text || ' '::text) || t_unite_fonctionnelle.texte_court::text AS texte, + t_unite_fonctionnelle.code, + '1'::text AS level, + '9'::text || t_unite_fonctionnelle.code::text AS tri, + '0'::character(1) AS is_cti + FROM rh.t_unite_fonctionnelle + WHERE (t_unite_fonctionnelle.oid IN ( SELECT p_oids.oid + FROM rh.p_oids + WHERE p_oids.code_table::text = 'unite_fonctionnelle'::text)) + ORDER BY 5; \ No newline at end of file diff --git a/db/schema2/views/v_ventilation_capsante_1.yaml b/db/schema2/views/v_ventilation_capsante_1.yaml new file mode 100644 index 0000000..ef5c714 --- /dev/null +++ b/db/schema2/views/v_ventilation_capsante_1.yaml @@ -0,0 +1,9 @@ +src: | + SELECT p_ventilation_capsante.salarie_id AS ventilation_capsante_salarie_id, + p_ventilation_capsante.mois_paie AS ventilation_capsante_mois_paie, + p_ventilation_capsante.etablissement_id AS ventilation_capsante_etablissement_id, + t_etablissements.code AS ventilation_capsante_etablissement_code, + t_etablissements.texte AS ventilation_capsante_etablissement_texte, + p_ventilation_capsante.ratio AS ventilation_capsante_ratio + FROM rh.p_ventilation_capsante + JOIN rh.t_etablissements ON t_etablissements.oid = p_ventilation_capsante.etablissement_id; \ No newline at end of file diff --git a/db/schema2/views/v_ventilation_section_2_1.yaml b/db/schema2/views/v_ventilation_section_2_1.yaml new file mode 100644 index 0000000..4f36fb9 --- /dev/null +++ b/db/schema2/views/v_ventilation_section_2_1.yaml @@ -0,0 +1,10 @@ +src: | + SELECT p_ventilation_section.ventilation_id, + p_ventilation_section.section_analytique_id AS ng_section_analytique_1_id, + p_ventilation_section.section_analytique_code AS ng_section_analytique_1_code, + p_ventilation_section.section_analytique_texte AS ng_section_analytique_1_texte, + p_ventilation_section.ratio, + p_ventilation_section.section_analytique_section_id AS ng_section_analytique_1_section_id, + p_ventilation_section.section_analytique_section_code AS ng_section_analytique_1_section_code, + p_ventilation_section.section_analytique_section_texte AS ng_section_analytique_1_section_texte + FROM rh.p_ventilation_section; \ No newline at end of file diff --git a/db/schema2/views/v_ventilation_section_2_2.yaml b/db/schema2/views/v_ventilation_section_2_2.yaml new file mode 100644 index 0000000..90c6638 --- /dev/null +++ b/db/schema2/views/v_ventilation_section_2_2.yaml @@ -0,0 +1,10 @@ +src: | + SELECT p_ventilation_section.ventilation_id, + p_ventilation_section.section_analytique_id AS ng_section_analytique_2_id, + p_ventilation_section.section_analytique_code AS ng_section_analytique_2_code, + p_ventilation_section.section_analytique_texte AS ng_section_analytique_2_texte, + p_ventilation_section.ratio, + p_ventilation_section.section_analytique_section_id AS ng_section_analytique_2_section_id, + p_ventilation_section.section_analytique_section_code AS ng_section_analytique_2_section_code, + p_ventilation_section.section_analytique_section_texte AS ng_section_analytique_2_section_texte + FROM rh.p_ventilation_section; \ No newline at end of file diff --git a/db/schema2/views/v_ventilation_section_2_3.yaml b/db/schema2/views/v_ventilation_section_2_3.yaml new file mode 100644 index 0000000..45d6a27 --- /dev/null +++ b/db/schema2/views/v_ventilation_section_2_3.yaml @@ -0,0 +1,10 @@ +src: | + SELECT p_ventilation_section.ventilation_id, + p_ventilation_section.section_analytique_id AS ng_section_analytique_3_id, + p_ventilation_section.section_analytique_code AS ng_section_analytique_3_code, + p_ventilation_section.section_analytique_texte AS ng_section_analytique_3_texte, + p_ventilation_section.ratio, + p_ventilation_section.section_analytique_section_id AS ng_section_analytique_3_section_id, + p_ventilation_section.section_analytique_section_code AS ng_section_analytique_3_section_code, + p_ventilation_section.section_analytique_section_texte AS ng_section_analytique_3_section_texte + FROM rh.p_ventilation_section; \ No newline at end of file diff --git a/db/schema2/views/v_visites_medicales_1.yaml b/db/schema2/views/v_visites_medicales_1.yaml new file mode 100644 index 0000000..957d9a2 --- /dev/null +++ b/db/schema2/views/v_visites_medicales_1.yaml @@ -0,0 +1,89 @@ +src: | + SELECT p_visites_medicales.oid AS visite_id, + p_visites_medicales.oid AS visite_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS visite_texte, + p_visites_medicales.mois_activite AS mois_visite, + p_visites_medicales.date AS date_visite, + p_salaries.finess, + p_contrats_mois.etablissement_id AS rhp_etablissement_id, + p_salaries.oid AS salarie_id, + p_salaries.matricule AS salarie_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS salarie_texte, + p_salaries.nom, + p_salaries.nom_naissance, + p_salaries.prenom, + p_salaries.date_naissance, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 2 + ELSE 1 + END AS sexe_id, + p_salaries.sexe AS sexe_code, + CASE + WHEN p_salaries.sexe = 'F'::bpchar THEN 'Féminin'::text + ELSE 'Masculin'::text + END AS sexe_texte, + p_salaries.situation_famille_id AS rhp_situation_famille_id, + p_salaries.code_original, + p_salaries.entreprise_id AS rhp_entreprise_id, + p_salaries.nationalite_id AS rhp_nationalite_id, + p_salaries.code_postal_id AS rhp_code_postal_id, + p_salaries.personne_id AS rhp_personne_id, + p_profil_contrat_mois.profil_id AS rhp_profil_id, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_reprise_mois, + p_contrats_mois.anciennete_annee_id AS rhp_anciennete_annee_id, + p_contrats_mois.anciennete_reprise_annee_id AS rhp_anciennete_reprise_annee_id, + p_contrats_mois.age_id AS rhp_age_id, + p_contrats_mois.age_jours, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.mois_activite::bigint AS mois_activite_id, + p_contrats_mois.mois_activite::text AS mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS mois_activite_texte, + p_contrats_mois.mois_activite::bigint AS annee_mois_activite_id, + p_contrats_mois.mois_activite::text AS annee_mois_activite_code, + (base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_mois_activite_texte, + (substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text)::bigint AS annee_trimestre_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS annee_trimestre_activite_code, + (('T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text) || ' '::text) || substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_trimestre_activite_texte, + substr(p_contrats_mois.mois_activite::text, 1, 4)::bigint AS annee_activite_id, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_code, + substr(p_contrats_mois.mois_activite::text, 1, 4) AS annee_activite_texte, + substr(p_contrats_mois.mois_activite::text, 5, 2)::bigint AS mois_only_activite_id, + substr(p_contrats_mois.mois_activite::text, 5, 2) AS mois_only_activite_code, + base.cti_to_french(to_char(p_contrats_mois.date_fin::timestamp with time zone, 'Month'::text)) AS mois_only_activite_texte, + date_part('quarter'::text, p_contrats_mois.date_fin)::bigint AS trimestre_activite_id, + date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_code, + 'T'::text || date_part('quarter'::text, p_contrats_mois.date_fin)::text AS trimestre_activite_texte, + p_contrats_mois.date_debut AS date_debut_activite, + p_contrats_mois.date_fin AS date_fin_activite, + p_contrats.oid AS contrat_id, + p_contrats.numero_contrat AS contrat_code, + (p_salaries.nom::text || ' '::text) || p_salaries.prenom::text AS contrat_texte, + p_contrats.date_debut AS date_debut_contrat, + p_contrats.date_fin AS date_fin_contrat, + p_contrats_mois.effectif_permanent, + p_contrats_mois.present_debut_mois, + p_contrats_mois.present_fin_mois, + p_visites_medicales.motif_visite_id AS rhp_motif_visite_id, + p_contrats.salarie_remplace_id AS rhp_salarie_remplace_id, + p_salaries.date_entree_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id AS rhp_anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id AS rhp_anciennete_fph_annee_id, + p_salaries.no_adeli, + p_salaries.matricule_retraite, + p_salaries.code_cotisation_id AS rhp_code_cotisation_id, + p_salaries.section_id AS salarie_section_id, + p_salaries.section_code AS salarie_section_code, + p_salaries.section_texte AS salarie_section_texte, + p_profil_contrat_mois.pole_id AS rhp_pole_id, + p_profil_contrat_mois.population_id[1] AS rhp_population_id, + p_profil_contrat_mois.budget_cle_id AS rhp_budget_cle_id + FROM rh.p_salaries + JOIN rh.p_visites_medicales ON p_visites_medicales.salarie_id = p_salaries.oid + JOIN rh.p_contrats ON p_contrats.oid = p_visites_medicales.contrat_id + JOIN rh.p_contrats_mois ON p_contrats_mois.oid = p_visites_medicales.contrat_mois_id + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid; \ No newline at end of file diff --git a/dummy b/dummy new file mode 100644 index 0000000..ce3483e --- /dev/null +++ b/dummy @@ -0,0 +1 @@ +rh/v25.9 \ No newline at end of file diff --git a/import_rh/iCTI_consolidation_planning.php b/import_rh/iCTI_consolidation_planning.php new file mode 100644 index 0000000..cc4fc5e --- /dev/null +++ b/import_rh/iCTI_consolidation_planning.php @@ -0,0 +1,338 @@ +args['-raz'] = 'ONLYKEY'; + + // Initialisation + $cti_sqlStatements = new CTI_SqlStatements_class('iCTI_import_'.$moduleName.'_CONSOLIDATION.XML', $iCTI_connexion, $environmentVars, $sqlOptions, 'iCTI_import_'.$moduleName.'_SHARE.XML'); + $cti_sqlStatements->executeStatementsNode('DISABLE_INDEX'); + $cti_sqlStatements->executeStatementsNode('RAZ'); + + // Consolidation environnement + foreach ($childEnvironments as $environment) { + + $environmentVars = array(); + + $environmentVars['PX'] = $environment->code; + $environmentVars['IPX'] = $environment->oid.'000000000'; + $environmentVars['PPX'] = $environment->oid; + $environmentVars['TPX'] = $environment->code.'_'; + $environmentVars['CPX'] = $environment->code.'_'; + $environmentVars['FINESS'] = $environment->finess; + $environmentVars['FINESS_TEXTE'] = $environment->name; + $environmentVars['DBHOST'] = $environment->host; + $environmentVars['DBPORT'] = $environment->port; + $environmentVars['DBNAME'] = $environment->dbname; + $environmentVars['DBUSERNAME'] = $environment->username; + $environmentVars['DBPASSWORD'] = $environment->password; + + $cti_sqlStatementsEnvironment = new CTI_SqlStatements_class('iCTI_import_'.$moduleName.'_CONSOLIDATION.XML', $iCTI_connexion, $environmentVars, $sqlOptions, 'iCTI_import_'.$moduleName.'_SHARE.XML'); + + $cti_sqlStatementsEnvironment->executeStatementsNode('INIT'); + $cti_sqlStatementsEnvironment->executeStatementsNode('PARAM'); + $cti_sqlStatementsEnvironment->executeStatementsNode('PLANNING'); + } + + // Finalisation + $cti_sqlStatements = new CTI_SqlStatements_class('iCTI_import_'.$moduleName.'_CONSOLIDATION.XML', $iCTI_connexion, $environmentVars, $sqlOptions, 'iCTI_import_'.$moduleName.'_SHARE.XML'); + $cti_sqlStatements->executeStatementsNode('ENABLE_INDEX'); + $cti_sqlStatements->executeStatementsNode('POST'); + $cti_sqlStatements->executeStatementsNode('VACCUM'); +} + +/** Récupère les "environnements enfants" qui consolident le module dont on précise le nom + * Retourne un tableau de stclass contenant les propriétés suivantes : + * - name + * - directory + * - code + * - oid + * - finess + * - host ('localhost' si non trouvé) + * - port ('5432' si non trouvé) + * - dbname + * - username + * - password + * Ou false en cas d'erreur + * @param $moduleName + * @return array|bool Tableau des "environnements enfants" ou false en cas d'erreur + */ +function getChildEnvironments($moduleName) { + + $environmentError = false; + $childEnvironments = array(); + + $file = Environnement::getInstance()->getRootPath()."\settings\settings.XML"; + if (file_exists($file)) { + $xml = simplexml_load_file($file); + if ($xml) { + + $nodes = $xml->xpath("/SETTINGS/CONSOLIDATION" . strtoupper($moduleName) . "/ENVIRONMENT"); + + foreach ($nodes as $environmentNode) { + + $environment = new stdClass(); + + $environment->name = ''; + $environment->finess = ''; + $environment->directory = ''; + $environment->code = ''; + $environment->oid = ''; + $environment->host = ''; + $environment->port = ''; + $environment->dbname = ''; + $environment->username = ''; + $environment->password = ''; + + $environmentName = ''; + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='ENVIRONMENT']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environmentName = trim($propertyNodes[0]['value']); + } + + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='DIR']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environment->directory = trim($propertyNodes[0]['value']); + } + + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='PREFIX_CODE']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environment->code = strtoupper(trim($propertyNodes[0]['value'])); + } + + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='PREFIX_OID']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environment->oid = trim($propertyNodes[0]['value']); + } + + $environmentSettings = getChildEnvironmentSettings($environment); + if (! $environmentSettings) { + logErrorMsg("Environnement $environmentName sur $environment->directory inexistant ou mal configuré"); + $environmentError = true; + } else { + $environment->name = $environmentSettings->name; + $environment->finess = $environmentSettings->finess; + } + + $environmentDatabaseSettings = getChildEnvironmentDatabaseSettings($environment); + if (! $environmentDatabaseSettings) { + logErrorMsg("Environnement $environmentName sur $environment->directory inexistant ou mal configuré"); + $environmentError = true; + } else { + $environment->host = $environmentDatabaseSettings->host; + $environment->port = $environmentDatabaseSettings->port; + $environment->dbname = $environmentDatabaseSettings->dbname; + $environment->username = $environmentDatabaseSettings->username; + $environment->password = $environmentDatabaseSettings->password; + } + + if ($environment->code === '' || $environment->oid === 0) { + logErrorMsg("Préfixes obligatoires ($environment->code,$environment->oid) pour environnement $environmentName"); + $environmentError = true; + } + + // Ajout de l'environnement dont on a contrôlé les paramètres + if (!$environmentError) { + $childEnvironments[] = $environment; + } + } + + } + + if ($environmentError) { + logErrorMsg("Au moins un environnement de la consolidation ".ucfirst($moduleName)." n'est pas correct"); + return false; + } + } else { + return false; + } + + return $childEnvironments; +} + +/** Lit les informations d'un "environnement enfant" (qui consolide) + * On récupère le chemin de l'environnement via sa propriété 'directory' + * On retourne une stdClass avec les propriétés suivantes : + * - name + * - finess + * @param $environment + * @return stdClass|bool false en cas d'erreur + */ +function getChildEnvironmentSettings($environment) { + + $settings = new stdClass(); + + $settings->name = ''; + $settings->finess = ''; + + $file = $environment->directory."\settings\settings.XML"; + if (file_exists($file)) { + $xml = simplexml_load_file($file); + if ($xml) { + $nodes = $xml->xpath("/SETTINGS/ENVIRONMENT/PROPERTY[@name='ENVIRONMENT']"); + $settings->name = trim($nodes[0]['value']); + + $nodes = $xml->xpath("/SETTINGS/ENVIRONMENT/PROPERTY[@name='FINESS']"); + $settings->finess = trim($nodes[0]['value']); + } + } else { + return false; + } + + return $settings; +} + +/** Lit les informations de la base de données d'un "environnement enfant" (qui consolide) + * On récupère le chemin de l'environnement via sa propriété 'directory' + * On retourne une stdClass avec les propriétés suivantes : + * - host ('localhost' si non trouvé) + * - port ('5432' si non trouvé) + * - dbname + * - username + * - password + * @param $environment + * @return stdClass|bool false en cas d'erreur + */ +function getChildEnvironmentDatabaseSettings($environment) { + + $dbSettings = new EnvironmentDatabaseSettings($environment->directory); + try { + $dbSettings->readSettings(); + } catch (Exception $e) { + logErrorMsg($e->getMessage()); + return false; + } + + $database = new stdClass(); + $database->host = $dbSettings->getHost(); + $database->port = $dbSettings->getPort(); + $database->dbname = $dbSettings->getName(); + $database->username = $dbSettings->getUsername(); + $database->password = $dbSettings->getPassword(); + + return $database; +} + +/** Vérifie si le module dont on précise le nom est configuré pour la consolidation + * @param $moduleName + * @return bool + */ +function checkIsConsolidate($moduleName) { + $isConsolidate = false; + + $file = Environnement::getInstance()->getRootPath()."/settings/settings.XML"; + $xml = simplexml_load_file($file); + + $nodes = $xml->xpath("/SETTINGS/MODULES/MODULE/SUBMODULE[@name='".$moduleName."']"); + + // Le noeud a été trouvé + if (count($nodes) == 1) { + if (isset($nodes[0]['consolidate'])) { + $isConsolidate = (strtolower($nodes[0]['consolidate']) === 'true'); + } + } + + return $isConsolidate; +} + +/** Connecte la base de données de l'environnement + * @return bool false en cas d'erreur + * @throws Exception + */ +function iCTI_connect() { + + global $iCTI_connexion; + + // Connexion BD + $iCTI_connexion = Database2Factory::getInstance(Environnement::PROVIDER_CTI); + $ret = $iCTI_connexion->connect(); + + if (!$ret) { + logErrorMsg("La connexion PostgreSQL iCTI a échoué"); + return false; + } + + return true; +} + +function iCTI_disconnect() { + + global $iCTI_connexion; + + $iCTI_connexion->close(); +} + +?> \ No newline at end of file diff --git a/import_rh/iCTI_consolidation_rh.php b/import_rh/iCTI_consolidation_rh.php new file mode 100644 index 0000000..f89ddb4 --- /dev/null +++ b/import_rh/iCTI_consolidation_rh.php @@ -0,0 +1,381 @@ +getActivatedFeatures(); + } catch(Exception $e) { + // Si l'exception est la non présence de FEATURES alors on passe simplement + // Pour les autres exceptions, c'est donc une exception à signaler + if($e->getMessage() !== FeaturesManager::FEATURES_MANAGER_NO_FEATURES_EXCEPTION) { + logErrorMsg("Erreur lors de la gestion des features : ".$e->getMessage()); + } + $activatedFeatures = array(); + } + + if(in_array('RH_VENTILATION_CAPSANTE',$activatedFeatures)) { + // Contact de l'API pour initialisation de la ventilation + log automatique du retour (OK/ERREUR) + logInfoMsg("Initialisation de la Ventilation Capsanté"); + + $apiUrl = ApiUrlGenerator::generate(iCTI_dir(), 'rh/paie/ventilations/initialize'); + $HttpClient = HttpFactory::createInstance(); + $HttpClientResult = $HttpClient->post($apiUrl, array(), array('timeout' => 150), true); + $HttpClientMessage = is_array($HttpClientResult) && array_key_exists('message', $HttpClientResult) ? $HttpClientResult['message'] : ''; + $HttpClientResult ? logInfoMsg($HttpClientMessage) : logErrorMsg('Erreur lors de l\'initialisation de la Ventilation Capsanté'); + } + + logInfoMsg('Nettoyage cache'); + cleanAllCache('iCTI_'.$moduleName, true); + } + } +} + +iCTI_disconnect(); + +logEndMsg(); + +/** Consolide le module dont on précise le nom avec les "environnemnts enfants" concernés + * @param $moduleName + * @param $childEnvironments + */ +function consolidateEnvironments($moduleName, $childEnvironments) { + + global $iCTI_connexion; + global $childEnvironments; + global $cti_args; + + // Chargement requetes SQL + $environmentShareVars = array(); + $environmentShareVars["PX"] = ""; + + // Chargement requêtes SQL + $environmentVars = array(); + $sqlOptions = array(); + + // Raz forcé + $cti_args->args['-raz'] = 'ONLYKEY'; + + // Initialisation + $cti_sqlStatements = new CTI_SqlStatements_class('iCTI_import_'.$moduleName.'_CONSOLIDATION.XML', $iCTI_connexion, $environmentVars, $sqlOptions); + $cti_sqlStatements->executeStatementsNode('RAZ'); + $cti_sqlStatements->executeStatementsNode('DISABLE_INDEX'); + + $cti_sqlStatementsShare = new CTI_SqlStatements_class('iCTI_import_rh_SHARE.XML', $iCTI_connexion, $environmentShareVars, $sqlOptions); + $cti_sqlStatementsShare->executeStatementsNode("RAZ"); + $cti_sqlStatementsShare->executeStatementsNode("INIT"); + + // Consolidation environnement + foreach ($childEnvironments as $environment) { + + $environmentVars = array(); + + $environmentVars['PX'] = $environment->code; + $environmentVars['IPX'] = $environment->oid.'000000000'; + $environmentVars['PPX'] = $environment->oid; + $environmentVars['TPX'] = $environment->code.'_'; + $environmentVars['CPX'] = $environment->code.'_'; + $environmentVars['FINESS'] = $environment->finess; + $environmentVars['FINESS_TEXTE'] = $environment->name; + $environmentVars['DBHOST'] = $environment->host; + $environmentVars['DBPORT'] = $environment->port; + $environmentVars['DBNAME'] = $environment->dbname; + $environmentVars['DBUSERNAME'] = $environment->username; + $environmentVars['DBPASSWORD'] = $environment->password; + + $cti_sqlStatementsEnvironment = new CTI_SqlStatements_class('iCTI_import_'.$moduleName.'_CONSOLIDATION.XML', $iCTI_connexion, $environmentVars, $sqlOptions); + $cti_sqlStatementsEnvironment->executeStatementsNode('INIT'); + $cti_sqlStatementsEnvironment->executeStatementsNode('PARAM'); + $cti_sqlStatementsEnvironment->executeStatementsNode('PAIE'); + } + + // Finalisation + $cti_sqlStatements->executeStatementsNode('POST'); + $cti_sqlStatements->executeStatementsNode('ENABLE_INDEX'); + + $cti_sqlStatementsShare->executeStatementsNode("DIVERS"); + $cti_sqlStatementsShare->executeStatementsNode("POST"); + $cti_sqlStatementsShare->executeStatementsNode("VACUUM"); +} + +/** Récupère les "environnements enfants" qui consolident le module dont on précise le nom + * Retourne un tableau de stclass contenant les propriétés suivantes : + * - name + * - directory + * - code + * - oid + * - finess + * - host ('localhost' si non trouvé) + * - port ('5432' si non trouvé) + * - dbname + * - username + * - password + * Ou false en cas d'erreur + * @param $moduleName + * @return array|bool Tableau des "environnements enfants" ou false en cas d'erreur + */ +function getChildEnvironments($moduleName) { + + $environmentError = false; + $childEnvironments = array(); + + $file = Environnement::getInstance()->getRootPath()."\settings\settings.XML"; + if (file_exists($file)) { + $xml = simplexml_load_file($file); + if ($xml) { + + $nodes = $xml->xpath("/SETTINGS/CONSOLIDATION" . strtoupper($moduleName) . "/ENVIRONMENT"); + + foreach ($nodes as $environmentNode) { + + $environment = new stdClass(); + + $environment->name = ''; + $environment->finess = ''; + $environment->directory = ''; + $environment->code = ''; + $environment->oid = ''; + $environment->host = ''; + $environment->port = ''; + $environment->dbname = ''; + $environment->username = ''; + $environment->password = ''; + + $environmentName = ''; + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='ENVIRONMENT']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environmentName = trim($propertyNodes[0]['value']); + } + + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='DIR']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environment->directory = trim($propertyNodes[0]['value']); + } + + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='PREFIX_CODE']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environment->code = strtoupper(trim($propertyNodes[0]['value'])); + } + + $propertyNodes = $environmentNode->xpath("PROPERTY[@name='PREFIX_OID']"); + // Le noeud a été trouvé + if (count($propertyNodes) == 1) { + $environment->oid = trim($propertyNodes[0]['value']); + } + + $environmentSettings = getChildEnvironmentSettings($environment); + if (! $environmentSettings) { + logErrorMsg("Environnement $environmentName sur $environment->directory inexistant ou mal configuré"); + $environmentError = true; + } else { + $environment->name = $environmentSettings->name; + $environment->finess = $environmentSettings->finess; + } + + $environmentDatabaseSettings = getChildEnvironmentDatabaseSettings($environment); + if (! $environmentDatabaseSettings) { + logErrorMsg("Environnement $environmentName sur $environment->directory inexistant ou mal configuré"); + $environmentError = true; + } else { + $environment->host = $environmentDatabaseSettings->host; + $environment->port = $environmentDatabaseSettings->port; + $environment->dbname = $environmentDatabaseSettings->dbname; + $environment->username = $environmentDatabaseSettings->username; + $environment->password = $environmentDatabaseSettings->password; + } + + if ($environment->code === '' || $environment->oid === 0) { + logErrorMsg("Préfixes obligatoires ($environment->code,$environment->oid) pour environnement $environmentName"); + $environmentError = true; + } + + // Ajout de l'environnement dont on a contrôlé les paramètres + if (!$environmentError) { + $childEnvironments[] = $environment; + } + } + + } + + if ($environmentError) { + logErrorMsg("Au moins un environnement de la consolidation ".ucfirst($moduleName)." n'est pas correct"); + return false; + } + } else { + return false; + } + + return $childEnvironments; +} + +/** Lit les informations d'un "environnement enfant" (qui consolide) + * On récupère le chemin de l'environnement via sa propriété 'directory' + * On retourne une stdClass avec les propriétés suivantes : + * - name + * - finess + * @param $environment + * @return stdClass|bool false en cas d'erreur + */ +function getChildEnvironmentSettings($environment) { + + $settings = new stdClass(); + + $settings->name = ''; + $settings->finess = ''; + + $file = $environment->directory."\settings\settings.XML"; + if (file_exists($file)) { + $xml = simplexml_load_file($file); + if ($xml) { + $nodes = $xml->xpath("/SETTINGS/ENVIRONMENT/PROPERTY[@name='ENVIRONMENT']"); + $settings->name = trim($nodes[0]['value']); + + $nodes = $xml->xpath("/SETTINGS/ENVIRONMENT/PROPERTY[@name='FINESS']"); + $settings->finess = trim($nodes[0]['value']); + } + } else { + return false; + } + + return $settings; +} + +/** Lit les informations de la base de données d'un "environnement enfant" (qui consolide) + * On récupère le chemin de l'environnement via sa propriété 'directory' + * On retourne une stdClass avec les propriétés suivantes : + * - host ('localhost' si non trouvé) + * - port ('5432' si non trouvé) + * - dbname + * - username + * - password + * @param $environment + * @return stdClass|bool false en cas d'erreur + */ +function getChildEnvironmentDatabaseSettings($environment) { + + $dbSettings = new EnvironmentDatabaseSettings($environment->directory); + try { + $dbSettings->readSettings(); + } catch (Exception $e) { + logErrorMsg($e->getMessage()); + return false; + } + + $database = new stdClass(); + $database->host = $dbSettings->getHost(); + $database->port = $dbSettings->getPort(); + $database->dbname = $dbSettings->getName(); + $database->username = $dbSettings->getUsername(); + $database->password = $dbSettings->getPassword(); + + return $database; +} + +/** Vérifie si le module dont on précise le nom est configuré pour la consolidation + * @param $moduleName + * @return bool + */ +function checkIsConsolidate($moduleName) { + $isConsolidate = false; + + $file = Environnement::getInstance()->getRootPath()."/settings/settings.XML"; + $xml = simplexml_load_file($file); + + $nodes = $xml->xpath("/SETTINGS/MODULES/MODULE[@name='".$moduleName."' and @installed='true']"); + + // Le noeud a été trouvé + if (count($nodes) == 1) { + if (isset($nodes[0]['consolidate'])) { + $isConsolidate = (strtolower($nodes[0]['consolidate']) === 'true'); + } + } + + return $isConsolidate; +} + +/** Connecte la base de données de l'environnement + * @return bool false en cas d'erreur + * @throws Exception + */ +function iCTI_connect() { + + global $iCTI_connexion; + + // Connexion BD + $iCTI_connexion = Database2Factory::getInstance(Environnement::PROVIDER_CTI); + $ret = $iCTI_connexion->connect(); + + if (!$ret) { + logErrorMsg("La connexion PostgreSQL iCTI a échoué"); + return false; + } + + return true; +} + +function iCTI_disconnect() { + + global $iCTI_connexion; + + $iCTI_connexion->close(); +} + +?> \ No newline at end of file diff --git a/import_rh/iCTI_import_planning.exe b/import_rh/iCTI_import_planning.exe new file mode 100644 index 0000000..a342139 Binary files /dev/null and b/import_rh/iCTI_import_planning.exe differ diff --git a/import_rh/iCTI_import_planning.php b/import_rh/iCTI_import_planning.php new file mode 100644 index 0000000..ddfd4a3 --- /dev/null +++ b/import_rh/iCTI_import_planning.php @@ -0,0 +1,196 @@ +hasPlanningProvider2(); +$p1 = Environnement::getInstance()->getPlanningProvider(); +$p2 = Environnement::getInstance()->getPlanningProvider2(); + +$p1Start = Environnement::getInstance()->getPlanningProviderStart(); +if ($p1Start == '') { + $p1Start = Environnement::getInstance()->getRhProviderStart(); +} +$p2Start = Environnement::getInstance()->getPlanningProvider2Start(); +$tmpDate = date_create($p1Start); +date_modify($tmpDate, '-1 day'); +$p2End = date_format($tmpDate, 'Y-m-d'); + + +logStartMsg(); + +// Chargement des paramètres et connexion BD +$iCTI_connexion = Database2Factory::getInstance(Environnement::PROVIDER_CTI); +$ret = $iCTI_connexion->connect(); + +// Récupération des arguments passés en paramètres +$cti_args = new CTI_Args_class(); + +if (checkLoadedData($p1, $MODULE) === 0 || $cti_args->args["-f"]) { + logInfoMsg("Données prestataire $p1 chargées avec succès."); + + // import CTI + extraction_environnement($p1, $p1Start); + +} else { + logErrorMsg("Problème de chargement des données prestataire $p1."); +} + +if ($multiP) { + if (checkLoadedData($p2, $MODULE) === 0 || $cti_args->args["-f"]) { + logInfoMsg("Données prestataire $p2 chargées avec succès."); + + // import CTI + extraction_environnement($p2, $p2Start, $p2End); + + } else { + logErrorMsg("Problème de chargement des données prestataire $p2."); + } +} + +// Croisement Paie Planning +// Gestion des FEATURES +try { + $FM = new FeaturesManager(); + $activatedFeatures = $FM->getActivatedFeatures(); +} catch(Exception $e) { + // Si l'exception est la non présence de FEATURES alors on passe simplement + // Pour les autres exceptions, c'est donc une exception à signaler + if($e->getMessage() !== FeaturesManager::FEATURES_MANAGER_NO_FEATURES_EXCEPTION) { + logErrorMsg("Erreur lors de la gestion des features : ".$e->getMessage()); + } + $activatedFeatures = array(); +} + +if(in_array('RH_CROISEMENT_PAIE_PLANNING',$activatedFeatures)) { + $iCTI_connexion->query('SELECT rh.cti_croisement_paie_planning_generate()'); +} + +// nettoyage du cache +logInfoMsg("Nettoyage cache"); +cleanAllCache("iCTI_rh", TRUE); + +// Déconnexion BD +$iCTI_connexion->close(); + +logEndMsg(); + +/** + * ****************************************************** + * FONCTIONS * + * ****************************************************** + */ + + +// récupération historique +function extraction_environnement($_prestataire, $_start, $_end = '2099-12-31') { + global $cti_sqlStatements; + global $cti_args; + global $iCTI_connexion; + + try { + logInfoMsg("RECUPERATION DE LA PRODUCTION $_prestataire (de $_start à $_end)"); + + // Raz automatique le samedi + if (date("w") == 6) { + $cti_args->args["-raz"] = "ONLYKEY"; + } + + $environmentVars = array(); + $environmentVars["ENV_PLANNING_DATEDEBUT"] = $_start; + $environmentVars["ENV_PLANNING_DATEFIN"] = $_end; + + $environmentVars["FINESS"] = Environnement::getInstance()->getFiness(); + $environmentVars["SIREN"] = Environnement::getInstance()->getSiren(); + $environmentVars["OPTRH_AVT_NATURE"] = Environnement::getInstance()->getOptAvantageNature(); + + // Création d'une table SQL temporaire contenant les paramètres à passer à l'import RH. + // A appeler dans le SQL de la façon suivante : rhp('finess'); + + $tmpParamSql = " + DROP TABLE IF EXISTS rhp + ; + CREATE TEMP TABLE rhp AS + VALUES + ('siren'::text, '" . trim($environmentVars["SIREN"]) . "'::text), + ('finess'::text, '" . $environmentVars["FINESS"] . "'::text), + ('opt_avt_nature'::text, '" . $environmentVars["OPTRH_AVT_NATURE"] . "'::text), + ('planningprovider_start'::text, '" . $_start . "'::text) + ; + + DROP FUNCTION IF EXISTS rhp(text) + ; + CREATE FUNCTION rhp(text) + RETURNS text AS + \$BODY\$ + SELECT column2 FROM rhp WHERE column1 = \$1 + ; + \$BODY\$ + LANGUAGE 'sql' VOLATILE + ; + + DROP FUNCTION IF EXISTS rhp_in(text) + ; + CREATE FUNCTION rhp_in(text) + RETURNS setof text AS + \$BODY\$ + SELECT column2 FROM rhp WHERE column1 = \$1 + ; + \$BODY\$ + LANGUAGE 'sql' VOLATILE + ; + "; + $iCTI_connexion->query($tmpParamSql); + + $sqlOptions = array(); + foreach ($cti_args->args as $key => $value) { + $sqlOptions[] = $key; + } + + $cti_sqlStatements = new CTI_SqlStatements_class("iCTI_import_planning_".$_prestataire.".XML", $iCTI_connexion, $environmentVars, $sqlOptions, "iCTI_import_planning_SHARE.XML", "iCTI_import_rh_SHARE.XML"); + + if ($cti_args->args["-raz"]) { + $cti_sqlStatements->executeStatementsNode("RAZ"); + $cti_sqlStatements->executeStatementsNode("VACUUM"); + } + + $cti_sqlStatements->executeStatementsNode("INIT"); + $cti_sqlStatements->executeStatementsNode("PROD"); + $cti_sqlStatements->executeStatementsNode("POST"); + $cti_sqlStatements->executeStatementsNode("VACUUM"); + $cti_sqlStatements->executeStatementsNode("VENTILATION"); + } catch (Exception $e) { + logErrorMsg("Impossible de charger les requêtes SQL."); + exit(1); + } + + logEndMsg(); +} + +?> \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_AGILETIME.XML b/import_rh/iCTI_import_planning_AGILETIME.XML new file mode 100644 index 0000000..4aba972 --- /dev/null +++ b/import_rh/iCTI_import_planning_AGILETIME.XML @@ -0,0 +1,1243 @@ + + + + + + + + 250 THEN 30 ELSE 0 END END as duree + FROM w_plan_base + JOIN prod_agiletime.SALARIE ON SALARIE.idsalarie = w_plan_base.idsalarie and SALARIE.idetat = 1 + JOIN prod_agiletime.SALARIE_CONTRAT ON SALARIE.idsalarie = SALARIE_CONTRAT.idsalarie AND SALARIE_CONTRAT.idetat = 1 + JOIN prod_agiletime.CONTRAT ON SALARIE_CONTRAT.idcontrat = CONTRAT.idcontrat AND dt BETWEEN dtdebut AND (CASE WHEN dtfin != '1800-01-01' THEN dtfin ELSE '2099-12-31' END) AND CONTRAT.idetat = 1 + LEFT JOIN prod_agiletime.AFFPH on AFFPH.idaffch = w_plan_base.idaffch and AFFPH.idetat = 1 + -- cas Keraudren ou les plages sont divisées en deux + AND ((debut_th < fin_th) AND (AFFPH.heuredebut < fin_th AND AFFPH.heurefin > debut_th) OR (debut_th > fin_th) AND (AFFPH.heuredebut > fin_th AND AFFPH.heurefin < debut_th)) + LEFT JOIN prod_agiletime.AFFPH_TYPEHEURE ON AFFPH.idaffph = AFFPH_TYPEHEURE.idaffph and AFFPH_TYPEHEURE.idetat = 1 + LEFT JOIN (SELECT DISTINCT idph FROM prod_agiletime.ph_ecretage) sub on sub.idph = w_plan_base.idph + WHERE 1=1 + -- séparation en deux PPL et REF enlève les abscences on garde donc PPL et il faudra voir à la qualif + AND idplan = 'PPL' + AND (AFFPH_TYPEHEURE.idtypeheure = phidtypeheure OR AFFPH_TYPEHEURE.idtypeheure IS NULL) + + ; + + DELETE from w_plan_rea where doubleaff != -(AFFPHdoubleaff); + + -- ajustements des durées avec les pauses + + UPDATE w_plan_theo + SET + duree_th = w_plan_theo.duree_th - w_pauses.duree_th, + debut_th = CASE WHEN w_plan_theo.debut_th + w_pauses.duree_th < 1440 THEN w_plan_theo.debut_th + w_pauses.duree_th ELSE w_plan_theo.debut_th END, + fin_th = CASE WHEN w_plan_theo.debut_th + w_pauses.duree_th >= 1440 THEN w_plan_theo.fin_th + w_pauses.duree_th ELSE w_plan_theo.fin_th END + FROM w_plan_theo w_pauses + + + WHERE 1=1 + AND w_pauses.phidtypeheure = ANY(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_PAUSE'),',')) + AND w_plan_theo.idaffch = w_pauses.idaffch + AND w_plan_theo.doubleaff = w_pauses.doubleaff + AND w_plan_theo.phidtypeheure != ALL(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_PAUSE'),',')) + + + + ; + + + UPDATE w_plan_rea + SET + duree = w_plan_rea.duree - w_pauses.duree, + + heuredebut = CASE WHEN w_plan_rea.heuredebut + w_pauses.duree < 1440 THEN w_plan_rea.heuredebut + w_pauses.duree ELSE w_plan_rea.heuredebut END, + + heurefin = CASE WHEN w_plan_rea.heuredebut + w_pauses.duree >= 1440 THEN w_plan_rea.heurefin + w_pauses.duree ELSE w_plan_rea.heurefin END + + FROM w_plan_rea w_pauses + WHERE 1=1 + AND w_pauses.phidtypeheure = ANY(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_PAUSE'),',')) + + AND w_plan_rea.idaffch = w_pauses.idaffch + AND w_plan_rea.doubleaff = w_pauses.doubleaff + AND w_plan_rea.phidtypeheure != ALL(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_PAUSE'),',')) + + ; + + DELETE FROM w_plan_theo WHERE phidtypeheure = ANY(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_PAUSE'),',')); + DELETE FROM w_plan_rea WHERE phidtypeheure = ANY(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_PAUSE'),',')); + + ; + + --effacement des avenants + DELETE FROM w_plan_rea WHERE phidtypeheure = ANY(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_TODEL'),',')); + ; + DELETE FROM w_plan_theo WHERE phidtypeheure = ANY(regexp_split_to_array((SELECT valeur FROM rh.t_divers WHERE code = 'AGILETIME_TODEL'),',')); + + ; + + DROP SEQUENCE IF EXISTS w_cptres1_seq + ; + + CREATE TEMP SEQUENCE w_cptres1_seq + ; + + DROP TABLE IF EXISTS w_cptres1 + ; + -- heures travaillees = temps valide + CREATE TEMP TABLE w_cptres1 AS + SELECT + nextval('w_cptres1_seq') as cptres1_id, + matricule, + salarie_id, + numero, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(dt) AS date, + date(dt) AS date_orig, + duree/60.0 AS temps_orig, + idcompetence, + iduep, + ''::text AS abs_cod, + 0::numeric AS temps_du_initial, + 0::numeric AS temps_du, + CASE WHEN heurefin >= heuredebut AND (duree < 1440 OR duree is null) THEN heurefin - heuredebut ELSE (1440 - heuredebut) END/60.0 AS temps_valide, + 0::numeric AS temps_absence + FROM w_plan_rea + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_rea.salarie_corr AND etablissement_planning_code = site_code + WHERE 1=1 + AND idtypologiech IN (1,4) + AND idtypecomportement = 1 + ORDER BY 2,7 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + matricule, + salarie_id, + numero, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(dt) + interval '1 day' AS date, + date(dt) AS date_orig, + duree / 60.0 AS temps_orig, + idcompetence, + iduep, + ''::text AS abs_cod, + 0 AS temps_du_initial, + 0 AS temps_du, + heurefin / 60.0 AS temps_valide, + 0::numeric AS temps_absence + FROM w_plan_rea + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_rea.salarie_corr AND etablissement_planning_code = site_code + WHERE 1=1 + AND idtypologiech IN (1,4) + AND idtypecomportement = 1 + AND (heurefin < heuredebut OR duree > 1440) + ORDER BY 2,7 + ; + + -- heures planifiées = temps du intial + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + matricule, + salarie_id, + numero, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(dt) AS date, + date(dt) AS date_orig, + duree_th / 60.0 AS temps_orig, + idcompetence, + iduep, + ''::text AS abs_cod, + CASE WHEN fin_th >= debut_th AND duree_th < 1440 THEN duree_th ELSE (1440 - debut_th) END/60.0 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + 0::numeric AS temps_absence + FROM w_plan_theo + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_theo.salarie_corr AND etablissement_planning_code = site_code + WHERE 1=1 + AND idtypologiech IN (1,4) + AND idtypecomportement = 1 + ORDER BY 2,7 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + matricule, + salarie_id, + numero, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(dt) + interval '1 day' AS date, + date(dt) AS date_orig, + duree_th / 60.0 AS temps_orig, + idcompetence, + iduep, + ''::text AS abs_cod, + fin_th / 60.0 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + 0::numeric AS temps_absence + FROM w_plan_theo + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_theo.salarie_corr AND etablissement_planning_code = site_code + WHERE 1=1 + AND idtypologiech IN (1,4) + AND idtypecomportement = 1 + AND (fin_th < debut_th OR duree_th > 1440) + ORDER BY 2,7 + ; + + + -- absences + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + matricule, + salarie_id, + numero, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(dt) AS date, + date(dt) AS date_orig, + duree / 60.0 AS temps_orig, + idcompetence, + iduep, + idch AS abs_cod, + 0 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + CASE WHEN heurefin > heuredebut THEN duree + WHEN heurefin < heuredebut THEN (1440 - heuredebut) + WHEN heurefin = heuredebut AND duree != 0 THEN duree + ELSE dureejour END/60.0 AS temps_absence + FROM w_plan_rea + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_rea.salarie_corr AND etablissement_planning_code = site_code + WHERE 1=1 + AND idtypologiech = 2 + AND idtypecomportement IN (1,8,9) + ORDER BY 2,7 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + matricule, + salarie_id, + numero, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(dt) + interval '1 day' AS date, + date(dt) AS date_orig, + duree_th / 60.0 AS temps_orig, + idcompetence, + iduep, + idch AS abs_cod, + 0 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + heurefin/60.0 AS temps_absence + FROM w_plan_rea + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_rea.salarie_corr AND etablissement_planning_code = site_code + WHERE 1=1 + AND idtypologiech = 2 + AND idtypecomportement IN (1,8,9) + AND heurefin < heuredebut + ORDER BY 2,7 + ; + + UPDATE w_cptres1 + SET date = date_orig + FROM rh.t_divers + WHERE + code = 'VENTIL_JOUR' + AND valeur = 0; + + + VACUUM ANALYSE w_cptres1 + ; + + -- Association aux contrats et contrat_mois. + -- En général, les heures planning sont effectuées AVANT un contrat/paie à cause du décallage avec la paie : + -- => les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and w_cptres1.date between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + WHERE 1=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut > w_cptres1.date -- Sélection des contrats APRES heures planning. + WHERE 1=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut < w_cptres1.date -- Sélection des contrats AVANT heures planning. + WHERE 1=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + -- Création d'index. + CREATE INDEX w_cptres1_i_contrat_id ON w_cptres1 USING btree (contrat_id) + ; + CREATE INDEX w_cptres1_i_contrat_mois_id ON w_cptres1 USING btree (contrat_mois_id) + ; + CREATE INDEX w_cptres1_i_date ON w_cptres1 USING btree (date) + ; + CREATE INDEX w_cptres1_i_salarie_id ON w_cptres1 USING btree (salarie_id) + ; + + -- Alimentation des tables de paramètres. + + INSERT INTO rh.t_divers( + code, + texte, + valeur, + valeur_date, + description) + -- Ajout du paramétrage permettant de choisir le niveau intermédiaire Agiletime + SELECT + 'AGILETIME_NIV2', + 'Niveau intermédiaire dans Agiletime (0 ou 1).', + '1', + NULL::date, + '(0) Groupe d''UEP (1) Structure' + WHERE (SELECT count(*) FROM rh.t_divers WHERE code = 'AGILETIME_NIV2') = 0 + ; + + -- Màj des Services du Planning. (UEP) + INSERT INTO rh.t_planning_service(code_original, code, texte, texte_court, service_id) + WITH services AS ( + SELECT + iduep, + idstructure AS id, + structure_code AS code, + structure_nom as texte + FROM w_structure + JOIN rh.t_divers ON code ='AGILETIME_NIV2' AND valeur = '1' + UNION ALL + SELECT + iduep, + iduepgroupe AS id, + uepgroupe_code::text AS code, + uepgroupe_nom AS texte + FROM w_structure + JOIN rh.t_divers ON code ='AGILETIME_NIV2' AND valeur = '0' + UNION ALL + SELECT + null AS iduep, + 0 AS id, + 'NR' AS code, + 'Non renseigné' as texte + ) + SELECT id, code, texte, texte, (select oid from rh.t_classes where code = 'PLANIV2') as classe_id + FROM services + WHERE id IS NOT NULL AND + id NOT IN (SELECT code_original FROM rh.t_planning_service WHERE code_original IS NOT NULL) + AND (iduep IN (SELECT iduep FROM w_cptres1 GROUP BY 1) OR iduep IS NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des Niveaux du Planning. (UEP) + DROP TABLE IF EXISTS w_niv_uep; + CREATE TEMP TABLE w_niv_uep AS + SELECT + iduep, + site_code||'|'||COALESCE(CASE WHEN COALESCE(valeur::int,0) = 0 THEN uepgroupe_code ELSE structure_code END,'NR') ||'|'||uep_code||CASE WHEN rank() OVER (PARTITION BY uep_code ORDER BY iduep) > 1 THEN '_2' ELSE '' END as code_original, + uep_code, + uep_nom + FROM w_structure + LEFT JOIN rh.t_divers ON code ='AGILETIME_NIV2' + ; + + INSERT INTO rh.t_planning_niveau(code_original, code, texte, texte_court) + SELECT + code_original, + uep_code, + uep_nom, + substr(uep_nom,1,50) + FROM w_niv_uep + WHERE code_original NOT IN (SELECT code_original FROM rh.t_planning_niveau WHERE code_original IS NOT NULL) + AND iduep IN (SELECT iduep FROM w_cptres1 GROUP BY 1) + ; + + -- Màj des Qualifications du Planning. (competence) + INSERT INTO rh.t_planning_qualification(code_original, code, texte, texte_court) + SELECT + idcompetence, + idcompetence, + nom, + nom + FROM prod_agiletime.COMPETENCE + WHERE 1=1 + AND idcompetence IN (SELECT idcompetence FROM w_cptres1) + AND idcompetence NOT IN (SELECT code_original FROM rh.t_planning_qualification WHERE code_original IS NOT NULL) + ; + + -- Màj des Types d'absences du Planning. (ch) + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + idch, + nomabrege, + nom, + nom + FROM prod_agiletime.CH + WHERE 1=1 + AND idch IN (SELECT abs_cod FROM w_cptres1 GROUP BY 1) + AND idch NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + ; + + -- Création d'une table Entreprise/Etablissement. + DROP TABLE IF EXISTS w_entets + ; + + CREATE TEMP TABLE w_entets AS + SELECT + ets.oid as etablissement_id, + ent.planning_code||ets.planning_code as entets_code + from rh.t_entreprises as ent + join rh.t_etablissements as ets on ets.entreprise_id = ent.oid + Where 1=1 + and ent.oid != 0 + and ets.oid != 0 + ; + + DROP TABLE IF EXISTS w_ventil_structure; + CREATE TEMP TABLE w_ventil_structure AS + SELECT + idstructure, + code, + string_to_array(nom,' ') as codes, + string_to_array(code,'_')::int[] as coefs, + array_length(string_to_array(nom,' '),1) as nb_codes, + array_length(string_to_array(code,'_'),1) as nb_coefs, + (select sum(unnest) from (select unnest(string_to_array(code,'_')::int[])) sub) - split_part(code,'_',1)::int as coef_tot + FROM prod_agiletime.STRUCTURE + WHERE code ~ '_' + + ; + + DROP TABLE IF EXISTS w_ventil_services; + CREATE TABLE w_ventil_services AS + SELECT + idstructure, + code_original, + texte, + coefs[nb_coefs] AS coef, + coef_tot + FROM w_ventil_structure + LEFT JOIN rh.t_planning_service ON + CASE WHEN codes[nb_codes] IN (SELECT left(code,4) FROM rh.t_planning_service) THEN left(t_planning_service.code,4) ELSE upper(replace(left(t_planning_service.texte,3),'é','e')) END = codes[nb_codes] + ; + + INSERT INTO w_ventil_services + SELECT + idstructure, + code_original, + texte, + coefs[nb_coefs-1] AS coef, + coef_tot + FROM w_ventil_structure + LEFT JOIN rh.t_planning_service ON + CASE WHEN codes[nb_codes-1] IN (SELECT left(code,4) FROM rh.t_planning_service) THEN left(t_planning_service.code,4) ELSE upper(replace(left(t_planning_service.texte,3),'é','e')) END = codes[nb_codes-1] + ; + INSERT INTO w_ventil_services + SELECT + idstructure, + code_original, + texte, + coefs[nb_coefs-2] AS coef, + coef_tot + FROM w_ventil_structure + LEFT JOIN rh.t_planning_service ON + CASE WHEN codes[nb_codes-2] IN (SELECT left(code,4) FROM rh.t_planning_service) THEN left(t_planning_service.code,4) ELSE upper(replace(left(t_planning_service.texte,3),'é','e')) END = codes[nb_codes-2] + ; + INSERT INTO w_ventil_services + SELECT + idstructure, + code_original, + texte, + coefs[nb_coefs-3] AS coef, + coef_tot + FROM w_ventil_structure + LEFT JOIN rh.t_planning_service ON + CASE WHEN codes[nb_codes-3] IN (SELECT left(code,4) FROM rh.t_planning_service) THEN left(t_planning_service.code,4) ELSE upper(replace(left(t_planning_service.texte,3),'é','e')) END = codes[nb_codes-3] + ; + INSERT INTO w_ventil_services + SELECT + idstructure, + code_original, + texte, + coefs[nb_coefs-4] AS coef, + coef_tot + FROM w_ventil_structure + LEFT JOIN rh.t_planning_service ON + CASE WHEN codes[nb_codes-4] IN (SELECT left(code,4) FROM rh.t_planning_service) THEN left(t_planning_service.code,4) ELSE upper(replace(left(t_planning_service.texte,3),'é','e')) END = codes[nb_codes-4] + ; + + -- Alimentation de la table de mouvement. + -- Alimentation de la table de mouvement. + TRUNCATE rh.p_planning_mouvement + ; + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + date, + to_char(date, 'IYYYIW'::text)::numeric AS semaine, + to_char(date, 'YYYYMM'::text)::numeric AS mois, + coalesce(w_entets.etablissement_id, 0) as etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) as niveau_id, + temps_valide + temps_absence, + temps_du_initial, + temps_valide, + temps_absence + FROM w_cptres1 + LEFT JOIN w_structure ON w_cptres1.iduep = w_structure.iduep + LEFT JOIN w_ventil_services ON w_structure.idstructure = w_ventil_services.idstructure + LEFT JOIN rh.t_planning_service ON t_planning_service.code_original = w_structure.idstructure + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = w_cptres1.idcompetence + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code_original = w_cptres1.abs_cod + LEFT JOIN w_entets ON w_entets.entets_code = 1 -- w_cptres1.entets_code + LEFT JOIN w_niv_uep ON w_cptres1.iduep = w_niv_uep.iduep + LEFT JOIN rh.t_planning_niveau ON t_planning_niveau.code_original = w_niv_uep.code_original + LEFT JOIN rh.t_divers VENTIL_JOUR ON VENTIL_JOUR.code = 'VENTIL_JOUR' + WHERE w_ventil_services.idstructure IS NULL + ; + + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + CASE WHEN COALESCE(VENTIL_JOUR.valeur::int,0) = 1 THEN date ELSE date_orig::date END, + to_char(w_cptres1.date, 'IYYYIW'::text)::numeric AS semaine, + to_char(w_cptres1.date, 'YYYYMM'::text)::numeric AS mois, + coalesce(w_entets.etablissement_id, 0) as etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) as niveau_id, + (temps_valide + temps_absence)*coef/coef_tot, + temps_du_initial*coef/coef_tot, + temps_valide*coef/coef_tot, + temps_absence*coef/coef_tot + FROM w_cptres1 + LEFT JOIN w_structure ON w_cptres1.iduep = w_structure.iduep + LEFT JOIN w_ventil_services ON w_structure.idstructure = w_ventil_services.idstructure + JOIN rh.t_planning_service ON t_planning_service.code_original = w_ventil_services.code_original + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = w_cptres1.idcompetence + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code_original = w_cptres1.abs_cod + LEFT JOIN w_entets ON w_entets.entets_code = 1 -- w_cptres1.entets_code + LEFT JOIN w_niv_uep ON w_cptres1.iduep = w_niv_uep.iduep + LEFT JOIN rh.t_planning_niveau ON t_planning_niveau.code_original = w_niv_uep.code_original + LEFT JOIN rh.t_divers VENTIL_JOUR ON VENTIL_JOUR.code = 'VENTIL_JOUR' + ; + + VACUUM ANALYSE rh.p_planning_mouvement + ; + + ]]> + + + + 1 THEN '_2' ELSE '' END as code_original, + uep_nom as texte, + (select oid from rh.t_classes where code = 'PLANIV3') as classe_id + FROM w_structure + JOIN rh.t_divers ON code ='AGILETIME_NIV2' + ; + + INSERT INTO rh.t_classes_sections(code, texte, classe_id) + SELECT code, texte, classe_id + from w_clasec_3 + where 1=1 + and classe_id = (select oid from rh.t_classes where code = 'PLANIV3') + and code not in (select code from rh.t_classes_sections where t_classes_sections.classe_id = w_clasec_3.classe_id and code is not null) + group by 1,2,3 + ; + + update rh.t_classes_sections set + texte = w_clasec_3.texte + FROM w_clasec_3 + WHERE true + and w_clasec_3.classe_id = t_classes_sections.classe_id + and w_clasec_3.code = t_classes_sections.code + and w_clasec_3.texte is distinct from t_classes_sections.texte + ; + + -- Mise à jour du contenu des sections Niveau 3. + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_planning_niveau.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join w_clasec_3 on true + and w_clasec_3.classe_id = t_classes.oid + and w_clasec_3.code = t_classes_sections.code + join rh.t_planning_niveau on split_part(t_planning_niveau.code_original, '|', 1)||'|'||split_part(t_planning_niveau.code_original, '|', 2)||'|'||split_part(t_planning_niveau.code_original, '|', 3) = w_clasec_3.code_original + WHERE t_classes.code = 'PLANIV3' + group by 1,2 + ; + + SELECT rh.cti_update_schema_classes('*ALL') + ; + + -- Recensement des oid utilisés. + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_service', service_id + FROM rh.p_planning_mouvement + WHERE service_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_service') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_qualification', qualification_id + FROM rh.p_planning_mouvement + WHERE qualification_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_qualification') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_niveau', niveau_id + FROM rh.p_planning_mouvement + WHERE niveau_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_niveau') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_type_absence', type_absence_id + FROM rh.p_planning_mouvement + WHERE type_absence_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_type_absence') + GROUP BY 1,2 + ; + + ]]> + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_CEGI.XML b/import_rh/iCTI_import_planning_CEGI.XML new file mode 100644 index 0000000..b03761b --- /dev/null +++ b/import_rh/iCTI_import_planning_CEGI.XML @@ -0,0 +1,1297 @@ + + + + + + 0 and typhsp_cumh = 0) OR (typhsp_spla = 1 AND TYPHSP_SCOR = 1 AND typhsp_cump =0 AND typhsp_cumh =0 ))) + OR (rub_id = 0) AS est_comptabilise, -- hors Ast non travaillée et heure non comptab en heures ou planning (dépendant de REU peut être réduit à la deuxième condition) + GNTYPHSP.* + FROM prod_cegi.gntyphsp + ORDER by typhsp_code + ; + + DROP TABLE IF EXISTS w_corct + ; + CREATE TEMP TABLE w_corct AS + SELECT 'AR' as code, -1.0 as signe, 0.0 as surcharge -- Arrivée en retard. + UNION ALL + SELECT 'AV' as code, 1.0 as signe, 0.0 as surcharge -- Arrivée en avance. + UNION ALL + SELECT 'AW' as code, 1.0 as signe, 0.0 as surcharge -- Astreinte travaillée. + UNION ALL + SELECT 'DA' as code, -1.0 as signe, 0.0 as surcharge -- Départ en avance. + UNION ALL + SELECT 'DR' as code, 1.0 as signe, 0.0 as surcharge -- Départ en retard. + UNION ALL + SELECT 'M1' as code, 1.0 as signe, 1.0 as surcharge -- Modification complète type 1. + UNION ALL + SELECT 'M2' as code, 1.0 as signe, 1.0 as surcharge -- Modification complète type 2. + UNION ALL + SELECT 'OAW' as code, 1.0 as signe, 0.0 as surcharge -- Astreinte travaillée. + ; + + DROP TABLE IF EXISTS w_structure + ; + CREATE TEMP TABLE w_structure AS + SELECT + GNEQP.site_id, + eqp_id, + planning_code, + CASE WHEN COALESCE(cegi_site_service.valeur,'0') = '0' THEN + site_code || '|' || COALESCE(GNTYPEQP.typeqp_code,'NR') || '|' || eqp_code + ELSE planning_code || '|' || site_code || '|' || eqp_code + END AS code, + MAX(CASE WHEN COALESCE(cegi_site_service.valeur,'0') = '0' THEN + site_lib || '|' || CASE WHEN typeqp_lib IS NOT NULL THEN ' - ' || COALESCE(typeqp_lib,' ') ELSE '' END || '-' || eqp_lib + ELSE t_etablissements.texte || '-' || site_lib || '|' || eqp_lib + END) AS texte + FROM + prod_cegi.GNEQP + LEFT JOIN prod_cegi.GNTYPEQP ON GNEQP.typeqp_code = GNTYPEQP.typeqp_code + LEFT JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'CEGI_SITE_SERVICE') AS cegi_site_service ON 1=1 + JOIN prod_cegi.GNSITE on GNSITE.site_id = GNEQP.site_id + JOIN rh.t_etablissements ON t_etablissements.planning_code = CASE WHEN COALESCE(cegi_site_service.valeur,'0') = '0' THEN site_code ELSE planning_code END + WHERE planning_code != '*' + GROUP BY 1,2,3,4 + ; + + DROP TABLE IF EXISTS w_gnpla + ; + CREATE TEMP TABLE w_gnpla AS + WITH planning_override AS ( + SELECT + per_id, + pla_date, + pla_ordre + FROM prod_cegi.GNPLADC + WHERE GNPLADC.pladc_ordre = 0 + GROUP BY 1,2,3 + ) + , ar_da as ( -- Calcul des temps en +/-. + SELECT + per_id, + pla_date, + pla_ordre, + sum(pladc_duree * signe) as pladc_duree + FROM prod_cegi.GNPLADC + join w_corct on w_corct.code = GNPLADC.corct_code + WHERE corct_code in ('AR', 'AV', 'DA', 'DR') + GROUP BY 1,2,3 + ) + SELECT + gnpla.pla_type, + gnpla.pla_date, + gnpla.pla_heud, + gnpla.pla_heuf, + gnpla.SER_CODE, + 0::numeric as pla_duree, + coalesce( + case when (CASE WHEN gnpla.pla_heuf > gnpla.pla_heud THEN (gnpla.pla_heuf - gnpla.pla_heud) ELSE ('1899-12-30 24:00:00' - gnpla.pla_heud) + (gnpla.pla_heuf - '1899-12-30 00:00:00') END) + + (coalesce(ar_da.pladc_duree, 0)::text || ' minutes')::interval < '6 hours'::interval + then 0.0 -- #HINT02 Les pauses ne doivent pas être décomptées lorsque le temps de travail est < 6h (légal). + else + case when coalesce(typhsp_plapause, ''::text) in (select unnest(string_to_array(replace(valeur, ' ', ''), ',')) from rh.t_divers where code = 'CEGI_PAUSE_EXCL') -- #HINT03 Les pauses payées ne doivent pas être décomptées du temps travaillées (ex : sandwitch mangé tout en restant à l'accueil le dimanche). + then 0.0 + else gnpla.pla_pause + end + end, + gnpla.pla_pause + ) as pla_pause, + gnpla.prs_code, + gnpla.typhsp_code, + --GNPLA.*, + salarie_id, + sal_matricule, + sal_matricule AS salarie_corr, + cnt_id, + COALESCE(est_absence,false) AS est_absence, + COALESCE(est_h_planif_sup,false) AS est_h_planif_sup, + COALESCE(est_h_planif_moins,false) AS est_h_planif_moins, + w_structure.planning_code, + w_structure.code, + w_structure.texte, + w_structure.code AS code_original + FROM prod_cegi.GNPLA + JOIN prod_cegi.PYSALARIE ON GNPLA.per_id = PYSALARIE.per_id + left JOIN planning_override ON 1=1 + AND planning_override.per_id = GNPLA.per_id + AND planning_override.pla_date = GNPLA.pla_date + AND planning_override.pla_ordre = GNPLA.pla_ordre + left JOIN ar_da ON 1=1 + AND ar_da.per_id = GNPLA.per_id + AND ar_da.pla_date = GNPLA.pla_date + AND ar_da.pla_ordre = GNPLA.pla_ordre + JOIN w_structure ON GNPLA.eqp_id = w_structure.eqp_id AND GNPLA.site_id = w_structure.site_id + LEFT JOIN w_gntyphsp ON GNPLA.typhsp_code = w_gntyphsp.typhsp_code + LEFT JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'CEGI_SITE_SERVICE') AS cegi_site_service ON 1=1 + JOIN w_sal_pla ON w_sal_pla.salarie_corr = sal_matricule AND etablissement_planning_code = planning_code + WHERE 1=1 + AND planning_override.per_id IS NULL + AND (1!=1 + OR pla_heuf < pla_heud + OR EXTRACT(epoch from (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval) > 60) -- les mouvements d'une minute sont destinés à la paoe + AND (1!=1 + OR est_comptabilise IS NULL + OR est_comptabilise) + ; + + DROP TABLE IF EXISTS w_gnpladc + ; + CREATE TEMP TABLE w_gnpladc AS + SELECT + pla_type, + gnpladc.pla_date, + case + when GNPLADC.corct_code = 'AW' then pla_heud -- #HINT01 Recalcul de la borne de fin lorsque motif Astreinte Travaillées (AW) car elle ne sont pas forcément renseignées ou mal (cas astreinte travaillée fragmentée) --> recalcul de la borne de fin à partir de la durée qui elle est juste. + else pladc_heudeb + end as pladc_heudeb, + case + when GNPLADC.corct_code = 'AW' then pla_heud + (pladc_duree::text || ' minutes')::interval -- cf. #HINT01. + else pladc_heufin + end as pladc_heufin, + pla_heud, + pla_heuf, + pladc_duree as pladc_duree, + gnpla.pla_pause AS pla_pause, + prs_code, + SER_CODE, + gnpladc.typhsp_code, + GNPLADC.corct_code, + salarie_id, + sal_matricule, + sal_matricule AS salarie_corr, + cnt_id, + COALESCE(est_absence, false) AS est_absence, + COALESCE(est_h_planif_sup_at,false) AS est_h_planif_sup_at, + CASE WHEN est_absence AND pladc_heudeb BETWEEN pla_heud AND pla_heuf THEN true ELSE false END AS est_h_planif_sup_absence, + w_structure.planning_code, + w_structure.code, + w_structure.texte, + w_structure.code AS code_original + FROM prod_cegi.GNPLADC + JOIN prod_cegi.GNPLA ON GNPLA.per_id = GNPLADC.per_id AND GNPLA.pla_date = GNPLADC.pla_date AND GNPLA.pla_ordre = GNPLADC.pla_ordre AND pla_type = 0 + JOIN prod_cegi.PYSALARIE ON GNPLA.per_id = PYSALARIE.per_id + JOIN w_structure ON GNPLA.eqp_id = w_structure.eqp_id AND GNPLA.site_id = w_structure.site_id + LEFT JOIN w_gntyphsp ON GNPLADC.typhsp_code = w_gntyphsp.typhsp_code + JOIN w_sal_pla ON w_sal_pla.salarie_corr = sal_matricule AND etablissement_planning_code = planning_code + WHERE + (est_comptabilise IS NULL OR est_comptabilise) + ; + + + + DROP SEQUENCE IF EXISTS w_cptres1_seq + ; + + CREATE TEMP SEQUENCE w_cptres1_seq + ; + + DROP TABLE IF EXISTS w_cptres1 + ; + -- heures travaillees = temps valide + CREATE TEMP TABLE w_cptres1 AS + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_gnpla.salarie_corr, + salarie_id, + cnt_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(pla_date) AS date, + date(pla_date) AS date_orig, + EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE (pla_heuf + interval '1 day' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 AS temps_orig, + prs_code, + code_original AS niveau_code_original, + code_original AS service_code_original, + planning_code AS entets_code, + SER_CODE::text, + typhsp_code AS type_horaire, + CASE WHEN est_absence AND NOT est_h_planif_sup THEN typhsp_code ELSE ''::text END AS abs_cod, + 0::numeric AS temps_du_initial, + CASE WHEN est_h_planif_sup THEN EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE ('1899-12-30 24:00:00' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 + WHEN est_h_planif_moins THEN -EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE ('1899-12-30 24:00:00' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 + ELSE 0:: numeric END AS temps_du, + CASE WHEN NOT est_absence THEN EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE ('1899-12-30 24:00:00' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 ELSE 0:: numeric END AS temps_valide, + CASE WHEN est_absence AND NOT est_h_planif_sup THEN EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE ('1899-12-30 24:00:00' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 ELSE 0:: numeric END AS temps_absence + FROM w_gnpla + WHERE 1=1 + AND pla_type = 0 -- effectué + AND EXTRACT(epoch FROM (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval) != 0 -- pour la paie + ORDER BY 2,7 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_gnpla.salarie_corr, + salarie_id, + cnt_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(pla_date) + interval '1 day' AS date, + date(pla_date) AS date_orig, + EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) ELSE (pla_heuf + interval '1 day' - pla_heud) END)/3600 AS temps_orig, + prs_code, + code_original AS niveau_code_original, + code_original AS service_code_original, + planning_code AS entets_code, + SER_CODE, + typhsp_code AS type_horaire, + CASE WHEN est_absence AND NOT est_h_planif_sup THEN typhsp_code ELSE ''::text END AS abs_cod, + 0 AS temps_du_initial, + CASE WHEN est_h_planif_sup THEN EXTRACT(epoch FROM (pla_heuf - '1899-12-30 00:00:00'))/3600 + WHEN est_h_planif_moins THEN -EXTRACT(epoch FROM (pla_heuf - '1899-12-30 00:00:00'))/3600 + ELSE 0::numeric END AS temps_du, + CASE WHEN NOT est_absence THEN EXTRACT(epoch FROM (pla_heuf - '1899-12-30 00:00:00'))/3600 ELSE 0::numeric END AS temps_valide, + CASE WHEN est_absence AND NOT est_h_planif_sup THEN EXTRACT(epoch FROM (pla_heuf - '1899-12-30 00:00:00'))/3600 ELSE 0::numeric END AS temps_absence + FROM w_gnpla + WHERE 1=1 + AND pla_type = 0 -- effectué + --AND NOT est_absence + --AND NOT est_h_planif_sup + AND (EXTRACT(epoch FROM (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval) < 0 OR pla_duree > 1440)-- journée dépassant les minuit + AND EXTRACT(epoch FROM (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval) != 0 -- pour la paie + ORDER BY 2,7 + ; + -- heures travaillees supplémentaires + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_gnpladc.salarie_corr, + salarie_id, + cnt_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(pla_date) AS date, + date(pla_date) AS date_orig, + SUM(CASE WHEN NOT est_absence THEN pladc_duree/60.0 ELSE -pladc_duree/60.0 END)AS temps_orig, + prs_code, + code_original AS niveau_code_original, + code_original AS service_code_original, + planning_code AS entets_code, + SER_CODE, + typhsp_code AS type_horaire, + ''::text AS abs_cod, + 0::numeric AS temps_du_initial, + SUM(CASE + WHEN est_h_planif_sup_at THEN -EXTRACT(epoch FROM CASE WHEN pladc_heufin > pladc_heudeb OR pladc_duree > 1440 THEN (pladc_heufin - pladc_heudeb) ELSE ('1899-12-30 24:00:00' - pladc_heudeb) END)/3600::numeric + WHEN est_h_planif_sup_absence THEN EXTRACT(epoch FROM CASE WHEN pladc_heufin > pladc_heudeb OR pladc_duree > 1440 THEN (pladc_heufin - pladc_heudeb) ELSE ('1899-12-30 24:00:00' - pladc_heudeb) END)/3600::numeric + ELSE 0::numeric + END * coalesce(w_corct.signe, 1.0)) AS temps_du, + SUM(CASE WHEN NOT est_absence + THEN EXTRACT(epoch FROM CASE WHEN pladc_heufin > pladc_heudeb OR pladc_duree > 1440 THEN (pladc_heufin - pladc_heudeb) ELSE ('1899-12-30 24:00:00' - pladc_heudeb) END)/3600 - ((pla_pause / 60.0) * coalesce(w_corct.surcharge, 0.0))-- Les pauses ne sont retirées qu'une fois sur le jour 1 lorsque code de modification M1/M2. + ELSE -EXTRACT(epoch FROM CASE WHEN pladc_heufin > pladc_heudeb OR pladc_duree > 1440 THEN (pladc_heufin - pladc_heudeb) ELSE ('1899-12-30 24:00:00' - pladc_heudeb) END)/3600 + END * coalesce(w_corct.signe, 1.0)) AS temps_valide, + 0::numeric AS temps_absence + FROM w_gnpladc + left join w_corct on w_corct.code = w_gnpladc.corct_code + WHERE 1=1 + GROUP BY 1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17 + ORDER BY 2,7 + ; + + -- Traitement du deuxième jour lorsqu'évènement salarié chevauchant 2 jours. + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_gnpladc.salarie_corr, + salarie_id, + cnt_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(pla_date) + interval '1 day' AS date, + date(pla_date) AS date_orig, + SUM(CASE WHEN est_absence THEN pladc_duree/60.0 ELSE -pladc_duree/60.0 END)AS temps_orig, + prs_code, + code_original AS niveau_code_original, + code_original AS service_code_original, + planning_code AS entets_code, + SER_CODE, + typhsp_code AS type_horaire, + ''::text AS abs_cod, + 0 AS temps_du_initial, + SUM( + CASE WHEN est_h_planif_sup_at THEN + -EXTRACT(epoch FROM (pladc_heufin - '1899-12-30 00:00:00'))/3600 + WHEN est_h_planif_sup_absence THEN + EXTRACT(epoch FROM (pladc_heufin - '1899-12-30 00:00:00'))/3600 + ELSE + 0 END + * coalesce(w_corct.signe, 1.0)) AS temps_du, + SUM(CASE WHEN NOT est_absence THEN + EXTRACT(epoch FROM (pladc_heufin - '1899-12-30 00:00:00'))/3600 + ELSE + -EXTRACT(epoch FROM (pladc_heufin - '1899-12-30 00:00:00'))/3600 + END * coalesce(w_corct.signe, 1.0)) AS temps_valide, + 0::numeric AS temps_absence + FROM w_gnpladc + left join w_corct on w_corct.code = w_gnpladc.corct_code + WHERE 1=1 + AND EXTRACT(epoch FROM (pladc_heufin - pladc_heudeb)) < 0 OR pladc_duree > 1440 -- journée dépassant les minuit + GROUP BY 1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17 + ORDER BY 2,7 + ; + + + -- heures planifiées + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_gnpla.salarie_corr, + salarie_id, + cnt_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(pla_date) AS date, + date(pla_date) AS date_orig, + EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE (pla_heuf + interval '1 day' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 AS temps_orig, + prs_code, + code_original AS niveau_code_original, + code_original AS service_code_original, + planning_code AS entets_code, + SER_CODE, + typhsp_code AS type_horaire, + ''::text AS abs_cod, + EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE ('1899-12-30 24:00:00' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + 0::numeric AS temps_absence + FROM w_gnpla + WHERE 1=1 + AND pla_type = 1 -- planifié prev + AND NOT est_absence + AND EXTRACT(epoch FROM (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval) != 0 -- pour la paie + ORDER BY 2,7 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_gnpla.salarie_corr, + salarie_id, + cnt_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(pla_date + interval '1 day') AS date, + date(pla_date) AS date_orig, + EXTRACT(epoch FROM CASE WHEN pla_heuf > pla_heud THEN (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval ELSE (pla_heuf + interval '1 day' - pla_heud) - (pla_pause::text || ' minutes')::interval END)/3600 AS temps_orig, + prs_code, + code_original AS niveau_code_original, + code_original AS service_code_original, + planning_code AS entets_code, + SER_CODE, + typhsp_code AS type_horaire, + ''::text AS abs_cod, + EXTRACT(epoch FROM (pla_heuf - '1899-12-30 00:00:00'))/3600 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + 0::numeric AS temps_absence + FROM w_gnpla + WHERE 1=1 + AND pla_type = 1 -- planifié prev + AND NOT est_absence + AND EXTRACT(epoch FROM (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval) < 0 -- journée dépassant les minuit + AND EXTRACT(epoch FROM (pla_heuf - pla_heud) - (pla_pause::text || ' minutes')::interval) != 0 -- pour la paie + ORDER BY 2,7 + ; + + -- Code d'absence paramétrés en heure + DROP TABLE IF EXISTS w_codes_absences_unite_heure + ; + + CREATE TEMP TABLE w_codes_absences_unite_heure AS + SELECT abspar_code + FROM prod_cegi.PYABSENCEPARAM + WHERE + ( + un_id IN (708, 709 ,710, 711) + OR un_id IN (SELECT UNNEST(STRING_TO_ARRAY(REPLACE(valeur, ' ', ''), ',')) FROM rh.t_divers WHERE code = 'CEGI_UNITE_HEURE') -- Absences paramétrées dans CTI comme étant exprimées en heures. + ) + AND abspar_code NOT IN (SELECT UNNEST(STRING_TO_ARRAY(REPLACE(valeur, ' ', ''), ',')) FROM rh.t_divers WHERE code = 'CEGI_PLANNING_ABSENCE_HEURE') + ORDER BY abspar_code + ; + + -- Modulation des présence avec les absences + -- Recencement des absences exprimées en jours et en heures. + DROP TABLE IF EXISTS w_abs_bul + ; + CREATE TEMP TABLE w_abs_bul AS + SELECT + pyabsence.per_id, + cnt_id, + sal_matricule, + detabs_deb as dphl_debabs, + detabs_fin as dphl_finabs, + sum(detabs_val) as dphl_valabs, + abspar_code as dphl_code, + abspar_libelle as dphl_lib, + un_id + FROM prod_cegi.PYABSENCE + JOIN prod_cegi.PYDETABSENCE ON PYABSENCE.abs_id = PYDETABSENCE.abs_id + JOIN prod_cegi.PYSALARIE ON PYABSENCE.per_id = PYSALARIE.per_id + JOIN prod_cegi.PYABSENCEPARAM ON PYABSENCEPARAM.abspar_id = PYABSENCE.abspar_id + WHERE 1=1 + AND CASE WHEN (select valeur = '1' from rh.t_divers where code = 'CEGI_ABS_VALIDE') THEN abs_valide = 1 ELSE true END + AND abspar_code not in (select unnest(string_to_array(replace(valeur, ' ', ''), ',')) from rh.t_divers where code = 'CEGI_ABS_EXCL') + AND detabs_val IS NOT NULL + GROUP BY 1,2,3,4,5,7,8,9 + ; + + -- CAS des absence en jours : on transvase l'intégralité du temps validé dans le temps d'absence et on met le temps validé à 0. + UPDATE w_cptres1 + SET + abs_cod = dphl_code, + temps_absence = temps_valide, + temps_valide = 0 + FROM + w_abs_bul + WHERE 1=1 + AND w_abs_bul.sal_matricule = salarie_corr + AND date_orig BETWEEN dphl_debabs AND dphl_finabs + AND dphl_code NOT IN (SELECT abspar_code FROM w_codes_absences_unite_heure) -- Hors absences exprimées en heures. + AND temps_valide != 0 + ; + + -- Table temporaire qui va permettre de décompter les heures d'absences étalées sur plusieurs jours. + DROP TABLE IF EXISTS w_abs_h + ; + CREATE TEMP TABLE w_abs_h AS + SELECT + w_cptres1.*, + dphl_code, + dphl_lib, + dphl_valabs, + SUM(temps_valide) OVER (PARTITION BY salarie_corr, w_abs_bul.cnt_id, dphl_debabs, dphl_code ORDER by date_orig, date, cptres1_id) as somme, + dphl_valabs + temps_valide - SUM(temps_valide) OVER (PARTITION BY salarie_corr, w_abs_bul.cnt_id, dphl_debabs, dphl_code ORDER by date_orig, date, cptres1_id) as restant + FROM w_abs_bul + JOIN w_cptres1 ON w_abs_bul.sal_matricule = salarie_corr and w_abs_bul.cnt_id = w_cptres1.cnt_id + AND date_orig BETWEEN dphl_debabs AND dphl_finabs + WHERE 1=1 + AND dphl_code IN (SELECT abspar_code FROM w_codes_absences_unite_heure) -- Hors absences exprimées en heures. + ; + + -- Absences en heures + UPDATE w_cptres1 SET + temps_valide = w_cptres1.temps_valide - LEAST(w_cptres1.temps_valide, restant) + FROM + (SELECT + salarie_corr, + cnt_id, + date_orig, + sum(restant) as restant + FROM + w_abs_h + WHERE restant > 0 -- a deplacer vers la creation + GROUP BY 1,2,3 + ) as w_abs_h_group + WHERE + w_cptres1.salarie_corr = w_abs_h_group.salarie_corr AND + w_cptres1.cnt_id = w_abs_h_group.cnt_id AND + w_cptres1.date_orig = w_abs_h_group.date_orig AND + --w_cptres1.date = w_abs_h.date AND + w_cptres1.temps_valide > 0 + ; + + --todo ajouter cas eventuel non present d'absences longue mais ne constituant pas un nombre de jours exactes + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + salarie_corr, + salarie_id, + cnt_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date, + date_orig, + 0 as temps_orig, + prs_code, + niveau_code_original, + service_code_original, + entets_code, + SER_CODE, + ''::text AS type_horaire, + dphl_code AS abs_cod, + 0 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + LEAST(temps_valide,restant) AS temps_absence --bug observé sur cette rubrique + FROM w_abs_h + WHERE + dphl_valabs != 0 + and restant > 0 + + ; + + + + + --correctif rrh et amith qui s'ils sont seuls prennet la valeur travaillée même si leur valeur d'absence ne couvre pas la journée + DROP TABLE IF EXISTS w_tot_absence; + CREATE TEMP TABLE w_tot_absence AS + SELECT + salarie_corr, + date_orig, + CASE + WHEN 'AMITH' = ANY(array_agg(abs_cod)) THEN 'AMITH' + WHEN 'RRH' = ANY(array_agg(abs_cod)) THEN 'RRH' + END AS code, + sum(temps_absence) as tot_absence + FROM w_cptres1 + GROUP BY salarie_corr,date_orig + HAVING array_agg(abs_cod) && ARRAY['RRH','AMITH'] + ; + + + UPDATE w_cptres1 + SET temps_absence = temps_valide, + temps_valide = 0, + abs_cod = code + FROM w_tot_absence + WHERE + w_cptres1.salarie_corr = w_tot_absence.salarie_corr + AND w_cptres1.date_orig = w_tot_absence.date_orig + AND temps_valide != 0 + ; + + -- Transformation de certains types horaires de temps validé en temps d'absence + UPDATE w_cptres1 + SET + abs_cod = type_horaire, + temps_absence = temps_valide, + temps_valide = 0 - temps_valide + WHERE + string_to_array((SELECT replace(valeur, ' ', '') FROM rh.t_divers WHERE code = 'CEGI_PLANNING_FORCE_TYPE_HORAIRE_ABSENCE'),',') <> '{}' AND + type_horaire = ANY (ARRAY(SELECT string_to_array((SELECT replace(valeur, ' ', '') FROM rh.t_divers WHERE code = 'CEGI_PLANNING_FORCE_TYPE_HORAIRE_ABSENCE'),','))) + ; + + -- Transfert du temps comptabilisé comme du temps_validé vers le temps_du + UPDATE w_cptres1 + SET + temps_du = temps_valide, + temps_valide = 0 + WHERE + string_to_array((SELECT replace(valeur, ' ', '') FROM rh.t_divers WHERE code = 'CEGI_PLANNING_TYPE_HORAIRE_TEMPS_VALIDE_VERS_TEMPS_DU'),',') <> '{}' + AND type_horaire = ANY (ARRAY(SELECT STRING_TO_ARRAY((SELECT replace(valeur, ' ', '') FROM rh.t_divers WHERE code = 'CEGI_PLANNING_TYPE_HORAIRE_TEMPS_VALIDE_VERS_TEMPS_DU'),','))) + ; + + VACUUM ANALYSE w_cptres1 + ; + + -- Association aux contrats et contrat_mois. + -- En général, les heures planning sont effectuées AVANT un contrat/paie à cause du décallage avec la paie : + -- => les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and w_cptres1.date between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + WHERE 1=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut > w_cptres1.date -- Sélection des contrats APRES heures planning. + WHERE 1=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut < w_cptres1.date -- Sélection des contrats AVANT heures planning. + WHERE 1=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + -- Création d'index. + CREATE INDEX w_cptres1_i_contrat_id ON w_cptres1 USING btree (contrat_id) + ; + CREATE INDEX w_cptres1_i_contrat_mois_id ON w_cptres1 USING btree (contrat_mois_id) + ; + CREATE INDEX w_cptres1_i_date ON w_cptres1 USING btree (date) + ; + CREATE INDEX w_cptres1_i_salarie_id ON w_cptres1 USING btree (salarie_id) + ; + + -- Alimentation des tables de paramètres. + -- Màj des Services du Planning. + INSERT INTO rh.t_planning_service(code_original, code, texte, texte_court, service_id) + SELECT + code_original, + code, + texte, + substr(texte,1,50), + 0 + FROM w_GNPLA + WHERE code_original NOT IN (SELECT code_original FROM rh.t_planning_service WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des Niveaux du Planning. + INSERT INTO rh.t_planning_niveau(code_original, code, texte, texte_court) + SELECT + code_original, + code, + texte, + substr(texte,1,50) + FROM w_GNPLA + WHERE code_original NOT IN (SELECT code_original FROM rh.t_planning_niveau WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des Qualifications du Planning. + INSERT INTO rh.t_planning_qualification(code_original, code, texte, texte_court) + SELECT + prs_code, + prs_code, + prs_lib, + prs_lib + FROM prod_cegi.GNPRS + WHERE 1=1 + AND prs_code IN (SELECT prs_code FROM w_cptres1) + AND prs_code NOT IN (SELECT code_original FROM rh.t_planning_qualification WHERE code_original IS NOT NULL) + ; + + -- Màj des Types d'absences du Planning. + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + abspar_id, + abspar_code, + abspar_libelle, + abspar_libelle + FROM prod_cegi.PYABSENCEPARAM + WHERE 1=1 + AND abspar_id NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + AND abspar_code IN (SELECT abs_cod FROM w_cptres1 GROUP BY 1) + AND abspar_code != '' + GROUP BY 1,2,3,4 + ; + + -- Conversion code absence selon PYABSENCEPARAM + UPDATE w_cptres1 + SET abs_cod = ABSPAR_ID + FROM prod_cegi.PYABSENCEPARAM + JOIN rh.t_planning_type_absence ON t_planning_type_absence.code_original = PYABSENCEPARAM.ABSPAR_ID + WHERE ABS_COD = ABSPAR_CODE AND + abs_cod <> '' + ; + + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + dphl_code, + dphl_code, + MAX(dphl_lib), + MAX(dphl_lib) + FROM prod_cegi.GNDPHL + WHERE 1=1 + AND dphl_code NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + AND dphl_code IN (SELECT abs_cod FROM w_cptres1 GROUP BY 1) + AND dphl_code != '' + GROUP BY 1,2 + ; + + -- Codes horaires + INSERT INTO rh.t_planning_code_horaire(code_original, code, texte, texte_court) + SELECT + SER_CODE, + SER_CODE, + SER_CODE, + SER_CODE + FROM w_cptres1 + WHERE 1=1 + AND SER_CODE NOT IN (SELECT code_original FROM rh.t_planning_code_horaire WHERE code_original IS NOT NULL) + GROUP BY 1 + ; + + -- Création d'une table Entreprise/Etablissement. + DROP TABLE IF EXISTS w_entets + ; + + CREATE TEMP TABLE w_entets AS + select + MIN(ets.oid) as etablissement_id, + ent.planning_code||ets.planning_code as entets_code + from rh.t_entreprises as ent + join rh.t_etablissements as ets on ets.entreprise_id = ent.oid + Where 1=1 + and ent.oid != 0 + and ets.oid != 0 + GROUP BY 2 + ; + + -- Alimentation de la table de mouvement. + SELECT base.cti_execute('TRUNCATE rh.p_planning_mouvement',1) + WHERE '[ENV_PLANNING_DATEDEBUT]' = '0001-01-01' AND + '[ENV_PLANNING_DATEFIN]' = '2099-12-31' + ; + DELETE FROM rh.p_planning_mouvement + WHERE date BETWEEN '[ENV_PLANNING_DATEDEBUT]'::date and '[ENV_PLANNING_DATEFIN]'::date + ; + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + code_horaire_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + CASE WHEN COALESCE(VENTIL_JOUR.valeur,'0') = '1' THEN date ELSE date_orig END, + to_char(CASE WHEN COALESCE(VENTIL_JOUR.valeur,'0') = '1' THEN date ELSE date_orig END, 'IYYYIW'::text)::numeric AS semaine, + to_char(CASE WHEN COALESCE(VENTIL_JOUR.valeur,'0') = '1' THEN date ELSE date_orig END, 'YYYYMM'::text)::numeric AS mois, + coalesce(w_entets.etablissement_id, 0) as etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) as niveau_id, + coalesce(t_planning_code_horaire.oid, 0) as code_horaire_id, + temps_valide + temps_absence + temps_du, + temps_du_initial, + temps_valide, + temps_absence + FROM w_cptres1 + LEFT JOIN rh.t_planning_niveau ON t_planning_niveau.code_original = w_cptres1.niveau_code_original + LEFT JOIN rh.t_planning_service ON t_planning_service.code_original = w_cptres1.service_code_original + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = w_cptres1.prs_code + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code_original = w_cptres1.abs_cod + LEFT JOIN rh.t_planning_code_horaire ON t_planning_code_horaire.code_original = w_cptres1.SER_CODE + LEFT JOIN w_entets ON w_entets.entets_code = w_cptres1.entets_code + LEFT JOIN rh.t_divers VENTIL_JOUR ON VENTIL_JOUR.code = 'VENTIL_JOUR' + where w_cptres1.date between '[ENV_PLANNING_DATEDEBUT]'::date and '[ENV_PLANNING_DATEFIN]'::date + ; + + VACUUM ANALYSE rh.p_planning_mouvement + ; + + ]]> + + + + 7h + -- Ramener à 7 + UPDATE rh.p_planning_mouvement SET + temps_du = CASE WHEN temps_du > 7 THEN 7 ELSE temps_du END, + temps_du_initial = CASE WHEN temps_du_initial > 7 THEN 7 ELSE temps_du_initial END, + temps_valide = CASE WHEN temps_valide > 7 THEN 7 ELSE temps_valide END, + temps_absence = CASE WHEN temps_absence > 7 THEN 7 ELSE temps_absence END + FROM rh.t_planning_code_horaire, + base.t_finess + where t_finess.code = '690793468' AND + code_horaire_id = t_planning_code_horaire.oid AND + t_planning_code_horaire.code = 'EN' AND + ( + temps_du > 7 OR + temps_du_initial > 7 OR + temps_valide > 7 OR + temps_absence > 7 + ) + ; + + -- Lorsqu'il n'y a pas de liaison entre les Qualifications Paie/Planning, + -- essayer de faire un rapprochement par le code ET le libellé. + UPDATE rh.t_planning_qualification SET + qualification_id = t_qualifications.oid + FROM rh.t_qualifications + WHERE 1=1 + AND t_qualifications.code = t_planning_qualification.code + AND t_planning_qualification.qualification_id = 0 + AND substr(t_planning_qualification.texte, 1, 10) = substr(t_qualifications.texte, 1, 10) + ; + + -- Report des Qualification Paie sur Qualification Planning. + UPDATE rh.t_planning_qualification SET + qualification_code = t_qualifications.code, + qualification_texte = t_qualifications.texte_court, + qualification_section_id = t_qualifications.section_id, + qualification_section_code = t_qualifications.section_code, + qualification_section_texte = t_qualifications.section_texte + FROM rh.t_qualifications + WHERE 1=1 + AND t_planning_qualification.qualification_id = t_qualifications.oid + AND (1!=1 + OR qualification_code IS DISTINCT FROM t_qualifications.code + OR qualification_texte IS DISTINCT FROM t_qualifications.texte_court + OR qualification_section_id IS DISTINCT FROM t_qualifications.section_id + OR qualification_section_code IS DISTINCT FROM t_qualifications.section_code + OR qualification_section_texte IS DISTINCT FROM t_qualifications.section_texte) + ; + + -- Report des Services Paie sur Services Planning. + UPDATE rh.t_planning_service SET + service_code = t_services.code, + service_texte = t_services.texte_court, + service_section_id = t_services.section_id, + service_section_code = t_services.section_code, + service_section_texte = t_services.section_texte + FROM rh.t_services + WHERE 1=1 + AND t_planning_service.service_id = t_services.oid + AND (1!=1 + OR service_code IS DISTINCT FROM t_services.code + OR service_texte IS DISTINCT FROM t_services.texte_court + OR service_section_id IS DISTINCT FROM t_services.section_id + OR service_section_code IS DISTINCT FROM t_services.section_code + OR service_section_texte IS DISTINCT FROM t_services.section_texte) + ; + + -- Création des 3 classes de niveaux. + DROP TABLE IF EXISTS w_classes + ; + + CREATE TEMP TABLE w_classes AS + with classe_table as ( + select 'PLANIV1' as code, '[DICT.RH.NIVEAU1#1]' as texte, 1 as sequence + UNION ALL + select 'PLANIV2' as code, '[DICT.RH.NIVEAU2#1]' as texte, 2 as sequence + UNION ALL + select 'PLANIV3' as code, '[DICT.RH.NIVEAU3#1]' as texte, 3 as sequence) + SELECT code, texte, table_id, 0 as is_cti, sequence + FROM classe_table, (select oid as table_id from rh.t_listes_tables where code = 'PNI' LIMIT 1) as subq + ; + + insert into rh.t_classes (code, texte, table_id, is_cti, sequence) + select code, texte, table_id, is_cti, sequence + FROM w_classes + where code NOT in (select code from rh.t_classes where code is not null) + ; + + update rh.t_classes set + texte = w_classes.texte + FROM w_classes + WHERE true + and w_classes.code = t_classes.code + and w_classes.texte is distinct from t_classes.texte + ; + + -- Nettoyage du contenu + delete from rh.t_classes_sections_elements + where section_id in ( + select s.oid from rh.t_classes as c + join rh.t_classes_sections as s on s.classe_id = c.oid + where c.code IN ('PLANIV1', 'PLANIV2', 'PLANIV3')) + ; + + -- Création des 3 classes de niveaux. + DROP TABLE IF EXISTS w_classes + ; + + CREATE TEMP TABLE w_classes AS + with classe_table as ( + select 'PLANIV1' as code, '[DICT.RH.NIVEAU1#1]' as texte, 1 as sequence + UNION ALL + select 'PLANIV2' as code, '[DICT.RH.NIVEAU2#1]' as texte, 2 as sequence + UNION ALL + select 'PLANIV3' as code, '[DICT.RH.NIVEAU3#1]' as texte, 3 as sequence) + SELECT code, texte, table_id, 0 as is_cti, sequence + FROM classe_table, (select oid as table_id from rh.t_listes_tables where code = 'PNI' LIMIT 1) as subq + ; + + insert into rh.t_classes (code, texte, table_id, is_cti, sequence) + select code, texte, table_id, is_cti, sequence + FROM w_classes + where code NOT in (select code from rh.t_classes where code is not null) + ; + + update rh.t_classes set + texte = w_classes.texte + FROM w_classes + WHERE true + and w_classes.code = t_classes.code + and w_classes.texte is distinct from t_classes.texte + ; + + -- Nettoyage du contenu + delete from rh.t_classes_sections_elements + where section_id in ( + select s.oid from rh.t_classes as c + join rh.t_classes_sections as s on s.classe_id = c.oid + where c.code IN ('PLANIV1', 'PLANIV2', 'PLANIV3')) + ; + + -- Mise à jour des sections Niveau 1. + DROP TABLE IF EXISTS w_clasec_1 + ; + + CREATE TEMP TABLE w_clasec_1 AS + SELECT + site_code as code, + site_lib as texte, + (select oid from rh.t_classes where code = 'PLANIV1') as classe_id + FROM prod_cegi.GNSITE + JOIN rh.t_divers ON t_divers.code = 'CEGI_SITE_SERVICE' AND t_divers.valeur = '0' + GROUP BY 1,2,3 + UNION ALL + SELECT + t_etablissements.planning_code as code, + t_etablissements.planning_code as texte, + (select oid from rh.t_classes where code = 'PLANIV1') as classe_id + FROM rh.t_etablissements + JOIN rh.t_divers ON t_divers.code = 'CEGI_SITE_SERVICE' AND t_divers.valeur = '1' + WHERE planning_code != '*' + GROUP BY 1,2,3 + ; + + INSERT INTO rh.t_classes_sections(code, texte, classe_id) + SELECT code, texte, classe_id + from w_clasec_1 + where 1=1 + and classe_id = (select oid from rh.t_classes where code = 'PLANIV1') + and code not in (select code from rh.t_classes_sections where t_classes_sections.classe_id = w_clasec_1.classe_id and code is not null) + group by 1,2,3 + ; + + UPDATE rh.t_classes_sections set + texte = w_clasec_1.texte + FROM w_clasec_1 + WHERE true + AND w_clasec_1.classe_id = t_classes_sections.classe_id + AND w_clasec_1.code = t_classes_sections.code + AND w_clasec_1.texte is distinct from t_classes_sections.texte + ; + + -- Mise à jour du contenu des sections Niveau 1. + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_planning_niveau.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join rh.t_planning_niveau on split_part(code_original, '|', 1) = t_classes_sections.code + WHERE t_classes.code = 'PLANIV1' + group by 1,2 + ; + + -- Mise à jour des sections Niveau 2. + DROP TABLE IF EXISTS w_clasec_2 + ; + + + SELECT base.cti_execute(' + CREATE TEMP TABLE w_clasec_2 AS + WITH nb_niv AS ( + SELECT + typeqp_code, count(DISTINCT typeqp_lib) as niv_count + FROM prod_cegi.GNTYPEQP + GROUP BY 1 + ) + SELECT + CASE WHEN niv_count = 1 THEN GNEQP.typeqp_code else site_code || ''|'' || GNEQP.typeqp_code END as code, + site_code || ''|'' || GNEQP.typeqp_code as code_original, + typeqp_lib as texte, + (select oid from rh.t_classes where code = ''PLANIV2'') as classe_id + from prod_cegi.GNEQP + JOIN prod_cegi.GNSITE ON GNEQP.site_id = GNSITE.site_id + LEFT JOIN prod_cegi.GNTYPEQP ON GNEQP.typeqp_code = GNTYPEQP.typeqp_code + JOIN nb_niv ON nb_niv.typeqp_code = GNTYPEQP.typeqp_code + group by 1,2,3 + UNION ALL + SELECT + site_code || ''|'' || ''NR'', + site_code || ''|'' || ''NR'', + ''Non renseigné'', + (select oid from rh.t_classes where code = ''PLANIV2'') as classe_id + FROM prod_cegi.GNSITE',1) + WHERE (SELECT code FROM rh.t_divers WHERE code = 'CEGI_SITE_SERVICE' and valeur = '0') IS NOT NULL; + ; + + SELECT base.cti_execute(' + CREATE TEMP TABLE w_clasec_2 AS + SELECT + planning_code || ''|'' || site_code as code, + planning_code || ''|'' || site_code as code_original, + site_lib as texte, + (select oid from rh.t_classes where code = ''PLANIV2'') as classe_id + FROM prod_cegi.GNSITE + JOIN rh.t_etablissements ON t_etablissements.planning_code != ''*'' + group by 1,2,3 + UNION ALL + SELECT + planning_code || ''|'' || ''NR'', + planning_code || ''|'' || ''NR'', + ''Non renseigné'', + (select oid from rh.t_classes where code = ''PLANIV2'') as classe_id + FROM rh.t_etablissements',1) + WHERE (SELECT code FROM rh.t_divers WHERE code = 'CEGI_SITE_SERVICE' and valeur = '1') IS NOT NULL; + ; + + INSERT INTO rh.t_classes_sections(code, texte, classe_id) + SELECT code, texte, classe_id + from w_clasec_2 + where 1=1 + and classe_id = (select oid from rh.t_classes where code = 'PLANIV2') + and code not in (select code from rh.t_classes_sections where t_classes_sections.classe_id = w_clasec_2.classe_id and code is not null) + group by 1,2,3 + ; + + update rh.t_classes_sections set + texte = w_clasec_2.texte + FROM w_clasec_2 + WHERE true + and w_clasec_2.classe_id = t_classes_sections.classe_id + and w_clasec_2.code = t_classes_sections.code + and w_clasec_2.texte is distinct from t_classes_sections.texte + ; + + -- Mise à jour du contenu des sections Niveau 2. + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_planning_niveau.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join w_clasec_2 on true + and w_clasec_2.classe_id = t_classes.oid + and w_clasec_2.code = t_classes_sections.code + join rh.t_planning_niveau on split_part(t_planning_niveau.code_original, '|', 1)||'|'||split_part(t_planning_niveau.code_original, '|', 2) = w_clasec_2.code_original + WHERE t_classes.code = 'PLANIV2' + group by 1,2 + ; + + -- Mise à jour des sections Niveau 3. + DROP TABLE IF EXISTS w_clasec_3 + ; + + SELECT base.cti_execute('CREATE TEMP TABLE w_clasec_3 AS + with nb_niv as ( + select + eqp_code, count(DISTINCT eqp_lib) as niv_count + from prod_cegi.GNEQP + group by 1 + ) + SELECT + CASE WHEN niv_count = 1 THEN GNEQP.eqp_code ELSE site_code || ''|'' || COALESCE(GNTYPEQP.typeqp_code,''NR'') || ''|'' || GNEQP.eqp_code END as code, + site_code || ''|'' || COALESCE(GNTYPEQP.typeqp_code,''NR'') || ''|'' || GNEQP.eqp_code as code_original, + eqp_lib as texte, + (select oid from rh.t_classes where code = ''PLANIV3'') as classe_id + FROM prod_cegi.GNSITE + JOIN prod_cegi.GNEQP ON GNSITE.site_id = GNEQP.site_id + LEFT JOIN prod_cegi.GNTYPEQP ON GNEQP.typeqp_code = GNTYPEQP.typeqp_code + JOIN nb_niv ON nb_niv.eqp_code = GNEQP.eqp_code + group by 1,2,3',1) + WHERE (SELECT code FROM rh.t_divers WHERE code = 'CEGI_SITE_SERVICE' and valeur = '0') IS NOT NULL; + ; + + SELECT base.cti_execute('CREATE TEMP TABLE w_clasec_3 AS + SELECT + planning_code || ''|'' || site_code || ''|'' || GNEQP.eqp_code as code, + planning_code || ''|'' || site_code || ''|'' || GNEQP.eqp_code as code_original, + eqp_lib as texte, + (select oid from rh.t_classes where code = ''PLANIV3'') as classe_id + FROM prod_cegi.GNSITE + JOIN prod_cegi.GNEQP ON GNSITE.site_id = GNEQP.site_id + JOIN rh.t_etablissements ON t_etablissements.planning_code != ''*'' + group by 1,2,3',1) + WHERE (SELECT code FROM rh.t_divers WHERE code = 'CEGI_SITE_SERVICE' and valeur = '1') IS NOT NULL; + ; + + INSERT INTO rh.t_classes_sections(code, texte, classe_id) + SELECT code, texte, classe_id + from w_clasec_3 + where 1=1 + and classe_id = (select oid from rh.t_classes where code = 'PLANIV3') + and code not in (select code from rh.t_classes_sections where t_classes_sections.classe_id = w_clasec_3.classe_id and code is not null) + group by 1,2,3 + ; + + update rh.t_classes_sections set + texte = w_clasec_3.texte + FROM w_clasec_3 + WHERE true + and w_clasec_3.classe_id = t_classes_sections.classe_id + and w_clasec_3.code = t_classes_sections.code + and w_clasec_3.texte is distinct from t_classes_sections.texte + ; + + -- Mise à jour du contenu des sections Niveau 3. + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_planning_niveau.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join w_clasec_3 on true + and w_clasec_3.classe_id = t_classes.oid + and w_clasec_3.code = t_classes_sections.code + join rh.t_planning_niveau on t_planning_niveau.code_original = w_clasec_3.code_original + WHERE t_classes.code = 'PLANIV3' + group by 1,2 + ; + + SELECT rh.cti_update_schema_classes('*ALL') + ; + + -- Poles + SELECT rh.cti_reorganize_pole() + ; + + -- Recensement des oid utilisés. + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_service', service_id + FROM rh.p_planning_mouvement + WHERE service_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_service') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_qualification', qualification_id + FROM rh.p_planning_mouvement + WHERE qualification_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_qualification') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_niveau', niveau_id + FROM rh.p_planning_mouvement + WHERE niveau_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_niveau') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_type_absence', type_absence_id + FROM rh.p_planning_mouvement + WHERE type_absence_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_type_absence') + GROUP BY 1,2 + ; + + ]]> + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_CONSOLIDATION.XML b/import_rh/iCTI_import_planning_CONSOLIDATION.XML new file mode 100644 index 0000000..351b982 --- /dev/null +++ b/import_rh/iCTI_import_planning_CONSOLIDATION.XML @@ -0,0 +1,553 @@ + + + + + + + + t_planning_code_horaire_source.code OR + t_planning_code_horaire.texte <> t_planning_code_horaire_source.texte OR + t_planning_code_horaire.texte_court <> t_planning_code_horaire_source.texte_court + ) + + ]]> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_ECONNECTION.XML b/import_rh/iCTI_import_planning_ECONNECTION.XML new file mode 100644 index 0000000..f72dcfd --- /dev/null +++ b/import_rh/iCTI_import_planning_ECONNECTION.XML @@ -0,0 +1,700 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_planning + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_planning.salarie_id + and w_planning.date between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + where 1!=1 + OR w_planning.contrat_id is null + OR w_planning.contrat_mois_id is null + group by 1) + UPDATE w_planning SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_planning.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_planning + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_planning.salarie_id + and p_contrats_mois.date_debut > w_planning.date -- Sélection des contrats APRES heures planning. + where 1!=1 + OR w_planning.contrat_id is null + OR w_planning.contrat_mois_id is null + group by 1) + UPDATE w_planning SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_planning.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_planning + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_planning.salarie_id + and p_contrats_mois.date_debut < w_planning.date -- Sélection des contrats AVANT heures planning. + where 1!=1 + OR w_planning.contrat_id is null + OR w_planning.contrat_mois_id is null + group by 1) + UPDATE w_planning SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_planning.cptres1_id = w_asso.cptres1_id + ; + + -- Création d'index. + CREATE INDEX w_planning_i_contrat_id ON w_planning USING btree (contrat_id) + ; + CREATE INDEX w_planning_i_contrat_mois_id ON w_planning USING btree (contrat_mois_id) + ; + CREATE INDEX w_planning_i_date ON w_planning USING btree (date) + ; + CREATE INDEX w_planning_i_salarie_id ON w_planning USING btree (salarie_id) + ; + + ]]> + + + + + + + + + + + + + + + + 1 AND temps_du_initial > 0 + THEN temps_du_initial / array_length(absences_codes, 1) + ELSE temps_du_initial + END AS temps_du_initial_final, + CASE + WHEN array_length(absences_codes, 1) > 1 AND temps_du > 0 + THEN temps_du / array_length(absences_codes, 1) + ELSE temps_du + END AS temps_du_final, + CASE + WHEN array_length(absences_codes, 1) > 1 AND temps_valide > 0 + THEN temps_valide / array_length(absences_codes, 1) + ELSE temps_valide + END AS temps_valide_final, + temps_absence AS temps_absence_final, + temps_presence AS temps_presence_final + FROM unnested + ; + + -- Alimentation de la table de mouvement. + TRUNCATE rh.p_planning_mouvement + ; + + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + code_horaire_id, + temps_du_initial, + temps_du, + temps_du_ajuste, + temps_valide, + temps_valide_ajuste, + temps_presence, + temps_presence_ajuste, + temps_absence, + temps_absence_ajuste) + SELECT + w_planning_et_absences.salarie_id, + w_planning_et_absences.contrat_id, + w_planning_et_absences.contrat_mois_id, + w_planning_et_absences.date, + w_planning_et_absences.semaine, + w_planning_et_absences.mois, + coalesce(w_entets.etablissement_id, 0) AS etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) AS niveau_id, + coalesce(t_planning_code_horaire.oid, 0) AS code_horaire_id, + ROUND(w_planning_et_absences.temps_du_initial_final / 60, 4) AS temps_du_initial, + ROUND(w_planning_et_absences.temps_du_final / 60, 4) AS temps_du, + ROUND(w_planning_et_absences.temps_du_final / 60, 4) AS temps_du_ajuste, + ROUND(w_planning_et_absences.temps_valide_final / 60, 4) AS temps_valide, + ROUND(w_planning_et_absences.temps_valide_final / 60, 4) AS temps_valide_ajuste, + ROUND(w_planning_et_absences.temps_presence_final / 60, 4) AS temps_presence, + ROUND(w_planning_et_absences.temps_presence_final / 60, 4) AS temps_presence_ajuste, + ROUND(w_planning_et_absences.temps_absence_final / 60, 4) AS temps_absence, + ROUND(w_planning_et_absences.temps_absence_final / 60, 4) AS temps_absence_ajuste + FROM w_planning_et_absences + JOIN rh.p_salaries ON p_salaries.oid = w_planning_et_absences.salarie_id + JOIN w_entets ON w_entets.entreprise_id = p_salaries.entreprise_id + LEFT JOIN rh.t_planning_niveau ON t_planning_niveau.code_original = w_planning_et_absences.niveau_code--_original + LEFT JOIN rh.t_planning_service ON t_planning_service.code_original = w_planning_et_absences.service_code--_original + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = w_planning_et_absences.qualification_code + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code_original = w_planning_et_absences.absence_code + LEFT JOIN rh.t_planning_code_horaire ON t_planning_code_horaire.code_original = w_planning_et_absences.horaire_code + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 + ; + + VACUUM ANALYSE rh.p_planning_mouvement + ; + + ]]> + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_EXPERT_SANTE.XML b/import_rh/iCTI_import_planning_EXPERT_SANTE.XML new file mode 100644 index 0000000..1f9f134 --- /dev/null +++ b/import_rh/iCTI_import_planning_EXPERT_SANTE.XML @@ -0,0 +1,951 @@ + + + + + w_cycle.id + order by overlap.utilisateur_id, overlap.date_debut + ; + -- maj fin de période si overlap + UPDATE w_cycle + SET + date_fin_cor = sub.date_debut - '1 day'::interval + FROM (SELECT cycle_ref, min(date_debut) AS date_debut FROM w_cycle_overlap GROUP BY 1) sub + WHERE cycle_ref = id + ; + + INSERT INTO w_cycle + SELECT + w_cycle.id, + w_cycle.utilisateur_id, + w_cycle.poste_id, + w_cycle_overlap.date_fin_cor + interval '1 day', + w_cycle.date_fin, + COALESCE(LEAD(w_cycle_overlap.date_debut) OVER (PARTITION BY cycle_ref ORDER BY w_cycle_overlap.date_debut, w_cycle_overlap.id) - interval '1 day',w_cycle.date_fin), + w_cycle.cycle_id_remplacant, + w_cycle.rh_salarie_societe_id, + w_cycle.commentaire_arret + FROM w_cycle + join w_cycle_overlap on cycle_ref = w_cycle.id order by w_cycle.utilisateur_id ,w_cycle.date_debut, w_cycle_overlap.id; + + DELETE FROM w_cycle where date_fin_cor < date_debut; + CREATE INDEX w_cycle_i ON w_cycle USING btree (id); + CREATE INDEX w_cycle_i2 ON w_cycle USING btree (poste_id); + + --maj des matricule planning si non renseignés + UPDATE rh.p_salaries + SET matricule_planning = matricule + WHERE matricule_planning = '' + ; + + -- insertion des matricule non présents ou présent sans la bonne personne + INSERT INTO rh.p_salaries( + finess, + nom, + prenom, + sexe, + matricule, + matricule_planning, + code, + code_original, + entreprise_id + ) + SELECT + 'Planning' AS finess, + base.cti_soundex_nom((MAX(ARRAY[utilisateur.id::text, utilisateur.nom::text]))[2]), + base.cti_soundex_prenom((MAX(ARRAY[utilisateur.id::text, utilisateur.prenom::text]))[2]), + CASE WHEN (MAX(ARRAY[utilisateur.id, genre]))[2] NOT IN (1,4) THEN 'F' ELSE 'M' END, + 'PLA_' || utilisateur.matricule, + utilisateur.matricule AS matricule_planning, + 'PLA_' || utilisateur.matricule, + 'PLA_' || utilisateur.matricule, + COALESCE(sub.entreprise_id,0) + FROM prod_expert_sante.utilisateur + LEFT JOIN (SELECT entreprise_id FROM rh.t_etablissements JOIN rh.t_divers ON t_divers.code = 'EXPERT_SOCIETE_DEFAULT' AND valeur = planning_code) sub ON 1=1 + LEFT JOIN rh.p_salaries ON p_salaries.matricule_planning = utilisateur.matricule + WHERE utilisateur.matricule != '' + AND utilisateur.id IN (SELECT utilisateur_id FROM w_cycle) + AND 'PLA_' || utilisateur.matricule NOT IN (SELECT code_original FROM rh.p_salaries) + GROUP BY 5,6,7,8,9 + HAVING MAX(p_salaries.oid) IS NULL OR ( + base.cti_soundex_nom((MAX(ARRAY[utilisateur.id::text, utilisateur.nom::text]))[2]) != base.cti_soundex_nom(upper(MAX(p_salaries.nom))) AND + base.cti_soundex_prenom((MAX(ARRAY[utilisateur.id::text, utilisateur.prenom::text]))[2]) != base.cti_soundex_prenom(upper(MAX(p_salaries.prenom))) + ) + ORDER BY 5; + + -- maj des anciens matricule planning plus utilisés (matricule sans PLA) + UPDATE rh.p_salaries + SET matricule_planning = 'OLD_' || p_salaries.matricule_planning + FROM ( + SELECT matricule_planning, MAX(CASE WHEN matricule NOT LIKE 'PLA_%' THEN oid ELSE 0 END) as salarie_id + FROM rh.p_salaries + GROUP BY 1 HAVING count(*) > 1 + ) sub + WHERE oid = salarie_id + AND p_salaries.matricule_planning NOT LIKE 'OLD_%' + ; + + -- Màj des Etablissements + -- UPDATE rh.t_etablissements + -- SET planning_code = code + -- ; + + -- /!\ planning_code est à paramétrer dans la table listant les établissements. + + -- Recensement des salariés et établissements. + DROP TABLE IF EXISTS w_sal_pla + ; + CREATE TEMP TABLE w_sal_pla AS + SELECT + p_salaries.oid AS salarie_id, + p_salaries.matricule_planning AS matricule, + t_entreprises.code_original AS entreprise_code_original, + t_etablissements.code_original AS etablissement_code_original, + t_entreprises.code AS entreprise_code, + t_entreprises.planning_code AS entreprise_planning_code, + t_etablissements.code AS etablissement_code, + t_etablissements.planning_code as etablissement_planning_code, -- Pour cas 3 Sage + lpad(t_entreprises.code, 3, '0') || lpad(t_etablissements.code, 3, '0') || p_salaries.matricule AS matricule_planning, -- Pour cas 2 SHS + lpad(t_entreprises.planning_code, 3, '0') || lpad(t_etablissements.planning_code, 3, '0') || substr(p_salaries.matricule, 1, 5) AS matricule_planning_conso, -- Pour cas 5 SHS consolidé + ltrim(p_salaries.matricule, '0') AS matricule_trim, -- Pour cas 1 Cegid + ''::text AS salarie_corr + FROM rh.p_salaries + -- Il faut absoluement faire le produit cartésien matricule/établissement même si un salarié n'a jamais travaillé dans un des établissement. + -- En effet, ce traitement pourrait ne pas remonter les données associées. + JOIN rh.t_entreprises ON t_entreprises.oid = p_salaries.entreprise_id + JOIN rh.t_etablissements ON t_etablissements.entreprise_id = p_salaries.entreprise_id AND t_etablissements.planning_code != '' + WHERE 1=1 + AND salarie_fusionne_id = 0 + -- Uniquement les établissements avec planning_code renseigné dans le cas où l'établissement est en mode manuel. + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12 + ORDER BY 1,2,3 + ; + + -- Gestion des salariés fusionnés. + INSERT INTO w_sal_pla + SELECT + w_sal_pla.salarie_id, + p_salaries.matricule, + w_sal_pla.entreprise_code_original, + w_sal_pla.etablissement_code_original, + w_sal_pla.entreprise_code, + w_sal_pla.entreprise_planning_code, + w_sal_pla.etablissement_code, + w_sal_pla.etablissement_planning_code, + lpad(w_sal_pla.entreprise_code, 3, '0') || lpad(w_sal_pla.etablissement_code, 3, '0') || p_salaries.matricule AS matricule_planning, + lpad(w_sal_pla.entreprise_planning_code, 3, '0') || lpad(w_sal_pla.etablissement_planning_code, 3, '0') || substr(p_salaries.matricule, 1, 5) AS matricule_planning_conso, + ltrim(p_salaries.matricule, '0') AS matricule_trim, + ''::text AS salarie_corr + FROM w_sal_pla + JOIN rh.p_salaries ON salarie_fusionne_id = w_sal_pla.salarie_id + WHERE salarie_fusionne_id != 0 + ; + + -- INSERT INTO rh.p_salaries (code, code_original, nom) + -- lorsque nom ne correspond pas, changer le matricule + --UPDATE w_sal_pla SET + -- matricule_planning = etablissement_code_original || matricule + --WHERE etablissement_code LIKE '%-%' + ; + + -- Alimenter le champ w_sal_pla.salarie_corr. + UPDATE w_sal_pla SET + salarie_corr = matricule + ; + + -- Création d'index. + CREATE INDEX w_sal_pla_i_matricule ON w_sal_pla USING btree (matricule) + ; + CREATE INDEX w_sal_pla_i_matricule_planning ON w_sal_pla USING btree (matricule_planning) + ; + CREATE INDEX w_sal_pla_i_matricule_trim ON w_sal_pla USING btree (matricule_trim) + ; + + DROP TABLE IF EXISTS w_plan_base; + CREATE TEMP TABLE w_plan_base AS + SELECT + w_cycle.id, + COALESCE(NULLIF(salarie_societe.matricule,''),utilisateur.matricule) as matricule, + rh_societe_id, + w_cycle.utilisateur_id, + w_cycle.date_debut, + w_cycle.date_fin, + commentaire_arret, + courant.date, + courant.date as date_orig, + poste_id, + profession_rh_id, + etage_id, + rh_salarie_societe_id, + type_poste.code, + CASE WHEN heure_debut != '' THEN left(heure_debut,2)::numeric + right(heure_debut,2)::numeric / 60 ELSE 0 END AS heure_debut, + CASE WHEN heure_fin != '' THEN left(heure_fin,2)::numeric + right(heure_fin,2)::numeric / 60 ELSE 0 END AS heure_fin, + left(temps_travail,2)::numeric + right(temps_travail,2)::numeric / 60 as temps_travail, + temps_pause, + impacte_compteur_nuit, + impacte_compteur_heures_ferie, + impacte_totaux_planning, + roulement.renfort as roulement_renfort, + poste.renfort as poste_renfort, + cycle_id_remplacant, + type_poste.id AS type_poste_id, + rank() OVER (PARTITION BY w_cycle.utilisateur_id, courant.date ORDER BY w_cycle.id) as rank, + last_value(w_cycle.id) OVER (PARTITION BY w_cycle.utilisateur_id, courant.date) as last + FROM w_cycle + JOIN prod_expert_sante.utilisateur ON utilisateur_id = utilisateur.id + left join prod_expert_sante.salarie_societe on rh_salarie_societe_id = salarie_societe.id + join base.p_calendrier courant on courant.date between date_debut AND COALESCE(date_fin_cor, now()) + join prod_expert_sante.poste on poste_id = poste.id + join base.p_calendrier debut on debut.date = poste.date_debut + join base.v_calendrier_indicateurs_1 ON courant.date = v_calendrier_indicateurs_1.date + join prod_expert_sante.roulement on roulement_id = roulement.id + join prod_expert_sante.modele_roulement on poste.roulement_id = modele_roulement.roulement_id + AND num_jour = courant.jour_semaine + AND num_semaine = 1 + (debut_semaine - 1 + courant.iso_semaine - debut.iso_semaine + 52 * (date_part('year',courant.date)::numeric - date_part('year', debut.date)::numeric))%nb_semaines + left join prod_expert_sante.type_poste on (type_poste.id = modele_roulement.type_poste_id and (nb_jour_ouvre = 1 or type_poste_jf = 0)) or (nb_jour_ouvre = 0 AND type_poste_jf != 0 AND type_poste_jf = type_poste.id) + WHERE courant.date > '[ENV_PLANNING_DATEDEBUT]' + ; + + CREATE INDEX w_plan_base_mat ON w_plan_base USING btree (matricule); + + -- croisement avec les contrats et les personnes + + DROP SEQUENCE IF EXISTS w_cptres1_seq + ; + + CREATE TEMP SEQUENCE w_cptres1_seq + ; + + DROP TABLE IF EXISTS w_cptres1 + ; + -- temps travail = temps du initial + CREATE TEMP TABLE w_cptres1 AS + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_plan_base.utilisateur_id, + w_plan_base.matricule, + salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date, + date_orig, + temps_travail AS temps_orig, + profession_rh_id, + etage_id, + rh_societe_id, + ''::text AS motif_absence_id, + temps_travail::numeric AS temps_du_initial, + 0::numeric AS temps_du, + 0::numeric AS temps_valide, + 0::numeric AS temps_absence, + type_poste_id + FROM w_plan_base + LEFT JOIN prod_expert_sante.absence_salarie ON w_plan_base.id = absence_salarie.cycle_id AND date_orig BETWEEN absence_salarie.date_debut AND absence_salarie.date_fin + LEFT JOIN prod_expert_sante.motif_absence ON motif_absence.id = motif_absence_id + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_base.matricule + WHERE 1=1 + AND COALESCE(absence_non_reelle,0) != 1 + AND w_plan_base.id = last + ORDER BY 2,7 + ; + + + + -- absences (note dans table pas d'heure de debut ni de fin) + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_plan_base.utilisateur_id, + w_plan_base.matricule, + salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date, + date_orig, + temps_travail AS temps_orig, + profession_rh_id, + etage_id, + rh_societe_id, + motif_absence_id, + 0 AS temps_du_initial, + CASE WHEN absence_non_reelle = 0 THEN temps_travail ELSE 0 END AS temps_du, + 0 AS temps_valide, + CASE WHEN absence_non_reelle = 0 THEN temps_travail ELSE 0 END AS temps_absence, + type_poste_id + FROM w_plan_base + JOIN prod_expert_sante.absence_salarie ON w_plan_base.id = absence_salarie.cycle_id AND date_orig BETWEEN absence_salarie.date_debut AND absence_salarie.date_fin + JOIN prod_expert_sante.motif_absence ON motif_absence.id = motif_absence_id + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_base.matricule + WHERE 1=1 AND + validee = 1 + ORDER BY 2,7 + ; + + -- pas d'absence => valide sur dernier cycle prevu + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + w_plan_base.utilisateur_id, + w_plan_base.matricule, + salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date, + date_orig, + temps_travail AS temps_orig, + profession_rh_id, + etage_id, + rh_societe_id, + motif_absence_id, + 0 AS temps_du_initial, + temps_travail AS temps_du, + temps_travail AS temps_valide, + 0 AS temps_absence, + type_poste_id + FROM w_plan_base + LEFT JOIN prod_expert_sante.absence_salarie ON w_plan_base.id = absence_salarie.cycle_id AND date_orig BETWEEN absence_salarie.date_debut AND absence_salarie.date_fin + JOIN w_sal_pla ON w_sal_pla.matricule = w_plan_base.matricule + WHERE 1=1 + AND absence_salarie.id IS NULL + AND w_plan_base.id = last + --AND validee = 1 + ORDER BY 2,7 + ; + + + + -- heures supplémentaires - comment utiliser type_heure_supplemntaire_id ? + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + heure_supplementaire.utilisateur_id, + utilisateur.matricule, + salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + jour, + jour AS date_orig, + 0 AS temps_orig, + profession_rh_id, + etage_id, + null, + -1, + 0 AS temps_du_initial, + CASE WHEN sens = '+' then 1 ELSE -1 END * (left(heure,2)::numeric + right(heure,2)::numeric / 60) AS temps_du, + CASE WHEN sens = '+' then 1 ELSE -1 END * (left(heure,2)::numeric + right(heure,2)::numeric / 60) AS temps_valide, + 0 AS temps_absence, + 0 as type_poste_id + FROM prod_expert_sante.heure_supplementaire + --LEFT JOIN prod_expert_sante.salarie_societe_dis on heure_supplementaire.utilisateur_id = salarie_societe_dis.utilisateur_id AND visible = 1 + JOIN prod_expert_sante.utilisateur ON heure_supplementaire.utilisateur_id = utilisateur.id + JOIN prod_expert_sante.poste ON poste_id = poste.id + JOIN w_sal_pla ON w_sal_pla.matricule = utilisateur.matricule + LEFt JOIN rh.t_divers ON code = 'EXPERT_SOCIETE_DEFAULT' + WHERE jour > '[ENV_PLANNING_DATEDEBUT]' + --AND payable = 1 + ; + + + /* UPDATE w_cptres1 + SET rh_societe_id = salarie_societe_dis.rh_societe_id + FROM prod_expert_sante.salarie_societe_dis + WHERE salarie_societe_dis.utilisateur_id = w_cptres1.utilisateur_id + AND w_cptres1.rh_societe_id IS NULL + ;*/ + + SELECT base.cti_execute('INSERT INTO rh.t_divers (code, valeur, description) + VALUES + (''EXPERT_SOCIETE_DEFAULT'',''0'',''id societe expert à affecter aux salaries par defaut'')',1) + WHERE (SELECT count(*) FROM rh.t_divers WHERE code = 'EXPERT_SOCIETE_DEFAULT') = 0 + ; + + UPDATE w_cptres1 + SET rh_societe_id = valeur::int + FROM rh.t_divers + WHERE t_divers.code = 'EXPERT_SOCIETE_DEFAULT' + AND rh_societe_id IS NULL + ; + + + DELETE FROM w_cptres1 WHERE temps_du_initial = 0 AND temps_valide = 0 AND temps_absence = 0 AND temps_du = 0; + CREATE INDEX w_cptres1_i_date ON w_cptres1 USING btree (date_orig) + ; + CREATE INDEX w_cptres1_i_salarie_id ON w_cptres1 USING btree (salarie_id) + ; + + VACUUM ANALYSE w_cptres1 + ; + + + + -- Association aux contrats et contrat_mois. + -- En général, les heures planning sont effectuées AVANT un contrat/paie à cause du décallage avec la paie : + -- => les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and w_cptres1.date_orig between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + WHERE 1!=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut > w_cptres1.date_orig -- Sélection des contrats APRES heures planning. + WHERE 1!=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + AND w_cptres1.contrat_mois_id is null + + ; +/* + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut < w_cptres1.date_orig -- Sélection des contrats AVANT heures planning. + WHERE 1!=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + AND w_cptres1.contrat_mois_id is null + ; +*/ + -- Création d'index. + CREATE INDEX w_cptres1_i_contrat_id ON w_cptres1 USING btree (contrat_id) + ; + CREATE INDEX w_cptres1_i_contrat_mois_id ON w_cptres1 USING btree (contrat_mois_id) + ; + + + -- Alimentation des tables de paramètres. + + + + -- Màj des Services du Planning. + INSERT INTO rh.t_planning_service(code_original, code, texte, texte_court, service_id) + WITH services AS ( + SELECT + id, + id::text as code, + nom, + etage_id + FROM prod_expert_sante.service + WHERE id != 0 + GROUP BY 1,2,3,4 + UNION ALL + SELECT + '0' AS id, + 'NR' AS code, + 'Non renseigné' as texte, + null as etage_id + ) + SELECT id , id, nom, LEFT(nom,50), (select oid from rh.t_classes where code = 'PLANIV3') as classe_id + FROM services + WHERE id NOT IN (SELECT code_original FROM rh.t_planning_service WHERE code_original IS NOT NULL) + AND (etage_id IN (SELECT etage_id FROM w_cptres1 GROUP BY 1) OR etage_id IS NULL) + GROUP BY 1,2,3,4 + ; + + + INSERT INTO rh.t_planning_niveau(code_original, code, texte, texte_court) + SELECT + code_original, + code, + texte, + left(texte,50) + FROM w_structure + WHERE code_original NOT IN (SELECT code_original FROM rh.t_planning_niveau WHERE code_original IS NOT NULL) + AND split_part(code_original,'|',3) IN (SELECT etage_id FROM w_cptres1 GROUP BY 1) + ; + + -- Màj des Qualifications du Planning. (competence) + INSERT INTO rh.t_planning_qualification(code_original, code, texte, texte_court) + SELECT + ID, + ID, + NOM, + NOM + FROM prod_expert_sante.RH_PROFESSION + WHERE 1=1 + AND ID IN (SELECT profession_rh_id FROM w_cptres1) + AND ID NOT IN (SELECT code_original FROM rh.t_planning_qualification WHERE code_original IS NOT NULL) + ; + + -- Màj des Types d'absences du Planning. (ch) + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + id, + code, + nom, + left(nom,50) + FROM prod_expert_sante.motif_absence + WHERE 1=1 + AND id IN (SELECT motif_absence_id FROM w_cptres1 GROUP BY 1) + AND id NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + ; + + -- Màj des Codes Horaires du Planning. + INSERT INTO rh.t_planning_code_horaire(code_original, code, texte, texte_court) + SELECT + id, + code, + nom, + LEFT(nom,50) + FROM prod_expert_sante.type_poste + WHERE 1=1 + AND id IN (SELECT DISTINCT type_poste_id FROM w_cptres1) + AND id NOT IN (SELECT code_original FROM rh.t_planning_code_horaire WHERE code_original IS NOT NULL) + ; + + + -- Création d'une table Entreprise/Etablissement. + DROP TABLE IF EXISTS w_entets + ; + + CREATE TEMP TABLE w_entets AS + SELECT + ets.oid as etablissement_id, + ent.planning_code||ets.planning_code as entets_code + from rh.t_entreprises as ent + join rh.t_etablissements as ets on ets.entreprise_id = ent.oid + Where 1=1 + and ent.oid != 0 + and ets.oid != 0 + ; + + + + -- Alimentation de la table de mouvement. + -- Alimentation de la table de mouvement. + TRUNCATE rh.p_planning_mouvement + ; + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence, + code_horaire_id) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + date_orig, + to_char(date_orig, 'IYYYIW'::text)::numeric AS semaine, + to_char(date_orig, 'YYYYMM'::text)::numeric AS mois, + coalesce(w_entets.etablissement_id, 0) as etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) as niveau_id, + temps_valide + temps_absence, + temps_du_initial, + temps_valide, + temps_absence, + COALESCE(t_planning_code_horaire.oid,0) + FROM w_cptres1 + LEFT JOIN rh.t_planning_service ON t_planning_service.code_original = w_cptres1.etage_id + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = w_cptres1.profession_rh_id + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code_original = w_cptres1.motif_absence_id + LEFT JOIN w_entets ON w_entets.entets_code = 1 -- w_cptres1.entets_code + LEFT JOIN rh.t_planning_niveau ON split_part(t_planning_niveau.code_original,'|',3) = w_cptres1.etage_id AND split_part(t_planning_niveau.code_original,'|',1) = w_cptres1.rh_societe_id + LEFT JOIN rh.t_planning_code_horaire ON t_planning_code_horaire.code_original = w_cptres1.type_poste_id + LEFT JOIN rh.t_divers VENTIL_JOUR ON VENTIL_JOUR.code = 'VENTIL_JOUR' + ; + + VACUUM ANALYSE rh.p_planning_mouvement + ; + + ]]> + + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_GEOCOM.XML b/import_rh/iCTI_import_planning_GEOCOM.XML new file mode 100644 index 0000000..f3db201 --- /dev/null +++ b/import_rh/iCTI_import_planning_GEOCOM.XML @@ -0,0 +1,426 @@ + + + + + + + + + + + + + + + + + + + + + + + + les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_planning + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_planning.salarie_id + and w_planning.date between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + where 1!=1 + OR w_planning.contrat_id is null + OR w_planning.contrat_mois_id is null + group by 1) + UPDATE w_planning SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_planning.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_planning + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_planning.salarie_id + and p_contrats_mois.date_debut > w_planning.date -- Sélection des contrats APRES heures planning. + where 1!=1 + OR w_planning.contrat_id is null + OR w_planning.contrat_mois_id is null + group by 1) + UPDATE w_planning SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_planning.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_planning + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_planning.salarie_id + and p_contrats_mois.date_debut < w_planning.date -- Sélection des contrats AVANT heures planning. + where 1!=1 + OR w_planning.contrat_id is null + OR w_planning.contrat_mois_id is null + group by 1) + UPDATE w_planning SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_planning.cptres1_id = w_asso.cptres1_id + ; + + ]]> + + + + + + + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_GESTOR.XML b/import_rh/iCTI_import_planning_GESTOR.XML new file mode 100644 index 0000000..50223d7 --- /dev/null +++ b/import_rh/iCTI_import_planning_GESTOR.XML @@ -0,0 +1,592 @@ + + + + + + w_histo_ser.datefin + AND w_histo_ser_overlap.datedeb BETWEEN w_histo_ser.datedeb AND w_histo_ser.datefin + ; + -- insert autre période si date fin overlap inférieur + INSERT INTO w_histo_ser (nummat, datedeb, datefin, niv1, niv2, niv3, niv4, niv5) + SELECT + w_histo_ser_overlap.nummat, + w_histo_ser_overlap.datefin + '1 day'::interval as datedeb, + w_histo_ser.datefin, + w_histo_ser.niv1, + w_histo_ser.niv2, + w_histo_ser.niv3, + w_histo_ser.niv4, + w_histo_ser.niv5 + FROM w_histo_ser_overlap + JOIN w_histo_ser ON + w_histo_ser.nummat = w_histo_ser_overlap.nummat + AND w_histo_ser_overlap.datefin BETWEEN w_histo_ser.datedeb AND w_histo_ser.datefin + AND w_histo_ser_overlap.datedeb BETWEEN w_histo_ser.datedeb AND w_histo_ser.datefin + ; + -- réduit date de fin si date fin overlap supérieure + UPDATE w_histo_ser + SET + datefin = w_histo_ser_overlap.datedeb - '1 day'::interval + FROM w_histo_ser_overlap + WHERE 1=1 + AND w_histo_ser_overlap.nummat = w_histo_ser.nummat + AND w_histo_ser_overlap.datefin BETWEEN w_histo_ser.datedeb AND w_histo_ser.datefin + AND w_histo_ser_overlap.datedeb BETWEEN w_histo_ser.datedeb AND w_histo_ser.datefin + ; + + -- codes = code ou numero si pas tous les codes + UPDATE w_histo_ser + SET + niv_cod1 = CASE WHEN empty_codes[1] = 0 THEN niveaux1.niv_code ELSE niveaux1.numero::text END, + niv_cod2 = CASE WHEN empty_codes[2] = 0 THEN niveaux2.niv_code ELSE niveaux2.numero::text END, + niv_cod3 = CASE WHEN empty_codes[3] = 0 THEN niveaux3.niv_code ELSE niveaux3.numero::text END, + niv_cod4 = CASE WHEN empty_codes[4] = 0 THEN niveaux4.niv_code ELSE niveaux4.numero::text END, + niv_cod5 = CASE WHEN empty_codes[5] = 0 THEN niveaux5.niv_code ELSE niveaux5.numero::text END + + FROM + prod_gestor.niveaux1,prod_gestor.niveaux2,prod_gestor.niveaux3,prod_gestor.niveaux4,prod_gestor.niveaux5, + ( + SELECT ARRAY[ + (SELECT count(*) FROM prod_gestor.niveaux1 WHERE niv_code = '' AND numero != 0), + (SELECT count(*) FROM prod_gestor.niveaux2 WHERE niv_code = '' AND numero != 0), + (SELECT count(*) FROM prod_gestor.niveaux3 WHERE niv_code = '' AND numero != 0), + (SELECT count(*) FROM prod_gestor.niveaux4 WHERE niv_code = '' AND numero != 0), + (SELECT count(*) FROM prod_gestor.niveaux5 WHERE niv_code = '' AND numero != 0)] AS empty_codes + ) sub + WHERE 1=1 + AND niv1 = niveaux1.numero + AND niv2 = niveaux2.numero + AND niv3 = niveaux3.numero + AND niv4 = niveaux4.numero + AND niv5 = niveaux5.numero + ; + + UPDATE w_histo_ser + SET niv2 = niv_cod2 + ; + ]]> + + + + '2015-01-01' + LEFT JOIN w_histo_ser ON w_histo_ser.nummat = prod_gestor_compteurj.nummat + AND datej BETWEEN datedeb AND datefin + WHERE + (1!=1 + OR cpt001 != 0 + OR cpt003 != 0 + ) + and datej > '2015-01-01' + ; + + INSERT INTO w_compteurj + SELECT + nextval('w_compteurj_seq') as compteurj_id, + prod_gestor_absence.salarie_corr, + 0::bigint AS salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(dateval) AS date, + niv5, + niv2, + niv3, + niv4, + niv2 || '|' || niv3 || '|' || niv4 AS niveaux_code_original, + niv2 || '|' || niv3 || '|' || niv4 AS service_code_original, + niv_cod2 AS entets_code, + code AS abs_cod, + 0 AS temps_du_initial, + duree::numeric AS temps_du, + 0 AS temps_valide, + duree::numeric AS temps_absence + FROM prod_gestor_absence + LEFT JOIN w_histo_ser ON w_histo_ser.nummat = prod_gestor_absence.nummat + AND dateval BETWEEN w_histo_ser.datedeb AND w_histo_ser.datefin + WHERE duree != 0 + and dateval > '2015-01-01' + ; + + -- ajout de la structure du salarie si elle n'est pas trouvé dans l'historique + UPDATE w_compteurj + SET + service_code_original = niv_code||'|'||prod_gestor_pers.niv3||'|'||prod_gestor_pers.niv4, + entets_code = niv_code, + niv2 = niv_code, + niv3 = prod_gestor_pers.niv3, + niv4 = prod_gestor_pers.niv4, + niv5 = prod_gestor_pers.niv5 + FROM prod_gestor_pers + JOIN prod_gestor.niveaux2 ON prod_gestor_pers.niv2 = numero + WHERE 1=1 + AND prod_gestor_pers.matricule = w_compteurj.salarie_corr + AND entets_code IS NULL + ; + + UPDATE w_compteurj + SET + salarie_id = w_sal_pla.salarie_id + FROM + w_sal_pla + WHERE 1=1 + AND UPPER(w_sal_pla.salarie_corr) = UPPER(w_compteurj.salarie_corr) + AND entets_code = etablissement_planning_code + ; + + VACUUM ANALYSE w_compteurj + ; + + -- Association aux contrats et contrat_mois. + -- En général, les heures planning sont effectuées AVANT un contrat/paie à cause du décallage avec la paie : + -- => les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + compteurj_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_compteurj + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_compteurj.salarie_id + and w_compteurj.date between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + where 1!=1 + OR w_compteurj.contrat_id is null + OR w_compteurj.contrat_mois_id is null + group by 1) + UPDATE w_compteurj SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_compteurj.compteurj_id = w_asso.compteurj_id + ; + + with w_asso as ( + select + compteurj_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_compteurj + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_compteurj.salarie_id + and p_contrats_mois.date_debut > w_compteurj.date -- Sélection des contrats APRES heures planning. + where 1!=1 + OR w_compteurj.contrat_id is null + OR w_compteurj.contrat_mois_id is null + group by 1) + UPDATE w_compteurj SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_compteurj.compteurj_id = w_asso.compteurj_id + ; + + with w_asso as ( + select + compteurj_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_compteurj + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_compteurj.salarie_id + and p_contrats_mois.date_debut < w_compteurj.date -- Sélection des contrats AVANT heures planning. + where 1!=1 + OR w_compteurj.contrat_id is null + OR w_compteurj.contrat_mois_id is null + group by 1) + UPDATE w_compteurj SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_compteurj.compteurj_id = w_asso.compteurj_id + ; + + DELETE FROM w_compteurj + where 1=1 + and (1!=1 + or contrat_mois_id is null + or contrat_id is null) + ; + + -- Création d'index. + CREATE INDEX w_compteurj_i_contrat_id ON w_compteurj USING btree (contrat_id) + ; + CREATE INDEX w_compteurj_i_contrat_mois_id ON w_compteurj USING btree (contrat_mois_id) + ; + CREATE INDEX w_compteurj_i_date ON w_compteurj USING btree (date) + ; + CREATE INDEX w_compteurj_i_salarie_id ON w_compteurj USING btree (salarie_id) + ; + + DROP TABLE IF EXISTS w_ser; + CREATE TEMP TABLE w_ser AS + SELECT + service_code_original, + niv2, + niv3, + niv4, + entets_code as niv_cod2, + ''::text AS niv_cod3, + ''::text AS niv_cod4, + ''::text AS texte, + ''::text AS texte_court + FROM + w_compteurj + GROUP BY 1,2,3,4,5 + ; + + UPDATE w_ser SET + niv_cod3 = CASE WHEN empty_codes[1] = 0 THEN niveaux3.niv_code ELSE niveaux3.numero::text END, + niv_cod4 = CASE WHEN empty_codes[2] = 0 THEN niveaux4.niv_code ELSE niveaux4.numero::text END + FROM + prod_gestor.niveaux3,prod_gestor.niveaux4, + ( + SELECT ARRAY[ + (SELECT count(*) FROM prod_gestor.niveaux3 WHERE (niv_code = '' OR niv_code IS NULL) AND numero != 0), + (SELECT count(*) FROM prod_gestor.niveaux4 WHERE (niv_code = '' OR niv_code IS NULL) AND numero != 0)] AS empty_codes + ) sub + WHERE 1=1 + AND niv3 = niveaux3.numero + AND niv4 = niveaux4.numero + ; + + UPDATE w_ser SET + texte = COALESCE(niveaux2.libelle, niv_cod2)|| ' - '||COALESCE(niveaux3.libelle, niv_cod3) || ' - '||COALESCE(niveaux4.libelle, niv_cod4), + texte_court = substr(COALESCE(niveaux2.libelle, niv_cod2)|| ' - '||COALESCE(niveaux3.libelle, niv_cod3) || ' - '||COALESCE(niveaux4.libelle, niv_cod4),1,50) + FROM + prod_gestor.niveaux2,prod_gestor.niveaux3,prod_gestor.niveaux4 + WHERE 1=1 + AND niv2 = niveaux2.niv_code + AND niv3 = niveaux3.numero + AND niv4 = niveaux4.numero + ; + + -- Alimentation des tables de paramètres. + -- Màj des Services du Planning. + INSERT INTO rh.t_planning_service(code_original, code, texte, texte_court, service_id) + SELECT + service_code_original, + niv_cod2||'|'||niv_cod3||'|'||niv_cod4, + texte, + texte_court, + 0 as service_id + FROM w_ser + WHERE service_code_original NOT IN (SELECT code_original FROM rh.t_planning_service WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des niveauxx du Planning. + INSERT INTO rh.t_planning_niveau(code_original, code, texte, texte_court) + SELECT + service_code_original, + niv_cod2||'|'||niv_cod3||'|'||niv_cod4, + texte, + texte_court + FROM w_ser + WHERE service_code_original NOT IN (SELECT code_original FROM rh.t_planning_niveau WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des Qualifications du Planning. + INSERT INTO rh.t_planning_qualification(code_original, code, texte, texte_court) + SELECT + numero, + numero, + libelle, + substr(libelle,1,50) + FROM prod_gestor.niveaux5 AS poste + WHERE 1=1 + AND numero IN (SELECT niv5 FROM w_compteurj) + AND numero NOT IN (SELECT code_original FROM rh.t_planning_qualification WHERE code_original IS NOT NULL) + ; + + -- Màj des Types d'absences du Planning. + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + numero, + code, + libelle, + substr(libelle,1,50) + FROM prod_gestor.codeevt AS absence + WHERE 1=1 + AND code IN (SELECT abs_cod FROM w_compteurj) + AND numero NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Création d'une table Entreprise/Etablissement. + DROP TABLE IF EXISTS w_entets + ; + + CREATE TEMP TABLE w_entets AS + select + ets.oid as etablissement_id, + ent.planning_code||ets.planning_code as entets_code + from rh.t_entreprises as ent + join rh.t_etablissements as ets on ets.entreprise_id = ent.oid + Where 1=1 + and ent.oid != 0 + and ets.oid != 0 + ; + + -- Alimentation de la table de mouvement. + TRUNCATE rh.p_planning_mouvement + ; + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + date, + to_char(w_compteurj.date, 'IYYYIW'::text)::numeric AS semaine, + to_char(w_compteurj.date, 'YYYYMM'::text)::numeric AS mois, + coalesce(w_entets.etablissement_id, 0) as etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) as niveau_id, + temps_du, + temps_du_initial::numeric, + temps_valide, + temps_absence + FROM w_compteurj + LEFT JOIN rh.t_planning_niveau ON t_planning_niveau.code_original = w_compteurj.niveaux_code_original + LEFT JOIN rh.t_planning_service ON t_planning_service.code_original = w_compteurj.service_code_original + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = w_compteurj.niv5 + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code = w_compteurj.abs_cod + LEFT JOIN w_entets ON w_entets.entets_code = w_compteurj.entets_code + ; + + + VACUUM ANALYSE rh.p_planning_mouvement + ; + + ]]> + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_KELIO.XML b/import_rh/iCTI_import_planning_KELIO.XML new file mode 100644 index 0000000..f08591d --- /dev/null +++ b/import_rh/iCTI_import_planning_KELIO.XML @@ -0,0 +1,1805 @@ + + + + + + '[ENV_PLANNING_DATEDEBUT]'::date + ; + + -- surcharge de types d'absence + UPDATE prod_kelio_absence + SET est_presence = CASE WHEN to_id IS NOT NULL THEN 1 ELSE 0 END + FROM rh.t_planning_type_absence + LEFT JOIN ( + SELECT + to_id, + t_planning_type_absence.code + FROM rh.t_listes + JOIN rh.t_listes_contenu ON liste_id = t_listes.oid + JOIN rh.t_planning_type_absence ON to_id = t_planning_type_absence.oid + WHERE t_listes.code = 'CTI_ABS_TRAVAILLEES' + ) sub ON sub.code = t_planning_type_absence.code + WHERE 1=1 + AND abrege_ = t_planning_type_absence.code; + + ]]> + + + + + + '2015-01-01' + AND (ferie IS NULL OR (ferie IS NOT NULL AND jour_travaille_ = 1)) + -- AND (periode_realise.debut_ IS NULL OR (periode_realise.debut_ BETWEEN periode_travail.debut_ AND periode_travail.fin_ + -- OR periode_travail.debut_ BETWEEN periode_realise.debut_ AND periode_realise.fin_ + -- )) + ; + + -- cas 0 2 devient 2 ou 1 devient ou 2 devient 1 + UPDATE prod_kelio_affectation_horaire_journalier to_update + SET + plage_updated = true, + debut = CASE WHEN to_update.debut_th = debut_th_max THEN 0 ELSE to_update.debut END, + fin = CASE WHEN to_update.debut_th = debut_th_max THEN 0 ELSE to_update.fin END, + duree = CASE WHEN to_update.debut_th = debut_th_max THEN 0 ELSE to_update.duree END, + debut_th = CASE WHEN to_update.debut = debut_max THEN 0 ELSE to_update.debut END, + fin_th = CASE WHEN to_update.debut = debut_max THEN 0 ELSE to_update.fin_th END, + duree_th = CASE WHEN to_update.debut = debut_max THEN 0 ELSE to_update.duree END + FROM ( + SELECT + affectation_horaire_journalie_, debut, fin, MAX(debut_th) AS debut_th_max + FROM prod_kelio_affectation_horaire_journalier GROUP BY 1,2,3 + HAVING count(*) > 1 + ) sub, + ( + SELECT + affectation_horaire_journalie_, debut_th, fin_th, MAX(debut) AS debut_max + FROM prod_kelio_affectation_horaire_journalier GROUP BY 1,2,3 + HAVING count(*) > 1 + ) sub2 + WHERE + to_update.affectation_horaire_journalie_ = sub.affectation_horaire_journalie_ + AND to_update.affectation_horaire_journalie_ = sub2.affectation_horaire_journalie_ + ; + + + + -- cas 1 période th devient 2 rea + UPDATE prod_kelio_affectation_horaire_journalier + SET + debut_th = 0, + fin_th = 0, + duree_th = 0, + pause_th = 0, + pause_deb_th = 0, + pause_fin_th = 0 + FROM ( + SELECT + affectation_horaire_journalie_, debut_th, fin_th, MAX(debut) AS debut_max + FROM prod_kelio_affectation_horaire_journalier GROUP BY 1,2,3 + HAVING count(*) > 1 + ) sub + WHERE + prod_kelio_affectation_horaire_journalier.affectation_horaire_journalie_ = sub.affectation_horaire_journalie_ + AND debut_max = debut + AND plage_updated = false + ; + + -- cas 2 périodes th deviennent 1 rea + UPDATE prod_kelio_affectation_horaire_journalier + SET + debut = 0, + fin = 0, + duree = 0 + FROM ( + SELECT + affectation_horaire_journalie_, debut, fin, MAX(debut_th) AS debut_max + FROM prod_kelio_affectation_horaire_journalier GROUP BY 1,2,3 + HAVING count(*) > 1 + ) sub + WHERE + prod_kelio_affectation_horaire_journalier.affectation_horaire_journalie_ = sub.affectation_horaire_journalie_ + AND debut_max = debut_th + AND plage_updated = false + ; + ]]> + + + + + + 1 + -- ) sub + --WHERE + -- prod_kelio_affectation_horaire_journalier.affectation_horaire_journalie_ = sub.affectation_horaire_journalie_ + -- AND debut_max = debut_th + --; + + -- Recensement des salariés et établissements. + DROP TABLE IF EXISTS w_sal_pla + ; + CREATE TEMP TABLE w_sal_pla AS + SELECT + p_salaries.oid AS salarie_id, + p_salaries.matricule, + t_entreprises.code_original AS entreprise_code_original, + t_etablissements.code_original AS etablissement_code_original, + t_entreprises.code AS entreprise_code, + t_entreprises.planning_code AS entreprise_planning_code, + t_etablissements.code AS etablissement_code, + right(t_etablissements.code,3) as etablissement_planning_code, + ''::text AS salarie_corr + FROM rh.p_salaries + -- Il faut absoluement faire le produit cartésien matricule/établissement même si un salarié n'a jamais travaillé dans un des établissement. + -- En effet, cela pourrait être le cas dans gestor et ce traitement pourrait ne pas remonter les données associées. + JOIN rh.t_entreprises ON t_entreprises.oid = p_salaries.entreprise_id + JOIN rh.t_etablissements ON t_etablissements.entreprise_id = p_salaries.entreprise_id + WHERE 1=1 + AND salarie_fusionne_id = 0 + GROUP BY 1,2,3,4,5,6,7,8,9 + ORDER BY 1,2,3 + ; + + + -- Alimenter le champ w_sal_pla.salarie_corr. + UPDATE w_sal_pla SET + salarie_corr = matricule; + + -- Création d'index. + CREATE INDEX w_sal_pla_i_matricule ON w_sal_pla USING btree (matricule) + ; + + DROP SEQUENCE IF EXISTS w_affectation_horaire_journalier_seq + ; + + CREATE TEMP SEQUENCE w_affectation_horaire_journalier_seq + ; + + DROP TABLE IF EXISTS w_affectation_horaire_journalier + ; + + -- consitution des compteurs heures travaillées en ommetant les pauses + CREATE TEMP TABLE w_affectation_horaire_journalier AS + SELECT + nextval('w_affectation_horaire_journalier_seq') as affectation_horaire_journalier_id, + prod_kelio_affectation_horaire_journalier.salarie_corr, + null::bigint AS salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(date_application_) AS date, + debut, + fin, + debut_th, + fin_th, + pause_th, + pause_deb_th, + pause_fin_th, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS niveaux_code_original, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS service_code_original, + libNiv2 AS entets_code, + ''::text AS abs_cod, + CASE + WHEN heure_debut_periode_ = 0 THEN duree_th - pause_th + WHEN heure_debut_periode_ < fin_th THEN fin_th - heure_debut_periode_ - pause_th + ELSE duree_th - pause_th END AS temps_du_initial, + CASE + WHEN heure_debut_periode_ = 0 THEN duree - pause + WHEN heure_debut_periode_ < fin THEN fin - heure_debut_periode_ - pause + ELSE duree - pause END + AS temps_du, + CASE + --WHEN theorique_applique_ = 1 AND heure_debut_periode_ = 0 THEN temps_theorique_/3600.0 - pause_th-- cas simple + --WHEN theorique_applique_ = 1 AND heure_debut_periode_ < fin THEN fin_th- heure_debut_periode_/3600.0 - pause_th-- re affectation + WHEN periodes_redefinies_ = 0 AND heure_debut_periode_ = 0 THEN duree_th - pause_th -- redefinition + WHEN periodes_redefinies_ = 0 AND heure_debut_periode_ < fin_th THEN fin_th- heure_debut_periode_/3600.0 - pause_th-- redefinition et reaff + WHEN periodes_redefinies_ = 1 AND heure_debut_periode_ = 0 THEN duree - pause-- redefinition + WHEN periodes_redefinies_ = 1 AND heure_debut_periode_ < fin THEN fin- heure_debut_periode_/3600.0 - pause-- redefinition et reaff + ELSE duree - pause END + AS temps_valide, + 0::numeric AS temps_absence + FROM prod_kelio_affectation_horaire_journalier + LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = prod_kelio_affectation_horaire_journalier.salarie_ AND date_application_ BETWEEN w_histo_ser.debut_ AND w_histo_ser.fin_ + LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + ; + + -- absence en jours + UPDATE w_affectation_horaire_journalier + SET + abs_cod = abrege_, + temps_absence = temps_valide * (CASE WHEN absence_date_debut_ = date THEN absence_commence_matin_ ELSE 1 END + CASE WHEN absence_date_fin_ = date THEN absence_termine_ap_midi_ ELSE 1 END) / 2, + temps_valide = temps_valide - temps_valide * (CASE WHEN absence_date_debut_ = date THEN absence_commence_matin_ ELSE 1 END + CASE WHEN absence_date_fin_ = date THEN absence_termine_ap_midi_ ELSE 1 END) / 2 + FROM + prod_kelio_absence + WHERE 1=1 AND + prod_kelio_absence.salarie_corr = w_affectation_horaire_journalier.salarie_corr AND + date BETWEEN absence_date_debut_ AND CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END AND + absence_heure_fin1_ = 0 AND absence_duree_abs_heures_ = 0 AND mode_cumul_ < 2 AND abrege_ != 'CA' AND + temps_valide != 0 AND est_presence = 0 + ; + + -- maj des jours d'absence avec présence + UPDATE w_affectation_horaire_journalier + SET + abs_cod = abrege_ + FROM + prod_kelio_absence + WHERE 1=1 AND + prod_kelio_absence.salarie_corr = w_affectation_horaire_journalier.salarie_corr AND + date BETWEEN absence_date_debut_ AND CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END AND + absence_heure_fin1_ = 0 AND absence_duree_abs_heures_ = 0 AND mode_cumul_ = 2 AND + temps_valide != 0 AND est_presence = 1 + ; + + -- suppression des hoarires travaillés restants correspondant aux absences en jours + DELETE FROM w_affectation_horaire_journalier + USING + prod_kelio_absence + WHERE 1=1 AND + prod_kelio_absence.salarie_corr = w_affectation_horaire_journalier.salarie_corr AND + date BETWEEN absence_date_debut_ AND CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END AND + absence_heure_fin1_ = 0 AND absence_duree_abs_heures_ = 0 AND (mode_cumul_ = 2 OR abrege_ = 'CA') AND + temps_valide != 0 AND est_presence = 0 + ; + + --nettoyage des horaires vides + DELETE FROM w_affectation_horaire_journalier + WHERE 1=1 AND + COALESCE(temps_du,0) = 0 AND + COALESCE(temps_du_initial,0) = 0 AND + COALESCE(temps_valide,0) = 0 AND + COALESCE(temps_absence,0) = 0 ; + + + -- absences en heures + DROP TABLE IF EXISTS w_abs_h; + CREATE TEMP TABLE w_abs_h AS + SELECT + affectation_horaire_journalier_id, + abrege_, + libelle_, + absence_duree_abs_heures_, -- pause_th AS absence_duree_abs_heures_, + absence_heure_deb1_, + absence_heure_deb2_, + absence_heure_fin1_, + absence_heure_fin2_, + pause_deb_th, + pause_fin_th, + SUM(temps_valide) OVER (PARTITION BY prod_kelio_absence.salarie_corr,date ORDER by date,absence_heure_deb1_,affectation_horaire_journalier_id) as somme, + CASE + WHEN heure_debut_periode_ = 0 OR heure_debut_periode_ IS NULL THEN + CASE + WHEN absence_heure_deb1_ != 0 THEN (least(absence_heure_fin2_,fin*3600) - absence_heure_deb2_)/3600.0 + (least(absence_heure_fin1_,fin*3600) - absence_heure_deb1_)/3600.0 + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) + OR (pause_fin_th > absence_heure_deb2_/3600.0 AND pause_deb_th < absence_heure_fin2_/3600.0))) + AND absence_heure_deb1_ < fin_th + AND rank() OVER (PARTITION BY prod_kelio_absence.salarie_corr,date,abrege_,absence_heure_deb1_ ORDER by date,absence_heure_deb1_,affectation_horaire_journalier_id) = 1 THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ + ELSE 0 END + ELSE + CASE + WHEN absence_heure_deb1_ != 0 THEN + CASE WHEN heure_debut_periode_ < absence_heure_fin1_ THEN (least(absence_heure_fin1_,fin*3600) - absence_heure_deb1_)/3600.0 ELSE 0 END + + CASE WHEN heure_debut_periode_ < absence_heure_fin2_ AND heure_debut_periode_ > absence_heure_fin1_ THEN (least(absence_heure_fin2_,fin*3600) - absence_heure_deb2_)/3600.0 ELSE 0 END + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) OR (pause_fin_th > absence_heure_deb2_/3600.0 + AND pause_deb_th < absence_heure_fin2_/3600.0))) AND absence_heure_deb1_ < fin_th + AND rank() OVER (PARTITION BY prod_kelio_absence.salarie_corr,date,abrege_,absence_heure_deb1_ ORDER by date,absence_heure_deb1_,affectation_horaire_journalier_id) = 1 + THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ -- répartition tres tres tres basique et dangeureuse si plusieurs plages horaires + ELSE 0 END + END + + temps_valide - SUM(temps_valide) OVER (PARTITION BY prod_kelio_absence.salarie_corr,date,abrege_,absence_heure_deb1_ ORDER by date,absence_heure_deb1_,affectation_horaire_journalier_id) as restant, + est_presence + FROM prod_kelio_absence + JOIN w_affectation_horaire_journalier ON w_affectation_horaire_journalier.salarie_corr = prod_kelio_absence.salarie_corr + AND date BETWEEN absence_date_debut_ AND + CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END + AND ((absence_heure_fin1_/3600.0 > debut AND absence_heure_deb1_/3600.0< fin) OR (absence_heure_fin2_/3600.0 > debut AND absence_heure_deb2_/3600.0< fin)) + LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = prod_kelio_absence.salarie_ AND date BETWEEN w_histo_ser.debut_ and w_histo_ser.fin_ + LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + WHERE NOT(absence_heure_fin1_ = 0 AND absence_duree_abs_heures_ = 0) --OR (absence_commence_matin_ + absence_termine_ap_midi_) != 2 + ; + + --modification des horaires travaillés par les absences en heures + UPDATE w_affectation_horaire_journalier + SET + temps_du = temps_du - LEAST(temps_du,restant), + temps_valide = temps_valide - LEAST(temps_valide,restant) + FROM + (SELECT + affectation_horaire_journalier_id, + SUM(restant) AS restant + FROM w_abs_h + GROUP BY 1 + HAVING COUNT(*) = 1 + ) w_abs_h + WHERE + w_affectation_horaire_journalier.affectation_horaire_journalier_id = w_abs_h.affectation_horaire_journalier_id + --and est_presence = 0 + ; + + UPDATE w_affectation_horaire_journalier + SET + temps_du = temps_du - LEAST(temps_du,restant), + temps_valide = temps_valide - LEAST(temps_valide,restant) + FROM + (SELECT + affectation_horaire_journalier_id, + SUM(restant) AS restant + FROM w_abs_h + GROUP BY 1 + HAVING COUNT(*) > 1 + ) w_abs_h + WHERE + w_affectation_horaire_journalier.affectation_horaire_journalier_id = w_abs_h.affectation_horaire_journalier_id + --and est_presence = 0 + ; + + --modification des horaires travaillés par les absences en heures + -- UPDATE w_affectation_horaire_journalier + -- SET + -- abs_code = abrege_, + -- temps_du = GREATEST(temps_du,restant), + -- temps_valide = temps_valide - GREATEST(temps_valide,restant) + -- FROM + -- w_abs_h + -- WHERE + -- w_affectation_horaire_journalier.affectation_horaire_journalier_id = w_abs_h.affectation_horaire_journalier_id + -- AND est_presence = 1 and mode_cumul_ = 2 + -- ; + + -- insetion des absences en heures celles sans horaire + INSERT INTO w_affectation_horaire_journalier + SELECT + nextval('w_affectation_horaire_journalier_seq') as affectation_horaire_journalier_id, + prod_kelio_absence.salarie_corr, + null::bigint AS salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + COALESCE(date(date_application_), p_calendrier.date) AS date, + debut, + fin, + debut_th, + fin_th, + pause_th, + pause_deb_th, + pause_fin_th, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS niveaux_code_original, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS service_code_original, + libNiv2 AS entets_code, + abrege_ AS abs_cod, + 0 AS temps_du_initial, + CASE + WHEN heure_debut_periode_ = 0 OR heure_debut_periode_ IS NULL THEN + CASE + WHEN absence_heure_deb1_ != 0 THEN (absence_heure_fin2_ - absence_heure_deb2_)/3600.0 + (absence_heure_fin1_ - absence_heure_deb1_)/3600.0 + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) OR (pause_fin_th > absence_heure_deb2_/3600.0 AND pause_deb_th < absence_heure_fin2_/3600.0))) THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ + ELSE duree_th - pause_th END + ELSE + CASE + WHEN absence_heure_deb1_ != 0 THEN + CASE WHEN heure_debut_periode_ < absence_heure_fin1_ THEN (absence_heure_fin1_ - absence_heure_deb1_)/3600.0 ELSE 0 END + + CASE WHEN heure_debut_periode_ < absence_heure_fin2_ AND heure_debut_periode_ > absence_heure_fin1_ THEN (absence_heure_fin2_ - absence_heure_deb2_)/3600.0 ELSE 0 END + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) OR (pause_fin_th > absence_heure_deb2_/3600.0 AND pause_deb_th < absence_heure_fin2_/3600.0))) THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ -- répartition tres tres tres basique et dangeureuse + ELSE heure_fin_periode_ - heure_debut_periode_ END + END AS temps_du, + CASE WHEN est_presence = 1 THEN CASE + WHEN heure_debut_periode_ = 0 OR heure_debut_periode_ IS NULL THEN + CASE + WHEN absence_heure_deb1_ != 0 THEN (absence_heure_fin2_ - absence_heure_deb2_)/3600.0 + (absence_heure_fin1_ - absence_heure_deb1_)/3600.0 + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) OR (pause_fin_th > absence_heure_deb2_/3600.0 AND pause_deb_th < absence_heure_fin2_/3600.0))) THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ + ELSE duree_th END + ELSE + CASE + WHEN absence_heure_deb1_ != 0 THEN + CASE WHEN heure_debut_periode_ < absence_heure_fin1_ THEN (absence_heure_fin1_ - absence_heure_deb1_)/3600.0 ELSE 0 END + + CASE WHEN heure_debut_periode_ < absence_heure_fin2_ AND heure_debut_periode_ > absence_heure_fin1_ THEN (absence_heure_fin2_ - absence_heure_deb2_)/3600.0 ELSE 0 END + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) OR (pause_fin_th > absence_heure_deb2_/3600.0 AND pause_deb_th < absence_heure_fin2_/3600.0))) THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ -- répartition tres tres tres basique et dangeureuse + ELSE heure_fin_periode_ - heure_debut_periode_ END + END ELSE 0 END AS temps_valide, + CASE WHEN est_presence = 0 THEN CASE + WHEN heure_debut_periode_ = 0 OR heure_debut_periode_ IS NULL THEN + CASE + WHEN absence_heure_deb1_ != 0 THEN (absence_heure_fin2_ - absence_heure_deb2_)/3600.0 + (absence_heure_fin1_ - absence_heure_deb1_)/3600.0 + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) OR (pause_fin_th > absence_heure_deb2_/3600.0 AND pause_deb_th < absence_heure_fin2_/3600.0))) THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ + ELSE duree_th END + ELSE + CASE + WHEN absence_heure_deb1_ != 0 THEN + CASE WHEN heure_debut_periode_ < absence_heure_fin1_ THEN (absence_heure_fin1_ - absence_heure_deb1_)/3600.0 ELSE 0 END + + CASE WHEN heure_debut_periode_ < absence_heure_fin2_ AND heure_debut_periode_ > absence_heure_fin1_ THEN (absence_heure_fin2_ - absence_heure_deb2_)/3600.0 ELSE 0 END + - CASE WHEN (pause_deb_th IS NOT NULL AND ((pause_fin_th > absence_heure_deb1_/3600.0 AND pause_deb_th < absence_heure_fin1_/3600.0) OR (pause_fin_th > absence_heure_deb2_/3600.0 AND pause_deb_th < absence_heure_fin2_/3600.0))) THEN pause_th ELSE 0 END + WHEN absence_duree_abs_heures_ > 0 THEN absence_duree_abs_heures_ -- répartition tres tres tres basique et dangeureuse + ELSE heure_fin_periode_ - heure_debut_periode_ END + END ELSE 0 END + AS temps_absence + FROM prod_kelio_absence + JOIN base.p_calendrier ON p_calendrier.date BETWEEN absence_date_debut_ AND + CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END + LEFT JOIN prod_kelio_affectation_horaire_journalier ON prod_kelio_affectation_horaire_journalier.salarie_ = prod_kelio_absence.salarie_ + AND prod_kelio_affectation_horaire_journalier.date_application_ BETWEEN absence_date_debut_ AND + CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END + AND ((absence_heure_fin1_ > 0 AND (absence_heure_fin1_/3600.0 > debut AND absence_heure_deb1_/3600.0< fin)) + OR (absence_heure_fin2_ > 0 AND (absence_heure_fin2_/3600.0 > debut AND absence_heure_deb2_/3600.0< fin))) + LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = prod_kelio_absence.salarie_ AND COALESCE(date_application_,p_calendrier.date) BETWEEN w_histo_ser.debut_ and w_histo_ser.fin_ + LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + WHERE mode_cumul_ < 2 AND NOT(absence_heure_fin1_ = 0 AND absence_duree_abs_heures_ = 0) -- prise en charge au niveau du jour + ; + + -- absence sans affectation d'horaire en jours ou sans code d'absence dans Kelio + INSERT INTO w_affectation_horaire_journalier + SELECT + nextval('w_affectation_horaire_journalier_seq') as affectation_horaire_journalier_id, + employee_identification_number, + null::bigint AS salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + COALESCE(w_affectation_horaire_journalier.date, total_date) AS date, + debut, + fin, + debut_th, + fin_th, + pause_th, + pause_deb_th, + pause_fin_th, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS niveaux_code_original, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS service_code_original, + libNiv2 AS entets_code, + abs_type_abbreviation AS abs_cod, + 0 AS temps_du_initial, + hours AS temps_du, + CASE WHEN COALESCE(est_presence,0) = 1 THEN hours ELSE 0 END AS temps_valide, + CASE WHEN COALESCE(est_presence,0) != 1 THEN hours ELSE 0 END AS temps_absence + FROM prod_keliod.estimated_daily_absence + LEFT JOIN w_affectation_horaire_journalier ON + total_date = date + AND w_affectation_horaire_journalier.salarie_corr = employee_identification_number + --LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = estimated_daily_absence.section_key + LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = employee_key AND total_date BETWEEN w_histo_ser.debut_ and w_histo_ser.fin_ + LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + LEFT JOIN ( + SELECT CASE WHEN to_id IS NOT NULL THEN 1 ELSE 0 END AS est_presence, t_planning_type_absence.code FROM + rh.t_listes JOIN rh.t_listes_contenu ON liste_id = t_listes.oid + JOIN rh.t_planning_type_absence ON to_id = t_planning_type_absence.oid + WHERE + t_listes.code = 'CTI_ABS_TRAVAILLEES' + ) sub ON sub.code = abs_type_abbreviation + WHERE (w_affectation_horaire_journalier.date IS NULL OR COALESCE(abs_cod, '') != abs_type_abbreviation) + AND (TOTAL_DATE != ALL (ARRAY(SELECT DISTINCT date_application_ FROM prod_kelio.jour_ferie)::date[]) OR est_presence = 1) + ; + + --INSERT INTO w_affectation_horaire_journalier + --SELECT + -- nextval('w_affectation_horaire_journalier_seq') as affectation_horaire_journalier_id, + -- prod_kelio_absence.salarie_corr, + -- null::bigint AS salarie_id, + -- null::bigint AS contrat_id, + -- null::bigint AS contrat_mois_id, + -- COALESCE(w_affectation_horaire_journalier.date, p_calendrier.date) AS date, + -- debut, + -- fin, + -- debut_th, + -- fin_th, + -- pause_th, + -- pause_deb_th, + -- pause_fin_th, + -- codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS niveaux_code_original, + -- codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS service_code_original, + -- libNiv2 AS entets_code, + -- abrege_ AS abs_cod, + -- (tx_temps / 100.0) * (CASE + -- WHEN mode_cumul_ < 2 AND nb_jour_ouvre = 1 THEN base_horaire_ / (5 * 3600.0) + -- WHEN mode_cumul_ = 2 THEN base_horaire_ / (7 * 3600.0) + -- ELSE 0 END) AS temps_du_initial, + -- (tx_temps / 100.0) * (CASE + -- WHEN mode_cumul_ < 2 AND nb_jour_ouvre = 1 THEN base_horaire_ / (5 * 3600.0) + -- WHEN mode_cumul_ = 2 THEN base_horaire_ / (7 * 3600.0) + -- ELSE 0 END) AS temps_du, + -- 0 AS temps_valide, + -- (tx_temps / 100.0) * (CASE + -- WHEN mode_cumul_ < 2 AND nb_jour_ouvre = 1 THEN base_horaire_ / (5 * 3600.0) + -- WHEN mode_cumul_ = 2 THEN base_horaire_ / (7 * 3600.0) + -- ELSE 0 END) AS temps_absence + -- FROM prod_kelio_absence + -- JOIN base.p_calendrier ON p_calendrier.date BETWEEN absence_date_debut_ AND + -- CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END + -- JOIN base.v_calendrier_indicateurs_1 ON v_calendrier_indicateurs_1.date = p_calendrier.date + -- LEFT JOIN w_affectation_horaire_journalier ON + -- CASE WHEN mode_cumul_ = 2 THEN p_calendrier.date = w_affectation_horaire_journalier.date + -- ELSE w_affectation_horaire_journalier.date BETWEEN absence_date_debut_ AND + -- CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END + -- END + -- AND w_affectation_horaire_journalier.salarie_corr = prod_kelio_absence.salarie_corr + -- LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = prod_kelio_absence.salarie_ AND p_calendrier.date BETWEEN w_histo_ser.debut_ and w_histo_ser.fin_ + -- LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + -- JOIN prod_kelio.affectation_duree_travail ON salarie_g_t_p_ = prod_kelio_absence.salarie_ and p_calendrier.date BETWEEN affectation_duree_travail.date_debut_ AND COALESCE(affectation_duree_travail.date_fin_,'2099-12-31') + -- LEFT JOIN prod_keliod.SCHEDULE_ASSIGNMENT ON employee_identification_number = prod_kelio_absence.salarie_corr + -- AND p_calendrier.date BETWEEN assignment_date and assignment_end_date + -- LEFT JOIN ( + -- SELECT + -- schedule_abbreviation AS tx_code, + -- replace(split_part(regexp_replace(regexp_replace(schedule_description,'[^0-9\.%]','','g'),'[0-9\.]*%([0-9\.]*)%$','\1'),'%',1),'..','')::numeric AS tx_temps + -- FROM + -- prod_keliod.SCHEDULE_ASSIGNMENT GROUP BY 1,2) sub ON tx_code = schedule_abbreviation + -- WHERE absence_heure_fin1_ = 0 AND absence_duree_abs_heures_ = 0 AND w_affectation_horaire_journalier.date IS NULL AND mode_cumul_ < 2 + -- + --; + -- + --INSERT INTO w_affectation_horaire_journalier + --SELECT + -- nextval('w_affectation_horaire_journalier_seq') as affectation_horaire_journalier_id, + -- prod_kelio_absence.salarie_corr, + -- null::bigint AS salarie_id, + -- null::bigint AS contrat_id, + -- null::bigint AS contrat_mois_id, + -- p_calendrier.date AS date, + -- 0 AS debut, + -- 0 AS fin, + -- 0 AS debut_th, + -- 0 AS fin_th, + -- 0 AS pause_th, + -- 0 AS pause_deb_th, + -- 0 AS pause_fin_th, + -- codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS niveaux_code_original, + -- codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS service_code_original, + -- libNiv2 AS entets_code, + -- abrege_ AS abs_cod, + -- (tx_temps / 100.0) * (CASE + -- WHEN mode_cumul_ < 2 AND nb_jour_ouvre = 1 THEN base_horaire_ / (5 * 3600.0) + -- WHEN mode_cumul_ = 2 THEN base_horaire_ / (7 * 3600.0) + -- ELSE 0 END) AS temps_du_initial, + -- (tx_temps / 100.0) * (CASE + -- WHEN mode_cumul_ < 2 AND nb_jour_ouvre = 1 THEN base_horaire_ / (5 * 3600.0) + -- WHEN mode_cumul_ = 2 THEN base_horaire_ / (7 * 3600.0) + -- ELSE 0 END) AS temps_du, + -- 0 AS temps_valide, + -- (tx_temps / 100.0) * (CASE + -- WHEN mode_cumul_ < 2 AND nb_jour_ouvre = 1 THEN base_horaire_ / (5 * 3600.0) + -- WHEN mode_cumul_ = 2 THEN base_horaire_ / (7 * 3600.0) + -- ELSE 0 END) AS temps_absence + -- FROM prod_kelio_absence + -- JOIN base.p_calendrier ON p_calendrier.date BETWEEN absence_date_debut_ AND + -- CASE WHEN absence_date_fin_ IS NOT NULL THEN absence_date_fin_ ELSE absence_date_debut_ + (absence_nbre_jours_abs_ || 'days')::interval END + -- JOIN base.v_calendrier_indicateurs_1 ON v_calendrier_indicateurs_1.date = p_calendrier.date + -- LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = prod_kelio_absence.salarie_ AND p_calendrier.date BETWEEN w_histo_ser.debut_ and w_histo_ser.fin_ + -- LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + -- JOIN prod_kelio.affectation_duree_travail ON salarie_g_t_p_ = prod_kelio_absence.salarie_ and p_calendrier.date BETWEEN affectation_duree_travail.date_debut_ AND COALESCE(affectation_duree_travail.date_fin_,'2099-12-31') + -- LEFT JOIN prod_keliod.SCHEDULE_ASSIGNMENT ON employee_identification_number = prod_kelio_absence.salarie_corr + -- AND p_calendrier.date BETWEEN assignment_date and assignment_end_date + -- LEFT JOIN ( + -- SELECT + -- schedule_abbreviation AS tx_code, + -- replace(split_part(regexp_replace(regexp_replace(schedule_description,'[^0-9\.%]','','g'),'[0-9\.]*%([0-9\.]*)%$','\1'),'%',1),'..','')::numeric AS tx_temps + -- FROM + -- prod_keliod.SCHEDULE_ASSIGNMENT GROUP BY 1,2) sub ON tx_code = schedule_abbreviation + -- WHERE absence_heure_fin1_ = 0 AND absence_duree_abs_heures_ = 0 AND mode_cumul_ = 2 + + ; + -- ajout des heures spéciales (pour l'instant heures de pause annulées) + INSERT INTO w_affectation_horaire_journalier + SELECT + nextval('w_affectation_horaire_journalier_seq') as affectation_horaire_journalier_id, + employee_identification_number, + null::bigint AS salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + total_date AS date, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS niveaux_code_original, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS service_code_original, + libNiv2 AS entets_code, + special_hour_type_abbreviation AS abs_cod, + 0 AS temps_du_initial, + hours AS temps_du, + hours AS temps_valide, + 0 AS temps_absence + FROM prod_keliod.ESTIMATED_DAILY_SPEC_HOUR + --LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.code_original = ESTIMATED_DAILY_SPEC_HOUR.section_key + LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = employee_key AND total_date BETWEEN w_histo_ser.debut_ and w_histo_ser.fin_ + LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + WHERE + special_hour_type_abbreviation = 'NBHPA' + ; + + -- Ajout des jours d'absence "blanc" (pas de theorique ni de temps d'absence; typiquement les jours fériés; permet de compter correctement le nombre de jours d'absence). + INSERT INTO w_affectation_horaire_journalier + SELECT + nextval('w_affectation_horaire_journalier_seq') as affectation_horaire_journalier_id, + prod_kelio_absence.salarie_corr as employee_identification_number, + null::bigint AS salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + cal.date AS date, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS niveaux_code_original, + codeNiv1 || '|' || codeNiv2 || '|' || prod_kelio_organigramme.service_ AS service_code_original, + libNiv2 AS entets_code, + abrege_ AS abs_cod, + 0 AS temps_du_initial, + 0 AS temps_du, + 0 AS temps_valide, + 0 AS temps_absence + from prod_kelio_absence + join base.p_calendrier as cal on cal.date between prod_kelio_absence.absence_date_debut_ and prod_kelio_absence.absence_date_fin_ + left join w_affectation_horaire_journalier on true + and w_affectation_horaire_journalier.salarie_corr = prod_kelio_absence.salarie_corr + and w_affectation_horaire_journalier.date = cal.date + LEFT JOIN w_histo_ser ON w_histo_ser.salarie_ = prod_kelio_absence.salarie_ AND cal.date BETWEEN w_histo_ser.debut_ and w_histo_ser.fin_ + LEFT JOIN prod_kelio_organigramme ON prod_kelio_organigramme.service_ = w_histo_ser.service_ + where true + and w_affectation_horaire_journalier.date is null + ; + + DROP TABLE IF EXISTS w_ser; + CREATE TEMP TABLE w_ser AS + SELECT + codeNiv1 || '|' || codeNiv2 || '|' || code_original AS service_code_original, + codeNiv1, + codeNiv2, + codeNiv3, + libNiv1 as niv_cod1, + libNiv2 AS niv_cod2, + codeniv3 AS niv_cod3, + libNiv1 || '-' || libNiv2 || '-' || libniv3 AS texte, + libNiv1 || '-' || libNiv2 || '-' || libniv3 AS texte_court + FROM + prod_kelio_organigramme + + ; + + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + special_hour_type_key, + special_hour_type_abbreviation, + special_hour_type_description, + substr(special_hour_type_description,1,50) + FROM prod_keliod.ESTIMATED_DAILY_SPEC_HOUR + WHERE 1=1 + AND special_hour_type_abbreviation IN (SELECT abs_cod FROM w_affectation_horaire_journalier) + AND special_hour_type_key NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + ]]> + + + + + + + + '2015-01-01' + --AND (ferie IS NULL OR (ferie IS NOT NULL AND jour_travaille_ = 1)) + -- AND (periode_realise.debut_ IS NULL OR (periode_realise.debut_ BETWEEN periode_travail.debut_ AND periode_travail.fin_ + -- OR periode_travail.debut_ BETWEEN periode_realise.debut_ AND periode_realise.fin_ + -- )) + ; + + UPDATE prod_kelio_affectation_horaire_journalier + SET + debut_th = 9, + fin_th = 17, + duree_th = 8, + pause_th = 1, + pause_deb_th = 12, + pause_fin_th = 13 + WHERE + horaire_journalier_ = 35 + ; + + UPDATE prod_kelio_affectation_horaire_journalier + SET + debut = 9, + fin = 17, + duree = 8 + WHERE + calcule_horairehoraire_journal = 35 + ; + ]]> + + + + + + + + + + les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + affectation_horaire_journalier_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_affectation_horaire_journalier + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_affectation_horaire_journalier.salarie_id + and w_affectation_horaire_journalier.date between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + where 1!=1 + OR w_affectation_horaire_journalier.contrat_id is null + OR w_affectation_horaire_journalier.contrat_mois_id is null + group by 1) + UPDATE w_affectation_horaire_journalier SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_affectation_horaire_journalier.affectation_horaire_journalier_id = w_asso.affectation_horaire_journalier_id + ; + + with w_asso as ( + select + affectation_horaire_journalier_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_affectation_horaire_journalier + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_affectation_horaire_journalier.salarie_id + and p_contrats_mois.date_debut > w_affectation_horaire_journalier.date -- Sélection des contrats APRES heures planning. + where 1!=1 + OR w_affectation_horaire_journalier.contrat_id is null + OR w_affectation_horaire_journalier.contrat_mois_id is null + group by 1) + UPDATE w_affectation_horaire_journalier SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_affectation_horaire_journalier.affectation_horaire_journalier_id = w_asso.affectation_horaire_journalier_id + ; + + with w_asso as ( + select + affectation_horaire_journalier_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_affectation_horaire_journalier + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_affectation_horaire_journalier.salarie_id + and p_contrats_mois.date_debut < w_affectation_horaire_journalier.date -- Sélection des contrats AVANT heures planning. + where 1!=1 + OR w_affectation_horaire_journalier.contrat_id is null + OR w_affectation_horaire_journalier.contrat_mois_id is null + group by 1) + UPDATE w_affectation_horaire_journalier SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_affectation_horaire_journalier.affectation_horaire_journalier_id = w_asso.affectation_horaire_journalier_id + ; + + -- Création d'index. + CREATE INDEX w_affectation_horaire_journalier_i_contrat_id ON w_affectation_horaire_journalier USING btree (contrat_id) + ; + CREATE INDEX w_affectation_horaire_journalier_i_contrat_mois_id ON w_affectation_horaire_journalier USING btree (contrat_mois_id) + ; + CREATE INDEX w_affectation_horaire_journalier_i_date ON w_affectation_horaire_journalier USING btree (date) + ; + CREATE INDEX w_affectation_horaire_journalier_i_salarie_id ON w_affectation_horaire_journalier USING btree (salarie_id) + ; + + + -- Màj des niveauxx du Planning. + INSERT INTO rh.t_planning_niveau(code_original, code, texte, texte_court) + SELECT + service_code_original, + service_code_original, + texte, + texte_court + FROM w_ser + WHERE service_code_original NOT IN (SELECT code_original FROM rh.t_planning_niveau WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + + -- Alimentation des tables de paramètres. + -- Màj des Services du Planning. + INSERT INTO rh.t_planning_service(code_original, code, texte, texte_court, service_id) + SELECT + service_code_original, + service_code_original, + texte, + texte_court, + 0 as service_id + FROM w_ser + WHERE service_code_original NOT IN (SELECT code_original FROM rh.t_planning_service WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des Types d'absences du Planning. + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + absence_motif_absence_, + abrege_, + libelle_, + substr(libelle_,1,50) + FROM prod_kelio_absence AS absence + WHERE 1=1 + AND abrege_ IN (SELECT abs_cod FROM w_affectation_horaire_journalier) + AND absence_motif_absence_ NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Création d'une table Entreprise/Etablissement. + DROP TABLE IF EXISTS w_entets + ; + + CREATE TEMP TABLE w_entets AS -- manque SSI, DG et HAD à reventiler correctement + select + ets.oid as etablissement_id, + ent.planning_code||ets.planning_code as entets_code + from rh.t_entreprises as ent + join rh.t_etablissements as ets on ets.entreprise_id = ent.oid + Where 1=1 + and ent.oid != 0 + and ets.oid != 0 + ; + + -- suppression du planning si employé parti + DELETE FROM w_affectation_horaire_journalier + USING rh.p_salaries + WHERE p_salaries.oid = salarie_id + AND date > date_sortie_ets + ; + + ]]> + + + + + établissement. + + UPDATE w_affectation_horaire_journalier SET + entets_code = 'HSB' + WHERE entets_code in ('DG', 'HAD', 'SSIAB') + ; + + -- Alimentation de la table de mouvement. + TRUNCATE rh.p_planning_mouvement + ; + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + date, + to_char(w_affectation_horaire_journalier.date, 'IYYYIW'::text)::numeric AS semaine, + to_char(w_affectation_horaire_journalier.date, 'YYYYMM'::text)::numeric AS mois, + coalesce(w_entets.etablissement_id, 0) as etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) as niveau_id, + CASE WHEN date < now() THEN temps_du ELSE 0 END, + temps_du_initial::numeric, + CASE WHEN date < now() THEN temps_valide ELSE 0 END, + CASE WHEN date < now() THEN temps_absence ELSE 0 END + FROM w_affectation_horaire_journalier + LEFT JOIN rh.t_planning_niveau ON t_planning_niveau.code_original = w_affectation_horaire_journalier.niveaux_code_original + LEFT JOIN rh.t_planning_service ON t_planning_service.code_original = w_affectation_horaire_journalier.service_code_original + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = 0 + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code = w_affectation_horaire_journalier.abs_cod + LEFT JOIN w_entets ON w_entets.entets_code = w_affectation_horaire_journalier.entets_code + WHERE salarie_id IS NOT NULL + ; + + ]]> + + + + + + + on prend celles de la rh + INSERT INTO rh.t_planning_qualification (code, code_original, texte, texte_court) + SELECT code, 'K_'||code_original, texte, texte_court + FROM rh.t_qualifications + WHERE 1=1 + AND 'K_'||t_qualifications.code_original NOT IN (SELECT code_original FROM rh.t_planning_qualification) + AND t_qualifications.oid != 0 + ; + + UPDATE rh.p_planning_mouvement SET + qualification_id = t_planning_qualification.oid + FROM + (SELECT + p_contrats_mois.salarie_id, + date_debut, + date_fin, + 'K_'||qualification_code_original as planning_qualification_code_original + FROM + rh.p_contrats_mois + join rh.p_profil_contrat_mois on contrat_mois_id = p_contrats_mois.oid + join rh.p_profils on p_profil_contrat_mois.profil_id = p_profils.oid + GROUP BY 1,2,3,4 + ) sub, + rh.t_planning_qualification + WHERE 1=1 + AND sub.planning_qualification_code_original = t_planning_qualification.code_original + AND p_planning_mouvement.salarie_id = sub.salarie_id + AND date BETWEEN date_debut AND date_fin + ; + + ]]> + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_OCTIME.XML b/import_rh/iCTI_import_planning_OCTIME.XML new file mode 100644 index 0000000..f17912d --- /dev/null +++ b/import_rh/iCTI_import_planning_OCTIME.XML @@ -0,0 +1,2974 @@ + + + + + + 0 + FROM information_schema.tables + WHERE 1=1 + AND table_schema = 'prod_octime' + ; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + FROM information_schema.tables + WHERE 1=1 + AND table_schema = 'prod_octime2' + AND table_name LIKE 'cptres1%' + ; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + FROM information_schema.tables + WHERE 1=1 + AND table_schema = 'prod_octime_saas' + AND table_name LIKE 'cptres1%' + ; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + FROM information_schema.tables + WHERE 1=1 + AND table_schema = 'prod_octime' + ; + ]]> + + + + + + 0 + FROM information_schema.tables + WHERE 1=1 + AND table_schema = 'prod_octime2' + AND table_name LIKE 'cptres1%' + ; + + ]]> + + + + 0 + FROM information_schema.tables + WHERE 1=1 + AND table_schema = 'prod_octime_saas' + AND table_name LIKE 'cptres1%' + ; + + ]]> + + + + + + + + + 0 -- il faut que le matricule de paie Octime contienne INT. + ELSE true END + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13, 15,16,17,18,19,20,21,22,23,24,25,26 + ; + + -- Alimenter le champ prod_octime_cptres1.salarie_corr pour les intérim qui n'auraient pas été préfixés par le code ent/ets comme les matricules salariés. + UPDATE prod_octime_cptres1 SET + salarie_corr = (SELECT trim(valeur) FROM rh.t_divers WHERE code = 'OCTIME_INTERIM_PREFIXE')||coalesce(nullif(pers.pers_matp, ''), pers.pers_mat) + FROM prod_octime_pers AS pers, w_salaries + WHERE 1=1 + AND prod_octime_cptres1.pers_mat = pers.pers_mat + AND prod_octime_cptres1.pers_mat = w_salaries.pers_mat -- uniquement les intérimaires. + AND salarie_corr = '' -- uniquement les données pas déjà mis à jour. + AND (SELECT trim(valeur) != '' FROM rh.t_divers WHERE code = 'OCTIME_INTERIM_PREFIXE') -- uniquement si un paramétrage a été fait. + ; + + ]]> + + + + + + + + + + + + + + ADP. + WHEN 11 THEN -- Cas 11 - NIR. avec gestion de l'interim sans NIR + CASE WHEN cont_cod = (select valeur from rh.t_divers where code = 'INTERIM_CNT_CODE') + THEN coalesce(nullif(pers.pers_matp, ''), pers.pers_mat) + ELSE pers.pers_nsecu + END + ELSE coalesce(nullif(pers.pers_matp, ''), pers.pers_mat) -- Par défaut. + END + FROM prod_octime_pers AS pers + WHERE 1=1 + AND prod_octime_cptres1.pers_mat = pers.pers_mat + AND salarie_corr = '' -- uniquement les données pas déjà mis à jour (cf. interim plus haut). + ; + + -- Recensement des salariés et établissements. + DROP TABLE IF EXISTS w_sal_pla + ; + CREATE TEMP TABLE w_sal_pla AS + SELECT + p_salaries.oid AS salarie_id, + p_salaries.nir, + p_salaries.matricule, + p_salaries.date_debut as sal_date_debut, -- utilisé lorsque + p_salaries.date_fin as sal_date_fin, + p_salaries.matricule_planning as matricule_paie_planning, -- Matricule planning saisi dans la paie. + t_entreprises.code_original AS entreprise_code_original, + t_etablissements.code_original AS etablissement_code_original, + t_entreprises.code AS entreprise_code, + t_entreprises.planning_code AS entreprise_planning_code, + t_etablissements.code AS etablissement_code, + t_etablissements.planning_code as etablissement_planning_code, -- Pour cas 3 Sage + lpad(t_entreprises.code, 3, '0') || lpad(t_etablissements.code, 3, '0') || p_salaries.matricule AS matricule_planning, -- Pour cas 2 SHS + lpad(t_entreprises.planning_code, 3, '0') || lpad(t_etablissements.planning_code, 3, '0') || substr(p_salaries.matricule, 1, 5) AS matricule_planning_conso, -- Pour cas 5 SHS consolidé + ltrim(p_salaries.matricule, '0') AS matricule_trim, -- Pour cas 1 Cegid + rank() over (partition by p_salaries.nir order by p_salaries.date_fin desc) as rang, -- Lorsque stratégie basée sur le NIR, permet d'identifier les doublons. + ''::text AS salarie_corr + FROM rh.p_salaries + -- Il faut absoluement faire le produit cartésien matricule/établissement même si un salarié n'a jamais travaillé dans un des établissement. + -- En effet, cela pourrait être le cas dans Octime et ce traitement pourrait ne pas remonter les données associées. + JOIN rh.t_entreprises ON t_entreprises.oid = p_salaries.entreprise_id + JOIN rh.t_etablissements ON t_etablissements.entreprise_id = p_salaries.entreprise_id + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_ID') AS octime_ets_id ON 1=1 + WHERE 1=1 + AND salarie_fusionne_id = 0 + -- Uniquement les établissements avec planning_code renseigné dans le cas où l'établissement est en mode manuel. + AND CASE WHEN octime_ets_id.valeur = 0 THEN nullif(trim(t_etablissements.planning_code), '') IS NOT NULL ELSE TRUE END + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + ORDER BY 1,2,3 + ; + + -- Stratégie basée sur le NIR : suppression des salariés en doublons. + DELETE FROM w_sal_pla + WHERE 1=1 + and (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SALARIE') = 11 + and rang > 1 + ; + + -- Gestion des salariés fusionnés. + INSERT INTO w_sal_pla + SELECT + w_sal_pla.salarie_id, + p_salaries.nir, + p_salaries.matricule, + w_sal_pla.sal_date_debut, + w_sal_pla.sal_date_fin, + p_salaries.matricule_planning as matricule_paie_planning, + w_sal_pla.entreprise_code_original, + w_sal_pla.etablissement_code_original, + w_sal_pla.entreprise_code, + w_sal_pla.entreprise_planning_code, + w_sal_pla.etablissement_code, + w_sal_pla.etablissement_planning_code, + lpad(w_sal_pla.entreprise_code, 3, '0') || lpad(w_sal_pla.etablissement_code, 3, '0') || p_salaries.matricule AS matricule_planning, + lpad(w_sal_pla.entreprise_planning_code, 3, '0') || lpad(w_sal_pla.etablissement_planning_code, 3, '0') || substr(p_salaries.matricule, 1, 5) AS matricule_planning_conso, + ltrim(p_salaries.matricule, '0') AS matricule_trim, + 1 as rang, + ''::text AS salarie_corr + FROM w_sal_pla + JOIN rh.p_salaries ON salarie_fusionne_id = w_sal_pla.salarie_id + WHERE salarie_fusionne_id != 0 + ; + + -- #CORRECTION SHS lorsque le code établissement contient un tiret, utiliser son code original uniquement pour matricule_planning. + UPDATE w_sal_pla SET + matricule_planning = etablissement_code_original || matricule + WHERE etablissement_code LIKE '%-%' + ; + + -- Alimenter le champ w_sal_pla.salarie_corr. + UPDATE w_sal_pla SET + salarie_corr = + CASE (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SALARIE') + WHEN 1 THEN matricule_trim + WHEN 2 THEN matricule_planning + WHEN 5 THEN matricule_planning_conso + WHEN 3 THEN etablissement_planning_code||'|'||matricule + -- Le cas 6 nécessite le paramétrage du planning_code pour l'établissement et éventuellement l'entreprise. + -- Pour le cas "010000002631K", on peut paramétrer ent. à "01000" et ets. à "000". + WHEN 6 THEN entreprise_planning_code||etablissement_planning_code||matricule + -- Le cas 9 utilise la matricule planning saisi dans la paie. + WHEN 9 THEN matricule_paie_planning + WHEN 10 THEN case when substr(matricule, 1 , 4) = '0000' then (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_OLDMAT_PREFIXE')||matricule_trim else matricule end -- Cas 10 - Fusion QuadraRH -> ADP. + WHEN 11 THEN nir -- Cas 11 : NIR + -- Les cas 4, 7 et 8 ne nécessitent pas de transformation du matricule issu de la paie. + ELSE matricule + END + ; + + -- Création d'index. + CREATE INDEX w_sal_pla_i_matricule ON w_sal_pla USING btree (matricule) + ; + CREATE INDEX w_sal_pla_i_matricule_planning ON w_sal_pla USING btree (matricule_planning) + ; + CREATE INDEX w_sal_pla_i_matricule_trim ON w_sal_pla USING btree (matricule_trim) + ; + + DROP SEQUENCE IF EXISTS w_cptres1_seq + ; + + CREATE TEMP SEQUENCE w_cptres1_seq + ; + + DROP TABLE IF EXISTS w_cptres1 + ; + + CREATE TEMP TABLE w_cptres1 AS + SELECT + nextval('w_cptres1_seq') as cptres1_id, + prod_octime_cptres1.salarie_corr, + w_sal_pla.salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(cal_dat) AS date, + pos_cod, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + CASE octime_max_niveau.valeur + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS niveau_code_original, + CASE octime_service_id.valeur + WHEN 1 THEN niv_cod1 + WHEN 2 THEN niv_cod1 || '|' || niv_cod2 + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS service_code_original, + CASE octime_ets_id.valeur + WHEN 0 THEN octime_ets_manuel.valeur + WHEN 1 THEN niv_cod1 -- cas AHO + WHEN 2 THEN niv_cod2 + WHEN 3 THEN niv_cod3 + WHEN 4 THEN CASE WHEN octime_max_niveau.valeur = '3' THEN left(prod_octime_cptres1.pers_mat, -5) ELSE niv_cod4 END -- cas Fondation Hopale avec OCTIME_MAX_NIVEAU positionné par défaut sur 3. + WHEN 9 THEN left(prod_octime_cptres1.pers_mat, -5) -- cas Fondation Hopale + END AS entets_code, + ''::text AS abs_cod, + hor_cod, -- code horaire. + cal_val2/60.00 AS temps_du_initial, + cal_val3/60.00 AS temps_du, + CASE tps_valide.valeur WHEN '6' THEN cal_val6 ELSE cal_val5 END/60.00 AS temps_valide, + 0::numeric AS temps_absence, + 0 AS temps_hs, + 0 AS temps_hc + FROM prod_octime_cptres1 + JOIN w_sal_pla ON w_sal_pla.salarie_corr = prod_octime_cptres1.salarie_corr + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_TPS_VALIDE') AS tps_valide ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SERVICE_ID') AS octime_service_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_ID') AS octime_ets_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_MANUEL') AS octime_ets_manuel ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_MAX_NIVEAU') AS octime_max_niveau ON 1=1 + WHERE 1!=1 + OR cal_val2 != 0 + OR cal_val3 != 0 + OR CASE tps_valide.valeur WHEN '6' THEN cal_val6 ELSE cal_val5 END != 0 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + prod_octime_cptres1.salarie_corr, + w_sal_pla.salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(cal_dat) AS date, + pos_cod, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + CASE octime_max_niveau.valeur + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS niveau_code_original, + CASE octime_service_id.valeur + WHEN 1 THEN niv_cod1 + WHEN 2 THEN niv_cod1 || '|' || niv_cod2 + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS service_code_original, + CASE octime_ets_id.valeur + WHEN 0 THEN octime_ets_manuel.valeur + WHEN 1 THEN niv_cod1 -- cas AHO + WHEN 2 THEN niv_cod2 + WHEN 3 THEN niv_cod3 + WHEN 4 THEN CASE WHEN octime_max_niveau.valeur = '3' THEN left(prod_octime_cptres1.pers_mat, -5) ELSE niv_cod4 END -- cas Fondation Hopale avec OCTIME_MAX_NIVEAU positionné par défaut sur 3. + WHEN 9 THEN left(prod_octime_cptres1.pers_mat, -5) -- cas Fondation Hopale + END AS entets_code, + cal_val24 AS abs_cod, + hor_cod, -- code horaire. + 0 AS temps_du, + 0 AS temps_du_initial, + 0 AS temps_valide, + cal_val21/60.00 AS temps_absence, + 0 AS temps_hs, + 0 AS temps_hc + FROM prod_octime_cptres1 + JOIN w_sal_pla ON w_sal_pla.salarie_corr = prod_octime_cptres1.salarie_corr + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SERVICE_ID') AS octime_service_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_ID') AS octime_ets_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_MANUEL') AS octime_ets_manuel ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_MAX_NIVEAU') AS octime_max_niveau ON 1=1 + WHERE cal_val21 != 0 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + prod_octime_cptres1.salarie_corr, + w_sal_pla.salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(cal_dat) AS date, + pos_cod, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + CASE octime_max_niveau.valeur + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS niveau_code_original, + CASE octime_service_id.valeur + WHEN 1 THEN niv_cod1 + WHEN 2 THEN niv_cod1 || '|' || niv_cod2 + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS service_code_original, + CASE octime_ets_id.valeur + WHEN 0 THEN octime_ets_manuel.valeur + WHEN 1 THEN niv_cod1 -- cas AHO + WHEN 2 THEN niv_cod2 + WHEN 3 THEN niv_cod3 + WHEN 4 THEN CASE WHEN octime_max_niveau.valeur = '3' THEN left(prod_octime_cptres1.pers_mat, -5) ELSE niv_cod4 END -- cas Fondation Hopale avec OCTIME_MAX_NIVEAU positionné par défaut sur 3. + WHEN 9 THEN left(prod_octime_cptres1.pers_mat, -5) -- cas Fondation Hopale + END AS entets_code, + cal_val25 AS abs_cod, + hor_cod, -- code horaire. + 0 AS temps_du, + 0 AS temps_du_initial, + 0 AS temps_valide, + cal_val22/60.00 AS temps_absence, + 0 AS temps_hs, + 0 AS temps_hc + FROM prod_octime_cptres1 + JOIN w_sal_pla ON w_sal_pla.salarie_corr = prod_octime_cptres1.salarie_corr + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SERVICE_ID') AS octime_service_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_ID') AS octime_ets_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_MANUEL') AS octime_ets_manuel ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_MAX_NIVEAU') AS octime_max_niveau ON 1=1 + WHERE cal_val22 != 0 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + prod_octime_cptres1.salarie_corr, + w_sal_pla.salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(cal_dat) AS date, + pos_cod, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + CASE octime_max_niveau.valeur + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS niveau_code_original, + CASE octime_service_id.valeur + WHEN 1 THEN niv_cod1 + WHEN 2 THEN niv_cod1 || '|' || niv_cod2 + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS service_code_original, + CASE octime_ets_id.valeur + WHEN 0 THEN octime_ets_manuel.valeur + WHEN 1 THEN niv_cod1 -- cas AHO + WHEN 2 THEN niv_cod2 + WHEN 3 THEN niv_cod3 + WHEN 4 THEN CASE WHEN octime_max_niveau.valeur = '3' THEN left(prod_octime_cptres1.pers_mat, -5) ELSE niv_cod4 END -- cas Fondation Hopale avec OCTIME_MAX_NIVEAU positionné par défaut sur 3. + WHEN 9 THEN left(prod_octime_cptres1.pers_mat, -5) -- cas Fondation Hopale + END AS entets_code, + cal_val26 AS abs_cod, + hor_cod, -- code horaire. + 0 AS temps_du, + 0 AS temps_du_initial, + 0 AS temps_valide, + cal_val23/60.00 AS temps_absence, + 0 AS temps_hs, + 0 AS temps_hc + FROM prod_octime_cptres1 + JOIN w_sal_pla ON w_sal_pla.salarie_corr = prod_octime_cptres1.salarie_corr + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SERVICE_ID') AS octime_service_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_ID') AS octime_ets_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_MANUEL') AS octime_ets_manuel ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_MAX_NIVEAU') AS octime_max_niveau ON 1=1 + WHERE cal_val23 != 0 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + prod_octime_cptres1.salarie_corr, + w_sal_pla.salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(cal_dat) AS date, + pos_cod, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + CASE octime_max_niveau.valeur + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS niveau_code_original, + CASE octime_service_id.valeur + WHEN 1 THEN niv_cod1 + WHEN 2 THEN niv_cod1 || '|' || niv_cod2 + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS service_code_original, + CASE octime_ets_id.valeur + WHEN 0 THEN octime_ets_manuel.valeur + WHEN 1 THEN niv_cod1 -- cas AHO + WHEN 2 THEN niv_cod2 + WHEN 3 THEN niv_cod3 + WHEN 4 THEN CASE WHEN octime_max_niveau.valeur = '3' THEN left(prod_octime_cptres1.pers_mat, -5) ELSE niv_cod4 END -- cas Fondation Hopale avec OCTIME_MAX_NIVEAU positionné par défaut sur 3. + WHEN 9 THEN left(prod_octime_cptres1.pers_mat, -5) -- cas Fondation Hopale + END AS entets_code, + cal_val26 AS abs_cod, + hor_cod, -- code horaire. + 0 AS temps_du, + 0 AS temps_du_initial, + 0 AS temps_valide, + 0 AS temps_absence, + cal_val387/60.0 AS temps_hs, + 0 AS temps_hc + FROM prod_octime_cptres1 + JOIN w_sal_pla ON w_sal_pla.salarie_corr = prod_octime_cptres1.salarie_corr + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SERVICE_ID') AS octime_service_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_ID') AS octime_ets_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_MANUEL') AS octime_ets_manuel ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_MAX_NIVEAU') AS octime_max_niveau ON 1=1 + WHERE cal_val387 != 0 + ; + + INSERT INTO w_cptres1 + SELECT + nextval('w_cptres1_seq') as cptres1_id, + prod_octime_cptres1.salarie_corr, + w_sal_pla.salarie_id, + null::bigint AS contrat_id, + null::bigint AS contrat_mois_id, + date(cal_dat) AS date, + pos_cod, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + CASE octime_max_niveau.valeur + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS niveau_code_original, + CASE octime_service_id.valeur + WHEN 1 THEN niv_cod1 + WHEN 2 THEN niv_cod1 || '|' || niv_cod2 + WHEN 3 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 + WHEN 4 THEN niv_cod1 || '|' || niv_cod2 || '|' || niv_cod3 || '|' || niv_cod4 + END AS service_code_original, + CASE octime_ets_id.valeur + WHEN 0 THEN octime_ets_manuel.valeur + WHEN 1 THEN niv_cod1 -- cas AHO + WHEN 2 THEN niv_cod2 + WHEN 3 THEN niv_cod3 + WHEN 4 THEN CASE WHEN octime_max_niveau.valeur = '3' THEN left(prod_octime_cptres1.pers_mat, -5) ELSE niv_cod4 END -- cas Fondation Hopale avec OCTIME_MAX_NIVEAU positionné par défaut sur 3. + WHEN 9 THEN left(prod_octime_cptres1.pers_mat, -5) -- cas Fondation Hopale + END AS entets_code, + cal_val26 AS abs_cod, + hor_cod, -- code horaire. + 0 AS temps_du, + 0 AS temps_du_initial, + 0 AS temps_valide, + 0 AS temps_absence, + 0 AS temps_hs, + cal_val388/60.0 AS temps_hc + FROM prod_octime_cptres1 + JOIN w_sal_pla ON w_sal_pla.salarie_corr = prod_octime_cptres1.salarie_corr + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SERVICE_ID') AS octime_service_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_ID') AS octime_ets_id ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_ETS_MANUEL') AS octime_ets_manuel ON 1=1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_MAX_NIVEAU') AS octime_max_niveau ON 1=1 + WHERE cal_val388 != 0 + ; + + -- Permet de s'assurer que le Niveau Planning non renseigné sera bien celui avec l'OID 0. + UPDATE w_cptres1 SET + niveau_code_original = '' + WHERE niveau_code_original = '||' + ; + + VACUUM ANALYSE w_cptres1 + ; + + -- Association aux contrats et contrat_mois. + -- En général, les heures planning sont effectuées AVANT un contrat/paie à cause du décallage avec la paie : + -- => les heures effectuées en fin de mois sont à associer avec le mois suivant. + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and w_cptres1.date between p_contrats_mois.date_debut and p_contrats_mois.date_fin -- Sélection des contrats pendant heures planning. + where 1!=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (min(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut > w_cptres1.date -- Sélection des contrats APRES heures planning. + where 1!=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + with w_asso as ( + select + cptres1_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_cptres1 + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_cptres1.salarie_id + and p_contrats_mois.date_debut < w_cptres1.date -- Sélection des contrats AVANT heures planning. + where 1!=1 + OR w_cptres1.contrat_id is null + OR w_cptres1.contrat_mois_id is null + group by 1) + UPDATE w_cptres1 SET + contrat_id = w_asso.contrat_id, + contrat_mois_id = w_asso.contrat_mois_id + FROM w_asso + WHERE w_cptres1.cptres1_id = w_asso.cptres1_id + ; + + -- Création d'index. + CREATE INDEX w_cptres1_i_contrat_id ON w_cptres1 USING btree (contrat_id) + ; + CREATE INDEX w_cptres1_i_contrat_mois_id ON w_cptres1 USING btree (contrat_mois_id) + ; + CREATE INDEX w_cptres1_i_date ON w_cptres1 USING btree (date) + ; + CREATE INDEX w_cptres1_i_salarie_id ON w_cptres1 USING btree (salarie_id) + ; + + -- Alimentation des tables de paramètres. + -- Màj des Services du Planning. + INSERT INTO rh.t_planning_service(code_original, code, texte, texte_court, service_id) + with w_cptres1_tmp as ( + select + service_code_original, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + octime_service_id.valeur + from w_cptres1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_SERVICE_ID') AS octime_service_id ON 1=1 + group by 1,2,3,4,5,6) + SELECT + w_cptres1.service_code_original, + w_cptres1.service_code_original, + coalesce(niv1.niv_lib1, w_cptres1.niv_cod1)||case when valeur >= 2 THEN ' - '||coalesce(niv2.niv_lib2, w_cptres1.niv_cod2) ELSE '' END||CASE WHEN valeur >= 3 THEN ' - '||coalesce(niv3.niv_lib3, w_cptres1.niv_cod3) ELSE '' END||CASE WHEN valeur >= 4 THEN ' - '||coalesce(niv4.niv_lib4, w_cptres1.niv_cod4) ELSE '' END, + substr(coalesce(niv1.niv_lib1, w_cptres1.niv_cod1)||case when valeur >= 2 THEN ' - '||coalesce(niv2.niv_lib2, w_cptres1.niv_cod2) ELSE '' END||CASE WHEN valeur >= 3 THEN ' - '||coalesce(niv3.niv_lib3, w_cptres1.niv_cod3) ELSE '' END||CASE WHEN valeur >= 4 THEN ' - '||coalesce(niv4.niv_lib4, w_cptres1.niv_cod4) ELSE '' END, 1, 50), + 0 as service_id + FROM w_cptres1_tmp as w_cptres1 + LEFT JOIN prod_octime_niveau1 as niv1 ON niv1.niv_cod1 = w_cptres1.niv_cod1 + LEFT JOIN prod_octime_niveau2 as niv2 ON 1=1 + AND niv2.niv_cod1 = w_cptres1.niv_cod1 + AND niv2.niv_cod2 = w_cptres1.niv_cod2 + LEFT JOIN prod_octime_niveau3 as niv3 ON 1=1 + AND niv3.niv_cod1 = w_cptres1.niv_cod1 + AND niv3.niv_cod2 = w_cptres1.niv_cod2 + AND niv3.niv_cod3 = w_cptres1.niv_cod3 + LEFT JOIN prod_octime_niveau4 as niv4 ON 1=1 + AND niv4.niv_cod1 = w_cptres1.niv_cod1 + AND niv4.niv_cod2 = w_cptres1.niv_cod2 + AND niv4.niv_cod3 = w_cptres1.niv_cod3 + AND niv4.niv_cod4 = w_cptres1.niv_cod4 + WHERE w_cptres1.service_code_original NOT IN (SELECT code_original FROM rh.t_planning_service WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des Niveaux du Planning. + DROP TABLE IF EXISTS w_nivpla + ; + + CREATE TEMP TABLE w_nivpla AS + with w_cptres1_tmp as ( + select + niveau_code_original, + niv_cod1, + niv_cod2, + niv_cod3, + niv_cod4, + octime_max_niveau.valeur as octime_max_niveau + from w_cptres1 + JOIN (SELECT valeur FROM rh.t_divers WHERE code = 'OCTIME_MAX_NIVEAU') AS octime_max_niveau ON 1=1 + group by 1,2,3,4,5,6) + SELECT + w_cptres1.niveau_code_original, + coalesce(niv1.niv_lib1, w_cptres1.niv_cod1)||' -|- '||coalesce(niv2.niv_lib2, w_cptres1.niv_cod2)||' -|- '||coalesce(niv3.niv_lib3, w_cptres1.niv_cod3)||case when octime_max_niveau = 4 then ' -|- '||coalesce(niv4.niv_lib4, w_cptres1.niv_cod4) else '' end as niv_txt, + substr(coalesce(niv1.niv_lib1, w_cptres1.niv_cod1)||' -|- '||coalesce(niv2.niv_lib2, w_cptres1.niv_cod2)||' -|- '||coalesce(niv3.niv_lib3, w_cptres1.niv_cod3)||case when octime_max_niveau = 4 then ' -|- '||coalesce(niv4.niv_lib4, w_cptres1.niv_cod4) else '' end, 1, 50) as niv_txt_crt + FROM w_cptres1_tmp as w_cptres1 + LEFT JOIN prod_octime_niveau1 as niv1 ON niv1.niv_cod1 = w_cptres1.niv_cod1 + LEFT JOIN prod_octime_niveau2 as niv2 ON 1=1 + AND niv2.niv_cod1 = w_cptres1.niv_cod1 + AND niv2.niv_cod2 = w_cptres1.niv_cod2 + LEFT JOIN prod_octime_niveau3 as niv3 ON 1=1 + AND niv3.niv_cod1 = w_cptres1.niv_cod1 + AND niv3.niv_cod2 = w_cptres1.niv_cod2 + AND niv3.niv_cod3 = w_cptres1.niv_cod3 + LEFT JOIN prod_octime_niveau4 as niv4 ON 1=1 + AND niv4.niv_cod1 = w_cptres1.niv_cod1 + AND niv4.niv_cod2 = w_cptres1.niv_cod2 + AND niv4.niv_cod3 = w_cptres1.niv_cod3 + AND niv4.niv_cod4 = w_cptres1.niv_cod4 + WHERE 1=1 + AND niveau_code_original != '' + GROUP BY 1,2,3 + ; + + -- Màj des libellés uniquement. + UPDATE rh.t_planning_niveau SET + texte = niv_txt, + texte_court = niv_txt_crt + FROM w_nivpla + WHERE 1=1 + AND t_planning_niveau.code_original = w_nivpla.niveau_code_original + AND (1!=1 + OR t_planning_niveau.texte IS DISTINCT FROM w_nivpla.niv_txt + OR t_planning_niveau.texte_court IS DISTINCT FROM w_nivpla.niv_txt_crt) + ; + + -- Insertion des nouveaux niveaux de planning. + INSERT INTO rh.t_planning_niveau(code_original, code, texte, texte_court) + SELECT + w_nivpla.niveau_code_original, + w_nivpla.niveau_code_original, + w_nivpla.niv_txt, + w_nivpla.niv_txt_crt + FROM w_nivpla + JOIN w_cptres1 ON w_cptres1.niveau_code_original = w_nivpla.niveau_code_original + WHERE w_nivpla.niveau_code_original NOT IN (SELECT code_original FROM rh.t_planning_niveau WHERE code_original IS NOT NULL GROUP BY 1) + GROUP BY 1,2,3,4 + ; + + -- Màj des Qualifications du Planning. + INSERT INTO rh.t_planning_qualification(code_original, code, texte, texte_court) + SELECT + pos_cod, + pos_cod, + pos_lib, + pos_lib + FROM prod_octime_poste AS poste + WHERE 1=1 + AND pos_cod IN (SELECT pos_cod FROM w_cptres1) + AND pos_cod NOT IN (SELECT code_original FROM rh.t_planning_qualification WHERE code_original IS NOT NULL) + ; + + -- Màj des Types d'absences du Planning. + INSERT INTO rh.t_planning_type_absence(code_original, code, texte, texte_court) + SELECT + abs_cod, + abs_cod, + abs_lib, + abs_lib + FROM prod_octime_absence AS absence + WHERE 1=1 + AND abs_cod IN (SELECT abs_cod FROM w_cptres1) + AND abs_cod NOT IN (SELECT code_original FROM rh.t_planning_type_absence WHERE code_original IS NOT NULL) + ; + + -- Màj des Codes Horaires du Planning. + INSERT INTO rh.t_planning_code_horaire(code_original, code, texte, texte_court) + SELECT + hor_cod, + hor_abr, + substr(hor_dmis, 1, 2)||'h'||substr(hor_dmis, 3, 2)||'-'||substr(hor_fmis, 1, 2)||'h'||substr(hor_fmis, 3, 2)||' ('||substr(hor_tmis, 1, 2)||':'||substr(hor_tmis, 3, 2)||')', + substr(substr(hor_dmis, 1, 2)||'h'||substr(hor_dmis, 3, 2)||'-'||substr(hor_fmis, 1, 2)||'h'||substr(hor_fmis, 3, 2)||' ('||substr(hor_tmis, 1, 2)||':'||substr(hor_tmis, 3, 2)||')', 1, 50) + FROM prod_octime_cjourn AS cjourn + WHERE 1=1 + AND hor_cod IN (SELECT hor_cod FROM w_cptres1) + AND hor_cod NOT IN (SELECT code_original FROM rh.t_planning_code_horaire WHERE code_original IS NOT NULL) + ; + + -- Forçage des libellés et codes horaires lorsqu'ils sautent + UPDATE rh.t_planning_code_horaire + SET code = hor_abr, + texte = substr(hor_dmis, 1, 2)||'h'||substr(hor_dmis, 3, 2)||'-'||substr(hor_fmis, 1, 2)||'h'||substr(hor_fmis, 3, 2)||' ('||substr(hor_tmis, 1, 2)||':'||substr(hor_tmis, 3, 2)||')', + texte_court = substr(substr(hor_dmis, 1, 2)||'h'||substr(hor_dmis, 3, 2)||'-'||substr(hor_fmis, 1, 2)||'h'||substr(hor_fmis, 3, 2)||' ('||substr(hor_tmis, 1, 2)||':'||substr(hor_tmis, 3, 2)||')', 1, 50) + FROM prod_octime_cjourn AS cjourn + WHERE code_original = hor_cod AND + (code <> hor_abr OR + texte <> substr(hor_dmis, 1, 2)||'h'||substr(hor_dmis, 3, 2)||'-'||substr(hor_fmis, 1, 2)||'h'||substr(hor_fmis, 3, 2)||' ('||substr(hor_tmis, 1, 2)||':'||substr(hor_tmis, 3, 2)||')' OR + texte_court <> substr(substr(hor_dmis, 1, 2)||'h'||substr(hor_dmis, 3, 2)||'-'||substr(hor_fmis, 1, 2)||'h'||substr(hor_fmis, 3, 2)||' ('||substr(hor_tmis, 1, 2)||':'||substr(hor_tmis, 3, 2)||')', 1, 50)) + ; + + -- Création d'une table Entreprise/Etablissement. + DROP TABLE IF EXISTS w_entets + ; + + CREATE TEMP TABLE w_entets AS + select + max(ent.oid) as entreprise_id, + max(ets.oid) as etablissement_id, + ent.planning_code||ets.planning_code as entets_code + from rh.t_entreprises as ent + join rh.t_etablissements as ets on ets.entreprise_id = ent.oid + Where 1=1 + and ent.oid != 0 + and ets.oid != 0 + GROUP BY ent.planning_code||ets.planning_code + ; + + -- Ajout de l'établissement en cours si la valeur de OCTIME_REPRISE_HISTO est à 1 (reprise de l'histo paramétré) car le max renvoi l'établissement historique + WITH w_ets_encours_reprise_histo AS + (SELECT ent.oid as entreprise_id, + ets.oid as etablissement_id, + ent.planning_code||ets.planning_code as entets_code + FROM rh.t_entreprises as ent + JOIN rh.t_etablissements as ets on ets.entreprise_id = ent.oid + JOIN rh.t_divers ON t_divers.code IN ('OCTIME_REPRISE_HISTO') + LEFT JOIN w_entets ON w_entets.entreprise_id = ent.oid AND w_entets.etablissement_id = ets.oid + WHERE 1=1 + AND ent.oid != 0 + AND ets.oid != 0 + AND ent.planning_code||ets.planning_code != '' + AND t_divers.valeur = 1 + AND w_entets.etablissement_id IS NULL) + INSERT INTO w_entets SELECT * FROM w_ets_encours_reprise_histo; + + -- Alimentation de la table de mouvement. + TRUNCATE rh.p_planning_mouvement + ; + INSERT INTO rh.p_planning_mouvement( + salarie_id, + contrat_id, + contrat_mois_id, + date, + semaine, + mois, + etablissement_id, -- @todo à renseigner en fonction du paramétrage dans t_divers. + service_id, + qualification_id, + type_absence_id, + niveau_id, + code_horaire_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence, + temps_du_ajuste, + temps_valide_ajuste, + temps_absence_ajuste) + SELECT + w_cptres1.salarie_id, + w_cptres1.contrat_id, + w_cptres1.contrat_mois_id, + w_cptres1.date, + to_char(w_cptres1.date, 'IYYYIW'::text)::numeric AS semaine, + to_char(w_cptres1.date, 'YYYYMM'::text)::numeric AS mois, + coalesce(w_entets.etablissement_id, 0) as etablissement_id, + coalesce(t_planning_service.oid, 0) AS service_id, + coalesce(t_planning_qualification.oid, 0) AS qualification_id, + coalesce(t_planning_type_absence.oid, 0) AS type_absence_id, + coalesce(t_planning_niveau.oid, 0) as niveau_id, + coalesce(t_planning_code_horaire.oid, 0) as code_horaire_id, + temps_du, + temps_du_initial, + temps_valide, + temps_absence, + temps_du, + temps_valide, + temps_absence + FROM w_cptres1 + JOIN rh.p_salaries ON p_salaries.oid = w_cptres1.salarie_id + JOIN w_entets ON true + AND w_entets.entreprise_id = p_salaries.entreprise_id + AND w_entets.entets_code = w_cptres1.entets_code -- Limiter les données au seul établissement paramétré. + LEFT JOIN rh.t_planning_niveau ON t_planning_niveau.code_original = w_cptres1.niveau_code_original + LEFT JOIN rh.t_planning_service ON t_planning_service.code_original = w_cptres1.service_code_original + LEFT JOIN rh.t_planning_qualification ON t_planning_qualification.code_original = w_cptres1.pos_cod + LEFT JOIN rh.t_planning_type_absence ON t_planning_type_absence.code_original = w_cptres1.abs_cod + LEFT JOIN rh.t_planning_code_horaire ON t_planning_code_horaire.code_original = w_cptres1.hor_cod + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + ; + + VACUUM ANALYSE rh.p_planning_mouvement + ; + + -- Ajustement des temps + + -- Temps validé sans temps du, alimenter temps du + UPDATE rh.p_planning_mouvement + SET temps_du_ajuste = p_planning_mouvement.temps_valide + FROM + ( + SELECT salarie_id, date + FROM rh.p_planning_mouvement + JOIN RH.t_divers ON t_divers.code = 'OCTIME_TPS_VALIDE_A' AND t_divers.valeur = '1' + GROUP BY 1,2 + HAVING SUM(temps_du) = 0 AND SUM(temps_valide) > 0 + ) subview + WHERE p_planning_mouvement.salarie_id = subview.salarie_id AND + p_planning_mouvement.date = subview.date + ; + + + -- Temps du - temps absence différent de temps validé -> temps valide = Temps du - temps absence + UPDATE rh.p_planning_mouvement + SET temps_valide_ajuste = p_planning_mouvement.temps_valide + ecart_temps_valide + FROM + ( + SELECT salarie_id, date, SUM(temps_du_ajuste) AS temps_du_ajuste, SUM(temps_valide) AS temps_valide, SUM(temps_absence) AS temps_absence, + MIN(CASE WHEN temps_du_ajuste > 0 THEN p_planning_mouvement.CTID ELSE NULL END) AS upd_ctid, SUM(temps_du_ajuste) - SUM(temps_absence) - SUM(temps_valide) AS ecart_temps_valide + FROM rh.p_planning_mouvement + JOIN RH.t_divers ON t_divers.code = 'OCTIME_TPS_VALIDE_A' AND t_divers.valeur = '1' + GROUP BY 1,2 + HAVING SUM(temps_du_ajuste) - SUM(temps_absence) <> SUM(temps_valide) + ) subview + WHERE p_planning_mouvement.salarie_id = subview.salarie_id AND + p_planning_mouvement.date = subview.date AND + p_planning_mouvement.ctid = subview.upd_ctid + ; + + ]]> + + + + + + 0 + FROM rh.t_divers + WHERE code = 'OCTIME_VENTILATION' + ; + + ]]> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_planning_SHARE.XML b/import_rh/iCTI_import_planning_SHARE.XML new file mode 100644 index 0000000..399469e --- /dev/null +++ b/import_rh/iCTI_import_planning_SHARE.XML @@ -0,0 +1,512 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + GROUP BY 1,2,3 + ; + + INSERT INTO rh.t_classes_sections(code, texte, classe_id) + SELECT code, texte, classe_id + from w_clasec_1 + where 1=1 + and classe_id = (select oid from rh.t_classes where code = 'PLANIV1') + and code not in (select code from rh.t_classes_sections where t_classes_sections.classe_id = w_clasec_1.classe_id and code is not null) + group by 1,2,3 + ; + + update rh.t_classes_sections set + texte = w_clasec_1.texte + FROM w_clasec_1 + WHERE true + and w_clasec_1.classe_id = t_classes_sections.classe_id + and w_clasec_1.code = t_classes_sections.code + and w_clasec_1.texte is distinct from t_classes_sections.texte + ; + + -- Mise à jour du contenu des sections Niveau 1. + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_planning_niveau.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join rh.t_planning_niveau on split_part(t_planning_niveau.code, '|', 1) = t_classes_sections.code + WHERE t_classes.code = 'PLANIV1' + group by 1,2 + ; + + -- Mise à jour des sections Niveau 2. + DROP TABLE IF EXISTS w_clasec_2 + ; + + CREATE TEMP TABLE w_clasec_2 AS + with nb_niv as ( + select + split_part(code, '|', 2) as niv_cod2, + count(DISTINCT trim(split_part(texte, '-|-', 2))) as niv_count + from rh.t_planning_niveau + group by 1 + ) + SELECT + case when niv_count = 1 then split_part(code, '|', 2) else split_part(code, '|', 1) || '|' || split_part(code, '|', 2) end as code, + split_part(code, '|', 1) || '|' || split_part(code, '|', 2) as code_original, + trim(split_part(texte, '-|-', 2)) as texte, + (select oid from rh.t_classes where code = 'PLANIV2') as classe_id + from rh.t_planning_niveau as niveau2 + JOIN nb_niv ON nb_niv.niv_cod2 = split_part(code, '|', 2) + WHERE oid > 0 + group by 1,2,3 + ; + + INSERT INTO rh.t_classes_sections(code, texte, classe_id) + SELECT code, texte, classe_id + from w_clasec_2 + where 1=1 + and classe_id = (select oid from rh.t_classes where code = 'PLANIV2') + and code not in (select code from rh.t_classes_sections where t_classes_sections.classe_id = w_clasec_2.classe_id and code is not null) + group by 1,2,3 + ; + + update rh.t_classes_sections set + texte = w_clasec_2.texte + FROM w_clasec_2 + WHERE true + and w_clasec_2.classe_id = t_classes_sections.classe_id + and w_clasec_2.code = t_classes_sections.code + and w_clasec_2.texte is distinct from t_classes_sections.texte + ; + + -- Mise à jour du contenu des sections Niveau 2. + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_planning_niveau.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join w_clasec_2 on true + and w_clasec_2.classe_id = t_classes.oid + and w_clasec_2.code = t_classes_sections.code + join rh.t_planning_niveau on split_part(t_planning_niveau.code, '|', 1)||'|'||split_part(t_planning_niveau.code, '|', 2) = w_clasec_2.code_original + WHERE t_classes.code = 'PLANIV2' + group by 1,2 + ; + + -- Mise à jour des sections Niveau 3. + DROP TABLE IF EXISTS w_clasec_3 + ; + + CREATE TEMP TABLE w_clasec_3 AS + with nb_niv as ( + select + split_part(code, '|', 3) as niv_cod3, + count(DISTINCT trim(split_part(texte, '-|-', 3))) as niv_count + from rh.t_planning_niveau + group by 1 + ) + SELECT + case when niv_count = 1 then split_part(code, '|', 3) else split_part(code, '|', 1) || '|' || split_part(code, '|', 2) || '|' || split_part(code, '|', 3) end as code, + split_part(code, '|', 1) || '|' || split_part(code, '|', 2) || '|' || split_part(code, '|', 3) as code_original, + trim(split_part(texte, '-|-', 3)) as texte, + (select oid from rh.t_classes where code = 'PLANIV3') as classe_id + from rh.t_planning_niveau as niveau3 + JOIN nb_niv ON nb_niv.niv_cod3 = split_part(code, '|', 3) + WHERE oid > 0 + group by 1,2,3 + ; + + INSERT INTO rh.t_classes_sections(code, texte, classe_id) + SELECT code, texte, classe_id + from w_clasec_3 + where 1=1 + and classe_id = (select oid from rh.t_classes where code = 'PLANIV3') + and code not in (select code from rh.t_classes_sections where t_classes_sections.classe_id = w_clasec_3.classe_id and code is not null) + group by 1,2,3 + ; + + update rh.t_classes_sections set + texte = w_clasec_3.texte + FROM w_clasec_3 + WHERE true + and w_clasec_3.classe_id = t_classes_sections.classe_id + and w_clasec_3.code = t_classes_sections.code + and w_clasec_3.texte is distinct from t_classes_sections.texte + ; + + -- Mise à jour du contenu des sections Niveau 3. + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_planning_niveau.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join w_clasec_3 on true + and w_clasec_3.classe_id = t_classes.oid + and w_clasec_3.code = t_classes_sections.code + join rh.t_planning_niveau on t_planning_niveau.code = w_clasec_3.code_original + WHERE t_classes.code = 'PLANIV3' + group by 1,2 + ; + + SELECT rh.cti_update_schema_classes('*ALL') + ; + + -- Recensement des oid utilisés. + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_service', service_id + FROM rh.p_planning_mouvement + WHERE service_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_service') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_qualification', qualification_id + FROM rh.p_planning_mouvement + WHERE qualification_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_qualification') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_niveau', niveau_id + FROM rh.p_planning_mouvement + WHERE niveau_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_niveau') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_type_absence', type_absence_id + FROM rh.p_planning_mouvement + WHERE type_absence_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_type_absence') + GROUP BY 1,2 + ; + + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'planning_code_horaire', code_horaire_id + FROM rh.p_planning_mouvement + WHERE code_horaire_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_code_horaire') + GROUP BY 1,2 + ; + + -- Pour remonter le type de contrat intérim. + INSERT INTO rh.p_oids (code_table, oid) + SELECT 'types_contrat', type_contrat_id + FROM rh.p_profils + WHERE type_contrat_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'types_contrat') + GROUP BY 1,2 + ; + + -- Populations : pas encore de règle de population basée sur le Planning. + -- SELECT rh.cti_reorganize_population() + -- ; + + -- Poles + SELECT rh.cti_reorganize_pole() + ; + + -- Options Divers + INSERT INTO rh.t_divers( + code, + texte, + valeur, + valeur_date, + description) + SELECT + 'PLANNING_BASE_ETP'::text, + 'Base pour calcul ETP Planning'::text, + '0'::text, + NULL, + '0 : La base des ETP est 151,67h / mois, 1 : La base des ETP est nb jours ouvrés période * 7h13, 2 : La base des ETP est nb jours semaine période * 7'::text + WHERE 'PLANNING_BASE_ETP' NOT IN (SELECT code FROM rh.t_divers) + ; + + ]]> + + + + + + + + diff --git a/import_rh/iCTI_import_rh.exe b/import_rh/iCTI_import_rh.exe new file mode 100644 index 0000000..a342139 Binary files /dev/null and b/import_rh/iCTI_import_rh.exe differ diff --git a/import_rh/iCTI_import_rh.php b/import_rh/iCTI_import_rh.php new file mode 100644 index 0000000..56c018a --- /dev/null +++ b/import_rh/iCTI_import_rh.php @@ -0,0 +1,503 @@ + 'AD', + 'aliciarh' => 'AL', + 'cador' => 'CA', + 'ccmx' => 'CX', + 'cegi' => 'CJ', + 'cegid' => 'CD', + 'pegase' => 'PG', + 'qsp' => 'QP', + 'quadrarh' => 'QR', + 'sage' => 'SA', + 'sagex3rhp' => 'SX', + 'shs' => 'SH', + 'shspub' => 'SP', + 'sigems' => 'SI', + 'cegidhru' => 'CU', + 'rhplace' => 'RE', +); + +$p2Histo = false; // Est-ce que le second prestataire est de type historique. + +logStartMsg(); + +// Récupération des arguments passés en paramètres et traitement de ces paramètres. +$cti_args = new CTI_Args_class(); +$cti_args->checkArgs(); + +$multiP = Environnement::getInstance()->hasRhProvider2(); +$p1 = Environnement::getInstance()->getRhProvider(); +$p2 = Environnement::getInstance()->getRhProvider2(); + +// Si $p2 est suffixé par _histo, passer le booléen $p2Histo à true. +if (substr($p2, -6, 6) === "_histo") { + // Vérification que le prestataire en cours est bien égal au prestataire histo. + if ($p1 !== substr($p2, 0, -6)) { + logErrorMsg("Le prestataire en cours $p1 est différent du prestataire historisé $p2."); + logEndMsg(); + exit(1); + } + $p2Histo = true; +} + +$p1Start = Environnement::getInstance()->getRhProviderStart(); +$p2Start = Environnement::getInstance()->getRhProvider2Start(); +$tmpDate = date_create($p1Start); +date_modify($tmpDate, '-1 day'); +$p2End = date_format($tmpDate, 'Y-m-d'); + +// Vérification de la remontée. +$exitCode1 = 0; +$exitCode2 = 0; +$exitCodePlanning = 0; + +// Si quadra RH, creation put_result avec contenu des tables pour verifier que COPY est OK +if ($p1 == 'quadrarh') { + $iCTI_connexion = Database2Factory::getInstance(Environnement::PROVIDER_CTI); + $ret = $iCTI_connexion->connect(); + + $putResultFilename = __ROOT__."/prodsgbd/quadrarh/data/iCTI_synchronize_quadrarh_put_result.XML"; + + $executeControlSql = " + DROP TABLE IF EXISTS w_putresult; + CREATE TEMP TABLE w_putresult AS + SELECT tablename, 0::numeric AS nbrows + FROM pg_tables + WHERE schemaname = 'prod_quadrarh' + ORDER BY 1 + ; + + SELECT base.cti_execute('UPDATE w_putresult SET nbrows = (SELECT count(*) FROM prod_quadrarh.'||tablename||') WHERE tablename = '''||tablename||''' ',1) + FROM w_putresult + ; + + COPY ( + SELECT data + FROM + ( + SELECT 1, '' AS data + UNION + SELECT 2, '
' + UNION + SELECT 9, '
' + UNION + SELECT 3, ' 0 THEN 'OK' ELSE 'KO' END||'\" />' + FROM w_putresult + ORDER BY 1,2 + ) subview + ) + TO '$putResultFilename' + "; + $iCTI_connexion->query($executeControlSql); + +} + + +$exitCode1 = checkLoadedData($p1, $MODULE); +if ($multiP && !$p2Histo) { + // Prestataire p2 arrêté, p1 uniquement ? + if (!$cti_args->args["-p1"]) { + $exitCode2 = checkLoadedData($p2, $MODULE, false); + } +} + +if ($exitCode1 + $exitCode2 + $exitCodePlanning === 0 || $cti_args->args["-f"]) { + logInfoMsg("Données prestataire chargées avec succès."); + + // Chargement des paramètres et connexion BD. + $iCTI_connexion = Database2Factory::getInstance(Environnement::PROVIDER_CTI); + $ret = $iCTI_connexion->connect(); + + // Auto-réparation des schémas si plantage en cours. + if (schemaExists('rh_ori')) { + logInfoMsg("Auto-réparation des schémas."); + if (schemaExists("rh_$p2") && schemaExists('rh')) { + changeSchemaName("rh", "rh_$p1"); + } elseif (schemaExists("rh_$p1") && schemaExists('rh')) { + changeSchemaName("rh", "rh_$p2"); + } + if (!schemaExists('rh')) { + changeSchemaName("rh_ori", "rh"); + } + } + if (schemaExists('rh_src')) { + logInfoMsg("Auto-réparation des schémas."); + if (schemaExists("rh_$p2")) { + changeSchemaName("rh_src", "rh_$p1"); + } elseif (schemaExists("rh_$p1")) { + changeSchemaName("rh_src", "rh_$p2"); + } + if (!schemaExists('rh') && schemaExists('rh_ori')) { + changeSchemaName("rh_ori", "rh"); + } + } + if (schemaExists('prod_rh_p1')) { + logInfoMsg("Auto-réparation des schémas prod."); + changeSchemaName("prod_$p1", "prod_$p2"); + changeSchemaName("prod_rh_p1", "prod_$p1"); + } + + // Import CTI + if ($multiP && !isset($cti_args->args["--fusion_only"]) && (isset($cti_args->args["-p1"]) || !isset($cti_args->args["-p2"]))) { + logInfoMsg("___________________________________________"); + logInfoMsg(">>> FUSION " . strtoupper($p1) . " (actuel) / " . strtoupper($p2) . " (ancien)"); + logInfoMsg(""); + + logInfoMsg("___________________________________________"); + logInfoMsg(">>> PREPARATION TRANSFORMATION " . strtoupper($p1)); + logInfoMsg(""); + + changeSchemaName("rh", "rh_ori"); + changeSchemaName("rh_$p1", "rh"); + initialisationSchemas(0, ''); + + logInfoMsg("___________________________________________"); + logInfoMsg(">>> TRANSFORMATION " . strtoupper($p1)); + logInfoMsg(""); + } + + if (!isset($cti_args->args["--fusion_only"]) && (isset($cti_args->args["-p1"]) || !isset($cti_args->args["-p2"]))) { + extractionEnvironnement($p1, Environnement::getInstance()->getSiren(), $p1Start, $cti_args->args["-raz"]); + } + + if ($multiP && !isset($cti_args->args["--fusion_only"]) && (isset($cti_args->args["-p1"]) || !isset($cti_args->args["-p2"]))) { + changeSchemaName("rh", "rh_$p1"); + changeSchemaName("rh_ori", "rh"); + } + + if ($multiP && !isset($cti_args->args["--fusion_only"]) && (isset($cti_args->args["-p2"]) || !isset($cti_args->args["-p1"]))) { + logInfoMsg("___________________________________________"); + logInfoMsg(">>> PREPARATION TRANSFORMATION " . strtoupper($p2)); + logInfoMsg(""); + + changeSchemaName("rh", "rh_ori"); + changeSchemaName("rh_$p2", "rh"); + initialisationSchemas(1, $prefixes[($p2Histo ? $p1 : $p2)]); + + if ($p2Histo) { + changeSchemaName("prod_$p1", "prod_rh_p1"); + changeSchemaName("prod_$p2", "prod_$p1"); + } + + logInfoMsg("___________________________________________"); + logInfoMsg(">>> TRANSFORMATION " . strtoupper($p2)); + logInfoMsg(""); + + if (!isset($cti_args->args["--fusion_only"]) && (isset($cti_args->args["-p2"]) || !isset($cti_args->args["-p1"]))) { + extractionEnvironnement(($p2Histo ? $p1 : $p2), Environnement::getInstance()->getSiren2(), $p2Start, $cti_args->args["-raz"]); + } + + changeSchemaName("rh", "rh_$p2"); + changeSchemaName("rh_ori", "rh"); + + if ($p2Histo) { + changeSchemaName("prod_$p1", "prod_$p2"); + changeSchemaName("prod_rh_p1", "prod_$p1"); + } + } + + // Fusion CTI + if ($multiP && !isset($cti_args->args["--no_fusion"])) { + logInfoMsg("___________________________________________"); + logInfoMsg(">>> FUSION " . strtoupper($p1)); + logInfoMsg(""); + changeSchemaName("rh_$p1", "rh_src"); + fusionEnvironnement($p1, 0, '', $p1Start); + changeSchemaName("rh_src", "rh_$p1"); + + logInfoMsg("___________________________________________"); + logInfoMsg(">>> FUSION " . strtoupper($p2)); + logInfoMsg(""); + changeSchemaName("rh_$p2", "rh_src"); + fusionEnvironnement($p2, 1, $prefixes[($p2Histo ? $p1 : $p2)], $p2Start, $p2End); + changeSchemaName("rh_src", "rh_$p2"); + + logInfoMsg("___________________________________________"); + logInfoMsg(">>> POST-TRAITEMENTS FUSION"); + logInfoMsg(""); + postEnvironnement(); + } + + // Déconnexion BD + $iCTI_connexion->close(); + + // Calcul des Essentiels. + if ($cti_args->args['-e'] || $cti_args->args['--essentiels']) { + essentielCompute(); + } + + executeExpertControls($iCTI_connexion); + + // nettoyage du cache + logInfoMsg("Nettoyage cache"); + cleanAllCache("iCTI_rh", true); +} else { + logErrorMsg("Problème de chargement des données prestataire."); +} +logEndMsg(); + +/** + * ****************************************************** + * FONCTIONS * + * ****************************************************** + */ + +function extractionEnvironnement($_rhProvider, $_siren, $_start, $_raz = false) +{ + global $iCTI_connexion; + global $cti_args; + + logInfoMsg("DEBUT RECUPERATION DE LA PRODUCTION " . strtoupper($_rhProvider)); + + $time = strtotime("-5 year", time()); + $start = date("Y-m-d", $time); + + // RHPROVIDER_START + if (strlen($_start) > 0) { + $start = $_start; + } + + // Préparation + // Initiatlisation du tableau de paramètres + $environmentVars = array(); + + // Spécifique SHS (permet d'avoir des imports génériques indépendants du code client SHS). + if (strtolower($_rhProvider) === 'shs') { + + $provider = Provider::createFromName($_rhProvider); + $extractionReportFile = $provider->getDataExtractionReportFile(); + if (file_exists($extractionReportFile)) { + $dcpm = new DatabaseContentParametersManager($extractionReportFile); + $providerDatabaseParameters = $dcpm->getParameters(); + + // Générer les vues génériques + // Bibl. RH. + if ($providerDatabaseParameters['rhlib'] !== '') { + $environmentVars['rhlib'] = $providerDatabaseParameters['rhlib']; + $listViewsSql = " + SELECT table_name as tablename + FROM information_schema.columns + WHERE 1=1 + AND table_schema = 'prod_shs' + AND table_name ilike '" . $environmentVars['rhlib'] . "%' + GROUP BY 1 + ORDER BY 1 + "; + $res = $iCTI_connexion->query($listViewsSql); + if ($res !== false) { + while ($prodShsTable = pg_fetch_assoc($res)) { + $createViewSql = " + DROP VIEW IF EXISTS prod_shs." . str_ireplace($environmentVars['rhlib'], 'rhlib', $prodShsTable["tablename"]) . " + ; + CREATE VIEW prod_shs." . str_ireplace($environmentVars['rhlib'], 'rhlib', $prodShsTable["tablename"]) . " AS + SELECT * FROM prod_shs." . $prodShsTable["tablename"] . " + ; + "; + $iCTI_connexion->query($createViewSql); + } + } + } + + // Bibl. RHDIF. + if ($providerDatabaseParameters['rhdiflib'] !== '') { + $environmentVars['rhdiflib'] = $providerDatabaseParameters['rhdiflib']; + $listViewsSql = " + SELECT table_name as tablename + FROM information_schema.columns + WHERE 1=1 + AND table_schema = 'prod_shs' + AND table_name ilike '" . $environmentVars['rhdiflib'] . "%' + GROUP BY 1 + ORDER BY 1 + "; + $res = $iCTI_connexion->query($listViewsSql); + if ($res !== false) { + while ($prodShsTable = pg_fetch_assoc($res)) { + $createViewSql = " + DROP VIEW IF EXISTS prod_shs." . str_ireplace($environmentVars['rhdiflib'], 'rhdiflib', $prodShsTable["tablename"]) . " + ; + CREATE VIEW prod_shs." . str_ireplace($environmentVars['rhdiflib'], 'rhdiflib', $prodShsTable["tablename"]) . " AS + SELECT * FROM prod_shs." . $prodShsTable["tablename"] . " + ; + "; + $iCTI_connexion->query($createViewSql); + } + } + } + + } + + } + + // Initialisation du requêteur + try { + $sqlOptions = array(); + $environmentVars["FINESS"] = Environnement::getInstance()->getFiness(); + + if (strlen($_siren) > 0) { + $environmentVars["SIREN"] = $_siren; + } + + $environmentVars["OPTRH_AVT_NATURE"] = 'false'; + if (strtolower($OPTRH_AVT_NATURE) == '1') { + $environmentVars["OPTRH_AVT_NATURE"] = 'true'; + } + + $environmentVars["APP_ROOT"] = __ROOT__; + + // Création d'une table SQL temporaire contenant les paramètres à passer à l'import RH. + // A appeler dans le SQL de la façon suivante : rhp('finess'); + + $sqlSiren = ''; + if (isset($environmentVars["SIREN"])) { + foreach (explode(',', $_siren) as $siren) { + $sqlSiren .= "('siren'::text, '" . trim($siren) . "'::text)," . PHP_EOL; + } + } + + $sqlEnt = ''; + if (isset($environmentVars["entreprise"])) { + foreach ($environmentVars["entreprise"] as $ent) { + $sqlEnt .= "('entreprise'::text, '$ent'::text)," . PHP_EOL; + } + } + + $tmpParamSql = " + DROP TABLE IF EXISTS rhp + ; + CREATE TEMP TABLE rhp AS + VALUES + $sqlSiren + $sqlEnt + ('finess'::text, '" . $environmentVars["FINESS"] . "'::text), + ('opt_avt_nature'::text, '" . $environmentVars["OPTRH_AVT_NATURE"] . "'::text), + ('rhprovider_start'::text, '" . $start . "'::text) + ; + + DROP FUNCTION IF EXISTS rhp(text) + ; + CREATE FUNCTION rhp(text) + RETURNS text AS + \$BODY\$ + SELECT column2 FROM rhp WHERE column1 = \$1 + ; + \$BODY\$ + LANGUAGE 'sql' VOLATILE + ; + + DROP FUNCTION IF EXISTS rhp_in(text) + ; + CREATE FUNCTION rhp_in(text) + RETURNS setof text AS + \$BODY\$ + SELECT column2 FROM rhp WHERE column1 = \$1 + ; + \$BODY\$ + LANGUAGE 'sql' VOLATILE + ; + "; + $iCTI_connexion->query($tmpParamSql); + + foreach ($cti_args->args as $key => $value) { + $sqlOptions[] = $key; + } + + $cti_sqlStatements = new CTI_SqlStatements_class("iCTI_import_rh_" . strtoupper($_rhProvider) . ".XML", $iCTI_connexion, $environmentVars, $sqlOptions, "iCTI_import_rh_SHARE.XML"); + + // Raz automatique le samedi + if (date("w") == 6) { + $_raz = "ONLYKEY"; + } + + if ($_raz) { + $cti_sqlStatements->executeStatementsNode("RAZ"); + $cti_sqlStatements->executeStatementsNode("VACUUM"); + } + + $cti_sqlStatements->executeStatementsNode("INIT"); + $cti_sqlStatements->executeStatementsNode("PROD"); + $cti_sqlStatements->executeStatementsNode("POST"); + $cti_sqlStatements->executeStatementsNode("VACUUM"); + } catch (Exception $e) { + logErrorMsg("Impossible de charger les requêtes SQL."); + logEndMsg(); + exit(1); + } + + logInfoMsg("FIN RECUPERATION DE LA PRODUCTION " . strtoupper($_rhProvider)); +} + +function postEnvironnement() +{ + global $iCTI_connexion; + global $cti_args; + + $sqlOptions = array(); + $environmentVars = array(); + + foreach ($cti_args->args as $key => $value) { + $sqlOptions[] = $key; + } + + $sqlStatements = new CTI_SqlStatements_class("iCTI_import_rh_FUSION.XML", $iCTI_connexion, $environmentVars, $sqlOptions, "iCTI_import_rh_SHARE.XML"); + + $sqlStatements->executeStatementsNode("POST"); + $sqlStatements->executeStatementsNode("VACUUM"); +} + +function essentielCompute() +{ + logInfoMsg("Calcul des indicateurs essentiels RH."); + + $exe = "..\..\outils\dashboard\iCTI_aggregateCtiIndicators.exe"; + + if (file_exists($exe)) { + $return = exec("$exe -m rh -e"); + } else { + logErrorMsg("La fonction de calcul des essentiels RH est absente."); + } +} + +function executeExpertControls($iCTI_connexion) +{ + logInfoMsg("Contrôles expert"); + $executeControlSql = "SELECT base.cti_calcul_expert_controls('rh', 0);"; + $res = $iCTI_connexion->query($executeControlSql); + if ($res === false) { + logErrorMsg("Le traitement des contrôles experts a echoué"); + } +} \ No newline at end of file diff --git a/import_rh/iCTI_import_rh_ADP.XML b/import_rh/iCTI_import_rh_ADP.XML new file mode 100644 index 0000000..ce34b34 --- /dev/null +++ b/import_rh/iCTI_import_rh_ADP.XML @@ -0,0 +1,2105 @@ + + + + + + + + + + + + + + + + + = rhp('rhprovider_start')::date + group by 1,2 + ; + + ]]> + + + + + + = rhp('rhprovider_start')::date + AND t_etablissements.oid != 0 + GROUP BY 1,2 + ) + SELECT + nextval('s_bulletins'::regclass) AS bulletin_id, + entreprise_id, + etablissement_id, + 'BULLETIN' || '-' || matricule || '-' || mois AS numero_bulletin, + date_debut, + date_fin, + mois, + matricule, + resbru, + rehpay, + rehtra, + 0::bigint AS affectation_contrat_mois_id, + 0::int AS est_hors_periode_contrat + FROM gestion_multi_bulletins + ) + ; + + ]]> + + + = 151.67 then 'TC' else 'TP' end||round(cnhmens::numeric, 2)::text, chr(1)||'*') AS type_temps_travail, + coalesce(nullif(cnhmens / 151.67, 0), 1.0) AS etp_theorique, + 0::int AS est_hors_periode, + dernier_bulletin_salaries.date_fin_dernier_bulletin + FROM prod_adp.contrat + JOIN w_sal_ets ON w_sal_ets.etcmat = contrat.etcmat -- Limiter la remontée des contrats aux seuls salariés ayant un bulletin + JOIN rh.t_divers ON code = 'ADP_TYPE_CONTRAT' + LEFT JOIN dernier_bulletin_salaries ON dernier_bulletin_salaries.matricule = contrat.etcmat + WHERE (cnlcnt != '' OR lnmcnt != '') -- exclu les contrats "en erreur". + ORDER BY H1DDEB + ) + ; + + ]]> + + + = w_contrats.date_debut_contrat + AND w_bulletins.date_fin <= w_contrats.date_fin_contrat + ; + + -- Si etablissement_id restant à 0, on renseigne le dernier id connu dans les contrats + UPDATE w_contrats + SET + etablissement_id = subview.etablissement_id, + entreprise_id = subview.entreprise_id + FROM + ( + SELECT + matricule, + (MAX(array[w_contrats.date_fin_contrat::text, w_contrats.etablissement_id::text]))[2]::int AS etablissement_id, + (MAX(array[w_contrats.date_fin_contrat::text, w_contrats.entreprise_id::text]))[2]::int AS entreprise_id + FROM w_contrats + WHERE etablissement_id <> 0 + GROUP BY 1 + ) AS subview + WHERE + w_contrats.etablissement_id = 0 + AND w_contrats.matricule = subview.matricule + ; + + -- Si etablissement_id restant à 0, on renseigne l'établissement le plus récent + UPDATE w_contrats + SET + etablissement_id = subview.etablissement_id, + entreprise_id = subview.entreprise_id + FROM + ( + SELECT + matricule, + (MAX(array[w_bulletins.date_fin::text, w_bulletins.etablissement_id::text]))[2]::int AS etablissement_id, + (MAX(array[w_bulletins.date_fin::text, w_bulletins.entreprise_id::text]))[2]::int AS entreprise_id + FROM w_bulletins + GROUP BY 1 + ) AS subview + WHERE + w_contrats.etablissement_id = 0 + AND w_contrats.matricule = subview.matricule + ; + + ANALYZE w_contrats + ; + + -- Mise à jours des bulletins hors période de contrat + UPDATE w_bulletins + SET est_hors_periode_contrat = 1 + FROM + ( + SELECT + w_bulletins.matricule, + w_bulletins.bulletin_id + FROM w_bulletins + LEFT JOIN w_contrats ON w_contrats.matricule = w_bulletins.matricule AND w_bulletins.date_debut BETWEEN w_contrats.date_debut_contrat AND w_contrats.date_fin_contrat + WHERE w_contrats.contrat_id IS NULL + ) AS subview + WHERE + w_bulletins.matricule = subview.matricule + AND w_bulletins.bulletin_id = subview.bulletin_id + ; + + ANALYZE w_bulletins + ; + + ]]> + + + = (rhp('rhprovider_start')::date - interval '2 YEAR') + ) + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + base.cti_first_day(w_contrats_mois.date_debut_contrat_mois) then 0 else 1 end AS present_debut_mois, + case when w_contrats_mois.date_fin_contrat < base.cti_last_day(w_contrats_mois.date_debut_contrat_mois) then 0 else 1 end AS present_fin_mois, + w_contrats_mois.etp_theorique AS equivalent_temps_plein, + w_contrats_mois.date_fin_contrat_mois - coalesce(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + w_contrats_mois.etablissement_id + FROM rh.p_contrats + JOIN w_contrats_mois on w_contrats_mois.contrat_id = p_contrats.oid + JOIN rh.p_salaries on p_salaries.oid = w_contrats_mois.salarie_id + ; + + ]]> + + + chr(1)||'*' + AND categorie_socio_professionnelle_code NOT IN (SELECT code_original FROM rh.t_categories_socio_professionnelle WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des motifs de début de contrat. + INSERT INTO rh.t_motifs_debut_contrat(code_original, code, texte, texte_court) + SELECT substr(md5(act_motif_debut), 1, 5), substr(md5(act_motif_debut), 1, 5), act_motif_debut, substr(max(act_motif_debut),1,50) + FROM prod_adp.contrat + WHERE substr(md5(act_motif_debut), 1, 5) NOT IN (SELECT code_original FROM rh.t_motifs_debut_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3 + ORDER BY 2 + ; + + -- Màj des motifs de fin de contrat. + INSERT INTO rh.t_motifs_fin_contrat(code_original, code, texte, texte_court) + SELECT motif_fin_code, motif_fin_code, MAX(motif_fin_texte), substr(MAX(motif_fin_texte), 1, 50) + FROM w_contrats_mois + WHERE + motif_fin_code <> chr(1)||'*' + AND motif_fin_code NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + -- Màj des nationalités. + INSERT INTO rh.t_nationalites(code, texte, texte_court, code_original) + SELECT etcnat, max(etlnat), max(substr(etlnat,1,50)), etcnat + FROM prod_adp.etaciv + WHERE etcnat NOT IN (SELECT code_original FROM rh.t_nationalites WHERE code_original IS NOT NULL) + GROUP BY 1,4 + ; + + -- Màj des qualifications + INSERT INTO rh.t_qualifications(code_original, code, texte, texte_court) + SELECT qualification_code, qualification_code, max(qualification_texte), substr(max(qualification_texte), 1, 50) + FROM w_contrats_mois + WHERE + qualification_code <> chr(1)||'*' + AND qualification_code NOT IN (SELECT code_original FROM rh.t_qualifications WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + -- Màj des rubriques + INSERT INTO rh.t_rubriques(code_original, code, texte, texte_court, rang_edition) + select rubid, rubid, libelle, substr(libelle, 1, 50), noordre + from prod_adp.rgl_pp_tabrub + WHERE rubid NOT IN (SELECT code_original FROM rh.t_rubriques WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4,5 + ; + + -- Màj des situations de famille + INSERT INTO rh.t_situations_famille(code_original, code, texte_court, texte) + SELECT etcsfa, etcsfa, MAX(substr(etlsfa,1,50)), MAX(etlsfa) + FROM prod_adp.etaciv + WHERE etcsfa NOT IN (SELECT code_original FROM rh.t_situations_famille WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code_original, code, texte, texte_court) + SELECT type_contrat_code, type_contrat_code, type_contrat_texte, substr(type_contrat_texte, 1, 50) + FROM w_contrats_mois + WHERE + type_contrat_code <> chr(1)||'*' + AND type_contrat_code NOT IN (SELECT code_original FROM rh.t_types_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + SELECT statut_code, statut_code, statut_texte, substr(statut_texte, 1, 50) + FROM w_contrats_mois + WHERE + statut_code <> chr(1)||'*' + AND statut_code NOT IN (SELECT code_original FROM rh.t_statuts WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + SELECT + CASE WHEN heures_theoriques >= 151.67 THEN 'TC' ELSE 'TP' END||ROUND(heures_theoriques::numeric, 2)::text, + CASE WHEN heures_theoriques >= 151.67 THEN 'TC' ELSE 'TP' END||ROUND(heures_theoriques::numeric, 2)::text, + CASE WHEN heures_theoriques >= 151.67 THEN 'Temps Complet ' ELSE 'Temps Partiel ' end||round(heures_theoriques::numeric, 2)::text, + CASE WHEN heures_theoriques >= 151.67 THEN 'TC ' ELSE 'TP ' END||ROUND(heures_theoriques::numeric, 2)::text + FROM w_contrats_mois + WHERE CASE WHEN heures_theoriques >= 151.67 THEN 'TC' ELSE 'TP' END||ROUND(heures_theoriques::numeric, 2)::text NOT IN (SELECT code_original FROM rh.t_types_temps_travail WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + SELECT service_code, service_code, max(service_texte), max(substr(service_texte, 1, 50)) + FROM w_contrats_mois + WHERE + service_code <> chr(1)||'*' + AND service_code NOT IN (SELECT code_original FROM rh.t_services WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + -- Màj des codes emploi. avec LTR ADP ELSAN. + INSERT INTO rh.t_codes_emploi(code_original, code, texte, texte_court) + SELECT code_emploi_code, code_emploi_code, max(code_emploi_texte), max(substr(code_emploi_texte, 1, 50)) + FROM w_contrats_mois + WHERE + code_emploi_code <> chr(1)||'*' + AND code_emploi_code NOT IN (SELECT code_original FROM rh.t_codes_emploi WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT grille_groupe_code, grille_groupe_code, max(grille_groupe_texte), max(substr(grille_groupe_texte, 1, 50)) + FROM w_contrats_mois + WHERE + grille_groupe_code <> chr(1)||'*' + AND grille_groupe_code NOT IN (SELECT code_original FROM rh.t_grilles_groupes WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + ]]> + + + + + + = rhp('rhprovider_start')::date + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié méme s'il n'y a rien. + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + ]]> + + + + + + + + + + + + = 1 + ; + + ]]> + + + + + + + + + + 1 + ) subview + ON p_salaries.nir = subview.nir + WHERE p_salaries.oid <> subview.to_oid + ; + + ANALYSE w_map_doublons + ; + + UPDATE rh.p_accident_travail + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_arrets_travail + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_arrets_travail_mois + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_contrats + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_contrats_mois + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_handicap + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_handicap2 + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_historique_paie + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + UPDATE rh.p_profil_contrat_mois + SET salarie_id = to_oid + FROM w_map_doublons + WHERE salarie_id = from_oid + ; + + DELETE FROM rh.p_salaries + USING w_map_doublons + WHERE oid = from_oid + ; + + ]]> + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_ALICIARH.XML b/import_rh/iCTI_import_rh_ALICIARH.XML new file mode 100644 index 0000000..d4f89e5 --- /dev/null +++ b/import_rh/iCTI_import_rh_ALICIARH.XML @@ -0,0 +1,854 @@ + + + + + + + + + + + x_hst_bulletin.date_debut + where x_hst_bulletin.cnt_code_original is null + group by 1 + ) + UPDATE temp.x_hst_bulletin set + cnt_code_original = toto.cnt_code_original, + est_hors_periode = 1 + from toto + where x_hst_bulletin.row_id = toto.row_id + ; + + -- ICI : Tous les bulletins doivent avoir un contrat de renseigné. + -- A remonter plus tard dans une table spéciale avant suppression pour controle expert. + delete from temp.x_hst_bulletin + where cnt_code_original is null + ; + + -- HISTORIQUE ETP Théorique contrat. + DROP TABLE IF EXISTS temp.x_hst_etp_contrat + ; + + CREATE TABLE temp.x_hst_etp_contrat AS + select + dossier||'-'||dossier as ety_code_original, + id1 as sal_code_original, + id1||'-'||lpad(no, 3, '0') as cnt_code_original, + to_date(datapp, 'DD/MM/YYYY') as date_effet, + opa::numeric / 151.67 as etp_contrat + from prod_aliciarh.a_cont + join w_ets on w_ets.ets_id1 = a_cont.dossier + join temp.x_ref_salarie on x_ref_salarie.code_original = a_cont.id1 + where rub = 'A079' + group by 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_categorie_socio_professionnelle + ; + + CREATE TABLE temp.x_hst_categorie_socio_professionnelle AS + select + dossier||'-'||dossier as ety_code_original, + id1 as sal_code_original, + id1||'-'||lpad(no, 3, '0') as cnt_code_original, + to_date(datapp, 'DD/MM/YYYY') as date_effet, + opf::text as categorie_socio_professionnelle_code_original + from prod_aliciarh.a_cont + join w_ets on w_ets.ets_id1 = a_cont.dossier + join temp.x_ref_salarie on x_ref_salarie.code_original = a_cont.id1 + where rub = 'AZ02' + group by 1,2,3,4,5 + ; + + -- HISTORIQUE Motif de début. + DROP TABLE IF EXISTS temp.x_hst_motif_debut_contrat + ; + + CREATE TABLE temp.x_hst_motif_debut_contrat AS + SELECT + null::text as ety_code_original, + null::text as sal_code_original, + null::text as cnt_code_original, + null::date as date_effet, + null::text as motif_debut_code_original + limit 0 + ; + + -- HISTORIQUE Motif de fin. + DROP TABLE IF EXISTS temp.x_hst_motif_fin_contrat + ; + + CREATE TABLE temp.x_hst_motif_fin_contrat AS + SELECT + null::text as ety_code_original, + null::text as sal_code_original, + null::text as cnt_code_original, + null::date as date_effet, + null::text as motif_fin_code_original + limit 0 + ; + + + -- HISTORIQUE Types de contrat. + DROP TABLE IF EXISTS temp.x_hst_type_contrat + ; + + CREATE TABLE temp.x_hst_type_contrat AS + select + dossier||'-'||dossier as ety_code_original, + id1 as sal_code_original, + id1||'-'||lpad(no, 3, '0') as cnt_code_original, + to_date(datapp, 'DD/MM/YYYY') as date_effet, + opf::text as type_contrat_code_original + from prod_aliciarh.a_cont + join w_ets on w_ets.ets_id1 = a_cont.dossier + join temp.x_ref_salarie on x_ref_salarie.code_original = a_cont.id1 + where rub = 'A070' + group by 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_qualification + ; + + CREATE TABLE temp.x_hst_qualification AS + select + dossier||'-'||dossier as ety_code_original, + id1 as sal_code_original, + id1||'-'||lpad(no, 3, '0') as cnt_code_original, + to_date(datapp, 'DD/MM/YYYY') as date_effet, + replace(opf::text,' ','_') as qualification_code_original + from prod_aliciarh.a_cont + join w_ets on w_ets.ets_id1 = a_cont.dossier + join temp.x_ref_salarie on x_ref_salarie.code_original = a_cont.id1 + where rub = 'AVF1' + or rub = 'AV10' --qualifications non référencées issues d'un champ libre + group by 1,2,3,4,5 + ; + + -- HISTORIQUE Status. + DROP TABLE IF EXISTS temp.x_hst_statut + ; + + CREATE TABLE temp.x_hst_statut AS + select + dossier||'-'||dossier as ety_code_original, + id1 as sal_code_original, + id1||'-'||lpad(no, 3, '0') as cnt_code_original, + to_date(datapp, 'DD/MM/YYYY') as date_effet, + opf::text as statut_code_original + from prod_aliciarh.a_cont + join w_ets on w_ets.ets_id1 = a_cont.dossier + join temp.x_ref_salarie on x_ref_salarie.code_original = a_cont.id1 + where rub = 'A072' + group by 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_type_temps_travail + ; + + CREATE TABLE temp.x_hst_type_temps_travail AS + select + dossier||'-'||dossier as ety_code_original, + id1 as sal_code_original, + id1||'-'||lpad(no, 3, '0') as cnt_code_original, + to_date(datapp, 'DD/MM/YYYY') as date_effet, + case when opa = '151.67' then 'C' else 'P'||opa end as type_temps_travail_code_original + from prod_aliciarh.a_cont + join w_ets on w_ets.ets_id1 = a_cont.dossier + join temp.x_ref_salarie on x_ref_salarie.code_original = a_cont.id1 + where rub = 'A079' + group by 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_service + ; + + CREATE TABLE temp.x_hst_service AS + select + dossier||'-'||dossier as ety_code_original, + id1 as sal_code_original, + id1||'-'||lpad(no, 3, '0') as cnt_code_original, + to_date(datapp, 'DD/MM/YYYY') as date_effet, + opf::text as service_code_original + from prod_aliciarh.a_cont + join w_ets on w_ets.ets_id1 = a_cont.dossier + join temp.x_ref_salarie on x_ref_salarie.code_original = a_cont.id1 + where rub = 'A948' + group by 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_code_emploi + ; + + CREATE TABLE temp.x_hst_code_emploi AS + SELECT + null::text as ety_code_original, + null::text as sal_code_original, + null::text as cnt_code_original, + null::date as date_effet, + null::text as code_emploi_code_original + limit 0 + ; + + -- HISTORIQUE GRILLE. + DROP TABLE IF EXISTS temp.x_hst_grille + ; + + CREATE TABLE temp.x_hst_grille AS + SELECT + null::text as ety_code_original, + null::text as sal_code_original, + null::text as cnt_code_original, + null::date as date_effet, + null::text as grille_code_original + limit 0 + ; + + + ]]> + + + = to_char(rhp('rhprovider_start')::date, 'YYYYMM') + ; + + ]]> + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_CADOR.XML b/import_rh/iCTI_import_rh_CADOR.XML new file mode 100644 index 0000000..9d7232a --- /dev/null +++ b/import_rh/iCTI_import_rh_CADOR.XML @@ -0,0 +1,1183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 0 else t_entreprises.code_original = salarie.cc_code end + join pg_class on salarie.tableoid = pg_class.oid + join pg_namespace on pg_namespace.oid = pg_class.relnamespace + -- sal_postal, + -- sal_secu, + -- sal_natio, + -- sal_situ_fam + group by 1,2,3,4,5,6, 12,13,14,15,16,17,19,21,22,23,24,25 + ; + + ]]> + + + + + + + base.cti_first_day((w_profils.mois::text||'01')::date) then 0 else (case when w_profils.est_hors_periode = 1 then 0 else 1 end) end as present_debut_mois, + case when w_profils.cnt_date_fin < base.cti_last_day((w_profils.mois::text||'01')::date) then 0 else (case when w_profils.est_hors_periode = 1 then 0 else 1 end) end as present_fin_mois, + 1 as equivalent_temps_plein, -- ! Mettre le bon ETP. + base.cti_age(least(w_profils.date_fin, w_profils.cnt_date_fin)::date, coalesce(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + least(w_profils.date_fin, w_profils.cnt_date_fin)::date - coalesce(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + p_contrats.anciennete_anterieure_jours + + (w_profils.date_fin - w_profils.cnt_date_debut) + + 1 + AS anciennete_jours, + base.cti_age(date_trunc('month', w_profils.date_fin::date)::date, date_trunc('month', w_profils.cnt_date_debut)::date, 'nm') + + p_contrats.anciennete_anterieure_calculee_mois + 1 AS anciennete_mois, + floor((base.cti_age(date_trunc('month', w_profils.date_fin::date)::date, date_trunc('month', w_profils.cnt_date_debut)::date, 'nm') + + p_contrats.anciennete_anterieure_calculee_mois + 1) / 12) AS anciennete_annee_id, + p_contrats.etablissement_id + FROM w_profils + JOIN rh.p_contrats on p_contrats.code_original = w_profils.act_code + JOIN rh.p_salaries on p_salaries.oid = p_contrats.salarie_id + ; + + -- On renseigne les id de contrats de w_profils. + UPDATE w_profils + SET contrat_id = p_contrats_mois.contrat_id, + contrat_mois_id = p_contrats_mois.oid + FROM rh.p_contrats_mois + WHERE w_profils.row_id = p_contrats_mois.code_original + ; + + ]]> + + + = rhp('rhprovider_start')::date + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié méme s'il n'y a rien. + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer) + ; + + ]]> + + + = to_char(rhp('rhprovider_start')::date, 'YYYYMM')::int + and p_cumul + GROUP BY 1,2,3 + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_CCMX.XML b/import_rh/iCTI_import_rh_CCMX.XML new file mode 100644 index 0000000..ac90245 --- /dev/null +++ b/import_rh/iCTI_import_rh_CCMX.XML @@ -0,0 +1,1214 @@ + + + + + 39811 + ; + + DROP VIEW IF EXISTS prod_ccmx.v_h_coeff + ; + + CREATE OR REPLACE VIEW prod_ccmx.v_h_coeff AS + SELECT + to_timestamp((coe_du - 25567) * 86400)::date AS date_debut, + CASE WHEN coe_au = 0 THEN '2099-12-31'::date ELSE to_timestamp((coe_au - 25567) * 86400)::date END AS date_fin, + * + FROM prod_ccmx.h_coeff + ; + + DROP VIEW IF EXISTS prod_ccmx.v_h_es + ; + + CREATE OR REPLACE VIEW prod_ccmx.v_h_es AS + SELECT + to_timestamp((e_s_date - 25567) * 86400)::date AS date_debut, + CASE WHEN e_s_dates = 0 THEN '2099-12-31'::date ELSE to_timestamp((e_s_dates - 25567) * 86400)::date END AS date_fin, + * + FROM prod_ccmx.h_es + ; + + ]]> + + + + 0 + GROUP BY 1,2,3,4 + ; + + -- Màj des motifs de fin de contrat + INSERT INTO rh.t_motifs_fin_contrat(code, code_original, texte, texte_court) + SELECT mes_ids||motif_id, mes_ids||motif_id, mes_ids||motif_id, substr(mes_ids||motif_id, 1, 50) + FROM prod_ccmx.v_h_es + WHERE 1=1 + AND mes_ids||motif_id NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat) + AND length(trim(mes_ids)) > 0 + GROUP BY 1,2,3,4 + ; + + -- Màj des nationalités + INSERT INTO rh.t_nationalites(code, texte, texte_court, code_original) + SELECT sal_cod_pays, sal_cod_pays, substr(sal_cod_pays,1,50), sal_cod_pays + FROM prod_ccmx.v_salarie + WHERE sal_cod_pays NOT IN (SELECT code_original FROM rh.t_nationalites) + GROUP BY 1,2,3,4 + ; + + -- Màj des organismes de cotisation + + -- Màj des qualifications (ATTENTION aux jointures : code sur 3 mais dans les tables de faits, sur 2 et 3) + + -- Màj des rubriques + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT + pla_id, + max(pla_int), + max(substr(pla_int, 1, 50)), + pla_id, + max(pla_type::numeric) -- @TODO NOT SURE => reg_id ? + FROM prod_ccmx.plap + WHERE 1=1 + AND pla_id NOT IN (SELECT code_original FROM rh.t_rubriques) + GROUP BY 1,4 + ; + + -- création des rubriques CTI de cumul + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C000', 'Ecart cumulé', 'Ecart cumulé', 'C000', -1 + WHERE 'C000' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + -- Màj des situations de famille (non profil) + INSERT INTO rh.t_situations_famille(code, texte, texte_court, code_original) + SELECT fam_id, fam_id, substr(fam_id, 1, 50), fam_id + FROM prod_ccmx.v_salarie + WHERE 1=1 + AND fam_id NOT IN (SELECT code_original FROM rh.t_situations_famille) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code_original, code, texte, texte_court) + SELECT ctr_id, ctr_id, ctr_id, substr(ctr_id,1,50) + FROM prod_ccmx.v_h_contrat + WHERE 1=1 + AND ctr_id NOT IN (SELECT code_original FROM rh.t_types_contrat) + GROUP BY 1,2,3,4 + ; + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + SELECT cat_id, cat_id, cat_lib, substr(cat_lib, 1, 50) + FROM prod_ccmx.ar_categ + WHERE 1=1 + AND cat_id NOT IN (SELECT code_original FROM rh.t_statuts) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + SELECT cem_id, cem_id, cem_id, substr(cem_id, 1, 50) + FROM prod_ccmx.h_cemploi + WHERE 1=1 + AND cem_id NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + GROUP BY 1,2,3,4 + UNION + SELECT + cem_id::text||coalesce(tem_taux::text, ''), + cem_id::text||coalesce(tem_taux::text, ''), + cem_id::text||coalesce(tem_taux::text, ''), + substr(cem_id::text||coalesce(tem_taux::text, ''), 1, 50) + FROM prod_ccmx.h_cemploi + left join prod_ccmx.h_tempart ON 1=1 + WHERE 1=1 + AND cem_id::text||coalesce(tem_taux::text, '') NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + GROUP BY 1,2,3,4 + ; + + -- Màj des types d'horaire + INSERT INTO rh.t_types_horaire(code_original, code, texte, texte_court) + SELECT hth_id, hth_id, hth_id, substr(hth_id, 1, 50) + FROM prod_ccmx.h_typ_hor + WHERE 1=1 + AND hth_id NOT IN (SELECT code_original FROM rh.t_types_horaire) + GROUP BY 1,2,3,4 + ; + + -- Màj des services + + -- Màj des spécialités + + -- Màj des codes emploi + INSERT INTO rh.t_codes_emploi(code_original, code, texte, texte_court) + SELECT emp_id, emp_id, emp_lib, substr(emp_lib, 1, 50) + FROM prod_ccmx.ar_emploi + WHERE 1=1 + AND emp_id NOT IN (SELECT code_original FROM rh.t_codes_emploi) + GROUP BY 1,2,3,4 + ; + + -- Màj des comptes. + INSERT INTO rh.t_compte(code_original, code, texte, texte_court) + SELECT cpt_cle, substr(cpt_cpt1, 2, 6), cpt_lib, substr(cpt_lib, 1, 50) + FROM prod_ccmx.ar_compte + WHERE 1=1 + AND length(trim(cpt_lib)) > 0 + AND cpt_cle NOT IN (SELECT code_original FROM rh.t_compte WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- [NON] Màj des sociétés d'interim + + -- Màj des grilles + INSERT INTO rh.t_grilles(code_original, code, texte, texte_court) + SELECT coe_val, coe_val, coe_val, coe_val + FROM prod_ccmx.v_h_coeff + WHERE 1=1 + AND coe_val NOT IN (SELECT code_original FROM rh.t_grilles) + GROUP BY 1 + ; + + -- [NON] Màj des groupes de grilles + + -- [NON] Màj des motifs d'arret + + -- [NON] Màj des précisions du motif d'arrêt + + -- [NON] Màj des motifs de visite médicale + + -- [NON] Màj des circonstances d'accident du travail + + -- [NON] Màj des lieux d'accident du travail + + -- [NON] Màj de la nature de l'accident du travail + + -- [NON] Màj des sièges d'accident du travail + + -- [NON] Màj des listes de formations + + -- [NON] Màj des sections analytiques compta + + -- [NON] Màj des sections analytiques paie + + ]]> + + + + + + + + t2.date_fin + where 1=1 + and t1.numero_contrat is null + and t2.numero_contrat is not null + group by 1,2 + ) AS subq + WHERE 1=1 + AND w_tmp_1.mat = subq.mat + AND w_tmp_1.bul_id = subq.bul_id + ; + + -- #correction Association des bulletins de paie au futur contrat connu. + UPDATE w_tmp_1 + SET numero_contrat = subq.numero_contrat + FROM ( + select + t1.bul_id, + t1.mat, + (min(array[t2.date_debut::text, t2.numero_contrat::text]))[2] as numero_contrat + from w_tmp_1 AS t1 + left join w_tmp_1 AS t2 ON 1=1 + and t1.mat = t2.mat + and t1.bul_id != t2.bul_id + and t1.date_fin < t2.date_debut + where 1=1 + and t1.numero_contrat is null + and t2.numero_contrat is not null + group by 1,2 + ) AS subq + WHERE 1=1 + AND w_tmp_1.mat = subq.mat + AND w_tmp_1.bul_id = subq.bul_id + ; + + DROP TABLE IF EXISTS w_profils + ; + + CREATE TEMP TABLE w_profils AS + SELECT + 0 AS profil_id, -- Identifiant CTI du profil CTI + 0 AS last_profil, -- Profil le + récent = 1, sinon à 0 + + -- Cléfs naturelles permettant le matching du profil CTI au données Cegid + bul_id, + numero_contrat, + mat AS matricule, + min(date_debut) AS date_debut, + max(date_fin) AS date_fin, + est_hors_periode, + + -- Données du Profil CTI + categorie_socio_professionnelle_code_original, + code_emploi_code_original, + grille_code_original AS grille_code_original, + chr(1)||'*' AS grille_groupe_code_original, + chr(1)||'*' AS groupe_cotisant_code_original, + motif_debut_code_original AS motif_debut_code_original, + motif_fin_code_original AS motif_fin_code_original, + chr(1)||'*' AS qualification_code_original, + chr(1)||'*' AS section_analytique_code_original, + chr(1)||'*' AS section_analytique_paie_code_original, + chr(1)||'*' AS service_code_original, + chr(1)||'*' AS societe_interim_code_original, + chr(1)||'*' AS specialite_code_original, + statut_code_original AS statut_code_original,--greatest(hst.phs_dadscat, chr(1)||'*') AS statut_code_original, + type_contrat_code_original AS type_contrat_code_original, + chr(1)||'*' AS type_horaire_code_original, + type_temps_travail_code_original AS type_temps_travail_code_original,--greatest(hst.phs_condemploi||phs_ttauxpartiel::float, chr(1)||'*') AS type_temps_travail_code_original, + + -- Champs dédiés au public. + chr(1)||'*' AS unite_fonctionnelle_code_original, + chr(1)||'*' AS categorie_conge_code_original, + chr(1)||'*' AS compte_salarie_code_original, + chr(1)||'*' AS commission_paritaire_code_original, + chr(1)||'*' AS lettre_budgetaire_code_original, + chr(1)||'*' AS cadre_emploi_code_original, + chr(1)||'*' AS filiere_code_original, + chr(1)||'*' AS categorie_statutaire_code_original + FROM w_tmp_1 + GROUP BY 1,2,3,4,5,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 + ; + + ]]> + + + + 0 THEN sal_val_nom ELSE sal_naiss END AS nom, + sal_prenom AS prenom, + v_sal_dnaiss AS date_naissance, + CASE WHEN substr(sal_noss, 1, 1) = 1 THEN 'M' ELSE 'F' END AS sexe, + salarie.sal_matr AS matricule, + salarie.sal_matr AS code, + salarie.sal_matr AS code_original, + coalesce(t_entreprises.oid,0) AS entreprise_id, + coalesce(t_nationalites.oid,0) AS nationalite_id, + coalesce(t_codes_postaux.oid,0) AS code_postal_id, + sal_naiss AS nom_naissance, + coalesce(t_situations_famille.oid,0) AS situation_famille_id, + 0 AS profil_id, -- dernier profil salarié. + max(h_cnt_trav.date_debut) AS date_debut, -- date de début du dernier contrat. + max(h_cnt_trav.date_fin) AS date_fin, -- date de fin du dernier contrat. + salarie.v_sal_dat_cemp AS date_entree_ets, + max(h_cnt_trav.date_fin) AS date_sortie_ets, + -- Champs dédiés au public. + '1900-01-01'::date AS date_entree_fp, + '1900-01-01'::date AS date_entree_fph, + 0 AS no_adeli, + 0 AS code_cotisation_id, + 0 AS matricule_retraite + FROM prod_ccmx.v_salarie AS salarie + JOIN w_cnt AS h_cnt_trav ON 1=1 + AND h_cnt_trav.ent_id = salarie.ent_id + AND h_cnt_trav.sal_matr = salarie.sal_matr + AND h_cnt_trav.cnt_id = salarie.cnt_id + LEFT JOIN rh.t_codes_postaux ON t_codes_postaux.code = salarie.sal_cp + LEFT JOIN rh.t_situations_famille ON t_situations_famille.code_original = salarie.fam_id + LEFT JOIN rh.t_entreprises ON t_entreprises.code_original = salarie.ent_id + LEFT JOIN rh.t_nationalites ON t_nationalites.code_original = salarie.sal_cod_pays + --LEFT JOIN w_profils ON w_profils.matricule = salaries.psa_salarie + WHERE salarie.eta_id = '0001' + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,17,19,20,21,22,23 + ; + + ]]> + + + + date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_entree_ets = date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND to_char(date_entree_ets, 'YYYY')::numeric >= 2009 + AND date_entree_ets < date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_sortie_ets = date_fin_contrat + FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND date_fin_contrat > date_sortie_ets + ; + + -- Calcul ancienneté au début de contrat + UPDATE rh.p_contrats + SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_calculee_mois + FROM ( + SELECT + t1.numero_contrat, + sum(t2.duree) AS anciennete_anterieure_jours, + sum(t2.duree) / 30 AS anciennete_anterieure_calculee_mois + FROM w_cnt AS t1 + JOIN w_cnt AS t2 ON 1=1 + AND t2.sal_matr = t1.sal_matr + AND t2.cnt_date < t1.cnt_date + group by 1 + ) AS subq + WHERE 1=1 + AND p_contrats.numero_contrat = subq.numero_contrat + ; + + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, + present_debut_mois, + present_fin_mois, + equivalent_temps_plein, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id + ) + SELECT + p_salaries.oid AS salarie_id, + p_contrats.oid AS contrat_id, + p_calendrier_mois.mois AS mois, + GREATEST(p_calendrier_mois.date_debut, w_profils.date_debut) AS date_debut, + LEAST(p_calendrier_mois.date_fin, w_profils.date_fin) AS date_fin, + CASE WHEN p_salaries.date_entree_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_entrees, + CASE WHEN p_salaries.date_sortie_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_departs, + CASE WHEN p_contrats.date_debut BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_contrat, + CASE WHEN p_contrats.date_fin BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_contrat, + w_profils.est_hors_periode, + CASE WHEN p_calendrier_mois.date_debut BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_debut_mois, + CASE WHEN p_calendrier_mois.date_fin BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + 0, -- L'ETP théorique est calculé plus loin à l'issue de la "Ventilation des profils". + base.cti_age(LEAST(p_calendrier_mois.date_fin, w_profils.date_fin), COALESCE(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + LEAST(p_calendrier_mois.date_fin, w_profils.date_fin)::date - COALESCE(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + p_contrats.anciennete_anterieure_jours + + (LEAST(p_calendrier_mois.date_fin, w_profils.date_fin) - p_contrats.date_debut) + + 1 + AS anciennete_jours, + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + AS anciennete_mois, + floor( + ( + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + ) / 12 + ) AS anciennete_annee_id + FROM w_profils + JOIN base.p_calendrier_mois ON base.cti_overlaps(w_profils.date_debut, w_profils.date_fin, p_calendrier_mois.date_debut, p_calendrier_mois.date_fin) + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_profils.numero_contrat + JOIN rh.p_salaries ON p_salaries.matricule = w_profils.matricule + WHERE 1=1 + AND p_calendrier_mois.mois < to_char(now() + '1 month'::interval, 'YYYYMM') + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 + ; + + ]]> + + + fixée dans l'aspirateur. + and bulletin.eta_id = '0001' + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + -- #correction + UPDATE w_hp + SET date_paie = (mois_paie||'01')::date + '1 month - 1 day'::interval + WHERE to_char(date_paie, 'YYYYMM')::numeric != mois_paie + ; + + CREATE INDEX i_w_hp_1 + ON w_hp + USING btree (matricule) + ; + + CREATE INDEX i_w_hp_2 + ON w_hp + USING btree (mois_activite) + ; + + CREATE INDEX i_w_hp_3 + ON w_hp + USING btree (mois_paie) + ; + + CREATE INDEX i_w_hp_4 + ON w_hp + USING btree (rubrique) + ; + + -- Insertion dans la table de production CTI. + TRUNCATE rh.p_historique_paie + ; + + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + INSERT INTO rh.p_historique_paie + ( + age_id, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id + ) + SELECT + date_part('year', age(w_hp.date_debut, date_naissance)) AS age_id, + w_hp.base AS base, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.contrat_id]))[2] AS contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.oid]))[2] AS contrat_mois_id, + w_hp.date_debut AS date_debut, + w_hp.date_fin AS date_fin, + w_hp.date_paie AS date_paie, + w_hp.mois_activite AS mois_activite, + w_hp.mois_paie AS mois_paie, + 0 AS montant_avantage_nature, + w_hp.brut AS montant_brut, + w_hp.mt_pat AS montant_cotisation_patronale, + w_hp.mt_sal AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + w_hp.net_a_payer AS montant_net_a_payer_salarie, + w_hp.net_imposable AS montant_net_imposable_salarie, + w_hp.od_net AS montant_od_net_salarie, + 0 AS organisme_cotisation_id, + t_rubriques.oid AS rubrique_id, + p_salaries.oid AS salarie_id, + w_hp.tx_pat AS taux_cotisation_patronale, + w_hp.tx_sal AS taux_cotisation_salarie, + coalesce(t_compte.oid, 0) AS compte_id + FROM w_hp + JOIN rh.t_rubriques ON t_rubriques.code_original = w_hp.rubrique + JOIN rh.p_salaries ON p_salaries.matricule = w_hp.matricule + -- LEFT JOIN rh.t_organismes_cotisation ON t_organismes_cotisation.code_original = w_hp.organisme + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + --AND p_contrats_mois.mois_activite = w_hp.mois + AND base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, w_hp.date_debut, w_hp.date_fin) + LEFT JOIN rh.t_compte ON t_compte.code_original = w_hp.compte + GROUP BY 1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calculer l'écart + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + select + -- Dates d'activité + date_debut, + date_fin, + to_char(date_fin, 'YYYYMM')::numeric AS mois_activite, + -- Dates de paie + date_paie, + substr(bulletin.bul_id, 1, 6)::numeric AS mois_paie, + bulletin.sal_matr AS matricule, + substr(bulletin.bul_id, 1, 4)::numeric AS mois, + sum(case when pla_id = 'BRUT' then lig_mont1 else 0 end)::numeric AS brut, + sum(case when pla_id = 'IMPO' then lig_mont1 else 0 end)::numeric AS net_imposable, + sum(case when pla_id = 'NETT' then lig_mont1 else 0 end)::numeric AS net_a_payer, + sum(case when pla_id = 'TOTR' then lig_mont1 else 0 end)::numeric AS mt_sal, + sum(case when pla_id = 'TOTR' then lig_mont2 * (-1) else 0 end)::numeric AS mt_pat + from prod_ccmx.v_bulletin AS bulletin + join prod_ccmx.ligne ON ligne.bul_id = bulletin.bul_id + where 1=1 + AND pla_id IN ('BRUT', 'TOTR', 'IMPO', 'NETT') + and bul_type = 'V' -- on ne conserve que les bulletins corrects. + and bulletin.eta_id = '0001' + group by 1,2,3,4,5,6,7 + ; + + -- #correction + UPDATE w_totaux + SET date_paie = (mois_paie||'01')::date + '1 month - 1 day'::interval + WHERE to_char(date_paie, 'YYYYMM')::numeric != mois_paie + ; + + -- Inserer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie + ( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, -- @deprecated + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie + ) + SELECT + age_id, + contrat_id, + contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + 0 AS montant_avantage_nature, + sum(brut - subq.montant_brut) AS montant_brut, + sum(mt_pat - subq.montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(mt_sal - subq.montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(net_a_payer - subq.montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(net_imposable - subq.montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM + ( + SELECT + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + 0 AS base, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + 0 AS organisme_cotisation_id, + 0 AS profil_id, -- p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8,9, 18,19,20,21 + ) AS subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON 1=1 + AND w_totaux.matricule = p_salaries.matricule + AND w_totaux.date_debut = subq.date_debut + AND w_totaux.date_fin = subq.date_fin + GROUP BY 1,2,3,4,5,6,7,8,9, 18,19,20,21 + HAVING 1!=1 + OR sum(brut - subq.montant_brut) <> 0 + OR sum(mt_pat - subq.montant_cotisation_patronale) <> 0 + OR sum(mt_sal - subq.montant_cotisation_salarie) <> 0 + OR sum(net_a_payer - subq.montant_net_a_payer_salarie) <> 0 + OR sum(net_imposable - subq.montant_net_imposable_salarie) <> 0 + ; + + /* + + Quels sont les écarts cumulés > 0 ? : + + SELECT + p_salaries.matricule, + p_historique_paie.* + FROM rh.p_historique_paie + JOIN rh.p_salaries on p_salaries.oid = p_historique_paie.salarie_id + JOIN rh.t_rubriques on t_rubriques.oid = p_historique_paie.rubrique_id + WHERE 1=1 + AND t_rubriques.code_original = 'C000' + AND + (1!=1 + OR p_historique_paie.base <> 0 + OR p_historique_paie.montant_brut <> 0 + OR p_historique_paie.montant_cotisation_salarie <> 0 + OR p_historique_paie.montant_cotisation_patronale <> 0 + OR p_historique_paie.montant_net_a_payer_salarie <> 0 + OR p_historique_paie.montant_net_imposable_salarie <> 0 + OR p_historique_paie.montant_avantage_nature <> 0 + ) + ORDER BY 1,4 DESC + ; + + */ + + ]]> + + + Temps complet + WHEN substr(type_temps_travail_code, 1, 1) = 'C' THEN 100 -- Tous les codes C => Temps complet + WHEN substr(type_temps_travail_code, 1, 1) = 'I' + AND length(substr(type_temps_travail_code, 2)) = 0 THEN 50 -- Tous les codes I sans % défini => Temps partiel à 50% + WHEN length(substr(type_temps_travail_code, 2)) = 0 THEN 1 -- Pas de % défini => Temps minimum à 1% + ELSE substr(type_temps_travail_code, 2)::numeric -- Le reste (P) => % défini + END)::numeric AS pct_temps_travail, + (date_fin - date_debut + 1)::numeric AS duree, + (CASE date_part('month',date_fin) + WHEN 02 THEN CASE WHEN date_part('year',date_fin) IN (2000,2004,2008,2012) THEN 29 ELSE 28 END + WHEN 04 THEN 30 + WHEN 06 THEN 30 + WHEN 09 THEN 30 + WHEN 11 THEN 30 + ELSE 31 + END)::numeric AS duree_mois + FROM rh.p_contrats_mois + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profils ON p_profils.oid = p_profil_contrat_mois.profil_id + ; + + UPDATE rh.p_contrats_mois + SET equivalent_temps_plein = round((duree / duree_mois) * (pct_temps_travail / 100), 7) + FROM maj_etp + WHERE 1=1 + AND p_contrats_mois.oid = maj_etp.contrat_mois_id + AND equivalent_temps_plein IS DISTINCT FROM round((duree / duree_mois) * (pct_temps_travail / 100), 7) + ; + + ]]> + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_CEGI.XML b/import_rh/iCTI_import_rh_CEGI.XML new file mode 100644 index 0000000..86ffb2d --- /dev/null +++ b/import_rh/iCTI_import_rh_CEGI.XML @@ -0,0 +1,2527 @@ + + + + + + '' + GROUP BY 1,4 + ; + /* + INSERT INTO rh.t_categories_socio_professionnelle + (code, texte, texte_court, code_original) + SELECT pcs_code, pcs_libelle, substr(pcs_libelle,1,50), pcs_code + FROM prod_cegi.pypcs + WHERE pcs_code NOT IN (SELECT code FROM rh.t_categories_socio_professionnelle) + ; + */ + + -- Màj des groupes cotisants. + INSERT INTO rh.t_groupes_cotisant(code, texte, texte_court, code_original) + SELECT typcot_code, typcot_libelle, substr(typcot_libelle,1,50), typcot_code + FROM prod_cegi.pytypecotisant + WHERE typcot_code NOT IN (SELECT code_original FROM rh.t_groupes_cotisant) + ; + + -- Màj des motifs de début de contrat + INSERT INTO rh.t_motifs_debut_contrat(code, texte, texte_court, code_original) + SELECT mitemb_code, mtemb_libelle, substr(mtemb_libelle,1,50), mitemb_code + FROM prod_cegi.pymtembauche + WHERE mitemb_code NOT IN (SELECT code_original FROM rh.t_motifs_debut_contrat) + ; + + -- Màj des motifs de fin de contrat + INSERT INTO rh.t_motifs_fin_contrat(code, texte, texte_court, code_original) + SELECT mtfcnt_code, mtfcnt_libelle, substr(mtfcnt_libelle,1,50), mtfcnt_code + FROM prod_cegi.pymtfcnt + WHERE mtfcnt_code NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat) + UNION ALL + SELECT 'EC', 'Contrat en cours', 'Contrat en cours', 'CTI_EC' + WHERE 'CTI_EC' NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat) + ; + + -- Màj des nationalités + INSERT INTO rh.t_nationalites(code, texte, texte_court, code_original) + SELECT nat_code, max(nat_nationalite), max(substr(nat_nationalite,1,50)), nat_code + FROM prod_cegi.pynationalite + WHERE nat_code NOT IN (SELECT code_original FROM rh.t_nationalites) + GROUP BY 1,4 + ; + + -- Màj des organismes de cotisation + INSERT INTO rh.t_organismes_cotisation(code, texte, texte_court, code_original) + SELECT org_code, org_nom, substr(org_nom_court,1,50), org_code + FROM prod_cegi.pyorganisme + WHERE org_code NOT IN (SELECT code_original FROM rh.t_organismes_cotisation) + ; + + -- Màj des qualifications + DROP TABLE IF EXISTS w_qualifications; + CREATE TEMP TABLE w_qualifications AS + SELECT qcv_code AS code, max(qcv_libelle) AS texte, substr(max(qcv_libelle),1,50) AS texte_court, qcv_code AS code_original + FROM prod_cegi.pyqualconv + WHERE true + and (select valeur = 'QUALCONV' FROM rh.t_divers WHERE code = 'CEGI_QUALIFICATION') + GROUP BY qcv_code + UNION ALL + SELECT max(qual_code) AS code, max(qual_libelle) AS texte, substr(max(qual_libelle), 1, 50) AS texte_court, qual_id::text AS code_original + FROM prod_cegi.pyqualification + WHERE true + and (select valeur = 'QUALIFICATION' FROM rh.t_divers WHERE code = 'CEGI_QUALIFICATION') + GROUP BY qual_id + ; + + INSERT INTO rh.t_qualifications(code, texte, texte_court, code_original) + SELECT code, texte, texte_court, code_original + FROM w_qualifications + WHERE true + and w_qualifications.code_original NOT IN (SELECT t_qualifications.code_original FROM rh.t_qualifications) + ; + + UPDATE rh.t_qualifications SET + code = w_qualifications.code, + texte = w_qualifications.texte, + texte_court = w_qualifications.texte_court + FROM w_qualifications + where true + AND (select valeur = '1' FROM rh.t_divers WHERE code = 'OPT_IMP_QUALIF') AND + t_qualifications.code_original = w_qualifications.code_original AND + ( + t_qualifications.code IS DISTINCT FROM w_qualifications.code OR + t_qualifications.texte IS DISTINCT FROM w_qualifications.texte OR + t_qualifications.texte_court IS DISTINCT FROM w_qualifications.texte_court + + ) + ; + + -- Màj des rubriques + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT lpad(rub_id,5,'0'), rub_libelle, substr(rub_libelle,1,50), rub_id, rub_id + FROM prod_cegi.pyrubrique + WHERE rub_id NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + -- Rubrique C000 est créée dans le SHARE. + + -- Màj des situations de famille + INSERT INTO rh.t_situations_famille(code, texte, texte_court, code_original) + SELECT + upper(substr(valpossible,1,3))||lpad(length(valpossible), 3, '0'), + valpossible, + substr(valpossible,1,50), + upper(substr(valpossible,1,3))||lpad(length(valpossible), 3, '0') + FROM prod_cegi.pypossible_valeurs + WHERE + upper(substr(valpossible,1,3))||lpad(length(valpossible), 3, '0') + NOT IN (SELECT code_original FROM rh.t_situations_famille) + AND att_code = 'SITUA' + GROUP BY 1,2,3,4 + ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code, texte, texte_court, code_original) + SELECT typcnt_code, typcnt_libelle, substr(typcnt_libelle,1,50), typcnt_code + FROM prod_cegi.PYTYPECONTRAT + WHERE typcnt_code NOT IN (SELECT code_original FROM rh.t_types_contrat) + ; + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + SELECT rhcatsoc_code, rhcatsoc_code, rhcatsoc_libelle, substr(rhcatsoc_libelle, 1, 50) + FROM prod_cegi.rhcatsoc + WHERE 1=1 + and rhcatsoc_code NOT IN (SELECT code_original FROM rh.t_statuts) + and (select valeur = 'CATSOC' from rh.t_divers where code = 'CEGI_STATUT') + GROUP BY 1,2,3,4 + UNION ALL + SELECT gri_code, gri_code, gri_libelle, substr(gri_libelle::text, 1, 50) + FROM prod_cegi.pygrilleind + WHERE 1=1 + AND gri_code NOT IN (SELECT code_original FROM rh.t_statuts) + and (select valeur = 'GRILLE' from rh.t_divers where code = 'CEGI_STATUT') + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + select + replace(cst_cnt_valeur, ',', '.'), + case when replace(cst_cnt_valeur, ',', '.') = '151.67' then 'TC' else 'TP'||round(replace(cst_cnt_valeur, ',', '.')::numeric/151.67*100, 2) end, + case when replace(cst_cnt_valeur, ',', '.') = '151.67' then 'Temps Complet' else 'Temps Partiel '||round(replace(cst_cnt_valeur, ',', '.')::numeric/151.67*100, 2)||'%' end, + case when replace(cst_cnt_valeur, ',', '.') = '151.67' then 'TC' else 'TP '||round(replace(cst_cnt_valeur, ',', '.')::numeric/151.67*100, 2)||'%' end + from prod_cegi.pycst_cnt + JOIN prod_cegi.pyconstante on pyconstante.cst_id = pycst_cnt.cst_id + WHERE true + AND cst_code = (select valeur from rh.t_divers where code = 'CEGI_CODE_TTT') + AND replace(cst_cnt_valeur, ',', '.') NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + group by 1,2,3,4 + ; + + -- Màj de la clase de type de temps de travail automatiquement. + DELETE FROM rh.t_classes_sections_elements + USING rh.t_classes, rh.t_classes_sections + WHERE 1=1 + AND t_classes_sections_elements.section_id = t_classes_sections.oid + AND t_classes_sections.classe_id = t_classes.oid + AND t_classes.code = 'CTI_TTT' + ; + + INSERT INTO rh.t_classes_sections_elements (section_id, to_id) + SELECT + t_classes_sections.oid AS section_id, + t_types_temps_travail.oid AS to_id + FROM rh.t_classes + join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + join rh.t_types_temps_travail on substr(t_types_temps_travail.code, 1, 2) = t_classes_sections.code + WHERE t_classes.code = 'CTI_TTT' + ; + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + SELECT svc_code, svc_code, max(svc_court), max(svc_court) + FROM prod_cegi.PYSERVICE + WHERE svc_code NOT IN (SELECT code_original FROM rh.t_services) + GROUP BY 1,2 + ; + + -- Màj des spécialités + INSERT INTO rh.t_specialites(code_original, code, texte, texte_court) + SELECT qcv_code AS code_original, qcv_code AS code, max(qcv_libelle) AS texte, substr(max(qcv_libelle),1,50) AS texte_court + FROM prod_cegi.pyqualconv + WHERE qcv_code NOT IN (SELECT code_original FROM rh.t_specialites) + GROUP BY 1,2 + ; + + -- Màj des codes emploi + with w_cem AS ( + SELECT modcnt_code as code_original, modcnt_code as code, max(modcnt_libelle) as texte, max(substr(modcnt_libelle,1,50)) AS texte_court + FROM prod_cegi.PYMODELCNT + WHERE true + AND (select valeur = 'MODCNT' FROM rh.t_divers WHERE code = 'CEGI_CODE_EMPLOI') + GROUP BY 1,2 + UNION ALL + SELECT qual_id::text AS code_original, max(qual_code) AS code, max(qual_libelle) AS texte, substr(max(qual_libelle), 1, 50) AS texte_court + FROM prod_cegi.pyqualification + WHERE true + and (select valeur = 'QUALIFICATION' FROM rh.t_divers WHERE code = 'CEGI_CODE_EMPLOI') + GROUP BY qual_id + ) + INSERT INTO rh.t_codes_emploi(code_original, code, texte, texte_court) + SELECT code_original, code, texte, texte_court + FROM w_cem + WHERE code_original NOT IN (SELECT code_original FROM rh.t_codes_emploi) + ; + + -- Màj des types d'horaire + + -- Màj des sociétés d'interim + + -- Màj des grilles + INSERT INTO rh.t_grilles(code_original, code, texte, texte_court) + SELECT ech_coefficient::text, ech_coefficient::text, ech_coefficient::text, substr(ech_coefficient::text, 1, 50) + FROM prod_cegi.pyvalechelon + WHERE 1=1 + AND ech_coefficient NOT IN (SELECT code_original FROM rh.t_grilles) + AND ech_coefficient != 0 + and (select valeur = 'ECHELON' from rh.t_divers where code = 'CEGI_GRILLE') + GROUP BY 1,2,3,4 + UNION ALL + SELECT gri_code, gri_code, gri_libelle, substr(gri_libelle::text, 1, 50) + FROM prod_cegi.pygrilleind + WHERE 1=1 + AND gri_code NOT IN (SELECT code_original FROM rh.t_grilles) + and (select valeur = 'GRILLE' from rh.t_divers where code = 'CEGI_GRILLE') + GROUP BY 1,2,3,4 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT rpad(gri_code, 5, '0')||ech_ordre, rpad(gri_code, 5, '0')||ech_ordre, ech_ordre::text||' : '||ech_echelon::text, substr(ech_ordre::text||' : '||ech_echelon::text,1,50) + FROM prod_cegi.pyechelon + JOIN prod_cegi.pygrilleind ON pygrilleind.gri_id = pyechelon.gri_id + WHERE rpad(gri_code, 5, '0')||ech_ordre NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + ; + + -- Màj des motifs d'arret + INSERT INTO rh.t_motifs_arret(code_original, code, texte, texte_court) + SELECT abspar_code, abspar_code, max(abspar_libelle), substr(max(abspar_libelle),1,50) + FROM prod_cegi.absenceparam + WHERE abspar_code NOT IN (SELECT code_original FROM rh.t_motifs_arret) + GROUP BY 1,2 + ; + + -- Màj des sections analytiques compta + INSERT INTO rh.t_sections_analytiques(code_original, code, texte, texte_court) + SELECT vent_id, vent_code, vent_libelle, substr(vent_libelle,1,50) + FROM prod_cegi.pyventilation + WHERE vent_id NOT IN (SELECT code_original FROM rh.t_sections_analytiques) + ; + + -- Màj des sections analytiques paie + INSERT INTO rh.t_sections_analytiques_paie(code_original, code, texte, texte_court) + SELECT ana_id, ana_codana, ana_lib, substr(ana_lib,1,50) + FROM prod_cegi.rhp_cmcodesana + WHERE ana_id NOT IN (SELECT code_original FROM rh.t_sections_analytiques_paie) + ; + + -- Màj des "Comptes" + INSERT INTO rh.t_compte(code_original, code, texte, texte_court) + SELECT plc_compte, plc_compte, plc_libelle, substr(plc_libelle, 1, 50) + FROM prod_cegi.rhp_cmplancpt + WHERE plc_compte NOT IN (SELECT code_original FROM rh.t_compte) + ; + + ]]> + + + + + + + + = 2016 + AND (p_cumul OR p_detail) + GROUP BY 1,2,3 + ; + + ]]> + + + 0 + ; + + CREATE INDEX w_pycontrat_1 ON w_pycontrat USING btree (per_id) + ; + CREATE INDEX w_pycontrat_2 ON w_pycontrat USING btree (cnt_id) + ; + CREATE INDEX w_pycontrat_3 ON w_pycontrat USING btree (date_debut) + ; + CREATE INDEX w_pycontrat_4 ON w_pycontrat USING btree (date_fin) + ; + + -- Création d'une table de bulletins avec dates traitées. + DROP TABLE IF EXISTS w_pybulletin + ; + + CREATE TEMP TABLE w_pybulletin AS + SELECT + case when to_char(bul_debutrem, 'YYYYMM')::int = (cal_an::int::text||lpad(cal_nperiode, 2, '0'))::int + then bul_debutrem::date + else base.cti_last_day((cal_an::int::text||lpad(cal_nperiode, 2, '0')||'01')::date) + end AS date_debut, + case when to_char(bul_debutrem, 'YYYYMM')::int = (cal_an::int::text||lpad(cal_nperiode, 2, '0'))::int + then coalesce(bul_finrem::date, '20991231'::date) + else base.cti_last_day((cal_an::int::text||lpad(cal_nperiode, 2, '0')||'01')::date) + end AS date_fin, + (cal_an::int::text||lpad(cal_nperiode, 2, '0'))::int as mois_paie, + w_pycontrat.eta_id, + pybulletin.* + FROM prod_cegi.pybulletin + JOIN w_pycontrat ON 1=1 + and w_pycontrat.per_id = pybulletin.per_id + and w_pycontrat.cnt_id = pybulletin.cnt_id + WHERE 1=1 + and pybulletin.per_id > 0 + -- and pybulletin.bul_apayer = 1 + ; + + CREATE INDEX w_pybulletin_1 ON w_pybulletin USING btree (per_id) + ; + CREATE INDEX w_pybulletin_2 ON w_pybulletin USING btree (bul_id) + ; + CREATE INDEX w_pybulletin_3 ON w_pybulletin USING btree (date_debut) + ; + CREATE INDEX w_pybulletin_4 ON w_pybulletin USING btree (date_fin) + ; + + -- Création d'une table d'échelons avec dates traitées. + DROP TABLE IF EXISTS w_pyech_cnt + ; + + CREATE TEMP TABLE w_pyech_cnt AS + with w_temp as ( + select + ech_id, + per_id, + cnt_id, + cnt_ech_deb::date as date_debut + from prod_cegi.pyech_cnt + group by 1,2,3,4 + ) + select + ech_id, + per_id, + cnt_id, + date_debut, + coalesce(lead(date_debut) over (partition by per_id, cnt_id order by date_debut) - 1, '20991231'::date) as date_fin + from w_temp + ; + + CREATE INDEX w_pyech_cnt_1 ON w_pyech_cnt USING btree (per_id) + ; + CREATE INDEX w_pyech_cnt_2 ON w_pyech_cnt USING btree (ech_id) + ; + CREATE INDEX w_pyech_cnt_3 ON w_pyech_cnt USING btree (date_debut) + ; + CREATE INDEX w_pyech_cnt_4 ON w_pyech_cnt USING btree (date_fin) + ; + CREATE INDEX w_pyech_cnt_5 ON w_pyech_cnt USING btree (cnt_id) + ; + + DROP TABLE IF EXISTS w_pyvalechelon + ; + + CREATE TEMP TABLE w_pyvalechelon AS + select + ech_id, + ech_coefficient, + ech_deb::date as date_debut, + coalesce(lead(ech_deb::date) over (partition by ech_id order by ech_deb) - 1, '20991231'::date) as date_fin + from prod_cegi.pyvalechelon + ; + CREATE INDEX w_pyvalechelon_1 ON w_pyvalechelon USING btree (ech_id) + ; + CREATE INDEX w_pyvalechelon_2 ON w_pyvalechelon USING btree (date_debut) + ; + CREATE INDEX w_pyvalechelon_3 ON w_pyvalechelon USING btree (date_fin) + ; + + -- Création d'une table de types de temps de travail. + DROP TABLE IF EXISTS w_ttt + ; + + CREATE TEMP TABLE w_ttt AS + select + pycst_cnt.per_id, + pycst_cnt.cnt_id, + replace(cst_cnt_valeur, ',', '.') as ttt_code_original, + replace(cst_cnt_valeur, ',', '.')::numeric as heures_theoriques, -- heures théoriques de la constante Cegi AAAAC. + cst_cnt_deb::date as ttt_cnt_deb, + row_number() OVER w as ttt_id, + cst_cnt_deb::date AS date_debut, + coalesce(lead(cst_cnt_deb::date) over w - 1, '20991231'::date) as date_fin + from prod_cegi.pycst_cnt + JOIN prod_cegi.pyconstante on pyconstante.cst_id = pycst_cnt.cst_id + WHERE 1=1 + AND cst_code = (select valeur from rh.t_divers where code = 'CEGI_CODE_TTT') -- Par défaut 'AAAAC', 'AARM' pour M. LGF. + AND trim(cst_cnt_valeur) != '' + WINDOW w as (partition by pycst_cnt.per_id, pycst_cnt.cnt_id order by cst_cnt_deb) + ; + + CREATE INDEX w_ttt_1 ON w_ttt USING btree (per_id) + ; + CREATE INDEX w_ttt_2 ON w_ttt USING btree (cnt_id) + ; + CREATE INDEX w_ttt_3 ON w_ttt USING btree (ttt_code_original) + ; + CREATE INDEX w_ttt_4 ON w_ttt USING btree (date_debut) + ; + CREATE INDEX w_ttt_5 ON w_ttt USING btree (date_fin) + ; + + -- Création d'une table des qualifications conventionelles. + DROP TABLE IF EXISTS w_qualconv + ; + + CREATE TEMP TABLE w_qualconv AS + select + per_id, + cnt_id, + cnt_qcv_effet::date as date_debut, + lag(cnt_qcv_effet::date - 1, -1, '2099-12-31'::date) over w as date_fin, + qcv_code, + pcs_code_2003 + from prod_cegi.pyqconv_cnt + JOIN prod_cegi.pyqualconv ON pyqualconv.qcv_id = pyqconv_cnt.qcv_id + window w as (partition by per_id, cnt_id order by cnt_qcv_effet) + ; + + CREATE INDEX w_quaconv_1 ON w_qualconv USING btree (per_id) + ; + CREATE INDEX w_quaconv_2 ON w_qualconv USING btree (cnt_id) + ; + CREATE INDEX w_quaconv_3 ON w_qualconv USING btree (qcv_code) + ; + + -- Création d'une table des qualifications. + DROP TABLE IF EXISTS w_qualification + ; + + CREATE TEMP TABLE w_qualification AS + select + per_id, + cnt_id, + cnt_qual_effet::date as date_debut, + lag(cnt_qual_effet::date - 1, -1, '2099-12-31'::date) over w as date_fin, + qual_id::text + from prod_cegi.pyqual_cnt + window w as (partition by per_id, cnt_id order by cnt_qual_effet) + ; + + CREATE INDEX w_qualification_1 ON w_qualification USING btree (per_id) + ; + CREATE INDEX w_qualification_2 ON w_qualification USING btree (cnt_id) + ; + CREATE INDEX w_qualification_3 ON w_qualification USING btree (qual_id) + ; + + -- Création d'une table des ventilations analytiques. + DROP TABLE IF EXISTS w_ana + ; + + CREATE TEMP TABLE w_ana AS + with pyperioderep as ( + select + per_id, + cnt_id, + prep_id, + prep_debut::date as date_debut, + coalesce(lead(prep_debut) over (partition by per_id, cnt_id order by prep_debut) - '1 day'::interval, '2099-12-31'::date)::date as date_fin + from prod_cegi.pyperioderep) + , pyrepcnt_compta as ( + select + vent_id, + rep_id, + ana_id, + sum(repcompta_taux) as repcompta_taux + from prod_cegi.pyrepcnt_compta + group by 1,2,3) + , ana as ( + select + pyperioderep.per_id, + pyperioderep.cnt_id, + pyperioderep.date_debut, + pyperioderep.date_fin, + pyrepcnt_compta.ana_id, + pyrepcnt_compta.vent_id, + -- #correction des taux qui ne font pas 100%... + coalesce(base.cti_division(coalesce(repana_taux, repcompta_taux, 1)::numeric , sum(coalesce(repana_taux, repcompta_taux, 1)) over (partition by pyperioderep.per_id, pyperioderep.cnt_id, pyperioderep.date_debut, pyrepartition.rep_id)::numeric), 1) * (pyrepartition.rep_taux / 100.0) as ratio + from pyperioderep + LEFT JOIN prod_cegi.pyrepartition ON 1=1 + and pyrepartition.prep_id = pyperioderep.prep_id + and pyrepartition.rep_taux > 0 + LEFT JOIN prod_cegi.pyrepcnt_ana ON pyrepcnt_ana.rep_id = pyrepartition.rep_id + LEFT JOIN pyrepcnt_compta ON pyrepcnt_compta.rep_id = pyrepartition.rep_id) + select + per_id, + cnt_id, + date_debut, + date_fin, + ana_id, + vent_id, + sum(ratio) as ratio + from ana + GROUP BY 1,2,3,4,5,6 + ; + + CREATE INDEX w_ana_1 ON w_ana USING btree (per_id) + ; + CREATE INDEX w_ana_2 ON w_ana USING btree (cnt_id) + ; + CREATE INDEX w_ana_3 ON w_ana USING btree (ana_id) + ; + CREATE INDEX w_ana_4 ON w_ana USING btree (vent_id) + ; + + DROP TABLE IF EXISTS w_rhcatscnt + ; + + CREATE TEMP TABLE w_rhcatscnt AS + select + rhcatsoc_code, + per_id, + cnt_id, + rhcatscnt_datdeb::date as date_debut, + coalesce(lead(rhcatscnt_datdeb::date) over (partition by per_id, cnt_id order by rhcatscnt_datdeb) - 1, '20991231'::date) as date_fin + from prod_cegi.rhcatscnt + join prod_cegi.rhcatsoc on rhcatsoc.rhcatsoc_id = rhcatscnt.rhcatsoc_id + ; + CREATE INDEX w_rhcatscnt_1 ON w_rhcatscnt USING btree (per_id) + ; + CREATE INDEX w_rhcatscnt_2 ON w_rhcatscnt USING btree (date_debut) + ; + CREATE INDEX w_rhcatscnt_3 ON w_rhcatscnt USING btree (date_fin) + ; + CREATE INDEX w_rhcatscnt_4 ON w_rhcatscnt USING btree (cnt_id) + ; + + -- Etape 0 : identifier les salariés qui ont eu au moins 1 bulletin ET 1 contrat. + + -- Etape 1 : se créer une ventilation "maître" des événements salariés basée sur les contrats et/ou les bulletins. + -- Elle doit identifier les bulletins hors période de contrat (est_hors_periode). + -- Elle doit aussi être corrigée (les bulletins sans contrat doivent être associés d'abord au contrat le plus en amont et à défaut en aval s'il y en a) + + -- Etape 2 : Cette ventilation maître servira à rattacher les autres dimensions. + + -- Ventilation journalière ? mensuelle ? + -- Comment fait-on quand changement de dimension en cours de route (sans changement de contrat/bulletin) + -- => la ventilation "maître" ne sert à rien dans ce cas alors ... => SI : à cadrer les historiques des autres dimensions. + + + -- Etape 0 : création d'une table de salariés ayant eu au moins une paie ET un contrat. + DROP TABLE IF EXISTS w_sal_paye + ; + + CREATE TEMP TABLE w_sal_paye AS + SELECT + pysalarie.per_id, + pysalarie.sal_matricule, + min(greatest('2015-01-01'::date, least(w_pycontrat.date_debut, w_pybulletin.date_debut))) AS min_date, -- FIXME Optimiser la requete car on part de 2015 pour l'instant... + max(least(base.cti_last_day(current_date), greatest(w_pycontrat.date_fin, w_pybulletin.date_fin, w_pybulletin.bul_datepaie::date))) AS max_date + FROM prod_cegi.pysalarie + LEFT JOIN w_pycontrat ON w_pycontrat.per_id = pysalarie.per_id + LEFT JOIN w_pybulletin ON w_pybulletin.per_id = pysalarie.per_id + WHERE pysalarie.per_id > 0 + GROUP BY 1, 2, w_pycontrat.per_id, w_pybulletin.per_id + HAVING 1!=1 + OR w_pycontrat.per_id IS NOT NULL + OR w_pybulletin.per_id IS NOT NULL + ; + + CREATE INDEX w_sal_paye_1 ON w_sal_paye USING btree (per_id) + ; + + -- Etape 1 + DROP TABLE IF EXISTS w_tmp_1 + ; + + CREATE TEMP TABLE w_tmp_1 AS + with raw as ( + select + w_sal_paye.sal_matricule, + w_sal_paye.per_id, + cnt_id, + false as est_hors_periode, + eta_id, + p_calendrier.date, + p_calendrier.mois + FROM base.p_calendrier + join w_sal_paye ON date BETWEEN w_sal_paye.min_date AND w_sal_paye.max_date + JOIN w_pycontrat ON 1=1 + AND w_pycontrat.per_id = w_sal_paye.per_id + AND date BETWEEN w_pycontrat.date_debut AND w_pycontrat.date_fin + -- where w_sal_paye.per_id = 11868 + group by 1,2,3,4,5,6,7 + union all + select + w_sal_paye.sal_matricule, + w_sal_paye.per_id, + cnt_id as cnt_id, + true as est_hors_periode, + eta_id, + p_calendrier.date, + p_calendrier.mois + FROM base.p_calendrier + join w_sal_paye ON date BETWEEN w_sal_paye.min_date AND w_sal_paye.max_date + JOIN w_pybulletin ON 1=1 + AND w_pybulletin.per_id = w_sal_paye.per_id + AND date BETWEEN w_pybulletin.date_debut AND w_pybulletin.date_fin + -- where w_sal_paye.per_id = 11868 + group by 1,2,3,4,5,6) + , trame_cnt as ( + select + sal_matricule, + per_id, + cnt_id, + bool_and(est_hors_periode) as est_hors_periode, + max(eta_id) as eta_id, + date, + mois + from raw + group by 1,2,3, 6,7) + select + trame_cnt.date, + trame_cnt.mois, + trame_cnt.sal_matricule, + trame_cnt.per_id, + trame_cnt.eta_id, + trame_cnt.est_hors_periode, + trame_cnt.cnt_id, + -- trame_cnt.cnt_id_all, + w_pybulletin.bul_id, + w_pyech_cnt.ech_id, + w_rhcatscnt.rhcatsoc_code, + coalesce(w_ttt.ttt_code_original, '151.67'::text) as ttt_code_original, -- Par défaut temps complet. + coalesce(w_ttt.heures_theoriques, 151.67) as heures_theoriques -- Par défaut temps complet. + FROM trame_cnt + -- LEFT JOIN w_pycontrat ON 1=1 + -- AND w_pycontrat.per_id = trame_cnt.per_id + -- AND date BETWEEN w_pycontrat.date_debut AND w_pycontrat.date_fin + LEFT JOIN w_pybulletin ON 1=1 + AND w_pybulletin.per_id = trame_cnt.per_id + AND w_pybulletin.cnt_id = trame_cnt.cnt_id -- rajout du lien technique Cegi obligatoire pour ne plus avoir de pdt cartésien lorsque multi-contrats. + AND date BETWEEN w_pybulletin.date_debut AND w_pybulletin.date_fin + LEFT JOIN w_pyech_cnt ON 1=1 + AND w_pyech_cnt.per_id = trame_cnt.per_id + AND w_pyech_cnt.cnt_id = trame_cnt.cnt_id -- rajout du lien technique Cegi obligatoire pour ne plus avoir de pdt cartésien lorsque multi-contrats. + AND date BETWEEN w_pyech_cnt.date_debut AND w_pyech_cnt.date_fin + LEFT JOIN w_ttt on 1=1 + AND w_ttt.per_id = trame_cnt.per_id + AND w_ttt.cnt_id = trame_cnt.cnt_id -- rajout du lien technique Cegi obligatoire pour ne plus avoir de pdt cartésien lorsque multi-contrats. + AND date BETWEEN w_ttt.date_debut AND w_ttt.date_fin + LEFT JOIN w_rhcatscnt on 1=1 + AND w_rhcatscnt.per_id = trame_cnt.per_id + AND w_rhcatscnt.cnt_id = trame_cnt.cnt_id -- rajout du lien technique Cegi obligatoire pour ne plus avoir de pdt cartésien lorsque multi-contrats. + AND date BETWEEN w_rhcatscnt.date_debut AND w_rhcatscnt.date_fin + ; + + DROP TABLE IF EXISTS w_profils + ; + + CREATE TEMP TABLE w_profils AS + SELECT + coalesce(case when mitemb_code = 'TC' then 'CDI' else typcnt_code end,chr(1)||'*') AS type_contrat_code_original, + chr(1)||'*' AS type_horaire_code_original, + coalesce(mitemb_code,chr(1)||'*') AS motif_debut_code_original, + coalesce(mtfcnt_code, case when pycontrat.date_fin = '20991231' then 'CTI_EC' else mtfcnt_code end, chr(1)||'*') AS motif_fin_code_original, + coalesce(CASE WHEN (select valeur = 'QUALIFICATION' FROM rh.t_divers WHERE code = 'CEGI_QUALIFICATION') THEN w_qualification.qual_id ELSE w_qualconv.qcv_code END, chr(1)||'*') AS qualification_code_original, + coalesce(pyservice.svc_code,chr(1)||'*') AS service_code_original, + coalesce(w_qualconv.qcv_code, chr(1)||'*') AS specialite_code_original, + coalesce(ttt_code_original, chr(1)||'*') AS type_temps_travail_code_original, + coalesce(lower(w_qualconv.pcs_code_2003),chr(1)||'*') AS categorie_socio_professionnelle_code_original, + coalesce(CASE WHEN (select valeur = 'GRILLE' FROM rh.t_divers WHERE code = 'CEGI_STATUT') THEN gri_code ELSE w_tmp_1.rhcatsoc_code END, chr(1)||'*') AS statut_code_original, + coalesce(CASE WHEN (select valeur = 'QUALIFICATION' FROM rh.t_divers WHERE code = 'CEGI_CODE_EMPLOI') THEN w_qualification.qual_id ELSE pymodelcnt.modcnt_code END, chr(1)||'*') AS code_emploi_code_original, + chr(1)||'*' AS societe_interim_code_original, + coalesce(w_ana.ana_id::text,chr(1)||'*') AS section_analytique_paie_code_original, + coalesce(w_ana.vent_id::text,chr(1)||'*') AS section_analytique_code_original, + coalesce(rpad(gri_code, 5, '0')||ech_ordre, chr(1)||'*') AS grille_groupe_code_original, + coalesce(case when (select valeur = 'GRILLE' from rh.t_divers where code = 'CEGI_GRILLE') then gri_code else ech_coefficient::text end, chr(1)||'*') AS grille_code_original, + coalesce(pytypecotisant.typcot_code,chr(1)||'*') AS groupe_cotisant_code_original, + chr(1)||'*' AS cadre_emploi_code_original, + chr(1)||'*' AS categorie_conge_code_original, + chr(1)||'*' AS categorie_statutaire_code_original, + chr(1)||'*' AS commission_paritaire_code_original, + chr(1)||'*' AS compte_salarie_code_original, + chr(1)||'*' AS filiere_code_original, + chr(1)||'*' AS lettre_budgetaire_code_original, + chr(1)||'*' AS unite_fonctionnelle_code_original, + pycontrat.date_debut AS date_debut_contrat, + pycontrat.date_fin AS date_fin_contrat, + coalesce(pycontrat.cnt_id,0) AS cnt_id, + -- w_tmp_1.cnt_id_all AS cnt_id_all, + w_tmp_1.est_hors_periode AS est_hors_periode, + w_tmp_1.per_id AS per_id, + w_tmp_1.eta_id AS eta_id, + coalesce(w_tmp_1.bul_id,0) AS bul_id, + w_tmp_1.eta_id::text||'|'||w_tmp_1.sal_matricule::text||'|'||pycontrat.cnt_id::text AS code_original_cnt, + -- w_tmp_1.eta_id::text||'|'||w_tmp_1.sal_matricule::text||'|'||w_tmp_1.cnt_id_all::text AS code_original_cnt_all, + w_tmp_1.heures_theoriques / 151.67 as ratio_temps_travail, + 0 AS profil_id, + w_tmp_1.mois, + coalesce(w_ana.ratio, 1) as ratio, + min(w_tmp_1.date) AS date_debut, + max(w_tmp_1.date) AS date_fin + FROM w_tmp_1 + LEFT JOIN w_pycontrat AS pycontrat ON 1=1 + AND pycontrat.per_id = w_tmp_1.per_id + AND pycontrat.cnt_id = w_tmp_1.cnt_id + LEFT JOIN prod_cegi.pymodelcnt on pymodelcnt.modcnt_id = pycontrat.modcnt_id + LEFT JOIN prod_cegi.pytypecnt_cnt ON 1=1 + AND pytypecnt_cnt.per_id = w_tmp_1.per_id + AND pytypecnt_cnt.cnt_id = w_tmp_1.cnt_id + AND date between cnt_typecnt_deb and case when cnt_typecnt_fin is null then '20991231'::date else cnt_typecnt_fin end + LEFT JOIN prod_cegi.pytypecontrat ON pytypecontrat.typcnt_id = pytypecnt_cnt.typcnt_id + LEFT JOIN prod_cegi.pytypecotisant ON pytypecotisant.typcot_code = pycontrat.typcot_code + LEFT JOIN prod_cegi.pymtembauche ON pymtembauche.mitemb_id = pycontrat.mitemb_id + LEFT JOIN prod_cegi.pymtfcnt ON pymtfcnt.mtfcnt_id = pycontrat.mtfcnt_id + LEFT JOIN prod_cegi.pygrilleind ON pygrilleind.gri_id = pycontrat.gri_id + LEFT JOIN prod_cegi.pyechelon ON pyechelon.ech_id = w_tmp_1.ech_id + LEFT JOIN w_pyvalechelon ON 1=1 + AND w_pyvalechelon.ech_id = w_tmp_1.ech_id + AND date BETWEEN w_pyvalechelon.date_debut AND w_pyvalechelon.date_fin + LEFT JOIN w_qualconv ON 1=1 + AND w_qualconv.cnt_id = w_tmp_1.cnt_id + AND w_qualconv.per_id = w_tmp_1.per_id + AND date between w_qualconv.date_debut and w_qualconv.date_fin + LEFT JOIN w_qualification ON 1=1 + AND w_qualification.cnt_id = w_tmp_1.cnt_id + AND w_qualification.per_id = w_tmp_1.per_id + AND date between w_qualification.date_debut and w_qualification.date_fin + LEFT JOIN prod_cegi.pyservice ON pyservice.svc_code = pycontrat.svc_code + LEFT JOIN w_ana ON 1=1 + AND w_ana.per_id = w_tmp_1.per_id + AND w_ana.cnt_id = w_tmp_1.cnt_id + AND date between w_ana.date_debut and w_ana.date_fin + JOIN w_ets ON w_ets.eta_id = w_tmp_1.eta_id + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37 + ; + + ]]> + + + + + + + + Si les dates d'entrée/sortie d'établissement semblent incohérentes par rapports aux dates des contrats, les corriger. + UPDATE rh.p_salaries + SET date_entree_ets = date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) subview + WHERE 1=1 + AND p_salaries.oid = subview.salarie_id + -- AND date_debut_contrat < date_entree_ets -- On corrige désormais TOUTES les dates d'entrées ets. car cela pose des soucis de calcul + -- des TOPs entrée/sortie ets. dans p_contrats_mois. + ; + + UPDATE rh.p_salaries + SET date_sortie_ets = date_fin_contrat + FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) subview + WHERE 1=1 + AND p_salaries.oid = subview.salarie_id + AND date_fin_contrat > date_sortie_ets + ; + + -- Calcul ancienneté au début de contrat + UPDATE rh.p_contrats SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_jours / 30 + FROM ( + select + pycontrat.code_original, + case when row_number() OVER w = 1 + then 0 + else lag(cnt_datefin::date, 1, '2099-12-31'::date) over w - min(cnt_datedeb::date) over w + 1 + end as anciennete_anterieure_jours + FROM w_pycontrat as pycontrat + WINDOW w AS (partition by per_id order by cnt_datedeb)) AS subq + WHERE 1=1 + AND p_contrats.code_original = subq.code_original + ; + + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + est_hors_periode, + ratio_temps_travail, + profil_id) + SELECT + p_contrats.salarie_id, + p_contrats.oid AS contrat_id, + w_profils.mois AS mois, + w_profils.date_debut AS date_debut, + w_profils.date_fin AS date_fin, + case when w_profils.cnt_id = 0 then 1 else 0 end as est_hors_periode, + w_profils.ratio_temps_travail, + max(coalesce(w_profils.profil_id, 0)) as profil_id -- si pas de max(), peut dédoubler les contrats mois à cause de prod_cegi.pyrepcnt_ana lors de la création de w_profils. + FROM w_profils + JOIN rh.p_contrats ON 1=1 + AND w_profils.code_original_cnt = p_contrats.code_original + -- AND base.cti_overlaps(p_contrats.date_debut, p_contrats.date_fin, w_profils.date_debut, w_profils.date_fin) + JOIN rh.p_salaries ON p_contrats.salarie_id = p_salaries.oid + JOIN rh.t_etablissements ON p_contrats.etablissement_id = t_etablissements.oid + JOIN rh.t_entreprises ON t_etablissements.entreprise_id = t_entreprises.oid + WHERE 1=1 + --AND p_calendrier_mois.mois >= 201601 + AND w_profils.date_debut <= base.cti_last_day(current_date) + GROUP BY 1,2,3,4,5,6,7 + ; + + ]]> + + + = 2016 + AND (1!=1 + OR t_rubriques.p_detail + OR t_rubriques.p_cumul) + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 + ; + + DROP TABLE IF EXISTS w_hp_1 + ; + + CREATE TEMP TABLE w_hp_1 AS + with ruv as ( + select + ruv_id, + ruvjs_signed, + plc_compte as ruv_plc_compte + from prod_cegi.pyrubjsal + join prod_cegi.pyljsalaireent on pyljsalaireent.ljs_id = PYRUBJSAL.ljs_id + where ruvjs_signed = 1) + ,cot as ( + select + cot_id, + cotjs_signed, + plc_compte as cot_plc_compte + from prod_cegi.pycotjsal + join prod_cegi.pyljsalaireent as cotcot on cotcot.ljs_id = PYcotJSAL.ljs_id) + ,hp as ( + select + pylignebulletin.ctid as plb_ctid, + pylignebulletin.bul_id, + pylignebulletin.rub_id, + max(coalesce(ruv_plc_compte, cot_plc_compte)::text) as plc_compte + from prod_cegi.pylignebulletin + join prod_cegi.pybulletin on pybulletin.bul_id = pylignebulletin.bul_id + left join ruv on ruv.ruv_id = pylignebulletin.ruv_id + left join cot on cot.cot_id = pylignebulletin.cot_id + group by 1,2,3) + , hp2 as ( + SELECT + w_hp.plb_ctid, + cti_cnt_id, + w_hp.bul_id, + w_hp.date_debut, + w_hp.date_fin, + bul_datepaie, + p_salaries.oid as salarie_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id, + w_hp.mois_activite, + w_hp.mois_paie, + w_hp.date_paie, + t_rubriques.oid as rubrique_id, + max(coalesce(t_compte.oid, 0)) as compte_id, + t_rubriques.p_detail, + t_rubriques.p_cumul, + 0 as organisme_cotisation_id, + w_hp.etablissement_id, + w_hp.base, + w_hp.nombre, + w_hp.heures_contrat, + w_hp.heures_payees, + w_hp.heures_travaillees, + w_hp.montant_masse_salariale, + w_hp.montant_brut, + w_hp.montant_avantage_nature, + w_hp.montant_frais_imposables, + w_hp.taux_cotisation_salarie, + w_hp.montant_cotisation_salarie, + w_hp.taux_cotisation_patronale, + w_hp.montant_cotisation_patronale, + w_hp.montant_od_net_salarie, + w_hp.montant_od_net_patronale, + w_hp.montant_net_imposable_salarie, + w_hp.montant_net_a_payer_salarie, + w_hp.nombre_provisions, + w_hp.montant_provisions, + w_hp.montant_masse_salariale_provisionnee + FROM w_hp + LEFT JOIN rh.p_contrats on p_contrats.code_original = w_hp.cti_cnt_id + LEFT JOIN rh.p_contrats_mois on 1=1 + AND p_contrats_mois.contrat_id = p_contrats.oid + AND p_contrats_mois.mois_activite = w_hp.mois_activite + JOIN rh.p_salaries on p_salaries.code_original = w_hp.salarie_code_original + JOIN rh.t_rubriques on t_rubriques.code_original = w_hp.RUB_ID + left join hp on hp.plb_ctid = w_hp.plb_ctid + left join hp as hp2 on hp2.bul_id = w_hp.bul_id and hp2.rub_id in (10000, 10001) + LEFT JOIN rh.t_compte on t_compte.code_original = coalesce(hp.plc_compte, case when w_hp.rub_id < 10000 then hp2.plc_compte else null end) + GROUP BY 1,2,3,4,5,6,7, 10,11,12,13 ,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,w_hp.ctid) + SELECT + nextval('rh.s_historique_paie') as hp_oid, + plb_ctid, + cti_cnt_id, + bul_id, + date_debut, + date_fin, + bul_datepaie, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + mois_paie, + date_paie, + rubrique_id, + compte_id, + p_detail, + p_cumul, + organisme_cotisation_id, + etablissement_id, + base, + nombre, + heures_contrat, + heures_payees, + heures_travaillees, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee + FROM hp2 + ; + + -- UPDATE rh.p_historique_paie + -- SET date_debut = date_fin + -- WHERE date_debut > date_fin + -- ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie( + oid, + code_original, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + compte_id, + organisme_cotisation_id, + etablissement_id, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + hp_oid, + bul_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + compte_id, + organisme_cotisation_id, + etablissement_id, + CASE WHEN base > 99999999 THEN 99999999.99 ELSE round(base::numeric,2) END , + nombre, + heures_contrat, + heures_payees, + heures_travaillees, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + CASE WHEN taux_cotisation_salarie > 999999 THEN 999999.9999999 ELSE round(taux_cotisation_salarie::numeric,7) END, + montant_cotisation_salarie, + CASE WHEN taux_cotisation_salarie > 999999 THEN 999999.9999999 ELSE round(taux_cotisation_patronale::numeric,7) END, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee + FROM w_hp_1 + where p_detail; + + -- Application du ratio temps de travail pour les temps partiels. + update rh.p_historique_paie set + base = base * ratio_temps_travail + from rh.p_contrats_mois + where 1=1 + and p_historique_paie.contrat_mois_id = p_contrats_mois.oid + and rubrique_id in (select oid from rh.t_rubriques where @c_base != 1) + and ratio_temps_travail != 1 + ; + + update rh.p_historique_paie set + nombre = nombre * ratio_temps_travail + from rh.p_contrats_mois + where 1=1 + and p_historique_paie.contrat_mois_id = p_contrats_mois.oid + and rubrique_id in (select oid from rh.t_rubriques where @c_nombre != 1) + and ratio_temps_travail != 1 + ; + + -- Alimentation de la base de la rubrique 1052 forfait jour à partir de la constante AAAAC. + DROP TABLE IF EXISTS w_forfait_jour + ; + + CREATE TEMP TABLE w_forfait_jour AS + with fj2 as ( + select pycontrat.eta_id::text||'|'||pysalarie.sal_matricule::text||'|'||pycontrat.cnt_id::text as ncnt + from prod_cegi.pyconstante + join prod_cegi.pycst_cnt on pycst_cnt.cst_id = pyconstante.cst_id + join prod_cegi.pysalarie on pysalarie.per_id = pycst_cnt.per_id + JOIN prod_cegi.pycontrat ON 1=1 + and pycontrat.per_id = pycst_cnt.per_id + and pycontrat.cnt_id = pycst_cnt.cnt_id + where cst_code = (select valeur FROM rh.t_divers WHERE code = 'CEGI_CST_FJ') + ) + select + php.oid as f_id, + ratio_temps_travail -- ratio du temps de travail (constance AAAAC). + -- ratio du nombre de jours du bulletin vs. nombre de jour sur le mois + * (php.date_fin - php.date_debut + 1)::numeric / (base.cti_last_day((php.mois_paie||'01')::date) - base.cti_first_day((php.mois_paie||'01')::date) + 1)::numeric + -- temps de travail réglementaire 35h. + * 151.67 as heures_forfait + from rh.p_historique_paie as php + join rh.p_contrats_mois on p_contrats_mois.oid = php.contrat_mois_id + where 1=1 + and rubrique_id = (select oid from rh.t_rubriques where code = '01052') + and (select valeur = '1' FROM rh.t_divers WHERE code = 'CEGI_FORFAIT_JOUR') + + UNION ALL + + select + hp_oid as f_id, + ratio_temps_travail -- ratio du temps de travail (constante AAAAC ou AARM). + -- ratio du nombre de jours du bulletin vs. nombre de jour sur le mois + * (php.date_fin - php.date_debut + 1)::numeric / (base.cti_last_day((php.mois_paie||'01')::date) - base.cti_first_day((php.mois_paie||'01')::date) + 1)::numeric + -- temps de travail réglementaire 35h. + * 151.67 as heures_forfait + from w_hp_1 as php + join rh.p_contrats_mois on p_contrats_mois.oid = php.contrat_mois_id + join rh.p_contrats on p_contrats.oid = p_contrats_mois.contrat_id + join fj2 on fj2.ncnt = p_contrats.code_original + where 1=1 + and rubrique_id IN (select oid from rh.t_rubriques where code IN ('01050', '10000')) + and (select valeur = '2' FROM rh.t_divers WHERE code = 'CEGI_FORFAIT_JOUR') + ; + + update rh.p_historique_paie as php set + base = heures_forfait, + heure_contrat = heures_forfait, + heure_payee = heures_forfait, + heure_travaillee = + case (select valeur FROM rh.t_divers WHERE code = 'CEGI_FORFAIT_JOUR') + when '1' then heures_forfait + when '2' then 0.0 + else 0.0 + end + from w_forfait_jour + where w_forfait_jour.f_id = php.oid + ; + + update w_hp_1 as php set + heures_contrat = heures_forfait, + heures_payees = heures_forfait, + heures_travaillees = + case (select valeur FROM rh.t_divers WHERE code = 'CEGI_FORFAIT_JOUR') + when '1' then heures_forfait + when '2' then 0.0 + else 0.0 + end + from w_forfait_jour + where w_forfait_jour.f_id = php.hp_oid + ; + + DROP TABLE IF EXISTS w_tmp + ; + + CREATE TEMP TABLE w_tmp AS + SELECT + cti_cnt_id, + bul_id, + salarie_id, + contrat_id, + contrat_mois_id, + etablissement_id, + mois_activite, + mois_paie, + date_debut, + date_fin, + date_paie, + round(sum(heures_contrat), 2) as heures_contrat, + round(sum(heures_payees), 2) as heures_payees, + round(sum(heures_travaillees), 2) as heures_travaillees, + round(sum(montant_masse_salariale), 2) as montant_masse_salariale, + round(sum(montant_brut), 2) AS montant_brut, + round(sum(montant_avantage_nature), 2) as montant_avantage_nature, + round(sum(montant_frais_imposables), 2) as montant_frais_imposables, + round(sum(montant_cotisation_salarie), 2) AS montant_cotisation_salarie, + round(sum(montant_cotisation_patronale), 2) AS montant_cotisation_patronale, + round(sum(montant_od_net_salarie), 2) as montant_od_net_salarie, + round(sum(montant_od_net_patronale), 2) as montant_od_net_patronale, + round(sum(montant_net_imposable_salarie), 2) as montant_net_imposable_salarie, + round(sum(montant_net_a_payer_salarie), 2) as montant_net_a_payer_salarie, + round(sum(nombre_provisions), 2) as nombre_provisions, + round(sum(montant_provisions), 2) as montant_provisions, + round(sum(montant_masse_salariale_provisionnee), 2) as montant_masse_salariale_provisionnee + FROM w_hp_1 + where p_detail + GROUP BY 1,2,3,4,5,6,7,8,9,10,11 + ; + + DROP TABLE IF EXISTS w_cible + ; + + CREATE TEMP TABLE w_cible AS + SELECT + cti_cnt_id, + bul_id, + salarie_id, + contrat_id, + contrat_mois_id, + etablissement_id, + mois_activite, + mois_paie, + date_debut, + date_fin, + date_paie, + round(sum(case when p_cumul then heures_contrat else 0 end), 2) as heures_contrat, + round(sum(case when p_cumul then heures_payees else 0 end), 2) as heures_payees, + round(sum(case when p_cumul then heures_travaillees else 0 end), 2) as heures_travaillees, + round(sum(case when p_cumul then montant_masse_salariale else 0 end), 2) as montant_masse_salariale, + round(sum(case when p_cumul then montant_brut else 0 end), 2) AS montant_brut, + round(sum(case when p_cumul then montant_avantage_nature else 0 end), 2) as montant_avantage_nature, + round(sum(case when p_cumul then montant_frais_imposables else 0 end), 2) as montant_frais_imposables, + round(sum(case when p_cumul then montant_cotisation_salarie else 0 end), 2) AS montant_cotisation_salarie, + round(sum(case when p_cumul then montant_cotisation_patronale else 0 end), 2) AS montant_cotisation_patronale, + round(sum(case when p_cumul then montant_od_net_salarie else 0 end), 2) as montant_od_net_salarie, + round(sum(case when p_cumul then montant_od_net_patronale else 0 end), 2) as montant_od_net_patronale, + round(sum(case when p_cumul then montant_net_imposable_salarie else 0 end), 2) as montant_net_imposable_salarie, + round(sum(case when p_cumul then montant_net_a_payer_salarie else 0 end), 2) as montant_net_a_payer_salarie, + round(sum(case when p_cumul then nombre_provisions else 0 end), 2) as nombre_provisions, + round(sum(case when p_cumul then montant_provisions else 0 end), 2) as montant_provisions, + round(sum(case when p_cumul then montant_masse_salariale_provisionnee else 0 end), 2) as montant_masse_salariale_provisionnee + FROM w_hp_1 + where p_cumul + GROUP BY 1,2,3,4,5,6,7,8,9,10,11 + ; + + -- Création d'une table récapitulative des écarts à calculer par indicateur de paie (1 seule ligne). + DROP TABLE IF EXISTS w_cumul + ; + + CREATE TEMP TABLE w_cumul AS + SELECT + bool_or(p_cumul and p_heures_contrat) as total_heures_contrat, + bool_or(p_cumul and p_heures_payees) as total_heures_payees, + bool_or(p_cumul and p_heures_travaillees) as total_heures_travaillees, + bool_or(p_cumul and p_masse_salariale) as total_masse_salariale, + bool_or(p_cumul and p_brut) as total_brut, + bool_or(p_cumul and p_avantage_nature) as total_avantage_nature, + bool_or(p_cumul and p_frais_imposables) as total_frais_imposables, + bool_or(p_cumul and p_cotisation_salarie) as total_cotisation_salarie, + bool_or(p_cumul and p_cotisation_patronale) as total_cotisation_patronale, + bool_or(p_cumul and p_od_net_salarie) as total_od_net_salarie, + bool_or(p_cumul and p_od_net_patronale) as total_od_net_patronale, + bool_or(p_cumul and p_net_imposable) as total_net_imposable, + bool_or(p_cumul and p_net_a_payer) as total_net_a_payer, + bool_or(p_cumul and p_nombre_provisions) as total_nombre_provisions, + bool_or(p_cumul and p_montant_provisions) as total_montant_provisions, + bool_or(p_cumul and p_masse_salariale_provisionnee) as total_masse_salariale_provisionnee + FROM rh.t_rubriques + ; + + -- Inserer pour chaque bulletin une ligne 'Ecart cumulé' qui va faire le compte avec le total + INSERT INTO rh.p_historique_paie( + salarie_id, + code_original, + contrat_id, + contrat_mois_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + compte_id, + organisme_cotisation_id, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + subq.salarie_id, + subq.bul_id, + subq.contrat_id, + subq.contrat_mois_id, + subq.mois_activite, + subq.date_debut, + subq.date_fin, + subq.mois_paie, + subq.date_paie, + (select oid from rh.t_rubriques where code_original = 'C000'), + subq.compte_id, + 0 as organisme_cotisation_id, + 0 as base, + 0 as nombre, + subq.heures_contrat, + subq.heures_payees, + subq.heures_travaillees, + subq.montant_masse_salariale, + subq.montant_brut, + subq.montant_avantage_nature, + subq.montant_frais_imposables, + 0 as taux_cotisation_salarie, + subq.montant_cotisation_salarie, + 0 as taux_cotisation_patronale, + subq.montant_cotisation_patronale, + subq.montant_od_net_salarie, + subq.montant_od_net_patronale, + subq.montant_net_imposable_salarie, + subq.montant_net_a_payer_salarie, + subq.nombre_provisions, + subq.montant_provisions, + subq.montant_masse_salariale_provisionnee + FROM ( + SELECT + coalesce(w_cible.salarie_id, w_tmp.salarie_id) as salarie_id, + coalesce(w_cible.contrat_id, w_tmp.contrat_id) as contrat_id, + coalesce(w_cible.contrat_mois_id, w_tmp.contrat_mois_id) as contrat_mois_id, + 0 as compte_id, + coalesce(w_cible.bul_id, w_tmp.bul_id) as bul_id, + coalesce(w_cible.mois_activite, w_tmp.mois_activite) as mois_activite, + coalesce(w_cible.date_debut, w_tmp.date_debut) as date_debut, + coalesce(w_cible.date_fin, w_tmp.date_fin) as date_fin, + coalesce(w_cible.mois_paie, w_tmp.mois_paie) as mois_paie, + coalesce(w_cible.date_paie, w_tmp.date_paie) as date_paie, + 0 AS heures_contrat, -- Tant que sous Cegi aucune rubrique n'a ?t? identifi?e comme ?tant la totalisation des heures contrat/travaill?es, on ne calcul pas d'?cart cumul?. + sum(case when total_heures_payees then coalesce(w_cible.heures_payees, 0) - coalesce(w_tmp.heures_payees, 0) else 0 end) AS heures_payees, + 0 AS heures_travaillees, -- Tant que sous Cegi aucune rubrique n'a ?t? identifi?e comme ?tant la totalisation des heures contrat/travaill?es, on ne calcul pas d'?cart cumul?. + sum(case when total_masse_salariale then coalesce(w_cible.montant_masse_salariale, 0) - coalesce(w_tmp.montant_masse_salariale, 0) else 0 end) AS montant_masse_salariale, + sum(case when total_brut then coalesce(w_cible.montant_brut, 0) - coalesce(w_tmp.montant_brut, 0) else 0 end) AS montant_brut, + sum(case when total_avantage_nature then coalesce(w_cible.montant_avantage_nature, 0) - coalesce(w_tmp.montant_avantage_nature, 0) else 0 end) AS montant_avantage_nature, + sum(case when total_frais_imposables then coalesce(w_cible.montant_frais_imposables, 0) - coalesce(w_tmp.montant_frais_imposables, 0) else 0 end) AS montant_frais_imposables, + sum(case when total_cotisation_salarie then coalesce(w_cible.montant_cotisation_salarie, 0) - coalesce(w_tmp.montant_cotisation_salarie, 0) else 0 end) AS montant_cotisation_salarie, + sum(case when total_cotisation_patronale then coalesce(w_cible.montant_cotisation_patronale, 0) - coalesce(w_tmp.montant_cotisation_patronale, 0) else 0 end) AS montant_cotisation_patronale, + sum(case when total_od_net_salarie then coalesce(w_cible.montant_od_net_salarie, 0) - coalesce(w_tmp.montant_od_net_salarie, 0) else 0 end) AS montant_od_net_salarie, + sum(case when total_od_net_patronale then coalesce(w_cible.montant_od_net_patronale, 0) - coalesce(w_tmp.montant_od_net_patronale, 0) else 0 end) AS montant_od_net_patronale, + sum(case when total_net_imposable then coalesce(w_cible.montant_net_imposable_salarie, 0) - coalesce(w_tmp.montant_net_imposable_salarie, 0) else 0 end) AS montant_net_imposable_salarie, + sum(case when total_net_a_payer then coalesce(w_cible.montant_net_a_payer_salarie, 0) - coalesce(w_tmp.montant_net_a_payer_salarie, 0) else 0 end) AS montant_net_a_payer_salarie, + sum(case when total_nombre_provisions then coalesce(w_cible.nombre_provisions, 0) - coalesce(w_tmp.nombre_provisions, 0) else 0 end) AS nombre_provisions, + sum(case when total_montant_provisions then coalesce(w_cible.montant_provisions, 0) - coalesce(w_tmp.montant_provisions, 0) else 0 end) AS montant_provisions, + sum(case when total_masse_salariale_provisionnee then coalesce(w_cible.montant_masse_salariale_provisionnee, 0) - coalesce(w_tmp.montant_masse_salariale_provisionnee, 0) else 0 end) AS montant_masse_salariale_provisionnee + FROM (select bul_id from w_tmp + union + select bul_id from w_cible) as all_buls + JOIN w_cumul ON true + left JOIN w_tmp ON w_tmp.bul_id = all_buls.bul_id + left JOIN w_cible ON w_cible.bul_id = all_buls.bul_id + GROUP BY 1,2,3,4,5,6,7,8,9,10) AS subq + WHERE 1!=1 + OR subq.heures_contrat != 0 + OR subq.heures_payees != 0 + OR subq.heures_travaillees != 0 + OR subq.montant_masse_salariale != 0 + OR subq.montant_brut != 0 + OR subq.montant_avantage_nature != 0 + OR subq.montant_frais_imposables != 0 + OR subq.montant_cotisation_salarie != 0 + OR subq.montant_cotisation_patronale != 0 + OR subq.montant_od_net_salarie != 0 + OR subq.montant_od_net_patronale != 0 + OR subq.montant_net_imposable_salarie != 0 + OR subq.montant_net_a_payer_salarie != 0 + OR subq.nombre_provisions != 0 + OR subq.montant_provisions != 0 + OR subq.montant_masse_salariale_provisionnee != 0 + ; + + ]]> + + + + + + = 2016 + GROUP BY w_at.unique_abs_id, w_at.signe, 1,2, 7, 8 + ; + + INSERT INTO rh.p_arrets_travail_mois( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + nb_debut_arret, + nb_fin_arret, + nb_reprise_apres_arret, + date_debut, + date_fin, + nb_jours, + nb_arret) + SELECT + arr.oid AS arret_travail_id, + arr.salarie_id AS salarie_id, + arr.contrat_id AS contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + cal.mois, + CASE WHEN arr.date_debut BETWEEN cal.date_debut AND cal.date_fin THEN 1 ELSE 0 END AS nombre_debut_arret, + CASE WHEN arr.date_fin BETWEEN cal.date_debut AND cal.date_fin THEN 1 ELSE 0 END AS nombre_fin_arret, + CASE WHEN arr.date_reprise BETWEEN cal.date_debut AND cal.date_fin THEN 1 ELSE 0 END AS nombre_reprise_apres_arret, + -- Lorsque la date de reprise est isolée sur un mois (l'arrêt de travail s'est terminé le mois précédent) : + -- la date de début = date de reprise, + CASE WHEN arr.date_reprise BETWEEN cal.date_debut AND cal.date_fin AND arr.date_fin= p_contrats_mois.date_debut AND p_arrets_travail_mois.date_debut <= p_contrats_mois.date_fin THEN 1 ELSE 0 END,contrat_mois_id]))[2] AS keep_contrat_mois_id + FROM rh.p_arrets_travail_mois + JOIN rh.p_contrats_mois ON contrat_mois_id = p_contrats_mois.oid + GROUP BY 1,2 + HAVING count(*) > 1 + ) subview + WHERE p_arrets_travail_mois.arret_travail_id = subview.arret_travail_id AND + p_arrets_travail_mois.mois_activite = subview.mois_activite AND + p_arrets_travail_mois.contrat_mois_id <> keep_contrat_mois_id + ; + + ]]> + + + 0 OR + p_heures_payees AND ABS(c_heures_payees) BETWEEN 5 AND 8 AND heure_payee <> 0 + ) AND + proratiser_conversion AND + equivalent_temps_plein <> 1 AND + equivalent_temps_plein > 0 + ; + + ]]> + + + 0 + FROM rh.t_divers + WHERE code = 'CEGI_VENTILATION' + ; + + ]]> + 0 + JOIN pyrepcnt_x ON pyrepcnt_x.rep_id = pyrepartition.rep_id + join prod_cegi.pyreppla_compta on pyreppla_compta.repcompta_id = pyrepcnt_x.repcompta_id + join prod_cegi.pybulletin on 1=1 + and pybulletin.cnt_id = pyperioderep.cnt_id + and pybulletin.per_id = pyperioderep.per_id + and pybulletin.cal_an = pyreppla_compta.cal_an + and pybulletin.cal_nperiode = pyreppla_compta.cal_nperiode + join rh.t_section_analytique on t_section_analytique.oid = pyreppla_compta.ana_id + where pycontrat.cnt_repplanning = 1 -- Case "Autoriser les imapcts de répartition de l'application Planning" cochée. + group by 1,2,3 + UNION + select + pybulletin.bul_id, + t_section_analytique.code as section_analytique_code, + t_section_analytique.oid as section_analytique_id, + sum(pyrepcnt_x.repx_taux / 100.0 * pyrepartition.rep_taux / 100.0) as ratio + from pyperioderep + join prod_cegi.pycontrat on 1=1 + and pycontrat.cnt_id = pyperioderep.cnt_id + and pycontrat.per_id = pyperioderep.per_id + JOIN prod_cegi.pyrepartition ON 1=1 + and pyrepartition.prep_id = pyperioderep.prep_id + and pyrepartition.rep_taux > 0 + JOIN pyrepcnt_x ON pyrepcnt_x.rep_id = pyrepartition.rep_id + join prod_cegi.pybulletin on 1=1 + and pybulletin.cnt_id = pyperioderep.cnt_id + and pybulletin.per_id = pyperioderep.per_id + and base.cti_overlaps(pybulletin.bul_debutrem::date, pybulletin.bul_finrem::date, pyperioderep.date_debut, pyperioderep.date_fin) + join rh.t_section_analytique on t_section_analytique.oid = pyrepcnt_x.ana_id + where pycontrat.cnt_repplanning = 0 -- Case "Autoriser les imapcts de répartition de l'application Planning" NON cochée. + group by 1,2,3 + ; + + DROP TABLE IF EXISTS w_ven_agg + ; + + CREATE TEMP TABLE w_ven_agg AS + select + bul_id, + dense_rank() over (order by array_agg(section_analytique_id order by section_analytique_id), array_agg(ratio order by section_analytique_id)) as ventilation_id, + array_to_string(array_agg(section_analytique_code||'@'||(round(ratio*100)) order by section_analytique_code), ', ') as ventilation_texte + FROM w_ven + group by 1 + ; + + -- Récupération des différents schémas/modèles de ventilation. + TRUNCATE rh.p_ventilation + ; + + INSERT INTO rh.p_ventilation(oid, code, texte, plan_analytique_id) + select + ventilation_id, + ventilation_id::text, + ventilation_texte, + (SELECT valeur::bigint FROM rh.t_divers WHERE code = 'CEGI_VENTILATION') + FROM w_ven_agg + group by 1,2,3,4 + UNION ALL + SELECT + 0, + 'N/R', + 'Non renseignée', + (SELECT valeur::bigint FROM rh.t_divers WHERE code = 'CEGI_VENTILATION') + ; + + TRUNCATE rh.p_ventilation_section + ; + INSERT INTO rh.p_ventilation_section( + ventilation_id, + section_analytique_id, + section_analytique_code, + section_analytique_texte, + ratio) + SELECT + ventilation_id, + t_section_analytique.oid, + t_section_analytique.code, + t_section_analytique.texte, + ratio + from w_ven + join w_ven_agg on w_ven_agg.bul_id = w_ven.bul_id + JOIN rh.t_section_analytique on t_section_analytique.oid = w_ven.section_analytique_id + group by 1,2,3,4,5 + UNION ALL + SELECT + 0, + oid, + code, + texte, + 1 + FROM rh.t_section_analytique + WHERE oid = 0 + ; + + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id + FROM ( + select + p_historique_paie.oid, + coalesce(ventilation_id, 0) as ventilation_id + from rh.p_historique_paie + left join w_ven_agg on w_ven_agg.bul_id = p_historique_paie.code_original + group by 1,2) as subq + WHERE p_historique_paie.oid = subq.oid + ; + + -- Dans certains cas, le ratio n'est pas égal à 1, on ajuste + UPDATE rh.p_ventilation_section + SET ratio = ratio*ratio_coef + FROM + ( + SELECT ventilation_id, 1/sum(ratio) AS ratio_coef + FROM rh.p_ventilation_section + GROUP BY 1 + HAVING round(sum(ratio),0) <> 1 AND SUM(ratio) > 0 + ) subview + WHERE p_ventilation_section.ventilation_id = subview.ventilation_id + ; + + ]]> + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_CEGIALPHA.XML b/import_rh/iCTI_import_rh_CEGIALPHA.XML new file mode 100644 index 0000000..f47a06d --- /dev/null +++ b/import_rh/iCTI_import_rh_CEGIALPHA.XML @@ -0,0 +1,1589 @@ + + + + + + + + + + + + + + = 201401 + ; + + TRUNCATE rh.p_chiffrier_production + ; + + INSERT INTO rh.p_chiffrier_production (entreprise_id, etablissement_id, mois, nombre_salaries, montant_brut, nombre_heures) + SELECT + entreprise_id, + etablissement_id, + annee_mois, + count(distinct cpte_personne), + sum(montant_brut), + sum(heures_payees) + from w_bul + GROUP BY 1,2,3 + ; + + ]]> + + + on met le mois de paie en cours (et surtout pas current_date). + from w_cnt, w_periode + group by 1 + UNION ALL + select + cpte_personne, + min(date_debut_paie) as date_debut, + max(date_fin_paie) as date_fin + from w_bul + group by 1 + ) as subq + join prod_cegialpha.fnp_tab_per_personnes on fnp_tab_per_personnes.cpt_personne = subq.cpte_personne + group by 1,2 + ; + + DROP TABLE IF EXISTS w_evt_mois + ; + + CREATE TEMP TABLE w_evt_mois AS + select + w_lim_sal.cpte_personne, + w_lim_sal.matricule, + cpt_contrat, -- contrat + cpt_bulletin, -- bulletins + p_calendrier.mois, + min(p_calendrier.date) as date_debut, + max(p_calendrier.date) as date_fin + from base.p_calendrier + join w_lim_sal on p_calendrier.date between w_lim_sal.date_debut and w_lim_sal.date_fin + left join w_cnt on 1=1 + and w_cnt.cpte_personne = w_lim_sal.cpte_personne + and p_calendrier.date between w_cnt.date_debut and w_cnt.date_fin + left join w_bul on 1=1 + and w_bul.cpte_personne = w_lim_sal.cpte_personne + and p_calendrier.date between w_bul.date_debut_paie and w_bul.date_fin_paie + group by 1,2,3,4,5 --,6,7,8,9 --,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38 + having 1!=1 + or cpt_contrat is not null -- on ne conserve que les évenements ou il y a un contrat OU + or cpt_bulletin is not null -- un bulletin + ; + + DROP TABLE IF EXISTS w_profils + ; + + CREATE TEMP TABLE w_profils AS + select + row_number() over () as row_id, + 0 as profil_id, + 0 as contrat_id, + 0 as contrat_mois_id, + 0 as salarie_id, + w_evt_mois.cpte_personne, + w_evt_mois.matricule, + w_evt_mois.mois, + w_evt_mois.date_debut, + w_evt_mois.date_fin, + coalesce(w_cnt.entreprise_id, w_bul.entreprise_id, 0) as entreprise_id, + coalesce(w_cnt.etablissement_id, w_bul.etablissement_id, 0) as etablissement_id, + -- **** contrat **** + w_cnt.cpt_contrat, + w_cnt.identifiant_contrat, + w_cnt.etp_cnt, + coalesce(w_cnt.cpt_contrat, -- si la valeur est renseignée sur la ligne courante, on la prend. + (max(case when w_cnt.cpt_contrat is null then null else ARRAY[extract(epoch from w_evt_mois.date_debut)::text, w_cnt.cpt_contrat] end) over wb)[2], -- sinon on prend la valeur renseignée la plus proche dans le passé + (min(case when w_cnt.cpt_contrat is null then null else ARRAY[extract(epoch from w_evt_mois.date_debut)::text, w_cnt.cpt_contrat] end) over wf)[2], -- sinon on prend la valeur renseignée la plus proche dans le futur + null -- sinon on prend null. Ne devrait pas arriver. + ) as cti_cnt_all, -- cpt_contrat mais renseigné avec les valeurs précédentes ou suivantes lorsque hors période de contrat. Utile pour p_contrats_mois. + w_cnt.date_debut as cnt_date_debut, + w_cnt.date_fin as cnt_date_fin, + -- **** bulletins **** + w_bul.cpt_bulletin, + --w_bul.date_debut as bul_date_debut, + --w_bul.date_fin as bul_date_fin, + case when w_cnt.cpt_contrat is null then 1 else 0 end as est_hors_periode, + -- **** code original **** + coalesce(code_csp, chr(1)||'*') AS categorie_socio_professionnelle_code_original, + coalesce(cpte_emploi, chr(1)||'*') AS code_emploi_code_original, + chr(1)||'*' AS grille_code_original, + chr(1)||'*' AS grille_groupe_code_original, + coalesce(cpte_groupe, chr(1)||'*') AS groupe_cotisant_code_original, + coalesce(code_dad_motif_debut, chr(1)||'*') as motif_debut_code_original, + coalesce(code_dad_motif_fin, chr(1)||'*') as motif_fin_code_original, + coalesce(cpte_qualification, chr(1)||'*') AS qualification_code_original, + chr(1)||'*' AS section_analytique_code_original, + chr(1)||'*' AS section_analytique_paie_code_original, + chr(1)||'*' AS service_code_original, -- @todo + chr(1)||'*' AS societe_interim_code_original, + chr(1)||'*' AS specialite_code_original, -- @todo + coalesce(code_dad_statut_prof, chr(1)||'*') AS statut_code_original, + coalesce(code_type_contrat, chr(1)||'*') as type_contrat_code_original, + coalesce(bl_travail_nuit, chr(1)||'*') AS type_horaire_code_original, + coalesce(case when etp_cnt = 1 then 'TC' else 'TP'||lpad(round(etp_cnt * 100, 2), 2, '0') end, chr(1)||'*') AS type_temps_travail_code_original, -- @todo + -- Public + chr(1)||'*' AS cadre_emploi_code_original, + chr(1)||'*' AS categorie_conge_code_original, + chr(1)||'*' AS categorie_statutaire_code_original, + chr(1)||'*' AS commission_paritaire_code_original, + chr(1)||'*' AS compte_salarie_code_original, + chr(1)||'*' AS filiere_code_original, + chr(1)||'*' AS lettre_budgetaire_code_original, + chr(1)||'*' AS unite_fonctionnelle_code_original + from w_evt_mois + left join w_cnt on w_cnt.cpt_contrat = w_evt_mois.cpt_contrat + left join w_bul on w_bul.cpt_bulletin = w_evt_mois.cpt_bulletin + window wb as (PARTITION BY w_evt_mois.cpte_personne ORDER BY w_evt_mois.date_debut rows unbounded preceding), -- sélectionne les lignes précédentes + wf as (PARTITION BY w_evt_mois.cpte_personne ORDER BY w_evt_mois.date_debut rows between current row and unbounded following) -- sélectionne les lignes suivantes + ; + + ]]> + + + + + + + + + + + Si les dates d'entrée/sortie d'établissement semblent incohérentes par rapports aux dates des contrats, les corriger. + -- UPDATE rh.p_salaries + -- SET date_entree_ets = date_debut_contrat + -- FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) subview + -- WHERE 1=1 + -- AND p_salaries.oid = subview.salarie_id + -- -- AND date_debut_contrat < date_entree_ets -- On corrige désormais TOUTES les dates d'entrées ets. car cela pose des soucis de calcul + -- -- des TOPs entrée/sortie ets. dans p_contrats_mois. + -- ; + + -- UPDATE rh.p_salaries + -- SET date_sortie_ets = date_fin_contrat + -- FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) subview + -- WHERE 1=1 + -- AND p_salaries.oid = subview.salarie_id + -- AND date_fin_contrat > date_sortie_ets + -- ; + + -- Màj de l'ancienneté. + UPDATE rh.p_contrats SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_calculee_mois + FROM ( + select + numero_contrat, + coalesce(sum(date_fin - date_debut + 1) over w, 0) AS anciennete_anterieure_jours, + coalesce(sum(date_fin - date_debut + 1) over w / 30::numeric, 0) AS anciennete_anterieure_calculee_mois + from rh.p_contrats + window w as (partition by salarie_id order by date_debut rows between UNBOUNDED PRECEDING and 1 preceding)) AS subq + WHERE 1=1 + AND p_contrats.numero_contrat = subq.numero_contrat + ; + + SELECT base.cti_stash_table_indexes('rh.p_contrats_mois') + ; + + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + DROP TABLE IF EXISTS w_contrats_mois + ; + + CREATE TEMP TABLE w_contrats_mois AS + SELECT + nextval('rh.s_contrats_mois'::regclass) as contrat_mois_id, + p_salaries.oid AS salarie_id, + p_contrats.oid AS contrat_id, + w_profils.mois AS mois_activite, + w_profils.date_debut, + w_profils.date_fin, + CASE WHEN p_salaries.date_entree_ets BETWEEN w_profils.date_debut AND w_profils.date_fin THEN 1 ELSE 0 END AS nombre_entrees, + CASE WHEN p_salaries.date_sortie_ets BETWEEN w_profils.date_debut AND w_profils.date_fin THEN 1 ELSE 0 END AS nombre_departs, + CASE WHEN w_profils.cnt_date_debut BETWEEN w_profils.date_debut AND w_profils.date_fin THEN 1 ELSE 0 END AS nombre_debut_contrat, + CASE WHEN w_profils.cnt_date_fin BETWEEN w_profils.date_debut AND w_profils.date_fin THEN 1 ELSE 0 END AS nombre_fin_contrat, + w_profils.est_hors_periode, + CASE WHEN w_profils.date_debut BETWEEN w_profils.cnt_date_debut AND w_profils.cnt_date_fin THEN 1 ELSE 0 END AS present_debut_mois, + CASE WHEN w_profils.date_fin BETWEEN w_profils.cnt_date_debut AND w_profils.cnt_date_fin THEN 1 ELSE 0 END AS present_fin_mois, + case when cpt_contrat IS NOT NULL then w_profils.etp_cnt -- Il n'y a pas d'ETP contrat ni d'anciennetés pour les contrats_mois hors période. + * ( + (least(w_profils.date_fin, w_profils.cnt_date_fin) - greatest(w_profils.date_debut, w_profils.cnt_date_debut) + 1)::numeric + / + (base.cti_last_day(to_date(w_profils.mois, 'YYYYMM')) - to_date(w_profils.mois, 'YYYYMM') + 1)::numeric + ) else 0 end AS equivalent_temps_plein, + base.cti_age(least(w_profils.date_fin, w_profils.cnt_date_fin), coalesce(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + least(w_profils.date_fin, w_profils.cnt_date_fin)::date - coalesce(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + case when cpt_contrat IS NOT NULL then p_contrats.anciennete_anterieure_jours + + (w_profils.date_fin - w_profils.cnt_date_debut) + + 1 + else 0 end AS anciennete_jours, + case when cpt_contrat IS NOT NULL then base.cti_age(date_trunc('month', w_profils.date_fin::date)::date, date_trunc('month', w_profils.cnt_date_debut)::date, 'nm') + + greatest(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + 1 else 0 end AS anciennete_mois, + case when cpt_contrat IS NOT NULL then floor((base.cti_age(date_trunc('month', w_profils.date_fin::date)::date, date_trunc('month', w_profils.cnt_date_debut)::date, 'nm') + + greatest(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + 1) / 12) else 0 end AS anciennete_annee_id, + coalesce(w_profils.etablissement_id, p_contrats.etablissement_id, 0) as etablissement_id, + array_agg(w_profils.row_id) as array_row_id -- array des profils. + FROM w_profils + JOIN rh.p_salaries ON w_profils.salarie_id = p_salaries.oid + LEFT JOIN rh.p_contrats ON p_contrats.code_original = w_profils.cti_cnt_all + WHERE false -- Il faut au moins un contrat ou un bulletin. + OR cpt_contrat IS NOT NULL + OR cpt_bulletin IS NOT NULL + GROUP BY 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 + ; + + -- On renseigne les id de contrats de w_profils. + UPDATE w_profils SET + contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + unnest(array_row_id) as row_id, + contrat_mois_id, + contrat_id + from w_contrats_mois) as subq + WHERE w_profils.row_id = subq.row_id + ; + + INSERT INTO rh.p_contrats_mois( + oid, + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, -- bulletins de paie hors période de contrat. + present_debut_mois, + present_fin_mois, + equivalent_temps_plein, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id, + etablissement_id) + SELECT + contrat_mois_id, + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, + present_debut_mois, + present_fin_mois, + equivalent_temps_plein, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id, + etablissement_id + FROM w_contrats_mois + ; + + SELECT base.cti_stash_pop_table_indexes('rh.p_contrats_mois') + ; + + /* Présents fin de mois */ + DROP TABLE IF EXISTS w_presents_fin_mois + ; + CREATE TEMP TABLE w_presents_fin_mois AS + SELECT + p_contrats.salarie_id, + date(p_contrats_mois.date_debut - interval '1 day') AS date_presence + FROM rh.p_contrats_mois + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid + WHERE 1=1 + AND fictif <> '1' + AND est_hors_periode <> '1' + AND date_part('day',p_contrats_mois.date_debut) = 01 + GROUP BY 1,2 + ; + + UPDATE rh.p_contrats_mois + SET present_fin_mois = '1' + FROM w_presents_fin_mois + WHERE p_contrats_mois.salarie_id = w_presents_fin_mois.salarie_id AND + p_contrats_mois.date_fin = w_presents_fin_mois.date_presence AND + present_fin_mois <> '1' AND + fictif <> '1' AND + est_hors_periode <> '1' + ; + + UPDATE rh.p_contrats_mois + SET present_fin_mois = '0' + WHERE present_fin_mois = '1' AND + ( + date_part('day',date_fin+interval '1 day') <> 1 OR + fictif = '1' OR + est_hors_periode = '1' + ) + ; + + UPDATE rh.p_contrats_mois + SET present_fin_mois = '0' + FROM + ( + SELECT oid + FROM rh.p_contrats_mois + LEFT JOIN w_presents_fin_mois ON + p_contrats_mois.salarie_id = w_presents_fin_mois.salarie_id AND + p_contrats_mois.date_fin = w_presents_fin_mois.date_presence + WHERE present_fin_mois = '1' AND + w_presents_fin_mois IS NULL + ) subview + WHERE p_contrats_mois.oid = subview.oid + ; + + ]]> + + + = 201401 + ; + + CREATE TEMP TABLE w_hp AS + SELECT + cpt_bulletin, + cpte_contrat, + cpte_personne, + code_dossier_gestion, + cpte_rubrique, + cpte_organisme, + date_paie, + mois_paie, + date_debut, + date_fin, + mois, + t_rubriques.oid as rubrique_id, + sum(CASE WHEN p_base THEN (CASE s_base + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_base) AS base, + sum(CASE WHEN p_nombre THEN (CASE s_nombre + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_nombre) AS nombre, + sum(CASE WHEN p_heures_payees THEN (CASE s_heures_payees + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_heures_payees) AS heures_payees, + sum(CASE WHEN p_heures_travaillees THEN (CASE s_heures_travaillees + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_heures_travaillees) AS heures_travaillees, + sum(CASE WHEN p_masse_salariale THEN (CASE s_masse_salariale + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN (montant + montant_pat) + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_masse_salariale) AS montant_masse_salariale, + sum(CASE WHEN p_brut THEN (CASE s_brut + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_brut) AS montant_brut, + sum(CASE WHEN p_avantage_nature THEN (CASE s_avantage_nature + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_avantage_nature) AS montant_avantage_nature, + sum(CASE WHEN p_frais_imposables THEN (CASE s_frais_imposables + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_frais_imposables) AS montant_frais_imposables, + sum(taux * coefficient_txs) AS taux_cotisation_salarie, + sum(CASE WHEN p_cotisation_salarie THEN (CASE s_cotisation_salarie + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_cotisation_salarie) AS montant_cotisation_salarie, + sum(taux_pat * coefficient_txp) AS taux_cotisation_patronale, + sum(CASE WHEN p_cotisation_patronale THEN (CASE s_cotisation_patronale + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_cotisation_patronale) AS montant_cotisation_patronale, + sum(CASE WHEN p_od_net_salarie THEN (CASE s_od_net_salarie + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_od_net_salarie) AS montant_od_net_salarie, + sum(CASE WHEN p_od_net_patronale THEN (CASE s_od_net_patronale + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_od_net_patronale) AS montant_od_net_patronale, + sum(CASE WHEN p_net_imposable THEN (CASE s_net_imposable + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_net_imposable) AS montant_net_imposable_salarie, + sum(CASE WHEN p_net_a_payer THEN (CASE s_net_a_payer + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 2 THEN taux + WHEN 3 THEN montant + WHEN 4 THEN taux_pat + WHEN 5 THEN montant_pat + WHEN 6 THEN montant + montant_pat + WHEN 7 THEN montant - montant_pat + WHEN 8 THEN -montant + montant_pat + END) ELSE 0 END * c_net_a_payer) AS montant_net_a_payer_salarie + FROM w_hp0 + JOIN rh.t_rubriques on t_rubriques.code_original = w_hp0.cpte_rubrique + WHERE p_detail + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12 + ; + + DROP TABLE IF EXISTS w_hp_1 + ; + + CREATE TEMP TABLE w_hp_1 AS + SELECT + cpt_bulletin, + cpte_contrat, + cpte_personne, + code_dossier_gestion, + cpte_rubrique, + cpte_organisme, + w_hp.date_paie, + w_hp.mois_paie, + w_hp.date_debut, + w_hp.date_fin, + w_hp.mois, + p_salaries.oid as salarie_id, + p_contrats.oid as contrat_id, + CASE WHEN max(p_contrats_mois.oid) IS NOT NULL + THEN (max(ARRAY[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] + ELSE ( + SELECT (max(ARRAY[p_contrats_mois.mois_activite, p_contrats_mois.oid]))[2] + FROM rh.p_contrats_mois + WHERE + p_contrats_mois.contrat_id = p_contrats.oid + AND p_contrats_mois.mois_activite < w_hp.mois) + END as contrat_mois_id, + w_hp.rubrique_id, + 0 as organisme_cotisation_id, -- @todo + w_hp.base, + w_hp.nombre, + round(w_hp.heures_payees, 2) AS heures_payees, -- arrondis nécessaires pour retomber juste avec les cumuls. + round(w_hp.heures_travaillees, 2) as heures_travaillees, + w_hp.montant_masse_salariale, + w_hp.montant_brut, + w_hp.montant_avantage_nature, + w_hp.montant_frais_imposables, + w_hp.taux_cotisation_salarie, + w_hp.montant_cotisation_salarie, + w_hp.taux_cotisation_patronale, + w_hp.montant_cotisation_patronale, + w_hp.montant_od_net_salarie, + w_hp.montant_od_net_patronale, + w_hp.montant_net_imposable_salarie, + w_hp.montant_net_a_payer_salarie + FROM w_hp + JOIN rh.p_contrats on p_contrats.code_original = w_hp.cpte_contrat + LEFT JOIN rh.p_contrats_mois on 1=1 + AND p_contrats_mois.contrat_id = p_contrats.oid + AND p_contrats_mois.mois_activite = mois + JOIN rh.p_salaries on p_salaries.code_original = w_hp.cpte_personne + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13, 15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32 + ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + organisme_cotisation_id, + base, + nombre, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + mois, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + organisme_cotisation_id, + base, + nombre, + heures_payees, + heures_travaillees, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie + FROM w_hp_1 + ; + + -- Calcul de la rubrique C000. + -- Pas la peine de paramétrer une rubrique de cumul dans l'application car + -- il existe une table des bulletins qui reprend les montants cumuls. + -- Peut-être faudra-t-il un jour généré comme pour Sage de fausse rubrique + -- reprenant les montants et devoir les paramétrer. + + -- Inserer pour chaque bulletin une ligne 'Ecart cumulé' qui va faire le compte avec le total + WITH somme_detail as ( + SELECT + w_hp_1.salarie_id, + w_hp_1.contrat_id, + w_hp_1.contrat_mois_id, + w_hp_1.cpt_bulletin, + w_hp_1.mois_paie, + w_hp_1.date_paie, + w_hp_1.mois, + w_hp_1.date_debut, + w_hp_1.date_fin, + sum(w_hp_1.heures_payees) AS heures_payees, + 0 AS heures_travaillees, + sum(w_hp_1.montant_masse_salariale) AS montant_masse_salariale, + sum(w_hp_1.montant_brut) AS montant_brut, + 0 AS montant_avantage_nature, + 0 AS montant_frais_imposables, + sum(w_hp_1.montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(w_hp_1.montant_cotisation_patronale) AS montant_cotisation_patronale, + -- La somme des OD sal et pat est compensée uniquement dans les OD Sal car la rubrique de cumul Cegi Alpha ne fait pas le distingo. + sum(w_hp_1.montant_od_net_salarie + w_hp_1.montant_od_net_patronale) AS montant_od_net_salarie, + 0 AS montant_od_net_patronale, + sum(w_hp_1.montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(w_hp_1.montant_net_a_payer_salarie) AS montant_net_a_payer_salarie + FROM w_hp_1 + GROUP BY 1,2,3,4,5,6,7,8,9), + diff as ( + SELECT + somme_detail.salarie_id, + somme_detail.contrat_id, + somme_detail.contrat_mois_id, + somme_detail.cpt_bulletin, + somme_detail.mois_paie, + somme_detail.date_paie, + somme_detail.mois, + somme_detail.date_debut, + somme_detail.date_fin, + sum(w_bul.heures_payees - somme_detail.heures_payees) AS heures_payees, + --sum(w_bul.heures_travaillees - somme_detail.heures_travaillees) AS heures_travaillees, + 0 AS heures_travaillees, + sum(w_bul.montant_masse_salariale - somme_detail.montant_masse_salariale) AS montant_masse_salariale, + sum(w_bul.montant_brut - somme_detail.montant_brut) AS montant_brut, + -- sum(w_bul.montant_avantage_nature - somme_detail.montant_avantage_nature) AS montant_avantage_nature, + 0 AS montant_avantage_nature, + --sum(w_bul.montant_frais_imposables - somme_detail.montant_frais_imposables) AS montant_frais_imposables, + 0 AS montant_frais_imposables, + sum(w_bul.montant_cotisation_salarie - somme_detail.montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(w_bul.montant_cotisation_patronale - somme_detail.montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(w_bul.montant_od_net_salarie - somme_detail.montant_od_net_salarie) AS montant_od_net_salarie, + -- sum(w_bul.montant_od_net_patronale - somme_detail.montant_od_net_patronale) AS montant_od_net_patronale, + 0 AS montant_od_net_patronale, + sum(w_bul.montant_net_imposable_salarie - somme_detail.montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(w_bul.montant_net_a_payer_salarie - somme_detail.montant_net_a_payer_salarie) AS montant_net_a_payer_salarie + FROM somme_detail + JOIN w_bul ON w_bul.cpt_bulletin = somme_detail.cpt_bulletin + GROUP BY 1,2,3,4,5,6,7,8,9) + INSERT INTO rh.p_historique_paie( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + organisme_cotisation_id, + base, + nombre, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie) + SELECT + diff.salarie_id, + diff.contrat_id, + diff.contrat_mois_id, + diff.mois, + diff.date_debut, + diff.date_fin, + diff.mois_paie, + diff.date_paie, + (select oid from rh.t_rubriques where code_original = 'C000'), + 0 as organisme_cotisation_id, + 0 as base, + 0 as nombre, + diff.heures_payees, + diff.heures_travaillees, + diff.montant_masse_salariale, + diff.montant_brut, + diff.montant_avantage_nature, + diff.montant_frais_imposables, + 0 as taux_cotisation_salarie, + diff.montant_cotisation_salarie, + 0 as taux_cotisation_patronale, + diff.montant_cotisation_patronale, + diff.montant_od_net_salarie, + diff.montant_od_net_patronale, + diff.montant_net_imposable_salarie, + diff.montant_net_a_payer_salarie + FROM diff + WHERE 1!=1 + OR diff.heures_payees != 0 + OR diff.heures_travaillees != 0 + OR diff.montant_brut != 0 + OR diff.montant_avantage_nature != 0 + OR diff.montant_frais_imposables != 0 + OR diff.montant_cotisation_salarie != 0 + OR diff.montant_cotisation_patronale != 0 + OR diff.montant_od_net_salarie != 0 + OR diff.montant_od_net_patronale != 0 + OR diff.montant_net_imposable_salarie != 0 + OR diff.montant_net_a_payer_salarie != 0 + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 + ; + + ]]> + + + + + + = 2008 + -- GROUP BY w_at.abs_id,1,7,8 + -- ; + + -- INSERT INTO rh.p_arrets_travail_mois( + -- arret_travail_id, + -- salarie_id, + -- contrat_id, + -- contrat_mois_id, + -- mois_activite, + -- nb_debut_arret, + -- nb_fin_arret, + -- nb_reprise_apres_arret, + -- date_debut, + -- date_fin, + -- nb_jours, + -- nb_arret + -- ) + -- SELECT + -- arr.oid AS arret_travail_id, + -- arr.salarie_id AS salarie_id, + -- arr.contrat_id AS contrat_id, + -- p_contrats_mois.oid AS contrat_mois_id, + -- cal.mois, + -- CASE WHEN arr.date_debut BETWEEN cal.date_debut AND cal.date_fin THEN 1 ELSE 0 END AS nombre_debut_arret, + -- CASE WHEN arr.date_fin BETWEEN cal.date_debut AND cal.date_fin THEN 1 ELSE 0 END AS nombre_fin_arret, + -- CASE WHEN arr.date_reprise BETWEEN cal.date_debut AND cal.date_fin THEN 1 ELSE 0 END AS nombre_reprise_apres_arret, + -- -- Lorsque la date de reprise est isolée sur un mois (l'arrêt de travail s'est terminé le mois précédent) : + -- -- la date de début = date de reprise, + -- CASE WHEN arr.date_reprise BETWEEN cal.date_debut AND cal.date_fin AND arr.date_fin + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_CEGID.XML b/import_rh/iCTI_import_rh_CEGID.XML new file mode 100644 index 0000000..1b60536 --- /dev/null +++ b/import_rh/iCTI_import_rh_CEGID.XML @@ -0,0 +1,3121 @@ + + + + + + + + + + + + = lag(pci_debutcontrat) over w_desc then lag(pci_debutcontrat) over w_desc - '1 day'::interval else pci_fincontrat end) + END)::date + AS date_fin, + * + FROM prod_cegid.contrattravail + window w_desc as (partition by pci_salarie order by pci_debutcontrat desc) + ) + SELECT + ((CASE WHEN date_fin = '2099-12-31'::date then now() else date_fin END)::date - date_debut + 1) AS duree, + to_char(date_debut, 'YYYYMM') AS mois, + pci_salarie::text||lpad(pci_ordre,4,'0') AS numero_contrat, + * + FROM cnt1 + ; + + -- #correction + -- Type de contrat CCD => CDD. + UPDATE w_contrattravail + SET pci_typecontrat = 'CDD' + WHERE pci_typecontrat = 'CCD' + ; + + -- Ventilation mensuelle des contrats + DROP TABLE IF EXISTS w_contrattravail_mois + ; + + CREATE TEMP TABLE w_contrattravail_mois AS + SELECT + GREATEST(p_calendrier_mois.date_debut, w_contrattravail.date_debut) AS date_debut_mv, -- date debut mois ventilé + LEAST(p_calendrier_mois.date_fin, w_contrattravail.date_fin) AS date_fin_mv, -- date fin mois ventilé + p_calendrier_mois.mois AS mois_mv, -- mois ventilation + w_contrattravail.* + FROM w_contrattravail + JOIN base.p_calendrier_mois ON base.cti_overlaps(w_contrattravail.date_debut, w_contrattravail.date_fin, p_calendrier_mois.date_debut, p_calendrier_mois.date_fin) + ; + + -- TRAITEMENT de la table prod_cegid.paieencours + DROP TABLE IF EXISTS w_paieencours + ; + + CREATE TEMP TABLE w_paieencours AS + SELECT + ppu_datedebut::date AS date_debut, + ppu_datefin::date AS date_fin, + to_char(ppu_datedebut::date, 'YYYYMM') AS mois, + * + FROM prod_cegid.paieencours + ; + + -- Type temps de travail à blanc + UPDATE w_histosalarie + SET phs_condemploi = 'C' + WHERE 1=1 + AND phs_condemploi = '' + AND phs_ttauxpartiel = 0 + ; + + -- Taux temps partiel anormal + UPDATE w_histosalarie + SET phs_ttauxpartiel = round(phs_ttauxpartiel / 100,0) + WHERE phs_ttauxpartiel > 1000 + ; + + -- #specifique Parc à caen 243 récup. nb heures pour les forfaits jours notamment. + UPDATE w_histosalarie + SET nb_heures = case when phs_condemploi = 'C' then 151.6700 else round(phs_ttauxpartiel / 100.0 * 151.67, 4) end + WHERE @phs_horairemois = 0 + ; + + ]]> + + + + + + + + cf. n½eud XML suivant. + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + SELECT phs_dadscat, phs_dadscat, phs_dadscat, phs_dadscat + FROM w_histosalarie + WHERE 1=1 + -- Si la table 'commun' n'est pas remontée. + AND (select count(*) = 0 + from information_schema.tables + where 1=1 + and table_schema = 'prod_cegid' + and table_name = 'commun') + AND phs_dadscat IS NOT NULL + AND trim(phs_dadscat) != '' + AND phs_dadscat NOT IN (SELECT code_original FROM rh.t_statuts) + AND (select valeur = 'DADSCAT' FROM rh.t_divers WHERE code = 'CEGID_STATUT') + GROUP BY 1,2,3,4 + UNION + SELECT ltrim(pmi_code, '0'), ltrim(pmi_code, '0'), pmi_libelle, substr(pmi_libelle, 1, 50) + FROM prod_cegid.minimumconvent + WHERE 1=1 + AND pmi_nature = 'IND' + AND ltrim(pmi_code, '0') != '' + AND ltrim(pmi_code, '0') NOT IN (SELECT code_original FROM rh.t_statuts) + AND (select valeur = 'INDICE' FROM rh.t_divers WHERE code = 'CEGID_STATUT') + GROUP BY 1,2,3,4 + UNION + SELECT cc_code, cc_code, cc_libelle, substr(cc_abrege,1,50) + FROM prod_cegid.choixcod + WHERE 1=1 + AND cc_type = case (select valeur from rh.t_divers where code = 'CEGID_STATUT') + when 1 then 'PAG' + when 2 then 'PST' + when 3 then 'PUN' + when 4 then 'PIW' + end -- pas de code pour 5, pas encore... + AND cc_code NOT IN (SELECT code_original FROM rh.t_statuts) + AND (select valeur in (1, 2, 3, 4) from rh.t_divers where code = 'CEGID_STATUT') + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + SELECT + phs_condemploi||phs_ttauxpartiel::float, + phs_condemploi||phs_ttauxpartiel::float, + phs_condemploi||' '||phs_ttauxpartiel::float||' %', + substr( phs_condemploi||' '||phs_ttauxpartiel::float||' %', 1, 50) + FROM w_histosalarie + WHERE 1=1 + AND phs_condemploi IS NOT NULL + AND trim(phs_condemploi) != '' + AND phs_condemploi||phs_ttauxpartiel::float NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + GROUP BY 1,2,3,4 + ; + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + with niv1 as ( + SELECT cc_code as code, cc_libelle as texte + FROM prod_cegid.choixcod + WHERE cc_type = 'PAG' + GROUP BY 1,2), + niv2 as ( + SELECT cc_code as code, cc_libelle as texte + FROM prod_cegid.choixcod + WHERE cc_type = 'PST' + GROUP BY 1,2), + niv3 as ( + SELECT cc_code as code, cc_libelle as texte + FROM prod_cegid.choixcod + WHERE cc_type = 'PUN' + GROUP BY 1,2) + select + niv1.code||'|'||niv2.code||'|'||niv3.code as code_original, + niv1.code||'|'||niv2.code||'|'||niv3.code as code, + niv1.texte||case when upper(niv2.code) not in ('0', 'O') then ' - '||niv2.texte else '' end||case when upper(niv3.code) not in ('0', 'O') then ' - '||niv3.texte else '' end as texte, + substr(niv1.texte||case when upper(niv2.code) not in ('0', 'O') then ' - '||niv2.texte else '' end||case when upper(niv3.code) not in ('0', 'O') then ' - '||niv3.texte else '' end, 1, 50) as texte_court + from niv1, niv2, niv3 + where 1=1 + AND niv1.code||'|'||niv2.code||'|'||niv3.code NOT IN (SELECT code_original FROM rh.t_services) + AND (select valeur = 4 from rh.t_divers where code = 'CEGID_SERVICE') + group by 1,2,3,4 + UNION + SELECT cc_code, cc_code, cc_libelle, substr(cc_abrege,1,50) + FROM prod_cegid.choixcod + WHERE 1=1 + AND cc_type = case (select valeur from rh.t_divers where code = 'CEGID_SERVICE') + when 1 then 'PAG' + when 2 then 'PST' + when 3 then 'PUN' end + AND cc_code NOT IN (SELECT code_original FROM rh.t_services) + AND (select valeur in (1, 2, 3) from rh.t_divers where code = 'CEGID_SERVICE') + GROUP BY 1,2,3,4 + ; + + -- Màj des spécialités + INSERT INTO rh.t_specialites(code_original, code, texte, texte_court) + SELECT cc_code, cc_code, cc_libelle, substr(cc_abrege,1,50) + FROM prod_cegid.choixcod + WHERE 1=1 + AND cc_type = 'PST' + AND cc_code NOT IN (SELECT code_original FROM rh.t_specialites) + GROUP BY 1,2,3,4 + ; + + -- Màj des codes emploi + INSERT INTO rh.t_codes_emploi(code_original, code, texte, texte_court) + SELECT cc_code, cc_code as code_o, cc_libelle, LEFT(cc_libelle,50) + FROM prod_cegid.choixcod + WHERE 1=1 + AND cc_type = 'PLE' + AND cc_code NOT IN (SELECT code_original FROM rh.t_codes_emploi) + GROUP BY 1,2,3,4 + UNION + SELECT ppu_libelleemploi, ppu_libelleemploi, ppu_libelleemploi, substr(ppu_libelleemploi, 1, 50) + FROM prod_cegid.paieencours + WHERE ppu_libelleemploi NOT IN (SELECT code_original FROM rh.t_codes_emploi) AND + ppu_libelleemploi NOT IN (SELECT cc_code FROM prod_cegid.choixcod WHERE cc_type = 'PLE') + GROUP BY 1,2,3,4 + ; + + -- @TODO: Màj des types d'horaire + + -- Màj des sociétés d'interim + + -- Màj des grilles + INSERT INTO rh.t_grilles(code_original, code, texte, texte_court) + SELECT ppu_coefficient, ppu_coefficient, ppu_coefficient, ppu_coefficient + FROM prod_cegid.paieencours + WHERE 1=1 + AND ppu_coefficient NOT IN (SELECT code_original FROM rh.t_grilles) + AND (select valeur = 'GRILLE' FROM rh.t_divers WHERE code = 'CEGID_GRILLE') + GROUP BY 1 + UNION ALL + SELECT ltrim(pmi_code, '0'), ltrim(pmi_code, '0'), pmi_libelle, substr(pmi_libelle, 1, 50) + FROM prod_cegid.minimumconvent + WHERE 1=1 + AND pmi_nature = 'QUA' + AND ltrim(pmi_code, '0') NOT IN (SELECT code_original FROM rh.t_grilles) + AND (select valeur = 'QUALIFICATION' FROM rh.t_divers WHERE code = 'CEGID_GRILLE') + GROUP BY 1,2,3,4 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT ppu_coefficient, ppu_coefficient, ppu_coefficient, ppu_coefficient + FROM prod_cegid.paieencours + WHERE 1=1 + AND ppu_coefficient NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + AND (select valeur = 'COEFF' FROM rh.t_divers WHERE code = 'CEGID_GRP_GRILLE') + GROUP BY 1 + UNION ALL + SELECT ltrim(pmi_code, '0'), ltrim(pmi_code, '0'), pmi_libelle, substr(pmi_libelle, 1, 50) + FROM prod_cegid.minimumconvent + WHERE 1=1 + AND pmi_nature = 'IND' + AND ltrim(pmi_code, '0') != '' + AND ltrim(pmi_code, '0') NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + AND (select valeur = 'IND' FROM rh.t_divers WHERE code = 'CEGID_GRP_GRILLE') + GROUP BY 1,2,3,4 + UNION ALL + SELECT phc_montant::int::text, phc_montant::int::text, phc_montant::int::text, phc_montant::int::text + FROM prod_cegid.histocumsal + WHERE 1=1 + AND phc_cumulpaie = (SELECT valeur::int FROM rh.t_divers WHERE code = 'CEGID_GRP_GRILLE_CST') + AND phc_montant NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + AND (select valeur = 'BUL' FROM rh.t_divers WHERE code = 'CEGID_GRP_GRILLE') + GROUP BY 1,2,3,4 + ; + + -- Màj des motifs d'arret + INSERT INTO rh.t_motifs_arret(code_original, code, texte, texte_court) + SELECT + pcn_typeconge, + pcn_typeconge, + max(substring(pcn_libelle from '^(.*)[0-9]{2}/[0-9]{2}/[0-9]{2} au [0-9]{2}/[0-9]{2}/[0-9]{2}$')), + max(substr(substring(pcn_libelle from '^(.*)[0-9]{2}/[0-9]{2}/[0-9]{2} au [0-9]{2}/[0-9]{2}/[0-9]{2}$'),1,50)) + FROM prod_cegid.absencesalarie + WHERE 1=1 + AND pcn_typemvt = 'ABS' + AND pcn_mvtduplique != 'X' + AND pcn_typeconge NOT IN (SELECT code_original FROM rh.t_motifs_arret) + GROUP BY 1,2 + ; + + -- @TODO: Màj des précisions du motif d'arrêt + + -- @TODO: Màj des motifs de visite médicale + + -- @TODO: Màj des circonstances d'accident du travail + + -- @TODO: Màj des lieux d'accident du travail + + -- @TODO: Màj de la nature de l'accident du travail + + -- @TODO: Màj des sièges d'accident du travail + + -- @TODO: Màj des listes de formations + + -- Màj des sections analytiques compta + INSERT INTO rh.t_sections_analytiques(code_original, code, texte, texte_court) + SELECT s_section, s_section, MAX(s_libelle), MAX(substr(s_abrege,1,50)) + FROM prod_cegid.section + WHERE s_section NOT IN (SELECT code_original FROM rh.t_sections_analytiques) + GROUP BY 1,2 + ; + + -- Màj des sections analytiques paie + + ]]> + + + 0 + from information_schema.tables + where 1=1 + and table_schema = 'prod_cegid' + and table_name = 'guideecrpaie' + ; + + ]]> + + + + + + + + + + + + + + + + + 0 + OR phb_mtsalarial <> 0 + OR phb_mtpatronal <> 0 + ) + AND phb_datefin::date - phb_datedebut::date < 31 -- pas les bulletins de paie sur plus d'un mois (lève le matricule 151) + -- date_part('month', phb_datefin) != date_part('month', phb_datedebut) -- (lève les matricules 151 et 1217) + -- + GROUP BY 1,2 + ) AS subq ON 1=1 + AND subq.phb_salarie = ppu_salarie + AND subq.phb_datefin = ppu_datefin + LEFT JOIN ( -- Cette jointure permet de compter le bon nombre d'heures payées paramétré dans t_rubriques (code_calcul = 1). + SELECT + phc_salarie, + phc_datefin, + sum(phc_montant)::numeric AS heures_payees + FROM prod_cegid.histocumsal + WHERE phc_cumulpaie = (select substr(code_original, 3, 2)::int from rh.t_rubriques where substr(code_original, 1, 2) = 'C0' and code_calcul = 1) + GROUP BY 1,2 + ) AS subq2 ON 1=1 + AND subq2.phc_salarie = subq.phb_salarie + AND subq2.phc_datefin = subq.phb_datefin + JOIN rh.t_etablissements ON t_etablissements.code_original = ppu_etablissement + JOIN rh.t_entreprises ON t_entreprises.oid = t_etablissements.entreprise_id + WHERE 1=1 + AND date_part('year', ppu_datefin) >= 2009 + GROUP BY 1,2,3 + ; + + ]]> + + + = '2012-01-01'::date + then 1 + else 0 + end) + as est_en_cours + from prod_cegid.paieencours + where ppu_bulcompl != 'X' + group by 1 + ; + + -- Cas où plus d'un mois ont été identifiés comme en cours. + UPDATE w_paie_est_encours + SET est_en_cours = 0 + WHERE 1=1 + AND (SELECT count(est_en_cours) FROM w_paie_est_encours WHERE est_en_cours = 1) > 1 + AND est_en_cours = 1 + AND mois != (SELECT max(mois) FROM w_paie_est_encours WHERE est_en_cours = 1) + ; + + -- Cas où pas de mois en cours identifié. + insert into w_paie_est_encours + SELECT + to_char(max(to_date(mois, 'YYYYMM')) + '1 month'::interval, 'YYYYMM'), + 1 + FROM w_paie_est_encours + WHERE (SELECT max(est_en_cours) FROM w_paie_est_encours) = 0 + group by 2 + ; + + DROP TABLE IF EXISTS w_ventana + ; + + CREATE TEMP TABLE w_ventana AS + SELECT + split_part(yva_identifiant,';',1) as matricule, + to_char(to_date(split_part(yva_identifiant,';',2), 'DDMMYYYY'), 'YYYYMM') as mois, + to_date(split_part(yva_identifiant,';',2), 'DDMMYYYY') as date_debut, + to_date(split_part(yva_identifiant,';',3), 'DDMMYYYY') as date_fin, + yva_section as section, + sum(yva_pourcentage)/100.0 as ratio + FROM prod_cegid.ventana + JOIN w_paieencours_nc ON 1=1 -- permet de ne retenir que les ventilations analytiques associées à une paye (exclu les ventilations chevauchantes; ex :1579 du 1er au 25 novembre 2013) + AND w_paieencours_nc.ppu_salarie = split_part(yva_identifiant,';',1) + AND w_paieencours_nc.date_debut = to_date(split_part(yva_identifiant,';',2), 'DDMMYYYY') + AND w_paieencours_nc.date_fin = to_date(split_part(yva_identifiant,';',3), 'DDMMYYYY') + WHERE 1=1 + AND yva_axe = 'A1' + AND split_part(yva_identifiant,';',4) = 'COT' + AND yva_pourcentage > 0 + GROUP BY 1,2,3,4,5 + ; + + -- Clef ventilation_id : matricule, mois, section + DROP TABLE IF EXISTS w_ventilation + ; + + CREATE TEMP TABLE w_ventilation AS + select + w_ventana.mois, + greatest(w_ventana.date_debut, w_contrattravail_mois.date_debut_mv) AS date_debut, + least(w_ventana.date_fin, w_contrattravail_mois.date_fin_mv) AS date_fin, + w_ventana.matricule, + w_ventana.section, + 0 AS ventilation_id, + ratio, + numero_contrat, + 0 AS est_hors_periode + FROM w_ventana + LEFT JOIN w_contrattravail_mois on 1=1 + AND w_contrattravail_mois.pci_salarie = w_ventana.matricule + --AND w_contrattravail_mois.date_debut_mv = w_ventana.date_debut + --AND w_contrattravail_mois.date_fin_mv = w_ventana.date_fin + AND base.cti_overlaps(date_debut_mv, date_fin_mv, w_ventana.date_debut, w_ventana.date_fin) + WHERE (SELECT valeur = '1' FROM rh.t_divers WHERE code = 'OPT_VENT_PAIE') + group by 1,2,3,4,5,6,7,8,9 + ; + + DROP SEQUENCE IF EXISTS w_ventilation_seq + ; + + CREATE TEMP SEQUENCE w_ventilation_seq + ; + + UPDATE w_ventilation + SET ventilation_id = nextval('w_ventilation_seq') + ; + + -- Association des ventilations "hors période" au contrat plus récent (on prend le contrat précédent la ventilation). + UPDATE w_ventilation + SET + numero_contrat = subq.numero_contrat, + est_hors_periode = 1 + FROM ( + select + ventilation_id, + w_contrattravail.numero_contrat + FROM w_ventilation + left join w_contrattravail on w_contrattravail.pci_salarie = w_ventilation.matricule + where 1=1 + AND w_ventilation.numero_contrat is null + AND w_ventilation.date_debut > w_contrattravail.date_fin + GROUP BY 1,2 + ) AS subq + WHERE w_ventilation.ventilation_id = subq.ventilation_id + ; + + -- Association des ventilations "hors période" au contrat plus récent (on prend le contrat suivant la ventilation). + UPDATE w_ventilation + SET + numero_contrat = subq.numero_contrat, + est_hors_periode = 1 + FROM ( + select + ventilation_id, + w_contrattravail.numero_contrat + FROM w_ventilation + left join w_contrattravail on w_contrattravail.pci_salarie = w_ventilation.matricule + where 1=1 + AND w_ventilation.numero_contrat is null + AND w_ventilation.date_debut < w_contrattravail.date_fin + GROUP BY 1,2 + ) AS subq + WHERE w_ventilation.ventilation_id = subq.ventilation_id + ; + + -- Création d'une table temporaire ventilée mensuellement des évenements salariés. + DROP TABLE IF EXISTS w_salarie_mois + ; + + CREATE TEMP TABLE w_salarie_mois AS + SELECT + ppu_etablissement AS eta, + ppu_salarie AS matricule, + cnt.numero_contrat, + greatest(cnt.date_debut,pai.date_debut) AS date_debut, + least(cnt.date_fin,pai.date_fin) AS date_fin, + cnt.date_debut AS datedebutcontrat, + cnt.date_fin AS datefincontrat, + pai.ppu_datedebut::date AS datepaiedebut, + pai.ppu_datefin::date AS datepaiefin, + CASE WHEN pci_salarie IS NULL THEN 1 ELSE 0 END AS est_hors_periode, + coalesce(lower(ppu_codeemploi::text), chr(1)||'*') AS categorie_socio_professionnelle_code_original, + coalesce(upper(ppu_libelleemploi::text), chr(1)||'*') AS code_emploi_code_original, + coalesce(CASE WHEN (SELECT valeur = 'GRILLE' FROM rh.t_divers WHERE code = 'CEGID_GRILLE') THEN ppu_coefficient::text ELSE ltrim(ppu_qualification, '0') END, chr(1)||'*') AS grille_code_original, + coalesce(ppu_indice::text, chr(1)||'*') AS ppu_indice, + coalesce(ppu_coefficient::text, chr(1)||'*') AS ppu_coefficient, + coalesce(ppu_travailn1::text, chr(1)||'*') AS ppu_travailn1, + coalesce(ppu_travailn2::text, chr(1)||'*') AS ppu_travailn2, + coalesce(ppu_travailn3::text, chr(1)||'*') AS ppu_travailn3, + coalesce(ppu_travailn4::text, chr(1)||'*') AS ppu_travailn4, + coalesce(coefficient, chr(1)||'*') AS coefficient, + coalesce(ppu_codestat, chr(1)||'*') AS groupe_cotisant_code_original, + coalesce(CASE WHEN (SELECT valeur = 'QUALIFICATION' FROM rh.t_divers WHERE code = 'CEGID_QUALIFICATION') THEN ltrim(ppu_qualification, '0') ELSE upper(ppu_libelleemploi::text) END, chr(1)||'*') AS qualification_code_original, + coalesce( + CASE (SELECT valeur::int FROM rh.t_divers WHERE code = 'CEGID_SERVICE') + WHEN 1 THEN ppu_travailn1 + WHEN 2 THEN ppu_travailn2 + WHEN 3 THEN ppu_travailn3 + WHEN 4 THEN ppu_travailn1||'|'||ppu_travailn2||'|'||ppu_travailn3 -- le champ 4 existe (cf. type de contrat qqes lignes plus bas) ! : posera pb à PCBS. + ELSE ppu_travailn3 END, + chr(1)||'*') AS service_code_original, + coalesce(ppu_travailn2, chr(1)||'*') AS specialite_code_original, + coalesce(pci_typecontrat, + CASE (SELECT valeur::int FROM rh.t_divers WHERE code = 'CEGID_TYPE_CONTRAT') + WHEN 1 THEN ppu_travailn1 + WHEN 2 THEN ppu_travailn2 + WHEN 3 THEN ppu_travailn3 + WHEN 4 THEN ppu_travailn4 -- le champ 4 existe ! + ELSE ppu_travailn1 END, + chr(1)||'*') AS type_contrat_code_original, + cnt.pci_motifsortie as motif_fin_code_original + FROM w_paieencours_nc AS pai + LEFT JOIN w_contrattravail AS cnt ON 1=1 + AND pai.ppu_salarie = cnt.pci_salarie + AND base.cti_overlaps(pai.date_debut, pai.date_fin, cnt.date_debut, cnt.date_fin) + ; + + -- Mise à jour des contrat hors_période et non renseignés : + -- ex : 2 évènements : 201108 (couvert par CDD n°5) et 201109 (non couvert par contrat) + -- => 201109 sera renseigné avec le CDD n°5. + UPDATE w_salarie_mois + SET numero_contrat = subq.numero_contrat, + datedebutcontrat = subq.datedebutcontrat, + datefincontrat = subq.datefincontrat + FROM ( + select + w_contrattravail.pci_salarie AS matricule, + max(w_contrattravail.numero_contrat) AS numero_contrat, + max(w_contrattravail.date_debut) AS datedebutcontrat, + max(w_contrattravail.date_fin) AS datefincontrat, + datepaiedebut, + datepaiefin + from w_contrattravail + join ( + select matricule, datepaiedebut, datepaiefin + from w_salarie_mois + where est_hors_periode = 1 + ) as subq1 on subq1.matricule = w_contrattravail.pci_salarie + where 1=1 + and w_contrattravail.date_fin < subq1.datepaiedebut + group by 1,5,6 + ) AS subq + WHERE 1=1 + AND w_salarie_mois.matricule = subq.matricule + AND w_salarie_mois.datepaiedebut = subq.datepaiedebut + AND w_salarie_mois.datepaiefin = subq.datepaiefin + AND w_salarie_mois.est_hors_periode = 1 + ; + + -- Mise à jour des contrats restants non renseignés : + -- ex : 2 évènements : 201108 (non couvert par contrat) et 201109 (couvert par CDD n°1) + -- => 201108 sera renseigné avec le CDD n°1. + UPDATE w_salarie_mois + SET numero_contrat = subq.numero_contrat, + datedebutcontrat = subq.datedebutcontrat, + datefincontrat = subq.datefincontrat + FROM ( + select + w_contrattravail.pci_salarie AS matricule, + min(w_contrattravail.numero_contrat) AS numero_contrat, + min(w_contrattravail.date_debut) AS datedebutcontrat, + min(w_contrattravail.date_fin) AS datefincontrat, + datepaiedebut, + datepaiefin + from w_contrattravail + join ( + select matricule, datepaiedebut, datepaiefin + from w_salarie_mois + where est_hors_periode = 1 + ) as subq1 on subq1.matricule = w_contrattravail.pci_salarie + where 1=1 + and w_contrattravail.date_fin > subq1.datepaiedebut + group by 1,5,6 + ) AS subq + WHERE 1=1 + AND w_salarie_mois.matricule = subq.matricule + AND w_salarie_mois.datepaiedebut = subq.datepaiedebut + AND w_salarie_mois.datepaiefin = subq.datepaiefin + AND w_salarie_mois.est_hors_periode = 1 + ; + + ]]> + + + 0 + AND salaries.psa_motifentree IS NOT NULL + AND salaries.psa_salarie = w_profils.matricule + ; + + -- Mise à jour du motif de sortie du salarié de l'établissement (sur son dernier contrat uniquement) + UPDATE w_profils + SET motif_fin_code_original = trim(salaries.psa_motifsortie) + FROM prod_cegid.salaries + JOIN + ( + SELECT pci_salarie, (MAX(ARRAY[date_debut::text,numero_contrat]))[2] AS numero_contrat_fin + FROM w_contrattravail + GROUP BY 1 + ) subview ON psa_salarie = pci_salarie + WHERE 1=1 + AND (select valeur != '2' FROM rh.t_divers WHERE code = 'CEGID_MOTIF_FIN') + AND salaries.psa_salarie = w_profils.matricule + AND subview.numero_contrat_fin = w_profils.numero_contrat + AND length(trim(salaries.psa_motifsortie)) > 0 + AND salaries.psa_motifsortie IS NOT NULL + ; + + ]]> + + + + + + + + date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_entree_ets = date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND to_char(date_entree_ets, 'YYYY')::numeric >= 2009 + AND date_entree_ets < date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_sortie_ets = date_fin_contrat + FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND date_fin_contrat > date_sortie_ets + ; + + -- Calcul ancienneté au début de contrat + UPDATE rh.p_contrats + SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_calculee_mois + FROM ( + SELECT + t1.numero_contrat, + sum(t2.duree) AS anciennete_anterieure_jours, + sum(t2.duree) / 30 AS anciennete_anterieure_calculee_mois + FROM w_contrattravail AS t1 + JOIN w_contrattravail AS t2 ON 1=1 + AND t2.pci_salarie = t1.pci_salarie + AND t2.pci_ordre < t1.pci_ordre + group by 1 + ) AS subq + WHERE 1=1 + AND p_contrats.numero_contrat = subq.numero_contrat + ; + + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, + present_debut_mois, + present_fin_mois, + equivalent_temps_plein, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id + ) + SELECT + p_salaries.oid AS salarie_id, + p_contrats.oid AS contrat_id, + p_calendrier_mois.mois AS mois, + GREATEST(p_calendrier_mois.date_debut, w_salarie_mois.date_debut) AS date_debut, + LEAST(p_calendrier_mois.date_fin, w_salarie_mois.date_fin) AS date_fin, + CASE WHEN p_salaries.date_entree_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_entrees, + CASE WHEN p_salaries.date_sortie_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_departs, + CASE WHEN p_contrats.date_debut BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_contrat, + CASE WHEN p_contrats.date_fin BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_contrat, + w_salarie_mois.est_hors_periode, + CASE WHEN p_calendrier_mois.date_debut BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_debut_mois, + CASE WHEN p_calendrier_mois.date_fin BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + 0, -- L'ETP théorique est calculé plus loin à l'issue de la "Ventilation des profils". + base.cti_age(LEAST(p_calendrier_mois.date_fin, w_salarie_mois.date_fin), COALESCE(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + LEAST(p_calendrier_mois.date_fin, w_salarie_mois.date_fin)::date - COALESCE(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + p_contrats.anciennete_anterieure_jours + + (LEAST(p_calendrier_mois.date_fin, w_salarie_mois.date_fin) - p_contrats.date_debut) + + 1 + AS anciennete_jours, + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + AS anciennete_mois, + floor( + ( + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + ) / 12 + ) AS anciennete_annee_id + FROM w_salarie_mois + JOIN base.p_calendrier_mois ON base.cti_overlaps(w_salarie_mois.date_debut, w_salarie_mois.date_fin, p_calendrier_mois.date_debut, p_calendrier_mois.date_fin) + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_salarie_mois.numero_contrat + JOIN rh.p_salaries ON p_salaries.matricule = w_salarie_mois.matricule + WHERE 1=1 + AND p_calendrier_mois.mois < to_char(now() + '1 month'::interval, 'YYYYMM') + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 + ; + + ]]> + + + trim(PHB_SENSBUL) + ; + + ANALYSE w_histobulletin + ; + + ]]> + + + + + + + + + + + + 0 + OR phb_mtsalarial <> 0 + OR phb_mtpatronal <> 0 + ) + GROUP BY 1,2,3,4,5,6,7,8 + ) + , rub_det_1 as ( + select + codrubrique, + bool_or(brut) or bool_or(odns) or bool_or(odnp) or bool_or(cosd) or bool_or(copa) AS p_detail, + false AS p_nombre, + bool_or(brut) or bool_or(odns) or bool_or(odnp) or bool_or(cosd) or bool_or(copa) AS p_base, + bool_or(hresp) AS p_heures_payees, + bool_or(hresw) AS p_heures_travaillees, + bool_or(brut) or bool_or(odnp) or bool_or(copa) AS p_masse_salariale, + bool_or(brut) AS p_brut, + false AS p_avantage_nature, + false AS p_frais_imposables, + bool_or(cosd) AS p_cotisation_salarie, + bool_or(copa) AS p_cotisation_patronale, + bool_or(odns) AS p_od_net_salarie, + false AS p_od_net_patronale, + bool_or(brut) or bool_or(cosd) AS p_net_imposable, + bool_or(brut) or bool_or(cosd) or bool_or(odns) AS p_net_a_payer + from rub_det_0 + group by 1 + ) + + SELECT + codrubrique as code_original, + false as p_cumul, + p_detail as p_detail, + p_nombre as p_nombre, + 0 as s_nombre, + 1 as c_nombre, + p_base as p_base, + 1 as s_base, + 1 as c_base, + false as p_heures_contrat, + 0 as s_heures_contrat, + 1 as c_heures_contrat, + p_heures_payees as p_heures_payees, + 0 as s_heures_payees, + 1 as c_heures_payees, + p_heures_travaillees as p_heures_travaillees, + 0 as s_heures_travaillees, + 1 as c_heures_travaillees, + p_masse_salariale as p_masse_salariale, + case when p_cotisation_patronale or p_od_net_patronale then 5 else 3 end as s_masse_salariale, + 1 as c_masse_salariale, + p_brut as p_brut, + 3 as s_brut, + 1 as c_brut, + p_avantage_nature as p_avantage_nature, + 3 as s_avantage_nature, + 1 as c_avantage_nature, + p_frais_imposables as p_frais_imposables, + 3 as s_frais_imposables, + 1 as c_frais_imposables, + p_cotisation_salarie as p_cotisation_salarie, + 3 as s_cotisation_salarie, + 1 as c_cotisation_salarie, + p_cotisation_patronale as p_cotisation_patronale, + 5 as s_cotisation_patronale, + 1 as c_cotisation_patronale, + p_od_net_salarie as p_od_net_salarie, + 3 as s_od_net_salarie, + 1 as c_od_net_salarie, + p_od_net_patronale as p_od_net_patronale, + 5 as s_od_net_patronale, + 1 as c_od_net_patronale, + p_net_imposable as p_net_imposable, + 3 as s_net_imposable, + 1 as c_net_imposable, + p_net_a_payer as p_net_a_payer, + 3 as s_net_a_payer, + 1 as c_net_a_payer + FROM rub_det_1 + ; + + -- Pré-paramétrage automatique des rubriques (au mieux). + -- Cette requête n'intervient pas sur les rubriques paramétrées à la main. + update rh.t_rubriques + set + p_cumul = x_ref_rubrique.p_cumul, + p_detail = x_ref_rubrique.p_detail, + p_nombre = x_ref_rubrique.p_nombre, + s_nombre = x_ref_rubrique.s_nombre, + c_nombre = x_ref_rubrique.c_nombre, + p_base = x_ref_rubrique.p_base, + s_base = x_ref_rubrique.s_base, + c_base = x_ref_rubrique.c_base, + p_heures_contrat = x_ref_rubrique.p_heures_contrat, + s_heures_contrat = x_ref_rubrique.s_heures_contrat, + c_heures_contrat = x_ref_rubrique.c_heures_contrat, + p_heures_payees = x_ref_rubrique.p_heures_payees, + s_heures_payees = x_ref_rubrique.s_heures_payees, + c_heures_payees = x_ref_rubrique.c_heures_payees, + p_heures_travaillees = x_ref_rubrique.p_heures_travaillees, + s_heures_travaillees = x_ref_rubrique.s_heures_travaillees, + c_heures_travaillees = x_ref_rubrique.c_heures_travaillees, + p_masse_salariale = x_ref_rubrique.p_masse_salariale, + s_masse_salariale = x_ref_rubrique.s_masse_salariale, + c_masse_salariale = x_ref_rubrique.c_masse_salariale, + p_brut = x_ref_rubrique.p_brut, + s_brut = x_ref_rubrique.s_brut, + c_brut = x_ref_rubrique.c_brut, + p_avantage_nature = x_ref_rubrique.p_avantage_nature, + s_avantage_nature = x_ref_rubrique.s_avantage_nature, + c_avantage_nature = x_ref_rubrique.c_avantage_nature, + p_frais_imposables = x_ref_rubrique.p_frais_imposables, + s_frais_imposables = x_ref_rubrique.s_frais_imposables, + c_frais_imposables = x_ref_rubrique.c_frais_imposables, + p_cotisation_salarie = x_ref_rubrique.p_cotisation_salarie, + s_cotisation_salarie = x_ref_rubrique.s_cotisation_salarie, + c_cotisation_salarie = x_ref_rubrique.c_cotisation_salarie, + p_cotisation_patronale = x_ref_rubrique.p_cotisation_patronale, + s_cotisation_patronale = x_ref_rubrique.s_cotisation_patronale, + c_cotisation_patronale = x_ref_rubrique.c_cotisation_patronale, + p_od_net_salarie = x_ref_rubrique.p_od_net_salarie, + s_od_net_salarie = x_ref_rubrique.s_od_net_salarie, + c_od_net_salarie = x_ref_rubrique.c_od_net_salarie, + p_od_net_patronale = x_ref_rubrique.p_od_net_patronale, + s_od_net_patronale = x_ref_rubrique.s_od_net_patronale, + c_od_net_patronale = x_ref_rubrique.c_od_net_patronale, + p_net_imposable = x_ref_rubrique.p_net_imposable, + s_net_imposable = x_ref_rubrique.s_net_imposable, + c_net_imposable = x_ref_rubrique.c_net_imposable, + p_net_a_payer = x_ref_rubrique.p_net_a_payer, + s_net_a_payer = x_ref_rubrique.s_net_a_payer, + c_net_a_payer = x_ref_rubrique.c_net_a_payer + from temp.x_ref_rubrique + where 1=1 + AND t_rubriques.code_original = x_ref_rubrique.code_original + AND NOT t_rubriques.user_modified + ; + + DROP TABLE IF EXISTS temp.x_hst_paie + ; + + CREATE TABLE temp.x_hst_paie AS + ( + SELECT + 'histobulletin'::text || histobulletin.CTID::text AS source, + w_histosalarie.date_fin AS histosalarie_date_fin, + w_histosalarie.CTID::text AS histosalarie_ctid, + phb_etablissement::text||'-'||phb_salarie::text||'-'||phb_datefin::text as bul_id, + phb_etablissement AS ety_code_original, + phb_salarie AS sal_code_original, + phb_datedebut::date AS date_debut, + phb_datefin::date AS date_fin, + to_char(phb_datefin,'YYYYMM')::numeric AS mois, + phb_rubrique||'-'||phb_ordreetat AS rub_code_original, + case when phb_mtpatronal != 0 then w_comptes_p.cpt else w_comptes_s.cpt end as cpt, + phb_organisme AS organisme, + coalesce(nullif((max(ARRAY[extract(epoch from w_histosalarie.date_debut), w_histosalarie.phs_ttauxpartiel]))[2], 0) / 100.0, 1.0) as etp_contrat, + sum(phb_baserem * (CASE WHEN phb_sensbul = 'P' THEN 1 ELSE -1 END)) AS base, + sum(CASE WHEN phb_ordreetat in (1, 2, 6, 7) THEN phb_tauxrem ELSE phb_tauxsalarial END) AS txsal, + sum((phb_mtrem + phb_mtsalarial * -1.0) * (CASE WHEN phb_sensbul = 'P' THEN 1 ELSE -1 END)) AS mntsal, + sum(phb_tauxpatronal) AS txpat, + sum(phb_mtpatronal * (CASE WHEN phb_sensbul = 'P' THEN 1 ELSE -1 END)) AS mntpat + FROM w_histobulletin as histobulletin + left join w_histosalarie on 1=1 + and w_histosalarie.phs_salarie = histobulletin.phb_salarie + and base.cti_overlaps(w_histosalarie.date_debut, w_histosalarie.date_fin, histobulletin.phb_datedebut::date, histobulletin.phb_datefin::date) + left join w_comptes_s on w_comptes_s.rub = histobulletin.phb_rubrique + left join w_comptes_p on w_comptes_p.rub = histobulletin.phb_rubrique + WHERE 1=1 + AND (1!=1 + OR phb_mtrem <> 0 + OR phb_mtsalarial <> 0 + OR phb_mtpatronal <> 0 + ) + AND date_part('year', phb_datefin) >= to_char(rhp('rhprovider_start')::date, 'YYYY') + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12, histobulletin.ctid + ) + UNION ALL + ( + SELECT + 'histocumsal'::text || histocumsal.CTID::text AS source, + w_histosalarie.date_fin AS histosalarie_date_fin, + w_histosalarie.CTID::text AS histosalarie_ctid, + phc_etablissement::text||'-'||phc_salarie::text||'-'||phc_datefin::text as bul_id, + phc_etablissement AS ety_code_original, + phc_salarie AS sal_code_original, + phc_datedebut::date AS date_debut, + phc_datefin::date AS date_fin, + to_char(phc_datefin,'YYYYMM')::numeric AS mois, + 'C'||lpad(phc_cumulpaie,3,'0') AS rub_code_original, + '' as cpt, + '' AS organisme, + coalesce(nullif((max(ARRAY[extract(epoch from w_histosalarie.date_debut), w_histosalarie.phs_ttauxpartiel]))[2], 0) / 100.0, 1.0) as etp_contrat, + CASE WHEN phc_cumulpaie in ('20', '21', '22') THEN phc_montant ELSE 0 END AS base, + 0 AS txsal, + CASE WHEN phc_cumulpaie in ('01', '02', '08', '09', '10') THEN phc_montant ELSE 0 END as mntsal, + 0 AS txpat, + CASE WHEN phc_cumulpaie = '07' THEN phc_montant ELSE 0 END as mntpat + FROM prod_cegid.histocumsal + left join w_histosalarie on 1=1 + and w_histosalarie.phs_salarie = histocumsal.phc_salarie + and base.cti_overlaps(w_histosalarie.date_debut, w_histosalarie.date_fin, histocumsal.phc_datedebut::date, histocumsal.phc_datefin::date) + WHERE 1=1 + AND phc_cumulpaie IN ('01', '02', '07', '08', '09', '10', '20', '21', '22') + AND date_part('year', phc_datefin) >= to_char(rhp('rhprovider_start')::date, 'YYYY') + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12, phc_montant, phc_cumulpaie, histocumsal.ctid + ) + ; + + ANALYSE temp.x_hst_paie + ; + + -- Suppression des doublons dus à un écart entre dates contrats et dates paie + DELETE FROM temp.x_hst_paie + USING + ( + SELECT source, count(*), (MAX(ARRAY[histosalarie_date_fin::text, histosalarie_ctid]))[2] AS keep_ctid + FROM temp.x_hst_paie + GROUP BY 1 + HAVING count(*) > 1 + ) subview + WHERE x_hst_paie.source = subview.source AND + x_hst_paie.histosalarie_ctid <> keep_ctid + ; + + -- #specifique - Màj des jours des fofaits jours (rubrique 0007) en heures à partir de la table 'prod_cegid.histosalarie'. + with liste_rub_fj as ( + select t_rubriques.code_original + from rh.t_listes + join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + join rh.t_rubriques on t_rubriques.oid = t_listes_contenu.to_id + where t_listes.code = 'CTI_PEGASE_FTJ' + ) + , heures as ( + select + phs_salarie as matricule, + to_char(date_debut, 'YYYYMM') as mois_debut, + to_char(date_fin, 'YYYYMM') as mois_fin, + max(nb_heures) as nb_heures + from w_histosalarie + group by 1,2,3) + , forfaits as ( + select + x_hst_paie.sal_code_original, + x_hst_paie.mois + from temp.x_hst_paie + WHERE 1=1 + and rub_code_original in (select code_original from liste_rub_fj) + and @base = 0 + ) + UPDATE temp.x_hst_paie SET + base = nb_heures * (x_hst_paie.date_fin - x_hst_paie.date_debut + 1.0) / (base.cti_last_day(x_hst_paie.date_debut) - base.cti_first_day(x_hst_paie.date_debut) + 1.0) + FROM heures, forfaits + WHERE 1=1 + and x_hst_paie.sal_code_original = heures.matricule + and x_hst_paie.sal_code_original = forfaits.sal_code_original + and x_hst_paie.mois between heures.mois_debut and heures.mois_fin + and x_hst_paie.mois = forfaits.mois + and rub_code_original = 'C021' + ; + + with liste_rub_fj as ( + select t_rubriques.code_original + from rh.t_listes + join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + join rh.t_rubriques on t_rubriques.oid = t_listes_contenu.to_id + where t_listes.code = 'CTI_PEGASE_FTJ' + ) + , heures as ( + select + phs_salarie as matricule, + to_char(date_debut, 'YYYYMM') as mois_debut, + to_char(date_fin, 'YYYYMM') as mois_fin, + max(nb_heures) as nb_heures + from w_histosalarie + group by 1,2,3) + UPDATE temp.x_hst_paie SET + base = nb_heures * (x_hst_paie.date_fin - x_hst_paie.date_debut + 1.0) / (base.cti_last_day(x_hst_paie.date_debut) - base.cti_first_day(x_hst_paie.date_debut) + 1.0) + FROM heures + WHERE 1=1 + and x_hst_paie.sal_code_original = heures.matricule + and x_hst_paie.mois between heures.mois_debut and heures.mois_fin + and x_hst_paie.rub_code_original in (select code_original from liste_rub_fj) + and @base = 0 + ; + + DROP TABLE IF EXISTS w_hp + ; + + CREATE TEMP TABLE w_hp AS + SELECT + x_hst_paie.bul_id, + t_etablissements.oid as etablissement_id, + p_salaries.oid as salarie_id, + x_hst_paie.sal_code_original, + x_hst_paie.sal_code_original AS matricule, + x_hst_paie.date_debut, + x_hst_paie.date_fin, + x_hst_paie.mois as mois_activite, + x_hst_paie.date_fin as date_paie, + x_hst_paie.mois as mois_paie, + t_rubriques.oid AS rubrique_id, + 0::bigint as organisme_cotisation_id, + 0::bigint as compte_id, + t_rubriques.c_base + * case when @t_rubriques.c_base != 1 then coalesce(case when proratiser_conversion then x_hst_paie.etp_contrat else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_base THEN (CASE s_base + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) else 0 end AS base, + t_rubriques.c_nombre + * case when @t_rubriques.c_nombre != 1 then coalesce(case when proratiser_conversion then x_hst_paie.etp_contrat else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_nombre THEN (CASE s_nombre + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) else 0 end AS nombre, + t_rubriques.c_heures_contrat + * case when @t_rubriques.c_heures_contrat != 1 then coalesce(case when proratiser_conversion then x_hst_paie.etp_contrat else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_heures_contrat + then (CASE s_heures_contrat + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS heure_contrat, + t_rubriques.c_heures_payees + * case when @t_rubriques.c_heures_payees != 1 then coalesce(case when proratiser_conversion then x_hst_paie.etp_contrat else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_heures_payees + then (CASE s_heures_payees + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees + * case when @t_rubriques.c_heures_travaillees != 1 then coalesce(case when proratiser_conversion then x_hst_paie.etp_contrat else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_heures_travaillees + then (CASE s_heures_travaillees + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale * + CASE WHEN p_masse_salariale + THEN (CASE s_masse_salariale + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS montant_masse_salariale, + t_rubriques.c_brut * + CASE WHEN p_brut + THEN (CASE s_brut + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS montant_brut, + t_rubriques.c_frais_imposables * + case when p_frais_imposables + then (CASE s_frais_imposables + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS montant_frais_imposables, + t_rubriques.coefficient_txs * + case when p_cotisation_salarie + then txsal + else 0 end AS taux_cotisation_salarie, + t_rubriques.c_cotisation_salarie * + case when p_cotisation_salarie + then (CASE s_cotisation_salarie + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS montant_cotisation_salarie, + t_rubriques.coefficient_txp * + case when p_cotisation_patronale + then txpat + else 0 end AS taux_cotisation_patronale, + t_rubriques.c_cotisation_patronale * + case when p_cotisation_patronale + then (CASE s_cotisation_patronale + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + else 0 end AS montant_cotisation_patronale, + t_rubriques.c_od_net_salarie * + CASE WHEN p_od_net_salarie + THEN (CASE s_od_net_salarie + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + ELSE 0 END AS montant_od_net_salarie, + t_rubriques.c_od_net_patronale * + CASE WHEN p_od_net_patronale + THEN (CASE s_od_net_patronale + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + ELSE 0 END AS montant_od_net_patronale, + t_rubriques.c_avantage_nature * + CASE WHEN p_avantage_nature + THEN (CASE s_avantage_nature + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + ELSE 0 END AS montant_avantage_nature, + t_rubriques.c_net_imposable * + CASE WHEN p_net_imposable + THEN (CASE s_net_imposable + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + WHEN 6 THEN mntsal + mntpat + WHEN 7 THEN mntsal - mntpat + WHEN 8 THEN -mntsal + mntpat + END) + ELSE 0 END AS montant_net_imposable_salarie, + t_rubriques.c_net_a_payer * + CASE WHEN p_net_a_payer + THEN (CASE s_net_a_payer + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + ELSE 0 END AS montant_net_a_payer_salarie, + t_rubriques.c_nombre_provisions * + CASE WHEN p_nombre_provisions + THEN (CASE s_nombre_provisions + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + ELSE 0 END AS nombre_provisions, + t_rubriques.c_montant_provisions * + CASE WHEN p_montant_provisions + THEN (CASE s_montant_provisions + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + ELSE 0 END AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * + CASE WHEN p_masse_salariale_provisionnee + THEN (CASE s_masse_salariale_provisionnee + WHEN 0 THEN base + WHEN 1 THEN base + WHEN 3 THEN mntsal + WHEN 5 THEN mntpat + END) + ELSE 0 END AS montant_masse_salariale_provisionnee, + t_rubriques.p_cumul, + t_rubriques.p_detail, + (max(ARRAY[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] as contrat_mois_id, + (max(ARRAY[extract(epoch from p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] as contrat_id, + 0::bigint as profil_id + FROM temp.x_hst_paie + JOIN rh.t_rubriques ON t_rubriques.code_original = x_hst_paie.rub_code_original + join rh.p_salaries on p_salaries.code_original = x_hst_paie.sal_code_original + join rh.t_etablissements on t_etablissements.code_original = x_hst_paie.ety_code_original + left JOIN rh.p_contrats_mois ON 1=1 + and p_contrats_mois.salarie_id = p_salaries.oid + AND base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, x_hst_paie.date_debut, x_hst_paie.date_fin) + where false + OR t_rubriques.p_detail + OR t_rubriques.p_cumul + group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35, x_hst_paie.ctid -- ce dernier regroupement nous assure de ne pas aggréger à tort des colonnes. + ; + + -- #correction Si un bulletin n'a pas de contrat rattaché. + UPDATE w_hp SET + contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + w_hp.bul_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_hp + JOIN rh.p_contrats_mois ON p_contrats_mois.salarie_id = w_hp.salarie_id + where w_hp.contrat_mois_id is null + group by 1) as subq + WHERE w_hp.bul_id = subq.bul_id + ; + + -- Génération paie + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie( + code_original, + etablissement_id, + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + mois_activite, + date_paie, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + montant_cotisation_salarie, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + taux_cotisation_salarie, + taux_cotisation_patronale, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + w_hp.bul_id, + w_hp.etablissement_id, + date_part('year', age(w_hp.date_fin, p_salaries.date_naissance)) AS age_id, + w_hp.contrat_id, + w_hp.contrat_mois_id, + w_hp.date_debut, + w_hp.date_fin, + w_hp.mois_activite, + w_hp.date_paie, + w_hp.mois_paie, + w_hp.base, + w_hp.nombre, + w_hp.heure_contrat, + w_hp.heure_payee, + w_hp.heure_travaillee, + w_hp.montant_masse_salariale, + w_hp.montant_brut, + w_hp.montant_avantage_nature, + w_hp.montant_frais_imposables, + w_hp.montant_cotisation_salarie, + w_hp.montant_cotisation_patronale, + w_hp.montant_od_net_salarie, + w_hp.montant_od_net_patronale, + w_hp.montant_net_imposable_salarie, + w_hp.montant_net_a_payer_salarie, + w_hp.taux_cotisation_salarie, + w_hp.taux_cotisation_patronale, + w_hp.organisme_cotisation_id, + w_hp.profil_id, + w_hp.rubrique_id, + w_hp.compte_id, + w_hp.salarie_id, + w_hp.nombre_provisions, + w_hp.montant_provisions, + w_hp.montant_masse_salariale_provisionnee + FROM w_hp + JOIN rh.p_salaries ON p_salaries.matricule = w_hp.matricule + where p_detail + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + -- Création d'une table récapitulative des écarts à calculer par indicateur de paie (1 seule ligne). + DROP TABLE IF EXISTS w_cumul + ; + + CREATE TEMP TABLE w_cumul AS + SELECT + bool_or(p_cumul and p_heures_contrat) as total_heures_contrat, + bool_or(p_cumul and p_heures_payees) as total_heures_payees, + bool_or(p_cumul and p_heures_travaillees) as total_heures_travaillees, + bool_or(p_cumul and p_masse_salariale) as total_masse_salariale, + bool_or(p_cumul and p_brut) as total_brut, + bool_or(p_cumul and p_avantage_nature) as total_avantage_nature, + bool_or(p_cumul and p_frais_imposables) as total_frais_imposables, + bool_or(p_cumul and p_cotisation_salarie) as total_cotisation_salarie, + bool_or(p_cumul and p_cotisation_patronale) as total_cotisation_patronale, + bool_or(p_cumul and p_od_net_salarie) as total_od_net_salarie, + bool_or(p_cumul and p_od_net_patronale) as total_od_net_patronale, + bool_or(p_cumul and p_net_imposable) as total_net_imposable, + bool_or(p_cumul and p_net_a_payer) as total_net_a_payer, + bool_or(p_cumul and p_nombre_provisions) as total_nombre_provisions, + bool_or(p_cumul and p_montant_provisions) as total_montant_provisions, + bool_or(p_cumul and p_masse_salariale_provisionnee) as total_masse_salariale_provisionnee + FROM rh.t_rubriques + ; + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calculer l'écart + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + SELECT + w_hp.bul_id, + w_hp.etablissement_id, + w_hp.salarie_id, + w_hp.mois_paie, + sum(case when p_heures_contrat then heure_contrat else 0 end) as heure_contrat, + sum(case when p_heures_payees then heure_payee else 0 end) as heure_payee, + sum(case when p_heures_travaillees then heure_travaillee else 0 end) as heure_travaillee, + sum(case when p_masse_salariale then montant_masse_salariale else 0 end) as montant_masse_salariale, + sum(case when p_brut then montant_brut else 0 end) AS montant_brut, + sum(case when p_avantage_nature then montant_avantage_nature else 0 end) as montant_avantage_nature, + sum(case when p_frais_imposables then montant_frais_imposables else 0 end) as montant_frais_imposables, + sum(case when p_cotisation_salarie then montant_cotisation_salarie else 0 end) AS montant_cotisation_salarie, + sum(case when p_cotisation_patronale then montant_cotisation_patronale else 0 end) AS montant_cotisation_patronale, + sum(case when p_od_net_salarie then montant_od_net_salarie else 0 end) as montant_od_net_salarie, + sum(case when p_od_net_patronale then montant_od_net_patronale else 0 end) as montant_od_net_patronale, + sum(case when p_net_imposable then montant_net_imposable_salarie else 0 end) as montant_net_imposable_salarie, + sum(case when p_net_a_payer then montant_net_a_payer_salarie else 0 end) as montant_net_a_payer_salarie, + sum(case when p_nombre_provisions then nombre_provisions else 0 end) as nombre_provisions, + sum(case when p_montant_provisions then montant_provisions else 0 end) as montant_provisions, + sum(case when p_masse_salariale_provisionnee then montant_masse_salariale_provisionnee else 0 end) as montant_masse_salariale_provisionnee + FROM w_hp + JOIN rh.t_rubriques ON t_rubriques.oid = w_hp.rubrique_id + where w_hp.p_cumul + GROUP BY 1,2,3,4 + ; + + -- Insérer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie ( + code_original, + etablissement_id, + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + montant_cotisation_salarie, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + WITH subq as ( + SELECT + p_historique_paie.code_original as bul_id, + p_historique_paie.etablissement_id, + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + 0 AS base, + 0 AS nombre, + organisme_cotisation_id AS organisme_cotisation_id, + profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') as rubrique_id, + compte_id, + salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + sum(heure_contrat) AS heure_contrat, + sum(heure_payee) AS heure_payee, + sum(heure_travaillee) AS heure_travaillee, + sum(montant_masse_salariale) AS montant_masse_salariale, + sum(montant_brut) AS montant_brut, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_frais_imposables) AS montant_frais_imposables, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_od_net_salarie) AS montant_od_net_salarie, + sum(montant_od_net_patronale) AS montant_od_net_patronale, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(nombre_provisions) AS nombre_provisions, + sum(montant_provisions) AS montant_provisions, + sum(montant_masse_salariale_provisionnee) AS montant_masse_salariale_provisionnee + FROM rh.p_historique_paie + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 + ) + SELECT + subq.bul_id, + subq.etablissement_id, + subq.age_id, + subq.contrat_id, + subq.contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + subq.base, + subq.nombre, + case when total_heures_contrat then w_totaux.heure_contrat - subq.heure_contrat else 0 end as heure_contrat, + case when total_heures_payees then w_totaux.heure_payee - subq.heure_payee else 0 end as heure_payee, + case when total_heures_travaillees then w_totaux.heure_travaillee - subq.heure_travaillee else 0 end as heure_travaillee, + case when total_masse_salariale then w_totaux.montant_masse_salariale - subq.montant_masse_salariale else 0 end as montant_masse_salariale, + case when total_brut then w_totaux.montant_brut - subq.montant_brut else 0 end as montant_brut, + case when total_avantage_nature then w_totaux.montant_avantage_nature - subq.montant_avantage_nature else 0 end as montant_avantage_nature, + case when total_frais_imposables then w_totaux.montant_frais_imposables - subq.montant_frais_imposables else 0 end as montant_frais_imposables, + case when total_cotisation_salarie then w_totaux.montant_cotisation_salarie - subq.montant_cotisation_salarie else 0 end as montant_cotisation_salarie, + case when total_cotisation_patronale then w_totaux.montant_cotisation_patronale - subq.montant_cotisation_patronale else 0 end as montant_cotisation_patronale, + case when total_od_net_salarie then w_totaux.montant_od_net_salarie - subq.montant_od_net_salarie else 0 end as montant_od_net_salarie, + case when total_od_net_patronale then w_totaux.montant_od_net_patronale - subq.montant_od_net_patronale else 0 end as montant_od_net_patronale, + case when total_net_imposable then w_totaux.montant_net_imposable_salarie - subq.montant_net_imposable_salarie else 0 end as montant_net_imposable_salarie, + case when total_net_a_payer then w_totaux.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie else 0 end as montant_net_a_payer_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id, + subq.rubrique_id, + subq.compte_id, + subq.salarie_id, + subq.taux_cotisation_patronale, + subq.taux_cotisation_salarie, + case when total_nombre_provisions then w_totaux.nombre_provisions - subq.nombre_provisions else 0 end as nombre_provisions, + case when total_montant_provisions then w_totaux.montant_provisions - subq.montant_provisions else 0 end as montant_provisions, + case when total_masse_salariale_provisionnee then w_totaux.montant_masse_salariale_provisionnee - subq.montant_masse_salariale_provisionnee else 0 end as montant_masse_salariale_provisionnee + FROM subq + JOIN w_totaux ON w_totaux.bul_id = subq.bul_id + JOIN w_cumul ON true + WHERE 1!=1 + OR (total_heures_contrat AND w_totaux.heure_contrat - subq.heure_contrat != 0) + OR (total_heures_payees AND w_totaux.heure_payee - subq.heure_payee != 0) + OR (total_heures_travaillees AND w_totaux.heure_travaillee - subq.heure_travaillee != 0) + OR (total_masse_salariale AND w_totaux.montant_masse_salariale - subq.montant_masse_salariale != 0) + OR (total_brut AND w_totaux.montant_brut - subq.montant_brut != 0) + OR (total_avantage_nature AND w_totaux.montant_avantage_nature - subq.montant_avantage_nature != 0) + OR (total_frais_imposables AND w_totaux.montant_frais_imposables - subq.montant_frais_imposables != 0) + OR (total_cotisation_salarie AND w_totaux.montant_cotisation_salarie - subq.montant_cotisation_salarie != 0) + OR (total_cotisation_patronale AND w_totaux.montant_cotisation_patronale - subq.montant_cotisation_patronale != 0) + OR (total_od_net_salarie AND w_totaux.montant_od_net_salarie - subq.montant_od_net_salarie != 0) + OR (total_od_net_patronale AND w_totaux.montant_od_net_patronale - subq.montant_od_net_patronale != 0) + OR (total_net_imposable AND w_totaux.montant_net_imposable_salarie - subq.montant_net_imposable_salarie != 0) + OR (total_net_a_payer AND w_totaux.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie != 0) + OR (total_nombre_provisions AND w_totaux.nombre_provisions - subq.nombre_provisions != 0) + OR (total_montant_provisions AND w_totaux.montant_provisions - subq.montant_provisions != 0) + OR (total_masse_salariale_provisionnee AND w_totaux.montant_masse_salariale_provisionnee - subq.montant_masse_salariale_provisionnee != 0) + ; + + ]]> + + + + 0 + OR phb_mtsalarial <> 0 + OR phb_mtpatronal <> 0 + ) + AND phb_datefin::date - phb_datedebut::date < 31 -- pas les bulletins de paie sur plus d'un mois (lève le matricule 151) + -- date_part('month', phb_datefin) != date_part('month', phb_datedebut) -- (lève les matricules 151 et 1217) + -- + AND date_part('year', phb_datefin) >= 2009 + GROUP BY 1,2,3,4,5,6,7,8 + ) + UNION ALL + ( + SELECT + phc_etablissement AS eta, + phc_salarie AS matricule, + phc_datedebut::date AS date_debut, + phc_datefin::date AS date_fin, + to_char(phc_datefin,'YYYYMM')::numeric AS mois, + 'C'||lpad(phc_cumulpaie,3,'0') AS rubrique, + '' as cpt, + '' AS organisme, + CASE WHEN phc_cumulpaie in ('20', '21', '22') THEN phc_montant ELSE 0 END AS base, + 0, --CASE WHEN phc_cumulpaie = '01' THEN phc_montant ELSE 0 END AS brut, + 0 AS tx_sal, + 0, --CASE WHEN phc_cumulpaie = '08' THEN phc_montant ELSE 0 END AS mt_sal, + 0 AS tx_pat, + 0,--CASE WHEN phc_cumulpaie = '07' THEN phc_montant ELSE 0 END AS mt_pat, + 0 as net_imposable, --CASE WHEN phc_cumulpaie = '09' THEN phc_montant ELSE 0 END AS net_imposable, + 0 AS net_a_payer, + 0 AS od_net + FROM prod_cegid.histocumsal + WHERE 1=1 + AND phc_cumulpaie IN ('20', '21', '22') + AND date_part('year', phc_datefin) >= 2009 + ) + UNION ALL + ( -- Création de la rubrique C021 (heures payées) pour le parc à caen 243. + SELECT + phb_etablissement AS eta, + phb_salarie AS matricule, + phb_datedebut::date AS date_debut, + phb_datefin::date AS date_fin, + to_char(phb_datefin,'YYYYMM')::numeric AS mois, + 'C021' AS rubrique, + '' as cpt, + '' AS organisme, + 0 AS base, -- sera alimenté dans un second temps + 0, + 0 AS tx_sal, + 0, + 0 AS tx_pat, + 0, + 0 as net_imposable, + 0 AS net_a_payer, + 0 AS od_net + FROM w_histobulletin + LEFT JOIN prod_cegid.histocumsal on 1=1 -- Jointure avec la table des cumuls pour ne pas en re-créer 2 fois. + and histocumsal.phc_cumulpaie = '21' + and histocumsal.phc_salarie = w_histobulletin.phb_salarie + and histocumsal.phc_datefin = w_histobulletin.phb_datefin + WHERE 1=1 + AND phb_rubrique = '0007' + and @phb_baserem = 0 + and current_database() = 'icti_243' + and histocumsal.phc_cumulpaie is null + AND date_part('year', phb_datefin) >= 2009 + ) + ; + + CREATE INDEX i_w_hp_1 + ON w_hp + USING btree (matricule) + ; + + CREATE INDEX i_w_hp_2 + ON w_hp + USING btree (mois) + ; + + CREATE INDEX i_w_hp_3 + ON w_hp + USING btree (rubrique) + ; + + -- Màj des jours d'absences (rubrique 3210) en heures d'absences à partir de la table 'absencesalarie'. + UPDATE w_hp + SET base = subq.heures + FROM ( + SELECT + pcn_salarie::text AS matricule, + pcn_datedebut::date AS date_debut, + pcn_datefin::date AS date_fin, + sum(pcn_jours) AS jours, + sum(pcn_heures) AS heures + FROM prod_cegid.absencesalarie + WHERE 1=1 + AND pcn_typeconge = 'PRI' + AND pcn_mvtduplique != 'X' + GROUP BY 1,2,3 + ) AS subq + WHERE 1=1 + AND w_hp.matricule = subq.matricule + AND w_hp.date_debut = subq.date_debut + AND w_hp.date_fin = subq.date_fin + AND w_hp.base = subq.jours + AND w_hp.rubrique in ('3210', '6968') + ; + + -- #specifique 243 - Màj des jours des fofaits jours (rubrique 0007) en heures à partir de la table 'prod_cegid.histosalarie'. + with heures as ( + select + phs_salarie as matricule, + to_char(date_debut, 'YYYYMM') as mois, + max(nb_heures) as nb_heures + from w_histosalarie + where current_database() = 'icti_243' + group by 1,2) + , forfaits as ( + select + w_hp.matricule, + w_hp.mois + from w_hp + WHERE 1=1 + and rubrique = '0007' + and @base = 0 + and current_database() = 'icti_243' + ) + UPDATE w_hp SET + base = nb_heures * (w_hp.date_fin - w_hp.date_debut + 1.0) / (base.cti_last_day(w_hp.date_debut) - base.cti_first_day(w_hp.date_debut) + 1.0) + FROM heures, forfaits + WHERE 1=1 + and w_hp.matricule = heures.matricule + and w_hp.matricule = forfaits.matricule + and w_hp.mois = heures.mois + and w_hp.mois = forfaits.mois + and rubrique = 'C021' + and current_database() = 'icti_243' + ; + + with heures as ( + select + phs_salarie as matricule, + to_char(date_debut, 'YYYYMM') as mois, + max(nb_heures) as nb_heures + from w_histosalarie + where current_database() = 'icti_243' + group by 1,2) + UPDATE w_hp SET + base = nb_heures * (w_hp.date_fin - w_hp.date_debut + 1.0) / (base.cti_last_day(w_hp.date_debut) - base.cti_first_day(w_hp.date_debut) + 1.0) + FROM heures + WHERE 1=1 + and w_hp.matricule = heures.matricule + and w_hp.mois = heures.mois + and rubrique = '0007' + and @base = 0 + and current_database() = 'icti_243' + ; + + -- Insertion dans la table de production CTI. + TRUNCATE rh.p_historique_paie + ; + + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + INSERT INTO rh.p_historique_paie + ( + age_id, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, -- @deprecated + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie + ) + SELECT + date_part('year', age(w_hp.date_debut, date_naissance)) AS age_id, + w_hp.base AS base, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.contrat_id]))[2] AS contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.oid]))[2] AS contrat_mois_id, + w_hp.date_debut AS date_debut, + w_hp.date_fin AS date_fin, + w_hp.date_fin AS date_paie, + w_hp.mois AS mois_activite, + w_hp.mois AS mois_paie, + 0 AS montant_avantage_nature, + w_hp.brut AS montant_brut, + w_hp.mt_pat AS montant_cotisation_patronale, + w_hp.mt_sal AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + w_hp.net_a_payer AS montant_net_a_payer_salarie, + w_hp.net_imposable AS montant_net_imposable_salarie, + w_hp.od_net AS montant_od_net_salarie, + coalesce(t_organismes_cotisation.oid, 0) AS organisme_cotisation_id, + 0,-- (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.profil_id]))[2] AS profil_id, + t_rubriques.oid AS rubrique_id, + COALESCE(t_compte.oid,0) as compte_id, + p_salaries.oid AS salarie_id, + w_hp.tx_pat AS taux_cotisation_patronale, + w_hp.tx_sal AS taux_cotisation_salarie + FROM w_hp + JOIN rh.t_rubriques ON t_rubriques.code_original = w_hp.rubrique + JOIN rh.p_salaries ON p_salaries.matricule = w_hp.matricule + LEFT JOIN rh.t_compte on t_compte.code_original = w_hp.cpt + LEFT JOIN rh.t_organismes_cotisation ON t_organismes_cotisation.code_original = w_hp.organisme + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + --AND p_contrats_mois.mois_activite = w_hp.mois + AND base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, w_hp.date_debut, w_hp.date_fin) + GROUP BY 1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24 + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + -- #correction Si un bulletin n'a pas de contrat rattaché. + UPDATE rh.p_historique_paie SET + contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + p_historique_paie.salarie_id, + p_historique_paie.date_paie, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.oid]))[2] as contrat_mois_id + from rh.p_historique_paie + JOIN rh.p_contrats_mois ON p_contrats_mois.salarie_id = p_historique_paie.salarie_id + where p_historique_paie.contrat_mois_id is null + group by 1,2) as subq + WHERE true + AND p_historique_paie.salarie_id = subq.salarie_id + AND p_historique_paie.date_paie = subq.date_paie + ; + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calculer l'écart + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + SELECT + ppu_salarie AS matricule, + ppu_datedebut AS date_debut, + ppu_datefin AS date_fin, + to_char(ppu_datefin,'YYYYMM')::numeric AS mois, + sum(ppu_cbrut)::numeric AS brut, + sum(ppu_cnetimposab)::numeric AS net_imposable, + sum(ppu_cnetapayer)::numeric AS net_a_payer, + sum(ppu_ccoutsalarie)::numeric * -1.0 AS mt_sal, + sum(ppu_ccoutpatron)::numeric AS mt_pat + FROM prod_cegid.paieencours + WHERE 1=1 + AND date_part('year', ppu_datedebut) >= 2009 + GROUP BY 1,2,3,4 + ; + + -- Inserer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie + ( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, -- @deprecated + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie + ) + SELECT + age_id, + contrat_id, + contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + 0 AS montant_avantage_nature, + sum(brut - subq.montant_brut) AS montant_brut, + sum(mt_pat - subq.montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(mt_sal - subq.montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(net_a_payer - subq.montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(net_imposable - subq.montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + 0 as compte_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM + ( + SELECT + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + 0 AS base, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + 0 AS organisme_cotisation_id, + 0 AS profil_id, -- p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + 0 as compte_id, + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8,9, 18,19,20,21,22 + ) AS subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON 1=1 + AND w_totaux.matricule = p_salaries.matricule + AND w_totaux.date_debut = subq.date_debut + AND w_totaux.date_fin = subq.date_fin + GROUP BY 1,2,3,4,5,6,7,8,9, 18,19,20,21,22 + HAVING 1!=1 + OR sum(brut - subq.montant_brut) <> 0 + OR sum(mt_pat - subq.montant_cotisation_patronale) <> 0 + OR sum(mt_sal - subq.montant_cotisation_salarie) <> 0 + OR sum(net_a_payer - subq.montant_net_a_payer_salarie) <> 0 + OR sum(net_imposable - subq.montant_net_imposable_salarie) <> 0 + ; + + /* + + Quels sont les écarts cumulés > 0 ? : + + SELECT + p_salaries.matricule, + p_historique_paie.* + FROM rh.p_historique_paie + JOIN rh.p_salaries on p_salaries.oid = p_historique_paie.salarie_id + JOIN rh.t_rubriques on t_rubriques.oid = p_historique_paie.rubrique_id + WHERE 1=1 + AND t_rubriques.code_original = 'C000' + AND + (1!=1 + OR p_historique_paie.base <> 0 + OR p_historique_paie.montant_brut <> 0 + OR p_historique_paie.montant_cotisation_salarie <> 0 + OR p_historique_paie.montant_cotisation_patronale <> 0 + OR p_historique_paie.montant_net_a_payer_salarie <> 0 + OR p_historique_paie.montant_net_imposable_salarie <> 0 + OR p_historique_paie.montant_avantage_nature <> 0 + ) + ORDER BY 1,4 DESC + ; + + */ + + ]]> + + + + + + 0 FROM rh.t_divers WHERE code = 'IMP_INC_MAR') then pcn_typeconge IN (SELECT trim(unnest(string_to_array(valeur, ','))) FROM rh.t_divers WHERE code = 'IMP_INC_MAR') else true end + and pcn_typeconge NOT IN (SELECT trim(unnest(string_to_array(valeur, ','))) FROM rh.t_divers WHERE code = 'IMP_EXC_MAR') + window w as (partition by pcn_salarie order by pcn_datedebutabs)), + assigned_clustering as ( + select + *, + count(new_cluster) over ( + order by matricule, date_debut + rows unbounded preceding + ) as cluster_id + from clustering) + select + matricule, + motif, + max(mois) AS mois, + min(date_debut) AS date_debut, + max(date_fin) AS date_fin, + sum(nb_jours) AS nb_jours, + sum(nb_heures) AS nb_heures, + max(numero_contrat) AS numero_contrat + from + assigned_clustering + group by matricule,motif, cluster_id + order by matricule, cluster_id + ; + + -- Alimentation des arrêts de travail + TRUNCATE rh.p_arrets_travail + ; + + ALTER SEQUENCE rh.s_arrets_travail RESTART WITH 1 + ; + + INSERT INTO rh.p_arrets_travail( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + date_reprise, + motif_arret_id, + precision_motif_arret_id, + nb_jours, + nb_heures + ) + SELECT p_salaries.oid, + p_contrats.oid, + w_arrets.mois, + w_arrets.date_debut, + w_arrets.date_fin, + (w_arrets.date_fin + INTERVAL '1 day')::date AS date_reprise, + t_motifs_arret.oid AS motif_arret_id, + 0 AS precision_motif_arret_id, + w_arrets.nb_jours, + w_arrets.nb_heures + FROM w_arrets + JOIN rh.p_salaries ON p_salaries.matricule = w_arrets.matricule + JOIN rh.t_motifs_arret ON t_motifs_arret.code_original = w_arrets.motif + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_arrets.numero_contrat + ; + + -- Ventilation mensuelle des arrêts de travail + TRUNCATE rh.p_arrets_travail_mois + ; + + INSERT INTO rh.p_arrets_travail_mois( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + nb_debut_arret, + nb_fin_arret, + nb_reprise_apres_arret, + date_debut, + date_fin, + nb_jours, + nb_heures, + nb_arret + ) + SELECT + p_arrets_travail.oid AS arret_travail_id, + p_arrets_travail.salarie_id AS salarie_id, + p_arrets_travail.contrat_id AS contrat_id, + (max(DISTINCT ARRAY[p_contrats_mois.date_fin - p_contrats_mois.date_debut, p_contrats_mois.oid]))[2] AS contrat_mois_id, -- On ratache l'arrêt au contrat le plus long dans le mois lorsque plusieurs contrat sur la même période. + p_contrats_mois.mois_activite, + CASE WHEN p_arrets_travail.date_debut BETWEEN min(p_contrats_mois.date_debut) AND max(p_contrats_mois.date_fin) THEN 1 ELSE 0 END AS nombre_debut_arret, + CASE WHEN p_arrets_travail.date_fin BETWEEN min(p_contrats_mois.date_debut) AND max(p_contrats_mois.date_fin) THEN 1 ELSE 0 END AS nombre_fin_arret, + 0 AS nb_reprise_apres_arret, + min(GREATEST(p_contrats_mois.date_debut, p_arrets_travail.date_debut)) AS date_debut, + max(LEAST(p_contrats_mois.date_fin, p_arrets_travail.date_fin)) AS date_fin, + max(LEAST(p_contrats_mois.date_fin, p_arrets_travail.date_fin)::date) - min(GREATEST(p_contrats_mois.date_debut, p_arrets_travail.date_debut)::date) + 1 AS nb_jours, + (max(LEAST(p_contrats_mois.date_fin, p_arrets_travail.date_fin)::date) - min(GREATEST(p_contrats_mois.date_debut, p_arrets_travail.date_debut)::date) + 1) + * (base.cti_division(max(p_arrets_travail.nb_heures), max(p_arrets_travail.nb_jours))) as nb_heures, + 1 + FROM rh.p_contrats_mois + JOIN rh.p_arrets_travail ON 1=1 + AND p_contrats_mois.contrat_id = p_arrets_travail.contrat_id + AND p_arrets_travail.date_debut <= p_contrats_mois.date_fin + AND p_arrets_travail.date_fin >= p_contrats_mois.date_debut + GROUP BY 1,2,3,5,p_arrets_travail.date_debut,p_arrets_travail.date_fin,p_arrets_travail.date_reprise + ORDER BY p_contrats_mois.mois_activite desc + ; + + update rh.p_arrets_travail_mois + set nb_reprise_apres_arret = subq.nb_reprise_apres_arret + from ( + select + t1.arret_travail_id, + t1.mois_activite, + min(case when p_arrets_travail.date_reprise between t2.date_debut and t2.date_fin then 0 else 1 end) as nb_reprise_apres_arret + from rh.p_arrets_travail_mois as t1 + join rh.p_arrets_travail ON p_arrets_travail.oid = t1.arret_travail_id + left join rh.p_arrets_travail_mois as t2 ON 1=1 + AND t1.salarie_id = t2.salarie_id + AND t1.date_debut != t2.date_debut + AND t1.date_fin != t2.date_fin + GROUP BY t1.arret_travail_id, t1.mois_activite + order by 2 desc + ) as subq + where 1=1 + and p_arrets_travail_mois.arret_travail_id = subq.arret_travail_id + and p_arrets_travail_mois.mois_activite = subq.mois_activite + ; + + -- Ventilation journalière des arrêts de travail + /* + TRUNCATE rh.p_arrets_travail_jour + ; + + INSERT INTO rh.p_arrets_travail_jour( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + est_debut_arret, + est_arret, + est_fin_arret, + est_reprise, + date + ) + SELECT + p_arrets_travail.oid AS arret_travail_id, + p_arrets_travail.salarie_id AS salarie_id, + p_arrets_travail.contrat_id AS contrat_id, + contrat_mois_id, + p_calendrier.mois, + CASE WHEN p_arrets_travail.date_debut = p_calendrier.date THEN 1 ELSE 0 END AS est_debut_arret, + CASE WHEN p_calendrier.date BETWEEN p_arrets_travail.date_debut AND p_arrets_travail.date_fin THEN 1 ELSE 0 END AS est_arret, + CASE WHEN p_arrets_travail.date_fin = p_calendrier.date THEN 1 ELSE 0 END AS est_fin_arret, + CASE WHEN p_arrets_travail.date_reprise = p_calendrier.date THEN 1 ELSE 0 END AS est_reprise, + p_calendrier.date + FROM rh.p_arrets_travail + JOIN base.p_calendrier ON p_calendrier.date BETWEEN p_arrets_travail.date_debut AND p_arrets_travail.date_reprise + JOIN rh.p_arrets_travail_mois ON 1=1 + AND p_arrets_travail_mois.arret_travail_id = p_arrets_travail.oid + AND p_arrets_travail_mois.mois_activite = p_calendrier.mois + GROUP BY 1,2,3,4,5,6,7,8,9,10 + --ORDER BY 2, p_calendrier.date desc + ; + */ + + ]]> + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_rh_CEGIDHRU.XML b/import_rh/iCTI_import_rh_CEGIDHRU.XML new file mode 100644 index 0000000..82107c4 --- /dev/null +++ b/import_rh/iCTI_import_rh_CEGIDHRU.XML @@ -0,0 +1,1285 @@ + + + + + '' OR i = 1) AND + PRC_array[i] > 0 + ; + + -- Trim des champs text + SELECT base.cti_execute('UPDATE w_ETL010 SET ' || + array_to_string(base.cti_array_accum(trim_set),',') || + ' WHERE ' || + array_to_string(base.cti_array_accum(trim_where),' OR '),1) + FROM + ( + SELECT + column_name||'=trim('||column_name||')' AS trim_set, + column_name||' IS DISTINCT FROM trim('||column_name||')' AS trim_where + FROM information_schema.columns + WHERE table_name = 'w_etl010' AND + data_type = 'text' + GROUP BY 1,2 + ) subview + ; + + + + -- Identification des Entreprises. + DROP TABLE IF EXISTS temp.x_ref_ent + ; + + CREATE TABLE temp.x_ref_ent AS + SELECT + ent_code_original AS code_original, + CODE_ETS AS code, + MAX(ETB_SIRET_NOM) AS texte, + MAX(NUM_SIREN_EMPL::text) AS siren, + null::text AS texte_court + FROM w_ETL016 + GROUP BY 1,2 + ; + + -- Identification des Etablissements. + DROP TABLE IF EXISTS temp.x_ref_ets + ; + + CREATE TABLE temp.x_ref_ets AS + SELECT + ent_code_original, + ety_code_original, + ets_code_original AS code_original, + '1' AS code, + MAX(ETB_SIRET_NUMER::text) AS siret, + MAX(ETB_SIRET_NOM) AS texte, + null::text AS texte_court + FROM w_ETL016 + GROUP BY 1,2,3,4 + ; + + + ]]> + + + '' + GROUP BY 1 + ) + SELECT + IMPUTATION_xx::bigint AS oid, + IMPUTATION_xx AS code_original, + IMPUTATION_xx AS code, + IMPUTATION_xx AS texte, + null::text AS texte_court + FROM ttt + ; + + -- Identification des rubriques de paie. + DROP TABLE IF EXISTS temp.x_ref_rubrique + ; + + CREATE TABLE temp.x_ref_rubrique AS + WITH rub_det_1 AS ( + SELECT + NUMERO_RUB, + MAX(LIB_RUBRIQUE) AS LIB_RUBRIQUE, + ( + NUMERO_RUB BETWEEN 500 AND 9989 OR + NUMERO_RUB BETWEEN 11000 AND 19800 + ) + AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%' AS p_detail, + CASE WHEN SUM(abs(INFO_COMP)) <> 0 THEN true ELSE false END p_nombre, + CASE WHEN SUM(abs(BASE)) <> 0 THEN true ELSE false END p_base, + false AS p_heures_payees, + false AS p_heures_travaillees, + (NUMERO_RUB BETWEEN 500 AND 9989 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%') + OR (SUM(abs(MONTANT_SALAR)) <> 0 OR SUM(abs(MONT_PATRONAL)) <> 0) AS p_masse_salariale, + NUMERO_RUB BETWEEN 500 AND 9989 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%' AS p_brut, + false AS p_avantage_nature, + false AS p_frais_imposables, + NUMERO_RUB BETWEEN 11000 AND 19800 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%' AS p_cotisation_salarie, + NUMERO_RUB BETWEEN 11000 AND 19800 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%' AS p_cotisation_patronale, + false AS p_od_net_salarie, + false AS p_od_net_patronale, + (NUMERO_RUB BETWEEN 500 AND 9989 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%') OR + (NUMERO_RUB BETWEEN 11000 AND 19000 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%') AS p_net_imposable, + 1 AS c_net_imposable, + (NUMERO_RUB BETWEEN 500 AND 9989 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%') OR + (NUMERO_RUB BETWEEN 11000 AND 19800 AND + MAX(LIB_RUBRIQUE) NOT LIKE '*%') AS p_net_a_payer, + 1 AS c_net_a_payer + FROM w_ETL016 + GROUP BY 1 + ), + rub_cum_0 AS ( + SELECT 'C000' AS code, 'Ecart cumulé' AS texte + UNION ALL + SELECT 'C001' AS code, 'Heures payées' AS texte + UNION ALL + SELECT 'C002' AS code, 'Heures travaillées' AS texte + UNION ALL + SELECT 'C003' AS code, 'Net à payer' AS texte + UNION ALL + SELECT 'C004' AS code, 'Net imposable' AS texte + UNION ALL + SELECT 'C005' AS code, 'Avantage en nature' AS texte + UNION ALL + SELECT 'C006' AS code, 'Cotisations patronales' AS texte + UNION ALL + SELECT 'C007' AS code, 'Cotisations salariales' AS texte + UNION ALL + SELECT 'C008' AS code, 'Brut' AS texte + UNION ALL + SELECT 'C009' AS code, 'Heures Cadres Forfaits Jours' AS texte + ) + SELECT + NUMERO_RUB::text AS code_original, + to_char(NUMERO_RUB,'FM00000') AS code, + LIB_RUBRIQUE AS texte, + null::text AS texte_court, + NUMERO_RUB::int AS rang_edition, + false AS p_cumul, + p_detail AS p_detail, + p_nombre AS p_nombre, + 0 AS s_nombre, + 1 AS c_nombre, + p_base AS p_base, + 1 AS s_base, + 1 AS c_base, + false AS p_heures_contrat, + 0 AS s_heures_contrat, + 1 AS c_heures_contrat, + p_heures_payees AS p_heures_payees, + 0 AS s_heures_payees, + 1 AS c_heures_payees, + p_heures_travaillees AS p_heures_travaillees, + 0 AS s_heures_travaillees, + 1 AS c_heures_travaillees, + p_masse_salariale AS p_masse_salariale, + case when p_cotisation_patronale OR p_od_net_patronale then 5 else 3 end AS s_masse_salariale, + case when p_cotisation_patronale then -1 else 1 end AS c_masse_salariale, + p_brut AS p_brut, + 3 AS s_brut, + 1 AS c_brut, + p_avantage_nature AS p_avantage_nature, + 3 AS s_avantage_nature, + 1 AS c_avantage_nature, + p_frais_imposables AS p_frais_imposables, + 3 AS s_frais_imposables, + 1 AS c_frais_imposables, + p_cotisation_salarie AS p_cotisation_salarie, + 3 AS s_cotisation_salarie, + 1 AS c_cotisation_salarie, + p_cotisation_patronale AS p_cotisation_patronale, + 5 AS s_cotisation_patronale, + -1 AS c_cotisation_patronale, + p_od_net_salarie AS p_od_net_salarie, + 3 AS s_od_net_salarie, + 1 AS c_od_net_salarie, + p_od_net_patronale AS p_od_net_patronale, + 5 AS s_od_net_patronale, + 1 AS c_od_net_patronale, + p_net_imposable AS p_net_imposable, + 3 AS s_net_imposable, + c_net_imposable AS c_net_imposable, + p_net_a_payer AS p_net_a_payer, + 3 AS s_net_a_payer, + c_net_a_payer AS c_net_a_payer + FROM rub_det_1 + UNION ALL + SELECT + code AS code_original, + code AS code, + texte AS texte, + null::text AS texte_court, + -1 AS rang_edition, + true AS p_cumul, + false AS p_detail, + false AS p_nombre, + 0 AS s_nombre, + 1 AS c_nombre, + false AS p_base, + 1 AS s_base, + 1 AS c_base, + false AS p_heures_contrat, + 0 AS s_heures_contrat, + 1 AS c_heures_contrat, + false AS p_heures_payees, + 0 AS s_heures_payees, + 1 AS c_heures_payees, + false AS p_heures_travaillees, + 0 AS s_heures_travaillees, + 1 AS c_heures_travaillees, + false AS p_masse_salariale, + 3 AS s_masse_salariale, + -1 AS c_masse_salariale, + false AS p_brut, + 3 AS s_brut, + 1 AS c_brut, + false AS p_avantage_nature, + 3 AS s_avantage_nature, + 1 AS c_avantage_nature, + false AS p_frais_imposables, + 3 AS s_frais_imposables, + 1 AS c_frais_imposables, + false AS p_cotisation_salarie, + 3 AS s_cotisation_salarie, + 1 AS c_cotisation_salarie, + false AS p_cotisation_patronale, + 5 AS s_cotisation_patronale, + -1 AS c_cotisation_patronale, + false AS p_od_net_salarie, + 3 AS s_od_net_salarie, + 1 AS c_od_net_salarie, + false AS p_od_net_patronale, + 5 AS s_od_net_patronale, + 1 AS c_od_net_patronale, + false AS p_net_imposable, + 3 AS s_net_imposable, + 1 AS c_net_imposable, + false AS p_net_a_payer, + 3 AS s_net_a_payer, + 1 AS c_net_a_payer + FROM rub_cum_0 + ; + + ]]> + + + x_hst_bulletin.date_debut + WHERE x_hst_bulletin.cnt_code_original is null + GROUP BY 1 + ) + UPDATE temp.x_hst_bulletin set + cnt_code_original = toto.cnt_code_original, + est_hors_periode = 1 + FROM toto + WHERE x_hst_bulletin.row_id = toto.row_id + ; + + -- ICI : Tous les bulletins doivent avoir un contrat de renseigné. + -- A remonter plus tard dans une table spéciale avant suppression pour controle expert. + DELETE FROM temp.x_hst_bulletin + WHERE cnt_code_original is null + ; + + -- La date min du premier contrat et/ou du premier bulletin détermine le début de la ventilation du salarié. + DROP TABLE IF EXISTS w_lim_sal + ; + + CREATE TEMP TABLE w_lim_sal AS + WITH toto AS ( + SELECT + sal_code_original, + min(date_debut) AS date_debut, + max(case when date_fin = '2099-12-31'::date then base.cti_last_day(current_date) else date_fin end) AS date_fin + FROM temp.x_hst_contrat + GROUP BY 1 + UNION ALL + SELECT + sal_code_original, + min(date_debut) AS date_debut, + max(case when date_fin = '2099-12-31'::date then base.cti_last_day(current_date) else date_fin end) AS date_fin + FROM temp.x_hst_bulletin + GROUP BY 1 + ) + SELECT + sal_code_original, + min(date_debut) AS date_debut, + to_char(min(date_debut), 'YYYYMM')::int AS mois_debut, + max(date_fin) AS date_fin, + to_char(max(date_fin), 'YYYYMM')::int AS mois_fin + FROM toto + GROUP BY 1 + ; + + + -- HISTORIQUE ETP Théorique contrat. + DROP TABLE IF EXISTS temp.x_hst_etp_contrat + ; + + CREATE TABLE temp.x_hst_etp_contrat AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + w_cnt.PRC_TEMP_PAR / 100 AS etp_contrat + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_categorie_socio_professionnelle + ; + + CREATE TABLE temp.x_hst_categorie_socio_professionnelle AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + LOWER(C_EMPLOI_PCSESE) AS categorie_socio_professionnelle_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- HISTORIQUE Motif de début. + DROP TABLE IF EXISTS temp.x_hst_motif_debut_contrat + ; + + CREATE TABLE temp.x_hst_motif_debut_contrat AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + CASE + WHEN w_cnt.MOTIF_EMBAUCHE <> '' THEN 'GCMEB' || w_cnt.MOTIF_EMBAUCHE + WHEN w_cnt.MOTIF_CDD <> '' THEN 'MRCDD' || w_cnt.MOTIF_CDD + ELSE '' END AS motif_debut_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + + + -- HISTORIQUE Motif de fin. + DROP TABLE IF EXISTS temp.x_hst_motif_fin_contrat + ; + + CREATE TABLE temp.x_hst_motif_fin_contrat AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + CASE + WHEN w_cnt.DEPART_CAUSE <> '' THEN 'CCDEP' || w_cnt.DEPART_CAUSE + ELSE '' END AS motif_fin_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + + + -- HISTORIQUE Types de contrat. + DROP TABLE IF EXISTS temp.x_hst_type_contrat + ; + + CREATE TABLE temp.x_hst_type_contrat AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + w_cnt.NATURE_CONTRAT AS type_contrat_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- -- HISTORIQUE CSP. + -- DROP TABLE IF EXISTS temp.x_hst_organisme_cotisation + -- ; + + -- CREATE TABLE temp.x_hst_organisme_cotisation AS + -- SELECT + -- w_cnt.ent_code_original||'-'||w_cnt.ets_code_original AS ety_code_original, + -- w_cnt.sal_code_original, + -- w_cnt.cnt_code_original, + -- greatest(w_cnt.date_debut, w_lim_sal.date_debut) AS date_effet, + -- w_cnt.codinseeemploi2003 AS categorie_socio_professionnelle_code_original + -- FROM w_cnt + -- JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + -- ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_qualification + ; + + CREATE TABLE temp.x_hst_qualification AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + w_cnt.CODE_EMPLOI AS qualification_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_statut + ; + + CREATE TABLE temp.x_hst_statut AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + w_cnt.CATEGORIE AS statut_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_type_temps_travail + ; + + CREATE TABLE temp.x_hst_type_temps_travail AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + w_cnt.MODALITE_TRAV::text||'-'||w_cnt.PRC_TEMP_PAR::text AS type_temps_travail_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_service + ; + + CREATE TABLE temp.x_hst_service AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + w_cnt.CTR_A_02 AS service_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_code_emploi + ; + + CREATE TABLE temp.x_hst_code_emploi AS + SELECT + w_cnt.ety_code_original, + w_cnt.sal_code_original, + w_cnt.cnt_code_original, + GREATEST(w_cnt.DATE_ENTREE, w_lim_sal.date_debut) AS date_effet, + ''::text AS code_emploi_code_original + FROM w_ETL009 w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.sal_code_original + ; + + -- HISTORIQUE GRILLE. + DROP TABLE IF EXISTS temp.x_hst_grille + ; + + CREATE TABLE temp.x_hst_grille AS + SELECT + null::text as ety_code_original, + null::text as sal_code_original, + null::text as cnt_code_original, + null::date as date_effet, + null::text as grille_code_original + limit 0 + ; + + ]]> + + + = 202101 + ) AS suqb + ) + SELECT + bulletins.bul_id, + bulletins.ety_code_original, + bulletins.sal_code_original, + bulletins.cnt_code_original, + bulletins.bul_code_original, + bulletins.date_debut, + bulletins.date_fin, + bulletins.mois_paie AS mois_activite, + bulletins.date_paie, + bulletins.mois_paie, + NUMERO_RUB::text AS rub_code_original, + COALESCE(nullif(BASE, 0), 0)::numeric AS base, + COALESCE(nullif(TAUX_SALAR, 0), 0)::numeric AS txsal, + COALESCE(nullif(MONTANT_SALAR, 0), 0)::numeric AS mntsal, + COALESCE(nullif(TAUX_PATRONAL, 0), 0)::numeric AS txpat, + COALESCE(nullif(MONT_PATRONAL, 0), 0)::numeric AS mntpat + FROM temp.x_hst_bulletin AS bulletins + JOIN temp.x_ref_ets ON x_ref_ets.ety_code_original = bulletins.ety_code_original + JOIN w_ETL016 ON bulletins.bul_code_original = w_ETL016.bul_code_original + WHERE 1=1 + AND bulletins.mois_paie >= 202101 + AND (1!=1 + OR MONTANT_SALAR != 0 + OR MONT_PATRONAL != 0 + OR BASE != 0) + + UNION ALL + + SELECT + bul_id, + ety_code_original, + sal_code_original, + cnt_code_original, + bul_code_original, + date_debut, + date_fin, + mois_paie AS mois_activite, + date_paie, + mois_paie, + rub AS rub_code_original, + case when rub in ('C001', 'C002', 'C009') then val::numeric else 0::numeric end AS base, + 0 AS txsal, + case + when rub in ('C003', 'C004', 'C008') then val::numeric + when rub = 'C007' then -val::numeric + else 0::numeric end AS mnt_sal, + 0 AS txpat, + case when rub = 'C006' then val::numeric else 0::numeric end AS mnt_pat + FROM w_cum + ; + + + ]]> + + + '' THEN w_ETL010.IMPUTATION_XX ELSE '0' END::bigint,0) AS section_analytique_id, + w_ETL010.IMPUTATION_XX AS section_analytique_code_original, + COALESCE(nullif(PRC_XX, 0), 100.0) AS pct + FROM temp.x_hst_bulletin + LEFT JOIN w_ETL010 ON 1=1 + AND x_hst_bulletin.ety_code_original = w_ETL010.ety_code_original + AND x_hst_bulletin.cnt_code_original = w_ETL010.cnt_code_original + ) + , ven AS ( + SELECT + bul_id, + section_analytique_id, + section_analytique_code_original, + base.cti_division(pct, sum(pct) over (partition by bul_id)) AS ratio + FROM base + ) + SELECT + bul_id, + section_analytique_id, + section_analytique_code_original, + sum(ratio) AS ratio + FROM ven + GROUP BY 1,2,3 + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_CEGIDHRU_MELIORIS.XML b/import_rh/iCTI_import_rh_CEGIDHRU_MELIORIS.XML new file mode 100644 index 0000000..e3b65a4 --- /dev/null +++ b/import_rh/iCTI_import_rh_CEGIDHRU_MELIORIS.XML @@ -0,0 +1,1430 @@ + + + + + = rhp('rhprovider_start')::date + GROUP BY 1 + ; + + ]]> + + + + + + = rhp('rhprovider_start')::date + GROUP BY 1,2 + ) + SELECT + nextval('s_bulletins'::regclass) AS bulletin_id, + t_etablissements.entreprise_id, + t_etablissements.oid AS etablissement_id, + 'BULLETIN' || '-' || matricule || '-' || mois AS numero_bulletin, + date_debut, + date_fin, + mois, + matricule, + total_brut, + total_heures_payees, + total_heures_travaillees, + 0::int AS affectation_contrat_mois_id, + 0::int AS est_hors_periode_contrat + FROM gestion_multi_bulletins + JOIN rh.t_etablissements ON t_etablissements.code_original::numeric = right(gestion_multi_bulletins.code_etablissement, 4) + WHERE t_etablissements.oid != 0 + ) + ; + + ]]> + + + = 151.67 then 'TC' else 'TP' end||round(contrats.nombres_heures_contractuelles::numeric, 2)::text, chr(1)||'*') AS type_temps_travail, + coalesce(nullif(contrats.nombres_heures_contractuelles::numeric / 151.67, 0), 1.0) AS etp_theorique, + 0::int AS est_hors_periode, + dernier_bulletin_salaries.date_fin_dernier_bulletin + FROM contrats + JOIN w_sal_ets ON w_sal_ets.matricule = contrats.matricule -- Limiter la remontée des contrats aux seuls salariés ayant un bulletin + JOIN dernier_bulletin_salaries ON dernier_bulletin_salaries.matricule = contrats.matricule + ORDER BY contrats.date_debut_contrat::date + ) + ; + + ]]> + + + = w_contrats.date_debut_contrat + AND w_bulletins.date_fin <= w_contrats.date_fin_contrat + ; + + -- Si etablissement_id restant à 0, on renseigne le dernier id connu dans les contrats + UPDATE w_contrats + SET + etablissement_id = subview.etablissement_id, + entreprise_id = subview.entreprise_id + FROM + ( + SELECT + matricule, + (MAX(array[w_contrats.date_fin_contrat::text, w_contrats.etablissement_id::text]))[2]::int AS etablissement_id, + (MAX(array[w_contrats.date_fin_contrat::text, w_contrats.entreprise_id::text]))[2]::int AS entreprise_id + FROM w_contrats + WHERE etablissement_id <> 0 + GROUP BY 1 + ) AS subview + WHERE + w_contrats.etablissement_id = 0 + AND w_contrats.matricule = subview.matricule + ; + + -- Si etablissement_id restant à 0, on renseigne l'établissement le plus récent + UPDATE w_contrats + SET + etablissement_id = subview.etablissement_id, + entreprise_id = subview.entreprise_id + FROM + ( + SELECT + matricule, + (MAX(array[w_bulletins.date_fin::text, w_bulletins.etablissement_id::text]))[2]::int AS etablissement_id, + (MAX(array[w_bulletins.date_fin::text, w_bulletins.entreprise_id::text]))[2]::int AS entreprise_id + FROM w_bulletins + GROUP BY 1 + ) AS subview + WHERE + w_contrats.etablissement_id = 0 + AND w_contrats.matricule = subview.matricule + ; + + ANALYZE w_contrats + ; + + -- Mise à jours des bulletins hors période de contrat + UPDATE w_bulletins + SET est_hors_periode_contrat = 1 + FROM + ( + SELECT + w_bulletins.matricule, + w_bulletins.bulletin_id + FROM w_bulletins + LEFT JOIN w_contrats ON + w_contrats.matricule = w_bulletins.matricule + AND base.cti_overlaps(w_contrats.date_debut_contrat, w_contrats.date_fin_contrat, w_bulletins.date_debut, w_bulletins.date_fin) + WHERE w_contrats.contrat_id IS NULL + ) AS subview + WHERE + w_bulletins.matricule = subview.matricule + AND w_bulletins.bulletin_id = subview.bulletin_id + ; + + ANALYZE w_bulletins + ; + + ]]> + + + = (rhp('rhprovider_start')::date - interval '2 YEAR') + ) + ; + + ]]> + + + = positp.date_debut::date + ) + ; + + -- Récupération pour chaque contrat_mois des informations les plus récentes du salarié + DROP TABLE IF EXISTS dernieres_infos_contrat_mois + ; + + CREATE TEMP TABLE dernieres_infos_contrat_mois AS + with dernieres_infos_par_contrat_mois AS ( + SELECT + w_contrats_mois.contrat_mois_id, + (MAX(ARRAY[EXTRACT(EPOCH FROM w_infos_positp.date_debut), w_infos_positp.id]))[2] AS dernier_infos_positp_id + FROM w_contrats_mois + LEFT JOIN w_infos_positp ON w_infos_positp.contrat_mois_id = w_contrats_mois.contrat_mois_id + GROUP BY 1 + ) + SELECT + w_contrats_mois.contrat_mois_id, + w_infos_positp.qualification_code, + w_infos_positp.qualification_texte, + w_infos_positp.statut_code, + w_infos_positp.statut_texte + FROM w_contrats_mois + LEFT JOIN dernieres_infos_par_contrat_mois ON dernieres_infos_par_contrat_mois.contrat_mois_id = w_contrats_mois.contrat_mois_id + LEFT JOIN w_infos_positp ON w_infos_positp.contrat_mois_id = w_contrats_mois.contrat_mois_id + AND w_infos_positp.id = dernieres_infos_par_contrat_mois.dernier_infos_positp_id + ; + + -- Mise à jour des éléments de positp et sadmin sur les contrats_mois + UPDATE w_contrats_mois + SET + qualification_code = COALESCE(dernieres_infos_contrat_mois.qualification_code, chr(1)||'*'), + qualification_texte = COALESCE(dernieres_infos_contrat_mois.qualification_texte, chr(1)||'*'), + statut_code = COALESCE(dernieres_infos_contrat_mois.statut_code, chr(1)||'*'), + statut_texte = COALESCE(dernieres_infos_contrat_mois.statut_texte, chr(1)||'*') + FROM dernieres_infos_contrat_mois + WHERE dernieres_infos_contrat_mois.contrat_mois_id = w_contrats_mois.contrat_mois_id + ; + + ANALYZE w_contrats_mois + ; + + ]]> + + + + + + + + + + + + + + + + + + + + base.cti_first_day(w_contrats_mois.date_debut_contrat_mois) then 0 else 1 end AS present_debut_mois, + case when w_contrats_mois.date_fin_contrat < base.cti_last_day(w_contrats_mois.date_debut_contrat_mois) then 0 else 1 end AS present_fin_mois, + w_contrats_mois.etp_theorique AS equivalent_temps_plein, + w_contrats_mois.date_fin_contrat_mois - coalesce(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + w_contrats_mois.etablissement_id + FROM rh.p_contrats + JOIN w_contrats_mois on w_contrats_mois.contrat_id = p_contrats.oid + JOIN rh.p_salaries on p_salaries.oid = w_contrats_mois.salarie_id + ; + + ]]> + + + chr(1)||'*' + AND categorie_socio_professionnelle_code NOT IN (SELECT code_original FROM rh.t_categories_socio_professionnelle WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des motifs de début de contrat. + INSERT INTO rh.t_motifs_debut_contrat(code_original, code, texte, texte_court) + SELECT + code_motif_debut_contrat, + code_motif_debut_contrat, + libelle_motif_debut_contrat, + substr(libelle_motif_debut_contrat,1,50) + FROM prod_cegidhru_melioris.contrat + WHERE code_motif_debut_contrat NOT IN (SELECT code_original FROM rh.t_motifs_debut_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ORDER BY 2 + ; + + -- Màj des motifs de fin de contrat. + INSERT INTO rh.t_motifs_fin_contrat(code_original, code, texte, texte_court) + SELECT + code_motif_fin_contrat, + code_motif_fin_contrat, + libelle_motif_fin_contrat, + substr(libelle_motif_fin_contrat,1,50) + FROM prod_cegidhru_melioris.contrat + WHERE code_motif_fin_contrat NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ORDER BY 2 + ; + + -- Màj des nationalités. + INSERT INTO rh.t_nationalites(code, code_original, texte, texte_court) + SELECT + code_nationalite, + code_nationalite, + libelle_nationalite, + substr(libelle_nationalite,1,50) + FROM prod_cegidhru_melioris.etat_civil + WHERE code_nationalite NOT IN (SELECT code_original FROM rh.t_nationalites WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des qualifications + INSERT INTO rh.t_qualifications(code_original, code, texte, texte_court) + SELECT qualification_code, qualification_code, max(qualification_texte), substr(max(qualification_texte), 1, 50) + FROM w_contrats_mois + WHERE + qualification_code <> chr(1)||'*' + AND qualification_code NOT IN (SELECT code_original FROM rh.t_qualifications WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + -- Màj des rubriques + INSERT INTO rh.t_rubriques(code_original, code, texte, texte_court) + SELECT + code_rubrique, + code_rubrique, + libelle_rubrique, + substr(libelle_rubrique, 1, 50) + FROM prod_cegidhru_melioris.rubrique + WHERE code_rubrique NOT IN (SELECT code_original FROM rh.t_rubriques WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des situations de famille + INSERT INTO rh.t_situations_famille(code_original, code, texte, texte_court) + SELECT + code_situation_familiale, + code_situation_familiale, + libelle_situation_familiale, + substr(libelle_situation_familiale, 1, 50) + FROM prod_cegidhru_melioris.etat_civil + WHERE code_situation_familiale NOT IN (SELECT code_original FROM rh.t_situations_famille WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code_original, code, texte, texte_court) + SELECT type_contrat_code, type_contrat_code, type_contrat_texte, substr(type_contrat_texte, 1, 50) + FROM w_contrats_mois + WHERE + type_contrat_code <> chr(1)||'*' + AND type_contrat_code NOT IN (SELECT code_original FROM rh.t_types_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + SELECT statut_code, statut_code, statut_texte, substr(statut_texte, 1, 50) + FROM w_contrats_mois + WHERE + statut_code <> chr(1)||'*' + AND statut_code NOT IN (SELECT code_original FROM rh.t_statuts WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + SELECT + CASE WHEN heures_theoriques >= 151.67 THEN 'TC' ELSE 'TP' END||ROUND(heures_theoriques::numeric, 2)::text, + CASE WHEN heures_theoriques >= 151.67 THEN 'TC' ELSE 'TP' END||ROUND(heures_theoriques::numeric, 2)::text, + CASE WHEN heures_theoriques >= 151.67 THEN 'Temps Complet ' ELSE 'Temps Partiel ' end||round(heures_theoriques::numeric, 2)::text, + CASE WHEN heures_theoriques >= 151.67 THEN 'TC ' ELSE 'TP ' END||ROUND(heures_theoriques::numeric, 2)::text + FROM w_contrats_mois + WHERE CASE WHEN heures_theoriques >= 151.67 THEN 'TC' ELSE 'TP' END||ROUND(heures_theoriques::numeric, 2)::text NOT IN (SELECT code_original FROM rh.t_types_temps_travail WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + SELECT service_code, service_code, max(service_texte), max(substr(service_texte, 1, 50)) + FROM w_contrats_mois + WHERE + service_code <> chr(1)||'*' + AND service_code NOT IN (SELECT code_original FROM rh.t_services WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + ]]> + + + = rhp('rhprovider_start')::date + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_CONSOLIDATION.XML b/import_rh/iCTI_import_rh_CONSOLIDATION.XML new file mode 100644 index 0000000..d70891e --- /dev/null +++ b/import_rh/iCTI_import_rh_CONSOLIDATION.XML @@ -0,0 +1,2972 @@ + + + + + + + + + 0 THEN service_id + [IPX] ELSE 0 END AS service_id, + CASE WHEN service_id <> 0 THEN (service_id + [IPX])::text ELSE '' END AS service_code_original, + CASE WHEN service_id <> 0 THEN '[CPX]' || service_code ELSE '' END AS service_code, + service_texte, + COALESCE(c_specialites.to_oid,0) AS specialite_id, + COALESCE(c_specialites.to_oid::text,'') AS specialite_code_original, + COALESCE(c_specialites.to_code,'') AS specialite_code, + COALESCE(c_specialites.to_texte,'') AS specialite_texte, + COALESCE(c_types_temps_travail.to_oid, 0) AS type_temps_travail_id, + COALESCE(c_types_temps_travail.to_oid::text, '') AS type_temps_travail_code_original, + COALESCE(c_types_temps_travail.to_code, '') AS type_temps_travail_code, + COALESCE(c_types_temps_travail.to_texte, '') AS type_temps_travail_texte, + COALESCE(c_categories_socio_professionnelle.to_oid,0) AS categorie_socio_professionnelle_id, + COALESCE(c_categories_socio_professionnelle.to_oid::text,'') AS categorie_socio_professionnelle_code_original, + COALESCE(c_categories_socio_professionnelle.to_code,'') AS categorie_socio_professionnelle_code, + COALESCE(c_categories_socio_professionnelle.to_texte,'') AS categorie_socio_professionnelle_texte, + COALESCE(c_statuts.to_oid, 0) AS statut_id, + COALESCE(c_statuts.to_oid::text, '') AS statut_code_original, + COALESCE(c_statuts.to_code, '') AS statut_code, + COALESCE(c_statuts.to_texte, '') AS statut_texte, + COALESCE(c_codes_emploi.to_oid,0) AS code_emploi_id, + COALESCE(c_codes_emploi.to_oid::text,'') AS code_emploi_code_original, + COALESCE(c_codes_emploi.to_code,'') AS code_emploi_code, + COALESCE(c_codes_emploi.to_texte,'') AS code_emploi_texte, + 0 AS societe_interim_id, + '' AS societe_interim_code_original, + '' AS societe_interim_code, + '' AS societe_interim_texte, + COALESCE(c_sections_analytiques_paie.to_oid,0) AS section_analytique_paie_id, + COALESCE(c_sections_analytiques_paie.to_oid::text,'') AS section_analytique_paie_code_original, + COALESCE(c_sections_analytiques_paie.to_code,'') AS section_analytique_paie_code, + COALESCE(c_sections_analytiques_paie.to_texte,'') AS section_analytique_paie_texte, + COALESCE(c_sections_analytiques.to_oid,0) AS section_analytique_id, + COALESCE(c_sections_analytiques.to_oid::text,'') AS section_analytique_code_original, + COALESCE(c_sections_analytiques.to_code,'') AS section_analytique_code, + COALESCE(c_sections_analytiques.to_texte,'') AS section_analytique_texte, + COALESCE(c_grilles.to_oid,0) AS grille_id, + COALESCE(c_grilles.to_oid::text,'') AS grille_code_original, + COALESCE(c_grilles.to_code,'') AS grille_code, + COALESCE(c_grilles.to_texte,'') AS grille_texte, + COALESCE(c_grilles_groupes.to_oid,0) AS grille_groupe_id, + COALESCE(c_grilles_groupes.to_oid::text,'') AS grille_groupe_code_original, + COALESCE(c_grilles_groupes.to_code,'') AS grille_groupe_code, + COALESCE(c_grilles_groupes.to_texte,'') AS grille_groupe_texte, + COALESCE(c_types_horaire.to_oid,0) AS type_horaire_id, + COALESCE(c_types_horaire.to_oid::text,'') AS type_horaire_code_original, + COALESCE(c_types_horaire.to_code,'') AS type_horaire_code, + COALESCE(c_types_horaire.to_texte,'') AS type_horaire_texte, + 0 AS groupe_cotisant_id, + '' AS groupe_cotisant_code_original, + '' AS groupe_cotisant_code, + '' AS groupe_cotisant_texte, + COALESCE(c_cadre_emploi.to_oid,0) AS cadre_emploi_id, + COALESCE(c_cadre_emploi.to_oid::text,'') AS cadre_emploi_code_original, + COALESCE(c_cadre_emploi.to_code,'') AS cadre_emploi_code, + COALESCE(c_cadre_emploi.to_texte,'') AS cadre_emploi_texte + FROM p_profils + LEFT JOIN c_types_contrat ON p_profils.type_contrat_id = c_types_contrat.oid + LEFT JOIN c_motifs_debut_contrat ON p_profils.motif_debut_id = c_motifs_debut_contrat.oid + LEFT JOIN c_motifs_fin_contrat ON p_profils.motif_fin_id = c_motifs_fin_contrat.oid + LEFT JOIN c_qualifications ON p_profils.qualification_id = c_qualifications.oid + LEFT JOIN c_specialites ON p_profils.specialite_id = c_specialites.oid + LEFT JOIN c_codes_emploi ON p_profils.code_emploi_id = c_codes_emploi.oid + LEFT JOIN c_categories_socio_professionnelle ON p_profils.categorie_socio_professionnelle_id = c_categories_socio_professionnelle.oid + LEFT JOIN c_types_horaire ON p_profils.type_horaire_id = c_types_horaire.oid + LEFT JOIN c_types_temps_travail ON p_profils.type_temps_travail_id = c_types_temps_travail.oid + LEFT JOIN c_statuts ON p_profils.statut_id = c_statuts.oid + LEFT JOIN c_sections_analytiques ON p_profils.section_analytique_id = c_sections_analytiques.oid + LEFT JOIN c_sections_analytiques_paie ON p_profils.section_analytique_paie_id = c_sections_analytiques_paie.oid + LEFT JOIN c_cadre_emploi ON p_profils.cadre_emploi_id = c_cadre_emploi.oid + LEFT JOIN c_grilles ON p_profils.grille_id = c_grilles.oid + LEFT JOIN c_grilles_groupes ON p_profils.grille_groupe_id = c_grilles_groupes.oid + ; + + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.p_salaries + ', 'temp p_salaries' + ); + + INSERT INTO rh.p_salaries( + oid, + code, + nom, + prenom, + date_naissance, + sexe, + matricule, + code_original, + nir, + entreprise_id, + nationalite_id, + code_postal_id, + nom_naissance, + situation_famille_id, + adresse1, + adresse2, + profil_id, + date_debut, + date_fin, + finess, + date_entree_ets, + date_sortie_ets, + date_entree_fp, + date_entree_fph, + no_adeli, + code_cotisation_id, + matricule_retraite, + salarie_fusionne_id, + -- personne_id, + date_anciennete) + SELECT + p_salaries.oid + [IPX] AS oid, + p_salaries.code, + p_salaries.nom, + p_salaries.prenom, + p_salaries.date_naissance, + p_salaries.sexe, + p_salaries.matricule || CASE WHEN [IPX] <> 0 THEN ' ([PX])' ELSE '' END AS matricule, + p_salaries.oid + [IPX] AS code_original, + p_salaries.nir, + CASE WHEN p_salaries.entreprise_id <> 0 THEN p_salaries.entreprise_id + [IPX] ELSE 0 END AS entreprise_id, + COALESCE(c_nationalites.to_oid, 0) AS nationalite_id, + COALESCE(t_codes_postaux.oid, 0) AS code_postal_id, + p_salaries.nom_naissance, + COALESCE(c_situations_famille.to_oid, 0) AS situation_famille_id, + p_salaries.adresse1, + p_salaries.adresse2, + CASE WHEN p_salaries.profil_id <> 0 THEN p_salaries.profil_id + [IPX] ELSE 0 END AS profil_id, + p_salaries.date_debut, + p_salaries.date_fin, + p_salaries.finess, + p_salaries.date_entree_ets, + p_salaries.date_sortie_ets, + p_salaries.date_entree_fp, + p_salaries.date_entree_fph, + p_salaries.no_adeli, + --p_salaries.code_cotisation_id + [IPX] AS code_cotisation_id, + 0 as code_cotisation_id, + p_salaries.matricule_retraite, + p_salaries.salarie_fusionne_id + [IPX] AS salarie_fusionne_id, + -- p_salaries.personne_id + [IPX], + p_salaries.date_anciennete + FROM p_salaries + LEFT JOIN c_nationalites ON p_salaries.nationalite_id = c_nationalites.oid + LEFT JOIN c_situations_famille ON p_salaries.situation_famille_id = c_situations_famille.oid + LEFT JOIN base.t_codes_postaux ON p_salaries.code_postal_id = t_codes_postaux.oid + LEFT JOIN rh.p_salaries AS rh_sal ON rh_sal.oid = p_salaries.oid + [IPX] + WHERE rh_sal.oid IS NULL + ; + + ]]> + + + 0 THEN ' ([PX])' ELSE '' END AS numero_contrat, + CASE WHEN etablissement_id <> 0 THEN etablissement_id + [IPX] ELSE 0 END AS etablissement_id, + p_contrats.oid + [IPX] AS code_original, + CASE WHEN profil_id <> 0 THEN profil_id + [IPX] ELSE 0 END AS profil_id, + anciennete_anterieure_mois, + anciennete_anterieure_calculee_mois, + CASE WHEN salarie_remplace_id <> 0 THEN salarie_remplace_id + [IPX] ELSE 0 END AS salarie_remplace_id, + anciennete_anterieure_jours, + anciennete_anterieure_calculee_jours + FROM p_contrats + ; + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.p_contrats_mois + ', 'temp p_contrats_mois' + ); + + INSERT INTO rh.p_contrats_mois ( + oid, + salarie_id, + contrat_id, + mois_activite, + profil_id, + nombre_debut_contrat, + nombre_fin_contrat, + equivalent_temps_plein, + date_debut, + date_fin, + age_id, + age_jours, + est_hors_periode, + present_fin_mois, + anciennete_mois, + anciennete_annee_id, + nombre_departs, + anciennete_grade_mois, + anciennete_grade_annee_id, + anciennete_fp_mois, + anciennete_fp_annee_id, + anciennete_fph_mois, + anciennete_fph_annee_id, + fictif, + nombre_entrees, + present_debut_mois, + anciennete_jours, + etablissement_id, + nombre_heures) + SELECT + p_contrats_mois.oid + [IPX] AS oid, + CASE WHEN p_contrats_mois.salarie_id <> 0 THEN p_contrats_mois.salarie_id + [IPX] ELSE 0 END AS salarie_id, + contrat_id + [IPX] AS contrat_id, + mois_activite, + CASE WHEN profil_id <> 0 THEN profil_id + [IPX] ELSE 0 END AS profil_id, + nombre_debut_contrat, + nombre_fin_contrat, + equivalent_temps_plein, + date_debut, + date_fin, + age_id, + age_jours, + est_hors_periode, + present_fin_mois, + anciennete_mois, + anciennete_annee_id, + nombre_departs, + anciennete_grade_mois, + anciennete_grade_annee_id, + anciennete_fp_mois, + anciennete_fp_annee_id, + anciennete_fph_mois, + anciennete_fph_annee_id, + fictif, + nombre_entrees, + present_debut_mois, + anciennete_jours, + CASE WHEN etablissement_id <> 0 THEN etablissement_id + [IPX] ELSE 0 END AS etablissement_id, + nombre_heures + FROM p_contrats_mois + ; + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.p_profil_contrat_mois + ', 'temp p_profil_contrat_mois') + ; + + INSERT INTO rh.p_profil_contrat_mois ( + -- profil_avant_transformation_id, + oid, + profil_id, + contrat_mois_id, + ratio, + mois, + salarie_id) + SELECT + -- profil_avant_transformation_id, + oid + [IPX], + CASE WHEN profil_id <> 0 THEN profil_id + [IPX] ELSE 0 END AS profil_id, + CASE WHEN contrat_mois_id <> 0 THEN contrat_mois_id + [IPX] ELSE 0 END AS contrat_mois_id, + ratio, + mois, + CASE WHEN salarie_id <> 0 THEN salarie_id + [IPX] ELSE 0 END AS salarie_id + FROM p_profil_contrat_mois + ; + + ]]> + + + 0 THEN etablissement_id + [IPX] ELSE 0 END AS etablissement_id, + contrat_id + [IPX] AS contrat_id, + age_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + COALESCE(c_rubriques.to_oid,0) AS rubrique_id, + COALESCE(c_compte.to_oid,0) AS compte_id, + 0 AS organisme_cotisation_id, + base, + montant_brut, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + salarie_id + [IPX] AS salarie_id, + contrat_mois_id + [IPX] AS contrat_mois_id, + CASE WHEN profil_id <> 0 THEN profil_id + [IPX] ELSE 0 END AS profil_id, + montant_avantage_nature, + montant_frais_imposables, + montant_od_net_salarie, + montant_od_net_patronale, + -- ventilation_1_id, + -- ventilation_2_id, + -- ventilation_3_id, + nombre, + montant_masse_salariale, + montant_salarial, + montant_patronal, + heure_contrat, + heure_payee, + heure_travaillee + FROM p_historique_paie + LEFT JOIN c_rubriques ON p_historique_paie.rubrique_id = c_rubriques.oid + LEFT JOIN c_compte ON p_historique_paie.compte_id = c_compte.oid + ; + + ]]> + + + + + + + + + + + + + + + + 0 AND oid + [IPX] NOT IN (SELECT oid FROM rh.t_entreprises); + + UPDATE rh.t_entreprises SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_entreprises SET code_original = oid WHERE code_original <> oid::text; + + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_etablissements + WHERE oid IN (SELECT etablissement_id FROM rh.p_contrats) + ', 'temp t_etablissements' + ); + + + INSERT INTO rh.t_etablissements( + oid, + code_original, + code, + texte, + texte_court, + entreprise_id, + base_calcul_etp) + SELECT + oid + [IPX], + oid + [IPX] AS code_original, + '[CPX]' || code, + texte, + texte_court, + CASE WHEN entreprise_id <> 0 THEN entreprise_id + [IPX] ELSE 0 END, + base_calcul_etp + FROM t_etablissements + WHERE oid <> 0 AND oid + [IPX] NOT IN (SELECT oid FROM rh.t_etablissements); + + UPDATE rh.t_etablissements SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_etablissements SET code_original = oid WHERE code_original <> oid::text; + + -- rubriques + + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_rubriques + WHERE oid <> 0 + ', 'temp t_rubriques' + ); + + + DROP TABLE IF EXISTS c_rubriques; + CREATE TEMP TABLE c_rubriques AS + SELECT + *, + lower(texte) AS texte_adapte, + ''::text AS texte_soundex, + ''::text AS to_code, + 0::bigint AS to_oid + FROM t_rubriques; + + UPDATE c_rubriques SET texte_adapte = replace(texte_adapte, 'apprenti', 'app'); + UPDATE c_rubriques SET texte_adapte = replace(texte_adapte, 'absence', 'abs'); + UPDATE c_rubriques SET texte_adapte = replace(texte_adapte, 'vieillesse', 'vieil'); + UPDATE c_rubriques SET texte_adapte = replace(texte_adapte, 'provisions', 'prov'); + UPDATE c_rubriques SET texte_adapte = replace(texte_adapte, 'intéressement', 'int'); + UPDATE c_rubriques SET texte_adapte = replace(texte_adapte, 'défiscalisées', 'défisc'); + UPDATE c_rubriques SET texte_adapte = replace(texte_adapte, 'salaire', 'sal'); + + UPDATE c_rubriques SET texte_soundex = base.cti_soundex_nom(texte_adapte); + + + DROP TABLE IF EXISTS w_rubriques_to; + CREATE TEMP TABLE w_rubriques_to AS + SELECT + *, + lower(texte) AS texte_adapte, + ''::text AS texte_soundex + FROM rh.t_rubriques + WHERE + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0' OR + t_rubriques.code IN ('C000') AND oid <= 999999999 + ; + + UPDATE w_rubriques_to SET texte_adapte = replace(texte_adapte, 'apprenti', 'app'); + UPDATE w_rubriques_to SET texte_adapte = replace(texte_adapte, 'absence', 'abs'); + UPDATE w_rubriques_to SET texte_adapte = replace(texte_adapte, 'vieillesse', 'vieil'); + UPDATE w_rubriques_to SET texte_adapte = replace(texte_adapte, 'provisions', 'prov'); + UPDATE w_rubriques_to SET texte_adapte = replace(texte_adapte, 'intéressement', 'int'); + UPDATE w_rubriques_to SET texte_adapte = replace(texte_adapte, 'défiscalisées', 'défisc'); + UPDATE w_rubriques_to SET texte_adapte = replace(texte_adapte, 'salaire', 'sal'); + + UPDATE w_rubriques_to SET texte_soundex = base.cti_soundex_nom(texte_adapte); + + UPDATE c_rubriques + SET to_oid = oid + [IPX], + to_code = CASE WHEN (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0' THEN code ELSE '[CPX]' || code END + WHERE code NOT IN (SELECT code FROM w_rubriques_to) + ; + + + UPDATE c_rubriques + SET to_oid = w_rubriques_to.oid, + to_code = c_rubriques.code + FROM w_rubriques_to + WHERE to_oid = 0 AND + c_rubriques.code = w_rubriques_to.code AND + (c_rubriques.texte_soundex = w_rubriques_to.texte_soundex OR c_rubriques.code = 'C000'); + + + UPDATE c_rubriques + SET to_oid = oid + [IPX], + to_code = code || '_[PX]' + WHERE to_oid = 0; + + ALTER TABLE c_rubriques ADD CONSTRAINT c_rubriques_pkey PRIMARY KEY(oid); + + UPDATE rh.t_rubriques SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_rubriques SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_rubriques( + oid, + code_original, + code, + texte, + texte_court, + rang_edition, + chapitre_bulletin, + heures_payees, + code_calcul, + unite, + coefficient) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court, + rang_edition, + chapitre_bulletin, + heures_payees, + code_calcul, + unite, + coefficient + FROM c_rubriques + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_rubriques); + + UPDATE rh.t_rubriques SET + code = c_rubriques.to_code, + code_original = c_rubriques.to_oid, + texte = c_rubriques.texte, + texte_court = c_rubriques.texte_court + FROM c_rubriques + WHERE t_rubriques.oid = c_rubriques.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_rubriques.code IS DISTINCT FROM c_rubriques.to_code OR + t_rubriques.code_original IS DISTINCT FROM c_rubriques.to_oid OR + t_rubriques.texte IS DISTINCT FROM c_rubriques.texte OR + t_rubriques.texte_court IS DISTINCT FROM c_rubriques.texte_court + ) + ; + + -- comptes + + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_compte + WHERE oid <> 0 + ', 'temp t_compte' + ); + + + + INSERT INTO rh.t_compte( + code_original, + code, + texte, + texte_court) + SELECT + code_original, + code, + texte, + texte_court + FROM t_compte + WHERE oid <> 0 AND + code NOT IN (SELECT code FROM rh.t_compte WHERE code IS NOT NULL) AND + code_original NOT IN (SELECT code_original FROM rh.t_compte WHERE code IS NOT NULL); + + + + INSERT INTO rh.t_compte(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_compte); + + + DROP TABLE IF EXISTS c_compte; + CREATE TEMP TABLE c_compte AS + SELECT + t_compte.oid, + MIN(t_compte_conso.oid) AS to_oid + FROM t_compte + JOIN rh.t_compte t_compte_conso ON t_compte_conso.code = t_compte.code + GROUP BY 1; + + + ALTER TABLE c_compte ADD CONSTRAINT c_compte_pkey PRIMARY KEY(oid); + + + -- Catégories socio professionnelles + + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_categories_socio_professionnelle + WHERE oid <> 0 + ', 'temp t_categories_socio_professionnelle' + ); + + + DROP TABLE IF EXISTS c_categories_socio_professionnelle; + CREATE TEMP TABLE c_categories_socio_professionnelle AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_categories_socio_professionnelle; + + + DROP TABLE IF EXISTS w_categories_socio_professionnelle_to; + CREATE TEMP TABLE w_categories_socio_professionnelle_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_categories_socio_professionnelle + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + + UPDATE c_categories_socio_professionnelle + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_categories_socio_professionnelle_to); + + + UPDATE c_categories_socio_professionnelle + SET to_oid = w_categories_socio_professionnelle_to.oid, + to_code = c_categories_socio_professionnelle.code, + to_texte = c_categories_socio_professionnelle.texte + FROM w_categories_socio_professionnelle_to + WHERE to_oid = 0 AND + c_categories_socio_professionnelle.code = w_categories_socio_professionnelle_to.code AND + c_categories_socio_professionnelle.texte_soundex = w_categories_socio_professionnelle_to.texte_soundex; + + + UPDATE c_categories_socio_professionnelle + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' ; + + UPDATE rh.t_categories_socio_professionnelle SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_categories_socio_professionnelle SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_categories_socio_professionnelle( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_categories_socio_professionnelle + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_categories_socio_professionnelle); + + UPDATE rh.t_categories_socio_professionnelle SET + code = c_categories_socio_professionnelle.to_code, + code_original = c_categories_socio_professionnelle.to_oid, + texte = c_categories_socio_professionnelle.texte, + texte_court = c_categories_socio_professionnelle.texte_court + FROM c_categories_socio_professionnelle + WHERE t_categories_socio_professionnelle.oid = c_categories_socio_professionnelle.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_categories_socio_professionnelle.code = c_categories_socio_professionnelle.to_code OR + t_categories_socio_professionnelle.code_original = c_categories_socio_professionnelle.to_oid OR + t_categories_socio_professionnelle.texte = c_categories_socio_professionnelle.texte OR + t_categories_socio_professionnelle.texte_court = c_categories_socio_professionnelle.texte_court + ) + ; + + -- codes_emploi + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_codes_emploi + WHERE oid <> 0 + ', 'temp t_codes_emploi' + ); + + + DROP TABLE IF EXISTS c_codes_emploi; + CREATE TEMP TABLE c_codes_emploi AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_codes_emploi; + + + DROP TABLE IF EXISTS w_codes_emploi_to; + CREATE TEMP TABLE w_codes_emploi_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_codes_emploi + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + + UPDATE c_codes_emploi + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_codes_emploi_to); + + + UPDATE c_codes_emploi + SET to_oid = w_codes_emploi_to.oid, + to_code = w_codes_emploi_to.code, + to_texte = w_codes_emploi_to.texte + FROM w_codes_emploi_to + WHERE to_oid = 0 AND + c_codes_emploi.code = w_codes_emploi_to.code AND + c_codes_emploi.texte_soundex = w_codes_emploi_to.texte_soundex; + + UPDATE c_codes_emploi + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_codes_emploi ADD CONSTRAINT c_codes_emploi_pkey PRIMARY KEY(oid); + + UPDATE rh.t_codes_emploi SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_codes_emploi SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_codes_emploi( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_codes_emploi + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_codes_emploi); + + UPDATE rh.t_codes_emploi SET + code = c_codes_emploi.to_code, + code_original = c_codes_emploi.to_oid, + texte = c_codes_emploi.texte, + texte_court = c_codes_emploi.texte_court + FROM c_codes_emploi + WHERE t_codes_emploi.oid = c_codes_emploi.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_codes_emploi.code = c_codes_emploi.to_code OR + t_codes_emploi.code_original = c_codes_emploi.to_oid OR + t_codes_emploi.texte = c_codes_emploi.texte OR + t_codes_emploi.texte_court = c_codes_emploi.texte_court + ) + ; + + -- cadre_emploi + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_cadre_emploi + WHERE oid <> 0 + ', 'temp t_cadre_emploi' + ); + + + DROP TABLE IF EXISTS c_cadre_emploi; + CREATE TEMP TABLE c_cadre_emploi AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_cadre_emploi; + + + DROP TABLE IF EXISTS w_cadre_emploi_to; + CREATE TEMP TABLE w_cadre_emploi_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_cadre_emploi + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + + UPDATE c_cadre_emploi + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_cadre_emploi_to); + + + UPDATE c_cadre_emploi + SET to_oid = w_cadre_emploi_to.oid, + to_code = w_cadre_emploi_to.code, + to_texte = w_cadre_emploi_to.texte + FROM w_cadre_emploi_to + WHERE to_oid = 0 AND + c_cadre_emploi.code = w_cadre_emploi_to.code AND + c_cadre_emploi.texte_soundex = w_cadre_emploi_to.texte_soundex; + + UPDATE c_cadre_emploi + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_cadre_emploi ADD CONSTRAINT c_cadre_emploi_pkey PRIMARY KEY(oid); + + UPDATE rh.t_cadre_emploi SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_cadre_emploi SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_cadre_emploi( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_cadre_emploi + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_cadre_emploi); + + UPDATE rh.t_cadre_emploi SET + code = c_cadre_emploi.to_code, + code_original = c_cadre_emploi.to_oid, + texte = c_cadre_emploi.texte, + texte_court = c_cadre_emploi.texte_court + FROM c_cadre_emploi + WHERE t_cadre_emploi.oid = c_cadre_emploi.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_cadre_emploi.code = c_cadre_emploi.to_code OR + t_cadre_emploi.code_original = c_cadre_emploi.to_oid OR + t_cadre_emploi.texte = c_cadre_emploi.texte OR + t_cadre_emploi.texte_court = c_cadre_emploi.texte_court + ) + ; + + + + + -- motifs_arret + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_motifs_arret + WHERE oid <> 0 + ', 'temp t_motifs_arret' + ); + + DROP TABLE IF EXISTS c_motifs_arret; + CREATE TEMP TABLE c_motifs_arret AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + 0::bigint AS to_oid + FROM t_motifs_arret; + + DROP TABLE IF EXISTS w_motifs_arret_to; + CREATE TEMP TABLE w_motifs_arret_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_motifs_arret + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_motifs_arret + SET to_oid = oid + [IPX], + to_code = code + WHERE code NOT IN (SELECT code FROM w_motifs_arret_to); + + UPDATE c_motifs_arret + SET to_oid = w_motifs_arret_to.oid, + to_code = c_motifs_arret.code + FROM w_motifs_arret_to + WHERE to_oid = 0 AND + c_motifs_arret.code = w_motifs_arret_to.code AND + c_motifs_arret.texte_soundex = w_motifs_arret_to.texte_soundex; + + UPDATE c_motifs_arret + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + UPDATE rh.t_motifs_arret SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_motifs_arret SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_motifs_arret( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_motifs_arret + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_motifs_arret); + + UPDATE rh.t_motifs_arret SET + code = c_motifs_arret.to_code, + code_original = c_motifs_arret.to_oid, + texte = c_motifs_arret.texte, + texte_court = c_motifs_arret.texte_court + FROM c_motifs_arret + WHERE t_motifs_arret.oid = c_motifs_arret.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_motifs_arret.code = c_motifs_arret.to_code OR + t_motifs_arret.code_original = c_motifs_arret.to_oid OR + t_motifs_arret.texte = c_motifs_arret.texte OR + t_motifs_arret.texte_court = c_motifs_arret.texte_court + ) + ; + + -- motifs_debut_contrat + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_motifs_debut_contrat + WHERE oid <> 0 + ', 'temp t_motifs_debut_contrat' + ); + + DROP TABLE IF EXISTS c_motifs_debut_contrat; + CREATE TEMP TABLE c_motifs_debut_contrat AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_motifs_debut_contrat; + + DROP TABLE IF EXISTS w_motifs_debut_contrat_to; + CREATE TEMP TABLE w_motifs_debut_contrat_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_motifs_debut_contrat + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_motifs_debut_contrat + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_motifs_debut_contrat_to); + + UPDATE c_motifs_debut_contrat + SET to_oid = w_motifs_debut_contrat_to.oid, + to_code = c_motifs_debut_contrat.code, + to_texte = c_motifs_debut_contrat.texte + FROM w_motifs_debut_contrat_to + WHERE to_oid = 0 AND + c_motifs_debut_contrat.code = w_motifs_debut_contrat_to.code AND + c_motifs_debut_contrat.texte_soundex = w_motifs_debut_contrat_to.texte_soundex; + + UPDATE c_motifs_debut_contrat + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + UPDATE rh.t_motifs_debut_contrat SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_motifs_debut_contrat SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_motifs_debut_contrat( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_motifs_debut_contrat + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_motifs_debut_contrat); + + UPDATE rh.t_motifs_debut_contrat SET + code = c_motifs_debut_contrat.to_code, + code_original = c_motifs_debut_contrat.to_oid, + texte = c_motifs_debut_contrat.texte, + texte_court = c_motifs_debut_contrat.texte_court + FROM c_motifs_debut_contrat + WHERE t_motifs_debut_contrat.oid = c_motifs_debut_contrat.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_motifs_debut_contrat.code = c_motifs_debut_contrat.to_code OR + t_motifs_debut_contrat.code_original = c_motifs_debut_contrat.to_oid OR + t_motifs_debut_contrat.texte = c_motifs_debut_contrat.texte OR + t_motifs_debut_contrat.texte_court = c_motifs_debut_contrat.texte_court + ) + ; + + -- motifs_fin_contrat + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_motifs_fin_contrat + WHERE oid <> 0 + ', 'temp t_motifs_fin_contrat' + ); + + DROP TABLE IF EXISTS c_motifs_fin_contrat; + CREATE TEMP TABLE c_motifs_fin_contrat AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_motifs_fin_contrat; + + DROP TABLE IF EXISTS w_motifs_fin_contrat_to; + CREATE TEMP TABLE w_motifs_fin_contrat_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_motifs_fin_contrat + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_motifs_fin_contrat + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_motifs_fin_contrat_to); + + UPDATE c_motifs_fin_contrat + SET to_oid = w_motifs_fin_contrat_to.oid, + to_code = c_motifs_fin_contrat.code, + to_texte = c_motifs_fin_contrat.texte + FROM w_motifs_fin_contrat_to + WHERE to_oid = 0 AND + c_motifs_fin_contrat.code = w_motifs_fin_contrat_to.code AND + c_motifs_fin_contrat.texte_soundex = w_motifs_fin_contrat_to.texte_soundex; + + UPDATE c_motifs_fin_contrat + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + UPDATE rh.t_motifs_fin_contrat SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_motifs_fin_contrat SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_motifs_fin_contrat( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_motifs_fin_contrat + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_motifs_fin_contrat); + + UPDATE rh.t_motifs_fin_contrat SET + code = c_motifs_fin_contrat.to_code, + code_original = c_motifs_fin_contrat.to_oid, + texte = c_motifs_fin_contrat.texte, + texte_court = c_motifs_fin_contrat.texte_court + FROM c_motifs_fin_contrat + WHERE t_motifs_fin_contrat.oid = c_motifs_fin_contrat.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_motifs_fin_contrat.code = c_motifs_fin_contrat.to_code OR + t_motifs_fin_contrat.code_original = c_motifs_fin_contrat.to_oid OR + t_motifs_fin_contrat.texte = c_motifs_fin_contrat.texte OR + t_motifs_fin_contrat.texte_court = c_motifs_fin_contrat.texte_court + ) + ; + + + -- nationalites + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_nationalites + WHERE oid <> 0 + ', 'temp t_nationalites' + ); + + DROP TABLE IF EXISTS c_nationalites; + CREATE TEMP TABLE c_nationalites AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + 0::bigint AS to_oid + FROM t_nationalites; + + DROP TABLE IF EXISTS w_nationalites_to; + CREATE TEMP TABLE w_nationalites_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_nationalites + ; + + UPDATE c_nationalites + SET to_oid = oid + [IPX], + to_code = code + WHERE code NOT IN (SELECT code FROM w_nationalites_to); + + UPDATE c_nationalites + SET to_oid = w_nationalites_to.oid, + to_code = c_nationalites.code + FROM w_nationalites_to + WHERE to_oid = 0 AND + c_nationalites.code = w_nationalites_to.code AND + c_nationalites.texte_soundex = w_nationalites_to.texte_soundex; + + UPDATE c_nationalites + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code + WHERE to_oid = 0; + + ALTER TABLE c_nationalites ADD CONSTRAINT c_nationalites_pkey PRIMARY KEY(oid); + + UPDATE rh.t_nationalites SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_nationalites SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_nationalites( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_nationalites + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_nationalites); + + -- qualifications + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_qualifications + WHERE oid <> 0 + ', 'temp t_qualifications' + ); + + DROP TABLE IF EXISTS c_qualifications; + CREATE TEMP TABLE c_qualifications AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_qualifications; + + DROP TABLE IF EXISTS w_qualifications_to; + CREATE TEMP TABLE w_qualifications_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_qualifications + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_qualifications + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte_court + WHERE code NOT IN (SELECT code FROM w_qualifications_to); + + UPDATE c_qualifications + SET to_oid = w_qualifications_to.oid, + to_code = w_qualifications_to.code, + to_texte = w_qualifications_to.texte_court + FROM w_qualifications_to + WHERE to_oid = 0 AND + c_qualifications.code = w_qualifications_to.code AND + c_qualifications.texte_soundex = w_qualifications_to.texte_soundex; + + UPDATE c_qualifications + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_qualifications ADD CONSTRAINT c_qualifications_pkey PRIMARY KEY(oid); + + UPDATE rh.t_qualifications SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_qualifications SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_qualifications( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_qualifications + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_qualifications); + + UPDATE rh.t_qualifications SET + code = c_qualifications.to_code, + code_original = c_qualifications.to_oid, + texte = c_qualifications.texte, + texte_court = c_qualifications.texte_court + FROM c_qualifications + WHERE t_qualifications.oid = c_qualifications.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_qualifications.code = c_qualifications.to_code OR + t_qualifications.code_original = c_qualifications.to_oid OR + t_qualifications.texte = c_qualifications.texte OR + t_qualifications.texte_court = c_qualifications.texte_court + ) + ; + + + + + -- sections_analytiques + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_sections_analytiques + WHERE oid <> 0 + ', 'temp t_sections_analytiques' + ); + + DROP TABLE IF EXISTS c_sections_analytiques; + CREATE TEMP TABLE c_sections_analytiques AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_sections_analytiques; + + DROP TABLE IF EXISTS w_sections_analytiques_to; + CREATE TEMP TABLE w_sections_analytiques_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_sections_analytiques + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_sections_analytiques + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte_court + WHERE code NOT IN (SELECT code FROM w_sections_analytiques_to); + + UPDATE c_sections_analytiques + SET to_oid = w_sections_analytiques_to.oid, + to_code = w_sections_analytiques_to.code, + to_texte = w_sections_analytiques_to.texte_court + FROM w_sections_analytiques_to + WHERE to_oid = 0 AND + c_sections_analytiques.code = w_sections_analytiques_to.code AND + c_sections_analytiques.texte_soundex = w_sections_analytiques_to.texte_soundex; + + + UPDATE c_sections_analytiques + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_sections_analytiques ADD CONSTRAINT c_sections_analytiques_pkey PRIMARY KEY(oid); + + UPDATE rh.t_sections_analytiques SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_sections_analytiques SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_sections_analytiques( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_sections_analytiques + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_sections_analytiques); + + UPDATE rh.t_sections_analytiques SET + code = c_sections_analytiques.to_code, + code_original = c_sections_analytiques.to_oid, + texte = c_sections_analytiques.texte, + texte_court = c_sections_analytiques.texte_court + FROM c_sections_analytiques + WHERE t_sections_analytiques.oid = c_sections_analytiques.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_sections_analytiques.code = c_sections_analytiques.to_code OR + t_sections_analytiques.code_original = c_sections_analytiques.to_oid OR + t_sections_analytiques.texte = c_sections_analytiques.texte OR + t_sections_analytiques.texte_court = c_sections_analytiques.texte_court + ) + ; + + -- sections_analytiques paie + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_sections_analytiques_paie + WHERE oid <> 0 + ', 'temp t_sections_analytiques_paie' + ); + + DROP TABLE IF EXISTS c_sections_analytiques_paie; + CREATE TEMP TABLE c_sections_analytiques_paie AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_sections_analytiques_paie; + + DROP TABLE IF EXISTS w_sections_analytiques_paie_to; + CREATE TEMP TABLE w_sections_analytiques_paie_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_sections_analytiques_paie + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_sections_analytiques_paie + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte_court + WHERE code NOT IN (SELECT code FROM w_sections_analytiques_paie_to); + + UPDATE c_sections_analytiques_paie + SET to_oid = w_sections_analytiques_paie_to.oid, + to_code = w_sections_analytiques_paie_to.code, + to_texte = w_sections_analytiques_paie_to.texte_court + FROM w_sections_analytiques_paie_to + WHERE to_oid = 0 AND + c_sections_analytiques_paie.code = w_sections_analytiques_paie_to.code AND + c_sections_analytiques_paie.texte_soundex = w_sections_analytiques_paie_to.texte_soundex; + + + UPDATE c_sections_analytiques_paie + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_sections_analytiques_paie ADD CONSTRAINT c_sections_analytiques_paie_pkey PRIMARY KEY(oid); + + UPDATE rh.t_sections_analytiques_paie SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_sections_analytiques_paie SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_sections_analytiques_paie( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_sections_analytiques_paie + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_sections_analytiques_paie); + + UPDATE rh.t_sections_analytiques_paie SET + code = c_sections_analytiques_paie.to_code, + code_original = c_sections_analytiques_paie.to_oid, + texte = c_sections_analytiques_paie.texte, + texte_court = c_sections_analytiques_paie.texte_court + FROM c_sections_analytiques_paie + WHERE t_sections_analytiques_paie.oid = c_sections_analytiques_paie.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_sections_analytiques_paie.code = c_sections_analytiques_paie.to_code OR + t_sections_analytiques_paie.code_original = c_sections_analytiques_paie.to_oid OR + t_sections_analytiques_paie.texte = c_sections_analytiques_paie.texte OR + t_sections_analytiques_paie.texte_court = c_sections_analytiques_paie.texte_court + ) + ; + + + + -- services + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_services + WHERE oid <> 0 + ', 'temp t_services' + ); + + DROP TABLE IF EXISTS c_services; + CREATE TEMP TABLE c_services AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_services; + + DROP TABLE IF EXISTS w_services_to; + CREATE TEMP TABLE w_services_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_services + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_services + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte_court + WHERE code NOT IN (SELECT code FROM w_services_to); + + UPDATE c_services + SET to_oid = w_services_to.oid, + to_code = w_services_to.code, + to_texte = w_services_to.texte_court + FROM w_services_to + WHERE to_oid = 0 AND + c_services.code = w_services_to.code AND + c_services.texte_soundex = w_services_to.texte_soundex; + + UPDATE c_services + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_services ADD CONSTRAINT c_services_pkey PRIMARY KEY(oid); + + UPDATE rh.t_services SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_services SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_services( + oid, + code_original, + code, + texte, + texte_court) + SELECT + oid + [IPX] AS to_oid, + oid + [IPX] AS code_original, + '[CPX]' || code AS code, + texte, + texte_court + FROM t_services + WHERE oid <> 0 AND oid + [IPX] NOT IN (SELECT oid FROM rh.t_services); + + UPDATE rh.t_services SET + code = c_services.to_code, + code_original = c_services.to_oid, + texte = c_services.texte, + texte_court = c_services.texte_court + FROM c_services + WHERE t_services.oid = c_services.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_services.code = c_services.to_code OR + t_services.code_original = c_services.to_oid OR + t_services.texte = c_services.texte OR + t_services.texte_court = c_services.texte_court + ) + ; + + + + + -- situations_famille + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_situations_famille + WHERE oid <> 0 + ', 'temp t_situations_famille' + ); + + DROP TABLE IF EXISTS c_situations_famille; + CREATE TEMP TABLE c_situations_famille AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + 0::bigint AS to_oid + FROM t_situations_famille; + + DROP TABLE IF EXISTS w_situations_famille_to; + CREATE TEMP TABLE w_situations_famille_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_situations_famille; + + UPDATE c_situations_famille + SET to_oid = oid + [IPX], + to_code = code + WHERE code NOT IN (SELECT code FROM w_situations_famille_to); + + UPDATE c_situations_famille + SET to_oid = w_situations_famille_to.oid, + to_code = c_situations_famille.code + FROM w_situations_famille_to + WHERE to_oid = 0 AND + c_situations_famille.code = w_situations_famille_to.code AND + c_situations_famille.texte_soundex = w_situations_famille_to.texte_soundex; + + UPDATE c_situations_famille + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code + WHERE to_oid = 0; + + ALTER TABLE c_situations_famille ADD CONSTRAINT c_situations_famille_pkey PRIMARY KEY(oid); + + UPDATE rh.t_situations_famille SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_situations_famille SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_situations_famille( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_situations_famille + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_situations_famille); + + + -- specialites + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_specialites + WHERE oid <> 0 + ', 'temp t_specialites' + ); + + DROP TABLE IF EXISTS c_specialites; + CREATE TEMP TABLE c_specialites AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_specialites; + + DROP TABLE IF EXISTS w_specialites_to; + CREATE TEMP TABLE w_specialites_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_specialites + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_specialites + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte_court + WHERE code NOT IN (SELECT code FROM w_specialites_to); + + UPDATE c_specialites + SET to_oid = w_specialites_to.oid, + to_code = w_specialites_to.code, + to_texte = w_specialites_to.texte + FROM w_specialites_to + WHERE to_oid = 0 AND + c_specialites.code = w_specialites_to.code AND + c_specialites.texte_soundex = w_specialites_to.texte_soundex; + + UPDATE c_specialites + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_specialites ADD CONSTRAINT c_specialites_pkey PRIMARY KEY(oid); + + UPDATE rh.t_specialites SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_specialites SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_specialites( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_specialites + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_specialites); + + UPDATE rh.t_specialites SET + code = c_specialites.to_code, + code_original = c_specialites.to_oid, + texte = c_specialites.texte, + texte_court = c_specialites.texte_court + FROM c_specialites + WHERE t_specialites.oid = c_specialites.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_specialites.code = c_specialites.to_code OR + t_specialites.code_original = c_specialites.to_oid OR + t_specialites.texte = c_specialites.texte OR + t_specialites.texte_court = c_specialites.texte_court + ) + ; + + -- types_contrat + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_types_contrat + WHERE oid <> 0 + ', 'temp t_types_contrat' + ); + + DROP TABLE IF EXISTS c_types_contrat; + CREATE TEMP TABLE c_types_contrat AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_types_contrat; + + DROP TABLE IF EXISTS w_types_contrat_to; + CREATE TEMP TABLE w_types_contrat_to AS + SELECT + *, + base.cti_soundex_nom(texte) AS texte_soundex + FROM rh.t_types_contrat + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + UPDATE c_types_contrat + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte_court + WHERE code NOT IN (SELECT code FROM w_types_contrat_to); + + UPDATE c_types_contrat + SET to_oid = w_types_contrat_to.oid, + to_code = w_types_contrat_to.code, + to_texte = w_types_contrat_to.texte_court + FROM w_types_contrat_to + WHERE to_oid = 0 AND + c_types_contrat.code = w_types_contrat_to.code AND + c_types_contrat.texte_soundex = w_types_contrat_to.texte_soundex; + + UPDATE c_types_contrat + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_types_contrat ADD CONSTRAINT c_types_contrat_pkey PRIMARY KEY(oid); + + UPDATE rh.t_types_contrat SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_types_contrat SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_types_contrat( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_types_contrat + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_types_contrat); + + UPDATE rh.t_types_contrat SET + code = c_types_contrat.to_code, + code_original = c_types_contrat.to_oid, + texte = c_types_contrat.texte, + texte_court = c_types_contrat.texte_court + FROM c_types_contrat + WHERE t_types_contrat.oid = c_types_contrat.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_types_contrat.code = c_types_contrat.to_code OR + t_types_contrat.code_original = c_types_contrat.to_oid OR + t_types_contrat.texte = c_types_contrat.texte OR + t_types_contrat.texte_court = c_types_contrat.texte_court + ) + ; + + + -- Types de temps de travail. + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_types_temps_travail + WHERE oid != 0 + ', 'temp t_types_temps_travail') + ; + + DROP TABLE IF EXISTS c_types_temps_travail + ; + CREATE TEMP TABLE c_types_temps_travail AS + SELECT + *, + code AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_types_temps_travail + ; + + DROP TABLE IF EXISTS w_types_temps_travail_to + ; + CREATE TEMP TABLE w_types_temps_travail_to AS + SELECT + *, + code AS texte_soundex + FROM rh.t_types_temps_travail + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0' + ; + + UPDATE c_types_temps_travail SET + to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_types_temps_travail_to) + ; + + UPDATE c_types_temps_travail SET + to_oid = w_types_temps_travail_to.oid, + to_code = w_types_temps_travail_to.code, + to_texte = w_types_temps_travail_to.texte + FROM w_types_temps_travail_to + WHERE 1=1 + AND to_oid = 0 + AND c_types_temps_travail.code = w_types_temps_travail_to.code + AND c_types_temps_travail.texte_soundex = w_types_temps_travail_to.texte_soundex + ; + + UPDATE c_types_temps_travail SET + to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' + ; + + ALTER TABLE c_types_temps_travail ADD CONSTRAINT c_types_temps_travail_pkey PRIMARY KEY(oid) + ; + + UPDATE rh.t_types_temps_travail SET + code_original = '#'||oid + WHERE code_original != oid::text + ; + UPDATE rh.t_types_temps_travail SET + code_original = oid + WHERE code_original != oid::text + ; + + INSERT INTO rh.t_types_temps_travail( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_types_temps_travail + WHERE 1=1 + AND oid != 0 + AND to_oid NOT IN (SELECT oid FROM rh.t_types_temps_travail) + ; + + UPDATE rh.t_types_temps_travail SET + code = c_types_temps_travail.to_code, + code_original = c_types_temps_travail.to_oid, + texte = c_types_temps_travail.texte, + texte_court = c_types_temps_travail.texte_court + FROM c_types_temps_travail + WHERE t_types_temps_travail.oid = c_types_temps_travail.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_types_temps_travail.code = c_types_temps_travail.to_code OR + t_types_temps_travail.code_original = c_types_temps_travail.to_oid OR + t_types_temps_travail.texte = c_types_temps_travail.texte OR + t_types_temps_travail.texte_court = c_types_temps_travail.texte_court + ) + ; + + -- types_horaire + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_types_horaire + WHERE oid <> 0 + ', 'temp t_types_horaire' + ); + + + DROP TABLE IF EXISTS c_types_horaire; + CREATE TEMP TABLE c_types_horaire AS + SELECT + *, + code AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_types_horaire; + + + DROP TABLE IF EXISTS w_types_horaire_to; + CREATE TEMP TABLE w_types_horaire_to AS + SELECT + *, + code AS texte_soundex + FROM rh.t_types_horaire + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + + UPDATE c_types_horaire + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_types_horaire_to); + + + UPDATE c_types_horaire + SET to_oid = w_types_horaire_to.oid, + to_code = w_types_horaire_to.code, + to_texte = w_types_horaire_to.texte + FROM w_types_horaire_to + WHERE to_oid = 0 AND + c_types_horaire.code = w_types_horaire_to.code AND + c_types_horaire.texte_soundex = w_types_horaire_to.texte_soundex; + + UPDATE c_types_horaire + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_types_horaire ADD CONSTRAINT c_types_horaire_pkey PRIMARY KEY(oid); + + UPDATE rh.t_types_horaire SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_types_horaire SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_types_horaire( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_types_horaire + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_types_horaire); + + UPDATE rh.t_types_horaire SET + code = c_types_horaire.to_code, + code_original = c_types_horaire.to_oid, + texte = c_types_horaire.texte, + texte_court = c_types_horaire.texte_court + FROM c_types_horaire + WHERE t_types_horaire.oid = c_types_horaire.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_types_horaire.code = c_types_horaire.to_code OR + t_types_horaire.code_original = c_types_horaire.to_oid OR + t_types_horaire.texte = c_types_horaire.texte OR + t_types_horaire.texte_court = c_types_horaire.texte_court + ) + ; + + -- Grilles + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_grilles + WHERE oid <> 0 + ', 'temp t_grilles' + ); + + + DROP TABLE IF EXISTS c_grilles; + CREATE TEMP TABLE c_grilles AS + SELECT + *, + code AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_grilles; + + + DROP TABLE IF EXISTS w_grilles_to; + CREATE TEMP TABLE w_grilles_to AS + SELECT + *, + code AS texte_soundex + FROM rh.t_grilles + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + + UPDATE c_grilles + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_grilles_to); + + + UPDATE c_grilles + SET to_oid = w_grilles_to.oid, + to_code = w_grilles_to.code, + to_texte = w_grilles_to.texte + FROM w_grilles_to + WHERE to_oid = 0 AND + c_grilles.code = w_grilles_to.code AND + c_grilles.texte_soundex = w_grilles_to.texte_soundex; + + UPDATE c_grilles + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_grilles ADD CONSTRAINT c_grilles_pkey PRIMARY KEY(oid); + + UPDATE rh.t_grilles SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_grilles SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_grilles( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_grilles + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_grilles); + + UPDATE rh.t_grilles SET + code = c_grilles.to_code, + code_original = c_grilles.to_oid, + texte = c_grilles.texte, + texte_court = c_grilles.texte_court + FROM c_grilles + WHERE t_grilles.oid = c_grilles.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_grilles.code = c_grilles.to_code OR + t_grilles.code_original = c_grilles.to_oid OR + t_grilles.texte = c_grilles.texte OR + t_grilles.texte_court = c_grilles.texte_court + ) + ; + + -- Groupes de grille. + + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_grilles_groupes + WHERE oid <> 0 + ', 'temp t_grilles_groupes' + ); + + + DROP TABLE IF EXISTS c_grilles_groupes; + CREATE TEMP TABLE c_grilles_groupes AS + SELECT + *, + code AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_grilles_groupes; + + + DROP TABLE IF EXISTS w_grilles_groupes_to; + CREATE TEMP TABLE w_grilles_groupes_to AS + SELECT + *, + code AS texte_soundex + FROM rh.t_grilles_groupes + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0'; + + + UPDATE c_grilles_groupes + SET to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_grilles_groupes_to); + + + UPDATE c_grilles_groupes + SET to_oid = w_grilles_groupes_to.oid, + to_code = w_grilles_groupes_to.code, + to_texte = w_grilles_groupes_to.texte + FROM w_grilles_groupes_to + WHERE to_oid = 0 AND + c_grilles_groupes.code = w_grilles_groupes_to.code AND + c_grilles_groupes.texte_soundex = w_grilles_groupes_to.texte_soundex; + + UPDATE c_grilles_groupes + SET to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0'; + + ALTER TABLE c_grilles_groupes ADD CONSTRAINT c_grilles_groupes_pkey PRIMARY KEY(oid); + + UPDATE rh.t_grilles_groupes SET code_original = '#'||oid WHERE code_original <> oid::text; + UPDATE rh.t_grilles_groupes SET code_original = oid WHERE code_original <> oid::text; + + INSERT INTO rh.t_grilles_groupes( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_grilles_groupes + WHERE oid <> 0 AND to_oid NOT IN (SELECT oid FROM rh.t_grilles_groupes); + + UPDATE rh.t_grilles_groupes SET + code = c_grilles_groupes.to_code, + code_original = c_grilles_groupes.to_oid, + texte = c_grilles_groupes.texte, + texte_court = c_grilles_groupes.texte_court + FROM c_grilles_groupes + WHERE t_grilles_groupes.oid = c_grilles_groupes.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_grilles_groupes.code = c_grilles_groupes.to_code OR + t_grilles_groupes.code_original = c_grilles_groupes.to_oid OR + t_grilles_groupes.texte = c_grilles_groupes.texte OR + t_grilles_groupes.texte_court = c_grilles_groupes.texte_court + ) + ; + + -- Statuts + SELECT base.cti_copy_table('dbname=[DBNAME] host=[DBHOST] port=[DBPORT] user=[DBUSERNAME] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_statuts + WHERE oid != 0 + ', 'temp t_statuts') + ; + + DROP TABLE IF EXISTS c_statuts + ; + CREATE TEMP TABLE c_statuts AS + SELECT + *, + code AS texte_soundex, + ''::text AS to_code, + ''::text AS to_texte, + 0::bigint AS to_oid + FROM t_statuts + ; + + DROP TABLE IF EXISTS w_statuts_to + ; + CREATE TEMP TABLE w_statuts_to AS + SELECT + *, + code AS texte_soundex + FROM rh.t_statuts + WHERE (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') IS DISTINCT FROM '0' + ; + + UPDATE c_statuts SET + to_oid = oid + [IPX], + to_code = code, + to_texte = texte + WHERE code NOT IN (SELECT code FROM w_statuts_to) + ; + + UPDATE c_statuts SET + to_oid = w_statuts_to.oid, + to_code = w_statuts_to.code, + to_texte = w_statuts_to.texte + FROM w_statuts_to + WHERE 1=1 + AND to_oid = 0 + AND c_statuts.code = w_statuts_to.code + AND c_statuts.texte_soundex = w_statuts_to.texte_soundex + ; + + UPDATE c_statuts SET + to_oid = oid + [IPX], + to_code = '[CPX]' || code, + to_texte = texte_court + WHERE to_oid = 0 OR + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' + ; + + ALTER TABLE c_statuts ADD CONSTRAINT c_statuts_pkey PRIMARY KEY(oid) + ; + + UPDATE rh.t_statuts SET + code_original = '#'||oid + WHERE code_original != oid::text + ; + UPDATE rh.t_statuts SET + code_original = oid + WHERE code_original != oid::text + ; + + INSERT INTO rh.t_statuts( + oid, + code_original, + code, + texte, + texte_court) + SELECT + to_oid, + to_oid AS code_original, + to_code, + texte, + texte_court + FROM c_statuts + WHERE 1=1 + AND oid != 0 + AND to_oid NOT IN (SELECT oid FROM rh.t_statuts) + ; + + UPDATE rh.t_statuts SET + code = c_statuts.to_code, + code_original = c_statuts.to_oid, + texte = c_statuts.texte, + texte_court = c_statuts.texte_court + FROM c_statuts + WHERE t_statuts.oid = c_statuts.to_oid AND + (SELECT valeur FROM rh.t_divers WHERE t_divers.code = 'CONSO_FUSIONPARAM') = '0' AND + ( + t_statuts.code = c_statuts.to_code OR + t_statuts.code_original = c_statuts.to_oid OR + t_statuts.texte = c_statuts.texte OR + t_statuts.texte_court = c_statuts.texte_court + ) + ; + + ]]> + + + + + + + + + + 1 + ); + + -- Les contrats 'unique' sur tous les sites sont remis avec le numero initial + UPDATE rh.p_contrats + SET numero_contrat = trim(split_part(numero_contrat,'(',1)) + WHERE trim(split_part(numero_contrat,'(',1)) + NOT IN ( + SELECT + trim(split_part(numero_contrat,'(',1)) + FROM rh.p_contrats + GROUP BY 1 + HAVING count(*) > 1 + ); + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_rh_EIG.XML b/import_rh/iCTI_import_rh_EIG.XML new file mode 100644 index 0000000..13c8e19 --- /dev/null +++ b/import_rh/iCTI_import_rh_EIG.XML @@ -0,0 +1,2024 @@ + + + + + + + + + + + sum(case when bl_histo_rub IN ('SALBASE', '51_PAY_METIER') then montant_sal else 0 end) as prendre_minconv + from w_hst_hp + group by 1,2,3,4,5,6,7,8 + ; + + -- Suppression des rubriques 51_MAINTIEN de septembre 2017 à septembre 2018 inclu (suite à qualif. RH-Paie avec Mme SALMON). + DELETE FROM w_hst_hp + WHERE 1=1 + AND bl_histo_rub = '51_MAINTIEN' + AND mois_paie between 201709 and 201809 + ; + + -- Suppression des rubriques SALBASE et 51_PAY_METIER lorsque le coefficient de la grille est <= 337 (suite à qualif. RH-Paie avec Mme SALMON). + -- DROP TABLE IF EXISTS w_grille_eig + -- ; + + -- CREATE TEMP TABLE w_grille_eig AS + -- SELECT grialias, grilibelle, griid, 0::numeric as griparentid, gricoef -- Correction de la racine qui pointe sur elle-même et bloque la requête récursive qui suit. + -- FROM prod_eig.sgrheig_grilles_convention + -- where griid = 1 + -- union + -- SELECT grialias, grilibelle, griid, griparentid, gricoef + -- FROM prod_eig.sgrheig_grilles_convention + -- where griid > 1 + -- ; + + -- DROP TABLE IF EXISTS w_grille_eig_coeff + -- ; + + -- CREATE TEMP TABLE w_grille_eig_coeff AS + -- with RECURSIVE search_graph as ( + -- SELECT grialias, grilibelle, griid, griparentid, gricoef + -- FROM w_grille_eig + -- where griid = 1 + -- UNION ALL + -- SELECT o.grialias, o.grilibelle, o.griid, o.griparentid, coalesce(nullif(o.gricoef, 0), search_graph.gricoef) as gricoef -- si le coefficient n'est pas renseigné on prend celui du parent. + -- FROM w_grille_eig as o + -- JOIN search_graph ON search_graph.griid = o.griparentid) + -- select * from search_graph + -- ; + + -- DELETE FROM w_hst_hp + -- USING prod_eig.sgrheig_contrats, w_grille_eig_coeff + -- WHERE 1=1 + -- AND sgrheig_contrats.ctrid = w_hst_hp.bl_histo_ctrid + -- AND w_grille_eig_coeff.grialias::int = sgrheig_contrats.v_grialias::int + -- AND bl_histo_rub IN ('SALBASE', '51_PAY_METIER') + -- AND gricoef::int <= 337 + -- ; + + -- WITH w_grille_eig_coeff as ( + -- select cti_bul + -- from w_hst_bul + -- where coeff <= 328 + -- ) + -- DELETE FROM w_hst_hp + -- USING w_grille_eig_coeff + -- WHERE 1=1 + -- AND w_hst_hp.cti_bul = w_grille_eig_coeff.cti_bul + -- AND bl_histo_rub IN ('SALBASE', '51_PAY_METIER') + -- ; + + WITH w_minconv as ( + select cti_bul + from w_hst_bul + where prendre_minconv + ) + DELETE FROM w_hst_hp + USING w_minconv + WHERE 1=1 + AND w_hst_hp.cti_bul = w_minconv.cti_bul + AND bl_histo_rub IN ('SALBASE', '51_PAY_METIER') + ; + + INSERT INTO rh.p_chiffrier_production(entreprise_id, etablissement_id, mois, nombre_salaries, montant_brut, nombre_heures) + SELECT + entreprise_id, + t_etablissements.oid, + to_char(date_debut, 'YYYYMM')::numeric, + count(DISTINCT bl_histo_perid), + sum(CASE WHEN p_brut and p_cumul THEN (CASE s_brut + WHEN 0 THEN to_number(coalesce(nullif(trim(nombre::text), ''), '0'), '999999999999.9999') + WHEN 1 THEN base + WHEN 2 THEN taux_sal + WHEN 3 THEN montant_sal + WHEN 4 THEN taux_emp + WHEN 5 THEN montant_emp + WHEN 6 THEN montant_sal + montant_emp + WHEN 7 THEN montant_sal - montant_emp + WHEN 8 THEN -montant_sal + montant_emp + END) ELSE 0 END * c_brut), + sum(CASE WHEN p_heures_payees and p_cumul THEN (CASE s_heures_payees + WHEN 0 THEN to_number(coalesce(nullif(trim(nombre::text), ''), '0'), '999999999999.9999') + WHEN 1 THEN base + WHEN 2 THEN taux_sal + WHEN 3 THEN montant_sal + WHEN 4 THEN taux_emp + WHEN 5 THEN montant_emp + WHEN 6 THEN montant_sal + montant_emp + WHEN 7 THEN montant_sal - montant_emp + WHEN 8 THEN -montant_sal + montant_emp + END) ELSE 0 END * c_heures_payees) + FROM w_hst_hp + JOIN prod_eig.sgrheig_contrats ON true + AND sgrheig_contrats.v_matpers::int = w_hst_hp.v_matpers + AND sgrheig_contrats.ctrid = w_hst_hp.bl_histo_ctrid + JOIN rh.t_etablissements ON t_etablissements.code_original = w_hst_hp.bl_histo_etab + JOIN prod_eig.sgrheig_rubriques ON sgrheig_rubriques.rubid::int::text = w_hst_hp.bl_histo_clerub + JOIN rh.t_rubriques ON t_rubriques.code_original = w_hst_hp.bl_histo_clerub + WHERE 1=1 + AND trim(sgrheig_contrats.v_matpers) != '' + AND to_char(date_paie, 'YYYY')::int >= 2015 + AND (p_cumul OR p_detail) + GROUP BY 1,2,3 + ; + + -- Ajout de la ligne chiffrier (production) à 0 pour le mois en cours si besoin. + INSERT INTO rh.p_chiffrier_production (entreprise_id, etablissement_id, mois, nombre_salaries, montant_brut, nombre_heures) + SELECT + entreprise_id, + etablissement_id, + mois_paie_encours::numeric, + 0,0,0 + FROM w_periode, rh.p_chiffrier_production + WHERE mois_paie_encours NOT IN (SELECT mois FROM rh.p_chiffrier_production GROUP BY 1) + GROUP BY 1,2,3 + ; + + ]]> + + + on met le mois de paie en cours (et surtout pas current_date). + from w_hst_contrat, w_periode + group by 1 + UNION ALL + select + v_matpers as mat, + min(date_debut) as date_debut, + max(greatest(date_fin, date_paie)) as date_fin + from w_hst_bul + group by 1 + ) as subq + join prod_eig.sgrheig_personnes on sgrheig_personnes.permatricule::int = subq.mat + JOIN rh.t_etablissements ON peretab = t_etablissements.code_original + group by 1 + ; + + CREATE INDEX i_lim_sal_v_matpers ON w_lim_sal USING btree(v_matpers); + CREATE INDEX i_lim_sal_dates ON w_lim_sal USING btree(date_debut, date_fin); + + DROP TABLE IF EXISTS w_evt_mois + ; + + -- CREATE TEMP TABLE w_evt_mois AS + -- select + -- w_lim_sal.v_matpers, + -- cti_cnt, -- contrat + -- cti_bul, -- bulletin. + -- p_calendrier.mois, + -- min(p_calendrier.date) as date_debut, + -- max(p_calendrier.date) as date_fin, + -- (max(p_calendrier.date) - min(p_calendrier.date) + 1)::numeric / (base.cti_last_day(max(p_calendrier.date)) - base.cti_first_day(min(p_calendrier.date)) + 1)::numeric as ratio_temps + -- from base.p_calendrier + -- join w_lim_sal on p_calendrier.date between w_lim_sal.date_debut and w_lim_sal.date_fin + -- left join w_hst_contrat on 1=1 + -- and w_hst_contrat.mat = w_lim_sal.v_matpers + -- and p_calendrier.date between w_hst_contrat.date_debut and w_hst_contrat.date_fin + -- left join w_hst_bul on 1=1 + -- and w_hst_bul.v_matpers = w_lim_sal.v_matpers + -- and p_calendrier.date between w_hst_bul.date_debut and w_hst_bul.date_fin + -- group by 1,2,3,4--5,,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38 + -- having 1!=1 + -- or cti_cnt is not null -- on ne conserve que les évenements ou il y a un contrat OU + -- or cti_bul is not null -- un bulletin + -- ; + + CREATE TEMP TABLE w_evt_mois AS + with ValidDates as ( + select v_matpers::int, date_debut::date as date from w_hst_contrat + union select v_matpers::int, date_fin::date as date from w_hst_contrat + union select v_matpers, date_debut::date as date from w_hst_bul + union select v_matpers, date_fin::date as date from w_hst_bul + ) + , ValidDateRanges1 as ( + select *, case when lead(date) over w = date + '1 day'::interval then false else true end as correct, + (case when lead(date) over w = date + '1 day'::interval then null else (date + '1 day'::interval) end)::date as date_debut, + (case when lead(date) over w = date + '1 day'::interval then null else (lead(date) over w - '1 day'::interval) end)::date as date_fin + from ValidDates + window w as (partition by v_matpers order by Date) + ) + , ValidDateRanges as ( + select v_matpers, date_debut as ValidFrom, date_fin as ValidTo from ValidDateRanges1 where correct + union + select v_matpers, date, date from ValidDates + ) + , detail as ( + select + E.v_matpers, + OU.cti_cnt, + -- L.cti_bul, + null::text as cti_bul, + D.ValidFrom, + D.ValidTo, + e.date_fin as max_date + from w_lim_sal E + join ValidDateRanges D on E.v_matpers::int=D.v_matpers::int and base.cti_overlaps(E.date_debut::date, E.date_fin::date, D.ValidFrom ,D.ValidTo ) + left join w_hst_contrat OU on true + and OU.v_matpers::int=D.v_matpers + and base.cti_overlaps(OU.date_debut::date, OU.date_fin::date, D.ValidFrom ,D.ValidTo ) + -- left join w_hst_bul L on true + -- and L.v_matpers=D.v_matpers + -- and base.cti_overlaps(L.date_debut::date, L.date_fin::date, D.ValidFrom ,D.ValidTo ) + -- and L.bl_histo_ctrid = OU.ctrid + where false + or cti_cnt is not null + -- or cti_bul is not null + ) + --,toto as ( + select + v_matpers, + cti_cnt, -- contrat + cti_cnt as cti_cnt_all, + cti_bul, -- bulletin. + mois, + min(greatest(validfrom, date_debut)) as date_debut, + max(least(validto, date_fin)) as date_fin, + (max(least(validto, date_fin)) - min(greatest(validfrom, date_debut)) + 1)::numeric / (max(date_fin) - min(date_debut) + 1)::numeric as ratio_temps + from detail + left join base.p_calendrier_mois on true + and base.cti_overlaps(validfrom, validto, date_debut, date_fin) + and date_fin <= max_date + group by 1,2,3,4,5 + -- ) + -- select + -- v_matpers, + -- cti_cnt, -- contrat + -- -- coalesce(cti_cnt, -- si la valeur est renseignée sur la ligne courante, on la prend. + -- -- (max(case when cti_cnt is null then null else ARRAY[extract(epoch from date_debut)::text, cti_cnt] end) over wb)[2], -- sinon on prend la valeur renseignée la plus proche dans le passé + -- -- (min(case when cti_cnt is null then null else ARRAY[extract(epoch from date_debut)::text, cti_cnt] end) over wf)[2], -- sinon on prend la valeur renseignée la plus proche dans le futur + -- -- null -- sinon on prend null. Ne devrait pas arriver. + -- -- ) + -- cti_cnt as cti_cnt_all, + -- cti_bul, -- bulletin. + -- -- coalesce(cti_bul, -- si la valeur est renseignée sur la ligne courante, on la prend. + -- -- (max(case when cti_bul is null then null else ARRAY[extract(epoch from date_debut)::text, cti_bul] end) over wb)[2], -- sinon on prend la valeur renseignée la plus proche dans le passé + -- -- (min(case when cti_bul is null then null else ARRAY[extract(epoch from date_debut)::text, cti_bul] end) over wf)[2], -- sinon on prend la valeur renseignée la plus proche dans le futur + -- -- null -- sinon on prend null. Ne devrait pas arriver. + -- -- ) as cti_bul_all, + -- mois, + -- date_debut, + -- date_fin, + -- ratio_temps + -- from toto + -- window wb as (PARTITION BY v_matpers ORDER BY date_debut rows unbounded preceding), -- sélectionne les lignes précédentes + -- wf as (PARTITION BY v_matpers ORDER BY date_debut rows between current row and unbounded following) -- sélectionne les lignes suivantes + ; + + -- WITH all_rsg as ( + -- SELECT + -- t1.ctid, + -- (max(array[t2.date_fin::text, t2.cti_cnt]))[2] as cti_cnt + -- FROM w_evt_mois as t1 + -- LEFT JOIN w_evt_mois as t2 ON true + -- AND t1.v_matpers = t2.v_matpers + -- AND t2.date_fin < t1.date_debut + -- -- WHERE cti_cnt IS NULL + -- GROUP BY 1 + -- ) + -- UPDATE w_evt_mois SET + -- cti_cnt_all = all_rsg.cti_cnt + -- FROM all_rsg + -- WHERE true + -- AND w_evt_mois.ctid = all_rsg.ctid + -- AND w_evt_mois.cti_cnt IS NULL + -- ; + + ]]> + + + + + + + + + + + + + + + + + + + + = 2015 + AND t_rubriques.p_detail + GROUP BY 1,2,3, 6,7,8,9,10,11,12 + ; + + DROP TABLE IF EXISTS w_hp_1 + ; + + CREATE TEMP TABLE w_hp_1 AS + SELECT + (max(ARRAY[extract(epoch from p_contrats.date_fin)::text, p_contrats.code_original]))[2] as cti_cnt_id, + cti_bul, + w_hp.date_debut, + w_hp.date_fin, + w_hp.mois_paie, + w_hp.date_paie, + p_salaries.oid as salarie_id, + (max(ARRAY[extract(epoch from p_contrats.date_fin), p_contrats.oid]))[2] as contrat_id, + (max(ARRAY[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id, + mois, + w_hp.rubrique_id, + w_hp.compte_id, + 0 as organisme_cotisation_id, + t_etablissements.oid as etablissement_id, + w_hp.base, + w_hp.nombre, + w_hp.heures_contrat, + w_hp.heures_payees, + w_hp.heures_travaillees, + w_hp.montant_masse_salariale, + w_hp.montant_brut, + w_hp.montant_avantage_nature, + w_hp.montant_frais_imposables, + w_hp.taux_cotisation_salarie, + w_hp.montant_cotisation_salarie, + w_hp.taux_cotisation_patronale, + w_hp.montant_cotisation_patronale, + w_hp.montant_od_net_salarie, + w_hp.montant_od_net_patronale, + w_hp.montant_net_imposable_salarie, + w_hp.montant_net_a_payer_salarie, + w_hp.nombre_provisions, + w_hp.montant_provisions, + w_hp.montant_masse_salariale_provisionnee + FROM w_hp + JOIN rh.p_salaries on p_salaries.code_original = w_hp.v_matpers + LEFT JOIN rh.p_contrats on p_contrats.code_original = w_hp.bl_histo_ctrid + LEFT JOIN rh.p_contrats_mois on 1=1 + AND p_contrats_mois.contrat_id = p_contrats.oid + AND p_contrats_mois.mois_activite = w_hp.mois_paie + JOIN rh.t_etablissements on t_etablissements.code_original = w_hp.bl_histo_etab + GROUP BY 2,3,4,5,6,7, 10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34, w_hp.ctid + ; + + -- Associer les bulletins hors contrat (is null) avec le contrat précédent. + UPDATE w_hp_1 + SET contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + w_hp_1.ctid, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_hp_1 + join rh.p_contrats_mois on true + and p_contrats_mois.salarie_id = w_hp_1.salarie_id + and p_contrats_mois.date_fin < w_hp_1.date_debut + where contrat_mois_id is null + group by 1) as subq + WHERE true + AND w_hp_1.ctid = subq.ctid + AND w_hp_1.contrat_mois_id is null + ; + + -- Associer les bulletins hors contrat (is null) avec le contrat suivant. + UPDATE w_hp_1 + SET contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + w_hp_1.ctid, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_hp_1 + join rh.p_contrats_mois on true + and p_contrats_mois.salarie_id = w_hp_1.salarie_id + and p_contrats_mois.date_fin > w_hp_1.date_debut + where contrat_mois_id is null + group by 1) as subq + WHERE true + AND w_hp_1.ctid = subq.ctid + AND w_hp_1.contrat_mois_id is null + ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + compte_id, + organisme_cotisation_id, + etablissement_id, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + mois, + date_debut, + date_fin, + mois_paie, + date_paie, --bul_datepaie, + rubrique_id, + compte_id, + organisme_cotisation_id, + etablissement_id, + base, + nombre, + heures_contrat, + heures_payees, + heures_travaillees, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee + FROM w_hp_1 + ; + + ]]> + + + = 2015 + -- AND p_cumul -- NE PAS LE METTRE ICI, ça enlève trop de ligne !! + GROUP BY 1,2,3,4 + ; + + -- Insérer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie ( + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_avantage_nature, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + etablissement_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + subq.contrat_id, + subq.contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + 0 AS nombre, + COALESCE(hcum_heures_contrat,0) - subq.heure_contrat AS heure_contrat, + COALESCE(hcum_heures_payees,0) - subq.heure_payee AS heure_payee, + COALESCE(hcum_heures_travaillees,0) - subq.heure_travaillee AS heure_travaillee, + COALESCE(hcum_avantage_nature,0) - subq.montant_avantage_nature AS montant_avantage_nature, + COALESCE(hcum_brut,0) - subq.montant_brut AS montant_brut, + COALESCE(hcum_masse_salariale, 0) - subq.montant_masse_salariale AS montant_masse_salariale, + COALESCE(hcum_cotisation_patronale,0) - subq.montant_cotisation_patronale AS montant_cotisation_patronale, + COALESCE(hcum_cotisation_salarie,0) - subq.montant_cotisation_salarie AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + COALESCE(hcum_net_a_payer_salarie,0) - subq.montant_net_a_payer_salarie AS montant_net_a_payer_salarie, + COALESCE(hcum_net_imposable_salarie,0) - subq.montant_net_imposable_salarie AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.etablissement_id as etablissement_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + 0 AS compte_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + COALESCE(hcum_nombre_provisions,0) - subq.nombre_provisions AS nombre_provisions, + COALESCE(hcum_montant_provisions,0) - subq.montant_provisions AS montant_provisions, + COALESCE(hcum_masse_salariale_provisionnee,0) - subq.montant_masse_salariale_provisionnee AS montant_masse_salariale_provisionnee + FROM ( + SELECT + cti_bul, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie as date_paie, + mois as mois_activite, + mois_paie as mois_paie, + 0 AS base, + 0 AS nombre, + sum(heures_contrat) AS heure_contrat, + sum(heures_payees) AS heure_payee, + sum(heures_travaillees) AS heure_travaillee, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_masse_salariale) AS montant_masse_salariale, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + organisme_cotisation_id, + etablissement_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + sum(nombre_provisions) AS nombre_provisions, + sum(montant_provisions) AS montant_provisions, + sum(montant_masse_salariale_provisionnee) AS montant_masse_salariale_provisionnee + FROM w_hp_1 + GROUP BY 1,2,3,4,5,6,7,8,9,10, 22, 23,24,25,26) AS subq + JOIN w_totaux ON w_totaux.cti_bul = subq.cti_bul + WHERE 1!=1 + OR COALESCE(hcum_avantage_nature,0) - subq.montant_avantage_nature != 0 + OR COALESCE(hcum_brut,0) - subq.montant_brut != 0 + OR COALESCE(hcum_masse_salariale,0) - subq.montant_masse_salariale != 0 + OR COALESCE(hcum_net_a_payer_salarie,0) - subq.montant_net_a_payer_salarie != 0 + OR COALESCE(hcum_net_imposable_salarie,0) - subq.montant_net_imposable_salarie != 0 + OR COALESCE(hcum_cotisation_patronale,0) - subq.montant_cotisation_patronale != 0 + OR COALESCE(hcum_cotisation_salarie,0) - subq.montant_cotisation_salarie != 0 + OR COALESCE(hcum_heures_contrat,0) - subq.heure_contrat != 0 + OR COALESCE(hcum_heures_payees,0) - subq.heure_payee != 0 + OR COALESCE(hcum_heures_travaillees,0) - subq.heure_travaillee != 0 + OR COALESCE(hcum_nombre_provisions,0) - subq.nombre_provisions != 0 + OR COALESCE(hcum_montant_provisions,0) - subq.montant_provisions != 0 + OR COALESCE(hcum_masse_salariale_provisionnee,0) - subq.montant_masse_salariale_provisionnee != 0 + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_FUSION.XML b/import_rh/iCTI_import_rh_FUSION.XML new file mode 100644 index 0000000..c948db7 --- /dev/null +++ b/import_rh/iCTI_import_rh_FUSION.XML @@ -0,0 +1,1450 @@ + + + + + + + + + + + + + + + 0 + ; + INSERT INTO rh.t_entreprises( + oid, + code_original, + code, + texte, + texte_court, + planning_code, + siren) + SELECT + oid + fp('idx')::bigint, + fp('idc')||code_original, + fp('idc')||code, + texte, + texte_court, + planning_code, + siren + FROM rh_src.t_entreprises + WHERE oid > 0 + ; + + -- Màj des Etablissements. NE PAS SUPPRIMER car paramétrage associé. + -- DELETE FROM rh.t_etablissements + -- WHERE true + -- AND oid BETWEEN fp('idx')::bigint AND (fp('idx')::bigint + fp('pas')::bigint) + -- AND oid > 0 + -- ; + INSERT INTO rh.t_etablissements( + oid, + code_original, + code, + texte, + texte_court, + entreprise_id, + base_calcul_etp, + mode_calcul_etp_paye, + planning_code, + siret) + SELECT + oid + fp('idx')::bigint, + fp('idc')||code_original, + fp('idc')||code, + texte, + texte_court, + entreprise_id + fp('idx')::bigint, + base_calcul_etp, + mode_calcul_etp_paye, + planning_code, + siret + FROM rh_src.t_etablissements + WHERE true + and oid > 0 + and oid + fp('idx')::bigint not in (select oid from rh.t_etablissements group by 1) + ; + + -- Màj du siret. + UPDATE rh.t_etablissements SET + siret = src.siret + FROM rh_src.t_etablissements as src + WHERE 1=1 + and t_etablissements.oid = src.oid + fp('idx')::bigint + and t_etablissements.siret is distinct from src.siret + ; + + -- Màj des catégories socio-professionnelles (fusion des codes). + INSERT INTO rh.t_categories_socio_professionnelle (code_original, code, texte, texte_court) + SELECT src_csp.code_original, src_csp.code, src_csp.texte, src_csp.texte_court + FROM rh_src.t_categories_socio_professionnelle AS src_csp + LEFT JOIN rh.t_categories_socio_professionnelle ON t_categories_socio_professionnelle.code_original = src_csp.code_original + WHERE 1=1 + AND t_categories_socio_professionnelle.oid IS NULL + AND src_csp.oid > 0 + ; + + -- Màj des groupes cotisants. + SELECT syncTable3('t_groupes_cotisant') + ; + + -- Màj Motifs début + SELECT syncTable3('t_motifs_debut_contrat') + ; + + -- Màj des motifs de fin de contrat + SELECT syncTable3('t_motifs_fin_contrat') + ; + + -- Màj des nationalités + SELECT syncTable3('t_nationalites') + ; + + -- Màj des organismes de cotisation + SELECT syncTable3('t_organismes_cotisation') + ; + + -- Màj des qualifications + SELECT syncTable3('t_qualifications') + ; + + -- Màj des rubriques + SELECT syncTable3('t_rubriques') + ; + + -- On réplique le paramétrage des rubriques. + -- FIXME besoin de refaire descendre le paramétrage ? + UPDATE rh.t_rubriques + SET + c_avantage_nature = rub_src.c_avantage_nature, + c_base = rub_src.c_base, + c_brut = rub_src.c_brut, + c_cotisation_patronale = rub_src.c_cotisation_patronale, + c_cotisation_salarie = rub_src.c_cotisation_salarie, + c_frais_imposables = rub_src.c_frais_imposables, + c_heures_contrat = rub_src.c_heures_contrat, + c_heures_payees = rub_src.c_heures_payees, + c_heures_travaillees = rub_src.c_heures_travaillees, + c_masse_salariale = rub_src.c_masse_salariale, + c_masse_salariale_provisionnee = rub_src.c_masse_salariale_provisionnee, + c_montant_provisions = rub_src.c_montant_provisions, + c_net_a_payer = rub_src.c_net_a_payer, + c_net_imposable = rub_src.c_net_imposable, + c_nombre = rub_src.c_nombre, + c_nombre_provisions = rub_src.c_nombre_provisions, + c_od_net_patronale = rub_src.c_od_net_patronale, + c_od_net_salarie = rub_src.c_od_net_salarie, + code_calcul = rub_src.code_calcul, + coefficient = rub_src.coefficient, + coefficient_base = rub_src.coefficient_base, + coefficient_nombre = rub_src.coefficient_nombre, + coefficient_txp = rub_src.coefficient_txp, + coefficient_txs = rub_src.coefficient_txs, + heures_payees = rub_src.heures_payees, + p_avantage_nature = rub_src.p_avantage_nature, + p_base = rub_src.p_base, + p_brut = rub_src.p_brut, + p_cotisation_patronale = rub_src.p_cotisation_patronale, + p_cotisation_salarie = rub_src.p_cotisation_salarie, + p_cumul = rub_src.p_cumul, + p_detail = rub_src.p_detail, + p_frais_imposables = rub_src.p_frais_imposables, + p_heures_contrat = rub_src.p_heures_contrat, + p_heures_payees = rub_src.p_heures_payees, + p_heures_travaillees = rub_src.p_heures_travaillees, + p_masse_salariale = rub_src.p_masse_salariale, + p_masse_salariale_provisionnee = rub_src.p_masse_salariale_provisionnee, + p_montant_provisions = rub_src.p_montant_provisions, + p_net_a_payer = rub_src.p_net_a_payer, + p_net_imposable = rub_src.p_net_imposable, + p_nombre = rub_src.p_nombre, + p_nombre_provisions = rub_src.p_nombre_provisions, + p_od_net_patronale = rub_src.p_od_net_patronale, + p_od_net_salarie = rub_src.p_od_net_salarie, + s_avantage_nature = rub_src.s_avantage_nature, + s_base = rub_src.s_base, + s_brut = rub_src.s_brut, + s_cotisation_patronale = rub_src.s_cotisation_patronale, + s_cotisation_salarie = rub_src.s_cotisation_salarie, + s_frais_imposables = rub_src.s_frais_imposables, + s_heures_contrat = rub_src.s_heures_contrat, + s_heures_payees = rub_src.s_heures_payees, + s_heures_travaillees = rub_src.s_heures_travaillees, + s_masse_salariale = rub_src.s_masse_salariale, + s_masse_salariale_provisionnee = rub_src.s_masse_salariale_provisionnee, + s_montant_provisions = rub_src.s_montant_provisions, + s_net_a_payer = rub_src.s_net_a_payer, + s_net_imposable = rub_src.s_net_imposable, + s_nombre = rub_src.s_nombre, + s_nombre_provisions = rub_src.s_nombre_provisions, + s_od_net_patronale = rub_src.s_od_net_patronale, + s_od_net_salarie = rub_src.s_od_net_salarie, + unite = rub_src.unite, + user_modified = rub_src.user_modified + FROM rh_src.t_rubriques AS rub_src + WHERE 1=1 + AND t_rubriques.oid = rub_src.oid + fp('idx')::bigint + AND (1!=1 + OR t_rubriques.c_avantage_nature IS DISTINCT FROM rub_src.c_avantage_nature + OR t_rubriques.c_base IS DISTINCT FROM rub_src.c_base + OR t_rubriques.c_brut IS DISTINCT FROM rub_src.c_brut + OR t_rubriques.c_cotisation_patronale IS DISTINCT FROM rub_src.c_cotisation_patronale + OR t_rubriques.c_cotisation_salarie IS DISTINCT FROM rub_src.c_cotisation_salarie + OR t_rubriques.c_frais_imposables IS DISTINCT FROM rub_src.c_frais_imposables + OR t_rubriques.c_heures_contrat IS DISTINCT FROM rub_src.c_heures_contrat + OR t_rubriques.c_heures_payees IS DISTINCT FROM rub_src.c_heures_payees + OR t_rubriques.c_heures_travaillees IS DISTINCT FROM rub_src.c_heures_travaillees + OR t_rubriques.c_masse_salariale IS DISTINCT FROM rub_src.c_masse_salariale + OR t_rubriques.c_masse_salariale_provisionnee IS DISTINCT FROM rub_src.c_masse_salariale_provisionnee + OR t_rubriques.c_montant_provisions IS DISTINCT FROM rub_src.c_montant_provisions + OR t_rubriques.c_net_a_payer IS DISTINCT FROM rub_src.c_net_a_payer + OR t_rubriques.c_net_imposable IS DISTINCT FROM rub_src.c_net_imposable + OR t_rubriques.c_nombre IS DISTINCT FROM rub_src.c_nombre + OR t_rubriques.c_nombre_provisions IS DISTINCT FROM rub_src.c_nombre_provisions + OR t_rubriques.c_od_net_patronale IS DISTINCT FROM rub_src.c_od_net_patronale + OR t_rubriques.c_od_net_salarie IS DISTINCT FROM rub_src.c_od_net_salarie + OR t_rubriques.code_calcul IS DISTINCT FROM rub_src.code_calcul + OR t_rubriques.coefficient IS DISTINCT FROM rub_src.coefficient + OR t_rubriques.coefficient_base IS DISTINCT FROM rub_src.coefficient_base + OR t_rubriques.coefficient_nombre IS DISTINCT FROM rub_src.coefficient_nombre + OR t_rubriques.coefficient_txp IS DISTINCT FROM rub_src.coefficient_txp + OR t_rubriques.coefficient_txs IS DISTINCT FROM rub_src.coefficient_txs + OR t_rubriques.heures_payees IS DISTINCT FROM rub_src.heures_payees + OR t_rubriques.p_avantage_nature IS DISTINCT FROM rub_src.p_avantage_nature + OR t_rubriques.p_base IS DISTINCT FROM rub_src.p_base + OR t_rubriques.p_brut IS DISTINCT FROM rub_src.p_brut + OR t_rubriques.p_cotisation_patronale IS DISTINCT FROM rub_src.p_cotisation_patronale + OR t_rubriques.p_cotisation_salarie IS DISTINCT FROM rub_src.p_cotisation_salarie + OR t_rubriques.p_cumul IS DISTINCT FROM rub_src.p_cumul + OR t_rubriques.p_detail IS DISTINCT FROM rub_src.p_detail + OR t_rubriques.p_frais_imposables IS DISTINCT FROM rub_src.p_frais_imposables + OR t_rubriques.p_heures_contrat IS DISTINCT FROM rub_src.p_heures_contrat + OR t_rubriques.p_heures_payees IS DISTINCT FROM rub_src.p_heures_payees + OR t_rubriques.p_heures_travaillees IS DISTINCT FROM rub_src.p_heures_travaillees + OR t_rubriques.p_masse_salariale IS DISTINCT FROM rub_src.p_masse_salariale + OR t_rubriques.p_masse_salariale_provisionnee IS DISTINCT FROM rub_src.p_masse_salariale_provisionnee + OR t_rubriques.p_montant_provisions IS DISTINCT FROM rub_src.p_montant_provisions + OR t_rubriques.p_net_a_payer IS DISTINCT FROM rub_src.p_net_a_payer + OR t_rubriques.p_net_imposable IS DISTINCT FROM rub_src.p_net_imposable + OR t_rubriques.p_nombre IS DISTINCT FROM rub_src.p_nombre + OR t_rubriques.p_nombre_provisions IS DISTINCT FROM rub_src.p_nombre_provisions + OR t_rubriques.p_od_net_patronale IS DISTINCT FROM rub_src.p_od_net_patronale + OR t_rubriques.p_od_net_salarie IS DISTINCT FROM rub_src.p_od_net_salarie + OR t_rubriques.s_avantage_nature IS DISTINCT FROM rub_src.s_avantage_nature + OR t_rubriques.s_base IS DISTINCT FROM rub_src.s_base + OR t_rubriques.s_brut IS DISTINCT FROM rub_src.s_brut + OR t_rubriques.s_cotisation_patronale IS DISTINCT FROM rub_src.s_cotisation_patronale + OR t_rubriques.s_cotisation_salarie IS DISTINCT FROM rub_src.s_cotisation_salarie + OR t_rubriques.s_frais_imposables IS DISTINCT FROM rub_src.s_frais_imposables + OR t_rubriques.s_heures_contrat IS DISTINCT FROM rub_src.s_heures_contrat + OR t_rubriques.s_heures_payees IS DISTINCT FROM rub_src.s_heures_payees + OR t_rubriques.s_heures_travaillees IS DISTINCT FROM rub_src.s_heures_travaillees + OR t_rubriques.s_masse_salariale IS DISTINCT FROM rub_src.s_masse_salariale + OR t_rubriques.s_masse_salariale_provisionnee IS DISTINCT FROM rub_src.s_masse_salariale_provisionnee + OR t_rubriques.s_montant_provisions IS DISTINCT FROM rub_src.s_montant_provisions + OR t_rubriques.s_net_a_payer IS DISTINCT FROM rub_src.s_net_a_payer + OR t_rubriques.s_net_imposable IS DISTINCT FROM rub_src.s_net_imposable + OR t_rubriques.s_nombre IS DISTINCT FROM rub_src.s_nombre + OR t_rubriques.s_nombre_provisions IS DISTINCT FROM rub_src.s_nombre_provisions + OR t_rubriques.s_od_net_patronale IS DISTINCT FROM rub_src.s_od_net_patronale + OR t_rubriques.s_od_net_salarie IS DISTINCT FROM rub_src.s_od_net_salarie + OR t_rubriques.unite IS DISTINCT FROM rub_src.unite + OR t_rubriques.user_modified IS DISTINCT FROM rub_src.user_modified) + ; + + -- Màj comptes + SELECT syncTable3('t_compte') + ; + + -- Màj des situations de famille + SELECT syncTable3('t_situations_famille') + ; + + -- Màj des types de contrat + SELECT syncTable3('t_types_contrat') + ; + + -- Màj des statuts + SELECT syncTable3('t_statuts') + ; + + -- Màj des types de temps de travail + SELECT syncTable3('t_types_temps_travail') + ; + + -- Màj des services + SELECT syncTable3('t_services') + ; + + -- Màj des spécialités + SELECT syncTable3('t_specialites') + ; + + -- Màj des codes emploi + SELECT syncTable3('t_codes_emploi') + ; + + -- Màj des types d'horaire + SELECT syncTable3('t_types_horaire') + ; + + -- Màj des sociétés d'interim + SELECT syncTable3('t_societes_interim') + ; + + -- Màj des grilles + SELECT syncTable3('t_grilles') + ; + + -- Màj des groupes de grilles + SELECT syncTable3('t_grilles_groupes') + ; + + -- Màj des sections analytiques paie + SELECT syncTable3('t_sections_analytiques_paie') + ; + + -- Màj des sections analytiques comptable + SELECT syncTable3('t_sections_analytiques') + ; + + -- Màj des plans analytiques ng + DELETE FROM rh.t_plan_analytique WHERE oid BETWEEN fp('idx')::bigint AND (fp('idx')::bigint + fp('pas')::bigint) AND oid > 0 + ; + INSERT INTO rh.t_plan_analytique(oid, code, texte) + SELECT oid, code, texte + FROM rh_src.t_plan_analytique + WHERE oid > 0 + ; + + -- Màj des sections analytiques ng + SELECT syncTable3('t_section_analytique') + ; + + -- Màj des motifs d'arret + SELECT syncTable3('t_motifs_arret') + ; + + -- Màj des précisions du motif d'arrêt + SELECT syncTable3('t_precisions_motif_arret') + ; + + -- Màj des motifs de visite médicale + SELECT syncTable3('t_motifs_visite') + ; + + -- Màj des circonstances d'accident du travail + SELECT syncTable3('t_accident_circonstance') + ; + + -- Màj des lieux d'accident du travail + SELECT syncTable3('t_accident_lieu') + ; + + -- Màj de la nature de l'accident du travail + SELECT syncTable3('t_accident_nature') + ; + + -- Màj des sièges d'accident du travail + SELECT syncTable3('t_accident_siege') + ; + + -- Màj des listes de formations + SELECT syncTable3('t_liste_formations') + ; + + -- Màj des codes de cotisation. + SELECT syncTable3('t_code_cotisation') + ; + + ]]> + + + + + + + + + + + Cegid : 2299Z -> 0000002299. On conserve 0000002299. + -- * 2 = Le n° de SS sert à effectuer le rapprochement. On conserver le matricule le plus récent (celui du prestataire en cours). + + DROP TABLE IF EXISTS w_salaries + ; + CREATE TEMP TABLE w_salaries AS + SELECT + oid + fp('idx')::bigint AS oid, + finess, + nom, + prenom, + date_naissance, + sexe, + CASE t_divers.valeur + WHEN 0 THEN matricule + WHEN 1 THEN (CASE WHEN length(matricule) = 10 THEN matricule ELSE lpad(substring(matricule from '(....).$'), 10, '0') END) + WHEN 2 THEN matricule + END AS matricule, + matricule_planning, + CASE t_divers.valeur + WHEN 0 THEN p_salaries.code + WHEN 1 THEN (CASE WHEN length(p_salaries.code) = 10 THEN p_salaries.code ELSE lpad(substring(p_salaries.code from '(....).$'), 10, '0') END) + WHEN 2 THEN p_salaries.code + END AS code, + CASE t_divers.valeur + WHEN 0 THEN code_original + WHEN 1 THEN (CASE WHEN length(code_original) = 10 THEN code_original ELSE lpad(substring(code_original from '(....).$'), 10, '0') END) + WHEN 2 THEN code_original + END AS code_original, + coalesce(nir, matricule) as nir, -- prise en du compte matricule pour les salaries sans nir e.g. étrangers + getOid(entreprise_id) as entreprise_id, + getOid(nationalite_id) as nationalite_id, + code_postal_id, + nom_naissance, + getOid(situation_famille_id) as situation_famille_id, + adresse1, + adresse2, + getOid(profil_id) as profil_id, + date_debut, + date_fin, + date_entree_ets, + date_sortie_ets, + date_anciennete, + date_entree_fp, + date_entree_fph, + no_adeli, + case when code_cotisation_id = 0 then 0 else code_cotisation_id + fp('idx')::bigint end as code_cotisation_id, + matricule_retraite as matricule_retraite + FROM rh_src.p_salaries + join rh.t_divers ON t_divers.code = 'FUSION_STRATEGIE' + ; + + DELETE FROM rh.p_salaries WHERE oid BETWEEN fp('idx')::bigint AND (fp('idx')::bigint + fp('pas')::bigint) + ; + + -- Ajout des salariés pas déjà insérés précédemment. + INSERT INTO rh.p_salaries( + oid, + finess, + nom, + prenom, + date_naissance, + sexe, + matricule, + matricule_planning, + code, + code_original, + nir, + entreprise_id, + nationalite_id, + code_postal_id, + nom_naissance, + situation_famille_id, + adresse1, + adresse2, + profil_id, + date_debut, + date_fin, + date_entree_ets, + date_sortie_ets, + date_anciennete, + date_entree_fp, + date_entree_fph, + no_adeli, + code_cotisation_id, + matricule_retraite) + SELECT + oid, + finess, + nom, + prenom, + date_naissance, + sexe, + matricule, + matricule_planning, + code, + code_original, + nir, + entreprise_id, + nationalite_id, + code_postal_id, + nom_naissance, + situation_famille_id, + adresse1, + adresse2, + profil_id, + date_debut, + date_fin, + date_entree_ets, + date_sortie_ets, + date_anciennete, + date_entree_fp, + date_entree_fph, + no_adeli, + code_cotisation_id, + matricule_retraite + FROM w_salaries + WHERE matricule NOT IN (SELECT matricule FROM rh.p_salaries) + ; + + ]]> + + + rh.oid pour les salariés. + DROP TABLE IF EXISTS w_map_sal + ; + CREATE TEMP TABLE w_map_sal AS + SELECT + p_salaries.oid as salarie_src_id, + min(p.oid) as salarie_id, -- Utile lorsque FUSION_STRATEGIE à 2 car plusieurs matricules pour le même n°SS. + -- CASE t_divers.valeur + -- WHEN 0 THEN p_salaries.matricule + -- WHEN 1 THEN (CASE WHEN length(p_salaries.matricule) = 10 THEN p_salaries.matricule ELSE lpad(substring(p_salaries.matricule from '(....).$'), 10, '0') END) + -- WHEN 2 THEN p_salaries.matricule + -- END AS matricule, + p_salaries.nir + FROM rh_src.p_salaries + join rh.t_divers ON t_divers.code = 'FUSION_STRATEGIE' + JOIN rh.p_salaries as p ON + (CASE t_divers.valeur + WHEN 0 THEN p.matricule = p_salaries.matricule + WHEN 1 THEN p.matricule = (CASE WHEN length(p_salaries.matricule) = 10 THEN p_salaries.matricule ELSE lpad(substring(p_salaries.matricule from '(....).$'), 10, '0') END) + WHEN 2 THEN substring(p.nir, 1, 13) = substring(p_salaries.nir, 1, 13) + END) + GROUP BY 1, 3 + ; + + ]]> + + + nouveaux oids. + -- Seuls les contrats avec cnt_to_insert à true seront à insérer. + DROP TABLE IF EXISTS w_map_cnt + ; + CREATE TEMP TABLE w_map_cnt AS + with src_contrat_bul as ( + select contrat_id + from rh_src.p_historique_paie + where mois_paie BETWEEN to_char(fp('str')::date, 'YYYYMM') AND to_char(fp('end')::date, 'YYYYMM') + group by 1) + SELECT + coalesce(cnt_ori.oid, MAX(cnt.oid) + fp('idx')::bigint) AS contrat_id, -- id (à insérer si cnt_to_insert = true) du contrat dans le schéma de rh. + MAX(cnt.oid) AS contrat_src_id, -- id du contrat dans le schéma du prestataire. + cnt_ori.oid IS NULL as cnt_to_insert, -- true : contrat à insérer; false : contrat déjà inséré. + map1.salarie_id -- on met le bon id de salarié issu du mapping. + --coalesce(cnt_ori.date_debut, cnt.date_debut) AS date_debut, + --coalesce(cnt_ori.date_fin, cnt.date_fin) AS date_fin + FROM rh_src.p_contrats as cnt + JOIN w_map_sal as map1 ON map1.salarie_src_id = cnt.salarie_id + left join src_contrat_bul on src_contrat_bul.contrat_id = cnt.oid + LEFT JOIN rh.p_contrats as cnt_ori ON 1=1 + AND cnt_ori.salarie_id = map1.salarie_id + AND cnt_ori.date_debut = cnt.date_debut -- On fait uniquement le lien avec la date de début, car la date de fin pouvait ne pas être déterminé dans l'ancien prestataire. + -- AND cnt_ori.date_fin = cnt.date_fin -- <- A laisser commentée. + -- AND base.cti_overlaps(cnt.date_debut, cnt.date_fin, cnt_ori.date_debut, cnt_ori.date_fin) -- Permet de ne pas prendre des contrats en trop qui seraient chevauchant (cf. exemple ci-dessous) + WHERE true + and (false + or base.cti_overlaps(cnt.date_debut, cnt.date_fin, fp('str')::date, fp('end')::date) -- on prend uniquement les contrats relatif à la période prestataire... + or src_contrat_bul.contrat_id is not null) -- ... ou ceux dont le contrat aurait été positionné avant le changement de prestataire (IC-4475). + GROUP BY cnt_ori.oid, map1.salarie_id, cnt.date_debut + ; + + /** + + UPDATE : + -------- + Tant pis pour le cas où la reprise des contrat n'a pas été correcte (avec date de début identique). + En effet cela pose problème pour la gestion du multi-contrat. + + + EXPLICATION ORIGINELLE : + ------------------------ + + Cas d'un salarié. + + LEFT JOIN rh.p_contrats as cnt_ori basé sur cnt_ori.date_debut = cnt.date_debut + + Cegid (nouveau prestataire) : + "2003-08-02";"2003-08-31";"00000020310001" -- NON (via le WHERE) + "2003-10-01";"2003-10-31";"00000020310002" -- NON (via le WHERE) + "2003-11-01";"2003-11-30";"00000020310003" -- NON (via le WHERE) + "2003-12-01";"2003-12-31";"00000020310004" -- NON (via le WHERE) + "2004-01-01";"2099-12-31";"00000020310005" -- Sélectionné + + SHS (ancien prestataire ) : + "2003-08-02";"2003-08-31";"2031H-1" -- Sélectionné + "2003-10-01";"2003-10-31";"2031H-2" -- Sélectionné + "2003-11-01";"2003-11-30";"2031H-3" -- Sélectionné + "2003-12-01";"2003-12-31";"2031H-4" -- Sélectionné + "2004-01-01";"2004-06-30";"2031H-5" -- Non sélectionné car déjà remonté avec Cegid. + "2004-07-01";"2099-12-31";"2031H-6" -- Sélectionné + + Fusion (erronée car 2 contrats se terminant en 2099-12-31) : + "2003-08-02";"2003-08-31";"SH_2031H-1" + "2003-10-01";"2003-10-31";"SH_2031H-2" + "2003-11-01";"2003-11-30";"SH_2031H-3" + "2003-12-01";"2003-12-31";"SH_2031H-4" + "2004-01-01";"2099-12-31";"00000020310005" + "2004-07-01";"2099-12-31";"SH_2031H-6" -- ce contrat n'aurait pas du être remonté et c'est le sens du cti_overlaps dans le LEFT JOIN. + + */ + + INSERT INTO rh.p_contrats ( + oid, + salarie_id, + date_debut, + date_fin, + numero_contrat, + code_original, + etablissement_id, + profil_id, + anciennete_anterieure_mois, + anciennete_anterieure_calculee_mois, + salarie_remplace_id, + anciennete_anterieure_jours, + anciennete_anterieure_calculee_jours) + SELECT + cnt.contrat_id, + cnt.salarie_id, -- on met le bon id de salarié issu du mapping. + p_contrats.date_debut, + p_contrats.date_fin, + fp('idc')||p_contrats.numero_contrat, + fp('idc')||p_contrats.code_original, + getOid(p_contrats.etablissement_id), + getOid(p_contrats.profil_id), + p_contrats.anciennete_anterieure_mois, + p_contrats.anciennete_anterieure_calculee_mois, + coalesce(map.salarie_id, 0), -- on met le bon id de salarié remplacé issu du mapping. + p_contrats.anciennete_anterieure_jours, + p_contrats.anciennete_anterieure_calculee_jours + FROM w_map_cnt as cnt + JOIN rh_src.p_contrats on p_contrats.oid = cnt.contrat_src_id + LEFT JOIN w_map_sal as map ON map.salarie_src_id = p_contrats.salarie_remplace_id + WHERE cnt.cnt_to_insert -- on insére uniquement les contrats pas déjà insérés précédemment. + ; + + -- On conserve uniquement la ventilation sur les périodes propres à chaque prestataire. + -- On considère que la ventilation sur les périodes propres à chaque prestataire est la plus à même de décrire l'évolution du salarié, + -- notamment pour les CDI pour lesquels l'historique n'aura pas été intégralement repris avec le nouveau prestataire. + DELETE FROM rh.p_contrats_mois WHERE oid BETWEEN fp('idx')::bigint AND (fp('idx')::bigint + fp('pas')::bigint) + ; + + -- Table qui fait le mapping entre les anciens oid et les éventuels nouveaux. + DROP TABLE IF EXISTS w_map_cnt_mois + ; + CREATE TEMP TABLE w_map_cnt_mois AS + with src_contrat_bul as ( + select contrat_mois_id + from rh_src.p_historique_paie + where mois_paie BETWEEN to_char(fp('str')::date, 'YYYYMM') AND to_char(fp('end')::date, 'YYYYMM') + group by 1) + SELECT + cnt_src.oid + fp('idx')::bigint as contrat_mois_id, + cnt_src.oid as contrat_mois_src_id, + w_map_cnt.contrat_id, + w_map_cnt.contrat_src_id, + cnt_src.mois_activite, + w_map_cnt.salarie_id + FROM rh_src.p_contrats_mois AS cnt_src + left join src_contrat_bul on src_contrat_bul.contrat_mois_id = cnt_src.oid + JOIN w_map_cnt ON 1=1 + AND w_map_cnt.contrat_src_id = cnt_src.contrat_id + -- UPDATE : NON -- V Les contrats_mois doivent correspondrent à un seul contrat sur une période donnée. + -- AND base.cti_overlaps(w_map_cnt.date_debut, w_map_cnt.date_fin, cnt_src.date_debut, cnt_src.date_fin) + WHERE true + and (false + or cnt_src.mois_activite BETWEEN to_char(fp('str')::date, 'YYYYMM') AND to_char(fp('end')::date, 'YYYYMM') -- on prend uniquement les contrats relatif à la période prestataire... + or src_contrat_bul.contrat_mois_id is not null) -- ... ou ceux dont le contrat aurait été positionné avant le changement de prestataire (IC-4475). + ; + + + INSERT INTO rh.p_contrats_mois( + oid, + contrat_id, + mois_activite, + nombre_debut_contrat, + nombre_fin_contrat, + equivalent_temps_plein, + date_debut, + date_fin, + age_id, + age_jours, + est_hors_periode, + present_fin_mois, + anciennete_mois, + anciennete_annee_id, + nombre_departs, + salarie_id, + anciennete_grade_mois, + anciennete_grade_annee_id, + anciennete_fp_mois, + anciennete_fp_annee_id, + anciennete_fph_mois, + anciennete_fph_annee_id, + fictif, + nombre_entrees, + present_debut_mois, + anciennete_jours, + profil_id, + etablissement_id, + code_original, + effectif_permanent, + nombre_transformation_cdi, + pole_id, + population_id, + ratio_temps_travail, + nombre_heures) + SELECT + w_map_cnt_mois.contrat_mois_id, + w_map_cnt_mois.contrat_id, + w_map_cnt_mois.mois_activite, + p_contrats_mois.nombre_debut_contrat, + p_contrats_mois.nombre_fin_contrat, + p_contrats_mois.equivalent_temps_plein, + p_contrats_mois.date_debut, + p_contrats_mois.date_fin, + p_contrats_mois.age_id, + p_contrats_mois.age_jours, + p_contrats_mois.est_hors_periode, + p_contrats_mois.present_fin_mois, + p_contrats_mois.anciennete_mois, + p_contrats_mois.anciennete_annee_id, + p_contrats_mois.nombre_departs, + w_map_cnt_mois.salarie_id, -- on met le bon id de salarié issu du mapping. + p_contrats_mois.anciennete_grade_mois, + p_contrats_mois.anciennete_grade_annee_id, + p_contrats_mois.anciennete_fp_mois, + p_contrats_mois.anciennete_fp_annee_id, + p_contrats_mois.anciennete_fph_mois, + p_contrats_mois.anciennete_fph_annee_id, + p_contrats_mois.fictif, + p_contrats_mois.nombre_entrees, + p_contrats_mois.present_debut_mois, + p_contrats_mois.anciennete_jours, + getOid(p_contrats_mois.profil_id), + getOid(p_contrats_mois.etablissement_id), + p_contrats_mois.code_original, + p_contrats_mois.effectif_permanent, + p_contrats_mois.nombre_transformation_cdi, + p_contrats_mois.pole_id, + p_contrats_mois.population_id, + p_contrats_mois.ratio_temps_travail, + p_contrats_mois.nombre_heures + FROM w_map_cnt_mois + JOIN rh_src.p_contrats_mois ON p_contrats_mois.oid = w_map_cnt_mois.contrat_mois_src_id + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_ICTI_RH.XML b/import_rh/iCTI_import_rh_ICTI_RH.XML new file mode 100644 index 0000000..d29ce5c --- /dev/null +++ b/import_rh/iCTI_import_rh_ICTI_RH.XML @@ -0,0 +1,2375 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ALL (Array[[ETABLISSEMENTS_CHOISIS]]) + ) + ', 'temp e_etablissements' + ); + + INSERT INTO rh.t_etablissements( + base_calcul_etp, code, code_original, entreprise_id, mode_calcul_etp_paye, + oid, planning_code, section_code, section_id, section_texte, + texte, texte_court) + SELECT + base_calcul_etp, code, code_original, entreprise_id, mode_calcul_etp_paye, + oid, planning_code, section_code, section_id, section_texte, + texte, texte_court + FROM e_etablissements + WHERE oid NOT IN (SELECT oid FROM rh.t_etablissements) + ; + + + SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_entreprises + WHERE oid IN + (SELECT entreprise_id + FROM rh.t_etablissements + WHERE t_etablissements.oid = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) OR oid = 0 + ) OR oid = 0 + ', 'temp e_entreprises' + ); + + TRUNCATE rh.t_entreprises + ; + + INSERT INTO rh.t_entreprises( + code, code_original, oid, planning_code, section_code, section_id, + section_texte, texte, texte_court) + SELECT + code, code_original, oid, planning_code, section_code, section_id, + section_texte, texte, texte_court + FROM e_entreprises + WHERE oid NOT IN (SELECT oid FROM rh.t_entreprises) + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '''' AND + oid IN (SELECT liste_id FROM rh.t_listes_contenu) + ', 'temp e_listes' + ); + + SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_listes_contenu + ', 'temp e_listes_contenu' + ); + + UPDATE e_listes + SET ok_liste = '1', ok_oid = t_listes.oid, ok_table_id = t_listes.table_id + FROM rh.t_listes + WHERE e_listes.code = t_listes.code + ; + + + DELETE + FROM rh.t_listes_contenu + WHERE liste_id IN (SELECT ok_oid FROM e_listes) + ; + + INSERT INTO rh.t_listes_contenu(liste_id, to_id) + SELECT ok_oid, to_id + FROM e_listes_contenu + JOIN e_listes ON e_listes.oid = e_listes_contenu.liste_id AND ok_liste = '1' + JOIN rh.t_listes_tables ON ok_table_id = t_listes_tables.oid AND t_listes_tables.code <> 'CPO' + ; + + + ]]> + + + + '''' AND + oid IN (SELECT classe_id FROM rh.t_classes_sections JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid) + ', 'temp e_classes' + ); + + + SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' + SELECT t_classes_sections.*, t_classes.code AS classe_code, 0::bigint AS ok_section_id, 0::bigint AS ok_classe_id, 0::bigint AS ok_table_id + FROM rh.t_classes_sections + JOIN rh.t_classes ON t_classes_sections.classe_id = t_classes.oid AND + t_classes.code <> '''' + ', 'temp e_classes_sections' + ); + + + SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' + SELECT * + FROM rh.t_classes_sections_elements + ', 'temp e_classes_sections_elements' + ); + + UPDATE e_classes + SET ok_classe = '1', ok_classe_id = t_classes.oid, ok_table_id = t_classes.table_id + FROM rh.t_classes + WHERE e_classes.code = t_classes.code + ; + + UPDATE e_classes_sections + SET ok_classe_id = e_classes.ok_classe_id, ok_table_id = e_classes.ok_table_id + FROM e_classes + WHERE e_classes_sections.classe_code = e_classes.code AND + ok_classe = '1' + ; + + UPDATE e_classes_sections + SET ok_section_id = t_classes_sections.oid + FROM rh.t_classes_sections + WHERE t_classes_sections.classe_id = e_classes_sections.ok_classe_id AND + e_classes_sections.code = t_classes_sections.code + ; + + DELETE + FROM rh.t_classes_sections_elements + WHERE section_id IN (SELECT oid FROM rh.t_classes_sections WHERE classe_id IN (SELECT ok_classe_id FROM e_classes)) + ; + + INSERT INTO rh.t_classes_sections_elements(section_id, to_id) + SELECT ok_section_id, to_id + FROM e_classes_sections_elements + JOIN e_classes_sections ON e_classes_sections.oid = e_classes_sections_elements.section_id AND ok_section_id <> 0 + JOIN rh.t_listes_tables ON ok_table_id = t_listes_tables.oid AND t_listes_tables.code <> 'CPO' + ; + + + ]]> + + + + + + + diff --git a/import_rh/iCTI_import_rh_META4.XML b/import_rh/iCTI_import_rh_META4.XML new file mode 100644 index 0000000..488c592 --- /dev/null +++ b/import_rh/iCTI_import_rh_META4.XML @@ -0,0 +1,1678 @@ + + + + + + = 1 then 'TC' else 'TP'||(sfr_etp::numeric * 100.0) end as type_temps_travail_code_original, + sfr_etp + from prod_meta4.sfr_h_hr_salaire + group by 1,2,3,4,5) + select + sfr_id_hr as mat, + case when row_number() over w = 1 then '1900-01-01'::date else sfr_dt_start end as date_debut, + (case when row_number() over wd = 1 then '2099-12-31'::date else lead(sfr_dt_start) over w - '1 day'::interval end)::date as date_fin, + * + from lite_roles + window w as (partition by sfr_id_hr order by sfr_dt_start), + wd as (partition by sfr_id_hr order by sfr_dt_start desc) + ; + + ]]> + + + 0). + with bulletins_fj_0 as ( + select + rownum, + max(date_fin - date_debut + 1) / max((base.cti_last_day(date_debut) - base.cti_first_day(date_debut) + 1.0)) as proratisation_jour, + sum(case when rub = 'sfr_nb_days_per_year' then base else 0 end) as sfr_nb_days_per_year, + sum(case when rub = 'cviva_coef_prorata_tp' then base else 0 end) as cviva_coef_prorata_tp, + sum(case when rub = 'sfr_base_sal_payslip' then base else 0 end) as sfr_base_sal_payslip, + sum(case when rub = 'sfr_base_sal_payslip' then mt_sal else 0 end) as sfr_base_sal_payslip_mt_sal + from w_hp_1 + where rub in ('sfr_nb_days_per_year', 'cviva_coef_prorata_tp', 'sfr_base_sal_payslip') + group by 1 + ) , bulletins_fj as ( + select + rownum, + cviva_coef_prorata_tp as heures_contrat + from bulletins_fj_0 + where 1=1 + and sfr_base_sal_payslip_mt_sal != 0 -- bulletins forfait jour ET ... + and sfr_base_sal_payslip = 0 -- ... ayant une base à 0 dans la rubrique standard des heures contrat. + ) + update w_hp_1 set + base = bulletins_fj.heures_contrat + from bulletins_fj + where 1=1 + and w_hp_1.rownum = bulletins_fj.rownum + and rub = 'sfr_base_sal_payslip' + ; + + -- Alimenter les cotisations séparées. + insert into w_hp_1 + select + w_hst_bul.cti_bul, + arr_rownum[1] as rownum, + sco_id_hr as mat, + sfr_ac_fund_retraite.sco_or_hr_period, + to_date(sco_dt_allocation, 'DD/MM/YYYY') as sco_dt_allocation, + to_date(sco_dt_payment, 'DD/MM/YYYY') as sco_dt_payment, + sco_pay_freq_alloc, + sco_pay_freq_paym, + id_currency, + to_date(sco_dt_start_slice, 'DD/MM/YYYY') as date_debut, + to_date(sco_dt_end_slice, 'DD/MM/YYYY') as date_fin, + sfr_etp, + lower(sfr_id_fund||'_'||sfr_id_cat_retraite||'_'||sfr_id_contribution_type||'_'||sfr_id_base_type) as rub, + sfr_name_contribution as rub_texte, + sfr_amount_base::numeric as base, + sfr_emp_part::numeric as tx_sal, + sfr_amount_employee::numeric as mt_sal, + sfr_comp_part::numeric as tx_pat, + sfr_amount_company::numeric as mt_pat + from prod_meta4.sfr_ac_fund_retraite + join w_hst_bul on 1=1 + and w_hst_bul.mat = sfr_ac_fund_retraite.sco_id_hr + and w_hst_bul.sco_or_hr_period = sfr_ac_fund_retraite.sco_or_hr_period + and w_hst_bul.date_debut = to_date(sfr_ac_fund_retraite.sco_dt_start_slice, 'DD/MM/YYYY') + and w_hst_bul.date_fin = to_date(sfr_ac_fund_retraite.sco_dt_end_slice, 'DD/MM/YYYY') + ; + + insert into w_hp_1 + select + w_hst_bul.cti_bul, + arr_rownum[1] as rownum, + sco_id_hr as mat, + sfr_ac_fund_prevoyance.sco_or_hr_period, + to_date(sco_dt_allocation, 'DD/MM/YYYY') as sco_dt_allocation, + to_date(sco_dt_payment, 'DD/MM/YYYY') as sco_dt_payment, + sco_pay_freq_alloc, + sco_pay_freq_paym, + id_currency, + to_date(sco_dt_start_slice, 'DD/MM/YYYY') as date_debut, + to_date(sco_dt_end_slice, 'DD/MM/YYYY') as date_fin, + sfr_etp, + lower(replace(sfr_id_fund, ' ', '_')||'_'||sfr_id_cat_prevoyance||'_'||sfr_id_contribution_type||'_'||sfr_id_base_type) as rub, + sfr_name_contribution as rub_texte, + sfr_amount_base::numeric as base, + sfr_emp_part::numeric as tx_sal, + sfr_amount_employee::numeric as mt_sal, + sfr_comp_part::numeric as tx_pat, + sfr_amount_company::numeric as mt_pat + from prod_meta4.sfr_ac_fund_prevoyance + join w_hst_bul on 1=1 + and w_hst_bul.mat = sfr_ac_fund_prevoyance.sco_id_hr + and w_hst_bul.sco_or_hr_period = sfr_ac_fund_prevoyance.sco_or_hr_period + and w_hst_bul.date_debut = to_date(sfr_ac_fund_prevoyance.sco_dt_start_slice, 'DD/MM/YYYY') + and w_hst_bul.date_fin = to_date(sfr_ac_fund_prevoyance.sco_dt_end_slice, 'DD/MM/YYYY') + ; + + -- Insertion des absences SS. + insert into w_hp_1 + select + w_hst_bul.cti_bul, + arr_rownum[1] as rownum, + std_id_hr as mat, + std_or_hr_period, + to_date(sco_dt_allocation, 'DD/MM/YYYY') as sco_dt_allocation, + to_date(sco_dt_payment, 'DD/MM/YYYY') as sco_dt_payment, + sco_pay_freq_alloc, + sco_pay_freq_paym, + 'EUR'::text as id_currency, + to_date(cfr_dt_start_slice, 'DD/MM/YYYY') as date_debut, + to_date(cfr_dt_end_slice, 'DD/MM/YYYY') as date_fin, + sfr_etp, + lower('a_'||sco_id_incidence) as rub, + 'Absence '||sco_id_incidence as rub_texte, + sfr_num_cal_days::numeric as base, -- sfr_num_working_hours n'est pas fiable + 0::numeric as tx_sal, + 0::numeric as mt_sal, + 0::numeric as tx_pat, + 0::numeric as mt_pat + from prod_meta4.sfr_h_detail_abs_ss + join w_hst_bul on 1=1 + and w_hst_bul.mat = sfr_h_detail_abs_ss.std_id_hr + and w_hst_bul.sco_or_hr_period = sfr_h_detail_abs_ss.std_or_hr_period + and w_hst_bul.date_debut = to_date(sfr_h_detail_abs_ss.cfr_dt_start_slice, 'DD/MM/YYYY') + and w_hst_bul.date_fin = to_date(sfr_h_detail_abs_ss.cfr_dt_end_slice, 'DD/MM/YYYY') + ; + + -- Insertion des absences + -- Déduction + insert into w_hp_1 + select + w_hst_bul.cti_bul, + arr_rownum[1] as rownum, + sfr_id_hr as mat, + sfr_or_hr_period, + to_date(sfr_dt_allocation, 'DD/MM/YYYY') as sco_dt_allocation, + to_date(sfr_dt_payment, 'DD/MM/YYYY') as sco_dt_payment, + sfr_pay_freq_alloc, + sfr_pay_freq_paym, + sfr_id_currency, + to_date(sfr_dt_start_slice, 'DD/MM/YYYY') as date_debut, + to_date(sfr_dt_end_slice, 'DD/MM/YYYY') as date_fin, + sfr_etp, + lower('a_'||sfr_id_entitlement) as rub, + 'Absence '||sfr_id_entitlement as rub_texte, + sfr_num_units_deduction::numeric as base, + sfr_rte_deduction::numeric as tx_sal, + sfr_amt_deduction::numeric * -1 as mt_sal, + 0::numeric as tx_pat, + 0::numeric as mt_pat + from prod_meta4.sfr_ac_hrp_absence + join w_hst_bul on 1=1 + and w_hst_bul.mat = sfr_ac_hrp_absence.sfr_id_hr + and w_hst_bul.sco_or_hr_period = sfr_ac_hrp_absence.sfr_or_hr_period + and base.cti_overlaps(w_hst_bul.date_debut, w_hst_bul.date_fin, to_date(sfr_ac_hrp_absence.sfr_dt_start_slice, 'DD/MM/YYYY'), to_date(sfr_ac_hrp_absence.sfr_dt_end_slice, 'DD/MM/YYYY')) + -- Ca ne marche pas : + -- and w_hst_bul.date_debut = to_date(sfr_ac_hrp_absence.sfr_dt_start_slice, 'DD/MM/YYYY') + -- and w_hst_bul.date_fin = to_date(sfr_ac_hrp_absence.sfr_dt_end_slice, 'DD/MM/YYYY') + where sfr_amt_deduction::numeric != 0 + ; + + -- et Paiements. + insert into w_hp_1 + select + w_hst_bul.cti_bul, + arr_rownum[1] as rownum, + sfr_id_hr as mat, + sfr_or_hr_period, + to_date(sfr_dt_allocation, 'DD/MM/YYYY') as sco_dt_allocation, + to_date(sfr_dt_payment, 'DD/MM/YYYY') as sco_dt_payment, + sfr_pay_freq_alloc, + sfr_pay_freq_paym, + sfr_id_currency, + to_date(sfr_dt_start_slice, 'DD/MM/YYYY') as date_debut, + to_date(sfr_dt_end_slice, 'DD/MM/YYYY') as date_fin, + sfr_etp, + lower('p_'||sfr_id_entitlement) as rub, + 'Paiement '||sfr_id_entitlement as rub_texte, + sfr_num_units_payment::numeric as base, + sfr_rte_payment::numeric as tx_sal, + sfr_amt_payment::numeric as mt_sal, + 0::numeric as tx_pat, + 0::numeric as mt_pat + from prod_meta4.sfr_ac_hrp_absence + join w_hst_bul on 1=1 + and w_hst_bul.mat = sfr_ac_hrp_absence.sfr_id_hr + and w_hst_bul.sco_or_hr_period = sfr_ac_hrp_absence.sfr_or_hr_period + and base.cti_overlaps(w_hst_bul.date_debut, w_hst_bul.date_fin, to_date(sfr_ac_hrp_absence.sfr_dt_start_slice, 'DD/MM/YYYY'), to_date(sfr_ac_hrp_absence.sfr_dt_end_slice, 'DD/MM/YYYY')) + -- Ca ne marche pas : + -- and w_hst_bul.date_debut = to_date(sfr_ac_hrp_absence.sfr_dt_start_slice, 'DD/MM/YYYY') + -- and w_hst_bul.date_fin = to_date(sfr_ac_hrp_absence.sfr_dt_end_slice, 'DD/MM/YYYY') + where sfr_amt_payment::numeric != 0 + ; + + -- Contrats. + DROP TABLE IF EXISTS w_hst_contrat + ; + + CREATE TEMP TABLE w_hst_contrat AS + SELECT + cti_cnt, + std_id_hr as mat, + std_or_hr_period, + to_date(std_dt_start, 'DD/MM/YYYY') as date_debut, + case when row_number() over w != 1 and to_date(std_dt_end, 'DD/MM/YYYY') = '4000-01-01'::date + then lag(to_date(std_dt_start, 'DD/MM/YYYY')) over w - '1 day'::interval + else coalesce(nullif(to_date(std_dt_end, 'DD/MM/YYYY'), '4000-01-01'::date), '2099-12-31'::date) + end as date_fin, + std_id_cont_type, + std_id_break_reason + from w_std_int_work_contract + window w as (partition by std_id_hr order by to_date(std_dt_start, 'DD/MM/YYYY') desc) + ; + + DROP TABLE IF EXISTS w_hst_qua + ; + + CREATE TEMP TABLE w_hst_qua AS + with lite_roles as ( + select + sco_id_hr, + sco_or_hr_role, + sco_or_hr_period, + to_date(sco_dt_start, 'DD/MM/YYYY') as sco_dt_start, + substr(md5(sco_n_rolefra), 1, 5) as qualification_code_original + from prod_meta4.sco_hr_role + group by 1,2,3,4,5) + select + sco_id_hr as mat, + case when row_number() over w = 1 then '1900-01-01'::date else sco_dt_start end as date_debut, + (case when row_number() over wd = 1 then '2099-12-31'::date else lead(sco_dt_start) over w - '1 day'::interval end)::date as date_fin, + * + from lite_roles + window w as (partition by sco_id_hr order by sco_dt_start), + wd as (partition by sco_id_hr order by sco_dt_start desc) + ; + + DROP TABLE IF EXISTS w_hst_ser + ; + + CREATE TEMP TABLE w_hst_ser AS + with lite_roles as ( + select + sco_id_hr, + sco_or_hr_role, + sco_or_hr_period, + to_date(sco_dt_start_slice, 'DD/MM/YYYY') as sco_dt_start_slice, + sfr_id_work_unit as service_code_original + from prod_meta4.sco_ac_hr_role + group by 1,2,3,4,5) + select + sco_id_hr as mat, + case when row_number() over w = 1 then '1900-01-01'::date else sco_dt_start_slice end as date_debut, + (case when row_number() over wd = 1 then '2099-12-31'::date else lead(sco_dt_start_slice) over w - '1 day'::interval end)::date as date_fin, + * + from lite_roles + window w as (partition by sco_id_hr order by sco_dt_start_slice), + wd as (partition by sco_id_hr order by sco_dt_start_slice desc) + ; + + DROP TABLE IF EXISTS w_hst_sta + ; + + CREATE TEMP TABLE w_hst_sta AS + with lite_roles as ( + select + sfr_id_hr, + sfr_or_hr_role, + to_date(sfr_dt_start, 'DD/MM/YYYY') as sfr_dt_start, + sfr_id_cat_lab_agree as statut_code_original + from prod_meta4.sfr_h_hr_job_classification + group by 1,2,3,4) + select + sfr_id_hr as mat, + case when row_number() over w = 1 then '1900-01-01'::date else sfr_dt_start end as date_debut, + (case when row_number() over wd = 1 then '2099-12-31'::date else lead(sfr_dt_start) over w - '1 day'::interval end)::date as date_fin, + * + from lite_roles + window w as (partition by sfr_id_hr order by sfr_dt_start), + wd as (partition by sfr_id_hr order by sfr_dt_start desc) + ; + + -- Limites salariés. + DROP TABLE IF EXISTS w_lim_sal + ; + + CREATE TEMP TABLE w_lim_sal AS + select + mat, + min(date_debut) as date_debut, + max(date_fin) as date_fin + from ( + select + mat, + min(date_debut) as date_debut, + coalesce(nullif(max(date_fin), '2099-12-31'::date), max(subq.ec)) as date_fin -- 2099-12-31 correspond à "contrat en cours" => on met le mois de paie en cours (et surtout pas current_date). + from w_hst_contrat + join (select max(date_fin) as ec from w_hst_bul) as subq on true + group by 1 + UNION ALL + select + mat, + min(date_debut) as date_debut, + max(date_fin) as date_fin + from w_hst_bul + group by 1 + ) as subq + group by 1 + ; + + CREATE INDEX i_lim_sal_mat ON w_lim_sal USING btree(mat); + CREATE INDEX i_lim_sal_dates ON w_lim_sal USING btree(date_debut, date_fin); + + DROP TABLE IF EXISTS w_evt_mois + ; + + CREATE TEMP TABLE w_evt_mois AS + with ValidDates as ( + select mat, date_debut::date as date from w_hst_contrat + union select mat, date_fin::date as date from w_hst_contrat + union select mat, date_debut::date as date from w_hst_bul + union select mat, date_fin::date as date from w_hst_bul + union select mat, date_debut::date as date from w_hst_qua + union select mat, date_fin::date as date from w_hst_qua + union select mat, date_debut::date as date from w_hst_ser + union select mat, date_fin::date as date from w_hst_ser + union select mat, date_debut::date as date from w_hst_sta + union select mat, date_fin::date as date from w_hst_sta + union select mat, date_debut::date as date from w_hst_ttt + union select mat, date_fin::date as date from w_hst_ttt + ) + , ValidDateRanges1 as ( + select *, case when lead(date) over w = date + '1 day'::interval then false else true end as correct, + (case when lead(date) over w = date + '1 day'::interval then null else (date + '1 day'::interval) end)::date as date_debut, + (case when lead(date) over w = date + '1 day'::interval then null else (lead(date) over w - '1 day'::interval) end)::date as date_fin + from ValidDates + window w as (partition by mat order by Date) + ) + , ValidDateRanges as ( + select mat, date_debut as ValidFrom, date_fin as ValidTo from ValidDateRanges1 where correct + union + select mat, date, date from ValidDates + ) + , detail as ( + select + E.mat, + OU.cti_cnt, + L.cti_bul, + --null::text as cti_bul, + w_hst_qua.qualification_code_original, + w_hst_ser.service_code_original, + w_hst_sta.statut_code_original, + w_hst_ttt.type_temps_travail_code_original, + D.ValidFrom, + D.ValidTo, + e.date_fin as max_date + from w_lim_sal E + join ValidDateRanges D on E.mat=D.mat and base.cti_overlaps(E.date_debut::date, E.date_fin::date, D.ValidFrom, D.ValidTo) + left join w_hst_contrat OU on true + and OU.mat=D.mat + and base.cti_overlaps(OU.date_debut::date, OU.date_fin::date, D.ValidFrom, D.ValidTo) + left join w_hst_bul L on true + and L.mat=D.mat + and base.cti_overlaps(L.date_debut::date, L.date_fin::date, D.ValidFrom, D.ValidTo) + left join w_hst_qua on true + and w_hst_qua.mat=D.mat + and base.cti_overlaps(w_hst_qua.date_debut::date, w_hst_qua.date_fin::date, D.ValidFrom, D.ValidTo) + left join w_hst_ser on true + and w_hst_ser.mat=D.mat + and base.cti_overlaps(w_hst_ser.date_debut::date, w_hst_ser.date_fin::date, D.ValidFrom, D.ValidTo) + left join w_hst_sta on true + and w_hst_sta.mat=D.mat + and base.cti_overlaps(w_hst_sta.date_debut::date, w_hst_sta.date_fin::date, D.ValidFrom, D.ValidTo) + left join w_hst_ttt on true + and w_hst_ttt.mat=D.mat + and base.cti_overlaps(w_hst_ttt.date_debut::date, w_hst_ttt.date_fin::date, D.ValidFrom, D.ValidTo) + where false + or cti_cnt is not null + or cti_bul is not null) + , detail2 as ( + select + mat, + cti_cnt, -- contrat + cti_bul, -- bulletin. + qualification_code_original, + service_code_original, + statut_code_original, + type_temps_travail_code_original, + mois, + min(greatest(validfrom, date_debut)) as date_debut, + max(least(validto, date_fin)) as date_fin, + (max(least(validto, date_fin)) - min(greatest(validfrom, date_debut)) + 1)::numeric / (max(date_fin) - min(date_debut) + 1)::numeric as ratio_temps + from detail + left join base.p_calendrier_mois on true + and base.cti_overlaps(validfrom, validto, date_debut, date_fin) + and date_fin <= max_date + group by 1,2,3,4,5,6,7,8) + select + mat, + cti_cnt, -- contrat + coalesce(cti_cnt, + (max(case when cti_cnt is null then null else ARRAY[extract(epoch from date_fin)::numeric, cti_cnt] end) over wb)[2], -- sinon on prend la valeur renseignée la plus proche dans le passé + (min(case when cti_cnt is null then null else ARRAY[extract(epoch from date_fin)::numeric, cti_cnt] end) over wf)[2], -- sinon on prend la valeur renseignée la plus proche dans le futur + null -- sinon on prend null + ) as cti_cnt_all, + cti_bul, -- bulletin. + qualification_code_original, + service_code_original, + statut_code_original, + type_temps_travail_code_original, + mois, + date_debut, + date_fin, + ratio_temps + from detail2 + window wb as (PARTITION BY mat ORDER BY date_fin rows unbounded preceding), -- sélectionne les lignes précédentes + wf as (PARTITION BY mat ORDER BY date_fin rows between current row and unbounded following) -- sélectionne les lignes suivantes + ; + + ]]> + + + = 1 then 'TC' else 'TP'||(sfr_etp::numeric * 100.0) end, + case when sfr_etp >= 1 then 'TC' else 'TP'||(sfr_etp::numeric * 100.0) end, + case when sfr_etp >= 1 then 'Temps Complet' else 'Temps Partiel '||(sfr_etp::numeric * 100.0)||' %' end, + substr(case when sfr_etp >= 1 then 'Temps Complet' else 'Temps Partiel '||(sfr_etp::numeric * 100.0)||' %' end, 1, 50) + FROM prod_meta4.sfr_h_hr_salaire + WHERE case when sfr_etp >= 1 then 'TC' else 'TP'||(sfr_etp::numeric * 100.0) end NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + GROUP BY 1,2,3,4 + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_NIBELIS.XML b/import_rh/iCTI_import_rh_NIBELIS.XML new file mode 100644 index 0000000..8dc9d2d --- /dev/null +++ b/import_rh/iCTI_import_rh_NIBELIS.XML @@ -0,0 +1,1854 @@ + + + + + '' OR w_HIST_RUBR_SALA_T.ID_SALA IS NOT NULL) + and id_etab in (select id_etab from w_ets group by 1) + and hist_salarie.id_sala not in (select id_sala from w_sal2excl) -- suppression des salariés de démo. + group by 1,2,3,4,5,6) + select + id_etab, + id_sala, + matr, + ncnt, + ncnt_ori, + date_debu_cont, + coalesce(date_fin_cont, lead(date_debu_cont) over w - '1 day'::interval, '2099-12-31'::date)::date as date_fin_cont, + sala_supp, + case when date_anci > date_debu_cont then date_debu_cont else date_anci end as date_anci + from cnt_agg + window w as (partition by id_etab, id_sala order by date_debu_cont) + ; + + DROP TABLE IF EXISTS w_cnt_bul + ; + + CREATE TEMP TABLE w_cnt_bul AS + with histo_rub as ( + SELECT + id_etab_rub, + id_sala_rub, + id_empl_rub, + peri_rub + FROM + (select + id_etab as id_etab_rub, + id_sala as id_sala_rub, + id_empl as id_empl_rub, + peri as peri_rub, + COUNT(*) OVER (PARTITION BY id_sala, id_etab, peri) AS nb_lignes + from MATERIAL_HIST_RUBR_SALA_T HIST_RUBR_SALA_T + group by 1,2,3,4 + ) AS subview + -- Permet d'éviter le problème de rubriques en doubles dans certains cas + WHERE subview.nb_lignes = 1 OR (subview.nb_lignes > 1 AND id_empl_rub IS NOT NULL) + ) + , w_emplois as ( + select + trim(id_empl) as id_empl, + trim(libe) as libe, + trim(code_inse) as code_inse + from prod_nibelis.emplois + where id_soci::bigint = (select id_soci from w_ets limit 1) + group by 1,2,3) + , w_coeff as ( + select + id_sala as coeff_id_sala, + peri as coeff_peri, + coalesce(vale, '0') as coeff + from MATERIAL_HIST_CONS_SALA hist_cons_sala + where code_cons = 'COEFFIC' + group by 1,2,3) + select + hist_salarie.id_etab::bigint, + hist_salarie.id_sala::bigint, + trim(hist_salarie.matr) as matr, + trim(hist_salarie.matr)||'-'::text||to_char(to_date(hist_salarie.date_debu_cont,'DD/MM/YYYY'), 'YYYYMMDD') as ncnt, + trim(hist_salarie.id_etab)||'-'::text||trim(hist_salarie.id_sala)||'-'::text||trim(hist_salarie.matr)||'-'::text||to_char(to_date(hist_salarie.date_debu_cont,'DD/MM/YYYY'), 'YYYYMMDD') as ncnt_ori, + w_cnt.date_debu_cont, + w_cnt.date_fin_cont, + w_cnt.date_anci, + hist_salarie.peri::date, + to_char(hist_salarie.peri::date, 'YYYYMM')::int as mois_paie, + trim(hist_salarie.nume_secu_soci) as nume_secu_soci, + trim(hist_salarie.cle_secu_soci) as cle_secu_soci, + trim(hist_salarie.titr) as titr, + trim(hist_salarie.nom) as nom, + trim(hist_salarie.nom_jeun_fill) as nom_jeun_fill, + trim(hist_salarie.pren) as pren, + trim(hist_salarie.code_post) as code_post, + trim(hist_salarie.nati) as nati, + hist_salarie.date_nais::date, + trim(hist_salarie.situ_fami) as situ_fami, + hist_salarie.date_emba::date, + trim(hist_salarie.code_moti_recr_cdd) as code_moti_recr_cdd, + coalesce(hist_salarie.date_depa::date, '2099-12-31'::date) as date_depa, + trim(hist_salarie.moti_depa) as moti_depa, + w_emplois.id_empl as id_empl, + w_emplois.code_inse as code_inse, + trim(hist_salarie.cate_prof) as cate_prof, + trim(hist_salarie.natu_cont) as natu_cont, + trim(hist_salarie.serv) as serv, + trim(hist_salarie.equi) as equi, + trim(hist_salarie.regr) as regr, + trim(hist_salarie.cate_conv) as cate_conv, + trim(hist_salarie.fili_conv) as fili_conv, + REPLACE(hist_salarie.hora_mens_fich, ',', '.')::numeric AS hora_mens_fich, + w_coeff.coeff, + case when replace(hist_salarie.hora_mens_fich, ',', '.')::numeric = 0 then 1.0 else replace(hist_salarie.hora_mens_fich, ',', '.')::numeric / 151.67 end as ratio_theo, + '':: text as ttt, + '':: text as ttt_libelle, + '':: text as ttt_libelle_court, + array_remove(ARRAY[ + CASE WHEN (hist_salarie.code_anal IS NOT NULL AND hist_salarie.code_anal != '') THEN hist_salarie.code_anal ELSE 'NO_CODE_ANAL' END, + CASE WHEN (hist_salarie.code_anal_axe2 IS NOT NULL AND hist_salarie.code_anal_axe2 != '') THEN hist_salarie.code_anal_axe2 ELSE 'NO_CODE_ANAL' END, + CASE WHEN (hist_salarie.code_anal_axe3 IS NOT NULL AND hist_salarie.code_anal_axe3 != '') THEN hist_salarie.code_anal_axe3 ELSE 'NO_CODE_ANAL' END, + CASE WHEN (hist_salarie.code_anal_axe4 IS NOT NULL AND hist_salarie.code_anal_axe4 != '') THEN hist_salarie.code_anal_axe4 ELSE 'NO_CODE_ANAL' END, + CASE + WHEN + (hist_salarie.code_anal IS NULL OR hist_salarie.code_anal = '') AND + (hist_salarie.code_anal_axe2 IS NULL OR hist_salarie.code_anal = '') AND + (hist_salarie.code_anal_axe3 IS NULL OR hist_salarie.code_anal = '') AND + (hist_salarie.code_anal_axe4 IS NULL OR hist_salarie.code_anal = '') + THEN chr(1)||'*' + ELSE 'NO_CODE_ANAL' + END + ], 'NO_CODE_ANAL') AS codes_anal, + array_remove(ARRAY[ + CASE WHEN (hist_salarie.code_anal IS NOT NULL AND hist_salarie.code_anal != '') THEN REPLACE(hist_salarie.pour_affe_anal, ',', '.') ELSE 'NO_CODE_ANAL' END, + CASE WHEN (hist_salarie.code_anal_axe2 IS NOT NULL AND hist_salarie.code_anal_axe2 != '') THEN REPLACE(hist_salarie.pour_affe_anal_axe2, ',', '.') ELSE 'NO_CODE_ANAL' END, + CASE WHEN (hist_salarie.code_anal_axe3 IS NOT NULL AND hist_salarie.code_anal_axe3 != '') THEN REPLACE(hist_salarie.pour_affe_anal_axe3, ',', '.') ELSE 'NO_CODE_ANAL' END, + CASE WHEN (hist_salarie.code_anal_axe4 IS NOT NULL AND hist_salarie.code_anal_axe4 != '') THEN REPLACE(hist_salarie.pour_affe_anal_axe4, ',', '.') ELSE 'NO_CODE_ANAL' END, + CASE + WHEN + (hist_salarie.code_anal IS NULL OR hist_salarie.code_anal = '') AND + (hist_salarie.code_anal_axe2 IS NULL OR hist_salarie.code_anal = '') AND + (hist_salarie.code_anal_axe3 IS NULL OR hist_salarie.code_anal = '') AND + (hist_salarie.code_anal_axe4 IS NULL OR hist_salarie.code_anal = '') + THEN '100' + ELSE 'NO_CODE_ANAL' + END + ], 'NO_CODE_ANAL') AS codes_anal_ratio + from w_HIST_SALARIE AS HIST_SALARIE + join w_cnt on w_cnt.ncnt_ori = trim(hist_salarie.id_etab)||'-'::text||trim(hist_salarie.id_sala)||'-'::text||trim(hist_salarie.matr)||'-'::text||to_char(to_date(hist_salarie.date_debu_cont,'DD/MM/YYYY'), 'YYYYMMDD') + left join histo_rub on true + and histo_rub.id_etab_rub = hist_salarie.id_etab + and histo_rub.id_sala_rub = hist_salarie.id_sala + and histo_rub.peri_rub = hist_salarie.peri + left join w_emplois on w_emplois.id_empl = histo_rub.id_empl_rub + left join w_coeff on true + and w_coeff.coeff_id_sala = hist_salarie.id_sala + and w_coeff.coeff_peri = hist_salarie.peri + where true + and hist_salarie.id_etab in (select id_etab from w_ets group by 1) + and hist_salarie.id_sala not in (select id_sala from w_sal2excl) -- suppression des salariés de démo. + ; + + update w_cnt_bul set + ttt = case when ratio_theo = 1 then 'TC100' else 'TP'||lpad((ratio_theo * 100)::int::text, 3, '0') end, + ttt_libelle = case when ratio_theo = 1 then 'Temps Complet' else 'Temps Partiel '||lpad((ratio_theo * 100)::int::text, 3, '0')|| ' %' end, + ttt_libelle_court = case when ratio_theo = 1 then 'TC' else 'TP '||lpad((ratio_theo * 100)::int::text, 3, '0')|| ' %' end + ; + + DROP TABLE IF EXISTS w_hp_0 + ; + + CREATE TEMP TABLE w_hp_0 AS + select + id_etab::bigint, + id_sala::bigint, + trim(HIST_RUBR_SALA_T.id_rubr) as id_rubr, + peri::date, + to_char(peri::date, 'YYYYMM')::int as mois_paie, + -- cate_prof, + -- serv, + id_modbull::bigint, + id_cais::bigint, + neut_code, + round(replace(nomb, ',', '.')::numeric, 2) as nombre, + round(replace(base, ',', '.')::numeric, 2) as base, + replace(taux_sala, ',', '.')::numeric as tx_sal, + round(replace(mont_sala, ',', '.')::numeric, 2) as mt_sal, + replace(taux_patr, ',', '.')::numeric as tx_pat, + round(replace(mont_patr, ',', '.')::numeric, 2) as mt_pat + from MATERIAL_HIST_RUBR_SALA_T HIST_RUBR_SALA_T + left join rh.t_rubriques on t_rubriques.code_original = HIST_RUBR_SALA_T.id_rubr + where true + and id_etab in (select id_etab from w_ets group by 1) + and id_sala not in (select id_sala from w_sal2excl) -- suppression des salariés de démo. + and (false + or t_rubriques.p_cumul -- il faut remonter toutes les rubriques de totalisation, même celles à 0. + or replace(nomb, ',', '.')::numeric != 0 + or replace(base, ',', '.')::numeric != 0 + or replace(mont_sala, ',', '.')::numeric != 0 + or replace(mont_patr, ',', '.')::numeric != 0) + ; + + with ets_sal as ( + select + id_etab, + id_sala as ets_id_sala, + peri as ets_peri + from w_hp_0 + group by 1,2,3) + INSERT INTO w_hp_0 + select + id_etab::bigint, + id_sala::bigint, + code_cons as id_rubr, + peri::date, + to_char(peri::date, 'YYYYMM')::int as mois_paie, + -- cate_prof, + -- serv, + 0, + 0, + '', + round(replace(vale, ',', '.')::numeric, 2) as nombre, + round(replace(vale, ',', '.')::numeric, 2) as base, + 0 as tx_sal, + 0 as mt_sal, + 0 as tx_pat, + 0 as mt_pat + from MATERIAL_HIST_CONS_SALA hist_cons_sala + join ets_sal on true + and ets_sal.ets_id_sala = hist_cons_sala.id_sala::bigint + and ets_sal.ets_peri = hist_cons_sala.peri::date + where code_cons in ('PRESENCE', 'TOTALH', 'TOTALHTRAV') + ; + + ]]> + + + + '1' + ; + + -- Màj des Entreprises. + INSERT INTO rh.t_entreprises(code_original, code, texte, texte_court) + select + id_soci, + MAX(substr(sire, 1, 9)), + MAX(nom), + MAX(substr(nom, 1, 50)) + from prod_nibelis.etablissement_t + where 1=1 + AND id_soci NOT IN (SELECT code_original FROM rh.t_entreprises WHERE code_original IS NOT NULL) + AND id_etab in (select id_etab from w_ets group by 1) + GROUP BY 1 + ; + + -- Màj des Etablissements. + INSERT INTO rh.t_etablissements(code_original, code, texte, texte_court, entreprise_id) + SELECT + id_etab, + sire, + nom, + substr(nom, 1, 50), + t_entreprises.oid + from prod_nibelis.etablissement_t + JOIN rh.t_entreprises ON t_entreprises.code_original = etablissement_t.id_soci + where 1=1 + AND id_etab NOT IN (SELECT code_original FROM rh.t_etablissements WHERE code_original IS NOT NULL) + and id_etab in (select id_etab from w_ets group by 1) + ; + + -- Màj des catégories socio-professionnelles + INSERT INTO rh.t_categories_socio_professionnelle (code_original, code, texte, texte_court) + SELECT lower(code_inse), lower(code_inse), lower(code_inse), substr(lower(code_inse), 1, 50) + FROM prod_nibelis.emplois + WHERE true + and lower(code_inse) NOT IN (SELECT code_original FROM rh.t_categories_socio_professionnelle WHERE code_original IS NOT NULL) + and id_soci::bigint = (select id_soci from w_ets limit 1) + GROUP BY 1,2,3,4 + ; + + -- Màj des sections analytiques comptables. + INSERT INTO rh.t_sections_analytiques(code_original, code, texte, texte_court) + SELECT code_anal, code_anal, libe_code_anal, substr(libe_code_anal, 1, 50) + FROM prod_nibelis.code_analytique + WHERE code_anal NOT IN (SELECT code_original FROM rh.t_sections_analytiques WHERE code_original IS NOT NULL) + ; + + -- Màj des sections analytiques paie. + INSERT INTO rh.t_sections_analytiques_paie(code_original, code, texte, texte_court) + SELECT code_anal, code_anal, libe_code_anal, substr(libe_code_anal, 1, 50) + FROM prod_nibelis.code_analytique + WHERE code_anal NOT IN (SELECT code_original FROM rh.t_sections_analytiques_paie WHERE code_original IS NOT NULL) + ; + + -- Màj des motifs de début de contrat. + INSERT INTO rh.t_motifs_debut_contrat(code_original, code, texte, texte_court) + SELECT code_moti_recr_cdd, code_moti_recr_cdd, code_moti_recr_cdd, substr(code_moti_recr_cdd, 1, 50) + FROM w_cnt_bul + WHERE code_moti_recr_cdd NOT IN (SELECT code_original FROM rh.t_motifs_debut_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des motifs de fin de contrat. + INSERT INTO rh.t_motifs_fin_contrat(code_original, code, texte, texte_court) + SELECT moti_depa, moti_depa, moti_depa, substr(moti_depa, 1, 50) + FROM w_cnt_bul + WHERE moti_depa NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des nationalités. + INSERT INTO rh.t_nationalites(code_original, code, texte, texte_court) + SELECT nati, nati, nati, substr(nati, 1, 50) + FROM w_cnt_bul + WHERE nati NOT IN (SELECT code_original FROM rh.t_nationalites WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des qualifications + INSERT INTO rh.t_qualifications(code_original, code, texte, texte_court) + SELECT id_empl, id_empl, libe, substr(libe, 1, 50) + FROM prod_nibelis.emplois + WHERE true + and id_empl NOT IN (SELECT code_original FROM rh.t_qualifications WHERE code_original IS NOT NULL) + and id_soci::bigint = (select id_soci from w_ets limit 1) + GROUP BY 1,2,3,4 + ; + + -- Rubriques + DROP TABLE IF EXISTS w_RUBRIQUE_HIST; + CREATE TEMP TABLE w_RUBRIQUE_HIST AS + SELECT ID_RUBR, + MAX(CODE_RUBR) AS CODE_RUBR, + MAX(LIBELLE) AS LIBELLE, + MAX(base.cti_to_number(CODE_RUBR)) AS ORDR + FROM MATERIAL_HIST_RUBR_SALA_T HIST_RUBR_SALA_T + GROUP BY 1 + ; + + INSERT INTO w_RUBRIQUE_HIST + SELECT + CODE_CONS, + CODE_CONS, + CODE_CONS, + -1 + FROM MATERIAL_HIST_CONS_SALA HIST_CONS_SALA + WHERE CODE_CONS IN ('PRESENCE', 'TOTALH', 'TOTALHTRAV') + GROUP BY 1 + ; + + UPDATE rh.t_rubriques SET + code = CODE_RUBR, + texte = LIBELLE, + texte_court = substr(LIBELLE, 1, 50) + FROM w_RUBRIQUE_HIST + WHERE t_rubriques.code_original = ID_RUBR AND + ( + code IS DISTINCT FROM CODE_RUBR OR + texte IS DISTINCT FROM LIBELLE OR + texte_court IS DISTINCT FROM substr(LIBELLE, 1, 50) + ) + ; + + INSERT INTO rh.t_rubriques(code_original, code, texte, texte_court, rang_edition) + SELECT + ID_RUBR, + CODE_RUBR, + LIBELLE, + substr(LIBELLE, 1, 50), + ORDR + FROM w_RUBRIQUE_HIST + WHERE ID_RUBR NOT IN (SELECT code_original FROM rh.t_rubriques WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4,5 + ; + + + -- Màj des situations de famille + INSERT INTO rh.t_situations_famille(code_original, code, texte, texte_court) + SELECT situ_fami, situ_fami, situ_fami, substr(situ_fami,1,50) + FROM w_cnt_bul + WHERE situ_fami NOT IN (SELECT code_original FROM rh.t_situations_famille WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code_original, code, texte, texte_court) + SELECT natu_cont, natu_cont, natu_cont, substr(natu_cont, 1, 50) + FROM w_cnt_bul + WHERE natu_cont NOT IN (SELECT code_original FROM rh.t_types_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + SELECT cate_prof, cate_prof, cate_prof, substr(cate_prof, 1, 50) + FROM w_cnt_bul + WHERE cate_prof NOT IN (SELECT code_original FROM rh.t_statuts WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + select ttt, ttt, ttt_libelle, ttt_libelle_court + from w_cnt_bul + where ttt NOT IN (SELECT code_original FROM rh.t_types_temps_travail WHERE code_original IS NOT NULL) + group by 1,2,3,4 + ; + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + SELECT serv, serv, serv, substr(serv, 1, 50) + FROM w_cnt_bul + WHERE serv NOT IN (SELECT code_original FROM rh.t_services WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des types horaires. + INSERT INTO rh.t_types_horaire(code_original, code, texte, texte_court) + SELECT equi, substr(equi,1,30), substr(equi,1,255), substr(equi, 1, 50) + FROM w_cnt_bul + WHERE equi NOT IN (SELECT code_original FROM rh.t_types_horaire WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des codes emploi + INSERT INTO rh.t_codes_emploi(code_original, code, texte, texte_court) + SELECT regr, regr, regr, substr(regr, 1, 50) + FROM w_cnt_bul + WHERE regr NOT IN (SELECT code_original FROM rh.t_codes_emploi WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT cate_conv, cate_conv, cate_conv, substr(cate_conv, 1, 50) + FROM w_cnt_bul + WHERE cate_conv NOT IN (SELECT code_original FROM rh.t_grilles_groupes WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des grilles + INSERT INTO rh.t_grilles(code_original, code, texte, texte_court) + SELECT fili_conv, fili_conv, fili_conv, substr(fili_conv, 1, 50) + FROM w_cnt_bul + WHERE fili_conv NOT IN (SELECT code_original FROM rh.t_grilles WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des spécialités (coefficient nibélis). + INSERT INTO rh.t_specialites(code_original, code, texte, texte_court) + SELECT coeff, coeff, coeff, substr(coeff, 1, 50) + FROM w_cnt_bul + WHERE coeff NOT IN (SELECT code_original FROM rh.t_specialites WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + = rhp('rhprovider_start')::date + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié méme s'il n'y a rien. + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer) + ; + + ]]> + + + = to_char(rhp('rhprovider_start')::date, 'YYYYMM')::int + GROUP BY 1,2,3 + ; + + ]]> + + + + + + 1 AND sum(ratio_theo) <> 0 + ) AS subview + WHERE w_profil_contrat_mois_anal.contrat_mois_id = subview.contrat_mois_id + ; + + UPDATE w_profil_contrat_mois_anal + SET ratio_theo = ratio_corr + FROM + ( + SELECT contrat_mois_id, sum(ratio_theo), base.cti_division(1,count(*)) AS ratio_corr + FROM w_profil_contrat_mois_anal + GROUP BY 1 + HAVING sum(ratio_theo) = 0 + ) AS subview + WHERE w_profil_contrat_mois_anal.contrat_mois_id = subview.contrat_mois_id + ; + + -- Alimentation des profils simultanés. + TRUNCATE rh.p_profil_contrat_mois + ; + + INSERT INTO rh.p_profil_contrat_mois ( + profil_id, + contrat_mois_id, + salarie_id, + ratio, + mois) + SELECT + w_profil_contrat_mois_anal.profil_id, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.salarie_id, + w_profil_contrat_mois_anal.ratio_theo AS ratio, + p_contrats_mois.mois_activite + FROM rh.p_contrats_mois + JOIN w_profil_contrat_mois_anal ON w_profil_contrat_mois_anal.contrat_mois_id = p_contrats_mois.oid + GROUP BY 1,2,3,4,5 + ; + + ]]> + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/import_rh/iCTI_import_rh_OCTIME.XML b/import_rh/iCTI_import_rh_OCTIME.XML new file mode 100644 index 0000000..01c2a41 --- /dev/null +++ b/import_rh/iCTI_import_rh_OCTIME.XML @@ -0,0 +1,426 @@ + + + + + + + + + + + = '2014-01-01'::date + GROUP BY 1,2,3 + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_PEGASE.XML b/import_rh/iCTI_import_rh_PEGASE.XML new file mode 100644 index 0000000..a3b130b --- /dev/null +++ b/import_rh/iCTI_import_rh_PEGASE.XML @@ -0,0 +1,1323 @@ + + + + + temp.x_) * + ************/ + + -- Création d'une table temp des établissements pour faciliter les futures jointures. + DROP TABLE IF EXISTS w_ets + ; + + CREATE TEMP TABLE w_ets AS + SELECT + societe.idsociete, + societe.codsociete, + etablissements.codetab, + MAX(numsiren) as siren, + MAX(numsiren||nic) as siret, + MAX(nomsociete) as nomsociete, + MAX(nometab) as nometab + FROM prod_pegase.etablissements + JOIN prod_pegase.societe ON societe.idsociete = etablissements.idsociete + WHERE 1=1 + and nullif(trim(etablissements.codetab), '') is not null + and (1!=1 + OR numsiren IN (SELECT rhp_in('siren')) -- Soit un ou plusieurs SIREN ont été défini, + OR numsiren||nic IN (SELECT rhp_in('siren')) -- et/ou soit un ou plusieurs SIRET, + OR societe.codsociete IN (SELECT rhp_in('siren')) -- et/ou soit un ou plusieurs codes entreprise. + OR etablissements.codetab IN (SELECT rhp_in('siren'))) -- et/ou soit un ou plusieurs codes établissement. + GROUP BY 1,2,3 + ; + + -- Identification des Entreprises. + DROP TABLE IF EXISTS temp.x_ref_ent + ; + + CREATE TABLE temp.x_ref_ent AS + SELECT + idsociete as code_original, + codsociete as code, + MAX(nomsociete) as texte, + MAX(siren) as siren, + null::text as texte_court + FROM w_ets + GROUP BY 1,2 + ; + + -- Identification des Etablissements. + DROP TABLE IF EXISTS temp.x_ref_ets + ; + + CREATE TABLE temp.x_ref_ets AS + SELECT + idsociete as ent_code_original, + idsociete||'-'||codetab as ety_code_original, + codetab as code_original, + codetab as code, + MAX(siret) as siret, + MAX(nometab) as texte, + null::text as texte_court + FROM w_ets + GROUP BY 1,2,3,4 + ; + + ]]> + + + + + + = to_char(rhp('rhprovider_start')::date, 'YYYYMM') + and (codexercice <> '' or codperiode <> '') + ; + + DROP TABLE IF EXISTS temp.x_hst_bulletin + ; + + CREATE TABLE temp.x_hst_bulletin AS + SELECT + w_bul.ent_code_original, + w_bul.ets_code_original, + w_bul.ent_code_original||'-'||w_bul.ets_code_original as ety_code_original, + w_bul.sal_code_original, + w_bul.bul_code_original, + w_bul.date_debut, + w_bul.date_fin, + w_bul.date_fin as date_paie, + w_bul.mois_paie, + row_number() over () as row_id, + row_number() over (order by ent_code_original, ets_code_original, sal_code_original, bul_code_original) as bul_id, + null::text as cnt_code_original, -- un bulletin est rattaché à un seul et unique contrat. + 0 as est_hors_periode + from w_bul + ; + + -- Association avec le contrat correspondant aux dates. + -- Un bulletin est rattaché à un seul et unique contrat. + with toto as ( + SELECT + x_hst_bulletin.row_id, + (max(array[x_hst_contrat.date_fin::text, x_hst_contrat.cnt_code_original]))[2] as cnt_code_original + from temp.x_hst_bulletin + join temp.x_hst_contrat on 1=1 + and x_hst_contrat.sal_code_original = x_hst_bulletin.sal_code_original + and base.cti_overlaps(x_hst_contrat.date_debut, x_hst_contrat.date_fin, x_hst_bulletin.date_debut, x_hst_bulletin.date_fin) + group by 1 + ) + UPDATE temp.x_hst_bulletin set + cnt_code_original = toto.cnt_code_original + from toto + where x_hst_bulletin.row_id = toto.row_id + ; + + -- Association avec le contrat précédent. + with toto as ( + SELECT + x_hst_bulletin.row_id, + (max(array[x_hst_contrat.date_fin::text, x_hst_contrat.cnt_code_original]))[2] as cnt_code_original + from temp.x_hst_bulletin + join temp.x_hst_contrat on 1=1 + and x_hst_contrat.sal_code_original = x_hst_bulletin.sal_code_original + and x_hst_contrat.date_fin < x_hst_bulletin.date_debut + where x_hst_bulletin.cnt_code_original is null + group by 1 + ) + UPDATE temp.x_hst_bulletin set + cnt_code_original = toto.cnt_code_original, + est_hors_periode = 1 + from toto + where x_hst_bulletin.row_id = toto.row_id + ; + + -- Association avec le contrat suivant. + with toto as ( + SELECT + x_hst_bulletin.row_id, + (max(array[x_hst_contrat.date_fin::text, x_hst_contrat.cnt_code_original]))[2] as cnt_code_original + from temp.x_hst_bulletin + join temp.x_hst_contrat on 1=1 + and x_hst_contrat.sal_code_original = x_hst_bulletin.sal_code_original + and x_hst_contrat.date_fin > x_hst_bulletin.date_debut + where x_hst_bulletin.cnt_code_original is null + group by 1 + ) + UPDATE temp.x_hst_bulletin set + cnt_code_original = toto.cnt_code_original, + est_hors_periode = 1 + from toto + where x_hst_bulletin.row_id = toto.row_id + ; + + -- ICI : Tous les bulletins doivent avoir un contrat de renseigné. + -- A remonter plus tard dans une table spéciale avant suppression pour controle expert. + delete from temp.x_hst_bulletin + where cnt_code_original is null + ; + + -- La date min du premier contrat et/ou du premier bulletin détermine le début de la ventilation du salarié. + DROP TABLE IF EXISTS w_lim_sal + ; + + CREATE TEMP TABLE w_lim_sal AS + with toto as ( + select + sal_code_original, + min(date_debut) as date_debut, + max(case when date_fin = '2099-12-31'::date then base.cti_last_day(current_date) else date_fin end) as date_fin + from temp.x_hst_contrat + group by 1 + union all + select + sal_code_original, + min(date_debut) as date_debut, + max(case when date_fin = '2099-12-31'::date then base.cti_last_day(current_date) else date_fin end) as date_fin + from temp.x_hst_bulletin + group by 1 + ) + select + sal_code_original, + min(date_debut) as date_debut, + to_char(min(date_debut), 'YYYYMM')::int as mois_debut, + max(date_fin) as date_fin, + to_char(max(date_fin), 'YYYYMM')::int as mois_fin + from toto + group by 1 + ; + + -- HISTORIQUE ETP Théorique contrat. + DROP TABLE IF EXISTS temp.x_hst_etp_contrat + ; + + CREATE TABLE temp.x_hst_etp_contrat AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.etp_contrat + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_categorie_socio_professionnelle + ; + + CREATE TABLE temp.x_hst_categorie_socio_professionnelle AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.codinseeemploi2003 as categorie_socio_professionnelle_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE Motif de début. + DROP TABLE IF EXISTS temp.x_hst_motif_debut_contrat + ; + + CREATE TABLE temp.x_hst_motif_debut_contrat AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.motif_debut as motif_debut_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE Motif de fin. + DROP TABLE IF EXISTS temp.x_hst_motif_fin_contrat + ; + + CREATE TABLE temp.x_hst_motif_fin_contrat AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.motif_fin as motif_fin_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + + -- HISTORIQUE Types de contrat. + DROP TABLE IF EXISTS temp.x_hst_type_contrat + ; + + CREATE TABLE temp.x_hst_type_contrat AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.typcontrat as type_contrat_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- -- HISTORIQUE CSP. + -- DROP TABLE IF EXISTS temp.x_hst_organisme_cotisation + -- ; + + -- CREATE TABLE temp.x_hst_organisme_cotisation AS + -- SELECT + -- w_cnt.ent_code_original||'-'||w_cnt.ets_code_original as ety_code_original, + -- w_cnt.sal_code_original, + -- w_cnt.cnt_code_original, + -- greatest(w_cnt.date_debut, w_lim_sal.date_debut) as date_effet, + -- w_cnt.codinseeemploi2003 as categorie_socio_professionnelle_code_original + -- from w_cnt + -- join w_lim_sal on w_lim_sal.sal_code_original = w_cnt.sal_code_original + -- ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_qualification + ; + + CREATE TABLE temp.x_hst_qualification AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.emploi as qualification_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_statut + ; + + CREATE TABLE temp.x_hst_statut AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.codcategorie as statut_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_type_temps_travail + ; + + CREATE TABLE temp.x_hst_type_temps_travail AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.code_ttt as type_temps_travail_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_service + ; + + CREATE TABLE temp.x_hst_service AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.codsection as service_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_code_emploi + ; + + CREATE TABLE temp.x_hst_code_emploi AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.emploi as code_emploi_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + -- HISTORIQUE GRILLE. + DROP TABLE IF EXISTS temp.x_hst_grille + ; + + CREATE TABLE temp.x_hst_grille AS + SELECT + w_evo.ent_code_original||'-'||w_evo.ets_code_original as ety_code_original, + w_evo.sal_code_original, + w_evo.cnt_code_original, + greatest(w_evo.sal_date_debut, w_evo.cnt_date_debut, w_lim_sal.date_debut) as date_effet, + w_evo.champslibres as grille_code_original + from w_evo + join w_lim_sal on w_lim_sal.sal_code_original = w_evo.sal_code_original + ; + + ]]> + + + = to_char(rhp('rhprovider_start')::date, 'YYYYMM') + ) as suqb) + select + bulletins.bul_id, + bulletins.ety_code_original, + bulletins.sal_code_original, + bulletins.cnt_code_original, + bulletins.bul_code_original, + bulletins.date_debut, + bulletins.date_fin, + bulletins.mois_paie as mois_activite, + bulletins.date_paie, + bulletins.mois_paie, + codrubrique as rub_code_original, + coalesce(nullif(eubasapc, ''), '0')::numeric as base, + coalesce(nullif(eutausalapc, ''), '0')::numeric as txsal, + coalesce(nullif(eumntsalapc, ''), '0')::numeric as mntsal, + coalesce(nullif(eutaupatapc, ''), '0')::numeric as txpat, + coalesce(nullif(eumntpatapc, ''), '0')::numeric as mntpat + from temp.x_hst_bulletin as bulletins + join temp.x_ref_ets on x_ref_ets.ety_code_original = bulletins.ety_code_original + join prod_pegase.bulletinsdetail on 1=1 + and bulletinsdetail.idsociete = bulletins.ent_code_original + and bulletinsdetail.codetab = bulletins.ets_code_original + and bulletinsdetail.codsalarie = bulletins.sal_code_original + and (bulletinsdetail.codexercice||bulletinsdetail.codbulletin)::text = bulletins.bul_code_original + where 1=1 + AND bulletins.mois_paie >= to_char(rhp('rhprovider_start')::date, 'YYYYMM') + AND (1!=1 + or eumntsalapc != '' + or eumntpatapc != '' + or eubasapc != '') + UNION ALL + select + bul_id, + ety_code_original, + sal_code_original, + cnt_code_original, + bul_code_original, + date_debut, + date_fin, + mois_paie as mois_activite, + date_paie, + mois_paie, + rub as rub_code_original, + case when rub in ('C001', 'C002', 'C009') then val::numeric else 0::numeric end as base, + 0 as txsal, + case + when rub in ('C003', 'C004', 'C008') then val::numeric + when rub = 'C007' then -val::numeric + else 0::numeric end as mnt_sal, + 0 as txpat, + case when rub = 'C006' then val::numeric else 0::numeric end as mnt_pat + from w_cum + ; + + -- #specifique Forfaits Jours & Vacations (on renseigne dans base le nombre d'heures contractuel d'après le champ "heures reconstituées"). + with liste_rub_fj as ( + select t_rubriques.code_original + from rh.t_listes + join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + join rh.t_rubriques on t_rubriques.oid = t_listes_contenu.to_id + where t_listes.code = 'CTI_PEGASE_FTJ' + ) + , fj_sal as ( + select + bul_id, + sal_code_original + from temp.x_hst_paie + where true + and rub_code_original in (select code_original from liste_rub_fj) + and base = 0 + ) + , sal_etp as ( + select + x_hst_etp_contrat.ety_code_original, + x_hst_etp_contrat.sal_code_original, + date_effet as date_debut, + lead(date_effet - 1, 1, '2099-12-31'::date) over w as date_fin, + etp_contrat + from temp.x_hst_etp_contrat + join fj_sal on fj_sal.sal_code_original = x_hst_etp_contrat.sal_code_original + group by 1,2,3 ,5 + window w as (partition by x_hst_etp_contrat.sal_code_original order by date_effet) + ) + , new_data_fj as ( + select + x_hst_paie.bul_id, + coalesce(etp_contrat, 1.0) * x_hst_paie.base as base + from temp.x_hst_paie + join fj_sal on fj_sal.bul_id = x_hst_paie.bul_id + join sal_etp on 1=1 + and sal_etp.ety_code_original = x_hst_paie.ety_code_original + and sal_etp.sal_code_original = x_hst_paie.sal_code_original + and x_hst_paie.date_paie between sal_etp.date_debut and sal_etp.date_fin + where 1=1 + and x_hst_paie.rub_code_original = 'C009') + update temp.x_hst_paie set + base = new_data_fj.base + from new_data_fj + where 1=1 + and new_data_fj.bul_id = x_hst_paie.bul_id + and x_hst_paie.rub_code_original in (select code_original from liste_rub_fj) + ; + + -- Alimentation de la base de la rubrique forfait jour à partir de la base d'une rubrique référence avec la condition de nombre de jour pour définir les temps pleins et affecter les heures contrat + + with parametrage_pegase_forfait_jour as ( + select + valeur + ,split_part(valeur, '|', 1) as rubrique_ref -- rubrique source + ,split_part(valeur, '|', 2) as rubrique_cible -- rubrique cible + ,split_part(valeur, '|', 3)::int as max_jour -- valeur de condition du nombre de jour maximum à prendre en compte pour distinguer les temps complets des temps partiels + from rh.t_divers + where code = 'PEGASE_FORFAIT_JOUR' + ) + , forfait_cadre as ( + select + sal_code_original, + mois_paie, + base, + bul_id + from temp.x_hst_paie + where rub_code_original in (select rubrique_ref from parametrage_pegase_forfait_jour) + ) + , modif_base as ( + select + x_hst_paie.sal_code_original as sal_code_original, + x_hst_paie.mois_paie as mois_paie, + x_hst_paie.base, + x_hst_paie.rub_code_original, + forfait_cadre.bul_id as bul_id, + case when forfait_cadre.base < (select max_jour from parametrage_pegase_forfait_jour) then forfait_cadre.base*7 else 151.67 end as forfait_jour_base -- si le nombre de jour (rubrique source) est inférieur au nombre de jour max défini alors on multiplie la base de la rubrique source par 7 et on affecte cette valeur à la rubrique cible sinon on affecte 151,7 (temps plein) + from temp.x_hst_paie + join forfait_cadre on forfait_cadre.sal_code_original = x_hst_paie.sal_code_original and forfait_cadre.mois_paie = x_hst_paie.mois_paie and forfait_cadre.bul_id = x_hst_paie.bul_id + where x_hst_paie.rub_code_original in (select rubrique_cible from parametrage_pegase_forfait_jour) + and (select valeur from parametrage_pegase_forfait_jour) is not null and (select valeur from parametrage_pegase_forfait_jour) <> '' + ) + + update temp.x_hst_paie set + base = modif_base.forfait_jour_base + from modif_base + where 1=1 + and x_hst_paie.sal_code_original = modif_base.sal_code_original + and x_hst_paie.mois_paie = modif_base.mois_paie + and x_hst_paie.bul_id = modif_base.bul_id + and x_hst_paie.base is distinct from modif_base.forfait_jour_base + and x_hst_paie.rub_code_original in (select rubrique_cible from parametrage_pegase_forfait_jour) + + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_PLEIADES.XML b/import_rh/iCTI_import_rh_PLEIADES.XML new file mode 100644 index 0000000..6bad5ab --- /dev/null +++ b/import_rh/iCTI_import_rh_PLEIADES.XML @@ -0,0 +1,2604 @@ + + + + + + + + = 100 OR @c03 = 0 then 'TC' else 'TP'||(@c03)::text end as ttt_code + from prod_pleiades.d01v1_perxhx + ; + + drop table if exists w_cnt_tho + ; + + create temp table w_cnt_tho as + select + cb as mat, + cb||'-'||(rank() over (partition by cb order by cf))::text as tho_num, + cf::date as date_debut, + coalesce(lead(cf::date) over (partition by cb order by cf) - 1, '20991231'::date) as date_fin, + c07 as tho_code + from prod_pleiades.d01v1_pereta + ; + + -- Relation 1 pour 1 entre le matricule et la spécialité. + drop table if exists w_cnt_spe + ; + + create temp table w_cnt_spe as + select + cb as mat, + max(c02)::text AS spe_code -- on enfonce le clou (1 pour 1) par sécurité. + from prod_pleiades.d01v1_perxme + group by 1 + ; + + -- Création table des contrats. + drop table if exists w_cnt + ; + + create temp table w_cnt as + select + d01v1_perctr.cb as mat, + d01v1_perctr.cb||'-'||rank() over (partition by d01v1_perctr.cb order by d01v1_perctr.cf) as cnt, + d01v1_perctr.cf::date as date_debut, + coalesce(d01v1_perctr.c09::date, '20991231'::date) as date_fin, + d01v1_perctr.c02 as motif_debut, + d01v1_perctr.c08 as motif_fin, + d01v1_perctr.c03 as nature_contrat, -- à concaténer avec le type de contrat + d01v1_perctr.c04 as type_contrat, + d01v1_percdd.c03 as mat_remp + from prod_pleiades.d01v1_perctr + left join prod_pleiades.d01v1_percdd on 1=1 + and d01v1_percdd.cb = d01v1_perctr.cb + and d01v1_percdd.cf = d01v1_perctr.cf + ; + + -- Création table de compte comptables. + drop table if exists w_compte + ; + + create temp table w_compte as + select + poste, + matricule, + compte, + ('20'||periode_imputation)::numeric as periode_imputation, + sous_periode, + periode_origine + from prod_pleiades.a01_compta + where 1=1 + and ecriture = 'C' + and compte != '999999999' + group by 1,2,3,4,5,6 + ; + + -- Création d'une table brut de paie + /*drop table if exists w_hp + ; + + create temp table w_hp as + select + trim(mat) as mat, + mois, + date1 as date_virement, + trim(col1) as sous_periode, + date_debut, + date_fin, + mois != to_char(date_debut, 'YYYYMM')::numeric as regul, -- true quand régulation. + trim(nb1) as rub, + to_number(mnt2, 'SG000000000D00') as base, + to_number(mnt3, 'SG000000000D00') as tx, + to_number(mnt4, 'SG000000000D00') as mt + from prod_pleiades.cti_pfedis01 + ;*/ + + -- créer une vue avec ca : vvvvvv + DROP VIEW IF EXISTS public.w_hp + ; + + CREATE OR REPLACE VIEW public.w_hp AS + select + ctid as hp_ctid, + trim(matricule) as mat, + date_compta::numeric as mois, + date_comptable::date as date_virement, + periode as sous_periode, + debut_periode::date as date_debut, + fin_periode::date as date_fin, + date_compta != to_char(debut_periode, 'YYYYMM')::numeric as regul, + trim(poste) as rub, + nombre as base, + taux as tx, + montant as mt + from prod_pleiades.a01_z_paic + ; + + -- Créer une table des bulletins. + -- Les rubriques de régulation (en "R") seront affectées systématiquement au 1er bulletin du mois. + DROP TABLE IF EXISTS w_bul + ; + CREATE TEMP TABLE w_bul AS + with bul_mois as ( + select + mat, + mois, + case when mois = to_char(date_debut, 'YYYYMM')::numeric then date_debut else (mois||'01')::date end as date_debut, + case when mois = to_char(date_debut, 'YYYYMM')::numeric then date_fin else base.cti_last_day((mois||'01')::date) end as date_fin, + count(*) over (partition by mat, mois) as nb_bul_month, + count(case when mois = to_char(date_debut, 'YYYYMM')::numeric then date_debut else null end) as nb_lines_month + from w_hp + group by 1,2,3,4) + -- + select + mat||mois||lpad(rank() over (partition by mat, mois order by date_debut), 2, '0') as bul, + * + from bul_mois + where case when nb_lines_month = 0 then nb_bul_month = 1 else true end -- on ne conserve que les bulletins mois qui n'ont aucune ligne sur le mois d'imputation (100% de régul). + ; + + ]]> + + + + + + + + + + + + = 2009 + AND (1!=1 + OR w_cnt is not NULL + OR w_cnt_csp is not null + OR w_cnt_emp is not null + OR w_cnt_aff is not null + OR w_cnt_ttt is not null + OR w_bul is not null) + group by 1,4,5,6,7,8,9,10,11,12,13,14,15,16,17 + ; + + -- Associer le dernier contrat aux bulletins hors période de contrat. + /* UPDATE w_evt + SET cnt = subq.cnt, + cnt_date_debut = subq.cnt_date_debut, + cnt_date_fin = subq.cnt_date_fin + FROM ( + select + t1.mat, + t1.date_debut, + t1.bul_0, + (max(ARRAY[t2.date_fin::text, t2.cnt::text]))[2] as cnt, + max(t2.date_debut) AS cnt_date_debut, + max(t2.date_fin) AS cnt_date_fin + from w_evt AS t1 + left JOIN w_cnt AS t2 on 1=1 + and t2.mat = t1.mat + and t2.date_fin < t1.date_debut + and t1.cnt is null + group by 1,2,3 + having (max(ARRAY[t2.date_fin::text, t2.cnt::text]))[2] is not null + ) AS subq + WHERE 1=1 + AND w_evt.mat = subq.mat + AND w_evt.date_debut = subq.date_debut + AND w_evt.bul_0 = subq.bul_0 + ;*/ + + ]]> + + + + + + + + + + + + + + + + + 100% + WHEN type_temps_travail_code = 'TC' THEN 100 -- lorsque TC -> 100% + WHEN base.cti_to_number(substr(type_temps_travail_code, 2)) = 0 THEN 1 -- lorsque TP à 0% -> 1% + ELSE base.cti_to_number(substr(type_temps_travail_code, 2)) -- n% + END)::numeric AS pct_temps_travail, + (date_fin - date_debut + 1)::numeric AS duree, + (CASE date_part('month', date_fin) + WHEN 02 THEN CASE WHEN date_part('year', date_fin) IN (2000, 2004, 2008, 2012) THEN 29 ELSE 28 END + WHEN 04 THEN 30 + WHEN 06 THEN 30 + WHEN 09 THEN 30 + WHEN 11 THEN 30 + ELSE 31 + END)::numeric AS duree_mois + FROM rh.p_contrats_mois + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profils ON p_profils.oid = p_profil_contrat_mois.profil_id + ; + + UPDATE rh.p_contrats_mois + SET equivalent_temps_plein = round((duree / duree_mois) * (pct_temps_travail / 100), 7) + FROM maj_etp + WHERE 1=1 + AND p_contrats_mois.oid = maj_etp.contrat_mois_id + AND equivalent_temps_plein IS DISTINCT FROM round((duree / duree_mois) * (pct_temps_travail / 100), 7) + ; +*/ + ]]> + + + + + + + + + = '2008-01-01' + GROUP BY 1,2,3,4 + ; + + -- Associer les visites hors contrat au plus récent existant précédemment (en amont) ... + UPDATE w_visites + SET cnt = subq.cnt + FROM ( + select + w_visites.mat, + w_visites.date, + (max(array[w_cnt.date_fin::text, w_cnt.cnt]))[2] as cnt + from w_visites + JOIN w_cnt ON true + AND w_cnt.mat = w_visites.mat + and w_cnt.date_fin < w_visites.date + where w_visites.cnt is null + group by 1,2 + ) as subq + WHERE true + AND w_visites.mat = subq.mat + AND w_visites.date = subq.date + ; + + -- ... Puis en aval. + UPDATE w_visites + SET cnt = subq.cnt + FROM ( + select + w_visites.mat, + w_visites.date, + (min(array[w_cnt.date_debut::text, w_cnt.cnt]))[2] as cnt + from w_visites + JOIN w_cnt ON true + AND w_cnt.mat = w_visites.mat + and w_visites.date < w_cnt.date_debut + where w_visites.cnt is null + group by 1,2 + ) as subq + WHERE true + AND w_visites.mat = subq.mat + AND w_visites.date = subq.date + ; + + -- Peuplement de rh.p_visites_medicales + TRUNCATE rh.p_visites_medicales + ; + + ALTER SEQUENCE rh.s_visites_medicales RESTART WITH 1 + ; + + INSERT INTO rh.p_visites_medicales( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date, + motif_visite_id) + SELECT p_salaries.oid, + p_contrats.oid, + p_contrats_mois.oid, + w_visites.mois_activite, + w_visites.date, + t_motifs_visite.oid + FROM w_visites + JOIN rh.p_salaries ON p_salaries.matricule = w_visites.mat + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_visites.cnt + JOIN rh.p_contrats_mois ON true + AND p_contrats_mois.contrat_id = p_contrats.oid + AND w_visites.date between p_contrats_mois.date_debut AND p_contrats_mois.date_fin + JOIN rh.t_motifs_visite ON t_motifs_visite.code_original = w_visites.motif + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_PLEIADES2.XML b/import_rh/iCTI_import_rh_PLEIADES2.XML new file mode 100644 index 0000000..a1db0cb --- /dev/null +++ b/import_rh/iCTI_import_rh_PLEIADES2.XML @@ -0,0 +1,2761 @@ + + + + + = 100 then 'TC' else 'TP'||(@toto.horpourcttxpl)::text end as ttt_code_original, + @toto.horpourcttxpl / 100 as etp_cnt + from toto + window w as (partition by toto.oid order by toto.begin_date) + ; + + drop table if exists w_cnt_tho + ; + + create temp table w_cnt_tho as + select + salarie.matricule as mat, + salarie.matricule||'-'||(rank() over w)::text as tho_num, + xrcaffectcompl.begin_date::date as date_debut, + coalesce(lead(xrcaffectcompl.begin_date::date) over w - 1, '20991231'::date) as date_fin, + xta_jrnuitaltsr.code as tho_code_original + from prod_pleiades2.relationcontrat + join prod_pleiades2.salarie on salarie.oid = relationcontrat.relatmatricule + join prod_pleiades2.xrcaffectcompl on xrcaffectcompl.relationcontrat = relationcontrat.oid + join prod_pleiades2.xta_jrnuitaltsr on xta_jrnuitaltsr.oid = xrcaffectcompl.xta_jrnuitaltsr + window w as (partition by salarie.oid order by xrcaffectcompl.begin_date) + ; + + -- Création table des contrats. + -- Source intégrateur Pleiades : "Attention, sur E5, le passage de CDD à CDI n'est pas à l'origine d'un nouveau contrat contrairement à Pléiades CS". + -- On mélange donc les 2 historiques de contrat et de type de contrat pour n'en faire qu'une seul comme dans CS. + drop table if exists w_cnt + ; + + create temp table w_cnt as + with toto as ( + select + salarie.matricule as mat, + salarie.matricule||'-'||row_number() over w as cnt, -- relationcontrat.relatnum + relationcontrat.relatnum, + typejuridqctr.begin_date::date as date_debut, -- relationcontrat.relatdatedeb + coalesce(nullif(typejuridqctr.end_date::date, '29990101'::date), relationcontrat.relatdatefin::date, '20991231'::date) as date_fin, -- relationcontrat.relatdatefin + nullif(ta_relamotifdeb.relatcodedeb, '') as motif_debut, + coalesce(case when lead(contrat.ctrrelation) over w = contrat.ctrrelation then 'CTI-TO_CDI' else null end, nullif(ta_relamotiffin.relationcodefin, '')) as motif_fin, + ta_relamotiffin.relationcodefin, + ta_contrattype.contrattypecode as type_contrat, + contrat.ctrsociete as etablissement, + coalesce(xunitefct.code, chr(1)||'*') as uf_localisation, + null::text as mat_remp + from prod_pleiades2.contrat + join prod_pleiades2.relationcontrat on relationcontrat.oid = contrat.ctrrelation + join prod_pleiades2.salarie on salarie.oid = relationcontrat.relatmatricule + join prod_pleiades2.ta_relamotifdeb on ta_relamotifdeb.oid = relationcontrat.relatmotifdeb + left join prod_pleiades2.ta_relamotiffin on ta_relamotiffin.oid = relationcontrat.relatmotiffin + join prod_pleiades2.typejuridqctr on contrat.oid = typejuridqctr.typecontrat + join prod_pleiades2.ta_contrattype on ta_contrattype.oid = typejuridqctr.typejuridique + left join prod_pleiades2.xrccomplement on xrccomplement.relationcontrat = relationcontrat.oid + left join prod_pleiades2.xunitefct on xunitefct.oid = xrccomplement.uflocalisation + window w as (partition by relationcontrat.relatmatricule order by typejuridqctr.begin_date)) + ,tata as ( + select + *, + date_fin - date_debut + 1 as duree, + coalesce((lag(date_fin) over w) + 1 = date_debut, false) as continue, + coalesce((lead(date_debut) over w) - 1 = date_fin, false) as continue2 + from toto + window w as (partition by mat order by date_debut)) + ,titi as ( + select + *, + case when lag(continue2) over w then false else continue2 end as new_cluster, + case when continue then lag(duree) over w else 0 end as prec_duree + from tata + window w as (partition by mat order by mat, date_debut)) + ,tutu as ( + select * , + case when new_cluster then count(new_cluster) over w else null end as cluster_id + from titi + window w as (partition by mat order by date_debut)) + ,tyty as ( + select + *, + max(cluster_id) over wb as cl2 + from tutu + window wb as (PARTITION BY mat ORDER BY date_debut rows unbounded preceding)) + select + mat, + cnt, + relatnum, + date_debut, + date_fin, + motif_debut, + motif_fin, + relationcodefin, + type_contrat, + etablissement, + uf_localisation, + mat_remp, + case when continue then sum(prec_duree) over w else 0 end as anciennete_anterieure_jours, + case when continue then sum(prec_duree) over w else 0 end / 30.0 as anciennete_anterieure_calculee_mois + from tyty + window w as (partition by mat, cl2 order by date_debut) + ; + + CREATE INDEX i_cnt_0 ON w_cnt USING btree(mat) + ; + CREATE INDEX i_cnt_1 ON w_cnt USING btree(cnt) + ; + + -- Création table de compte comptables CS. + drop table if exists w_cs_compte + ; + + create temp table w_cs_compte as + select + a01_compta.poste as poste, + matricule, + compte, + ('20'||periode_imputation)::numeric as periode_imputation, + sous_periode, + periode_origine, + montant, + montant_total + from w_a01_compta as a01_compta + where 1=1 + and ecriture = 'C' + and compte != '999999999' + group by 1,2,3,4,5,6,7,8 + ; + + -- Création table de compte comptables e5. + drop table if exists w_compte + ; + + create temp table w_compte as + with compte_9955 as ( + select + '9955'::text as poste, + poste_paie.code as rub, + to_char(begin_date, 'YYYYMM')::int as date_debut, + to_char(coalesce(nullif(end_date::date, '29990101'::date), '2099-12-31'::date), 'YYYYMM')::int as date_fin + from prod_pleiades2.assiettetdp + join prod_pleiades2.ass on ass.oid = assiettetdp.assiette + join prod_pleiades2.cumulassiette on cumulassiette.oid = assiettetdp.codecumul + join prod_pleiades2.poste_paie on poste_paie.oid = assiettetdp.postepaie + where true + and ass.code = '235') + ,compte_9956 as ( + select + '9956'::text as poste, + poste_paie.code as rub, + to_char(begin_date, 'YYYYMM')::int as date_debut, + to_char(coalesce(nullif(end_date::date, '29990101'::date), '2099-12-31'::date), 'YYYYMM')::int as date_fin + from prod_pleiades2.assiettetdp + join prod_pleiades2.ass on ass.oid = assiettetdp.assiette + join prod_pleiades2.cumulassiette on cumulassiette.oid = assiettetdp.codecumul + join prod_pleiades2.poste_paie on poste_paie.oid = assiettetdp.postepaie + where true + and ass.code = '236' + and cumulassiette.code != '0') + select + coalesce(compte_9955.rub, compte_9956.rub, a01_compta.poste) as poste, + matricule, + compte, + ('20'||periode_imputation)::numeric as periode_imputation, + sous_periode, + periode_origine, + montant, + montant_total + from w_a01_compta as a01_compta + left join compte_9955 on 1=1 + and compte_9955.poste = a01_compta.regroupement + and ('20'||periode_imputation)::numeric between compte_9955.date_debut and compte_9955.date_fin + left join compte_9956 on 1=1 + and compte_9956.poste = a01_compta.poste + and ('20'||periode_imputation)::numeric between compte_9956.date_debut and compte_9956.date_fin + where 1=1 + and ecriture = 'C' + and compte != '999999999' + group by 1,2,3,4,5,6,7,8 + ; + + -- Création d'une table brut de paie + + -- Suppression de l'ancienne vue w_hp du schéma public. + DROP VIEW IF EXISTS public.w_hp + ; + + DROP TABLE IF EXISTS w_hp + ; + CREATE TEMP TABLE w_hp AS + SELECT + paie_poste.ctid as hp_ctid, + salarie.matricule as mat, + relationcontrat.relatnum, + paie_periode.imputation::numeric as mois, + paie_periode.datevirement as date_virement, + rpad(paie_periode.moispaie, 6)||rpad(paie_periode.traitement, 1)||rpad(paie_periode.sousperiode, 2) as sous_periode, + paie_periode.datedebut as date_debut, + paie_periode.datefin as date_fin, + rpad(poste_paie.code, 4) as rub, + paie_poste.nombre as base, + sum(paie_poste.nombre) over w as base_total, + sum(paie_poste.nombre) over wi as base_total_imputation, + paie_poste.taux as tx, + paie_poste.montant as mt, + sum(paie_poste.montant) over w as montant_total, + sum(paie_poste.montant) over wi as montant_total_imputation + FROM prod_pleiades2.paie_poste + join prod_pleiades2.paie_periode on paie_periode.oid = paie_poste.paieperiode + join prod_pleiades2.poste_paie on poste_paie.oid = paie_poste.postepaie + join prod_pleiades2.relationcontrat on relationcontrat.oid = paie_periode.relationcontrat + join prod_pleiades2.salarie on salarie.oid = relationcontrat.relatmatricule + where to_char(paie_periode.datevirement, 'YYYYMM') >= CONCAT(SPLIT_PART(rhp('rhprovider_start'), '-', 1), SPLIT_PART(rhp('rhprovider_start'), '-', 2)) + window w as (partition by salarie.matricule, relationcontrat.relatnum, poste_paie.code, paie_periode.imputation, to_char(paie_periode.datedebut, 'YYYYMM')), + wi as (partition by salarie.matricule, relationcontrat.relatnum, poste_paie.code, paie_periode.imputation) + ; + + CREATE INDEX i_hp_0 ON w_hp USING btree(mat) + ; + CREATE INDEX i_hp_1 ON w_hp USING btree(rub) + ; + CREATE INDEX i_hp_3 ON w_hp USING btree(hp_ctid) + ; + + -- Créer une table des bulletins. + -- Les rubriques de régulation (en "R") seront affectées systématiquement au 1er bulletin du mois. + DROP TABLE IF EXISTS w_bul + ; + CREATE TEMP TABLE w_bul AS + with bul_mois as ( + select + mat, + mois, + case when mois = to_char(date_debut, 'YYYYMM')::numeric then date_debut else (mois||'01')::date end as date_debut, + case when mois = to_char(date_debut, 'YYYYMM')::numeric then date_fin else base.cti_last_day((mois||'01')::date) end as date_fin, + count(*) over (partition by mat, mois) as nb_bul_month, + count(case when mois = to_char(date_debut, 'YYYYMM')::numeric then date_debut else null end) as nb_lines_month + from w_hp + group by 1,2,3,4) + -- + select + mat||mois||lpad(rank() over (partition by mat, mois order by date_debut), 2, '0') as bul, + * + from bul_mois + where case when nb_lines_month = 0 then nb_bul_month = 1 else true end -- on ne conserve que les bulletins mois qui n'ont aucune ligne sur le mois d'imputation (100% de régul). + ; + + ]]> + + + + '' + group by 1,2,3,4 + ; + + ]]> + + + + + + + + = rhp('rhprovider_start')::date + AND (1!=1 + OR w_cnt.mat is not NULL + OR w_cnt_csp is not null + OR w_cnt_ufs is not null + OR w_cnt_qua is not null + OR w_cnt_ttt is not null + -- OR w_cnt_ttt is not null + OR w_bul.mat is not null) + group by 1,4,5,6,7,8,9,10,11,12,13,14,15,16--,17 + ; + + ]]> + + + + + + + + + + + + + + comptes e5. + join w_compte on true + and w_compte.matricule = w_hp.mat + and w_compte.poste = w_hp.rub + and w_compte.periode_imputation = w_hp.mois + and w_compte.periode_origine||w_compte.sous_periode = substr(w_hp.sous_periode, 3, 4)||substr(w_hp.sous_periode, 8, 2) + join rh.t_compte as cpt_e5 on cpt_e5.code_original = w_compte.compte + group by 1) + UPDATE w_asso_comptes SET + compte_id = subq.compte_id + FROM subq + WHERE 1=1 + AND w_asso_comptes.hp_ctid = subq.hp_ctid + AND w_asso_comptes.compte_id = 0 + ; + + WITH subq AS ( + select + w_hp.hp_ctid, + max(cpt_e5_bis.oid) as compte_id + from w_hp + -- Association rubriques <=> comptes e5. + join w_compte as w_compte2 on true + and w_compte2.matricule = w_hp.mat + and w_compte2.poste = w_hp.rub + and w_compte2.periode_imputation = w_hp.mois + and @w_compte2.montant_total = @w_hp.mt + join rh.t_compte as cpt_e5_bis on cpt_e5_bis.code_original = w_compte2.compte + group by 1) + UPDATE w_asso_comptes SET + compte_id = subq.compte_id + FROM subq + WHERE 1=1 + AND w_asso_comptes.hp_ctid = subq.hp_ctid + AND w_asso_comptes.compte_id = 0 + ; + + WITH subq AS ( + select + w_hp.hp_ctid, + max(cpt_e5_ter.oid) as compte_id + from w_hp + -- Association rubriques <=> comptes e5. + join w_compte as w_compte3 on true + and w_compte3.matricule = w_hp.mat + and w_compte3.poste = w_hp.rub + and w_compte3.periode_imputation = w_hp.mois + and @w_compte3.montant = @w_hp.montant_total + join rh.t_compte as cpt_e5_ter on cpt_e5_ter.code_original = w_compte3.compte + group by 1) + UPDATE w_asso_comptes SET + compte_id = subq.compte_id + FROM subq + WHERE 1=1 + AND w_asso_comptes.hp_ctid = subq.hp_ctid + AND w_asso_comptes.compte_id = 0 + ; + + WITH subq AS ( + select + w_hp.hp_ctid, + max(cpt_e5_qua.oid) as compte_id + from w_hp + -- Association rubriques <=> comptes e5. + join w_compte as w_compte4 on true + and w_compte4.matricule = w_hp.mat + and w_compte4.poste = w_hp.rub + and w_compte4.periode_imputation = w_hp.mois + and @w_compte4.montant_total = @w_hp.montant_total + join rh.t_compte as cpt_e5_qua on cpt_e5_qua.code_original = w_compte4.compte + group by 1) + UPDATE w_asso_comptes SET + compte_id = subq.compte_id + FROM subq + WHERE 1=1 + AND w_asso_comptes.hp_ctid = subq.hp_ctid + AND w_asso_comptes.compte_id = 0 + ; + + ALTER SEQUENCE rh.s_historique_paie RESTART WITH 1 + ; + + DROP TABLE IF EXISTS w_historique_paie + ; + + CREATE TEMP TABLE w_historique_paie AS + select + w_hp.hp_ctid, -- permet d'être sûr qu'on n'agrège pas à tort des lignes de paie w_hp. + date_part('year', age(w_bul.date_fin, date_naissance)) AS age_id, + w_hp.mat||w_hp.mois||(case when to_char(w_hp.date_debut, 'YYYYMM')::numeric = w_hp.mois then substring(w_hp.sous_periode, 8, 2) else '01' end), -- numero fictif de bulletin. Rang 01 lorsque régulation. + w_hp.mat, + w_hp.relatnum, + w_hp.mois::numeric as mois_paie, + w_bul.date_debut, + w_bul.date_fin, + w_bul.date_fin as date_paie, + substring(w_hp.sous_periode, 1, 6)::numeric as mois_activite, + date_virement, + t_rubriques.oid AS rubrique_id, + p_salaries.oid AS salarie_id, + w_hp.sous_periode, + w_hp.date_debut as date_debut_ori, + w_hp.date_fin as date_fin_ori, + w_hp.rub, + w_bul.bul, + w_hp.mt * coalesce(w_rub_brut.signe, w_rub_cotpat.signe, w_rub_netpayer.signe) as ori_mt, -- orienté masse salariale à cause du signe. + w_hp.montant_total * coalesce(w_rub_brut.signe, w_rub_cotpat.signe, w_rub_netpayer.signe) as montant_total, -- orienté masse salariale à cause du signe. + w_hp.montant_total_imputation * coalesce(w_rub_brut.signe, w_rub_cotpat.signe, w_rub_netpayer.signe) as montant_total_imputation, -- orienté masse salariale à cause du signe. + case + when w_rub_h_2.rub is not null then + case w_rub_h_2.is_montant + when true then w_hp.mt * w_rub_h_2.signe + when false then (case when w_hp.mt = 0 then 0 else w_hp.base end) + end + when w_rub_heures_dads.rub is not null then w_hp.mt -- on injecte la rubrique de cumul des heures DADS dans l'indicateur iCTI "base". + else w_hp.base + end as base, + case + when w_rub_h_2.rub is not null then + case w_rub_h_2.is_montant + when true then w_hp.montant_total * w_rub_h_2.signe + when false then (case when w_hp.montant_total = 0 then 0 else w_hp.base_total end) + end + when w_rub_heures_dads.rub is not null then w_hp.montant_total -- on injecte la rubrique de cumul des heures DADS dans l'indicateur iCTI "base". + else w_hp.base_total + end as base_total, + case + when w_rub_h_2.rub is not null then + case w_rub_h_2.is_montant + when true then w_hp.montant_total_imputation * w_rub_h_2.signe + when false then (case when w_hp.montant_total_imputation = 0 then 0 else w_hp.base_total_imputation end) + end + when w_rub_heures_dads.rub is not null then w_hp.montant_total_imputation -- on injecte la rubrique de cumul des heures DADS dans l'indicateur iCTI "base". + else w_hp.base_total_imputation + end as base_total_imputation, + case when w_rub_brut.rub is not null then w_hp.mt * w_rub_brut.signe else 0 end as montant_brut, + case when w_rub_cotsal.rub is not null then w_hp.tx else 0 end as taux_cotisation_salarie, + case when w_rub_cotsal.rub is not null then w_hp.mt * w_rub_cotsal.signe else 0 end as montant_cotisation_salarie, + case when w_rub_cotpat.rub is not null then w_hp.tx else 0 end as taux_cotisation_patronale, + case when w_rub_cotpat.rub is not null then w_hp.mt * w_rub_cotpat.signe else 0 end as montant_cotisation_patronale, + 0 as montant_avantage_nature, + 0 as montant_frais_imposables, + case when w_rub_netpayer.rub is not null then w_hp.mt * w_rub_netpayer.signe else 0 end as montant_net_a_payer_salarie, + case when w_rub_netimpos.rub is not null then w_hp.mt * w_rub_netimpos.signe else 0 end as montant_net_imposable_salarie, + 0 as montant_od_net_salarie, + case when w_rub_odnet_pat.rub is not null then w_hp.mt * w_rub_netpayer.signe else 0 end as montant_od_net_patronale, -- on prend le signe du net à payer. + 0 as organisme_cotisation_id, + w_asso_comptes.compte_id, + (max(array[extract(epoch from w_profils.date_debut), p_contrats.oid]))[2] AS contrat_id, + (max(array[extract(epoch from w_profils.date_debut), p_contrats_mois.oid]))[2] AS contrat_mois_id, + (max(array[extract(epoch from w_profils.date_debut), w_profils.profil_id]))[2] AS profil_id, + nextval('rh.s_historique_paie'::regclass) as oid + from w_hp + JOIN w_bul on w_bul.bul = w_hp.mat||w_hp.mois||(case when to_char(w_hp.date_debut, 'YYYYMM')::numeric = w_hp.mois then substring(sous_periode, 8, 2) else '01' end) + JOIN rh.t_rubriques ON t_rubriques.code_original = w_hp.rub + JOIN rh.p_salaries ON p_salaries.matricule = w_bul.mat + JOIN w_profils ON 1=1 + AND w_profils.bul = w_bul.bul + AND w_profils.bul_date_debut = w_bul.date_debut + left join w_rub_brut on true + and w_rub_brut.rub = w_hp.rub + and w_hp.date_fin between w_rub_brut.date_debut and w_rub_brut.date_fin + left join w_rub_cotsal on true + and w_rub_cotsal.rub = w_hp.rub + and w_hp.date_fin between w_rub_cotsal.date_debut and w_rub_cotsal.date_fin + left join w_rub_cotpat on true + and w_rub_cotpat.rub = w_hp.rub + and w_hp.date_fin between w_rub_cotpat.date_debut and w_rub_cotpat.date_fin + left join w_rub_netimpos on true + and w_rub_netimpos.rub = w_hp.rub + and w_hp.date_fin between w_rub_netimpos.date_debut and w_rub_netimpos.date_fin + left join w_rub_netpayer on true + and w_rub_netpayer.rub = w_hp.rub + and w_hp.date_fin between w_rub_netpayer.date_debut and w_rub_netpayer.date_fin + left join w_rub_h_2 on true + and w_rub_h_2.rub = w_hp.rub + --and w_hp.date_fin between w_rub_heures.date_debut and w_rub_heures.date_fin + left join w_rub_heures_dads on true + and w_rub_heures_dads.rub = w_hp.rub + left join w_asso_comptes on w_asso_comptes.hp_ctid = w_hp.hp_ctid + LEFT JOIN rh.p_contrats on p_contrats.numero_contrat = w_profils.cnt + LEFT JOIN rh.p_contrats_mois on 1=1 + AND p_contrats_mois.contrat_id = p_contrats.oid + AND p_contrats_mois.mois_activite = w_bul.mois + left join w_rub_odnet_pat on w_rub_odnet_pat.rub = w_hp.rub + where true + group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37, + w_rub_h_2.rub, w_rub_h_2.is_montant, w_rub_heures_dads.rub, w_rub_brut.rub, w_rub_cotsal.rub, w_rub_cotpat.rub, w_rub_netpayer.rub, w_rub_netimpos.rub, w_hp.mt, w_hp.base + HAVING 1!=1 + OR case when w_rub_h_2.rub is not null then 1 else 0 end != 0 + OR case when w_rub_heures_dads.rub is not null then 1 else 0 end != 0 + OR case when w_rub_brut.rub is not null then w_hp.mt else 0 end != 0 + OR case when w_rub_cotpat.rub is not null then w_hp.mt else 0 end != 0 + OR case when w_rub_cotsal.rub is not null then w_hp.mt else 0 end != 0 + OR case when w_rub_netpayer.rub is not null then w_hp.mt else 0 end != 0 + OR case when w_rub_netimpos.rub is not null then w_hp.mt else 0 end != 0 + ; + + -- Associer les bulletins hors contrat (is null) avec le contrat précédent. + UPDATE w_historique_paie + SET contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + w_historique_paie.oid, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_historique_paie + join rh.p_contrats_mois on true + and p_contrats_mois.salarie_id = w_historique_paie.salarie_id + and p_contrats_mois.date_fin < w_historique_paie.date_debut + where contrat_mois_id is null + group by 1) as subq + WHERE true + AND w_historique_paie.oid = subq.oid + AND w_historique_paie.contrat_mois_id is null + ; + + SELECT base.cti_stash_table_constraints('rh.p_historique_paie') + ; + + SELECT base.cti_stash_table_indexes('rh.p_historique_paie') + ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie ( + oid, + age_id, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + montant_od_net_patronale, + organisme_cotisation_id, + profil_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id) + SELECT + oid, + age_id, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + montant_od_net_patronale, + organisme_cotisation_id, + profil_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id + FROM w_historique_paie + ; + + -- Inserer pour chaque bulletin une ligne qui va faire le compte avec le total + INSERT INTO rh.p_historique_paie ( + age_id, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id, + code_original) + SELECT + age_id, + 0, + contrat_id, + contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0, + sum(chi.montant_brut - subq.montant_brut), + 0, -- sum(chi.montant_cotisation_patronale - subq.montant_cotisation_patronale), désactivé pour l'instant. + sum(chi.montant_cotisation_salarie - subq.montant_cotisation_salarie), + 0, + sum(chi.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie), + sum(chi.montant_net_imposable_salarie - subq.montant_net_imposable_salarie), + 0, + subq.organisme_cotisation_id, + subq.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + subq.salarie_id, + 0, + 0, + 0, + 0 -- Le code original est utilisé pour identifier quelle vague d'UPDATE a servi à faire la mise à jour (cf. plus bas). + FROM ( + SELECT + hp.age_id, + hp.contrat_id, + hp.contrat_mois_id, + hp.date_debut, + hp.date_fin, + hp.date_paie, + hp.mois_paie as mois_activite, -- il ne faut pas mettre le mois d'activite sinon on a plusieurs lignes et la C000 est mal calculée. + hp.mois_paie, + sum(montant_brut) as montant_brut, + sum(montant_cotisation_patronale) as montant_cotisation_patronale, + sum(montant_cotisation_salarie) as montant_cotisation_salarie, + sum(montant_net_a_payer_salarie) as montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) as montant_net_imposable_salarie, + hp.organisme_cotisation_id, + hp.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + hp.salarie_id, + hp.bul + FROM w_historique_paie AS hp + JOIN rh.p_salaries ON p_salaries.oid = hp.salarie_id + GROUP BY 1,2,3,4,5,6,7,8, 14,15,16,17,18) as subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_chiffrier AS chi ON 1=1 + AND chi.mat = p_salaries.matricule + AND chi.bul = subq.bul + AND chi.date_debut = subq.date_debut + AND chi.date_fin = subq.date_fin + GROUP BY 1,2,3,4,5,6,7,8,9,10, 14, 17,18,19,20,21,22,23 + HAVING 1!=1 + OR sum(chi.montant_brut - subq.montant_brut) != 0 + -- OR sum(chi.montant_cotisation_patronale - subq.montant_cotisation_patronale) != 0 -- désactivé pour l'instant. + OR sum(chi.montant_cotisation_salarie - subq.montant_cotisation_salarie) != 0 + OR sum(chi.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie) != 0 + OR sum(chi.montant_net_imposable_salarie - subq.montant_net_imposable_salarie) != 0 + ; + + ]]> + + + + + + = CONCAT(SPLIT_PART(rhp('rhprovider_start'), '-', 1), SPLIT_PART(rhp('rhprovider_start'), '-', 2))::int + group by 1,2,3,4,5,6,7 + having sum(montant) is not null), + ven_1 as ( + select + imputation, + periode_imputation, + periode_origine, + matricule, + contrat, + poste, + compte, + montant, + case sum(montant) over w1 + when 0 then 1.0 / count(*) over w1 + else round(base.cti_division(montant, sum(montant) over w1), 6) + end as ratio, + row_number() over w2 as rang + from ven_0 + window w1 as (partition by matricule, contrat, periode_imputation, periode_origine, poste, compte), + w2 as (partition by matricule, contrat, periode_imputation, periode_origine, poste, compte order by montant desc)), + ven_corr as ( + select + matricule, + contrat, + periode_imputation, + periode_origine, + poste, + compte, + 1.0 - sum(ratio) as corr + from ven_1 + group by 1,2,3,4,5,6 + having sum(ratio) != 1), + ven_tot as ( + select + ven_1.periode_imputation, + ven_1.periode_origine, + ven_1.matricule, + ven_1.contrat, + ven_1.poste, + ven_1.compte, + sum(ven_1.montant) as montant, + array_agg(ven_1.imputation order by ven_1.imputation) as imp, + array_agg(case when corr is not null and ven_1.rang = 1 then ven_1.ratio + ven_corr.corr else ven_1.ratio end order by ven_1.imputation) as rat, + nextval('ventilation_id') as ventilation_id + from ven_1 + left join ven_corr on 1=1 + and ven_corr.matricule = ven_1.matricule + and ven_corr.contrat = ven_1.contrat + and ven_corr.periode_imputation = ven_1.periode_imputation + and ven_corr.periode_origine = ven_1.periode_origine + and ven_corr.poste = ven_1.poste + and ven_corr.compte = ven_1.compte + group by 1,2,3,4,5,6) + select + periode_imputation, + periode_origine, + matricule, + contrat, + poste, + compte, + sum(montant) over w as montant_tot, -- sans periode_origine. + 0 = ANY(array_agg(montant) over w) as contains_zero,-- indicateur qui permet de traiter le cas des sous-périodes != imputation avec des montant_det à 0. + montant as montant_det, + imp, + rat, + ventilation_id + from ven_tot + window w as (partition by matricule, contrat, periode_imputation, poste, compte) + ; + + -- Création de la table des ventilations corrigées 2 (avec totalisation à date d'imputation). + DROP TABLE IF EXISTS w_ven_imp + ; + + CREATE TEMP TABLE w_ven_imp AS + with ven_0 as ( + select + replace(imputation, 'JR00', 'JH00') as imputation, + ('20'||periode_imputation)::int as periode_imputation, + matricule, + contrat, + poste, + compte, + sum(montant) as montant + from prod_pleiades2.a01_compta as a01_compta -- plus v_a01_compta car pas de notion de contrat avant 2017. + where 1=1 + AND ecriture = 'C' + AND ('20'||periode_imputation)::int >= CONCAT(SPLIT_PART(rhp('rhprovider_start'), '-', 1), SPLIT_PART(rhp('rhprovider_start'), '-', 2))::int + group by 1,2,3,4,5,6 + having sum(montant) is not null), + ven_1 as ( + select + imputation, + periode_imputation, + matricule, + contrat, + poste, + compte, + montant, + round(base.cti_division(montant, sum(montant) over (partition by matricule, contrat, periode_imputation, poste, compte)), 6) as ratio, + row_number() over (partition by matricule, contrat, periode_imputation, poste, compte order by montant desc) as rang + from ven_0), + ven_corr as ( + select + matricule, + contrat, + periode_imputation, + poste, + compte, + 1.0 - sum(ratio) as corr + from ven_1 + group by 1,2,3,4,5 + having sum(ratio) != 1), + ven_tot as ( + select + ven_1.periode_imputation, + ven_1.matricule, + ven_1.contrat, + ven_1.poste, + ven_1.compte, + sum(ven_1.montant) as montant, + array_agg(ven_1.imputation order by ven_1.imputation) as imp, + array_agg(case when corr is not null and ven_1.rang = 1 then ven_1.ratio + ven_corr.corr else ven_1.ratio end order by ven_1.imputation) as rat, + nextval('ventilation_id') as ventilation_id + from ven_1 + left join ven_corr on 1=1 + and ven_corr.matricule = ven_1.matricule + and ven_corr.contrat = ven_1.contrat + and ven_corr.periode_imputation = ven_1.periode_imputation + and ven_corr.poste = ven_1.poste + and ven_corr.compte = ven_1.compte + group by 1,2,3,4,5) + select + periode_imputation, + matricule, + contrat, + poste, + compte, + sum(montant) over w as montant_tot, -- sans periode_origine. + 0 = ANY(array_agg(montant) over w) as contains_zero,-- indicateur qui permet de traiter le cas des sous-périodes != imputation avec des montant_det à 0. + montant as montant_det, + imp, + rat, + ventilation_id + from ven_tot + window w as (partition by matricule, contrat, periode_imputation, poste, compte) + ; + + -- Récupération des différents schémas/modèles de ventilation. + TRUNCATE rh.p_ventilation + ; + + INSERT INTO rh.p_ventilation(oid, code, texte, plan_analytique_id) + select + ventilation_id, + ventilation_id::text, + array_to_string(imp, ',')||' @ '||array_to_string(rat, ','), + 1 + FROM w_ven + group by 1,2,3,4 + UNION ALL + select + ventilation_id, + ventilation_id::text, + array_to_string(imp, ',')||' @ '||array_to_string(rat, ','), + 1 + FROM w_ven_imp + group by 1,2,3,4 + UNION ALL + SELECT + 0, + 'N/R', + 'Non renseignée', + 1 + ; + + TRUNCATE rh.p_ventilation_section + ; + INSERT INTO rh.p_ventilation_section( + ventilation_id, + section_analytique_id, + section_analytique_code, + section_analytique_texte, + ratio) + SELECT + ventilation_id, + t_section_analytique.oid, + t_section_analytique.code, + t_section_analytique.texte, + rat + FROM ( + SELECT + ventilation_id, + unnest(imp) as imp, + unnest(rat) as rat + FROM w_ven + group by 1,2,3) as subq + JOIN rh.t_section_analytique on t_section_analytique.code_original = imp + UNION ALL + SELECT + ventilation_id, + t_section_analytique.oid, + t_section_analytique.code, + t_section_analytique.texte, + rat + FROM ( + SELECT + ventilation_id, + unnest(imp) as imp, + unnest(rat) as rat + FROM w_ven_imp + group by 1,2,3) as subq + JOIN rh.t_section_analytique on t_section_analytique.code_original = imp + UNION ALL + SELECT + 0, + oid, + code, + texte, + 1 + FROM rh.t_section_analytique + WHERE oid = 0 + ; + + -- VENTILATION DE LA MASSE SALARIALE. + -- OK BRUT Ventilation précise... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and w_ven.montant_det = w_historique_paie.ori_mt-- Association obligatoire en détaillé. + -- and not w_ven.contains_zero -- Ne pas prendre les ventilations qui sont égales à 0 en total pour les sous-période != imputation. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 1 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- OK @BRUT Ventilation précise mais en valeur absolue (= 1ère passe)... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and @w_ven.montant_det = @w_historique_paie.ori_mt-- Association obligatoire en détaillé. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 2 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- OK BRUT HP TOT Ventilation avec montant totalisé en paie en prenant en compte la sous-période... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and w_ven.montant_det = w_historique_paie.montant_total -- Association obligatoire en détaillé imputation mais totalisé. + -- and not w_ven.contains_zero -- Ne pas prendre les ventilations qui sont égales à 0 en total pour les sous-période != imputation. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 3 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- OK BRUT HP TOT Ventilation avec montant totalisé @bsolue en paie en prenant en compte la sous-période... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and @w_ven.montant_det = @w_historique_paie.montant_total -- Association obligatoire en détaillé imputation mais totalisé. + -- and not w_ven.contains_zero -- Ne pas prendre les ventilations qui sont égales à 0 en total pour les sous-période != imputation. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = '3.1' + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- OK BRUT Ventilation lorsque pas les mêmes montant sous-période entre paie et a01_compta (totaux égaux)... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + montant_total != montant_total_imputation as contains_retro, -- permet de cibler uniquement les rubriques avec de la rétro. + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + --and w_ven.montant_det = w_historique_paie.ori_mt-- non. + -- and not w_ven.contains_zero -- Ne pas prendre les ventilations qui sont égales à 0 en total pour les sous-période != imputation. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 4 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + and subq.contains_retro + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- COT ventilation sans sous-période avec montant (totalisé à l'imputation)... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven_imp.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven_imp on 1=1 + and w_ven_imp.matricule = w_historique_paie.mat + and w_ven_imp.contrat = w_historique_paie.relatnum + and w_ven_imp.poste = w_historique_paie.rub + and w_ven_imp.periode_imputation = w_historique_paie.mois_paie + -- and w_ven_imp.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and w_ven_imp.montant_tot = w_historique_paie.montant_total_imputation -- Association obligatoire en total imputation. + join rh.t_compte on t_compte.code_original = w_ven_imp.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 5 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- OK AST Ventilation des astreintes + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + t_compte.oid as compte_id + from w_historique_paie + join (select to_id from rh.t_listes join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid where code = 'RUB_AST_9956') as subq ON subq.to_id = w_historique_paie.rubrique_id + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.poste = '9956' + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 6 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- VENTILATION DES ETPS. + -- OK Ventilation précise... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and w_ven.montant_det = w_historique_paie.base -- Association obligatoire en détaillé. + -- and not w_ven.contains_zero -- Ne pas prendre les ventilations qui sont égales à 0 en total pour les sous-période != imputation. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 7 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- ETP @BSOLUE. + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and @w_ven.montant_det = @w_historique_paie.base -- Association obligatoire en détaillé. + -- and not w_ven.contains_zero -- Ne pas prendre les ventilations qui sont égales à 0 en total pour les sous-période != imputation. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 8 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + -- OK Ventilation avec base totalisé en paie en prenant en compte la sous-période... + WITH subq AS ( + select + w_historique_paie.oid, + w_ven.ventilation_id, + case when compte = '999999999' then w_historique_paie.compte_id else t_compte.oid end as compte_id -- on ne change pas le compte lorsqu'il s'agit du 999999999. + from w_historique_paie + join w_ven on 1=1 + and w_ven.matricule = w_historique_paie.mat + and w_ven.contrat = w_historique_paie.relatnum + and w_ven.poste = w_historique_paie.rub + and w_ven.periode_imputation = w_historique_paie.mois_paie + and w_ven.periode_origine = substr(w_historique_paie.sous_periode, 3, 4) -- ... On prend en compte la sous_periode (date d'activité). + and w_ven.montant_det = w_historique_paie.base_total -- Association obligatoire en détaillé imputation mais totalisé. + -- and not w_ven.contains_zero -- NON car en total. Ne pas prendre les ventilations qui sont égales à 0 en total pour les sous-période != imputation. + join rh.t_compte on t_compte.code_original = w_ven.compte + where rub not in (select rub from w_exc_rub)) + UPDATE rh.p_historique_paie SET + ventilation_1_id = subq.ventilation_id, + compte_id = subq.compte_id, + code_original = 9 + FROM subq + WHERE true + and p_historique_paie.oid = subq.oid + AND p_historique_paie.ventilation_1_id = 0 + ; + + SELECT base.cti_stash_pop_table_constraints('rh.p_historique_paie') + ; + + SELECT base.cti_stash_pop_table_indexes('rh.p_historique_paie') + ; + + ]]> + + + 0 FROM rh.t_divers WHERE code = 'IMP_INC_MAR') then ta_motifevt.motif IN (SELECT trim(unnest(string_to_array(valeur, ','))) FROM rh.t_divers WHERE code = 'IMP_INC_MAR') else true end + and ta_motifevt.motif NOT IN (SELECT trim(unnest(string_to_array(valeur, ','))) FROM rh.t_divers WHERE code = 'IMP_EXC_MAR') + group by 1,2,3,4,5,6,7,8 + ; + + DROP TABLE IF EXISTS w_arrets_mois -- version retravaillée (aggrégation des arrêts de même type continus sur un même mois). + ; + + CREATE TEMP TABLE w_arrets_mois AS + with clustering as ( + select + *, + case when lag(date_fin) over (partition by mat, motif order by date_debut) = date_debut - '1 day'::interval then null else true end as new_cluster + from w_arrets_0 + order by mat, motif, date_debut), + assigned_clustering as ( + select + *, + mat||'-'||count(new_cluster) over (order by mat, motif, date_debut) as cluster_id + from clustering + ) + select + mat as matricule, + motif, + cluster_id, + array_agg(uid) as uid, -- uid d'origine potentiellement dédoublé (inutilisable). + mat||'-'||row_number() over (order by mois) as uid2, -- uid ventilé. + min(date_debut) as date_debut, + max(date_fin) as date_fin, + mois as mois, + sum(nb_jours) as nb_jours, + sum(nb_heures) as nb_heures + from assigned_clustering + group by mat, motif, cluster_id, mois + ; + + DROP TABLE IF EXISTS w_arrets_mois_1 -- ventilation retravaillée + id de contrats. + ; + + CREATE TEMP TABLE w_arrets_mois_1 AS + select + w_arrets_mois.*, + p_salaries.oid as salarie_id, + p_contrats_mois.contrat_id, + p_contrats_mois.oid as contrat_mois_id + from w_arrets_mois + join rh.p_salaries on p_salaries.matricule = w_arrets_mois.matricule + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = p_salaries.oid + and base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, w_arrets_mois.date_debut, w_arrets_mois.date_fin) + ; + + -- Agrégation des arrêts de travail. + DROP TABLE IF EXISTS w_arrets + ; + + CREATE TEMP TABLE w_arrets AS + select + matricule, + motif, + cluster_id, + matricule||'-'||motif||'-'||cluster_id as uid3, -- un uid3 par arrêt + --array_agg(uid) as uid, + array_agg(uid2) as uid2, -- plusieurs uid2 par uid3 + min(date_debut) as date_debut, + max(date_fin) as date_fin, + max(mois) as mois, + sum(nb_jours) as nb_jours, + sum(nb_heures) as nb_heures + from w_arrets_mois + group by matricule, motif, cluster_id + ; + + -- Alimentation des arrêts de travail + TRUNCATE rh.p_arrets_travail + ; + + ALTER SEQUENCE rh.s_arrets_travail RESTART WITH 1 + ; + + DROP TABLE IF EXISTS w_arrets_travail + ; + + CREATE TEMP TABLE w_arrets_travail AS + SELECT p_salaries.oid as salarie_id, + (max(ARRAY[extract(EPOCH from p_contrats.date_fin), p_contrats.oid]))[2] as contrat_id, + w_arrets.mois as mois_activite, + w_arrets.date_debut, + w_arrets.date_fin, + CASE WHEN w_arrets.date_fin = '2099-12-31'::date THEN '2099-12-31'::date ELSE (w_arrets.date_fin + INTERVAL '1 day')::date END AS date_reprise, + coalesce(t_motifs_arret.oid, 0) AS motif_arret_id, + 0 AS precision_motif_arret_id, + w_arrets.nb_jours, + w_arrets.nb_heures, + w_arrets.cluster_id, + w_arrets.uid2, + w_arrets.uid3, + nextval('rh.s_arrets_travail'::regclass) as oid + FROM w_arrets + JOIN rh.p_salaries ON p_salaries.matricule = w_arrets.matricule + LEFT JOIN rh.t_motifs_arret ON t_motifs_arret.code_original = w_arrets.motif + JOIN rh.p_contrats ON 1=1 -- Ne pas s'inquièter si cetains arrets ne sont pas remontés faute d'association avec un contrat car il doit OBLIGRATOIREMENT avoir un contrat associé dans PLEIADES. + and p_contrats.salarie_id = p_salaries.oid + and base.cti_overlaps(p_contrats.date_debut, p_contrats.date_fin, w_arrets.date_debut, w_arrets.date_fin) + GROUP BY 1,3,4,5,6,7,8,9,10,11,12,13 + ; + + INSERT INTO rh.p_arrets_travail( + oid, + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + date_reprise, + motif_arret_id, + precision_motif_arret_id, + nb_jours, + nb_heures + ) + select + oid, + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + date_reprise, + motif_arret_id, + precision_motif_arret_id, + nb_jours, + nb_heures + from w_arrets_travail + ; + + -- Ventilation mensuelle des arrêts de travail + TRUNCATE rh.p_arrets_travail_mois + ; + + INSERT INTO rh.p_arrets_travail_mois( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + nb_debut_arret, + nb_fin_arret, + nb_reprise_apres_arret, + date_debut, + date_fin, + nb_jours, + nb_heures, + nb_arret + ) + SELECT + subq.oid AS arret_travail_id, + w_arrets_mois_1.salarie_id AS salarie_id, + w_arrets_mois_1.contrat_id AS contrat_id, + w_arrets_mois_1.contrat_mois_id AS contrat_mois_id, + p_contrats_mois.mois_activite, + CASE WHEN w_arrets_mois_1.date_debut BETWEEN min(p_contrats_mois.date_debut) AND max(p_contrats_mois.date_fin) THEN 1 ELSE 0 END AS nombre_debut_arret, + CASE WHEN w_arrets_mois_1.date_fin BETWEEN min(p_contrats_mois.date_debut) AND max(p_contrats_mois.date_fin) THEN 1 ELSE 0 END AS nombre_fin_arret, + 0 AS nb_reprise_apres_arret, + w_arrets_mois_1.date_debut, + w_arrets_mois_1.date_fin, + nb_jours, + nb_heures, + 1 + FROM (select + unnest(uid2) as uid2, + salarie_id, + contrat_id, + cluster_id, + oid + from w_arrets_travail) as subq + join w_arrets_mois_1 on w_arrets_mois_1.uid2 = subq.uid2 + join rh.p_contrats_mois on p_contrats_mois.oid = w_arrets_mois_1.contrat_mois_id + group by 1,2,3,4,5,8,9,10,11,12,13,w_arrets_mois_1.date_debut,w_arrets_mois_1.date_fin + ; + + -- Calcul de l'indicateur 'nb reprise après arrêt'. + update rh.p_arrets_travail_mois + set nb_reprise_apres_arret = subq.nb_reprise_apres_arret + from ( + select + t1.arret_travail_id, + t1.mois_activite, + min(case when p_arrets_travail.date_reprise between t2.date_debut and t2.date_fin then 0 else 1 end) as nb_reprise_apres_arret + from rh.p_arrets_travail_mois as t1 + join rh.p_arrets_travail ON p_arrets_travail.oid = t1.arret_travail_id + left join rh.p_arrets_travail_mois as t2 ON 1=1 + AND t1.salarie_id = t2.salarie_id + AND t1.date_debut != t2.date_debut + AND t1.date_fin != t2.date_fin + GROUP BY t1.arret_travail_id, t1.mois_activite + order by 2 desc + ) as subq + where 1=1 + and p_arrets_travail_mois.arret_travail_id = subq.arret_travail_id + and p_arrets_travail_mois.mois_activite = subq.mois_activite + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_QSP.XML b/import_rh/iCTI_import_rh_QSP.XML new file mode 100644 index 0000000..9f9931f --- /dev/null +++ b/import_rh/iCTI_import_rh_QSP.XML @@ -0,0 +1,1669 @@ + + + + + + + + + 0 + AND substr(md5(qualif), 1, 8) NOT IN (SELECT code_original FROM rh.t_qualifications) + GROUP BY 1,2,3,4 + ; + + -- Màj des rubriques + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT + code_rub, + lib_rub, + substr(lib_rub, 1, 50), + seq_rub, + rank() OVER (ORDER BY code_rub) + FROM prod_qsp.rubriques + WHERE 1=1 + AND seq_rub NOT IN (SELECT code_original FROM rh.t_rubriques) + GROUP BY 1,2,3,4 + ; + + -- création des rubriques CTI de cumul + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C000', 'Ecart cumulé', 'Ecart cumulé', 'C000', -1 + WHERE 'C000' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + -- Màj des situations de famille + INSERT INTO rh.t_situations_famille(code, texte, texte_court, code_original) + SELECT situation_fam, situation_fam, substr(situation_fam,1,50), situation_fam + FROM prod_qsp.salaries + WHERE 1=1 + AND situation_fam NOT IN (SELECT code_original FROM rh.t_situations_famille) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code, texte, texte_court, code_original) + SELECT type_contr, lib_contr, substr(lib_contr,1,50), type_contr + FROM prod_qsp.types_contr + WHERE 1=1 + AND type_contr NOT IN (SELECT code_original FROM rh.t_types_contrat) + GROUP BY 1,2,3,4 + ; + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + SELECT + histo_emp.seq_statut||lpad(code_statut_conv, 2, ' '), + histo_emp.seq_statut||lpad(code_statut_conv, 2, ' '), + lib_statut||' '||code_statut_conv, + substr(lib_statut||' '||code_statut_conv, 1, 50) + FROM prod_qsp.histo_emp + LEFT JOIN prod_qsp.statuts ON statuts.seq_statut = histo_emp.seq_statut + WHERE 1=1 + AND histo_emp.seq_statut||lpad(code_statut_conv, 2, ' ') NOT IN (SELECT code_original FROM rh.t_statuts) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + SELECT + CASE WHEN heures_contr IN (151.67, 169, 0) THEN 'TC' ELSE 'TP'||trim(to_char(heures_contr, '000.00')) END, + CASE WHEN heures_contr IN (151.67, 169, 0) THEN 'TC' ELSE 'TP'||trim(to_char(heures_contr, '000.00')) END, + CASE WHEN heures_contr IN (151.67, 169, 0) THEN 'Temps complet' ELSE 'Temps partiel '||replace(round(heures_contr / 151.67 * 100, 2), '.', ',')||' %' END, + CASE WHEN heures_contr IN (151.67, 169, 0) THEN 'Temps complet' ELSE 'Temps partiel '||replace(round(heures_contr / 151.67 * 100, 2), '.', ',')||' %' END + FROM prod_qsp.histo_emp + WHERE 1=1 + AND CASE WHEN heures_contr IN (151.67, 169, 0) THEN 'TC' ELSE 'TP'||trim(to_char(heures_contr, '000.00')) END NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + GROUP BY 1,2,3,4 + ; + + -- @TODO Màj des types d'horaire + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + SELECT seq_service, code_service, nom_service, substr(nom_service, 1, 50) + FROM prod_qsp.services + WHERE 1=1 + AND seq_service NOT IN (SELECT code_original FROM rh.t_services) + GROUP BY 1,2,3,4 + ; + + -- Màj des spécialités + INSERT INTO rh.t_specialites(code_original, code, texte, texte_court) + SELECT seq_nature, code_nature, lib_nature, substr(lib_nature, 1, 50) + FROM prod_qsp.natures_emp + WHERE 1=1 + AND seq_nature NOT IN (SELECT code_original FROM rh.t_specialites) + GROUP BY 1,2,3,4 + ; + + -- Màj des codes emploi + INSERT INTO rh.t_codes_emploi(code_original, code, texte, texte_court) + SELECT seq_categorie, seq_categorie, lib_categorie, substr(lib_categorie, 1, 50) + FROM prod_qsp.categories + WHERE 1=1 + AND seq_categorie NOT IN (SELECT code_original FROM rh.t_codes_emploi) + GROUP BY 1,2,3,4 + ; + + -- @TODO Màj des sociétés d'interim + + -- Màj des grilles + INSERT INTO rh.t_grilles(code_original, code, texte, texte_court) + SELECT + lpad(num_echelon, 4, '0') || lpad(chevron, 2, '0') || lpad(val_coef, 4, '0'), + lpad(num_echelon, 4, '0') || lpad(chevron, 2, '0') || lpad(val_coef, 4, '0'), + 'Echelon : '||num_echelon||' - Niveau : '||chevron||' - Coefficient : '||val_coef, + 'Ech '||num_echelon||' Niv '||chevron||' Coef '||val_coef + FROM prod_qsp.val_echelon + WHERE 1=1 + AND lpad(num_echelon, 4, '0') || lpad(chevron, 2, '0') || lpad(val_coef, 4, '0') NOT IN (SELECT code_original FROM rh.t_grilles) + GROUP BY 1,2,3,4 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT code_groupe, code_groupe, code_groupe, substr(code_groupe, 1, 50) + FROM prod_qsp.groupes + WHERE 1=1 + AND code_groupe NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + GROUP BY 1 + ; + + -- Màj des comptes + INSERT INTO rh.t_compte(code_original, code, texte, texte_court) + SELECT rad_cpt_compta_sal, rad_cpt_compta_sal, rad_cpt_compta_sal, rad_cpt_compta_sal + FROM prod_qsp.rubriques + WHERE 1=1 + AND rad_cpt_compta_sal NOT IN (SELECT code_original FROM rh.t_compte) + GROUP BY 1 + UNION + SELECT rad_cpt_compta_pat, rad_cpt_compta_pat, rad_cpt_compta_pat, rad_cpt_compta_pat + FROM prod_qsp.rubriques + WHERE 1=1 + AND rad_cpt_compta_pat NOT IN (SELECT code_original FROM rh.t_compte) + GROUP BY 1 + ; + + -- Màj des motifs d'arret + INSERT INTO rh.t_motifs_arret(code_original, code, texte, texte_court) + SELECT + seq_nat_abs, + lib_c_abs, + nature_abs, + substr(nature_abs, 1, 50) + FROM prod_qsp.natures_absence + WHERE 1=1 + AND seq_nat_abs NOT IN (SELECT code_original FROM rh.t_motifs_arret) + GROUP BY 1,2,3,4 + ; + + -- @TODO Màj des précisions du motif d'arrêt + + -- @TODO Màj des motifs de visite médicale + + -- @TODO Màj des circonstances d'accident du travail + + -- @TODO Màj des lieux d'accident du travail + + -- @TODO Màj de la nature de l'accident du travail + + -- @TODO Màj des sièges d'accident du travail + + -- @TODO Màj des listes de formations + + -- Màj des sections analytiques compta : prévu mais pas alimenté. + + -- Màj des sections analytiques paie : prévu mais pas alimenté. + + DROP TABLE IF EXISTS temp.x_ref_rubrique + ; + + CREATE TABLE temp.x_ref_rubrique AS + with rub_det_0 as ( + select + histo_lignes_bul.code_rub as code, + histo_lignes_bul.seq_rub as code_original, + histo_lignes_bul.code_rub between '100' and '499' as brut, + false as hresp, + false as hresw, + false as odns, + false as odnp, + histo_lignes_bul.code_rub between '501' and '900' as cosd, + histo_lignes_bul.code_rub between '501' and '900' as copa, + max(lib_rub) as texte + from prod_qsp.histo_lignes_bul + where 1=1 + -- and histo_lignes_bul.code_rub not in ('100', '387', '627 A', '627 Z', '699', '700', '896', '899', '900') + -- and histo_lignes_bul.code_rub not in ('898', '147') -- Spécifique Arago (= icti_344). + group by 1,2,3,4,5,6,7,8,9 + ) + , rub_det_1 as ( + select + code, + code_original, + texte, + bool_or(brut) or bool_or(odns) or bool_or(odnp) or bool_or(cosd) or bool_or(copa) AS p_detail, + false AS p_nombre, + bool_or(brut) or bool_or(odns) or bool_or(odnp) or bool_or(cosd) or bool_or(copa) AS p_base, + bool_or(hresp) AS p_heures_payees, + bool_or(hresw) AS p_heures_travaillees, + bool_or(brut) or bool_or(odnp) or bool_or(copa) AS p_masse_salariale, + bool_or(brut) AS p_brut, + false AS p_avantage_nature, + false AS p_frais_imposables, + bool_or(cosd) AS p_cotisation_salarie, + bool_or(copa) AS p_cotisation_patronale, + bool_or(odns) AS p_od_net_salarie, + false AS p_od_net_patronale, + bool_or(brut) or bool_or(cosd) AS p_net_imposable, + -- case when bool_or(cosd) then 1 else -1 end as c_net_imposable, + bool_or(brut) or bool_or(cosd) or bool_or(odns) AS p_net_a_payer + -- case when bool_or(cosd) then 1 else -1 end as c_net_a_payer + from rub_det_0 + group by 1,2,3 + ) + SELECT + code_original, + code, + texte, + null::text as texte_court, + -1 as rang_edition, + false as p_cumul, + p_detail as p_detail, + p_nombre as p_nombre, + 0 as s_nombre, + 1 as c_nombre, + p_base as p_base, + 1 as s_base, + 1 as c_base, + false as p_heures_contrat, + 0 as s_heures_contrat, + 1 as c_heures_contrat, + p_heures_payees as p_heures_payees, + 0 as s_heures_payees, + 1 as c_heures_payees, + p_heures_travaillees as p_heures_travaillees, + 0 as s_heures_travaillees, + 1 as c_heures_travaillees, + p_masse_salariale as p_masse_salariale, + case when p_cotisation_patronale or p_od_net_patronale then 5 else 3 end as s_masse_salariale, + case when p_cotisation_patronale then -1 else 1 end as c_masse_salariale, + p_brut as p_brut, + 3 as s_brut, + 1 as c_brut, + p_avantage_nature as p_avantage_nature, + 3 as s_avantage_nature, + 1 as c_avantage_nature, + p_frais_imposables as p_frais_imposables, + 3 as s_frais_imposables, + 1 as c_frais_imposables, + p_cotisation_salarie as p_cotisation_salarie, + 3 as s_cotisation_salarie, + 1 as c_cotisation_salarie, + p_cotisation_patronale as p_cotisation_patronale, + 5 as s_cotisation_patronale, + -1 as c_cotisation_patronale, + p_od_net_salarie as p_od_net_salarie, + 3 as s_od_net_salarie, + 1 as c_od_net_salarie, + p_od_net_patronale as p_od_net_patronale, + 5 as s_od_net_patronale, + 1 as c_od_net_patronale, + p_net_imposable as p_net_imposable, + 3 as s_net_imposable, + 1 as c_net_imposable, + p_net_a_payer as p_net_a_payer, + 3 as s_net_a_payer, + 1 as c_net_a_payer + FROM rub_det_1 + ; + + -- Pré-paramétrage automatique des rubriques (au mieux). + -- Cette requête n'intervient pas sur les rubriques paramétrées à la main. + update rh.t_rubriques + set + p_cumul = x_ref_rubrique.p_cumul, + p_detail = x_ref_rubrique.p_detail, + p_nombre = x_ref_rubrique.p_nombre, + s_nombre = x_ref_rubrique.s_nombre, + c_nombre = x_ref_rubrique.c_nombre, + p_base = x_ref_rubrique.p_base, + s_base = x_ref_rubrique.s_base, + c_base = x_ref_rubrique.c_base, + p_heures_contrat = x_ref_rubrique.p_heures_contrat, + s_heures_contrat = x_ref_rubrique.s_heures_contrat, + c_heures_contrat = x_ref_rubrique.c_heures_contrat, + p_heures_payees = x_ref_rubrique.p_heures_payees, + s_heures_payees = x_ref_rubrique.s_heures_payees, + c_heures_payees = x_ref_rubrique.c_heures_payees, + p_heures_travaillees = x_ref_rubrique.p_heures_travaillees, + s_heures_travaillees = x_ref_rubrique.s_heures_travaillees, + c_heures_travaillees = x_ref_rubrique.c_heures_travaillees, + p_masse_salariale = x_ref_rubrique.p_masse_salariale, + s_masse_salariale = x_ref_rubrique.s_masse_salariale, + c_masse_salariale = x_ref_rubrique.c_masse_salariale, + p_brut = x_ref_rubrique.p_brut, + s_brut = x_ref_rubrique.s_brut, + c_brut = x_ref_rubrique.c_brut, + p_avantage_nature = x_ref_rubrique.p_avantage_nature, + s_avantage_nature = x_ref_rubrique.s_avantage_nature, + c_avantage_nature = x_ref_rubrique.c_avantage_nature, + p_frais_imposables = x_ref_rubrique.p_frais_imposables, + s_frais_imposables = x_ref_rubrique.s_frais_imposables, + c_frais_imposables = x_ref_rubrique.c_frais_imposables, + p_cotisation_salarie = x_ref_rubrique.p_cotisation_salarie, + s_cotisation_salarie = x_ref_rubrique.s_cotisation_salarie, + c_cotisation_salarie = x_ref_rubrique.c_cotisation_salarie, + p_cotisation_patronale = x_ref_rubrique.p_cotisation_patronale, + s_cotisation_patronale = x_ref_rubrique.s_cotisation_patronale, + c_cotisation_patronale = x_ref_rubrique.c_cotisation_patronale, + p_od_net_salarie = x_ref_rubrique.p_od_net_salarie, + s_od_net_salarie = x_ref_rubrique.s_od_net_salarie, + c_od_net_salarie = x_ref_rubrique.c_od_net_salarie, + p_od_net_patronale = x_ref_rubrique.p_od_net_patronale, + s_od_net_patronale = x_ref_rubrique.s_od_net_patronale, + c_od_net_patronale = x_ref_rubrique.c_od_net_patronale, + p_net_imposable = x_ref_rubrique.p_net_imposable, + s_net_imposable = x_ref_rubrique.s_net_imposable, + c_net_imposable = x_ref_rubrique.c_net_imposable, + p_net_a_payer = x_ref_rubrique.p_net_a_payer, + s_net_a_payer = x_ref_rubrique.s_net_a_payer, + c_net_a_payer = x_ref_rubrique.c_net_a_payer + from temp.x_ref_rubrique + where 1=1 + AND t_rubriques.code_original = x_ref_rubrique.code_original + AND NOT t_rubriques.user_modified + ; + + ]]> + + + + + 0 + -- and bulletins.num_bul_annule = 0 -- On prend tous les bulletins, y compris les réguls. + AND bulletins.date_paye >= rhp('rhprovider_start')::date + ; + + TRUNCATE rh.p_chiffrier_production + ; + + INSERT INTO rh.p_chiffrier_production (entreprise_id, etablissement_id, mois, nombre_salaries, montant_brut, nombre_heures) + select + t_entreprises.oid, + t_etablissements.oid, + mois_paie, + count(distinct num_sal), + sum(res_sal), + sum(base) + from w_bulletins AS bulletins + join prod_qsp.histo_lignes_bul ON 1=1 + AND histo_lignes_bul.seq_emploi = bulletins.seq_emploi + AND case when histo_lignes_bul.NUM_BUL > 0 then histo_lignes_bul.NUM_BUL else @(histo_lignes_bul.NUM_BUL + 99999) end = bulletins.NUM_BUL + JOIN rh.t_etablissements ON t_etablissements.code_original = 1 -- @todo : code établissement en dur + JOIN rh.t_entreprises ON t_entreprises.oid = t_etablissements.entreprise_id + WHERE 1=1 + AND mois_paie >= 200901 + AND histo_lignes_bul.code_rub in ('500') + GROUP BY 1,2,3 + ; + + ]]> + + + + + + + + + + + + + + date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_entree_ets = date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND to_char(date_entree_ets, 'YYYY')::numeric >= 2009 + AND date_entree_ets < date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_sortie_ets = date_fin_contrat + FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND date_fin_contrat > date_sortie_ets + ; + + -- Calcul ancienneté au début de contrat + UPDATE rh.p_contrats + SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_calculee_mois + FROM ( + SELECT + t1.seq_emploi, + sum((t2.cti_date_fin - t2.cti_date_debut) + 1) AS anciennete_anterieure_jours, + sum((t2.cti_date_fin - t2.cti_date_debut) + 1) / 30 AS anciennete_anterieure_calculee_mois + FROM w_emplois AS t1 + JOIN w_emplois AS t2 ON 1=1 + AND t2.num_sal = t1.num_sal + AND t2.cti_date_debut < t1.cti_date_debut + group by 1 + ) AS subq + WHERE 1=1 + AND p_contrats.numero_contrat = subq.seq_emploi + ; + + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, + present_debut_mois, + present_fin_mois, + equivalent_temps_plein, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id + ) + SELECT + p_salaries.oid AS salarie_id, + p_contrats.oid AS contrat_id, + w_salarie_mois.mois AS mois, + w_salarie_mois.date_debut AS date_debut, + w_salarie_mois.date_fin AS date_fin, + CASE WHEN p_salaries.date_entree_ets BETWEEN w_salarie_mois.date_debut AND w_salarie_mois.date_fin THEN 1 ELSE 0 END AS nombre_entrees, + CASE WHEN p_salaries.date_sortie_ets BETWEEN w_salarie_mois.date_debut AND w_salarie_mois.date_fin THEN 1 ELSE 0 END AS nombre_departs, + CASE WHEN p_contrats.date_debut BETWEEN w_salarie_mois.date_debut AND w_salarie_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_contrat, + CASE WHEN p_contrats.date_fin BETWEEN w_salarie_mois.date_debut AND w_salarie_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_contrat, + 0 AS est_hors_periode, + CASE WHEN base.cti_first_day(w_salarie_mois.date_debut) BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_debut_mois, + CASE WHEN base.cti_last_day(w_salarie_mois.date_fin) BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + 0, -- L'ETP théorique est calculé plus loin à l'issue de la "Ventilation des profils". + base.cti_age(LEAST(w_salarie_mois.date_fin, w_salarie_mois.date_fin), COALESCE(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + LEAST(w_salarie_mois.date_fin, w_salarie_mois.date_fin)::date - COALESCE(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + p_contrats.anciennete_anterieure_jours + + (LEAST(w_salarie_mois.date_fin, w_salarie_mois.date_fin) - p_contrats.date_debut) + + 1 + AS anciennete_jours, + base.cti_months_between(p_contrats.date_debut, w_salarie_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + AS anciennete_mois, + floor( + ( + base.cti_months_between(p_contrats.date_debut, w_salarie_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + ) / 12 + ) AS anciennete_annee_id + FROM w_salarie_mois + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_salarie_mois.histo_emp_seq_emploi + JOIN rh.p_salaries ON p_salaries.matricule = w_salarie_mois.num_sal + WHERE 1=1 + AND w_salarie_mois.mois < to_char(now() + '1 month'::interval, 'YYYYMM') + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 + ; + + ]]> + + + 0 then histo_lignes_bul.NUM_BUL else @(histo_lignes_bul.NUM_BUL + 99999) end = bulletins.NUM_BUL + and histo_lignes_bul.num_bul = bulletins.num_bul + JOIN prod_qsp.rubriques ON rubriques.seq_rub = histo_lignes_bul.seq_rub + JOIN rh.t_rubriques on t_rubriques.code_original = rubriques.seq_rub + where false + OR t_rubriques.p_detail + OR t_rubriques.p_cumul + --GROUP BY 1,2,3,4,5,6,7,8 + ; + + DROP TABLE IF EXISTS w_hp + ; + + CREATE TEMP TABLE w_hp AS + SELECT + w_hp_0.bul_id, + p_salaries.oid as salarie_id, + date_part('year', age(w_hp_0.date_debut, date_naissance)) AS age_id, + w_hp_0.matricule as sal_code_original, + w_hp_0.matricule, + w_hp_0.date_debut, + w_hp_0.date_fin, + w_hp_0.mois_paie as mois_activite, + w_hp_0.date_fin as date_paie, + w_hp_0.mois_paie, + rubrique_id, + coalesce(t_organismes_cotisation.oid, 0) as organisme_cotisation_id, + coalesce(t_compte.oid, 0) as compte_id, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_avantage_nature, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + p_cumul, + p_detail, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] AS contrat_mois_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin), p_contrats_mois.contrat_id]))[2] AS contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin), p_contrats_mois.etablissement_id]))[2] as etablissement_id, + 0::bigint as profil_id + FROM w_hp_0 + JOIN rh.p_salaries ON p_salaries.matricule = w_hp_0.matricule + LEFT JOIN rh.t_organismes_cotisation ON t_organismes_cotisation.code_original = w_hp_0.caisse_code_original + LEFT JOIN rh.t_compte ON t_compte.code_original = w_hp_0.compte_code_original + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + AND base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, w_hp_0.date_debut, w_hp_0.date_fin) + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32 + ; + + -- Association avec le contrat précédent. + with toto as ( + SELECT + w_hp.bul_id, + (max(array[extract(epoch from w_hp.date_fin), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from w_hp.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_hp + join rh.p_contrats_mois on 1=1 + and p_contrats_mois.salarie_id = w_hp.salarie_id + and p_contrats_mois.date_fin < w_hp.date_debut + where w_hp.contrat_mois_id is null + group by 1 + ) + UPDATE w_hp set + contrat_id = toto.contrat_id, + contrat_mois_id = toto.contrat_mois_id + from toto + where w_hp.bul_id = toto.bul_id + ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie( + code_original, + etablissement_id, + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + mois_activite, + date_paie, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + montant_cotisation_salarie, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + taux_cotisation_salarie, + taux_cotisation_patronale, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id) + SELECT + w_hp.bul_id, + w_hp.etablissement_id, + w_hp.age_id, + w_hp.contrat_id, + w_hp.contrat_mois_id, + w_hp.date_debut, + w_hp.date_fin, + w_hp.mois_activite, + w_hp.date_paie, + w_hp.mois_paie, + w_hp.base, + w_hp.nombre, + w_hp.heure_contrat, + w_hp.heure_payee, + w_hp.heure_travaillee, + w_hp.montant_masse_salariale, + w_hp.montant_brut, + w_hp.montant_avantage_nature, + w_hp.montant_frais_imposables, + w_hp.montant_cotisation_salarie, + w_hp.montant_cotisation_patronale, + w_hp.montant_od_net_salarie, + w_hp.montant_od_net_patronale, + w_hp.montant_net_imposable_salarie, + w_hp.montant_net_a_payer_salarie, + w_hp.taux_cotisation_salarie, + w_hp.taux_cotisation_patronale, + w_hp.organisme_cotisation_id, + w_hp.profil_id, + w_hp.rubrique_id, + w_hp.compte_id, + w_hp.salarie_id + FROM w_hp + where p_detail + ; + + -- Création d'une table récapitulative des écarts à calculer par indicateur de paie (1 seule ligne). + DROP TABLE IF EXISTS w_cumul + ; + + CREATE TEMP TABLE w_cumul AS + SELECT + bool_or(p_cumul and p_heures_contrat) as total_heures_contrat, + bool_or(p_cumul and p_heures_payees) as total_heures_payees, + bool_or(p_cumul and p_heures_travaillees) as total_heures_travaillees, + bool_or(p_cumul and p_masse_salariale) as total_masse_salariale, + bool_or(p_cumul and p_brut) as total_brut, + bool_or(p_cumul and p_avantage_nature) as total_avantage_nature, + bool_or(p_cumul and p_frais_imposables) as total_frais_imposables, + bool_or(p_cumul and p_cotisation_salarie) as total_cotisation_salarie, + bool_or(p_cumul and p_cotisation_patronale) as total_cotisation_patronale, + bool_or(p_cumul and p_od_net_salarie) as total_od_net_salarie, + bool_or(p_cumul and p_od_net_patronale) as total_od_net_patronale, + bool_or(p_cumul and p_net_imposable) as total_net_imposable, + bool_or(p_cumul and p_net_a_payer) as total_net_a_payer + FROM rh.t_rubriques + ; + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calculer l'écart + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + SELECT + w_hp.bul_id, + w_hp.etablissement_id, + w_hp.salarie_id, + w_hp.mois_paie, + sum(case when p_heures_contrat then heure_contrat else 0 end) as heure_contrat, + sum(case when p_heures_payees then heure_payee else 0 end) as heure_payee, + sum(case when p_heures_travaillees then heure_travaillee else 0 end) as heure_travaillee, + sum(case when p_masse_salariale then montant_masse_salariale else 0 end) as montant_masse_salariale, + sum(case when p_brut then montant_brut else 0 end) AS montant_brut, + sum(case when p_avantage_nature then montant_avantage_nature else 0 end) as montant_avantage_nature, + sum(case when p_frais_imposables then montant_frais_imposables else 0 end) as montant_frais_imposables, + sum(case when p_cotisation_salarie then montant_cotisation_salarie else 0 end) AS montant_cotisation_salarie, + sum(case when p_cotisation_patronale then montant_cotisation_patronale else 0 end) AS montant_cotisation_patronale, + sum(case when p_od_net_salarie then montant_od_net_salarie else 0 end) as montant_od_net_salarie, + sum(case when p_od_net_patronale then montant_od_net_patronale else 0 end) as montant_od_net_patronale, + sum(case when p_net_imposable then montant_net_imposable_salarie else 0 end) as montant_net_imposable_salarie, + sum(case when p_net_a_payer then montant_net_a_payer_salarie else 0 end) as montant_net_a_payer_salarie + FROM w_hp + JOIN rh.t_rubriques ON t_rubriques.oid = w_hp.rubrique_id + where w_hp.p_cumul + GROUP BY 1,2,3,4 + ; + + -- Insérer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie ( + code_original, + etablissement_id, + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + montant_cotisation_salarie, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie) + WITH subq as ( + SELECT + p_historique_paie.code_original as bul_id, + p_historique_paie.etablissement_id, + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + 0 AS base, + 0 AS nombre, + 0 AS organisme_cotisation_id, + 0 AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') as rubrique_id, + 0 AS compte_id, + salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + sum(heure_contrat) AS heure_contrat, + sum(heure_payee) AS heure_payee, + sum(heure_travaillee) AS heure_travaillee, + sum(montant_masse_salariale) AS montant_masse_salariale, + sum(montant_brut) AS montant_brut, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_frais_imposables) AS montant_frais_imposables, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_od_net_salarie) AS montant_od_net_salarie, + sum(montant_od_net_patronale) AS montant_od_net_patronale, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie + FROM rh.p_historique_paie + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 + ) + SELECT + subq.bul_id, + subq.etablissement_id, + subq.age_id, + subq.contrat_id, + subq.contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + subq.base, + subq.nombre, + case when total_heures_contrat then w_totaux.heure_contrat - subq.heure_contrat else 0 end as heure_contrat, + case when total_heures_payees then w_totaux.heure_payee - subq.heure_payee else 0 end as heure_payee, + case when total_heures_travaillees then w_totaux.heure_travaillee - subq.heure_travaillee else 0 end as heure_travaillee, + case when total_masse_salariale then w_totaux.montant_masse_salariale - subq.montant_masse_salariale else 0 end as montant_masse_salariale, + case when total_brut then w_totaux.montant_brut - subq.montant_brut else 0 end as montant_brut, + case when total_avantage_nature then w_totaux.montant_avantage_nature - subq.montant_avantage_nature else 0 end as montant_avantage_nature, + case when total_frais_imposables then w_totaux.montant_frais_imposables - subq.montant_frais_imposables else 0 end as montant_frais_imposables, + case when total_cotisation_salarie then w_totaux.montant_cotisation_salarie - subq.montant_cotisation_salarie else 0 end as montant_cotisation_salarie, + case when total_cotisation_patronale then w_totaux.montant_cotisation_patronale - subq.montant_cotisation_patronale else 0 end as montant_cotisation_patronale, + case when total_od_net_salarie then w_totaux.montant_od_net_salarie - subq.montant_od_net_salarie else 0 end as montant_od_net_salarie, + case when total_od_net_patronale then w_totaux.montant_od_net_patronale - subq.montant_od_net_patronale else 0 end as montant_od_net_patronale, + case when total_net_imposable then w_totaux.montant_net_imposable_salarie - subq.montant_net_imposable_salarie else 0 end as montant_net_imposable_salarie, + case when total_net_a_payer then w_totaux.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie else 0 end as montant_net_a_payer_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id, + subq.rubrique_id, + subq.compte_id, + subq.salarie_id, + subq.taux_cotisation_patronale, + subq.taux_cotisation_salarie + FROM subq + JOIN w_totaux ON w_totaux.bul_id = subq.bul_id + JOIN w_cumul ON true + WHERE 1!=1 + OR (total_heures_contrat AND w_totaux.heure_contrat - subq.heure_contrat != 0) + OR (total_heures_payees AND w_totaux.heure_payee - subq.heure_payee != 0) + OR (total_heures_travaillees AND w_totaux.heure_travaillee - subq.heure_travaillee != 0) + OR (total_masse_salariale AND w_totaux.montant_masse_salariale - subq.montant_masse_salariale != 0) + OR (total_brut AND w_totaux.montant_brut - subq.montant_brut != 0) + OR (total_avantage_nature AND w_totaux.montant_avantage_nature - subq.montant_avantage_nature != 0) + OR (total_frais_imposables AND w_totaux.montant_frais_imposables - subq.montant_frais_imposables != 0) + OR (total_cotisation_salarie AND w_totaux.montant_cotisation_salarie - subq.montant_cotisation_salarie != 0) + OR (total_cotisation_patronale AND w_totaux.montant_cotisation_patronale - subq.montant_cotisation_patronale != 0) + OR (total_od_net_salarie AND w_totaux.montant_od_net_salarie - subq.montant_od_net_salarie != 0) + OR (total_od_net_patronale AND w_totaux.montant_od_net_patronale - subq.montant_od_net_patronale != 0) + OR (total_net_imposable AND w_totaux.montant_net_imposable_salarie - subq.montant_net_imposable_salarie != 0) + OR (total_net_a_payer AND w_totaux.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie != 0) + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + ]]> + + + + + + = p_contrats_mois.date_debut + GROUP BY 1,2,3,5,p_arrets_travail.date_debut,p_arrets_travail.date_fin,p_arrets_travail.date_reprise + ORDER BY p_contrats_mois.mois_activite desc + ; + + update rh.p_arrets_travail_mois + set nb_reprise_apres_arret = subq.nb_reprise_apres_arret + from ( + select + t1.arret_travail_id, + t1.mois_activite, + min(case when p_arrets_travail.date_reprise between t2.date_debut and t2.date_fin then 0 else 1 end) as nb_reprise_apres_arret + from rh.p_arrets_travail_mois as t1 + join rh.p_arrets_travail ON p_arrets_travail.oid = t1.arret_travail_id + left join rh.p_arrets_travail_mois as t2 ON 1=1 + AND t1.salarie_id = t2.salarie_id + AND t1.date_debut != t2.date_debut + AND t1.date_fin != t2.date_fin + GROUP BY t1.arret_travail_id, t1.mois_activite + order by 2 desc + ) as subq + where 1=1 + and p_arrets_travail_mois.arret_travail_id = subq.arret_travail_id + and p_arrets_travail_mois.mois_activite = subq.mois_activite + ; + + ]]> + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_QUADRARH.XML b/import_rh/iCTI_import_rh_QUADRARH.XML new file mode 100644 index 0000000..64b8988 --- /dev/null +++ b/import_rh/iCTI_import_rh_QUADRARH.XML @@ -0,0 +1,1514 @@ + + + + + trim(code_original) + ; + + UPDATE prod_quadrarh.employes + SET NUMERO = trim(NUMERO) + WHERE NUMERO <> trim(NUMERO) + ; + + UPDATE prod_quadrarh.bulletins + SET NUMEROEMPLOYE = trim(NUMEROEMPLOYE) + WHERE NUMEROEMPLOYE <> trim(NUMEROEMPLOYE) + ; + + UPDATE prod_quadrarh.entreesortieemp + SET NUMEROEMPLOYE = trim(NUMEROEMPLOYE) + WHERE NUMEROEMPLOYE <> trim(NUMEROEMPLOYE) + ; + + UPDATE prod_quadrarh.infoscomplbul + SET NUMERO = trim(NUMERO) + WHERE NUMERO <> trim(NUMERO) + ; + + UPDATE prod_quadrarh.lignesbulletin + SET NUMEROEMPLOYE = trim(NUMEROEMPLOYE) + WHERE NUMEROEMPLOYE <> trim(NUMEROEMPLOYE) + ; + + UPDATE prod_quadrarh.infoscomplbul + SET CDDCDI = CASE WHEN CDDCDI ILIKE 'True' THEN '1' WHEN CDDCDI ILIKE 'False' THEN '0' ELSE CDDCDI END + WHERE CDDCDI ILIKE 'True' OR CDDCDI ILIKE 'False' + ; + + ]]> + + + + + + + + 0 then 'NET' else 'BRUT' end) else typeabsence end as code_original, + max(libelle) as intitule + from prod_quadrarh.lignesbulletin + group by 1,2) + , all_rubs as ( + select + code, + code_original, + max(intitule) as intitule + from all_rubs_0 + group by 1,2) + SELECT code_original, code, intitule, substr(intitule, 1, 50), -1 + FROM all_rubs + WHERE code_original NOT IN (SELECT code_original FROM rh.t_rubriques WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4,5 + ; + + -- -- Màj des situations de famille + -- INSERT INTO rh.t_situations_famille(code_original, code, texte, texte_court) + -- SELECT situationfamille, situationfamille, substr(situationfamille,1,50), situationfamille + -- FROM prod_sage.t_hst_famille + -- WHERE situationfamille NOT IN (SELECT code_original FROM rh.t_situations_famille WHERE code_original IS NOT NULL) + -- GROUP BY 1,2,3,4 + -- ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code_original, code, texte, texte_court) + SELECT cddcdi, cddcdi, cddcdi, substr(cddcdi, 1, 50) + FROM w_hst + WHERE cddcdi NOT IN (SELECT code_original FROM rh.t_types_contrat WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des statuts + INSERT INTO rh.t_statuts(code_original, code, texte, texte_court) + select statut_code, statut_code, MAX(statut_libelle), MAX(substr(statut_libelle, 1, 50)) + from w_hst + WHERE statut_code NOT IN (SELECT code_original FROM rh.t_statuts WHERE code_original IS NOT NULL) + GROUP BY 1,2 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + select ttt, ttt, ttt_libelle, ttt_libelle_court + from w_hst + where ttt NOT IN (SELECT code_original FROM rh.t_types_temps_travail WHERE code_original IS NOT NULL) + group by 1,2,3,4 + ; + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + SELECT code, code, intitule, substr(intitule, 1, 50) + FROM prod_quadrarh.services + WHERE code NOT IN (SELECT code_original FROM rh.t_services WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des codes emploi. prod_quadrarh.profils ? + INSERT INTO rh.t_codes_emploi(code_original, code, texte, texte_court) + SELECT emploi_code, emploi_code, emploi_libelle, substr(emploi_libelle, 1, 50) + FROM w_hst + WHERE emploi_code NOT IN (SELECT code_original FROM rh.t_codes_emploi WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + select classification, classification, classification, substr(classification, 1, 50) + from w_hst + WHERE classification NOT IN (SELECT code_original FROM rh.t_grilles_groupes WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + ]]> + + + + + + + + = to_char(rhp('rhprovider_start')::date, 'YYYYMM')::int + GROUP BY 1,2,3 + ; + + ]]> + + + + + + + + + + + + + + base.cti_first_day((w_profils.mois::text||'01')::date) then 0 else (case when w_profils.est_hors_periode = 1 then 0 else 1 end) end as present_debut_mois, + case when w_profils.cnt_date_fin < base.cti_last_day((w_profils.mois::text||'01')::date) then 0 else (case when w_profils.est_hors_periode = 1 then 0 else 1 end) end as present_fin_mois, + 1 as equivalent_temps_plein, -- ! Mettre le bon ETP. + base.cti_age(least(w_profils.date_fin, w_profils.cnt_date_fin)::date, coalesce(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + least(w_profils.date_fin, w_profils.cnt_date_fin)::date - coalesce(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + p_contrats.anciennete_anterieure_jours + + (w_profils.date_fin - w_profils.cnt_date_debut) + + 1 + AS anciennete_jours, + base.cti_age(date_trunc('month', w_profils.date_fin::date)::date, date_trunc('month', w_profils.cnt_date_debut)::date, 'nm') + + p_contrats.anciennete_anterieure_calculee_mois + 1 AS anciennete_mois, + floor((base.cti_age(date_trunc('month', w_profils.date_fin::date)::date, date_trunc('month', w_profils.cnt_date_debut)::date, 'nm') + + p_contrats.anciennete_anterieure_calculee_mois + 1) / 12) AS anciennete_annee_id, + p_contrats.etablissement_id + FROM w_profils + JOIN rh.p_contrats on p_contrats.code_original = w_profils.ncnt + JOIN rh.p_salaries on p_salaries.oid = p_contrats.salarie_id + ; + + -- On renseigne les id de contrats de w_profils. + UPDATE w_profils + SET contrat_id = p_contrats_mois.contrat_id, + contrat_mois_id = p_contrats_mois.oid + FROM rh.p_contrats_mois + WHERE w_profils.row_id = p_contrats_mois.code_original + ; + + ]]> + + + 0 then 'NET' else 'BRUT' end) else typeabsence end as code, + -- libelle, + case when code = '.NAP' then montantglobal::numeric else montant2::numeric end as base, + montant1::numeric as nombre, + montantsalarial::numeric as tx_sal, + coalesce(nullif(round(montant2::numeric * montant1::numeric, 2), 0), round(montant2::numeric * montantsalarial::numeric / 100.0 , 2)) as mt_sal, + (montantglobal::numeric - montantsalarial::numeric) as tx_pat, + round(montant2::numeric * (montantglobal::numeric - montantsalarial::numeric) / 100.0 , 2) as mt_pat + from prod_quadrarh.lignesbulletin + where to_char(periode::date, 'YYYY')::int > 2015 + ; + + -- Régul pour Almaviva + UPDATE w_hp_0 + SET base = 0 + WHERE code = '.BAS_0' AND nombre < 1.1 AND current_database() IN ('icti_548','icti_549','icti_550','icti_551','icti_552','icti_553','icti_554') + ; + + DROP TABLE IF EXISTS w_hp + ; + + CREATE TEMP TABLE w_hp AS + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numeroemploye, + w_hp_0.sequence, + w_profils.date_debut, + least(w_profils.date_fin, base.cti_last_day(w_profils.date_debut)) as date_fin, + w_profils.date_paie, + w_profils.mois, + w_hp_0.code, + t_rubriques.oid AS rubrique_id, + t_rubriques.p_detail, + t_rubriques.p_cumul, + t_rubriques.c_base + * case when @t_rubriques.c_base != 1 then coalesce(case when proratiser_conversion then w_profils.ratio_theo else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_base THEN (CASE s_base + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) else 0 end AS base, + t_rubriques.c_nombre + * case when @t_rubriques.c_nombre != 1 then coalesce(case when proratiser_conversion then w_profils.ratio_theo else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_nombre THEN (CASE s_nombre + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) else 0 end AS nombre, + t_rubriques.c_heures_contrat + * case when @t_rubriques.c_heures_contrat != 1 then coalesce(case when proratiser_conversion then w_profils.ratio_theo else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_heures_contrat + then (CASE s_heures_contrat + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + else 0 end + AS heure_contrat, + t_rubriques.c_heures_payees + * case when @t_rubriques.c_heures_payees != 1 then coalesce(case when proratiser_conversion then w_profils.ratio_theo else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_heures_payees + then (CASE s_heures_payees + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees + * case when @t_rubriques.c_heures_travaillees != 1 then coalesce(case when proratiser_conversion then w_profils.ratio_theo else 1.0 end, 1.0) else 1.0 end + * CASE WHEN p_heures_travaillees + then (CASE s_heures_travaillees + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale + * (CASE WHEN p_masse_salariale THEN + (CASE s_masse_salariale + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + else 0 end) AS masse_salariale, + t_rubriques.c_brut + * (CASE WHEN p_brut THEN + (CASE s_brut + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + else 0 end) AS montant_brut, + t_rubriques.c_frais_imposables + * (case when p_frais_imposables then + (CASE s_frais_imposables + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + else 0 end) AS montant_frais_imposables, + t_rubriques.coefficient_txs * (case when p_cotisation_salarie then w_hp_0.tx_sal else 0 end) AS taux_sal, + t_rubriques.c_cotisation_salarie + * (case when p_cotisation_salarie then + (CASE s_cotisation_salarie + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + else 0 end) AS montant_cot_sal, + t_rubriques.coefficient_txp * (case when p_cotisation_patronale then w_hp_0.tx_pat else 0 end) AS taux_pat, + t_rubriques.c_cotisation_patronale + * (case when p_cotisation_patronale then + (CASE s_cotisation_patronale + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + else 0 end) AS montant_cot_pat, + t_rubriques.c_od_net_salarie + * (CASE WHEN p_od_net_salarie THEN + (CASE s_od_net_salarie + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + ELSE 0 END) AS od_net, + t_rubriques.c_od_net_patronale + * (CASE WHEN p_od_net_patronale THEN + (CASE s_od_net_patronale + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + ELSE 0 END) AS od_net_p, + t_rubriques.c_avantage_nature + * (CASE WHEN p_avantage_nature THEN + (CASE s_avantage_nature + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + ELSE 0 END) AS avt_nat, + t_rubriques.c_net_imposable + * (CASE WHEN p_net_imposable THEN + (CASE s_net_imposable + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + ELSE 0 END) AS net_imposable, + t_rubriques.c_net_a_payer + * (CASE WHEN p_net_a_payer THEN + (CASE s_net_a_payer + WHEN 0 THEN w_hp_0.nombre + WHEN 1 THEN w_hp_0.base + WHEN 2 THEN w_hp_0.tx_sal + WHEN 3 THEN w_hp_0.mt_sal + WHEN 4 THEN w_hp_0.tx_pat + WHEN 5 THEN w_hp_0.mt_pat + WHEN 6 THEN w_hp_0.mt_sal + w_hp_0.mt_pat + WHEN 7 THEN w_hp_0.mt_sal - w_hp_0.mt_pat + WHEN 8 THEN w_hp_0.mt_pat - w_hp_0.mt_sal + END) + ELSE 0 END) AS net_a_payer + FROM w_hp_0 + JOIN w_profils ON 1=1 + AND w_profils.numeroemploye = w_hp_0.numeroemploye + AND w_profils.mois = w_hp_0.mois_paie + AND w_profils.sequence = w_hp_0.sequence + JOIN rh.t_rubriques ON t_rubriques.code_original = w_hp_0.code + where 1=1 + -- AND t_hbns.datehist >= rhp('rhprovider_start')::date + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié même s'il n'y a rien. + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer) + ; + + -- Génération paie + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie( + code_original, + age_id, + base, + nombre, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + heure_contrat, + heure_payee, + heure_travaillee, + montant_avantage_nature, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie) + SELECT + w_hp.matricule||w_hp.sequence||w_hp.date_paie::date as code_original, + date_part('year', age(w_hp.date_fin, date_naissance)) AS age_id, + w_hp.base, + w_hp.nombre, + w_hp.contrat_id, + w_hp.contrat_mois_id, + w_hp.date_paie, + w_hp.date_paie, + w_hp.date_paie AS date_paie, + w_hp.mois AS mois_activite, + w_hp.mois AS mois_paie, + w_hp.heure_contrat, + w_hp.heure_payee, + w_hp.heure_travaillee, + w_hp.avt_nat AS montant_avantage_nature, + w_hp.montant_brut AS montant_brut, + w_hp.masse_salariale as montant_masse_salariale, + w_hp.montant_cot_pat AS montant_cotisation_patronale, + w_hp.montant_cot_sal AS montant_cotisation_salarie, + w_hp.montant_frais_imposables, + w_hp.net_a_payer AS montant_net_a_payer_salarie, + w_hp.net_imposable AS montant_net_imposable_salarie, + w_hp.od_net AS montant_od_net_salarie, + 0 AS organisme_cotisation_id, + w_hp.profil_id, + w_hp.rubrique_id, + 0 AS compte_id, + w_hp.salarie_id, + w_hp.taux_pat AS taux_cotisation_patronale, + w_hp.taux_sal AS taux_cotisation_salarie + FROM w_hp + JOIN rh.p_salaries ON p_salaries.oid = w_hp.salarie_id + WHERE p_detail + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + -- Création d'une table récapitulative des écarts à calculer par indicateur de paie (1 seule ligne). + DROP TABLE IF EXISTS w_cumul + ; + + CREATE TEMP TABLE w_cumul AS + SELECT + bool_or(p_cumul and p_avantage_nature) as total_avantage_nature, + bool_or(p_cumul and p_brut) as total_brut, + bool_or(p_cumul and p_masse_salariale) as total_masse_salariale, + bool_or(p_cumul and p_cotisation_patronale) as total_cot_pat, + bool_or(p_cumul and p_cotisation_salarie) as total_cot_sal, + bool_or(p_cumul and p_net_a_payer) as total_payer, + bool_or(p_cumul and p_net_imposable) as total_imposable, + bool_or(p_cumul and p_heures_contrat) as total_h_contrat, + bool_or(p_cumul and p_heures_payees) as total_h_payees, + bool_or(p_cumul and p_heures_travaillees) as total_h_travaillees + FROM rh.t_rubriques + ; + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calculer l'écart + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + SELECT + w_hp.matricule||w_hp.sequence||w_hp.date_paie::date as code_original, + w_hp.matricule, + w_hp.date_paie as date, + w_hp.mois, + round(sum(case when p_cumul then avt_nat else 0 end), 2) AS hcum_avantage_nature, + round(sum(case when p_cumul then montant_brut else 0 end), 2) AS hcum_brut, + round(sum(case when p_cumul then masse_salariale else 0 end), 2) AS hcum_masse_salariale, + round(sum(case when p_cumul then montant_cot_pat else 0 end), 2) AS hcum_cotisation_patronale, + round(sum(case when p_cumul then montant_cot_sal else 0 end), 2) AS hcum_cotisation_salarie, + 0::numeric AS hcum_frais_imposables, + round(sum(case when p_cumul then net_a_payer else 0 end), 2) AS hcum_net_a_payer_salarie, + round(sum(case when p_cumul then net_imposable else 0 end), 2) AS hcum_net_imposable_salarie, + sum(case when p_cumul then heure_contrat else 0 end) AS hcum_heures_contrat, + sum(case when p_cumul then heure_payee else 0 end) AS hcum_heures_payees, + sum(case when p_cumul then heure_travaillee else 0 end) AS hcum_heures_travaillees, + 0::numeric AS montant_od_net_salarie + FROM w_hp + WHERE p_cumul + GROUP BY 1,2,3,4 + ; + + -- A la demande de Mme CONSTANTIN, ajout des heures d'astreinte travaillees (B092 et BF92) au total des heures payées Quadra car mal paramétré dans Quadra. + WITH correction as( + SELECT + w_hp.matricule||w_hp.sequence||w_hp.date_paie::date as code_original, + sum(base) AS heures_astreinte + FROM w_hp + WHERE code in ('B092_0', 'BF92_0') + GROUP BY 1 + HAVING sum(base) != 0) + UPDATE w_totaux SET + hcum_heures_payees = hcum_heures_payees + heures_astreinte + FROM correction + WHERE w_totaux.code_original = correction.code_original + ; + + -- Insérer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie ( + code_original, + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_avantage_nature, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie) + SELECT + subq.code_original, + subq.age_id, + subq.contrat_id, + subq.contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + 0 AS nombre, + case when total_h_contrat then COALESCE(hcum_heures_contrat, 0) - subq.heure_contrat else 0.0 end AS heure_contrat, + case when total_h_payees then COALESCE(hcum_heures_payees,0) - subq.heure_payee else 0.0 end AS heure_payee, + case when total_h_travaillees then COALESCE(hcum_heures_travaillees,0) - subq.heure_travaillee else 0.0 end AS heure_travaillee, + case when total_avantage_nature then COALESCE(hcum_avantage_nature,0) - subq.montant_avantage_nature else 0.0 end AS montant_avantage_nature, + case when total_brut then COALESCE(hcum_brut,0) - subq.montant_brut else 0.0 end AS montant_brut, + case when total_masse_salariale then COALESCE(hcum_masse_salariale, 0) - subq.montant_masse_salariale else 0.0 end AS montant_masse_salariale, + case when total_cot_pat then COALESCE(hcum_cotisation_patronale,0) - subq.montant_cotisation_patronale else 0.0 end AS montant_cotisation_patronale, + case when total_cot_sal then COALESCE(hcum_cotisation_salarie,0) - subq.montant_cotisation_salarie else 0.0 end AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + case when total_payer then COALESCE(hcum_net_a_payer_salarie,0) - subq.montant_net_a_payer_salarie else 0.0 end AS montant_net_a_payer_salarie, + case when total_imposable then COALESCE(hcum_net_imposable_salarie,0) - subq.montant_net_imposable_salarie else 0.0 end AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + 0 AS compte_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM ( + SELECT + p_historique_paie.code_original, + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + 0 AS base, + 0 AS nombre, + sum(heure_contrat) AS heure_contrat, + sum(heure_payee) AS heure_payee, + sum(heure_travaillee) AS heure_travaillee, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_masse_salariale) AS montant_masse_salariale, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + p_historique_paie.organisme_cotisation_id, + p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8,9,10,11, 24,25,26,27) AS subq + JOIN w_totaux ON w_totaux.code_original = subq.code_original + JOIN w_cumul ON true + WHERE 1!=1 + OR case when total_avantage_nature then COALESCE(hcum_avantage_nature,0) - subq.montant_avantage_nature != 0 else false end + OR case when total_brut then COALESCE(hcum_brut,0) - subq.montant_brut != 0 else false end + OR case when total_masse_salariale then COALESCE(hcum_masse_salariale,0) - subq.montant_masse_salariale != 0 else false end + OR case when total_payer then COALESCE(hcum_net_a_payer_salarie,0) - subq.montant_net_a_payer_salarie != 0 else false end + OR case when total_imposable then COALESCE(hcum_net_imposable_salarie,0) - subq.montant_net_imposable_salarie != 0 else false end + OR case when total_cot_pat then COALESCE(hcum_cotisation_patronale,0) - subq.montant_cotisation_patronale != 0 else false end + OR case when total_cot_sal then COALESCE(hcum_cotisation_salarie,0) - subq.montant_cotisation_salarie != 0 else false end + OR case when total_h_contrat then COALESCE(hcum_heures_contrat, 0) - subq.heure_contrat != 0 else false end + OR case when total_h_payees then COALESCE(hcum_heures_payees,0) - subq.heure_payee != 0 else false end + OR case when total_h_travaillees then COALESCE(hcum_heures_travaillees,0) - subq.heure_travaillee != 0 else false end + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_RHPLACE.XML b/import_rh/iCTI_import_rh_RHPLACE.XML new file mode 100644 index 0000000..95be6c1 --- /dev/null +++ b/import_rh/iCTI_import_rh_RHPLACE.XML @@ -0,0 +1,1766 @@ + + + + + 41637 -- 2013-12-31 + ; + + -- Table des lignes de paies forfait jour (création d'une rubrique 4540 qui n'existe pas dans ces bulletins). + DROP TABLE IF EXISTS w_ligne_fj + ; + + CREATE TEMP TABLE w_ligne_fj AS + select + ent_id, + bul_id, + '4540'::text as code, + bul_horf::numeric as nombre, + bul_heure_payees::numeric as base + from w_bulletin + where forfait_jour + ; + + -- Alimentation de la base de la rubrique forfait 1350 avec la valeur de 1363, 1365 ou 3162. + UPDATE w_ligne SET + lig_bas1 = w_ligne_fj.base + FROM w_ligne_fj + WHERE 1=1 + AND w_ligne.bul_id = w_ligne_fj.bul_id + AND w_ligne.pla_id = 1350 + ; + + -- Conversion en heures de la base de la rubrique d'absence E/S 2250 lorsqu'il s'agit de forfaits jours car exprimée en jours. + UPDATE w_ligne SET + lig_bas1 = (lig_bas1 / 20.67) * 151.67 + FROM w_ligne_fj + WHERE 1=1 + AND w_ligne.bul_id = w_ligne_fj.bul_id + AND w_ligne.pla_id = 2250 + ; + + CREATE INDEX w_bulletin_1 ON w_bulletin USING btree (ent_id) + ; + CREATE INDEX w_bulletin_2 ON w_bulletin USING btree (bul_id) + ; + + DROP TABLE IF EXISTS w_h_coeff + ; + + CREATE TEMP TABLE w_h_coeff AS + SELECT + to_timestamp((coe_du - 25567) * 86400)::date AS date_debut, + CASE WHEN lead(coe_du) over w is null THEN '2099-12-31'::date ELSE to_timestamp((coalesce(lead(coe_du) over w - 1, 99999) - 25567) * 86400)::date END as date_fin, + h_coeff.* + FROM prod_rhplace.h_coeff + JOIN w_ets ON w_ets.ent_id = h_coeff.ent_id + window w as (partition by sal_matr order by coe_du) + ; + + DROP TABLE IF EXISTS w_h_es + ; + + CREATE TEMP TABLE w_h_es AS + SELECT + to_timestamp((e_s_date - 25567) * 86400)::date AS date_debut, + CASE WHEN e_s_dates = 0 THEN '2099-12-31'::date ELSE to_timestamp((e_s_dates - 25567) * 86400)::date END AS date_fin, + h_es.* + FROM prod_rhplace.h_es + JOIN w_ets ON w_ets.ent_id = h_es.ent_id + ; + + -- Statuts + DROP TABLE IF EXISTS w_h_stprof + ; + + CREATE TEMP TABLE w_h_stprof AS + SELECT + to_timestamp((stp_date - 25567) * 86400)::date AS date_debut, + CASE WHEN lead(stp_date) over w is null THEN '2099-12-31'::date ELSE to_timestamp((coalesce(lead(stp_date) over w - 1, 99999) - 25567) * 86400)::date END as date_fin, + h_stprof.* + FROM prod_rhplace.h_stprof + JOIN w_ets ON w_ets.ent_id = h_stprof.ent_id + window w as (partition by sal_matr order by stp_date) + ; + + DROP TABLE IF EXISTS w_rub + ; + + CREATE TEMP TABLE w_rub AS + with rub_per as ( + select + pla_id, + pla_type, + pla_int, + pla_dval, + coalesce(nullif(pla_tot, ''), 'N') as pla_tot, -- par défaut on met 'N'. + coalesce(lead(pla_dval) over (partition by pla_id order by pla_dval) - 1, 99999) as pla_fval + from prod_rhplace.plap) + ,rub_filter as ( + select * + from rub_per + where false + OR 41638 between pla_dval and pla_fval -- 41638 = 2014-01-01 + OR pla_dval >= 41638) + ,clustering as ( + select + pla_id, + pla_type, + pla_int, + pla_dval, + pla_fval, + pla_tot, + case when pla_tot != coalesce(lag(pla_tot) over w, 'C') then true else null end as new_cluster + from rub_filter + window w as (partition by pla_id order by pla_dval)) + ,assigned_clustering as ( + select + * + , count(new_cluster) over ( + partition by pla_id + order by pla_dval + rows unbounded preceding + ) as cluster_id + from clustering) + ,tmp_rubs as ( + select + pla_id, + pla_type, + pla_int, + pla_tot, + min(pla_dval) as pla_dval, + max(pla_fval) as pla_fval + from assigned_clustering + group by 1,2,3,4,cluster_id) + select + pla_id, + pla_type, + pla_int, + pla_tot, + case when count(*) over (partition by pla_id) > 1 + then + case when row_number() over (partition by pla_id order by pla_dval desc) = 1 + then pla_id + else pla_id||'_'||to_char(to_timestamp((pla_dval - 25567) * 86400)::date, 'DD/MM/YYYY') + end + else pla_id end as pla_code, + pla_id||'_'||to_char(to_timestamp((pla_dval - 25567) * 86400)::date, 'YYYYMMDD') as pla_code_original, + pla_dval, + pla_fval + from tmp_rubs + ; + + ]]> + + + + 0 + AND cpt_cle NOT IN (SELECT code_original FROM rh.t_compte WHERE code_original IS NOT NULL) + GROUP BY 1,2,3,4 + ; + + -- [NON] Màj des sociétés d'interim + + -- Màj des grilles + INSERT INTO rh.t_grilles(code_original, code, texte, texte_court) + SELECT cat_id, cat_id, cat_lib, substr(cat_lib, 1, 50) + FROM prod_rhplace.ar_categ + JOIN w_ets ON w_ets.ent_id = ar_categ.ent_id + WHERE cat_id NOT IN (SELECT code_original FROM rh.t_grilles) + GROUP BY 1,2,3,4 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT coe_val, coe_val, coe_val, coe_val + FROM w_h_coeff + WHERE coe_val NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + GROUP BY 1 + ; + + -- [NON] Màj des motifs d'arret + + -- [NON] Màj des précisions du motif d'arrêt + + -- [NON] Màj des motifs de visite médicale + + -- [NON] Màj des circonstances d'accident du travail + + -- [NON] Màj des lieux d'accident du travail + + -- [NON] Màj de la nature de l'accident du travail + + -- [NON] Màj des sièges d'accident du travail + + -- [NON] Màj des listes de formations + + -- [NON] Màj des sections analytiques compta + + -- [NON] Màj des sections analytiques paie + + ]]> + + + + + + + + + + + + + + + 0 THEN sal_val_nom ELSE sal_naiss END AS nom, + sal_prenom AS prenom, + v_sal_dnaiss AS date_naissance, + CASE WHEN substr(sal_noss, 1, 1) = 1 THEN 'M' ELSE 'F' END AS sexe, + salarie.sal_matr AS matricule, + salarie.sal_matr AS code, + salarie.sal_matr AS code_original, + max(coalesce(t_entreprises.oid, 0)) AS entreprise_id, + max(coalesce(t_nationalites.oid, 0)) AS nationalite_id, + max(coalesce(t_codes_postaux.oid, 0)) AS code_postal_id, + sal_naiss AS nom_naissance, + max(coalesce(t_situations_famille.oid, 0)) AS situation_famille_id, + ((max(ARRAY[w_profils.date_fin::text, w_profils.profil_id::text]))[2])::bigint AS profil_id, -- dernier profil salarié. + max(h_cnt_trav.date_debut) AS date_debut, -- date de début du dernier contrat. + max(h_cnt_trav.date_fin) AS date_fin, -- date de fin du dernier contrat. + salarie.v_sal_dat_cemp AS date_entree_ets, + max(h_cnt_trav.date_fin) AS date_sortie_ets, + -- Champs dédiés au public. + '1900-01-01'::date AS date_entree_fp, + '1900-01-01'::date AS date_entree_fph, + 0 AS no_adeli, + 0 AS code_cotisation_id, + 0 AS matricule_retraite, + salarie.sal_noss||salarie.sal_cless AS nir + FROM w_salarie AS salarie + JOIN w_ets ON w_ets.eta_id = salarie.eta_id + JOIN w_cnt AS h_cnt_trav ON 1=1 + AND h_cnt_trav.ent_id = salarie.ent_id + AND h_cnt_trav.sal_matr = salarie.sal_matr + JOIN w_profils on w_profils.numero_contrat = h_cnt_trav.numero_contrat + LEFT JOIN rh.t_codes_postaux ON t_codes_postaux.code = salarie.sal_cp + LEFT JOIN rh.t_situations_famille ON t_situations_famille.code_original = salarie.fam_id + LEFT JOIN rh.t_entreprises ON t_entreprises.code_original = salarie.ent_id + LEFT JOIN rh.t_nationalites ON t_nationalites.code_original = salarie.sal_cod_pays + GROUP BY 1,2,3,4,5,6,7,8, 12, 17,19,20,21,22,23,24 + ; + + ]]> + + + + date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_entree_ets = date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND to_char(date_entree_ets, 'YYYY')::numeric >= 2009 + AND date_entree_ets < date_debut_contrat + ; + + UPDATE rh.p_salaries + SET date_sortie_ets = date_fin_contrat + FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND date_fin_contrat > date_sortie_ets + ; + + -- Calcul ancienneté au début de contrat + UPDATE rh.p_contrats + SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_calculee_mois + FROM ( + SELECT + t1.numero_contrat, + sum(t2.duree) AS anciennete_anterieure_jours, + sum(t2.duree) / 30 AS anciennete_anterieure_calculee_mois + FROM w_cnt AS t1 + JOIN w_cnt AS t2 ON 1=1 + AND t2.sal_matr = t1.sal_matr + AND t2.date_debut < t1.date_debut + group by 1 + ) AS subq + WHERE 1=1 + AND p_contrats.numero_contrat = subq.numero_contrat + ; + + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + INSERT INTO rh.p_contrats_mois( + code_original, + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, + present_debut_mois, + present_fin_mois, + equivalent_temps_plein, + nombre_heures, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id) + SELECT + w_profils.code_original, + p_salaries.oid AS salarie_id, + p_contrats.oid AS contrat_id, + p_calendrier_mois.mois AS mois, + GREATEST(p_calendrier_mois.date_debut, w_profils.date_debut) AS date_debut, + LEAST(p_calendrier_mois.date_fin, w_profils.date_fin) AS date_fin, + CASE WHEN p_salaries.date_entree_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_entrees, + CASE WHEN p_salaries.date_sortie_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_departs, + CASE WHEN p_contrats.date_debut BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_contrat, + CASE WHEN p_contrats.date_fin BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_contrat, + w_profils.est_hors_periode, + CASE WHEN p_calendrier_mois.date_debut BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_debut_mois, + CASE WHEN p_calendrier_mois.date_fin BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + etp_contrat, + heures_contrat, + base.cti_age(LEAST(p_calendrier_mois.date_fin, w_profils.date_fin), COALESCE(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + LEAST(p_calendrier_mois.date_fin, w_profils.date_fin)::date - COALESCE(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + p_contrats.anciennete_anterieure_jours + + (LEAST(p_calendrier_mois.date_fin, w_profils.date_fin) - p_contrats.date_debut) + + 1 + AS anciennete_jours, + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + AS anciennete_mois, + floor( + ( + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + p_contrats.anciennete_anterieure_calculee_mois + ) / 12 + ) AS anciennete_annee_id + FROM w_profils + JOIN base.p_calendrier_mois ON base.cti_overlaps(w_profils.date_debut, w_profils.date_fin, p_calendrier_mois.date_debut, p_calendrier_mois.date_fin) + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_profils.numero_contrat + JOIN rh.p_salaries ON p_salaries.matricule = w_profils.matricule + WHERE 1=1 + AND p_calendrier_mois.mois < to_char(now() + '1 month'::interval, 'YYYYMM') + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + ; + + ]]> + + + heures). + -- En revanche, les autres salariés voient leur base multiplié par le coeff paramétré dans nombre (représente toujours des jours). + -- Cela permet d'appliquer le signe négatif sur la base de toute la population de salariés. + case when p_base then lig_bas1 else 0 end * case when forfait_jour then c_base * bulletin.etp else c_nombre end AS base, + case when p_nombre then lig_bas2 else 0 end * c_nombre AS nombre, + case + when p_heures_contrat and s_heures_contrat = 0 then lig_bas2 + when p_heures_contrat and s_heures_contrat = 1 then lig_bas1 + else 0 + end * c_heures_contrat as heure_contrat, + case + when p_heures_payees and s_heures_payees = 0 then lig_bas2 + when p_heures_payees and s_heures_payees = 1 then lig_bas1 + else 0 + end * c_heures_payees as heure_payee, + case + when p_heures_travaillees and s_heures_travaillees = 0 then lig_bas2 + when p_heures_travaillees and s_heures_travaillees = 1 then lig_bas1 + else 0 + end * c_heures_travaillees as heure_travaillee, + case + when p_masse_salariale and s_masse_salariale = 3 then lig_mont1 + when p_masse_salariale and s_masse_salariale = 5 then lig_mont2 + else 0 + end * c_masse_salariale as montant_masse_salariale, + CASE WHEN p_brut THEN lig_mont1 ELSE 0 END * c_brut AS montant_brut, + CASE WHEN p_avantage_nature THEN lig_mont1 ELSE 0 END * c_avantage_nature AS montant_avantage_nature, + case when p_frais_imposables then lig_mont1 else 0 end * c_frais_imposables as montant_frais_imposables, + case when p_cotisation_salarie then lig_mont1 else 0 end * c_cotisation_salarie as montant_cotisation_salarie, + case when p_cotisation_patronale then lig_mont2 else 0 end * c_cotisation_patronale as montant_cotisation_patronale, + case when p_od_net_salarie then lig_mont1 else 0 end * c_od_net_salarie as montant_od_net_salarie, + case when p_od_net_patronale then lig_taux2 else 0 end * c_od_net_patronale as montant_od_net_patronale, + lig_taux1 AS tx_sal, + lig_taux2 AS tx_pat, + CASE WHEN p_net_imposable THEN lig_mont1 ELSE 0 END * c_net_imposable AS montant_net_imposable_salarie, + CASE WHEN p_net_a_payer THEN lig_mont1 ELSE 0 END * c_net_a_payer AS montant_net_a_payer_salarie + FROM w_bulletin AS bulletin + JOIN w_ets ON w_ets.eta_id = bulletin.eta_id + join ligne ON 1=1 + AND ligne.bul_id = bulletin.bul_id + AND ligne.ent_id = bulletin.ent_id + join w_rub ON 1=1 + AND w_rub.pla_id = ligne.pla_id + AND bulletin.bul_fin between w_rub.pla_dval and w_rub.pla_fval + join rh.t_rubriques on t_rubriques.code_original = w_rub.pla_code_original + WHERE 1!=1 + OR p_detail + OR p_cumul + ; + + -- #correction + UPDATE w_hp + SET date_paie = (mois_paie||'01')::date + '1 month - 1 day'::interval + WHERE to_char(date_paie, 'YYYYMM')::numeric != mois_paie + ; + + CREATE INDEX i_w_hp_1 + ON w_hp + USING btree (matricule) + ; + + CREATE INDEX i_w_hp_2 + ON w_hp + USING btree (mois_activite) + ; + + CREATE INDEX i_w_hp_3 + ON w_hp + USING btree (mois_paie) + ; + + CREATE INDEX i_w_hp_4 + ON w_hp + USING btree (rubrique) + ; + + -- Insertion dans la table de production CTI. + TRUNCATE rh.p_historique_paie + ; + + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + INSERT INTO rh.p_historique_paie( + age_id, + nombre, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + heure_contrat, + heure_payee, + heure_travaillee, + montant_avantage_nature, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + montant_od_net_patronale, + organisme_cotisation_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id) + SELECT + date_part('year', age(w_hp.date_debut, date_naissance)) AS age_id, + w_hp.nombre, + w_hp.base AS base, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.contrat_id]))[2] AS contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.oid]))[2] AS contrat_mois_id, + w_hp.date_debut, + w_hp.date_fin, + w_hp.date_paie, + w_hp.mois_activite, + w_hp.mois_paie, + w_hp.heure_contrat, + w_hp.heure_payee, + w_hp.heure_travaillee, + w_hp.montant_avantage_nature, + w_hp.montant_brut, + w_hp.montant_masse_salariale, + w_hp.montant_cotisation_patronale, + w_hp.montant_cotisation_salarie, + w_hp.montant_frais_imposables, + w_hp.montant_net_a_payer_salarie, + w_hp.montant_net_imposable_salarie, + w_hp.montant_od_net_salarie, + w_hp.montant_od_net_patronale, + 0 AS organisme_cotisation_id, + t_rubriques.oid AS rubrique_id, + p_salaries.oid AS salarie_id, + w_hp.tx_pat AS taux_cotisation_patronale, + w_hp.tx_sal AS taux_cotisation_salarie, + 0 AS compte_id + FROM w_hp + JOIN rh.t_rubriques ON t_rubriques.code_original = w_hp.rubrique + JOIN rh.p_salaries ON p_salaries.matricule = w_hp.matricule + -- LEFT JOIN rh.t_organismes_cotisation ON t_organismes_cotisation.code_original = w_hp.organisme + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + --AND p_contrats_mois.mois_activite = w_hp.mois + AND base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, w_hp.date_debut, w_hp.date_fin) + -- LEFT JOIN rh.t_compte ON t_compte.code_original = w_hp.compte + WHERE w_hp.p_detail + GROUP BY 1,2,3, 6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29, w_hp.ctid + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calculer l'écart + DROP TABLE IF EXISTS w_totaux + ; + + + -- FIXME ATTENTION AUX DOUBLONS !!! + -- FIXME Bulletins sur 201600 ... + CREATE TEMP TABLE w_totaux AS + with ligne as ( + select + bul_id, + ligne.ent_id, + pla_id, + lig_bas1, + lig_bas2, + lig_mont1, + lig_mont2 + from w_ligne as ligne + JOIN w_ets ON w_ets.ent_id = ligne.ent_id + union all + select + bul_id, + ent_id, + code as pla_id, + base as lig_bas1, + nombre as lig_bas2, + 0 as lig_mont1, + 0 as lig_mont2 + from w_ligne_fj) + select + -- Dates d'activité + date_debut, + date_fin, + to_char(date_fin, 'YYYYMM')::numeric AS mois_activite, + -- Dates de paie + date_paie, + substr(bulletin.bul_id, 1, 6)::numeric AS mois_paie, + bulletin.eta_id, + bulletin.sal_matr AS matricule, + substr(bulletin.bul_id, 1, 4)::numeric AS mois, + sum(case when pla_id = 'BRUT' then lig_mont1 else 0 end)::numeric AS brut, + sum(case when pla_id = 'IMPO' then lig_mont1 else 0 end)::numeric AS net_imposable, + sum(case when pla_id = 'NETT' then lig_mont1 else 0 end)::numeric AS net_a_payer, + sum(case when pla_id = 'TOTR' then lig_mont1 else 0 end)::numeric AS mt_sal, + sum(case when pla_id = 'TOTR' then lig_mont2 * (-1) else 0 end)::numeric AS mt_pat + from w_bulletin AS bulletin + JOIN w_ets ON w_ets.eta_id = bulletin.eta_id + join ligne ON 1=1 + AND ligne.bul_id = bulletin.bul_id + AND ligne.ent_id = bulletin.ent_id + where pla_id IN ('BRUT', 'TOTR', 'IMPO', 'NETT') + group by 1,2,3,4,5,6,7,8 + ; + + -- #correction + UPDATE w_totaux + SET date_paie = (mois_paie||'01')::date + '1 month - 1 day'::interval + WHERE to_char(date_paie, 'YYYYMM')::numeric != mois_paie + ; + + -- Inserer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + nombre, + base, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + montant_cotisation_salarie, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + organisme_cotisation_id, + profil_id, -- @deprecated + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie) + SELECT + age_id, + contrat_id, + contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 as nombre, + 0 AS base, + 0 AS heure_payee, + 0 as heure_travaillee, + 0 as montant_masse_salariale, + sum(brut - subq.montant_brut) AS montant_brut, + 0 AS montant_avantage_nature, + 0 AS montant_frais_imposables, + sum(mt_sal - subq.montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(mt_pat - subq.montant_cotisation_patronale) AS montant_cotisation_patronale, + 0 as montant_od_net_salarie, + 0 as montant_od_net_patronale, + sum(net_imposable - subq.montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(net_a_payer - subq.montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM + (SELECT + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + 0 as nombre, + 0 AS base, + sum(heure_payee) as heure_payee, + sum(heure_travaillee) as heure_travaillee, + sum(montant_masse_salariale) as montant_masse_salariale, + sum(montant_brut) AS montant_brut, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_frais_imposables) AS montant_frais_imposables, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_od_net_salarie) as montant_od_net_salarie, + sum(montant_od_net_patronale) as montant_od_net_patronale, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + 0 AS organisme_cotisation_id, + 0 AS profil_id, -- p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8,9,10, 23,24,25,26,27,28) AS subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON 1=1 + AND w_totaux.matricule = p_salaries.matricule + AND w_totaux.date_debut = subq.date_debut + AND w_totaux.date_fin = subq.date_fin + GROUP BY 1,2,3,4,5,6,7,8, 23,24,25,26,27,28 + HAVING 1!=1 + OR sum(brut - subq.montant_brut) != 0 + OR sum(mt_pat - subq.montant_cotisation_patronale) != 0 + OR sum(mt_sal - subq.montant_cotisation_salarie) != 0 + OR sum(net_a_payer - subq.montant_net_a_payer_salarie) != 0 + OR sum(net_imposable - subq.montant_net_imposable_salarie) != 0 + ; + + /* + + Quels sont les écarts cumulés > 0 ? : + + SELECT + p_salaries.matricule, + p_historique_paie.* + FROM rh.p_historique_paie + JOIN rh.p_salaries on p_salaries.oid = p_historique_paie.salarie_id + JOIN rh.t_rubriques on t_rubriques.oid = p_historique_paie.rubrique_id + WHERE 1=1 + AND t_rubriques.code_original = 'C000' + AND + (1!=1 + OR p_historique_paie.base <> 0 + OR p_historique_paie.montant_brut <> 0 + OR p_historique_paie.montant_cotisation_salarie <> 0 + OR p_historique_paie.montant_cotisation_patronale <> 0 + OR p_historique_paie.montant_net_a_payer_salarie <> 0 + OR p_historique_paie.montant_net_imposable_salarie <> 0 + OR p_historique_paie.montant_avantage_nature <> 0 + ) + ORDER BY 1,4 DESC + ; + + */ + + ]]> + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SAGE.XML b/import_rh/iCTI_import_rh_SAGE.XML new file mode 100644 index 0000000..df7b33c --- /dev/null +++ b/import_rh/iCTI_import_rh_SAGE.XML @@ -0,0 +1,4344 @@ + + + + + + + + + + + + + + + + + + = 79900 + THEN false + ELSE t_hbns.coderubrique is not null + END as brut, + CASE WHEN 1=1 + AND t_rub.coderubrique > 19990 + AND t_rub.dasavnat != 1 + and t_hbns.coderubrique is not null + THEN true + ELSE false + END as odns, + false as odnp, + false as cosd, + false as copa + from prod_sage.t_rub + left join prod_sage.t_hbns on t_hbns.coderubrique = t_rub.coderubrique + where 1=1 + and t_rub.imprimable NOT IN (1, 3) + AND t_hbns.valeurmontant != 0 + group by 1,2,3 + UNION + select + t_rub.coderubrique, + CASE WHEN 1!=1 + OR t_rub.dasavnat = 1 + OR t_rub.coderubrique >= 79900 + THEN false + ELSE T_BNSSAL.coderubrique is not null + END as brut, + CASE WHEN 1=1 + AND t_rub.coderubrique > 19990 + AND t_rub.dasavnat != 1 + and T_BNSSAL.coderubrique is not null + THEN true + ELSE false + END as odns, + false as odnp, + false as cosd, + false as copa + from prod_sage.t_rub + left join prod_sage.t_bnssal on t_bnssal.coderubrique = t_rub.coderubrique + where 1=1 + and t_rub.imprimable NOT IN (1, 3) + AND t_bnssal.valeurmontantsalarial != 0 + group by 1,2,3 + UNION + select + t_rub.coderubrique, + false as brut, + false as odns, + false as odnp, + true as cosd, + true as copa + FROM prod_sage.t_hcot + JOIN prod_sage.t_rub ON t_rub.coderubrique = t_hcot.coderubrique + WHERE 1=1 + AND t_rub.imprimable != 1 + and (false + or t_hcot.valeursmontantsalarial != 0 + OR t_hcot.valeursmontantpatronal != 0) + group by 1,2,3 + UNION + select + t_rub.coderubrique, + false as brut, + false as odns, + false as odnp, + true as cosd, + true as copa + FROM prod_sage.T_COTSAL + JOIN prod_sage.t_rub ON t_rub.coderubrique = T_COTSAL.coderubrique + WHERE 1=1 + AND t_rub.imprimable != 1 + and (false + or t_cotsal.valeurmontantsal != 0 + or t_cotsal.valeurmontantpatronal != 0) + group by 1,2,3 + ) as subq + group by 1) as subqq + where 1=1 + AND t_rubriques.code_original = subqq.coderubrique + AND NOT t_rubriques.user_modified + ; + + ]]> + + + + + + + + + = to_char(rhp('rhprovider_start')::date, 'YYYY')::int + AND date_part('year', t_hcum.datehist) <= date_part('year', now() + interval '5 years') + GROUP BY 1,2,3,4 + HAVING sum(round((CASE WHEN entite IN (3, 4, 6, 7, 8, 84, 86) THEN valeurcumul ELSE 0 END)::numeric,2))::numeric != 0) as subq + group by 1,2,3 + ; + + ]]> + + + + = to_char(rhp('rhprovider_start')::date, 'YYYY')::int + AND date_part('year', t_hcum.datehist) <= date_part('year', now() + interval '5 years') + GROUP BY 1,2,3,4 + HAVING sum(round((CASE WHEN entite IN (3, 4, 6, 7, 8, 84, 86) THEN valeurcumul ELSE 0 END)::numeric,2))::numeric != 0) as subq + group by 1,2,3 + ; + + ]]> + + + + + + aux dates de fin. + DROP TABLE IF EXISTS w_hst_contrat_0 + ; + + CREATE TEMP TABLE w_hst_contrat_0 AS + SELECT * + FROM prod_sage.t_hst_contrat + ; + + UPDATE w_hst_contrat_0 SET + datedebutcontrat = datefincontrat, + datefincontrat = datedebutcontrat + WHERE datedebutcontrat > datefincontrat + ; + + -- Préparation contrats (pb chevauchement) + DROP TABLE IF EXISTS w_hst_contrat + ; + + CREATE TEMP TABLE w_hst_contrat AS + WITH hst_cnt as ( + SELECT + -- nettoie l'historique (infoencours = 0) de manière séquentielle. + case when lead(datedebutcontrat) over w = datedebutcontrat then true else false end as to_ex1, -- date de début suivante identique à celle de la ligne actuelle + -- nettoie l'historique (infoencours = 0) par rapport à la ligne infoencours. + case when last_value(datedebutcontrat) over w <= datedebutcontrat and infoencours = 0 then true else false end as to_ex2, -- date infoencours <= date ligne actuelle + * + FROM w_hst_contrat_0 + where 1=1 + and datedebutcontrat is not null -- la date de début doit être renseignée. + and case when infoencours = 0 and datefincontrat is null then false else true end -- l'historique doit avoir des des dates de fin. + window w as (partition by numsalarie order by infoencours, datedebutcontrat, datehist rows between UNBOUNDED PRECEDING and UNBOUNDED following)), + hst_soc as ( + SELECT + -- nettoie l'historique (infoencours = 0) de manière séquentielle. + case when lead(datedepart) over w = datedepart then true else false end as to_ex1, -- date de début suivante identique à celle de la ligne actuelle + -- nettoie l'historique (infoencours = 0) par rapport à la ligne infoencours. + case when last_value(datedepart) over w <= datedepart and infoencours = 0 then true else false end as to_ex2, -- date infoencours <= date ligne actuelle + * + FROM prod_sage.t_hst_infossociete + where 1=1 + and datedepart is not null -- la date de début doit être renseignée. + and case when infoencours = 0 and datedepart is null then false else true end -- l'historique doit avoir des des dates d'embauche. + window w as (partition by numsalarie order by infoencours, datedepart, datehist rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + -- selection avec correction des dates de fin chevauchantes. + select + rank() OVER (ORDER BY hst_cnt.numsalarie, hst_cnt.infoencours, datedebutcontrat, hst_cnt.datehist) as sequence, + hst_cnt.numsalarie::text||'-'::text||rank() OVER (PARTITION BY hst_cnt.numsalarie ORDER BY hst_cnt.infoencours, datedebutcontrat, hst_cnt.datehist) as cti_cnt, + datedebutcontrat::date as date_debut, + (case when lead(datedebutcontrat) over w <= datefincontrat then lead(datedebutcontrat) over w - '1 day'::interval else coalesce(datefincontrat, '2099-12-31'::date) end)::date as date_fin, + coalesce(hst_soc.codemotifdepart, chr(1) || '*') as soc_codemotifdepart, + hst_cnt.* + from hst_cnt + left join hst_soc on 1=1 + and hst_soc.numsalarie = hst_cnt.numsalarie + and hst_soc.datedepart = hst_cnt.datefincontrat + AND NOT hst_soc.to_ex1 + AND NOT hst_soc.to_ex2 + where 1=1 + AND NOT hst_cnt.to_ex1 + AND NOT hst_cnt.to_ex2 + window w as (PARTITION BY hst_cnt.numsalarie ORDER BY hst_cnt.infoencours, datedebutcontrat, hst_cnt.datehist) + ; + + CREATE INDEX i_hst_contrat_numsalarie ON w_hst_contrat USING btree(numsalarie); + CREATE INDEX i_hst_contrat_dates ON w_hst_contrat USING btree(date_debut, date_fin); + + -- Salaries + DROP TABLE IF EXISTS w_sal_ets + ; + + CREATE TEMP TABLE w_sal_ets AS + with hst_pre as ( + select + numsalarie, + coalesce(dateentree, datedebut) as dateentree, + datehist, + codeetab, + datesortie, + infoencours + FROM prod_sage.t_hst_etablissement) + , hst_corr as ( + select + numsalarie, + coalesce(case when infoencours = 1 and dateentree is null then greatest(lag(datehist) over w, lag(dateentree) over w) + '1 day'::interval else dateentree end, '1900-01-01'::date) as dateentree, + datehist, + codeetab, + datesortie, + infoencours + FROM hst_pre + where not (infoencours = 0 and dateentree is null) -- On exclu les historiques (infoencours = 0) avec une dateentree nulle. + window w as (partition by numsalarie order by infoencours, dateentree, datehist rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + , hst_ets as ( + select + lead(dateentree) over w, + case when lead(dateentree) over w = dateentree then true else false end as to_ex1, + case when last_value(dateentree) over w <= dateentree and infoencours = 0 then true else false end as to_ex2 + ,* + FROM hst_corr + where dateentree is not null + window w as (partition by numsalarie order by infoencours, dateentree, datehist rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + select + rank() OVER (ORDER BY numsalarie, infoencours, dateentree, datehist) as sequence, + numsalarie::text||'-'::text||rank() OVER w as cti_ets, + case when rank() OVER w = 1 + then '1900-01-01'::date + else dateentree::date + end as date_debut, + case when rank() OVER wd = 1 + then '2099-12-31'::date + else (case when lead(dateentree) over w <= coalesce(datesortie, '2099-12-31'::date) then lead(dateentree) over w - '1 day'::interval else coalesce(datesortie, '2099-12-31'::date) end)::date + end as date_fin, + min(dateentree::date) over wu as date_entree_ets, + max(coalesce(datesortie::date, '2099-12-31'::date)) over wu as date_sortie_ets, + * + from hst_ets + where 1=1 + AND NOT to_ex1 + AND NOT to_ex2 + window w as (PARTITION BY numsalarie ORDER BY infoencours, dateentree, datehist), + wd as (PARTITION BY numsalarie ORDER BY infoencours desc, dateentree desc, datehist desc), + wu as (PARTITION BY numsalarie) + ; + + CREATE INDEX i_sal_ets_numsalarie ON w_sal_ets USING btree(numsalarie); + CREATE INDEX i_sal_ets_dates ON w_sal_ets USING btree(date_debut, date_fin); + + -- Historique des affectations. On ne se base plus que sur la date de début. + DROP TABLE IF EXISTS w_hst_aff + ; + + CREATE TEMP TABLE w_hst_aff AS + with hst_corr as ( + select + coalesce(case when infoencours = 1 and datedebut is null then greatest(lag(datehist) over w, lag(datedebut) over w) + '1 day'::interval else datedebut end, '1900-01-01'::date) as datedebut, + numsalarie, + datehist, + infoencours, + departement, + service, + unite, + categorie, + emploioccupe, + qualification, + niveau, + coefficient, + indice + FROM prod_sage.t_hst_affectation + where true + and not (infoencours = 0 and datedebut is null) -- Mais on exclu les historiques (infoencours = 0) avec une datedebut nulle. + window w as (partition by numsalarie order by infoencours, datedebut, datehist rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + , hst_aff as ( + select + lead(datedebut) over w, + case when lead(datedebut) over w = datedebut then true else false end as to_ex1, + case when last_value(datedebut) over w <= datedebut and infoencours = 0 then true else false end as to_ex2 + ,* + FROM hst_corr + window w as (partition by numsalarie order by infoencours, datedebut, datehist rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + select + rank() OVER (ORDER BY numsalarie, infoencours, datedebut, datehist) as sequence, + numsalarie::text||'-'::text||rank() OVER w as cti_aff, + case when rank() OVER w = 1 + then '1900-01-01'::date + else datedebut::date + end as date_debut, + case when rank() OVER wd = 1 + then '2099-12-31'::date + else lead(datedebut) over w - '1 day'::interval + end as date_fin, + * + from hst_aff + where 1=1 + AND NOT to_ex1 + AND NOT to_ex2 + window w as (PARTITION BY numsalarie ORDER BY infoencours, datedebut, datehist), + wd as (PARTITION BY numsalarie ORDER BY infoencours desc, datedebut desc, datehist desc), + wu as (PARTITION BY numsalarie) + ; + + CREATE INDEX i_hst_aff_numsalarie ON w_hst_aff USING btree(numsalarie); + CREATE INDEX i_hst_aff_dates ON w_hst_aff USING btree(date_debut, date_fin); + + -- Historique des postes. + DROP TABLE IF EXISTS w_hst_pst + ; + + CREATE TEMP TABLE w_hst_pst AS + with hst_corr as ( + select + coalesce(case when infoencours = 1 and datedebut is null then greatest(lag(datehist) over w, lag(datedebut) over w) + '1 day'::interval else datedebut end, '1900-01-01'::date) as datedebut, + numsalarie, + datehist, + infoencours, + codeposte + FROM prod_sage.t_hst_poste + where true + and not (infoencours = 0 and datedebut is null) -- Mais on exclu les historiques (infoencours = 0) avec une datedebut nulle. + and trim(codeposte) is distinct from '' + window w as (partition by numsalarie order by infoencours, datehist, datedebut rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + , hst_pst as ( + select + lead(datedebut) over w, + case when lead(datedebut) over w = datedebut then true else false end as to_ex1, + case when last_value(datedebut) over w <= datedebut and infoencours = 0 then true else false end as to_ex2 + ,* + FROM hst_corr + window w as (partition by numsalarie order by infoencours, datehist, datedebut rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + select + rank() OVER (ORDER BY numsalarie, infoencours, datedebut, datehist) as sequence, + numsalarie::text||'-'::text||rank() OVER w as cti_pst, + case when rank() OVER w = 1 + then '1900-01-01'::date + else datedebut::date + end as date_debut, + case when rank() OVER wd = 1 + then '2099-12-31'::date + else lead(datedebut) over w - '1 day'::interval + end as date_fin, + * + from hst_pst + where 1=1 + AND NOT to_ex1 + AND NOT to_ex2 + window w as (PARTITION BY numsalarie ORDER BY infoencours, datedebut, datehist), + wd as (PARTITION BY numsalarie ORDER BY infoencours desc, datedebut desc, datehist desc), + wu as (PARTITION BY numsalarie) + ; + + CREATE INDEX i_hst_pst_numsalarie ON w_hst_pst USING btree(numsalarie); + CREATE INDEX i_hst_pst_dates ON w_hst_pst USING btree(date_debut, date_fin); + + + -- Historique des affections au travers des bulletins. + DROP TABLE IF EXISTS w_hst_affbul + ; + + CREATE TEMP TABLE w_hst_affbul AS + with temp_affbul as ( + select + numsalarie, + datehist::date, + case when typedubulletin != 0 then base.cti_first_day(datehist::date) else datehist::date end as datehist_cti, -- Permet de revenir vers un cas standard de bulletin exceptionnel émi le 1er du mois. + debutpaiement::date, + finpaiement::date, + departement, + service, + unite, + categorie, + codeetab, + typedubulletin + from prod_sage.t_haff + where datehist != '2069-09-16'::date) -- TOUS les datehist à 2069-09-16 n'ont aucune données renseignées. + select + numsalarie, + numsalarie::text||'-'::text||rank() OVER w AS cti_affbul, + datehist, + typedubulletin, + coalesce(lag(datehist_cti + 1) over w, base.cti_first_day(datehist_cti)) as date_debut, + datehist_cti as date_fin, + debutpaiement::date, + finpaiement::date, + departement, + service, + unite, + categorie, + codeetab + from temp_affbul + window w as (partition by numsalarie order by datehist_cti, typedubulletin) + ; + + CREATE INDEX i_hst_affbul_numsalarie ON w_hst_affbul USING btree(numsalarie); + CREATE INDEX i_hst_affbul_dates ON w_hst_affbul USING btree(date_debut, date_fin); + + -- Historique des bulletins (basé sur l'historique des cumuls t_hcum + w_periode pour le mois en cours). + DROP TABLE IF EXISTS w_hst_bul + ; + + CREATE TEMP TABLE w_hst_bul AS + with w_hcum as ( + select + numsalarie, + datehist::date, + case when typedubulletin != 0 then base.cti_first_day(datehist::date) else datehist::date end as datehist_cti, -- Permet de revenir vers un cas standard de bulletin exceptionnel émi le 1er du mois. + typedubulletin, + max(case when codeconstante = 'ETP' then VALEURCUMUL else null end) as cumul_68, + max(case when codeconstante = 'HORAIRE' then VALEURCUMUL else null end) as cumul_81 + from prod_sage.t_hcum + join prod_sage.t_cst on 1=1 + AND typeconstante = 6 + AND t_cst.CodeOperande1 = t_hcum.entite + where datehist != '2069-09-16'::date -- TOUS les datehist à 2069-09-16 n'ont aucune données renseignées. + group by 1,2,3,4 + union + select + numsalarie, + date_paie_encours as datehist, + date_paie_encours as datehist_cti, + 0 as typedubulletin, + null as cumul_68, + null as cumul_81 + from prod_sage.t_bnssal + join w_periode on true + where t_bnssal.valeurmontantsalarial != 0 -- repris depuis l'historique de la paie. + group by 1,2,3,4 + union + select + numsalarie, + date_paie_encours as datehist, + date_paie_encours as datehist_cti, + 0 as typedubulletin, + null as cumul_68, + null as cumul_81 + FROM prod_sage.t_cotsal + join w_periode on true + WHERE false + OR t_cotsal.valeurmontantsal != 0 + or t_cotsal.valeurmontantpatronal != 0 + group by 1,2,3,4) + , w_hcum2 as ( + select + numsalarie, + numsalarie::text||'-'::text||rank() OVER w AS cti_bul, + coalesce(cumul_68, -- si la valeur est renseignée sur la ligne courante, on la prend. + (max(case when cumul_68 is null then null else ARRAY[extract(epoch from datehist_cti)::numeric, cumul_68] end) over wb)[2], -- sinon on prend la valeur renseignée la plus proche dans le passé + (min(case when cumul_68 is null then null else ARRAY[extract(epoch from datehist_cti)::numeric, cumul_68] end) over wf)[2], -- sinon on prend la valeur renseignée la plus proche dans le futur + null -- sinon on prend null + ) as cumul_68, + coalesce(cumul_81, -- si la valeur est renseignée sur la ligne courante, on la prend. + (max(case when cumul_81 is null then null else ARRAY[extract(epoch from datehist_cti)::numeric, cumul_81] end) over wb)[2], -- sinon on prend la valeur renseignée la plus proche dans le passé + (min(case when cumul_81 is null then null else ARRAY[extract(epoch from datehist_cti)::numeric, cumul_81] end) over wf)[2], -- sinon on prend la valeur renseignée la plus proche dans le futur + null -- sinon on prend null + ) as cumul_81, + datehist, + datehist_cti, + typedubulletin, + coalesce(lag(datehist_cti + 1) over w, base.cti_first_day(datehist_cti)) as date_debut, + datehist_cti as date_fin + from w_hcum + window w as (partition by numsalarie order by datehist_cti, typedubulletin), + wb as (PARTITION BY numsalarie ORDER BY datehist_cti, typedubulletin rows unbounded preceding), -- sélectionne les lignes précédentes + wf as (PARTITION BY numsalarie ORDER BY datehist_cti, typedubulletin rows between current row and unbounded following)) -- sélectionne les lignes suivantes + select + numsalarie, + cti_bul, + cumul_68, + cumul_81, + coalesce( + CASE + WHEN sage_temps_travail.valeur = 'ETP' THEN cumul_68 -- Pour calculer un ETP contrat théorique, on prend la valeur ETP si non nulle... + WHEN sage_temps_travail.valeur = 'HORAIRE' THEN case when round(cumul_81::numeric, 2) = 151.67 then 1.0 else round(cumul_81::numeric, 2) / 151.67 end + END, + CASE + WHEN sage_temps_travail.valeur = 'HORAIRE' THEN case when round(cumul_81::numeric, 2) = 151.67 then 1.0 else round(cumul_81::numeric, 2) / 151.67 end + WHEN sage_temps_travail.valeur = 'ETP' THEN cumul_68 -- ... sinon on prend le nombre d'heures contrat... + END, + 1.0) as etp_contrat, -- ... sinon on met 1 par défaut. + datehist, + datehist_cti, + typedubulletin, + date_debut, + date_fin + from w_hcum2 + join (SELECT valeur FROM rh.t_divers WHERE code = 'SAGE_TEMPS_TRAVAIL') as sage_temps_travail on true + ; + + CREATE INDEX i_hst_bul_numsalarie ON w_hst_bul USING btree(numsalarie); + CREATE INDEX i_hst_bul_dates ON w_hst_bul USING btree(date_debut, date_fin); + + -- Historique codes insee + DROP TABLE IF EXISTS w_hst_insee + ; + + CREATE TEMP TABLE w_hst_insee AS + with hst_insee as ( + select + lead(datedebut) over w, + case when lead(datedebut) over w = datedebut then true else false end as to_ex1, + case when last_value(datedebut) over w <= datedebut and infoencours = 0 then true else false end as to_ex2 + ,* + FROM prod_sage.t_hst_dadsu + WHERE case when infoencours = 0 and datedebut is null then false else true end -- on exclu de facto les datedebut null pour les infos pas en cours. + window w as (partition by numsalarie order by infoencours, datedebut, datehist rows between UNBOUNDED PRECEDING and UNBOUNDED following)) + select + rank() OVER (ORDER BY numsalarie, infoencours, datedebut, datehist) as sequence, + numsalarie::text||'-'::text||rank() OVER w as cti_insee, + numsalarie, + coalesce(lag(datedebut::date + 1) over w, '0001-01-01'::date) as date_debut, + coalesce(datedebut::date, '2099-12-31'::date) as date_fin, + coalesce(nullif(codeinsee, ''), -- si la valeur est renseignée sur la ligne courante, on la prend. + (max(ARRAY[case when codeinsee = '' then null else coalesce(datedebut::date, '2099-12-31'::date)::text end, nullif(codeinsee, '')::text]) over wb)[2], -- sinon on prend la valeur renseignée la plus proche dans le passé + (min(ARRAY[case when codeinsee = '' then null else coalesce(datedebut::date, '2099-12-31'::date)::text end, nullif(codeinsee, '')::text]) over wf)[2], -- sinon on prend la valeur renseignée la plus proche dans le futur + null -- sinon on prend null + ) as codeinsee + from hst_insee + where 1=1 + AND NOT to_ex1 + AND NOT to_ex2 + window w as (PARTITION BY numsalarie ORDER BY infoencours, datedebut, datehist), + wb as (PARTITION BY numsalarie ORDER BY infoencours, datedebut, datehist rows unbounded preceding), -- sélectionne les lignes précédentes + wf as (PARTITION BY numsalarie ORDER BY infoencours, datedebut, datehist rows between current row and unbounded following) -- sélectionne les lignes suivantes + ; + + CREATE INDEX i_hst_insee_numsalarie ON w_hst_insee USING btree(numsalarie); + CREATE INDEX i_hst_insee_dates ON w_hst_insee USING btree(date_debut, date_fin); + + -- Identification des dates limites pour chaque salariés (pour des raisons de performances). + -- Basé sur les contrats et les bulletins (historique des cumuls t_hcum). + DROP TABLE IF EXISTS w_lim_sal + ; + + CREATE TEMP TABLE w_lim_sal AS + select + numsalarie, + matriculesalarie as matricule, + min(date_debut) as date_debut, + max(date_fin) as date_fin + from ( + select + numsalarie, + min(date_debut) as date_debut, + coalesce(nullif(max(date_fin), '2099-12-31'::date), max(date_paie_encours)) as date_fin -- 2099-12-31 correspond à "contrat en cours" => on met le mois de paie en cours (et surtout pas current_date). + from w_hst_contrat, w_periode + group by 1 + UNION ALL + select + numsalarie, + min(date_debut) as date_debut, + max(date_fin) as date_fin + from w_hst_bul + group by 1 + ) as subq + join prod_sage.t_sal on t_sal.sa_compteurnumero = subq.numsalarie + group by 1,2 + ; + + CREATE INDEX i_lim_sal_numsalarie ON w_lim_sal USING btree(numsalarie); + CREATE INDEX i_lim_sal_dates ON w_lim_sal USING btree(date_debut, date_fin); + + DROP TABLE IF EXISTS w_evt_mois + ; + + CREATE TEMP TABLE w_evt_mois AS + with raw_data as( + select + w_lim_sal.numsalarie, + w_lim_sal.matricule, + cti_cnt, -- contrat + cti_ets, -- ets. + cti_aff, -- affectations + cti_pst, -- postes + cti_affbul, -- affectations bulletins + cti_bul, -- bulletins + cti_insee, -- insee + p_calendrier.date + from base.p_calendrier + join w_lim_sal on p_calendrier.date between w_lim_sal.date_debut and w_lim_sal.date_fin + left join w_hst_contrat on 1=1 + and w_hst_contrat.numsalarie = w_lim_sal.numsalarie + and p_calendrier.date between w_hst_contrat.date_debut and w_hst_contrat.date_fin + left join w_sal_ets on 1=1 + and w_sal_ets.numsalarie = w_lim_sal.numsalarie + and p_calendrier.date between w_sal_ets.date_debut and w_sal_ets.date_fin + left join w_hst_insee on 1=1 + and w_hst_insee.numsalarie = w_lim_sal.numsalarie + and p_calendrier.date between w_hst_insee.date_debut and w_hst_insee.date_fin + left join w_hst_aff on 1=1 + and w_hst_aff.numsalarie = w_lim_sal.numsalarie + and p_calendrier.date between w_hst_aff.date_debut and w_hst_aff.date_fin + left join w_hst_pst on 1=1 + and w_hst_pst.numsalarie = w_lim_sal.numsalarie + and p_calendrier.date between w_hst_pst.date_debut and w_hst_pst.date_fin + left join w_hst_affbul on 1=1 + and w_hst_affbul.numsalarie = w_lim_sal.numsalarie + and p_calendrier.date between w_hst_affbul.date_debut and w_hst_affbul.date_fin + left join w_hst_bul on 1=1 + and w_hst_bul.numsalarie = w_lim_sal.numsalarie + and p_calendrier.date between w_hst_bul.date_debut and w_hst_bul.date_fin + where 1!=1 + or cti_cnt is not null -- on ne conserve que les évenements ou il y a un contrat OU + or cti_bul is not null -- un bulletin + ), + clustering as ( + select + numsalarie, + matricule, + cti_cnt, + cti_ets, + cti_aff, + cti_pst, + cti_affbul, + cti_bul, + cti_insee, + date, + case when lag(coalesce(cti_cnt, '')||coalesce(cti_ets, '')||coalesce(cti_aff, '')||coalesce(cti_pst, '')||coalesce(cti_affbul, '')||coalesce(cti_bul, '')||coalesce(cti_insee, '')) over w + = coalesce(cti_cnt, '')||coalesce(cti_ets, '')||coalesce(cti_aff, '')||coalesce(cti_pst, '')||coalesce(cti_affbul, '')||coalesce(cti_bul, '')||coalesce(cti_insee, '') then null else true end as new_cluster + from raw_data + window w as (partition by numsalarie order by date)), + assigned_clustering as ( + select + numsalarie, + matricule, + cti_cnt, + cti_ets, + cti_aff, + cti_pst, + cti_affbul, + cti_bul, + cti_insee, + date, + to_char(date, 'YYYYMM')::int as mois, + count(new_cluster) over (order by numsalarie, date rows unbounded preceding) as cluster_id + from clustering) + select + numsalarie, + matricule, + cti_cnt, + cti_ets, + cti_aff, + cti_pst, + cti_affbul, + cti_bul, + cti_insee, + mois, -- FIXME PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR PAS SUR + min(date) AS date_debut, + max(date) AS date_fin + from assigned_clustering + group by 1,2,3,4,5,6,7,8,9,10, cluster_id + ; + + ]]> + + + + + + + + + + + + + + + + + + = 79900 + THEN 0 + ELSE t_hbns.valeurmontant END)::numeric AS montant_brut, + (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * + (CASE WHEN 1!=1 + OR t_rubriques.code_calcul NOT IN ('3') + OR t_rub.coderubrique >= 79900 + THEN 0 + ELSE t_hbns.valeurmontant END)::numeric AS montant_frais_imposables, + t_hbns.valeurtaux::numeric AS taux_sal, + 0::numeric AS montant_sal, + 0::numeric AS taux_pat, + 0::numeric AS montant_pat, + ((CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * CASE WHEN t_rub.coderubrique > 19990 AND t_rub.dasavnat != 1 THEN t_hbns.valeurmontant ELSE 0 END)::numeric AS od_net, + 0 as od_net_p, + (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * + (CASE WHEN 1!=1 + OR t_rub.dasavnat = 1 AND montantdequivalence = 0 + OR t_rubriques.code_calcul = '4' + THEN t_hbns.valeurmontant + ELSE 0 END)::numeric AS avt_nat, + 0 AS net_imposable, + 0 AS net_a_payer, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee, + t_rub.nodordre AS ordre, + 0 AS type_rub + FROM prod_sage.t_hbns + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_hbns.numsalarie + AND t_hbns.datehist between w_profils.date_debut and w_profils.date_fin + JOIN prod_sage.t_rub ON t_rub.coderubrique = t_hbns.coderubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = t_rub.coderubrique + WHERE 1=1 + AND t_hbns.datehist >= rhp('rhprovider_start')::date + AND t_rub.imprimable NOT IN (1, 3) + AND t_hbns.valeurmontant != 0 + and t_rubriques.code_calcul NOT IN ('9') + ; + + -- BRUT et od (paie non cloturee) + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + date_paie_encours AS date, + 0 as typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', date_paie_encours)::text||lpad(date_part('month', date_paie_encours), 2, '0'))::numeric AS mois, + t_rub.coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + T_BNSSAL.valeurbase::numeric AS base, + T_BNSSAL.valeurnombre::numeric AS nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as masse_salariale, + (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN t_rubriques.code_calcul IN ('3', '4') OR t_rub.dasavnat = 1 OR t_rub.coderubrique = '9' OR t_rub.coderubrique >= 79900 THEN 0 ELSE T_BNSSAL.VALEURMONTANTSALARIAL END) AS montant_brut, + (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN t_rubriques.code_calcul NOT IN ('3') OR t_rub.coderubrique = '9' OR t_rub.coderubrique >= 79900 THEN 0 ELSE T_BNSSAL.VALEURMONTANTSALARIAL END) AS montant_frais_imposables, + T_BNSSAL.VALEURTAUXSALARIAL AS taux_sal, + 0 AS montant_sal, + 0 AS taux_pat, + 0 AS montant_pat, + (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * CASE WHEN t_rub.coderubrique > 19990 AND t_rub.dasavnat != 1 THEN T_BNSSAL.VALEURMONTANTSALARIAL ELSE 0 END AS od_net, + 0 as od_net_p, + (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * CASE WHEN t_rub.dasavnat = 1 AND montantdequivalence = 0 OR t_rubriques.code_calcul = '4' THEN T_BNSSAL.VALEURMONTANTSALARIAL ELSE 0 END AS avt_nat, + 0 AS net_imposable, + 0 AS net_a_payer, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee + t_rub.nodordre AS ordre, + 0 AS type_rub + FROM prod_sage.T_BNSSAL + JOIN w_periode ON 1=1 + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = T_BNSSAL.numsalarie + AND date_paie_encours between w_profils.date_debut and w_profils.date_fin + JOIN prod_sage.t_rub ON t_rub.coderubrique = T_BNSSAL.coderubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = t_rub.coderubrique + WHERE 1=1 + AND t_rub.imprimable NOT IN (1, 3) + AND T_BNSSAL.VALEURMONTANTSALARIAL != 0 + and t_rubriques.code_calcul NOT IN ('9') + ; + + -- Cotisations (mois clotures) + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + t_hcot.datehcot AS date, + t_hcot.typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', t_hcot.datehcot)::text||lpad(date_part('month', t_hcot.datehcot), 2, '0'))::numeric AS mois, + t_rub.coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_hcot.valeursbase AS base, + t_hcot.valeursnombre AS nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as masse_salariale, + 0 AS montant_brut, + 0 AS montant_frais_imposables, + t_hcot.valeurstauxsalarial AS taux_sal, + (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * t_hcot.valeursmontantsalarial AS montant_sal, + t_hcot.valeurstauxpatronal AS taux_pat, + (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * t_hcot.valeursmontantpatronal AS montant_pat, + 0 AS od_net, + 0 as od_net_p, + 0 AS avt_nat, + 0 AS net_imposable, + 0 AS net_a_payer, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee, + t_rub.nodordre AS ordre, + 1 AS type_rub + FROM prod_sage.t_hcot + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_hcot.numsalarie + AND t_hcot.datehcot between w_profils.date_debut and w_profils.date_fin + JOIN prod_sage.t_rub ON t_rub.coderubrique = t_hcot.coderubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = t_rub.coderubrique + WHERE true + AND t_hcot.datehcot >= rhp('rhprovider_start')::date + AND t_rub.imprimable != 1 + AND (t_hcot.valeursmontantsalarial != 0 OR t_hcot.valeursmontantpatronal != 0) + ; + + -- Cotisations (mois non clotures) + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + date_paie_encours AS date, + 0 as typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', date_paie_encours)::text||lpad(date_part('month', date_paie_encours), 2, '0'))::numeric AS mois, + t_rub.coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + T_COTSAL.valeurbase AS base, + T_COTSAL.valeurnombre AS nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as masse_salariale, + 0 AS montant_brut, + 0 AS montant_frais_imposables, + T_COTSAL.VALEURTAUXSAL AS taux_sal, + (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * T_COTSAL.VALEURMONTANTSAL AS montant_sal, + T_COTSAL.VALEURTAUXPATRONAL AS taux_pat, + (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * T_COTSAL.VALEURMONTANTPATRONAL AS montant_pat, + 0 AS od_net, + 0 as od_net_p, + 0 AS avt_nat, + 0 AS net_imposable, + 0 AS net_a_payer, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee, + t_rub.nodordre AS ordre, + 1 AS type_rub + FROM prod_sage.T_COTSAL + JOIN w_periode ON 1=1 + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = T_COTSAL.numsalarie + AND date_paie_encours between w_profils.date_debut and w_profils.date_fin + JOIN prod_sage.t_rub ON t_rub.coderubrique = T_COTSAL.coderubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = t_rub.coderubrique + WHERE t_rub.imprimable != 1 AND + (T_COTSAL.VALEURMONTANTSAL != 0 OR T_COTSAL.VALEURMONTANTPATRONAL != 0) + ; + + -- Cumuls paie cloturee + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + t_hcum.datehist AS date, + t_hcum.typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', t_hcum.datehist)::text||lpad(date_part('month', t_hcum.datehist), 2, '0'))::numeric AS mois, + 0 AS coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + CASE WHEN ENTITE IN (84, 86) THEN t_hcum.VALEURCUMUL ELSE 0 END AS base, + CASE WHEN ENTITE IN (84, 86) THEN t_hcum.VALEURCUMUL ELSE 0 END AS nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as masse_salariale, + 0 AS montant_brut, + 0 AS montant_frais_imposables, + 0 AS taux_sal, + 0 AS montant_sal, + 0 AS taux_pat, + 0 AS montant_pat, + 0 AS od_net, + 0 as od_net_p, + 0 AS avt_nat, + CASE WHEN ENTITE = 4 THEN t_hcum.VALEURCUMUL ELSE 0 END AS net_imposable, + CASE WHEN ENTITE = 3 THEN t_hcum.VALEURCUMUL ELSE 0 END AS net_a_payer, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee, + t_rubriques.rang_edition AS ordre, + 2 AS type_rub + FROM prod_sage.t_hcum + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_hcum.numsalarie + AND t_hcum.datehist between w_profils.date_debut and w_profils.date_fin + JOIN rh.t_rubriques ON t_rubriques.code_original = 'C' || lpad(t_hcum.ENTITE, 3, '0') + WHERE true + AND t_hcum.datehist >= rhp('rhprovider_start')::date + AND ENTITE IN (3, 4, 84, 86) + ; + + -- Cumuls paie non cloturee + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + date_paie_encours AS date, + 0 as typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', date_paie_encours)::text||lpad(date_part('month', date_paie_encours), 2, '0'))::numeric AS mois, + 0 AS coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + CASE WHEN OPCSTCUMUL in (84, 86) THEN T_CUMSAL.VALEURCUMINTERMEDIAIRE ELSE 0 END AS base, + CASE WHEN OPCSTCUMUL in (84, 86) THEN T_CUMSAL.VALEURCUMINTERMEDIAIRE ELSE 0 END AS nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as masse_salariale, + 0 AS montant_brut, + 0 AS montant_frais_imposables, + 0 AS taux_sal, + 0 AS montant_sal, + 0 AS taux_pat, + 0 AS montant_pat, + 0 AS od_net, + 0 as od_net_p, + 0 AS avt_nat, + CASE WHEN OPCSTCUMUL = 4 THEN T_CUMSAL.VALEURCUMINTERMEDIAIRE ELSE 0 END AS net_imposable, + CASE WHEN OPCSTCUMUL = 3 THEN T_CUMSAL.VALEURCUMINTERMEDIAIRE ELSE 0 END AS net_a_payer, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee, + t_rubriques.rang_edition AS ordre, + 2 AS type_rub + FROM prod_sage.T_CUMSAL + JOIN w_periode ON 1=1 + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = T_CUMSAL.numsalarie + AND date_paie_encours between w_profils.date_debut and w_profils.date_fin + JOIN rh.t_rubriques ON t_rubriques.code_original = 'C' || lpad(T_CUMSAL.OPCSTCUMUL, 3, '0') + WHERE OPCSTCUMUL IN (3, 4, 84, 86) + ; + + -- Suppression des bulletins composés uniquement des 3 (ou 4) rubriques de cumul : + -- * 3 (net à payer), + -- * 4 (net imposable), + -- * 86 (heures payées), + -- * [84 (heures travaillées)] + -- toutes à 0. + DELETE FROM w_hp + USING ( + select + matricule, + date + from w_hp + group by 1,2 + having 1=1 + AND sum(base) = 0 + AND sum(net_imposable) = 0 + AND sum(net_a_payer) = 0 + AND count(*) in (3, 4) + ) AS subq + WHERE 1=1 + AND w_hp.matricule = subq.matricule + AND w_hp.date = subq.date + ; + + ]]> + + + + = rhp('rhprovider_start')::date + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié même s'il n'y a rien. + AND (false + OR t_hbns.valeurmontant != 0 + OR t_hbns.valeurnombre != 0) + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + -- BRUT et od (paie non cloturee) + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + date_paie_encours AS date, + 0 as typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', date_paie_encours)::text||lpad(date_part('month', date_paie_encours), 2, '0'))::numeric AS mois, + t_rub.coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_rubriques.c_base + * case when @t_rubriques.c_base != 1 then coalesce(w_profils.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_base THEN (CASE s_base + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) else 0 end AS base, + t_rubriques.c_nombre + * case when @t_rubriques.c_nombre != 1 then coalesce(w_profils.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_nombre THEN (CASE s_nombre + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) else 0 end AS nombre, + t_rubriques.c_heures_contrat + * case when @t_rubriques.c_heures_contrat != 1 then coalesce(w_profils.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_heures_contrat + then (CASE s_heures_contrat + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) + else 0 end + AS heure_contrat, + t_rubriques.c_heures_payees + * case when @t_rubriques.c_heures_payees != 1 then coalesce(w_profils.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_heures_payees + then (CASE s_heures_payees + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) + else 0 end + AS heure_payee, + t_rubriques.c_heures_travaillees + * case when @t_rubriques.c_heures_travaillees != 1 then coalesce(w_profils.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_heures_travaillees + then (CASE s_heures_travaillees + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) + else 0 end + AS heure_travaillee, + t_rubriques.c_masse_salariale * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_masse_salariale THEN t_bnssal.valeurmontantsalarial::numeric else 0 end) AS masse_salariale, + t_rubriques.c_brut * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_brut THEN t_bnssal.valeurmontantsalarial::numeric else 0 end) AS montant_brut, + t_rubriques.c_frais_imposables * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (case when p_frais_imposables then t_bnssal.valeurmontantsalarial::numeric else 0 end) AS montant_frais_imposables, + t_rubriques.coefficient_txs * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (case when p_cotisation_salarie then t_bnssal.valeurtauxsalarial::numeric else 0 end) AS taux_sal, + t_rubriques.c_cotisation_salarie * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (case when p_cotisation_salarie then t_bnssal.valeurmontantsalarial::numeric else 0 end) AS montant_sal, + t_rubriques.coefficient_txp * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (case when p_cotisation_patronale then 0 else 0 end) AS taux_pat, + t_rubriques.c_cotisation_patronale * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (case when p_cotisation_patronale then 0 else 0 end) AS montant_pat, + t_rubriques.c_od_net_salarie * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_od_net_salarie THEN t_bnssal.valeurmontantsalarial::numeric ELSE 0 END) AS od_net, + t_rubriques.c_od_net_patronale * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_od_net_patronale then 0 ELSE 0 END) AS od_net_p, + t_rubriques.c_avantage_nature * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_avantage_nature THEN t_bnssal.valeurmontantsalarial::numeric ELSE 0 END) AS avt_nat, + t_rubriques.c_net_imposable * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_net_imposable THEN t_bnssal.valeurmontantsalarial::numeric ELSE 0 END) AS net_imposable, + t_rubriques.c_net_a_payer * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_net_a_payer THEN t_bnssal.valeurmontantsalarial::numeric ELSE 0 END) AS net_a_payer, + t_rubriques.c_nombre_provisions * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_nombre_provisions + then (CASE s_nombre_provisions + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) + else 0 end + AS nombre_provisions, + t_rubriques.c_montant_provisions * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_montant_provisions + then (CASE s_montant_provisions + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) + else 0 end + AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_masse_salariale_provisionnee + then (CASE s_masse_salariale_provisionnee + WHEN 0 THEN t_bnssal.valeurnombre::numeric + WHEN 1 THEN t_bnssal.valeurbase::numeric + WHEN 3 THEN t_bnssal.valeurmontantsalarial::numeric + WHEN 5 THEN t_bnssal.valeurmontantsalarial::numeric + END) + else 0 end + AS masse_salariale_provisionnee, + t_rub.nodordre AS ordre, + 0 AS type_rub + FROM prod_sage.t_bnssal + JOIN w_periode ON 1=1 + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_bnssal.numsalarie + AND date_paie_encours between w_profils.date_debut and w_profils.date_fin + JOIN prod_sage.t_rub ON t_rub.coderubrique = t_bnssal.coderubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = t_rub.coderubrique + where 1=1 + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié même s'il n'y a rien. + AND (false + OR t_bnssal.valeurmontantsalarial != 0 + OR t_bnssal.valeurnombre != 0) + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + -- Cotisations (mois clotures) + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + t_hcot.datehcot AS date, + t_hcot.typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', t_hcot.datehcot)::text||lpad(date_part('month', t_hcot.datehcot), 2, '0'))::numeric AS mois, + t_rub.coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_rubriques.c_base + * case when @t_rubriques.c_base != 1 then coalesce(w_hst_bul.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_base THEN (CASE s_base + WHEN 0 THEN t_hcot.valeursnombre::numeric + WHEN 1 THEN t_hcot.valeursbase::numeric + WHEN 2 THEN t_hcot.valeurstauxsalarial::numeric + WHEN 3 THEN t_hcot.valeursmontantsalarial::numeric + WHEN 4 THEN t_hcot.valeurstauxpatronal::numeric + WHEN 5 THEN t_hcot.valeursmontantpatronal::numeric + WHEN 6 THEN t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + WHEN 7 THEN t_hcot.valeursmontantsalarial::numeric - t_hcot.valeursmontantpatronal::numeric + WHEN 8 THEN -t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + END) else 0 end AS base, + t_rubriques.c_nombre + * case when @t_rubriques.c_nombre != 1 then coalesce(w_hst_bul.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_nombre THEN (CASE s_nombre + WHEN 0 THEN t_hcot.valeursnombre::numeric + WHEN 1 THEN t_hcot.valeursbase::numeric + WHEN 2 THEN t_hcot.valeurstauxsalarial::numeric + WHEN 3 THEN t_hcot.valeursmontantsalarial::numeric + WHEN 4 THEN t_hcot.valeurstauxpatronal::numeric + WHEN 5 THEN t_hcot.valeursmontantpatronal::numeric + WHEN 6 THEN t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + WHEN 7 THEN t_hcot.valeursmontantsalarial::numeric - t_hcot.valeursmontantpatronal::numeric + WHEN 8 THEN -t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + END) else 0 end AS nombre, + t_rubriques.c_heures_contrat * CASE WHEN p_heures_contrat THEN t_hcot.valeursnombre::numeric else 0 end AS heure_contrat, + t_rubriques.c_heures_payees * CASE WHEN p_heures_payees THEN t_hcot.valeursnombre::numeric else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees * CASE WHEN p_heures_travaillees THEN t_hcot.valeursnombre::numeric else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_masse_salariale THEN t_hcot.valeursmontantpatronal::numeric else 0 end) AS masse_salariale, + t_rubriques.c_brut * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_brut THEN t_hcot.valeursmontantsalarial::numeric else 0 end) AS montant_brut, + t_rubriques.c_frais_imposables * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_frais_imposables then t_hcot.valeursmontantsalarial::numeric else 0 end) AS montant_frais_imposables, + t_rubriques.coefficient_txs * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_salarie then t_hcot.valeurstauxsalarial::numeric else 0 end) AS taux_sal, + t_rubriques.c_cotisation_salarie * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_salarie then t_hcot.valeursmontantsalarial::numeric else 0 end) AS montant_sal, + t_rubriques.coefficient_txp * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_patronale then t_hcot.valeurstauxpatronal::numeric else 0 end) AS taux_pat, + t_rubriques.c_cotisation_patronale * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_patronale then t_hcot.valeursmontantpatronal::numeric else 0 end) AS montant_pat, + t_rubriques.c_od_net_salarie * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_od_net_salarie THEN t_hcot.valeursmontantsalarial::numeric ELSE 0 END) AS od_net, + t_rubriques.c_od_net_patronale * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_od_net_patronale THEN t_hcot.valeursmontantpatronal::numeric ELSE 0 END) AS od_net_p, + t_rubriques.c_avantage_nature * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_avantage_nature THEN t_hcot.valeursmontantsalarial::numeric ELSE 0 END) AS avt_nat, + t_rubriques.c_net_imposable * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * CASE WHEN p_net_imposable THEN (CASE s_net_imposable + WHEN 0 THEN t_hcot.valeursnombre::numeric + WHEN 1 THEN t_hcot.valeursbase::numeric + WHEN 2 THEN t_hcot.valeurstauxsalarial::numeric + WHEN 3 THEN t_hcot.valeursmontantsalarial::numeric + WHEN 4 THEN t_hcot.valeurstauxpatronal::numeric + WHEN 5 THEN t_hcot.valeursmontantpatronal::numeric + WHEN 6 THEN t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + WHEN 7 THEN t_hcot.valeursmontantsalarial::numeric - t_hcot.valeursmontantpatronal::numeric + WHEN 8 THEN -t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + END) ELSE 0 END AS net_imposable, + t_rubriques.c_net_a_payer * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_net_a_payer THEN t_hcot.valeursmontantsalarial::numeric ELSE 0 END) AS net_a_payer, + t_rubriques.c_nombre_provisions * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_nombre_provisions + then (CASE s_nombre_provisions + WHEN 0 THEN t_hcot.valeursnombre::numeric + WHEN 1 THEN t_hcot.valeursbase::numeric + WHEN 2 THEN t_hcot.valeurstauxsalarial::numeric + WHEN 3 THEN t_hcot.valeursmontantsalarial::numeric + WHEN 4 THEN t_hcot.valeurstauxpatronal::numeric + WHEN 5 THEN t_hcot.valeursmontantpatronal::numeric + WHEN 6 THEN t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + WHEN 7 THEN t_hcot.valeursmontantsalarial::numeric - t_hcot.valeursmontantpatronal::numeric + WHEN 8 THEN -t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + END) + else 0 end + AS nombre_provisions, + t_rubriques.c_montant_provisions * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_montant_provisions + then (CASE s_montant_provisions + WHEN 0 THEN t_hcot.valeursnombre::numeric + WHEN 1 THEN t_hcot.valeursbase::numeric + WHEN 2 THEN t_hcot.valeurstauxsalarial::numeric + WHEN 3 THEN t_hcot.valeursmontantsalarial::numeric + WHEN 4 THEN t_hcot.valeurstauxpatronal::numeric + WHEN 5 THEN t_hcot.valeursmontantpatronal::numeric + WHEN 6 THEN t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + WHEN 7 THEN t_hcot.valeursmontantsalarial::numeric - t_hcot.valeursmontantpatronal::numeric + WHEN 8 THEN -t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + END) + else 0 end + AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_masse_salariale_provisionnee + then (CASE s_masse_salariale_provisionnee + WHEN 0 THEN t_hcot.valeursnombre::numeric + WHEN 1 THEN t_hcot.valeursbase::numeric + WHEN 2 THEN t_hcot.valeurstauxsalarial::numeric + WHEN 3 THEN t_hcot.valeursmontantsalarial::numeric + WHEN 4 THEN t_hcot.valeurstauxpatronal::numeric + WHEN 5 THEN t_hcot.valeursmontantpatronal::numeric + WHEN 6 THEN t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + WHEN 7 THEN t_hcot.valeursmontantsalarial::numeric - t_hcot.valeursmontantpatronal::numeric + WHEN 8 THEN -t_hcot.valeursmontantsalarial::numeric + t_hcot.valeursmontantpatronal::numeric + END) + else 0 end + AS masse_salariale_provisionnee, + t_rub.nodordre AS ordre, + 1 AS type_rub + FROM prod_sage.t_hcot + JOIN w_hst_bul ON 1=1 + AND w_hst_bul.numsalarie = t_hcot.numsalarie + AND w_hst_bul.datehist = t_hcot.datehcot + AND w_hst_bul.typedubulletin = t_hcot.typedubulletin + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_hcot.numsalarie + AND w_hst_bul.datehist_cti between w_profils.date_debut and w_profils.date_fin + AND w_profils.typedubulletin = t_hcot.typedubulletin + JOIN prod_sage.t_rub ON t_rub.coderubrique = t_hcot.coderubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = t_rub.coderubrique + WHERE true + AND t_hcot.datehcot >= rhp('rhprovider_start')::date + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié même s'il n'y a rien. + AND (false + OR t_hcot.valeursnombre != 0 + OR t_hcot.valeursmontantsalarial != 0 + OR t_hcot.valeursmontantpatronal != 0) + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + -- Cotisations (mois non clotures) + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + date_paie_encours AS date, + 0 as typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', date_paie_encours)::text||lpad(date_part('month', date_paie_encours), 2, '0'))::numeric AS mois, + t_rub.coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_rubriques.c_base + * case when @t_rubriques.c_base != 1 then coalesce(w_profils.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_base THEN (CASE s_base + WHEN 0 THEN t_cotsal.valeurnombre::numeric + WHEN 1 THEN t_cotsal.valeurbase::numeric + WHEN 2 THEN t_cotsal.valeurtauxsal::numeric + WHEN 3 THEN t_cotsal.valeurmontantsal::numeric + WHEN 4 THEN t_cotsal.valeurtauxpatronal::numeric + WHEN 5 THEN t_cotsal.valeurmontantpatronal::numeric + WHEN 6 THEN t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + WHEN 7 THEN t_cotsal.valeurmontantsal::numeric - t_cotsal.valeurmontantpatronal::numeric + WHEN 8 THEN -t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + END) else 0 end AS base, + t_rubriques.c_nombre + * case when @t_rubriques.c_nombre != 1 then coalesce(w_profils.etp_contrat, 1.0) else 1.0 end + * CASE WHEN p_nombre THEN (CASE s_nombre + WHEN 0 THEN t_cotsal.valeurnombre::numeric + WHEN 1 THEN t_cotsal.valeurbase::numeric + WHEN 2 THEN t_cotsal.valeurtauxsal::numeric + WHEN 3 THEN t_cotsal.valeurmontantsal::numeric + WHEN 4 THEN t_cotsal.valeurtauxpatronal::numeric + WHEN 5 THEN t_cotsal.valeurmontantpatronal::numeric + WHEN 6 THEN t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + WHEN 7 THEN t_cotsal.valeurmontantsal::numeric - t_cotsal.valeurmontantpatronal::numeric + WHEN 8 THEN -t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + END) else 0 end AS nombre, + t_rubriques.c_heures_contrat * CASE WHEN p_heures_contrat THEN t_cotsal.valeurnombre::numeric else 0 end AS heure_contrat, + t_rubriques.c_heures_payees * CASE WHEN p_heures_payees THEN t_cotsal.valeurnombre::numeric else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees * CASE WHEN p_heures_travaillees THEN t_cotsal.valeurnombre::numeric else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_masse_salariale THEN t_cotsal.valeurmontantpatronal::numeric else 0 end) AS masse_salariale, + t_rubriques.c_brut * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_brut THEN t_cotsal.valeurmontantsal::numeric else 0 end) AS montant_brut, + t_rubriques.c_frais_imposables * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_frais_imposables then t_cotsal.valeurmontantsal::numeric else 0 end) AS montant_frais_imposables, + t_rubriques.coefficient_txs * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_salarie then t_cotsal.valeurtauxsal::numeric else 0 end) AS taux_sal, + t_rubriques.c_cotisation_salarie * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_salarie then t_cotsal.valeurmontantsal::numeric else 0 end) AS montant_sal, + t_rubriques.coefficient_txp * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_patronale then t_cotsal.valeurtauxpatronal::numeric else 0 end) AS taux_pat, + t_rubriques.c_cotisation_patronale * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (case when p_cotisation_patronale then t_cotsal.valeurmontantpatronal::numeric else 0 end) AS montant_pat, + t_rubriques.c_od_net_salarie * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_od_net_salarie THEN t_cotsal.valeurmontantsal::numeric ELSE 0 END) AS od_net, + t_rubriques.c_od_net_patronale * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_od_net_patronale THEN t_cotsal.valeurmontantpatronal::numeric ELSE 0 END) AS od_net_p, + t_rubriques.c_avantage_nature * (CASE WHEN t_rub.gain = 1 THEN -1 ELSE 1 END) * (CASE WHEN p_avantage_nature THEN t_cotsal.valeurmontantsal::numeric ELSE 0 END) AS avt_nat, + t_rubriques.c_net_imposable * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * CASE WHEN p_net_imposable THEN (CASE s_net_imposable + WHEN 0 THEN t_cotsal.valeurnombre::numeric + WHEN 1 THEN t_cotsal.valeurbase::numeric + WHEN 2 THEN t_cotsal.valeurtauxsal::numeric + WHEN 3 THEN t_cotsal.valeurmontantsal::numeric + WHEN 4 THEN t_cotsal.valeurtauxpatronal::numeric + WHEN 5 THEN t_cotsal.valeurmontantpatronal::numeric + WHEN 6 THEN t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + WHEN 7 THEN t_cotsal.valeurmontantsal::numeric - t_cotsal.valeurmontantpatronal::numeric + WHEN 8 THEN -t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + END) ELSE 0 END AS net_imposable, + t_rubriques.c_net_a_payer * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN p_net_a_payer THEN t_cotsal.valeurmontantsal::numeric ELSE 0 END) AS net_a_payer, + t_rubriques.c_nombre_provisions * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_nombre_provisions + then (CASE s_nombre_provisions + WHEN 0 THEN t_cotsal.valeurnombre::numeric + WHEN 1 THEN t_cotsal.valeurbase::numeric + WHEN 2 THEN t_cotsal.valeurtauxsal::numeric + WHEN 3 THEN t_cotsal.valeurmontantsal::numeric + WHEN 4 THEN t_cotsal.valeurtauxpatronal::numeric + WHEN 5 THEN t_cotsal.valeurmontantpatronal::numeric + WHEN 6 THEN t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + WHEN 7 THEN t_cotsal.valeurmontantsal::numeric - t_cotsal.valeurmontantpatronal::numeric + WHEN 8 THEN -t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + END) + else 0 end + AS nombre_provisions, + t_rubriques.c_montant_provisions * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_montant_provisions + then (CASE s_montant_provisions + WHEN 0 THEN t_cotsal.valeurnombre::numeric + WHEN 1 THEN t_cotsal.valeurbase::numeric + WHEN 2 THEN t_cotsal.valeurtauxsal::numeric + WHEN 3 THEN t_cotsal.valeurmontantsal::numeric + WHEN 4 THEN t_cotsal.valeurtauxpatronal::numeric + WHEN 5 THEN t_cotsal.valeurmontantpatronal::numeric + WHEN 6 THEN t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + WHEN 7 THEN t_cotsal.valeurmontantsal::numeric - t_cotsal.valeurmontantpatronal::numeric + WHEN 8 THEN -t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + END) + else 0 end + AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * (CASE WHEN t_rub.gain = 1 THEN 1 ELSE -1 END) + * CASE WHEN p_masse_salariale_provisionnee + then (CASE s_masse_salariale_provisionnee + WHEN 0 THEN t_cotsal.valeurnombre::numeric + WHEN 1 THEN t_cotsal.valeurbase::numeric + WHEN 2 THEN t_cotsal.valeurtauxsal::numeric + WHEN 3 THEN t_cotsal.valeurmontantsal::numeric + WHEN 4 THEN t_cotsal.valeurtauxpatronal::numeric + WHEN 5 THEN t_cotsal.valeurmontantpatronal::numeric + WHEN 6 THEN t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + WHEN 7 THEN t_cotsal.valeurmontantsal::numeric - t_cotsal.valeurmontantpatronal::numeric + WHEN 8 THEN -t_cotsal.valeurmontantsal::numeric + t_cotsal.valeurmontantpatronal::numeric + END) + else 0 end + AS masse_salariale_provisionnee, + t_rub.nodordre AS ordre, + 1 AS type_rub + FROM prod_sage.t_cotsal + JOIN w_periode ON 1=1 + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = T_COTSAL.numsalarie + AND date_paie_encours between w_profils.date_debut and w_profils.date_fin + JOIN prod_sage.t_rub ON t_rub.coderubrique = T_COTSAL.coderubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = t_rub.coderubrique + WHERE true + -- Filtrer les lignes générées systématiquement tous les mois par Sage pour chaque salarié même s'il n'y a rien. + AND (false + OR t_cotsal.valeurnombre != 0 + OR t_cotsal.valeurmontantsal != 0 + OR t_cotsal.valeurmontantpatronal != 0) + AND (false + OR p_nombre + OR p_base + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + -- Cumuls paie cloturee + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + t_hcum.datehist AS date, + t_hcum.typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', t_hcum.datehist)::text||lpad(date_part('month', t_hcum.datehist), 2, '0'))::numeric AS mois, + 0 AS coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_rubriques.c_base * CASE WHEN p_base THEN t_hcum.valeurcumul::numeric else 0 end AS base, + t_rubriques.c_nombre * CASE WHEN p_nombre THEN t_hcum.valeurcumul::numeric else 0 end AS nombre, + t_rubriques.c_heures_contrat * CASE WHEN p_heures_contrat THEN t_hcum.valeurcumul::numeric else 0 end AS heure_contrat, + t_rubriques.c_heures_payees * CASE WHEN p_heures_payees THEN t_hcum.valeurcumul::numeric else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees * CASE WHEN p_heures_travaillees THEN t_hcum.valeurcumul::numeric else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale * CASE WHEN p_masse_salariale THEN t_hcum.valeurcumul::numeric else 0 end AS masse_salariale, + t_rubriques.c_brut * CASE WHEN p_brut THEN t_hcum.valeurcumul::numeric else 0 end AS montant_brut, + t_rubriques.c_frais_imposables * case when p_frais_imposables then t_hcum.valeurcumul::numeric else 0 end AS montant_frais_imposables, + t_rubriques.coefficient_txs * case when p_cotisation_salarie then t_hcum.valeurcumul::numeric else 0 end AS taux_sal, + t_rubriques.c_cotisation_salarie * case when p_cotisation_salarie then t_hcum.valeurcumul::numeric else 0 end AS montant_sal, + t_rubriques.coefficient_txp * case when p_cotisation_patronale then t_hcum.valeurcumul::numeric else 0 end AS taux_pat, + t_rubriques.c_cotisation_patronale * case when p_cotisation_patronale then t_hcum.valeurcumul::numeric else 0 end AS montant_pat, + t_rubriques.c_od_net_salarie * CASE WHEN p_od_net_salarie THEN t_hcum.valeurcumul::numeric ELSE 0 END AS od_net, + t_rubriques.c_od_net_patronale * CASE WHEN p_od_net_patronale THEN t_hcum.valeurcumul::numeric ELSE 0 END AS od_net_p, + t_rubriques.c_avantage_nature * CASE WHEN p_avantage_nature THEN t_hcum.valeurcumul::numeric ELSE 0 END AS avt_nat, + t_rubriques.c_net_imposable * CASE WHEN p_net_imposable THEN t_hcum.valeurcumul::numeric ELSE 0 END AS net_imposable, + t_rubriques.c_net_a_payer * CASE WHEN p_net_a_payer THEN t_hcum.valeurcumul::numeric ELSE 0 END AS net_a_payer, + t_rubriques.c_nombre_provisions * CASE WHEN p_nombre_provisions THEN t_hcum.valeurcumul::numeric ELSE 0 END AS nombre_provisions, + t_rubriques.c_montant_provisions * CASE WHEN p_montant_provisions THEN t_hcum.valeurcumul::numeric ELSE 0 END AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * CASE WHEN p_masse_salariale_provisionnee THEN t_hcum.valeurcumul::numeric ELSE 0 END AS masse_salariale_provisionnee, + t_rubriques.rang_edition AS ordre, + 2 AS type_rub + FROM prod_sage.t_hcum + JOIN w_hst_bul ON 1=1 + AND w_hst_bul.numsalarie = t_hcum.numsalarie + AND w_hst_bul.datehist = t_hcum.datehist + AND w_hst_bul.typedubulletin = t_hcum.typedubulletin + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_hcum.numsalarie + AND w_hst_bul.datehist_cti between w_profils.date_debut and w_profils.date_fin + AND w_profils.typedubulletin = t_hcum.typedubulletin + JOIN rh.t_rubriques ON t_rubriques.code_original = 'C' || lpad(t_hcum.entite, 3, '0') + WHERE true + AND t_hcum.datehist >= rhp('rhprovider_start')::date + AND (false + OR p_base + OR p_nombre + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + -- Cumuls paie non cloturee + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + date_paie_encours AS date, + 0 as typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', date_paie_encours)::text||lpad(date_part('month', date_paie_encours), 2, '0'))::numeric AS mois, + 0 AS coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_rubriques.c_base * CASE WHEN p_base THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS base, + t_rubriques.c_nombre * CASE WHEN p_nombre THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS nombre, + t_rubriques.c_heures_contrat * CASE WHEN p_heures_contrat THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS heure_contrat, + t_rubriques.c_heures_payees * CASE WHEN p_heures_payees THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees * CASE WHEN p_heures_travaillees THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale * CASE WHEN p_masse_salariale THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS masse_salariale, + t_rubriques.c_brut * CASE WHEN p_brut THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_brut, + t_rubriques.c_frais_imposables * case when p_frais_imposables then t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_frais_imposables, + t_rubriques.coefficient_txs * case when p_cotisation_salarie then t_cumsal.valeurcumintermediaire::numeric else 0 end AS taux_sal, + t_rubriques.c_cotisation_salarie * case when p_cotisation_salarie then t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_sal, + t_rubriques.coefficient_txp * case when p_cotisation_patronale then t_cumsal.valeurcumintermediaire::numeric else 0 end AS taux_pat, + t_rubriques.c_cotisation_patronale * case when p_cotisation_patronale then t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_pat, + t_rubriques.c_od_net_salarie * CASE WHEN p_od_net_salarie THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS od_net, + t_rubriques.c_od_net_patronale * CASE WHEN p_od_net_patronale THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS od_net_p, + t_rubriques.c_avantage_nature * CASE WHEN p_avantage_nature THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS avt_nat, + t_rubriques.c_net_imposable * CASE WHEN p_net_imposable THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS net_imposable, + t_rubriques.c_net_a_payer * CASE WHEN p_net_a_payer THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS net_a_payer, + t_rubriques.c_nombre_provisions * CASE WHEN p_nombre_provisions THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS nombre_provisions, + t_rubriques.c_montant_provisions * CASE WHEN p_montant_provisions THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * CASE WHEN p_masse_salariale_provisionnee THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS masse_salariale_provisionnee, + t_rubriques.rang_edition AS ordre, + 2 AS type_rub + FROM prod_sage.t_cumsal + JOIN w_periode ON 1=1 + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_cumsal.numsalarie + AND date_paie_encours between w_profils.date_debut and w_profils.date_fin + JOIN rh.t_rubriques ON t_rubriques.code_original = 'C' || lpad(t_cumsal.opcstcumul, 3, '0') + WHERE false + OR p_base + OR p_nombre + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee + ; + + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + t_hcum.datehist AS date, + t_hcum.typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', t_hcum.datehist)::text||lpad(date_part('month', t_hcum.datehist), 2, '0'))::numeric AS mois, + 0 AS coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_rubriques.c_base * CASE WHEN p_base THEN t_hcum.valeurcumul::numeric else 0 end AS base, + t_rubriques.c_nombre * CASE WHEN p_nombre THEN t_hcum.valeurcumul::numeric else 0 end AS nombre, + t_rubriques.c_heures_contrat * CASE WHEN p_heures_contrat THEN t_hcum.valeurcumul::numeric else 0 end AS heure_contrat, + t_rubriques.c_heures_payees * CASE WHEN p_heures_payees THEN t_hcum.valeurcumul::numeric else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees * CASE WHEN p_heures_travaillees THEN t_hcum.valeurcumul::numeric else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale * CASE WHEN p_masse_salariale THEN t_hcum.valeurcumul::numeric else 0 end AS masse_salariale, + t_rubriques.c_brut * CASE WHEN p_brut THEN t_hcum.valeurcumul::numeric else 0 end AS montant_brut, + t_rubriques.c_frais_imposables * case when p_frais_imposables then t_hcum.valeurcumul::numeric else 0 end AS montant_frais_imposables, + t_rubriques.coefficient_txs * case when p_cotisation_salarie then t_hcum.valeurcumul::numeric else 0 end AS taux_sal, + t_rubriques.c_cotisation_salarie * case when p_cotisation_salarie then t_hcum.valeurcumul::numeric else 0 end AS montant_sal, + t_rubriques.coefficient_txp * case when p_cotisation_patronale then t_hcum.valeurcumul::numeric else 0 end AS taux_pat, + t_rubriques.c_cotisation_patronale * case when p_cotisation_patronale then t_hcum.valeurcumul::numeric else 0 end AS montant_pat, + t_rubriques.c_od_net_salarie * CASE WHEN p_od_net_salarie THEN t_hcum.valeurcumul::numeric ELSE 0 END AS od_net, + t_rubriques.c_od_net_patronale * CASE WHEN p_od_net_patronale THEN t_hcum.valeurcumul::numeric ELSE 0 END AS od_net_p, + t_rubriques.c_avantage_nature * CASE WHEN p_avantage_nature THEN t_hcum.valeurcumul::numeric ELSE 0 END AS avt_nat, + t_rubriques.c_net_imposable * CASE WHEN p_net_imposable THEN t_hcum.valeurcumul::numeric ELSE 0 END AS net_imposable, + t_rubriques.c_net_a_payer * CASE WHEN p_net_a_payer THEN t_hcum.valeurcumul::numeric ELSE 0 END AS net_a_payer, + t_rubriques.c_nombre_provisions * CASE WHEN p_nombre_provisions THEN t_hcum.valeurcumul::numeric ELSE 0 END AS nombre_provisions, + t_rubriques.c_montant_provisions * CASE WHEN p_montant_provisions THEN t_hcum.valeurcumul::numeric ELSE 0 END AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * CASE WHEN p_masse_salariale_provisionnee THEN t_hcum.valeurcumul::numeric ELSE 0 END AS masse_salariale_provisionnee, + t_rubriques.rang_edition AS ordre, + 2 AS type_rub + FROM prod_sage.t_hcum + JOIN w_hst_bul ON 1=1 + AND w_hst_bul.numsalarie = t_hcum.numsalarie + AND w_hst_bul.datehist = t_hcum.datehist + AND w_hst_bul.typedubulletin = t_hcum.typedubulletin + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_hcum.numsalarie + AND w_hst_bul.datehist_cti between w_profils.date_debut and w_profils.date_fin + AND w_profils.typedubulletin = t_hcum.typedubulletin + JOIN prod_sage.t_cst ON 1=1 + AND typeconstante = 6 + AND t_cst.CodeOperande1 = t_hcum.entite + JOIN rh.t_rubriques ON t_rubriques.code_original = t_cst.CodeConstante + WHERE true + AND t_hcum.datehist >= rhp('rhprovider_start')::date + AND t_hcum.valeurcumul::numeric != 0 + AND (false + OR p_base + OR p_nombre + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + -- Cumuls paie non cloturee + INSERT INTO w_hp + SELECT + w_profils.contrat_mois_id, + w_profils.contrat_id, + w_profils.salarie_id, + w_profils.profil_id, + w_profils.matricule AS code_original, + w_profils.matricule AS matricule, + w_profils.numsalarie, + w_profils.unite, + w_profils.categorie, + date_paie_encours AS date, + 0 as typedubulletin, + w_profils.bul_date_debut as date_debut, + w_profils.bul_date_fin as date_fin, + (date_part('year', date_paie_encours)::text||lpad(date_part('month', date_paie_encours), 2, '0'))::numeric AS mois, + 0 AS coderubrique, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + t_rubriques.c_base * CASE WHEN p_base THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS base, + t_rubriques.c_nombre * CASE WHEN p_nombre THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS nombre, + t_rubriques.c_heures_contrat * CASE WHEN p_heures_contrat THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS heure_contrat, + t_rubriques.c_heures_payees * CASE WHEN p_heures_payees THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS heure_payee, + t_rubriques.c_heures_travaillees * CASE WHEN p_heures_travaillees THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS heure_travaillee, + t_rubriques.c_masse_salariale * CASE WHEN p_masse_salariale THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS masse_salariale, + t_rubriques.c_brut * CASE WHEN p_brut THEN t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_brut, + t_rubriques.c_frais_imposables * case when p_frais_imposables then t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_frais_imposables, + t_rubriques.coefficient_txs * case when p_cotisation_salarie then t_cumsal.valeurcumintermediaire::numeric else 0 end AS taux_sal, + t_rubriques.c_cotisation_salarie * case when p_cotisation_salarie then t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_sal, + t_rubriques.coefficient_txp * case when p_cotisation_patronale then t_cumsal.valeurcumintermediaire::numeric else 0 end AS taux_pat, + t_rubriques.c_cotisation_patronale * case when p_cotisation_patronale then t_cumsal.valeurcumintermediaire::numeric else 0 end AS montant_pat, + t_rubriques.c_od_net_salarie * CASE WHEN p_od_net_salarie THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS od_net, + t_rubriques.c_od_net_patronale * CASE WHEN p_od_net_patronale THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS od_net_p, + t_rubriques.c_avantage_nature * CASE WHEN p_avantage_nature THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS avt_nat, + t_rubriques.c_net_imposable * CASE WHEN p_net_imposable THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS net_imposable, + t_rubriques.c_net_a_payer * CASE WHEN p_net_a_payer THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS net_a_payer, + t_rubriques.c_nombre_provisions * CASE WHEN p_nombre_provisions THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS nombre_provisions, + t_rubriques.c_montant_provisions * CASE WHEN p_montant_provisions THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS montant_provisions, + t_rubriques.c_masse_salariale_provisionnee * CASE WHEN p_masse_salariale_provisionnee THEN t_cumsal.valeurcumintermediaire::numeric ELSE 0 END AS masse_salariale_provisionnee, + t_rubriques.rang_edition AS ordre, + 2 AS type_rub + FROM prod_sage.t_cumsal + JOIN w_periode ON 1=1 + JOIN w_profils ON 1=1 + AND w_profils.numsalarie = t_cumsal.numsalarie + AND date_paie_encours between w_profils.date_debut and w_profils.date_fin + JOIN prod_sage.t_cst ON 1=1 + AND typeconstante = 6 + AND t_cst.CodeOperande1 = t_cumsal.opcstcumul + JOIN rh.t_rubriques ON t_rubriques.code_original = t_cst.CodeConstante + WHERE true + AND t_cumsal.valeurcumintermediaire::numeric != 0 + AND (false + OR p_base + OR p_nombre + OR p_heures_contrat + OR p_heures_payees + OR p_heures_travaillees + OR p_masse_salariale + OR p_brut + OR p_avantage_nature + OR p_frais_imposables + OR p_cotisation_salarie + OR p_cotisation_patronale + OR p_od_net_salarie + OR p_od_net_patronale + OR p_net_imposable + OR p_net_a_payer + OR p_nombre_provisions + OR p_montant_provisions + OR p_masse_salariale_provisionnee) + ; + + ]]> + + + 1 AND w_MOD_SAUF.NOLIEN IS NOT NULL THEN T_RUB.CODERUBRIQUE ELSE 0 END) AS RUBRIQUES_SAUF, + MAX(CASE WHEN NUMERO = 4 THEN BORNEINF ELSE NULL END) AS BORNEINF_CATEGORIE, + MAX(CASE WHEN NUMERO = 4 THEN BORNESUP ELSE NULL END) AS BORNESUP_CATEGORIE, + + MAX(CASE WHEN NUMERO = 3 THEN BORNEINF ELSE NULL END) AS BORNEINF_UNITE, + MAX(CASE WHEN NUMERO = 3 THEN BORNESUP ELSE NULL END) AS BORNESUP_UNITE, + + MAX(CASE WHEN NUMERO = 9 THEN BORNEINF ELSE NULL END) AS BORNEINF_MATRICULE, + MAX(CASE WHEN NUMERO = 9 THEN BORNESUP ELSE NULL END) AS BORNESUP_MATRICULE + FROM prod_sage.T_MOD + LEFT JOIN w_MOD_SAUF ON W_MOD_SAUF.NOLIEN = T_MOD.NOLIEN AND + W_MOD_SAUF.NOLIGNE = T_MOD.NOLIGNE + JOIN prod_sage.T_ECR ON T_MOD.NOLIEN = T_ECR.NOLIEN AND + T_MOD.NOLIGNE = T_ECR.NOLIGNE AND + COMPTEGENERAL BETWEEN '6' AND '799999' + JOIN prod_sage.T_SEL ON T_MOD.NOLIEN = T_SEL.NOLIEN + AND T_MOD.NOLIGNE = T_SEL.NOLIGNE + JOIN prod_sage.t_CRITERESSEL ON t_CRITERESSEL.IDSEL = T_SEL.IDSEL + LEFT JOIN prod_sage.T_RUB ON (CODEELEMENT = T_RUB.CODERUBRIQUE OR TYPEELEMENT = 2 AND CODEELEMENT = 'BRUT' AND + T_RUB.CODERUBRIQUE IN (SELECT coderubrique FROM prod_sage.T_RUB WHERE TYPERUBRIQUE = 1)) + GROUP BY 1,2,3 + ; + + UPDATE w_SEL SET + BORNEINF_CATEGORIE = COALESCE(BORNEINF_CATEGORIE,''), + BORNESUP_CATEGORIE = COALESCE(BORNESUP_CATEGORIE,'99999999'), + BORNEINF_UNITE = COALESCE(BORNEINF_UNITE,''), + BORNESUP_UNITE = COALESCE(BORNESUP_UNITE,'99999999') + ; + + + DROP TABLE IF EXISTS w_HP_CPT; + CREATE TEMP TABLE w_HP_CPT AS + SELECT NUMSALARIE, UNITE, CATEGORIE, CODERUBRIQUE, ''::text AS COMPTEGENERAL, NULL::bigint AS compte_id + FROM w_hp + WHERE CODERUBRIQUE <> 0 + GROUP BY 1,2,3,4 + ; + + UPDATE w_HP_CPT + SET COMPTEGENERAL = w_SEL.COMPTEGENERAL + FROM w_SEL + WHERE w_hp_CPT.CODERUBRIQUE = ANY(w_SEL.RUBRIQUES) AND + w_hp_CPT.CODERUBRIQUE <> ALL(w_SEL.RUBRIQUES_SAUF) AND + UNITE BETWEEN BORNEINF_UNITE AND BORNESUP_UNITE AND + CATEGORIE BETWEEN BORNEINF_CATEGORIE AND BORNESUP_CATEGORIE + ; + + UPDATE w_HP_CPT + SET compte_id = t_compte.oid + FROM rh.t_compte + WHERE COMPTEGENERAL = t_compte.code + ; + + CREATE INDEX i_HP_CPT_1 + ON w_HP_CPT + USING btree (NUMSALARIE) + ; + + -- Génération paie + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + TRUNCATE rh.p_historique_paie + ; + + INSERT INTO rh.p_historique_paie( + code_original, + age_id, + base, + nombre, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + heure_contrat, + heure_payee, + heure_travaillee, + montant_avantage_nature, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + w_hp.matricule||date::date||typedubulletin::text as code_original, + date_part('year', age(date, date_naissance)) AS age_id, + base, + nombre, + contrat_id, + contrat_mois_id, + w_hp.date_debut, + w_hp.date_fin, + date::date AS date_paie, + w_hp.mois AS mois_activite, + w_hp.mois AS mois_paie, + heure_contrat, + heure_payee, + heure_travaillee, + avt_nat AS montant_avantage_nature, + montant_brut AS montant_brut, + masse_salariale as montant_masse_salariale, + montant_pat AS montant_cotisation_patronale, + montant_sal AS montant_cotisation_salarie, + montant_frais_imposables, + net_a_payer AS montant_net_a_payer_salarie, + net_imposable AS montant_net_imposable_salarie, + od_net AS montant_od_net_salarie, + 0 AS organisme_cotisation_id, + w_hp.profil_id, + t_rubriques.oid AS rubrique_id, + COALESCE(w_HP_CPT.compte_id, w_RUB_CPG.compte_id,0) AS compte_id, + p_salaries.oid, + taux_pat AS taux_cotisation_patronale, + taux_sal AS taux_cotisation_salarie, + nombre_provisions, + montant_provisions, + masse_salariale_provisionnee AS montant_masse_salariale_provisionnee + FROM w_hp + JOIN rh.p_salaries ON p_salaries.matricule = w_hp.matricule + JOIN rh.t_rubriques ON t_rubriques.code_original = w_hp.rub_code + LEFT JOIN w_HP_CPT ON + w_hp.NUMSALARIE = w_HP_CPT.NUMSALARIE AND + w_hp.UNITE = w_HP_CPT.UNITE AND + w_hp.CATEGORIE = w_HP_CPT.CATEGORIE AND + w_hp.CODERUBRIQUE = w_HP_CPT.CODERUBRIQUE + LEFT JOIN w_RUB_CPG ON w_hp.rub_code = w_RUB_CPG.CODERUBRIQUE + WHERE t_rubriques.p_detail + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + ]]> + + + + = rhp('rhprovider_start')::date + GROUP BY 1,2,3 + ; + + -- Insérer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie ( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + subq.age_id, + subq.contrat_id, + subq.contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + 0 as nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as montant_masse_salariale, + COALESCE(hcum_avantage_nature,0) - subq.montant_avantage_nature AS montant_avantage_nature, + COALESCE(hcum_brut,0) - subq.montant_brut AS montant_brut, + 0 AS montant_cotisation_patronale, + 0 AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + COALESCE(hcum_net_a_payer_salarie,0) - subq.montant_net_a_payer_salarie AS montant_net_a_payer_salarie, + COALESCE(hcum_net_imposable_salarie,0) - subq.montant_net_imposable_salarie AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + 0 AS compte_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee + FROM ( + SELECT + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + p_historique_paie.organisme_cotisation_id, + p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8, 17,18,19,20) AS subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON 1=1 + AND w_totaux.matricule = p_salaries.matricule + AND w_totaux.date = subq.date_paie + WHERE 1!=1 + OR COALESCE(hcum_avantage_nature,0) - subq.montant_avantage_nature <> 0 + OR COALESCE(hcum_brut,0) - subq.montant_brut <> 0 + OR COALESCE(hcum_net_a_payer_salarie,0) - subq.montant_net_a_payer_salarie <> 0 + OR COALESCE(hcum_net_imposable_salarie,0) - subq.montant_net_imposable_salarie <> 0 + ; + + -- Insérer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C006' nommée 'Ecart cumulé patronal') + INSERT INTO rh.p_historique_paie + ( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee + ) + SELECT + subq.age_id, + subq.contrat_id, + subq.contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + 0 AS nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as montant_masse_salariale, + 0 AS montant_avantage_nature, + 0 AS montant_brut, + COALESCE(hcum_cotisation_patronale,0) - subq.montant_cotisation_patronale AS montant_cotisation_patronale, + 0 AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + 0 AS montant_net_a_payer_salarie, + 0 AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C006') AS rubrique_id, + 0 AS compte_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee + FROM ( + SELECT + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + p_historique_paie.organisme_cotisation_id, + p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C006'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8, 17,18,19,20) AS subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON 1=1 + AND w_totaux.matricule = p_salaries.matricule + AND w_totaux.date = subq.date_paie + WHERE 1!=1 + OR COALESCE(hcum_cotisation_patronale,0) - subq.montant_cotisation_patronale <> 0 + ; + + -- Insérer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C007' nommée 'Ecart cumulé cotisations salariales') + INSERT INTO rh.p_historique_paie + ( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + nombre, + heure_contrat, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + compte_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + nombre_provisions, + montant_provisions, + montant_masse_salariale_provisionnee) + SELECT + subq.age_id, + subq.contrat_id, + subq.contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + 0 as nombre, + 0 as heure_contrat, + 0 as heure_payee, + 0 as heure_travaillee, + 0 as montant_masse_salariale, + 0 AS montant_avantage_nature, + 0 AS montant_brut, + 0 AS montant_cotisation_patronale, + COALESCE(hcum_cotisation_salarie,0) - subq.montant_cotisation_salarie AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + 0 AS montant_net_a_payer_salarie, + 0 AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C007') AS rubrique_id, + 0 AS compte_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee + FROM ( + SELECT + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + p_historique_paie.organisme_cotisation_id, + p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS nombre_provisions, + 0 AS montant_provisions, + 0 AS montant_masse_salariale_provisionnee + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8, 17,18,19,20) AS subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON 1=1 + AND w_totaux.matricule = p_salaries.matricule + AND w_totaux.date = subq.date_paie + WHERE 1!=1 + OR COALESCE(hcum_cotisation_salarie,0) - subq.montant_cotisation_salarie <> 0 + ; + + -- Supprimer les C000 qui contrepassent exactement + DROP TABLE IF EXISTS w_historique_paie_c000 + ; + + CREATE TEMP TABLE w_historique_paie_c000 AS + SELECT + contrat_mois_id, + mois_paie, + SUM(montant_brut) AS montant_brut_c000, + MIN(rubrique_id) AS rubrique_c000_id + FROM rh.p_historique_paie + WHERE rubrique_id IN (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') + GROUP BY 1,2 + HAVING SUM(montant_brut) <> 0 + ; + + DROP TABLE IF EXISTS w_historique_paie_frais + ; + + CREATE TEMP TABLE w_historique_paie_frais AS + SELECT + p_historique_paie.contrat_mois_id, + p_historique_paie.mois_paie, + rubrique_c000_id, + MIN(rubrique_id) AS rubrique_frais_id + FROM rh.p_historique_paie + JOIN w_historique_paie_c000 ON + p_historique_paie.contrat_mois_id = w_historique_paie_c000.contrat_mois_id AND + p_historique_paie.mois_paie = w_historique_paie_c000.mois_paie AND + p_historique_paie.montant_brut = 0 - w_historique_paie_c000.montant_brut_c000 + GROUP BY 1,2,3 + HAVING count(*) = 1 + ; + + UPDATE rh.p_historique_paie + SET + montant_frais_imposables = CASE WHEN rubrique_id = rubrique_frais_id THEN montant_brut ELSE 0 END, + montant_brut = 0 + FROM w_historique_paie_frais + WHERE 1=1 + AND p_historique_paie.contrat_mois_id = w_historique_paie_frais.contrat_mois_id + AND p_historique_paie.mois_paie = w_historique_paie_frais.mois_paie + AND p_historique_paie.rubrique_id IN (rubrique_frais_id, rubrique_c000_id) + ; + + ]]> + + + + + + + + + + + + + = '2008-01-01' + GROUP BY 1,2,3,4 + ; + + -- Peuplement de rh.p_visites_medicales + TRUNCATE rh.p_visites_medicales + ; + + ALTER SEQUENCE rh.s_visites_medicales RESTART WITH 1 + ; + + INSERT INTO rh.p_visites_medicales( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date, + motif_visite_id) + SELECT + p_salaries.oid, + p_contrats_mois.contrat_id, + p_contrats_mois.oid, + w_visites.mois_activite, + w_visites.date, + coalesce(t_motifs_visite.oid, 0) + FROM w_visites + JOIN rh.p_salaries ON p_salaries.matricule = w_visites.matricule + JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + AND w_visites.date BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin + LEFT JOIN rh.t_motifs_visite ON t_motifs_visite.code_original = w_visites.motif + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SAGE100.XML b/import_rh/iCTI_import_rh_SAGE100.XML new file mode 100644 index 0000000..83abe02 --- /dev/null +++ b/import_rh/iCTI_import_rh_SAGE100.XML @@ -0,0 +1,1588 @@ + + + + + '' THEN ' Q'||qualif ELSE '' END, + substr(lib_group||CASE WHEN qualif <> '' THEN ' Q'||qualif ELSE '' END,1,50) + FROM prod_sigems.groupe_fiehp + WHERE lpad(c_group,2,'0')||lpad(qualif,4,'0') NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + GROUP BY 1,2,3,4 + ;*/ + + -- @TODO: Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_grilles_groupes) + ; + + /* INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT c_group, c_group, lib_group, substr(lib_group,1,50) + FROM prod_sigems.groupe_fiehp + WHERE c_group NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + GROUP BY 1,2,3,4 + ;*/ + + -- Màj des motifs d'arret + INSERT INTO rh.t_motifs_arret(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_arret) + ; + + INSERT INTO rh.t_motifs_arret(code, texte, texte_court, code_original) + SELECT ta_code, ta_intitule, substr(ta_intitule,1,50), ta_code + FROM prod_sage100.f_tab + WHERE 1=1 + AND ta_typetable = 0 + AND ta_code NOT IN (SELECT code_original FROM rh.t_motifs_arret) + GROUP BY 1,2,3,4 + ; + + -- Màj des précisions du motif d'arrêt + INSERT INTO rh.t_precisions_motif_arret(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_precisions_motif_arret) + ; + + -- @TODO: Màj des motifs de visite médicale + INSERT INTO rh.t_motifs_visite(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_visite) + ; + + /* INSERT INTO rh.t_motifs_visite(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.MOTIF_VISMED + WHERE code NOT IN (SELECT code_original FROM rh.t_motifs_visite) + GROUP BY 1,2,3,4 + ;*/ + + -- @TODO: Màj des circonstances d'accident du travail + INSERT INTO rh.t_accident_circonstance(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_circonstance) + ; + + /* INSERT INTO rh.t_accident_circonstance(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.acc_circst + WHERE + code NOT IN (SELECT code_original FROM rh.t_accident_circonstance) + AND code <> '' + AND code IS DISTINCT FROM NULL + GROUP BY 1,2,3,4 + ;*/ + + -- @TODO: Màj des lieux d'accident du travail + INSERT INTO rh.t_accident_lieu(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_lieu) + ; + + /* INSERT INTO rh.t_accident_lieu(code_original, code, texte, texte_court) + SELECT code_original, code, code_original, substr(code_original,1,50) + FROM w_tmp_lieu_1 + WHERE + code_original NOT IN (SELECT code_original FROM rh.t_accident_lieu) + GROUP BY 1,2,3,4 + ;*/ + + -- @TODO: Màj de la nature de l'accident du travail + INSERT INTO rh.t_accident_nature(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_nature) + ; + + /* INSERT INTO rh.t_accident_nature(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.acc_nature + WHERE + code NOT IN (SELECT code_original FROM rh.t_accident_nature) + AND code <> '' + AND code IS DISTINCT FROM NULL + GROUP BY 1,2,3,4 + ;*/ + + -- @TODO: Màj des sièges d'accident du travail + INSERT INTO rh.t_accident_siege(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_siege) + ; + + /* INSERT INTO rh.t_accident_siege(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.acc_siege + WHERE + code NOT IN (SELECT code_original FROM rh.t_accident_siege) + AND code <> '' + AND code IS DISTINCT FROM NULL + GROUP BY 1,2,3,4 + ;*/ + + -- Màj des listes de formations + INSERT INTO rh.t_liste_formations(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_liste_formations) + ; + + INSERT INTO rh.t_liste_formations(code_original, code, texte, texte_court) + SELECT fo_code, fo_code, fo_intitule, substr(fo_intitule,1,50) + FROM prod_sage100.f_formation + WHERE fo_code NOT IN (SELECT code_original FROM rh.t_liste_formations) + GROUP BY 1,2,3,4 + ; + + ]]> + + + + + = 2008 + AND date_part('year', f_hcum.hu_date::date) <= 2020 + GROUP BY 1,2,3 + ; + + ]]> + + + date_fin + ; + + -- Création d'une table temporaire des contrats + DROP TABLE IF EXISTS w_cnt + ; + + CREATE TEMP TABLE w_cnt AS + SELECT + matricule, + '' AS numero_contrat, + eta_code, + min(date_debut) AS date_debut, + max(date_fin) AS date_fin, + coalesce(fp_contrat_nature,chr(1)||'*') AS type_contrat + FROM w_aff + LEFT JOIN prod_sage100.f_renssal ON f_renssal.sa_matricule = w_aff.matricule + GROUP BY 1,2,3,6 + + ; + + UPDATE w_cnt + SET numero_contrat = matricule||replace(date_debut,'-','') + ; + + -- Création d'une table temporaire de l'histo salarié dans établissements + /*DROP TABLE IF EXISTS w_ets + ; + + CREATE TEMP TABLE w_ets AS + SELECT + sa_matricule AS matricule, + ae_datededebut::date AS date_debut, + (ae_date::date - interval '1 day')::date AS date_fin, + ae_etab_code AS eta_code + FROM prod_sage100.f_hst_etablissement + ; + + DELETE FROM w_ets + WHERE date_debut > date_fin + ; + + UPDATE w_ets + SET date_debut = date_fin + WHERE date_debut IS NULL + ;*/ + + ]]> + + + + + + + + + = p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',p_contrats.date_debut)::date, 'nm') + + GREATEST(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + 1 AS anciennete_mois, + floor((base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',p_contrats.date_debut)::date, 'nm') + + GREATEST(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + 1) / 12) AS anciennete_annee_id, + p_salaries.oid + FROM rh.p_contrats + JOIN rh.p_salaries ON p_contrats.salarie_id = p_salaries.oid + --JOIN rh.t_etablissements ON p_contrats.etablissement_id = t_etablissements.oid + --JOIN rh.t_entreprises ON t_etablissements.entreprise_id = t_entreprises.oid + JOIN base.p_calendrier_mois ON (p_contrats.date_debut <= p_calendrier_mois.date_fin AND p_contrats.date_fin >= p_calendrier_mois.date_debut) + JOIN w_profils ON w_profils.numero_contrat = p_contrats.numero_contrat + GROUP BY 1,2,3,4,6,7,8,9,10,11,12,13,14,15 + ; + + ]]> + + + déplacée dans OD/Net + CREATE TEMP TABLE w_hp AS + ( + SELECT + sa_matricule AS matricule, + hb_date::date AS date, + base.cti_first_day(hb_date::date) AS date_debut, + base.cti_last_day(hb_date::date) AS date_fin, + to_char(hb_date::date,'YYYYMM')::numeric as mois, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + hb_base::numeric AS base, + (CASE WHEN ru_gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN ru_rubrique::int != 440 AND ru_type = 1 AND ru_das_avnat != 1 THEN hb_montant::numeric ELSE 0 END) AS montant_brut, + 0, --(CASE WHEN ru_gain = 1 THEN 1 ELSE -1 END) * (CASE WHEN ru_rubrique = 9 OR ru_rubrique >= 7990 THEN 0 ELSE hb_montant::numeric END) AS montant_frais_imposables, + hb_taux::numeric AS taux_sal, + 0 AS montant_sal, + 0 AS taux_pat, + 0 AS montant_pat, + (CASE WHEN (ru_rubrique::int = 440 OR ru_rubrique::int > 1999) AND ru_das_avnat != 1 THEN hb_montant::numeric ELSE 0 END) AS od_net, + (CASE WHEN ru_dasenplus2 = 2 THEN hb_montant::numeric ELSE 0 END) AS avt_nat, + 0 AS net_imposable, + 0 AS net_a_payer + FROM prod_sage100.f_hbns + JOIN prod_sage100.f_rub ON f_rub.ru_rubrique = f_hbns.hb_rubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = f_rub.ru_rubrique + WHERE 1=1 + AND ru_imprimable = 2 + AND hb_montant != 0 + AND date_part('year', hb_date::date) >= 2008 + --AND sa_matricule = 1117 + --AND hb_date >= '2012-01-01' + ) + UNION ALL + ( + SELECT + sa_matricule AS matricule, + hc_date::date AS date, + base.cti_first_day(hc_date::date) AS date_debut, + base.cti_last_day(hc_date::date) AS date_fin, + to_char(hc_date::date,'YYYYMM')::numeric AS mois, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + hc_base::numeric AS base, + 0 AS montant_brut, + 0 AS montant_frais_imposables, + hc_taux_salarial::numeric AS taux_sal, + (CASE WHEN ru_gain = 1 THEN -1 ELSE 1 END) * hc_montant_salarial::numeric AS montant_sal, + hc_taux_patronal::numeric AS taux_pat, + (CASE WHEN ru_gain = 1 THEN -1 ELSE 1 END) * hc_montant_patronal::numeric AS montant_pat, + 0 AS od_net, + 0 AS avt_nat, + 0 AS net_imposable, + 0 AS net_a_payer + FROM prod_sage100.f_hcot + JOIN prod_sage100.f_rub ON f_rub.ru_rubrique = f_hcot.hc_rubrique + JOIN rh.t_rubriques ON t_rubriques.code_original = f_rub.ru_rubrique + WHERE 1=1 + AND ru_imprimable = 2 + AND (hc_montant_salarial != 0 OR hc_montant_patronal != 0) + AND date_part('year', hc_date::date) >= 2008 + --AND sa_matricule = 1117 + --AND hc_date >= '2012-01-01' + ) + UNION ALL + ( + SELECT + sa_matricule AS matricule, + hu_date::date AS date, + base.cti_first_day(hu_date::date) AS date_debut, + base.cti_last_day(hu_date::date) AS date_fin, + to_char(hu_date::date,'YYYYMM')::numeric AS mois, + t_rubriques.oid AS rub_id, + t_rubriques.code_original AS rub_code, + t_rubriques.texte AS rub_texte, + CASE WHEN hu_constante = 86 THEN hu_valeurcumul::numeric ELSE 0 END AS base, + 0 AS montant_brut, + 0 AS montant_frais_imposables, + 0 AS taux_sal, + 0 AS montant_sal, + 0 AS taux_pat, + 0 AS montant_pat, + 0 AS od_net, + 0 AS avt_nat, + CASE WHEN hu_constante = 4 THEN hu_valeurcumul::numeric ELSE 0 END AS net_imposable, + CASE WHEN hu_constante = 3 THEN hu_valeurcumul::numeric ELSE 0 END AS net_a_payer + FROM prod_sage100.f_hcum + JOIN rh.t_rubriques ON t_rubriques.code_original = 'C' || lpad(hu_constante, 3, '0') + WHERE 1=1 + AND hu_constante::int IN (3, 4, 86) + AND date_part('year', hu_date::date) >= 2008 + --AND sa_matricule = 1117 + --AND hu_date >= '2012-01-01' + ) + ; + + CREATE INDEX i_w_hp_1 + ON w_hp + USING btree (matricule) + ; + + CREATE INDEX i_w_hp_2 + ON w_hp + USING btree (date) + ; + + CREATE INDEX i_w_hp_3 + ON w_hp + USING btree (rub_code) + ; + + TRUNCATE rh.p_historique_paie + ; + + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + INSERT INTO rh.p_historique_paie + ( + age_id, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie + ) + SELECT + date_part('year', age(date, date_naissance)) AS age_id, + base AS base, + p_contrats_mois.contrat_id AS contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + date_trunc('month', date)::date AS date_debut, + date::date AS date_fin, + date::date AS date_paie, + w_hp.mois AS mois_activite, + w_hp.mois AS mois_paie, + avt_nat AS montant_avantage_nature, + montant_brut AS montant_brut, + montant_pat AS montant_cotisation_patronale, + montant_sal AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + net_a_payer AS montant_net_a_payer_salarie, + net_imposable AS montant_net_imposable_salarie, + od_net AS montant_od_net_salarie, + 0 AS organisme_cotisation_id, + w_profils.profil_id AS profil_id, + w_hp.rub_id AS rubrique_id, + p_salaries.oid AS salarie_id, + taux_pat AS taux_cotisation_patronale, + taux_sal AS taux_cotisation_salarie + FROM w_hp + JOIN rh.p_salaries ON p_salaries.matricule = w_hp.matricule + JOIN w_profils ON 1=1 + AND w_profils.matricule = w_hp.matricule + AND base.cti_overlaps(aff_date_debut,aff_date_fin,w_hp.date_debut,w_hp.date_fin) + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + AND p_contrats_mois.mois_activite = w_hp.mois + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + -- Associer le bulletin de paie au dernier contrat connu lorsque pas de contrat couvrant le mois de paie. + UPDATE rh.p_historique_paie + SET + contrat_id = contrat, + contrat_mois_id = contrat_mois, + profil_id = profil + FROM + ( + SELECT + p_historique_paie.salarie_id, + p_historique_paie.date_paie, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats.date_fin),p_contrats.oid]))[2] AS contrat, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats.date_fin),p_contrats.profil_id]))[2] AS profil, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.oid]))[2] AS contrat_mois + FROM rh.p_historique_paie + JOIN rh.p_contrats ON p_contrats.salarie_id = p_historique_paie.salarie_id + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + WHERE p_historique_paie.contrat_mois_id IS NULL + GROUP BY 1,2 + ) AS subq + WHERE 1=1 + AND p_historique_paie.salarie_id = subq.salarie_id + AND p_historique_paie.date_paie = subq.date_paie + ; + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calculer l'écart + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + SELECT + sa_matricule AS matricule, + hu_date::date AS date, + to_char(hu_date::date,'YYYYMM')::numeric AS mois, + hu_constante as rub_code, + hu_valeurcumul::numeric AS montant + FROM prod_sage100.f_hcum + WHERE 1=1 + AND date_part('year', hu_date::date) >= 2008 + AND hu_constante::int IN (3,4,5,6,7,8,86) + ; + + -- Inserer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie + ( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie + ) + SELECT + age_id, + contrat_id, + contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + sum(CASE WHEN rub_code = 5 THEN montant - subq.montant_avantage_nature ELSE 0 END) AS montant_avantage_nature, + sum(CASE WHEN rub_code = 8 THEN montant - subq.montant_brut ELSE 0 END) AS montant_brut, + sum(CASE WHEN rub_code = 6 THEN montant - subq.montant_cotisation_patronale ELSE 0 END) AS montant_cotisation_patronale, + sum(CASE WHEN rub_code = 7 THEN montant - subq.montant_cotisation_salarie ELSE 0 END) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(CASE WHEN rub_code = 3 THEN montant - subq.montant_net_a_payer_salarie ELSE 0 END) AS montant_net_a_payer_salarie, + sum(CASE WHEN rub_code = 4 THEN montant - subq.montant_net_imposable_salarie ELSE 0 END) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM + ( + SELECT + p_historique_paie.age_id, + p_historique_paie.contrat_id, + p_historique_paie.contrat_mois_id, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_activite, + p_historique_paie.mois_paie, + 0 AS base, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + 0 AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + 0 AS montant_od_net_salarie, + p_historique_paie.organisme_cotisation_id, + p_historique_paie.profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 1,2,3,4,5,6,7,8,9, 18,19,20,21 + ) AS subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON + w_totaux.matricule = p_salaries.matricule + AND w_totaux.date = subq.date_paie + GROUP BY 1,2,3,4,5,6,7,8,9, 18,19,20,21 + HAVING 1!=1 + OR sum(CASE WHEN rub_code = 8 THEN montant - subq.montant_brut ELSE 0 END) <> 0 + OR sum(CASE WHEN rub_code = 5 THEN montant - subq.montant_avantage_nature ELSE 0 END) <> 0 + OR sum(CASE WHEN rub_code = 6 THEN montant - subq.montant_cotisation_patronale ELSE 0 END) <> 0 + OR sum(CASE WHEN rub_code = 7 THEN montant - subq.montant_cotisation_salarie ELSE 0 END) <> 0 + OR sum(CASE WHEN rub_code = 3 THEN montant - subq.montant_net_a_payer_salarie ELSE 0 END) <> 0 + OR sum(CASE WHEN rub_code = 4 THEN montant - subq.montant_net_imposable_salarie ELSE 0 END) <> 0 + ; + + /* + + Quels sont les écarts cumulés > 0 ? : + + SELECT + p_salaries.matricule, + p_historique_paie.* + FROM rh.p_historique_paie + JOIN rh.p_salaries on p_salaries.oid = p_historique_paie.salarie_id + JOIN rh.t_rubriques on t_rubriques.oid = p_historique_paie.rubrique_id + WHERE 1=1 + AND t_rubriques.code_original = 'C000' + AND + (1!=1 + OR p_historique_paie.base <> 0 + OR p_historique_paie.montant_brut <> 0 + OR p_historique_paie.montant_cotisation_salarie <> 0 + OR p_historique_paie.montant_cotisation_patronale <> 0 + OR p_historique_paie.montant_net_a_payer_salarie <> 0 + OR p_historique_paie.montant_net_imposable_salarie <> 0 + OR p_historique_paie.montant_avantage_nature <> 0 + ) + ORDER BY 1,4 DESC + ; + + */ + + ]]> + + + + + + 0 -- nb_jours > 0 + AND date_part('year', ap_arret_01debut::date) >= '2008' + GROUP BY 1,2,3,4,5,6,7 + ) + UNION + ( + SELECT + sa_matricule AS matricule, + ap_arret_02type AS motif, + to_char(ap_arret_02debut::date,'YYYYMM')::numeric AS mois, + ap_arret_02debut::date AS date_debut, + ap_arret_02fin::date AS date_fin, + ap_arret_02fin::date - ap_arret_02debut::date + 1 AS nb_jours, + '' AS no_contrat + FROM prod_sage100.f_hst_arret + WHERE 1=1 + AND ap_arret_02debut IS NOT NULL + AND ap_arret_02fin IS NOT NULL + AND ap_arret_02fin::date - ap_arret_02debut::date + 1 > 0 -- nb_jours > 0 + AND date_part('year', ap_arret_02debut::date) >= '2008' + GROUP BY 1,2,3,4,5,6,7 + ) + UNION + ( + SELECT + sa_matricule AS matricule, + ap_arret_03type AS motif, + to_char(ap_arret_03debut::date,'YYYYMM')::numeric AS mois, + ap_arret_03debut::date AS date_debut, + ap_arret_03fin::date AS date_fin, + ap_arret_03fin::date - ap_arret_03debut::date + 1 AS nb_jours, + '' AS no_contrat + FROM prod_sage100.f_hst_arret + WHERE 1=1 + AND ap_arret_03debut IS NOT NULL + AND ap_arret_03fin IS NOT NULL + AND ap_arret_03fin::date - ap_arret_03debut::date + 1 > 0 -- nb_jours > 0 + AND date_part('year', ap_arret_03debut::date) >= '2008' + GROUP BY 1,2,3,4,5,6,7 + ) + ; + + UPDATE w_arr + SET no_contrat = w_cnt.numero_contrat + FROM w_cnt + WHERE 1=1 + AND w_arr.matricule = w_cnt.matricule + AND base.cti_overlaps(w_arr.date_debut,w_arr.date_fin,w_cnt.date_debut,w_cnt.date_fin) + ; + + -- Alimentation des arrêts de travail + TRUNCATE rh.p_arrets_travail + ; + + ALTER SEQUENCE rh.s_arrets_travail RESTART WITH 1 + ; + + INSERT INTO rh.p_arrets_travail( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + date_reprise, + motif_arret_id, + precision_motif_arret_id, + nb_jours + ) + SELECT p_salaries.oid, + p_contrats.oid, + w_arr.mois, + w_arr.date_debut, + w_arr.date_fin, + (w_arr.date_fin + INTERVAL '1 day')::date AS date_reprise, + t_motifs_arret.oid AS motif_arret_id, + 0 AS precision_motif_arret_id, + w_arr.nb_jours + FROM w_arr + JOIN rh.p_salaries ON p_salaries.matricule = w_arr.matricule + JOIN rh.t_motifs_arret ON t_motifs_arret.code_original = w_arr.motif + JOIN rh.p_contrats ON p_contrats.salarie_id = p_salaries.oid + ; + + -- Ventilation mensuelle des arrêts de travail + TRUNCATE rh.p_arrets_travail_mois + ; + + INSERT INTO rh.p_arrets_travail_mois( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + nb_debut_arret, + nb_fin_arret, + nb_reprise_apres_arret, + date_debut, + date_fin, + nb_jours + ) + SELECT + p_arrets_travail.oid AS arret_travail_id, + p_arrets_travail.salarie_id AS salarie_id, + p_arrets_travail.contrat_id AS contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.mois_activite, + CASE WHEN p_arrets_travail.date_debut BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_arret, + CASE WHEN p_arrets_travail.date_fin BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_arret, + CASE WHEN p_arrets_travail.date_reprise BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END AS nombre_reprise_apres_arret, + GREATEST(p_contrats_mois.date_debut, p_arrets_travail.date_debut) AS date_debut, + LEAST(p_contrats_mois.date_fin, p_arrets_travail.date_fin) AS date_fin, + LEAST(p_contrats_mois.date_fin, p_arrets_travail.date_fin)::date - GREATEST(p_contrats_mois.date_debut, p_arrets_travail.date_debut)::date + 1 AS nb_jours + FROM rh.p_contrats_mois + JOIN rh.p_arrets_travail ON (p_contrats_mois.contrat_id = p_arrets_travail.contrat_id AND + p_arrets_travail.date_debut <= p_contrats_mois.date_fin AND + p_arrets_travail.date_reprise >= p_contrats_mois.date_debut + ) + ORDER BY arret_travail_id, p_contrats_mois.mois_activite + ; + + ]]> + + + + + + + + + = '2008' + GROUP BY 1,2,3,4,5,6,7,8 + ; + + UPDATE w_for + SET no_contrat = w_cnt.numero_contrat + FROM w_cnt + WHERE 1=1 + AND w_for.matricule = w_cnt.matricule + AND base.cti_overlaps(w_for.date_debut, w_for.date_fin, w_cnt.date_debut, w_cnt.date_fin) + ; + + UPDATE w_for + SET no_contrat = subq.numero_contrat + FROM + ( + SELECT + matricule, + (max(ARRAY[extract(EPOCH FROM w_cnt.date_fin), w_cnt.numero_contrat::numeric]))[2] AS numero_contrat + FROM w_cnt + GROUP BY 1 + ) AS subq + WHERE 1=1 + AND w_for.matricule = subq.matricule + AND no_contrat = '' + ; + + -- Peuplement de rh.p_formations + TRUNCATE rh.p_formations + ; + + ALTER SEQUENCE rh.s_formations RESTART WITH 1 + ; + + INSERT INTO rh.p_formations + ( + salarie_id, + formation_id, + contrat_id, + contrat_mois_id, + formation_date, + mois_activite, + nb_heures, + organisateur + ) + SELECT + p_salaries.oid, + t_liste_formations.oid, + p_contrats_mois.contrat_id, + p_contrats_mois.oid, + w_for.date_fin, + w_for.mois_activite, + w_for.nb_heures, + substr(w_for.organisateur, 1, 20) + FROM + w_for + JOIN rh.p_salaries ON p_salaries.matricule = w_for.matricule + JOIN rh.t_liste_formations ON w_for.code = t_liste_formations.code + JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + AND p_contrats_mois.mois_activite = w_for.mois_activite + ORDER BY 1,2,3,4 + ; + + ]]> + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SAGEX3RHP.XML b/import_rh/iCTI_import_rh_SAGEX3RHP.XML new file mode 100644 index 0000000..f60cb7c --- /dev/null +++ b/import_rh/iCTI_import_rh_SAGEX3RHP.XML @@ -0,0 +1,1536 @@ + + + + + + + + '' + GROUP BY 1 + ; + + UPDATE temp.x_ref_qualification SET + texte = replace(texte,'(E )','(E)'), + texte_court = replace(texte,'(E )','(E)') + WHERE texte LIKE '%(E )%' + ; + + UPDATE temp.x_ref_qualification + SET code = + UPPER( + substr(split_part(texte,' ',1),1,3) || + substr(split_part(texte,' ',2),1,3) || + substr(split_part(texte,' ',3),1,3) || + substr(split_part(texte,' ',4),1,3) + ) + ; + + -- Identification des Comptes + DROP TABLE IF EXISTS temp.x_ref_compte + ; + + CREATE TABLE temp.x_ref_compte AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'DESTRA' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHOTRA' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'GACCOUNT' + GROUP BY 1 + ; + + -- Identification des situations de famille + DROP TABLE IF EXISTS temp.x_ref_situation_famille + ; + + CREATE TABLE temp.x_ref_situation_famille AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'LNGDES' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHODES' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'ATABDIV' + AND IDENT1_0 = '346' + GROUP BY 1 + ; + + -- Identification des statuts + DROP TABLE IF EXISTS temp.x_ref_statut + ; + + CREATE TABLE temp.x_ref_statut AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'LNGDES' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHODES' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'ATABDIV' + AND IDENT1_0 = '364' + GROUP BY 1 + ; + + -- Identification des types de temps de travail + DROP TABLE IF EXISTS temp.x_ref_type_temps_travail + ; + + CREATE TABLE temp.x_ref_type_temps_travail AS + SELECT + CASE WHEN round(HRSMTH_0/151.67,2) = 1 THEN 'TC' ELSE 'TP'||lpad((round(HRSMTH_0/151.67, 2) * 100)::int, 2, '0') END AS code_original, + MAX(CASE WHEN round(HRSMTH_0/151.67,2) = 1 THEN 'TC' ELSE 'TP'||lpad((round(HRSMTH_0/151.67, 2) * 100)::int, 2, '0') END) AS code, + MAX(CASE WHEN round(HRSMTH_0/151.67,2) = 1 THEN 'Temps Complet' ELSE 'Temps Partiel '||lpad((round(HRSMTH_0/151.67, 2) * 100)::int, 2, '0')||' %' END) AS texte, + MAX(CASE WHEN round(HRSMTH_0/151.67,2) = 1 THEN 'TC' ELSE 'TP' END) AS texte_court + FROM prod_sagex3rhp.EMPLOCTR + GROUP BY 1 + ; + + -- Identification des services + DROP TABLE IF EXISTS temp.x_ref_service + ; + + CREATE TABLE temp.x_ref_service AS + SELECT + COD_0 AS code_original, + MAX(COD_0) AS code, + MAX(DES_0) AS texte, + MAX(DESSHO_0) AS texte_court + FROM prod_sagex3rhp.SERVICE + GROUP BY 1 + ; + + -- Identification des spécialités + DROP TABLE IF EXISTS temp.x_ref_specialite + ; + + CREATE TABLE temp.x_ref_specialite AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'LNGDES' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHODES' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'ATABDIV' + AND IDENT1_0 = '392' + GROUP BY 1 + ; + + -- Identification des codes emploi + DROP TABLE IF EXISTS temp.x_ref_code_emploi + ; + + CREATE TABLE temp.x_ref_code_emploi AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'LNGDES' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHODES' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'ATABDIV' + AND IDENT1_0 = '357' + GROUP BY 1 + ; + + -- Identification des types d'horaire + DROP TABLE IF EXISTS temp.x_ref_type_horaire + ; + + CREATE TABLE temp.x_ref_type_horaire AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'LNGDES' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHODES' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'ATABDIV' + AND IDENT1_0 = '6004' + GROUP BY 1 + ; + + -- Identification des grilles + DROP TABLE IF EXISTS temp.x_ref_grille + ; + + CREATE TABLE temp.x_ref_grille AS + select + null::text AS code_original, + null::text AS code, + null::text AS texte, + null::text AS texte_court + limit 0 + ; + + -- Identification des groupes de grilles + + -- Identification des motifs d'arret + DROP TABLE IF EXISTS temp.x_ref_motif_arret + ; + + CREATE TABLE temp.x_ref_motif_arret AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'LNGDES' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHODES' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'ATABDIV' + AND IDENT1_0 = '396' + GROUP BY 1 + ; + + -- Identification des précisions du motif d'arrêt + + -- Identification des motifs de visite médicale + DROP TABLE IF EXISTS temp.x_ref_motif_visite + ; + + CREATE TABLE temp.x_ref_motif_visite AS + SELECT + IDENT2_0 AS code_original, + MAX(IDENT2_0) AS code, + MAX(CASE WHEN ZONE_0 = 'LNGDES' THEN TEXTE_0 ELSE '' END) AS texte, + MAX(CASE WHEN ZONE_0 = 'SHODES' THEN TEXTE_0 ELSE '' END) AS texte_court + FROM prod_sagex3rhp.ATEXTRA + WHERE 1=1 + AND LANGUE_0 = 'FRA' + AND CODFIC_0 = 'ATABDIV' + AND IDENT1_0 = '395' + GROUP BY 1 + ; + + -- Identification des circonstances d'accident du travail + + -- Identification des lieux d'accident du travail + + -- Identification de la nature de l'accident du travail + + -- Identification des sièges d'accident du travail + + -- Identification des listes de formations + DROP TABLE IF EXISTS temp.x_ref_liste_formation + ; + + CREATE TABLE temp.x_ref_liste_formation AS + SELECT + COD_0 AS code_original, + MAX(COD_0) AS code, + MAX(DES_0) AS texte, + NULL::text AS texte_court + FROM prod_sagex3rhp.STAGE + GROUP BY 1 + ; + + -- Identification des sections analytiques + DROP TABLE IF EXISTS temp.x_ref_section_analytique + ; + + CREATE TABLE temp.x_ref_section_analytique AS + SELECT + CCE_0 AS code_original, + MAX(CCE_0) AS code, + MAX(DES_0) AS texte, + MAX(DESSHO_0) AS texte_court + FROM prod_sagex3rhp.CACCE + GROUP BY 1 + ; + + -- Identification des rubriques de paie. + DROP TABLE IF EXISTS w_RUBRIQUE; + CREATE TEMP TABLE w_RUBRIQUE AS + SELECT + COD_0, + MAX(RUBRIQUE.ROW_0) AS ROW_0, + MAX(DES_0) AS DES_0, + MAX(DES_0) AS DESSHO_0, + MAX(AMTPRN_0) AS AMTPRN_0, + MAX(ARRAY[CUM_0,CUM_1,CUM_2,CUM_3,CUM_4,CUM_5,CUM_6,CUM_7,CUM_8,CUM_9]) AS CUM_x, + MAX(CASE WHEN HISTOPAYE.TYP_0 = 1 THEN '1' WHEN HISTOPAYE.TYP_0 = 7 THEN '1' ELSE '0' END) AS TYP_1, + MAX(CASE WHEN HISTOPAYE.TYP_0 = 2 THEN '1' ELSE '0' END) AS TYP_2, + MAX( + CASE RUB_0 + WHEN 'HRES_EFF' THEN '2' + WHEN 'HRES_PAY' THEN '2' + WHEN 'HRES_SAL' THEN '2' + WHEN 'NET_IMPOS' THEN '1' + WHEN 'NET_PAYER' THEN '1' + WHEN 'CHARGES' THEN '1' + WHEN 'RETENUES' THEN '1' + WHEN 'BRUT' THEN '1' + ELSE '0' END::text + ) AS is_total + + FROM prod_sagex3rhp.HISTOPAYE + JOIN prod_sagex3rhp.RUBRIQUE ON HISTOPAYE.RUB_0 = RUBRIQUE.COD_0 + WHERE (HISTOPAYE.TYP_0 IN (1,2,7) AND AMTPRN_0 BETWEEN 1 AND 5) OR + RUB_0 IN ('HRES_EFF','HRES_PAY','HRES_SAL','BRUT','CHARGES','RETENUES') + GROUP BY 1 + ; + + DROP TABLE IF EXISTS temp.x_ref_rubrique + ; + + CREATE TABLE temp.x_ref_rubrique AS + SELECT + COD_0::text AS code_original, + to_char(ROW_0,'FM9900000') AS code, + DES_0 AS texte, + DESSHO_0 AS texte_court, + ROW_0::int AS rang_edition, + is_total IN ('1','2') AS p_cumul, + is_total IN ('0','2') AS p_detail, + false AS p_nombre, + 0 AS s_nombre, + 1 AS c_nombre, + true AS p_base, + 1 AS s_base, + 1 AS c_base, + + COD_0 = 'HRES_SAL' AS p_heures_contrat, + 1 AS s_heures_contrat, + 1 AS c_heures_contrat, + + COD_0 = 'HRES_PAY' AS p_heures_payees, + 1 AS s_heures_payees, + 1 AS c_heures_payees, + + COD_0 = 'HRES_EFF' AS p_heures_travaillees, + 1 AS s_heures_travaillees, + 1 AS c_heures_travaillees, + + COD_0 = 'BRUT' OR COD_0 = 'CHARGES' OR (AMTPRN_0 BETWEEN 2 AND 5 AND ('TOTBRUT' = ANY(CUM_x) OR 'TOTCHARGE' = ANY(CUM_x))) AS p_masse_salariale, + CASE + WHEN COD_0 = 'BRUT' THEN 3 + WHEN AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTBRUT' = ANY(CUM_x) THEN 3 + WHEN COD_0 = 'CHARGES' THEN 5 + WHEN AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTCHARGE' = ANY(CUM_x) THEN 5 + ELSE NULL END + AS s_masse_salariale, + CASE WHEN 'TOTBRUT' = ANY(CUM_x) AND AMTPRN_0 IN (3,5) THEN -1 ELSE 1 END AS c_masse_salariale, + + COD_0 = 'BRUT' OR (AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTBRUT' = ANY(CUM_x)) AS p_brut, + 3 AS s_brut, + CASE WHEN AMTPRN_0 IN (3,5) THEN -1 ELSE 1 END AS c_brut, + + false AS p_avantage_nature, + 3 AS s_avantage_nature, + 1 AS c_avantage_nature, + + false AS p_frais_imposables, + 3 AS s_frais_imposables, + 1 AS c_frais_imposables, + + COD_0 = 'RETENUES' OR (AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTRETENU' = ANY(CUM_x) AND TYP_1 = '1') AS p_cotisation_salarie, + 3 AS s_cotisation_salarie, + 1 AS c_cotisation_salarie, + + COD_0 = 'CHARGES' OR (AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTCHARGE' = ANY(CUM_x) AND TYP_2 = '1') AS p_cotisation_patronale, + 5 AS s_cotisation_patronale, + 1 AS c_cotisation_patronale, + + false AS p_od_net_salarie, + 3 AS s_od_net_salarie, + 1 AS c_od_net_salarie, + + AMTPRN_0 BETWEEN 2 AND 5 AND ('TOTNAP' = ANY(CUM_x) AND TYP_2 = '1') AS p_od_net_patronale, + 5 AS s_od_net_patronale, + 1 AS c_od_net_patronale, + + COD_0 = 'NET_IMPOS' OR + (AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTBRUT' = ANY(CUM_x)) OR + (AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTRETENU' = ANY(CUM_x) AND TYP_1 = '1') AS p_net_imposable, + 3 AS s_net_imposable, + CASE + WHEN 'TOTBRUT' = ANY(CUM_x) AND AMTPRN_0 IN (3,5) THEN -1 + WHEN 'TOTBRUT' = ANY(CUM_x) AND AMTPRN_0 NOT IN (3,5) THEN 1 + WHEN 'TOTRETENU' = ANY(CUM_x) AND TYP_1 = '1' AND AMTPRN_0 BETWEEN 2 AND 5 THEN -1 + ELSE 1 END AS c_net_imposable, + + COD_0 = 'NET_PAYER' OR + (AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTBRUT' = ANY(CUM_x)) OR + (AMTPRN_0 BETWEEN 2 AND 5 AND 'TOTRETENU' = ANY(CUM_x) AND TYP_1 = '1') AS p_net_a_payer, + 3 AS s_net_a_payer, + CASE + WHEN 'TOTBRUT' = ANY(CUM_x) AND AMTPRN_0 IN (3,5) THEN -1 + WHEN 'TOTBRUT' = ANY(CUM_x) AND AMTPRN_0 NOT IN (3,5) THEN 1 + WHEN 'TOTRETENU' = ANY(CUM_x) AND TYP_1 = '1' AND AMTPRN_0 BETWEEN 2 AND 5 THEN -1 + ELSE 1 END AS c_net_a_payer + + FROM w_RUBRIQUE + ; + + WITH rub_cum_0 AS ( + SELECT 'C000' AS code, 'Ecart cumulé' AS texte + UNION ALL + SELECT 'C001' AS code, 'Heures payées' AS texte + UNION ALL + SELECT 'C002' AS code, 'Heures travaillées' AS texte + UNION ALL + SELECT 'C003' AS code, 'Net à payer' AS texte + UNION ALL + SELECT 'C004' AS code, 'Net imposable' AS texte + UNION ALL + SELECT 'C005' AS code, 'Avantage en nature' AS texte + UNION ALL + SELECT 'C006' AS code, 'Cotisations patronales' AS texte + UNION ALL + SELECT 'C007' AS code, 'Cotisations salariales' AS texte + UNION ALL + SELECT 'C008' AS code, 'Brut' AS texte + UNION ALL + SELECT 'C009' AS code, 'Heures Cadres Forfaits Jours' AS texte + ) + INSERT INTO temp.x_ref_rubrique + SELECT + code AS code_original, + code AS code, + texte AS texte, + null::text AS texte_court, + -1 AS rang_edition, + true AS p_cumul, + false AS p_detail, + false AS p_nombre, + 0 AS s_nombre, + 1 AS c_nombre, + false AS p_base, + 1 AS s_base, + 1 AS c_base, + false AS p_heures_contrat, + 0 AS s_heures_contrat, + 1 AS c_heures_contrat, + false AS p_heures_payees, + 0 AS s_heures_payees, + 1 AS c_heures_payees, + false AS p_heures_travaillees, + 0 AS s_heures_travaillees, + 1 AS c_heures_travaillees, + false AS p_masse_salariale, + 3 AS s_masse_salariale, + -1 AS c_masse_salariale, + false AS p_brut, + 3 AS s_brut, + 1 AS c_brut, + false AS p_avantage_nature, + 3 AS s_avantage_nature, + 1 AS c_avantage_nature, + false AS p_frais_imposables, + 3 AS s_frais_imposables, + 1 AS c_frais_imposables, + false AS p_cotisation_salarie, + 3 AS s_cotisation_salarie, + 1 AS c_cotisation_salarie, + false AS p_cotisation_patronale, + 5 AS s_cotisation_patronale, + -1 AS c_cotisation_patronale, + false AS p_od_net_salarie, + 3 AS s_od_net_salarie, + 1 AS c_od_net_salarie, + false AS p_od_net_patronale, + 5 AS s_od_net_patronale, + 1 AS c_od_net_patronale, + false AS p_net_imposable, + 3 AS s_net_imposable, + 1 AS c_net_imposable, + false AS p_net_a_payer, + 3 AS s_net_a_payer, + 1 AS c_net_a_payer + FROM rub_cum_0 + ; + + DROP TABLE IF EXISTS w_rub_cpt; + CREATE TEMP TABLE w_rub_cpt AS + SELECT COD_0, (MAX(ARRAY[to_char(LIG_0,'FM000000000'),ACC_0]))[2] AS cpt_code_original + FROM prod_sagex3rhp.RUBGAC + WHERE COA_0 = 'FRA' AND + (ACC_0 LIKE '6%' OR ACC_0 LIKE '7%') AND + ACC_0 <> '' + GROUP BY 1 + ORDER BY 1 + ; + + INSERT INTO w_rub_cpt + SELECT w_RUBRIQUE.COD_0, w_rub_cpt_cum.cpt_code_original + FROM w_RUBRIQUE + JOIN w_rub_cpt w_rub_cpt_cum ON w_rub_cpt_cum.COD_0 = 'BRUT' + LEFT JOIN w_rub_cpt ON w_rub_cpt.COD_0 = w_RUBRIQUE.COD_0 + WHERE 'TOTBRUT' = ANY(CUM_x) AND + w_rub_cpt IS NULL AND + w_rub_cpt_cum.cpt_code_original <> '' + ; + + INSERT INTO w_rub_cpt + SELECT w_RUBRIQUE.COD_0, w_rub_cpt_cum.cpt_code_original + FROM w_RUBRIQUE + JOIN w_rub_cpt w_rub_cpt_cum ON w_rub_cpt_cum.COD_0 = 'CHARGES' + LEFT JOIN w_rub_cpt ON w_rub_cpt.COD_0 = w_RUBRIQUE.COD_0 + WHERE 'TOTCHARGE' = ANY(CUM_x) AND + w_rub_cpt IS NULL AND + w_rub_cpt_cum.cpt_code_original <> '' + ; + + INSERT INTO w_rub_cpt + SELECT w_RUBRIQUE.COD_0, w_rub_cpt_cum.cpt_code_original + FROM w_RUBRIQUE + JOIN w_rub_cpt w_rub_cpt_cum ON w_rub_cpt_cum.COD_0 = 'RETENUES' + LEFT JOIN w_rub_cpt ON w_rub_cpt.COD_0 = w_RUBRIQUE.COD_0 + WHERE 'TOTRETENU' = ANY(CUM_x) AND + w_rub_cpt IS NULL AND + w_rub_cpt_cum.cpt_code_original <> '' + ; + + ANALYSE w_rub_cpt + ; + + + ]]> + + + = date_demarrage + GROUP BY 1 + ; + + ANALYSE w_HISTOPAYE_CTRNUM + ; + + + -- Création d'une table des contrats filtrés sur la bonne entreprise. + DROP TABLE IF EXISTS w_cnt + ; + + CREATE TEMP TABLE w_cnt AS + SELECT + 0::numeric AS rang, + null::text AS numero_contrat, + CTRNUM_0, + NUMLIG_0, + REFNUM_0||CTRNUM_0||'-'||numlig_0 AS cnt, + LEGCPY_0 || '-' || REFNUM_0||CTRNUM_0||'-'||numlig_0 AS contrat_code_original, + LEGCPY_0 AS entreprise_code_original, + ETRFCY_0 AS etablissement_code, + LEGCPY_0 || '-' || ETRFCY_0 AS etablissement_code_original, + REFNUM_0 AS mat, + REFNUM_0, + CTRDAT_0::date AS date_debut_contrat, + CASE WHEN XITDAT_0::date = '1753-01-01'::date THEN '2099-12-31'::date ELSE XITDAT_0::date END AS date_fin_contrat, + 0 AS duree, + to_char(CTRDAT_0, 'YYYYMM')::int AS mois_debut, + CTRGRD_0 AS motif_debut_code_original, + XITGRD_0 AS motif_fin_code_original, + MATREMP_0 AS mat_remplace, + NATCON_0 AS type_contrat_code_original, + LEGCPY_0 || '-' || REFNUM_0 AS salarie_code_original, + LEGCPY_0 || '-' || matrEMP_0 AS salarie_rmp_code_original, + hrs_0, -- Permettra surement de calculer le taux d'absentéisme. + hrswek_0, + HRSMTH_0, + CASE + WHEN round(HRSMTH_0/151.67,2) = 1 THEN 'TC' + ELSE 'TP'||lpad((round(HRSMTH_0/151.67, 2) * 100)::int, 2, '0') + END AS type_temps_travail_code_original, + modtps_0, + cddgrd_0 AS motif_remplacement_code_original, -- motif de remplacement (prod_sagex3rhp.ATEXTRA avec IDENT1_0 = 356) + ETRSRV_0 AS service_code_original, + qlf_0, -- mal renseigné. + catfrt_0, + CTRCODSEE_0 AS categorie_socio_professionnelle_code_original, -- CSP + JOB_0 AS qualification_code_original, + CATCSP_0, -- qualification code pour CMC (texte pris dans une autre table) + substr(md5(job_0), 1, 5) AS job_cod_0, -- qualification code pour MOUGIN + job_0 AS qualif_texte, -- qualification texte pour MOUGIN + ''::text AS qualif_code, + STACAT_0 AS statut_code_original, + CATJOB_0 AS code_emploi_code_original, + '' AS grille_groupe_y, -- mode grille y. + '' AS grille_groupe_x, -- ON ne prend pas l'échelon. + ''::text AS grille_groupe, + '' AS grille_y, + '' AS grille_x, + ''::text AS grille, + MAX(datlib_0) OVER (PARTITION BY REFNUM_0) AS datlib_0, + MAX(datanc_0) OVER (PARTITION BY REFNUM_0) AS datanc_0, + null::boolean AS acc_anc, -- accumuler ou non de l'ancienneté (1 ou 0). + pot_0, -- Ne pas utiliser + '' AS type_horaire_ori + FROM prod_sagex3rhp.EMPLOCTR + JOIN w_periode ON 1=1 + JOIN prod_sagex3rhp.FACILITY ON FACILITY.fcy_0 = EMPLOCTR.ETRFCY_0 + JOIN prod_sagex3rhp.COMPANY ON FACILITY.LEGCPY_0 = COMPANY.CPY_0 + WHERE 1=1 + AND COMPANY.CRN_0 IN (SELECT substr(rhp_in('siren'), 1, 9)) + AND ( + XITDAT_0::date = '1753-01-01' OR + XITDAT_0 >= date_demarrage OR + CTRNUM_0 IN (SELECT CTRNUM_0_paye FROM w_HISTOPAYE_CTRNUM) + ) + order by REFNUM_0, CTRDAT_0 + ; + + ANALYSE w_cnt + ; + + -- Mise à jour de la durée des contrats. + UPDATE w_cnt + SET duree = (CASE WHEN date_fin_contrat = '2099-12-31'::date THEN current_date ELSE date_fin_contrat END) - date_debut_contrat + 1 + ; + + -- Détermination du mode de grille. + DROP TABLE IF EXISTS w_gri + ; + + CREATE TEMP TABLE w_gri AS + SELECT count(distinct grille_groupe_y) < count(distinct grille_groupe_x) AS x_mode + FROM w_cnt + ; + + UPDATE w_cnt + SET grille_groupe = (CASE WHEN x_mode THEN grille_groupe_x ELSE grille_groupe_y END), + grille = (CASE WHEN x_mode THEN grille_x ELSE grille_y END), + acc_anc = date_fin_contrat > (CASE WHEN x_mode THEN datanc_0 ELSE datlib_0 END), -- ON cumule de l'ancienneté uniquement lorsque le contrat dépasse la date d'ancienneté. + qualif_code = (CASE WHEN x_mode THEN job_cod_0 ELSE catcsp_0 END) + FROM w_gri + ; + + DROP SEQUENCE IF EXISTS s_cnt; + CREATE TEMP SEQUENCE s_cnt START 1 + ; + + UPDATE w_cnt + SET rang = nextval('s_cnt') + ; + + -- #correction Attention, les contrats sont à aggréger. + -- Identification des ruptures de contrat. + update w_cnt + set numero_contrat = subq.numero_contrat + FROM ( + select + CASE WHEN t2.motif_fin_code_original = t1.motif_debut_code_original AND (t2.date_fin_contrat + '1 day'::interval)::date = t1.date_debut_contrat THEN null ELSE t1.cnt END AS numero_contrat, + t1.cnt, + t1.mat + FROM w_cnt AS t1 + left join w_cnt AS t2 ON 1=1 + AND t2.mat = t1.mat + AND t2.rang + 1 = t1.rang) AS subq + WHERE 1=1 + AND w_cnt.mat = subq.mat + AND w_cnt.cnt = subq.cnt + AND w_cnt.numero_contrat is distinct FROM subq.numero_contrat + ; + + -- #correction Attention, les contrats sont à aggréger. + -- Etalement des ruptures sur les contrats correspondant à l'évolution de carrière d'un salarié. + update w_cnt + set numero_contrat = subq.numero_contrat + FROM ( + select + t1.cnt, + t1.mat, + (MAX(ARRAY[lpad(t2.rang, 4, '0'), t2.numero_contrat]))[2] AS numero_contrat + FROM w_cnt AS t1 + left join w_cnt AS t2 ON 1=1 + AND t2.mat = t1.mat + AND t2.rang < t1.rang + WHERE 1=1 + AND t1.numero_contrat is null + AND t2.numero_contrat is not null + GROUP BY 1,2 + ) AS subq + WHERE 1=1 + AND w_cnt.mat = subq.mat + AND w_cnt.cnt = subq.cnt + AND w_cnt.numero_contrat is distinct FROM subq.numero_contrat + ; + + -- Association contrat au bulletin (on se débrouille !!!) + DROP TABLE IF EXISTS w_EMPLOCTR; + CREATE TEMP TABLE w_EMPLOCTR AS + SELECT CTRNUM_0, + CASE WHEN count(*) = 1 THEN MAX(LEGCPY_0 || '-' || REFNUM_0||CTRNUM_0||'-'||NUMLIG_0) ELSE NULL END AS contrat_code_original + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + JOIN prod_sagex3rhp.COMPANY ON FACILITY.LEGCPY_0 = COMPANY.CPY_0 + WHERE 1=1 + AND COMPANY.CRN_0 IN (SELECT substr(rhp_in('siren'), 1, 9)) + GROUP BY 1 + ; + + ANALYSE w_EMPLOCTR + ; + + DROP TABLE IF EXISTS w_EMPLOCTR_mois; + CREATE TEMP TABLE w_EMPLOCTR_mois AS + SELECT CTRNUM_0, + p_calendrier_mois.date_debut AS date_debut_mois, + CASE WHEN count(*) = 1 THEN MAX(LEGCPY_0 || '-' || REFNUM_0||CTRNUM_0||'-'||NUMLIG_0) ELSE NULL END AS contrat_code_original + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + JOIN prod_sagex3rhp.COMPANY ON FACILITY.LEGCPY_0 = COMPANY.CPY_0 + JOIN base.p_calendrier_mois ON + p_calendrier_mois.date_debut <= now() AND + date(CTRDAT_0) <= p_calendrier_mois.date_fin AND + ( + date(XITDAT_0) >= p_calendrier_mois.date_debut OR + date(XITDAT_0) < '19000101' + ) + WHERE 1=1 + AND COMPANY.CRN_0 IN (SELECT substr(rhp_in('siren'), 1, 9)) + GROUP BY 1,2 + HAVING count(*) = 1 + ; + + ANALYSE w_EMPLOCTR_mois + ; + + DROP TABLE IF EXISTS w_HRDSNDMT; + CREATE TEMP TABLE w_HRDSNDMT AS + SELECT BUL_0, MAX(CTRNUM_0) AS CTRNUM_0, MAX(STRDAT_0) AS STRDAT_0, MAX(CTRDAT_0) AS CTRDAT_0, NULL::text AS contrat_code_original + FROM prod_sagex3rhp.HRDSNDMC + JOIN prod_sagex3rhp.HRDSNDMT ON HRDSNDMC.DSNCTRUID_0 = HRDSNDMT.DSNCTRUID_0 + GROUP BY 1 + ; + + UPDATE w_HRDSNDMT SET + contrat_code_original = LEGCPY_0 || '-' || REFNUM_0||EMPLOCTR.CTRNUM_0||'-'||NUMLIG_0 + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + WHERE EMPLOCTR.CTRNUM_0 = w_HRDSNDMT.CTRNUM_0 AND + EMPLOCTR.CTRDAT_0 = w_HRDSNDMT.CTRDAT_0 + ; + + UPDATE w_HRDSNDMT SET + contrat_code_original = LEGCPY_0 || '-' || REFNUM_0||EMPLOCTR.CTRNUM_0||'-'||NUMLIG_0 + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + WHERE EMPLOCTR.CTRNUM_0 = w_HRDSNDMT.CTRNUM_0 AND + contrat_code_original IS NULL AND + EMPLOCTR.CTRDAT_0 = w_HRDSNDMT.STRDAT_0 + ; + + UPDATE w_HRDSNDMT SET + contrat_code_original = LEGCPY_0 || '-' || REFNUM_0||EMPLOCTR.CTRNUM_0||'-'||NUMLIG_0 + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + WHERE EMPLOCTR.CTRNUM_0 = w_HRDSNDMT.CTRNUM_0 AND + contrat_code_original IS NULL AND + date_trunc('month',EMPLOCTR.CTRDAT_0) = date_trunc('month',w_HRDSNDMT.CTRDAT_0) + ; + + UPDATE w_HRDSNDMT SET + contrat_code_original = LEGCPY_0 || '-' || REFNUM_0||EMPLOCTR.CTRNUM_0||'-'||NUMLIG_0 + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + WHERE EMPLOCTR.CTRNUM_0 = w_HRDSNDMT.CTRNUM_0 AND + contrat_code_original IS NULL AND + date_trunc('month',EMPLOCTR.CTRDAT_0) = date_trunc('month',w_HRDSNDMT.STRDAT_0) + ; + + UPDATE w_HRDSNDMT SET + contrat_code_original = LEGCPY_0 || '-' || REFNUM_0||EMPLOCTR.CTRNUM_0||'-'||NUMLIG_0 + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + WHERE EMPLOCTR.CTRNUM_0 = w_HRDSNDMT.CTRNUM_0 AND + contrat_code_original IS NULL AND + w_HRDSNDMT.STRDAT_0 BETWEEN EMPLOCTR.CTRDAT_0 AND EMPLOCTR.XITDAT_0 + ; + + UPDATE w_HRDSNDMT SET + contrat_code_original = LEGCPY_0 || '-' || REFNUM_0||EMPLOCTR.CTRNUM_0||'-'||NUMLIG_0 + FROM prod_sagex3rhp.EMPLOCTR + JOIN prod_sagex3rhp.FACILITY ON FACILITY.FCY_0 = EMPLOCTR.ETRFCY_0 + WHERE EMPLOCTR.CTRNUM_0 = w_HRDSNDMT.CTRNUM_0 AND + contrat_code_original IS NULL AND + w_HRDSNDMT.STRDAT_0 >= EMPLOCTR.CTRDAT_0 AND EMPLOCTR.XITDAT_0 < '19000101' + ; + + + DROP TABLE IF EXISTS w_bulletin_contrat; + CREATE TEMP TABLE w_bulletin_contrat AS + SELECT BUL_0, + EMP_0, + CTRNUM_0, + DAT_0, + row_number() OVER(PARTITION BY EMP_0, CTRNUM_0, DAT_0 ORDER BY BUL_0) AS seq, + contrat_code_original + FROM + ( + SELECT HISTOPAYE.BUL_0, + MAX(HISTOPAYE.EMP_0) AS EMP_0, + MAX(HISTOPAYE.CTRNUM_0) AS CTRNUM_0, + date(MAX(date_trunc('month',HISTOPAYE.DAT_0))) AS DAT_0, + MAX(COALESCE(w_EMPLOCTR_mois.contrat_code_original,w_EMPLOCTR.contrat_code_original,w_HRDSNDMT.contrat_code_original)) AS contrat_code_original + FROM prod_sagex3rhp.HISTOPAYE + JOIN w_EMPLOCTR ON HISTOPAYE.CTRNUM_0 = w_EMPLOCTR.CTRNUM_0 + LEFT JOIN w_EMPLOCTR_mois ON + HISTOPAYE.CTRNUM_0 = w_EMPLOCTR_mois.CTRNUM_0 AND + date(date_trunc('month',HISTOPAYE.DAT_0)) = date_debut_mois + LEFT JOIN w_HRDSNDMT ON + HISTOPAYE.BUL_0 = w_HRDSNDMT.BUL_0 + GROUP BY 1 + ) subview + ; + + ANALYSE w_bulletin_contrat + ; + + SELECT base.cti_execute( + 'UPDATE w_bulletin_contrat + SET contrat_code_original = subview.contrat_code_original_precedent + FROM + ( + SELECT BUL_0, + contrat_code_original, + LAG(contrat_code_original) OVER (PARTITION BY CTRNUM_0 ORDER BY DAT_0) AS contrat_code_original_precedent + FROM w_bulletin_contrat + ) subview + WHERE w_bulletin_contrat.BUL_0 = subview.BUL_0 AND + w_bulletin_contrat.contrat_code_original IS NULL AND + contrat_code_original_precedent IS NOT NULL + ',100) + ; + + SELECT base.cti_execute( + 'UPDATE w_bulletin_contrat + SET contrat_code_original = subview.contrat_code_original_suivant + FROM + ( + SELECT BUL_0, + contrat_code_original, + LEAD(contrat_code_original) OVER (PARTITION BY CTRNUM_0 ORDER BY DAT_0) AS contrat_code_original_suivant + FROM w_bulletin_contrat + ) subview + WHERE w_bulletin_contrat.BUL_0 = subview.BUL_0 AND + w_bulletin_contrat.contrat_code_original IS NULL AND + contrat_code_original_suivant IS NOT NULL + ',100) + + ; + + -- Création d'une table de la paie filtrée sur la bonne entreprise. + DROP TABLE IF EXISTS w_HISTOPAYE + ; + + CREATE TEMP TABLE w_HISTOPAYE AS + SELECT + HISTOPAYE.rowid, + MAX(HISTOPAYE.EMP_0) AS mat, + MAX(w_cnt.entreprise_code_original) AS entreprise_code_original, + MAX(w_cnt.etablissement_code) AS etablissement_code, + MAX(w_cnt.etablissement_code_original) AS etablissement_code_original, + MAX(w_cnt.salarie_code_original) AS salarie_code_original, + MAX(w_cnt.contrat_code_original) AS contrat_code_original, + MAX(HISTOPAYE.BUL_0) AS bulletin_code_original, + MAX(HISTOPAYE.DAT_0::date) AS date_paie, + MAX(HISTOPAYE.DAT_0::date) AS date_ligne, + MAX(HISTOPAYE.BUL_0) AS BUL_0, + MAX(HISTOPAYE.EMP_0) AS EMP_0, + MAX(HISTOPAYE.DAT_0) AS DAT_0, + MAX(HISTOPAYE.ROW_0::bigint) AS ROW_0, + MAX(HISTOPAYE.RUB_0) AS RUB_0, + MAX(HISTOPAYE.TYP_0) AS TYP_0, + MAX(HISTOPAYE.BAS_0) AS BAS_0, + MAX(HISTOPAYE.RAT_0) AS RAT_0, + MAX(HISTOPAYE.AMT_0) AS AMT_0, + COALESCE(MAX(CASE WHEN HISTOPAYE.RUB_0 <> 'CHARGES' AND HISTOPAYE.TYP_0 IN (1,7) THEN RAT_0 ELSE NULL END),0) AS RAT_0_1, + COALESCE(MAX(CASE WHEN HISTOPAYE.RUB_0 <> 'CHARGES' AND HISTOPAYE.TYP_0 IN (1,7) THEN AMT_0 ELSE NULL END),0) AS AMT_0_1, + COALESCE(MAX(CASE WHEN HISTOPAYE.RUB_0 = 'CHARGES' OR HISTOPAYE.TYP_0 IN (2,8) THEN RAT_0 ELSE NULL END),0) AS RAT_0_2, + COALESCE(MAX(CASE WHEN HISTOPAYE.RUB_0 = 'CHARGES' OR HISTOPAYE.TYP_0 IN (2,8) THEN AMT_0 ELSE NULL END),0) AS AMT_0_2, + MAX(HISTOPAYE.CTRNUM_0) AS CTRNUM_0AMTPRN_0, + MAX(AMTPRN_0) AS AMTPRN_0 + + FROM prod_sagex3rhp.HISTOPAYE + JOIN w_bulletin_contrat ON HISTOPAYE.BUL_0 = w_bulletin_contrat.BUL_0 + JOIN prod_sagex3rhp.RUBRIQUE ON RUB_0 = RUBRIQUE.COD_0 + JOIN w_cnt ON w_bulletin_contrat.contrat_code_original = w_cnt.contrat_code_original + JOIN w_periode ON 1=1 + WHERE 1=1 + AND (1!=1 + OR HISTOPAYE.BAS_0 != 0 + OR HISTOPAYE.RAT_0 != 0 + OR HISTOPAYE.AMT_0 != 0) + AND HISTOPAYE.DAT_0 >= date_demarrage + GROUP BY 1 + ; + + -- #correction des dates de ligne de bulletin : des fois, dates différentes pour un même bulletin. + UPDATE w_HISTOPAYE + SET date_paie = subq.DAT_0, + DAT_0 = subq.DAT_0 + FROM ( + SELECT + BUL_0, + DAT_0 + FROM w_HISTOPAYE + WHERE RUB_0 = 'BRUT') AS subq + WHERE 1=1 + AND w_HISTOPAYE.BUL_0 = subq.BUL_0 + AND w_HISTOPAYE.DAT_0 != subq.DAT_0 + ; + + + + -- Création d'une table par bulletin avec date de début/fin. + DROP TABLE IF EXISTS w_bul + ; + + CREATE TEMP TABLE w_bul AS + SELECT + BUL_0, + MAX(bulletin_code_original) AS bulletin_code_original, + MAX(mat) AS mat, + MAX(entreprise_code_original) AS entreprise_code_original, + MAX(etablissement_code) AS etablissement_code, + MAX(etablissement_code_original) AS etablissement_code_original, + MAX(salarie_code_original) AS salarie_code_original, + MAX(contrat_code_original) AS contrat_code_original, + MAX(date_paie) AS date_paie, + MAX(date_ligne) AS date_fin_bulletin, + date(date_trunc('month',MIN(date_ligne))) AS date_debut_bulletin, + MAX(to_char(date_paie, 'YYYYMM')::int) AS mois_paie, + (MAX(to_char(date_paie, 'YYYYMM')) || + lpad((sum(CASE WHEN RUB_0 = 'NBJC_SALE' THEN @BAS_0 ELSE 0 END) + 1)::int, 2, '0'))::date AS date_paie_debut, -- reconstitution à partir d'une rubrique de la date de début de contrat associé au bulletin. Surprenant !!! + null::date AS date_paie_fin, + null::text AS cnt, + MAX(CASE WHEN RUB_0 = 'COEF_BULL' THEN @BAS_0 ELSE 0 END)::int::text AS coeff -- utile lorsque le coefficient du contrat n'est pas fiable (x_mode à true). + FROM w_HISTOPAYE + GROUP BY 1 + ; + + + -- #correction de la date de début de paie lorsqu'elle est postérieure à la date de paie + UPDATE w_bul + SET date_paie_debut = date_paie + WHERE date_paie < date_paie_debut + ; + + -- Mise à jour de la date de fin et du contrat associé aux bulletins. + UPDATE w_bul + SET + date_paie_fin = least(w_cnt.date_fin_contrat, (date_trunc('MONTH', w_bul.date_paie_debut) + '1 month - 1 day'::interval)::date), + cnt = w_cnt.cnt + FROM w_cnt + WHERE 1=1 + AND w_cnt.mat = w_bul.mat + AND w_cnt.date_debut_contrat = w_bul.date_paie_debut + ; + + -- Mise à jour de la date de fin et du contrat associé aux bulletins (pour les contrats couvrants plusieurs mois). + UPDATE w_bul + SET + date_paie_fin = least(w_cnt.date_fin_contrat, (date_trunc('MONTH', w_bul.date_paie_debut) + '1 month - 1 day'::interval)::date), + cnt = w_cnt.cnt + FROM w_cnt + WHERE 1=1 + AND w_cnt.mat = w_bul.mat + AND w_bul.date_paie_debut between w_cnt.date_debut_contrat AND w_cnt.date_fin_contrat + AND w_bul.date_paie_fin IS NULL + ; + + -- Association des bulletins hors période de contrat (au contrat le plus en amont). + UPDATE w_bul + SET date_paie_fin = date_paie_debut, -- ON fait une paie d'un jour + cnt = subq.cnt + FROM ( + select + w_bul.mat, + BUL_0, + (MAX(ARRAY[w_cnt.date_fin_contrat::text, w_cnt.cnt]))[2] AS cnt + FROM w_bul + join w_cnt ON w_cnt.mat = w_bul.mat + WHERE 1=1 + AND w_cnt.date_fin_contrat < w_bul.date_paie_debut + AND w_bul.date_paie_fin IS NULL + GROUP BY 1, 2) AS subq + WHERE 1=1 + AND w_bul.mat = subq.mat + AND w_bul.BUL_0 = subq.BUL_0 + AND w_bul.date_paie_fin IS NULL + ; + + -- Correction des ventilations. + DROP TABLE IF EXISTS w_ven + ; + + CREATE TEMP TABLE w_ven AS + SELECT + EMP_0, + BUL_0, + cce_0, + cce_1, + sum(coe_0)::numeric AS coe_0 + FROM prod_sagex3rhp.valana + GROUP BY 1,2,3,4 + ; + + UPDATE w_ven + SET coe_0 = 100 + WHERE coe_0 = 0 + ; + + + + DROP TABLE IF EXISTS temp.x_ref_salarie + ; + + CREATE TABLE temp.x_ref_salarie AS + SELECT + EMPLOID.REFNUM_0 AS matricule, + EMPLOID.REFNUM_0 AS code, + entreprise_code_original || '-' || EMPLOID.REFNUM_0 AS code_original, + MAX(NUMSSC_0) AS nir, + MAX(entreprise_code_original) AS entreprise, + MAX(NAM_0) AS nom, + MAX(OLDNAM_0) AS nom_naissance, + MAX(SRN_0) AS prenom, + COALESCE(MAX(DATBRN_0)::date, '1962-04-18'::date) AS date_naissance, + MAX(CASE WHEN SEX_0 = 1 THEN 'M' ELSE 'F' END) AS sexe, + MAX(EMPLOID.NTT_0) AS nationalite, + MAX(EMPLOID.CODPOS_0) AS code_postal, + MAX(EMPLOID.SITFAM_0) AS situation_famille, + MAX(w_cnt.date_debut_contrat) AS date_debut, + MAX(w_cnt.date_fin_contrat) AS date_fin, + MIN(w_cnt.date_debut_contrat) AS date_entree_ets, + MAX(w_cnt.date_fin_contrat) AS date_sortie_ets, + MIN(w_cnt.date_debut_contrat) AS date_anciennete, + MAX(ADD1_0) AS adresse1, + MAX(ADD2_0) AS adresse2, + -- Champs dédiés au public. + null::date AS date_entree_fp, + null::date AS date_entree_fph, + 0 AS no_adeli, + 0 AS code_cotisation_id, + 0 AS matricule_retraite + FROM prod_sagex3rhp.emploid + JOIN w_cnt ON w_cnt.mat = emploid.REFNUM_0 + GROUP BY 1,2,3 + ; + + + DROP TABLE IF EXISTS temp.x_hst_contrat + ; + + CREATE TABLE temp.x_hst_contrat AS + SELECT + contrat_code_original AS cnt_code_original, + MAX(entreprise_code_original) AS ent_code_original, + MAX(etablissement_code) AS ets_code_original, + MAX(etablissement_code_original) AS ety_code_original, + MAX(salarie_code_original) AS sal_code_original, + MAX(w_cnt.numero_contrat) AS numero_contrat, + --cnt_uid, -- contrat universal id. + MIN(date_debut_contrat) AS date_debut, + MAX(date_fin_contrat) AS date_fin, + row_number() over () AS row_id + FROM w_cnt + GROUP BY 1 + ; + + + -- HISTORIQUE DES BULLETINS. + DROP TABLE IF EXISTS temp.x_hst_bulletin + ; + + CREATE TABLE temp.x_hst_bulletin AS + SELECT + entreprise_code_original AS ent_code_original, + etablissement_code AS ets_code_original, + etablissement_code_original AS ety_code_original, + salarie_code_original AS sal_code_original, + contrat_code_original AS cnt_code_original, + bulletin_code_original AS bul_code_original, + date_debut_bulletin AS date_debut, + date_fin_bulletin AS date_fin, + date_paie, + mois_paie, + row_number() over () AS row_id, + row_number() over (order by etablissement_code_original, salarie_code_original, bulletin_code_original) AS bul_id, + 0 AS est_hors_periode + FROM w_bul + ; + + DELETE FROM temp.x_hst_bulletin + WHERE cnt_code_original is null + ; + + UPDATE temp.x_hst_bulletin SET + est_hors_periode = '1' + FROM temp.x_hst_contrat + WHERE x_hst_bulletin.cnt_code_original = x_hst_contrat.cnt_code_original AND + x_hst_bulletin.date_debut > x_hst_contrat.date_fin + ; + + + + + + + -- ICI : Tous les bulletins doivent avoir un contrat de renseigné. + -- A remonter plus tard dans une table spéciale avant suppression pour controle expert. + DELETE FROM temp.x_hst_bulletin + WHERE cnt_code_original is null + ; + + -- La date min du premier contrat et/ou du premier bulletin détermine le début de la ventilation du salarié. + DROP TABLE IF EXISTS w_lim_sal + ; + + CREATE TEMP TABLE w_lim_sal AS + WITH toto AS ( + SELECT + sal_code_original, + min(date_debut) AS date_debut, + max(case when date_fin = '2099-12-31'::date then base.cti_last_day(current_date) else date_fin end) AS date_fin + FROM temp.x_hst_contrat + GROUP BY 1 + UNION ALL + SELECT + sal_code_original, + min(date_debut) AS date_debut, + max(case when date_fin = '2099-12-31'::date then base.cti_last_day(current_date) else date_fin end) AS date_fin + FROM temp.x_hst_bulletin + GROUP BY 1 + ) + SELECT + sal_code_original, + min(date_debut) AS date_debut, + to_char(min(date_debut), 'YYYYMM')::int AS mois_debut, + max(date_fin) AS date_fin, + to_char(max(date_fin), 'YYYYMM')::int AS mois_fin + FROM toto + GROUP BY 1 + ; + + + -- HISTORIQUE ETP Théorique contrat. + DROP TABLE IF EXISTS temp.x_hst_contrat_proprietes + ; + + CREATE TABLE temp.x_hst_contrat_proprietes AS + SELECT + w_cnt.etablissement_code_original AS ety_code_original, + w_cnt.salarie_code_original AS sal_code_original, + w_cnt.contrat_code_original AS cnt_code_original, + GREATEST(w_cnt.date_debut_contrat, w_lim_sal.date_debut) AS date_effet, + round(HRSMTH_0/151.67, 2) AS etp_contrat, + categorie_socio_professionnelle_code_original, + motif_debut_code_original, + motif_fin_code_original, + type_contrat_code_original, + qualification_code_original, + statut_code_original, + type_temps_travail_code_original, + service_code_original, + code_emploi_code_original + FROM w_cnt + JOIN w_lim_sal ON w_lim_sal.sal_code_original = w_cnt.salarie_code_original + ; + + ANALYSE temp.x_hst_contrat_proprietes + ; + + -- Suppression des proprietes pour des contrats dont la periode est comprise dans un autre contrat + DELETE FROM temp.x_hst_contrat_proprietes + WHERE cnt_code_original IN + ( + SELECT w_cnt.contrat_code_original + FROM w_cnt + JOIN w_cnt w_cnt2 ON + w_cnt.salarie_code_original = w_cnt2.salarie_code_original AND + w_cnt.date_debut_contrat >= w_cnt2.date_debut_contrat AND + w_cnt.date_fin_contrat < w_cnt2.date_fin_contrat AND + w_cnt.rang <> w_cnt2.rang + ) + ; + + DROP TABLE IF EXISTS temp.x_hst_etp_contrat + ; + + CREATE TABLE temp.x_hst_etp_contrat AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, etp_contrat + FROM temp.x_hst_contrat_proprietes + ; + + + DROP TABLE IF EXISTS temp.x_hst_categorie_socio_professionnelle + ; + + CREATE TABLE temp.x_hst_categorie_socio_professionnelle AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, categorie_socio_professionnelle_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_motif_debut_contrat + ; + + CREATE TABLE temp.x_hst_motif_debut_contrat AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, motif_debut_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_motif_fin_contrat + ; + + CREATE TABLE temp.x_hst_motif_fin_contrat AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, motif_fin_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_type_contrat + ; + + CREATE TABLE temp.x_hst_type_contrat AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, type_contrat_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_qualification + ; + + CREATE TABLE temp.x_hst_qualification AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, qualification_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_statut + ; + + CREATE TABLE temp.x_hst_statut AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, statut_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_type_temps_travail + ; + + CREATE TABLE temp.x_hst_type_temps_travail AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, type_temps_travail_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_service + ; + + CREATE TABLE temp.x_hst_service AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, service_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_code_emploi + ; + + CREATE TABLE temp.x_hst_code_emploi AS + SELECT ety_code_original, sal_code_original, cnt_code_original, date_effet, code_emploi_code_original + FROM temp.x_hst_contrat_proprietes + ; + + DROP TABLE IF EXISTS temp.x_hst_grille + ; + + CREATE TABLE temp.x_hst_grille AS + SELECT + null::text AS ety_code_original, + null::text AS sal_code_original, + null::text AS cnt_code_original, + null::date AS date_effet, + null::text AS grille_code_original + limit 0 + ; + + + ]]> + + + = mois_demarrage + AND w_HISTOPAYE.TYP_0 IN (1,2,7,8) + AND + ( + w_RUBRIQUE.AMTPRN_0 BETWEEN 2 AND 5 OR + 'TOTNAP' = ANY(CUM_x) OR + w_HISTOPAYE.RUB_0 = 'HRES_EFF' OR + w_HISTOPAYE.RUB_0 = 'HRES_PAY' OR + w_HISTOPAYE.RUB_0 = 'HRES_SAL' OR + w_HISTOPAYE.RUB_0 = 'NET_IMPOS' OR + w_HISTOPAYE.RUB_0 = 'NET_PAYER' OR + w_HISTOPAYE.RUB_0 = 'BRUT' OR + w_HISTOPAYE.RUB_0 = 'CHARGES' OR + w_HISTOPAYE.RUB_0 = 'RETENUES' OR + w_HISTOPAYE.RUB_0 = 'RETENUES' OR + w_HISTOPAYE.RUB_0 = ANY(SELECT code_original FROM rh.t_rubriques WHERE user_modified) + ) + AND (1!=1 + OR w_HISTOPAYE.AMT_0 != 0 + OR w_HISTOPAYE.BAS_0 != 0) + ; + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SHARE.XML b/import_rh/iCTI_import_rh_SHARE.XML new file mode 100644 index 0000000..b2f0794 --- /dev/null +++ b/import_rh/iCTI_import_rh_SHARE.XML @@ -0,0 +1,3721 @@ + + + + + + + + t_codes_postaux.code + ; + + INSERT INTO rh.t_codes_postaux(oid, code, texte, texte_court, longitude, latitude, departement_id, departement_code, departement_texte) + SELECT + t_codes_postaux.oid, + t_codes_postaux.code, + t_codes_postaux.texte, + t_codes_postaux.texte_court, + t_codes_postaux.longitude, + t_codes_postaux.latitude, + t_codes_postaux.departement_id, + t_codes_postaux.departement_code, + t_codes_postaux.departement_texte + FROM base.t_codes_postaux + LEFT JOIN rh.t_codes_postaux t_codes_postaux_rh ON t_codes_postaux_rh.oid = t_codes_postaux.oid + WHERE t_codes_postaux_rh.oid IS NULL + ; + + UPDATE rh.t_codes_postaux t_codes_postaux_rh + SET + code = t_codes_postaux.code, + texte = t_codes_postaux.texte, + texte_court = t_codes_postaux.texte_court, + longitude = t_codes_postaux.longitude, + latitude = t_codes_postaux.latitude, + departement_id = t_codes_postaux.departement_id, + departement_code = t_codes_postaux.departement_code, + departement_texte = t_codes_postaux.departement_texte + FROM base.t_codes_postaux + WHERE 1=1 + AND t_codes_postaux_rh.oid = t_codes_postaux.oid + AND (1!=1 + OR t_codes_postaux_rh.code IS DISTINCT FROM t_codes_postaux.code + OR t_codes_postaux_rh.texte IS DISTINCT FROM t_codes_postaux.texte + OR t_codes_postaux_rh.texte_court IS DISTINCT FROM t_codes_postaux.texte_court + OR t_codes_postaux_rh.longitude IS DISTINCT FROM t_codes_postaux.longitude + OR t_codes_postaux_rh.latitude IS DISTINCT FROM t_codes_postaux.latitude + OR t_codes_postaux_rh.departement_id IS DISTINCT FROM t_codes_postaux.departement_id + OR t_codes_postaux_rh.departement_code IS DISTINCT FROM t_codes_postaux.departement_code + OR t_codes_postaux_rh.departement_texte IS DISTINCT FROM t_codes_postaux.departement_texte) + ; + + -- Màj des Depts. + DELETE + FROM rh.t_departements t_departements_rh + USING base.t_departements + WHERE t_departements_rh.oid = t_departements.oid AND + t_departements_rh.code <> t_departements.code + ; + + INSERT INTO rh.t_departements(oid, code, texte, texte_court) + SELECT + t_departements.oid, + t_departements.code, + t_departements.texte, + t_departements.texte_court + FROM base.t_departements + LEFT JOIN rh.t_departements t_departements_rh ON t_departements_rh.oid = t_departements.oid + WHERE t_departements_rh.oid IS NULL + ; + + UPDATE rh.t_departements t_departements_rh + SET + code = t_departements.code, + texte = t_departements.texte, + texte_court = t_departements.texte_court + FROM base.t_departements + WHERE + t_departements_rh.oid = t_departements.oid + AND ( + t_departements_rh.code IS DISTINCT FROM t_departements.code OR + t_departements_rh.texte IS DISTINCT FROM t_departements.texte OR + t_departements_rh.texte_court IS DISTINCT FROM t_departements.texte_court + ) + ; + + -- Màj des Entreprises + INSERT INTO rh.t_entreprises(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_entreprises) + ; + + -- Màj des Etablissements + INSERT INTO rh.t_etablissements(oid, code_original, code, texte, texte_court, entreprise_id) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R', 0 + WHERE 0 NOT IN (SELECT oid FROM rh.t_etablissements) + ; + + -- Màj des "Catégories socio-professionnelles". + INSERT INTO rh.t_categories_socio_professionnelle(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_categories_socio_professionnelle) + ; + + -- Màj des "Groupes de cotisants". + INSERT INTO rh.t_groupes_cotisant(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_groupes_cotisant) + ; + + -- Màj des motifs de début de contrat. + INSERT INTO rh.t_motifs_debut_contrat(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_debut_contrat) + ; + + -- Màj des motifs de fin de contrat. + INSERT INTO rh.t_motifs_fin_contrat(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_fin_contrat) + ; + + -- Màj des motifs de fin de contrat : motif fictif CTI positionné lorsque contrat toujours en cours. + INSERT INTO rh.t_motifs_fin_contrat(code_original, code, texte, texte_court) + SELECT 'CTI_CNT_EC', 'CTI_CNT_EC', 'Contrat en cours', 'Contrat en cours' + WHERE 'CTI_CNT_EC' NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat) + ; + + -- Màj des "Nationalités". + INSERT INTO rh.t_nationalites(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_nationalites) + ; + + -- Màj des "Organismes de cotisation". + INSERT INTO rh.t_organismes_cotisation(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_organismes_cotisation) + ; + + -- Màj des "Unités Fonctionnelles". + INSERT INTO rh.t_unite_fonctionnelle(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_unite_fonctionnelle) + ; + + -- Màj des "Rubriques". + INSERT INTO rh.t_rubriques(oid, code_original, code, texte, texte_court, rang_edition) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R', 0 + WHERE 0 NOT IN (SELECT oid FROM rh.t_rubriques) + ; + + -- (création des rubriques CTI de cumul). + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C000', 'Ecart cumulé', 'Ecart cumulé', 'C000', -1 + WHERE 'C000' NOT IN (SELECT code_original FROM rh.t_rubriques) AND + 'C000' NOT IN (SELECT code FROM rh.t_rubriques) + ; + + -- Màj des situations de famille. + INSERT INTO rh.t_situations_famille(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_situations_famille) + ; + + -- Màj des "Types de contrat". + INSERT INTO rh.t_types_contrat(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_types_contrat) + ; + + -- Màj des "Statuts". + INSERT INTO rh.t_statuts(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_statuts) + ; + + -- Màj des types de temps de travail. + INSERT INTO rh.t_types_temps_travail(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_types_temps_travail) + ; + + -- Màj des "Services". + INSERT INTO rh.t_services(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_services) + ; + + -- Màj des "Qualifications". + INSERT INTO rh.t_qualifications(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_qualifications) + ; + + -- Màj des "Spécialités". + INSERT INTO rh.t_specialites(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_specialites) + ; + + -- Màj des "Lettres Budgétaires". + INSERT INTO rh.t_lettre_budgetaire(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_lettre_budgetaire) + ; + + -- Màj des "Codes emploi". + INSERT INTO rh.t_codes_emploi(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_codes_emploi) + ; + + -- Màj des types d'horaire. + INSERT INTO rh.t_types_horaire(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_types_horaire) + ; + + -- Màj des "Groupes de commission paritaire". + INSERT INTO rh.t_commission_paritaire(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_commission_paritaire) + ; + + -- Màj des grilles. + INSERT INTO rh.t_grilles(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_grilles) + ; + + -- Màj des groupes de grilles. + INSERT INTO rh.t_grilles_groupes(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_grilles_groupes) + ; + + -- Màj des motifs d'arret. + INSERT INTO rh.t_motifs_arret(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_arret) + ; + + -- Màj des précisions du motif d'arrêt. + INSERT INTO rh.t_precisions_motif_arret(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_precisions_motif_arret) + ; + + -- Màj des "Motifs de visite médicale". + INSERT INTO rh.t_motifs_visite(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_visite) + ; + + -- Màj des "Circonstances d'accident du travail". + INSERT INTO rh.t_accident_circonstance(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_circonstance) + ; + + -- Màj des "Lieux d'accident du travail". + INSERT INTO rh.t_accident_lieu(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_lieu) + ; + + -- Màj de la nature de l'accident du travail. + INSERT INTO rh.t_accident_nature(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_nature) + ; + + -- Màj des sièges d'accident du travail. + INSERT INTO rh.t_accident_siege(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_siege) + ; + + -- Màj des listes de formations. + INSERT INTO rh.t_liste_formations(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_liste_formations) + ; + + -- Màj des comptes. + INSERT INTO rh.t_compte(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_compte) + ; + + -- Màj des "Catégories de congé". + INSERT INTO rh.t_categorie_conge(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_categorie_conge) + ; + + -- Màj des "Cadres d'emploi". + INSERT INTO rh.t_cadre_emploi(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_cadre_emploi) + ; + + -- Màj des "Filières". + INSERT INTO rh.t_filiere(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_filiere) + ; + + -- Màj des "Catégories statutaires". + INSERT INTO rh.t_categorie_statutaire(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_categorie_statutaire) + ; + + -- Màj des "Codes cotisation". + INSERT INTO rh.t_code_cotisation(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_code_cotisation) + ; + + -- Sections analytiques niveau 1 + INSERT INTO rh.t_sections_analytiques_paie(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(127) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_sections_analytiques_paie) + ; + + INSERT INTO rh.t_sections_analytiques(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(127) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_sections_analytiques) + ; + + INSERT INTO rh.t_section_analytique(oid, code_original, code, texte, texte_court) + SELECT 0, '', chr(127) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_section_analytique) + ; + + -- Pôles + INSERT INTO rh.t_pole(oid, code, texte, texte_court) + SELECT 0, chr(127) || '*', 'Non renseigné', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_pole) + ; + + -- Populations. + INSERT INTO rh.t_population(oid, code, texte, texte_court) + SELECT 0, chr(127) || '*', 'Non renseignée', 'N/R' + WHERE 0 NOT IN (SELECT oid FROM rh.t_population) + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + FROM rh.t_divers + WHERE code = 'PAIE_VENTILATION' + ; + + ]]> + + + + + + + + + + + 0 as data_fusion + from rh.p_historique_paie + where p_historique_paie.oid >= 100000000000 -- uniquement la paie des anciens prestataires. + ) + select opt_hp_up and data_fusion + from divers, data_hp + ; + + ]]> + = 100000000000 -- uniquement la paie des anciens prestataires. + AND (false -- et uniquement pour les lignes où c'est nécessaire. + OR p_historique_paie.base IS DISTINCT FROM update_hp.base + OR p_historique_paie.nombre IS DISTINCT FROM update_hp.nombre + OR p_historique_paie.montant_masse_salariale IS DISTINCT FROM update_hp.montant_masse_salariale + OR p_historique_paie.heure_contrat IS DISTINCT FROM update_hp.heures_contrat + OR p_historique_paie.heure_payee IS DISTINCT FROM update_hp.heures_payees + OR p_historique_paie.heure_travaillee IS DISTINCT FROM update_hp.heures_travaillees) + ; + + -- Resolution d'un problème d'integrite + UPDATE rh.p_historique_paie SET + etablissement_id = p_contrats.etablissement_id, + contrat_mois_id = p_contrats_mois.oid + FROM rh.p_contrats_mois + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid + WHERE contrat_mois_id IS NULL AND + p_historique_paie.salarie_id = p_contrats_mois.salarie_id AND + p_historique_paie.contrat_id = p_contrats_mois.contrat_id AND + p_historique_paie.mois_paie = p_contrats_mois.mois_activite + ; + + ]]> + + + 0 + ; + + SELECT rh.cti_fusion_salaries(); + + -- Table des personnes + SELECT rh.cti_reorganize_personne(); + + -- Forcage date sortie etablissement selon motif fin de contrat + UPDATE rh.p_salaries + SET date_sortie_ets = p_contrats.date_fin + FROM rh.p_contrats + JOIN + ( + SELECT + p_contrats.salarie_id, + MAX(p_contrats.date_fin), + (MAX(array[p_contrats.date_fin::text, p_contrats.oid::text]))[2]::bigint AS last_contrat_id + FROM rh.p_contrats + GROUP BY 1 + HAVING MAX(p_contrats.date_fin) <= now() + ) subview ON p_contrats.oid = last_contrat_id + JOIN rh.p_profils ON p_contrats.profil_id = p_profils.oid + WHERE p_salaries.oid = subview.salarie_id AND + p_salaries.date_sortie_ets = '20991231' AND + p_profils.motif_fin_id IN ( + SELECT to_id + FROM rh.t_listes + JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id + WHERE t_listes.code = 'CTI_MFCDEP' + ) + ; + + -- Assignation du plus récent entreprise_id (là où non renseigné) + UPDATE rh.p_salaries + SET entreprise_id = subview.dernier_entreprise_id + FROM + ( + SELECT + p_salaries.oid AS salarie_id, + (MAX(array[p_contrats.date_fin::text, t_etablissements.entreprise_id::text]))[2]::bigint AS dernier_entreprise_id + FROM rh.p_salaries + JOIN rh.p_contrats ON p_contrats.salarie_id = p_salaries.oid + JOIN rh.t_etablissements ON t_etablissements.oid = p_contrats.etablissement_id + GROUP BY 1 + ) AS subview + WHERE + (p_salaries.entreprise_id = 0 OR p_salaries.entreprise_id IS NULL) + AND p_salaries.oid = subview.salarie_id + ; + + ]]> + + + date_entree_ets; + ; + + -- Màj de l'ancienneté. + UPDATE rh.p_contrats + SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_calculee_mois + FROM ( + select + numero_contrat, + coalesce(sum(date_fin - date_debut + 1) over w, 0) AS anciennete_anterieure_jours, + coalesce(sum(date_fin - date_debut + 1) over w / 30::numeric, 0) AS anciennete_anterieure_calculee_mois + from rh.p_contrats + window w as (partition by salarie_id order by date_debut rows between UNBOUNDED PRECEDING and 1 preceding)) AS subq + WHERE 1=1 + AND p_contrats.numero_contrat = subq.numero_contrat + ; + + -- Màj de l'ancienneté reprise. + UPDATE rh.p_contrats + SET + anciennete_reprise_anterieure_jours = subq.anciennete_reprise_anterieure_jours, + anciennete_reprise_anterieure_calculee_mois = subq.anciennete_reprise_anterieure_jours / 30 + FROM + ( + SELECT + p_contrats.numero_contrat, + COALESCE((p_contrats.anciennete_anterieure_jours + (p_salaries.date_entree_ets - p_salaries.date_anciennete)), 0) AS anciennete_reprise_anterieure_jours + FROM rh.p_salaries + JOIN rh.p_contrats ON p_contrats.salarie_id = p_salaries.oid + ) AS subq + WHERE p_contrats.numero_contrat = subq.numero_contrat + ; + + UPDATE rh.p_contrats_mois + SET + anciennete_jours = subq.anciennete_jours, + anciennete_reprise_jours = subq.anciennete_reprise_jours, + anciennete_mois = subq.anciennete_mois, + anciennete_reprise_mois = subq.anciennete_reprise_mois, + anciennete_annee_id = subq.anciennete_annee_id, + anciennete_reprise_annee_id = subq.anciennete_reprise_annee_id + FROM + ( + SELECT + p_contrats.salarie_id, + p_contrats.oid AS contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats.anciennete_anterieure_jours + + (p_contrats_mois.date_fin - p_contrats.date_debut) + + 1 AS anciennete_jours, + p_contrats.anciennete_reprise_anterieure_jours + + (p_contrats_mois.date_fin - p_contrats.date_debut) AS anciennete_reprise_jours, + base.cti_age(date_trunc('month', p_contrats_mois.date_fin)::date, date_trunc('month', p_contrats.date_debut)::date, 'nm') + + GREATEST(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + + 1 AS anciennete_mois, + base.cti_age(date_trunc('month', p_contrats_mois.date_fin)::date, date_trunc('month', p_contrats.date_debut)::date, 'nm') + + p_contrats.anciennete_reprise_anterieure_calculee_mois AS anciennete_reprise_mois, + floor((base.cti_age(date_trunc('month', p_contrats_mois.date_fin::date)::date, date_trunc('month', p_contrats.date_debut)::date, 'nm') + + GREATEST(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + + 1) / 12) AS anciennete_annee_id, + floor((base.cti_age(date_trunc('month', p_contrats_mois.date_fin::date)::date, date_trunc('month', p_contrats.date_debut)::date, 'nm') + + p_contrats.anciennete_reprise_anterieure_calculee_mois) / 12) AS anciennete_reprise_annee_id + FROM rh.p_contrats + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + ) AS subq + WHERE + p_contrats_mois.salarie_id = subq.salarie_id + AND p_contrats_mois.contrat_id = subq.contrat_id + AND p_contrats_mois.oid = subq.contrat_mois_id + ; + + -- Màj des compteurs + UPDATE rh.p_contrats_mois SET + nombre_entrees = CASE WHEN p_salaries.date_entree_ets BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END, + nombre_departs = CASE WHEN p_salaries.date_sortie_ets BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END, + nombre_debut_contrat = CASE WHEN p_contrats.date_debut BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END, + nombre_fin_contrat = CASE WHEN p_contrats.date_fin BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END, + present_debut_mois = CASE WHEN p_contrats_mois.date_debut = base.cti_first_day(p_contrats_mois.date_debut) THEN 1 ELSE 0 END, + present_fin_mois = CASE WHEN p_contrats_mois.date_fin = base.cti_last_day(p_contrats_mois.date_fin) THEN 1 ELSE 0 END, + age_jours = p_contrats_mois.date_fin - COALESCE(p_salaries.date_naissance, '1962-04-18'::date) + FROM rh.p_salaries, rh.p_contrats + WHERE 1=1 + AND p_salaries.oid = p_contrats_mois.salarie_id + AND p_contrats.oid = p_contrats_mois.contrat_id + ; + + with flagged_cnt as ( + select + p_contrats.oid, + coalesce(lag(p_contrats.date_fin) over w + '1 day'::interval = p_contrats.date_debut and + lag(p_profils.motif_fin_code) over w in (select unnest(string_to_array(replace(valeur, ' ', ''), ',')) from rh.t_divers where code = 'OPT_CNT_FIN_FUSION'), false) as pas_top_debut, + p_profils.motif_fin_code in (select unnest(string_to_array(replace(valeur, ' ', ''), ',')) from rh.t_divers where code = 'OPT_CNT_FIN_FUSION') as pas_top_fin + from rh.p_contrats + join rh.p_profils on p_profils.oid = p_contrats.profil_id + window w as (partition by p_contrats.salarie_id order by p_contrats.date_debut)) + update rh.p_contrats_mois set + nombre_debut_contrat = case when pas_top_debut then '0' else nombre_debut_contrat end, + nombre_fin_contrat = case when pas_top_fin then '0' else nombre_fin_contrat end + from flagged_cnt + where true + and p_contrats_mois.contrat_id = flagged_cnt.oid + and (false + or pas_top_debut + or pas_top_fin) + ; + + with toto as ( + select + p_contrats_mois.oid, + case when type_contrat_section_code[9] = 'CDI' and lag(type_contrat_section_code[9]) over w != 'CDI' then 1 else 0 end as nombre_transformation_cdi + from rh.p_contrats_mois + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + join rh.p_profils on p_profils.oid = p_profil_contrat_mois.profil_id + window w as (partition by p_contrats_mois.salarie_id order by p_contrats_mois.date_debut)) + UPDATE rh.p_contrats_mois SET + nombre_transformation_cdi = toto.nombre_transformation_cdi + FROM toto + WHERE 1=1 + AND p_contrats_mois.oid = toto.oid + AND p_contrats_mois.nombre_transformation_cdi IS DISTINCT FROM toto.nombre_transformation_cdi + ; + + /* CONTRATS */ + -- MAJ de l'age contrat si ce dernier est 0 + WITH w_age_contrat AS + ( + SELECT + p_contrats_mois.oid, + base.cti_age(p_contrats_mois.date_fin, coalesce(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id + FROM rh.p_contrats_mois + JOIN rh.p_salaries ON p_contrats_mois.salarie_id = p_salaries.oid + ) + UPDATE rh.p_contrats_mois + SET age_id = w_age_contrat.age_id + FROM w_age_contrat + WHERE p_contrats_mois.oid = w_age_contrat.oid + ; + + -- Màj des âges (plage autorisée : 0 -> 110 ans) + UPDATE rh.p_contrats_mois + SET age_id = 0 + WHERE age_id < 0 + ; + + UPDATE rh.p_contrats_mois + SET age_id = (SELECT max(oid) FROM rh.t_ages) + WHERE age_id > (SELECT max(oid) FROM rh.t_ages) + ; + + -- Màj des anciennetés (plage autorisée : 0 -> 50 ans) + UPDATE rh.p_contrats_mois + SET + anciennete_jours = 0, + anciennete_reprise_jours = 0, + anciennete_mois = 0, + anciennete_reprise_mois = 0, + anciennete_annee_id = 0, + anciennete_reprise_annee_id = 0 + WHERE anciennete_jours <= 0 + ; + + UPDATE rh.p_contrats_mois + SET anciennete_annee_id = (SELECT max(oid) FROM rh.t_anciennetes_annee) + WHERE anciennete_annee_id > (SELECT max(oid) FROM rh.t_anciennetes_annee) + ; + + UPDATE rh.p_contrats_mois + SET anciennete_reprise_annee_id = (SELECT max(oid) FROM rh.t_anciennetes_annee) + WHERE anciennete_reprise_annee_id > (SELECT max(oid) FROM rh.t_anciennetes_annee) + ; + + -- Màj des établissements dans p_contrats_mois lorsque non renseigné lors de l'import. + UPDATE rh.p_contrats_mois + SET etablissement_id = p_contrats.etablissement_id + FROM rh.p_contrats + WHERE 1=1 + AND p_contrats_mois.contrat_id = p_contrats.oid + AND p_contrats_mois.etablissement_id IS NULL + ; + + ]]> + + + + + + + + + + + + + + + + 0 + GROUP BY 1,2,3 + ) + SELECT + salarie_id, + annee, + MAX(mois_paie) AS mois_paie_max, + SUM(montant_brut_mensuel) AS montant_brut_annuel, + AVG(montant_brut_mensuel) AS montant_brut_mensuel_moyen + FROM montants_brut_mensuel + GROUP BY 1,2 + ORDER BY 1,2 + ; + + -- Mise à jour du montant_brut_mensuel_moyen et montant_brut_annuel sur la dernière ligne d'historique de paie du salarié + UPDATE rh.p_historique_paie + SET + montant_brut_annuel = subview.montant_brut_annuel, + montant_brut_mensuel_moyen = subview.montant_brut_mensuel_moyen + FROM + ( + with max_oid AS + ( + SELECT + montants_brut_cumules.salarie_id, + montants_brut_cumules.annee, + MAX(p_historique_paie.oid) AS oid_to_update + FROM rh.p_historique_paie + JOIN montants_brut_cumules ON montants_brut_cumules.salarie_id = p_historique_paie.salarie_id AND montants_brut_cumules.mois_paie_max = p_historique_paie.mois_paie + GROUP BY 1,2 + ) + SELECT + max_oid.oid_to_update, + montants_brut_cumules.salarie_id, + montants_brut_cumules.montant_brut_annuel, + montants_brut_cumules.montant_brut_mensuel_moyen + FROM montants_brut_cumules + JOIN max_oid ON max_oid.salarie_id = montants_brut_cumules.salarie_id AND max_oid.annee = montants_brut_cumules.annee + ) AS subview + WHERE p_historique_paie.oid = subview.oid_to_update + ; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SHS.XML b/import_rh/iCTI_import_rh_SHS.XML new file mode 100644 index 0000000..562b545 --- /dev/null +++ b/import_rh/iCTI_import_rh_SHS.XML @@ -0,0 +1,3292 @@ + + + + + + = to_char(rhp('rhprovider_start')::date, 'YYYY') + AND J0CENT IN (select substr(column2, 1, 3)::numeric from rhp where column1 = 'entreprise') + GROUP BY 1; + + CREATE INDEX w_entreprises_select_i1 ON w_entreprises_select USING btree(XXCENT) + ; + + DROP TABLE IF EXISTS w_etablissements_select; + CREATE TEMP TABLE w_etablissements_select AS + SELECT J0CENT AS XXCENT, J0CETS AS XXCETS + FROM prod_shs.rhlibH_J0P01 + WHERE 1=1 + AND J0DFPA >= to_char(rhp('rhprovider_start')::date, 'YYYY') + AND (1!=1 + OR J0CENT IN (select column2::numeric from rhp where column1 = 'entreprise') + OR to_char(J0CENT,'FM000') || to_char(J0CETS,'FM000') IN (select column2::numeric from rhp where column1 = 'entreprise')) + GROUP BY 1,2; + + CREATE INDEX w_etablissements_select_i1 ON w_etablissements_select USING btree(XXCETS) + ; + + -- Màj des codes postaux + INSERT INTO rh.t_codes_postaux(oid, code, texte, texte_court, longitude, latitude, departement_id, + departement_code, departement_texte) + SELECT + t_codes_postaux.oid, + t_codes_postaux.code, + t_codes_postaux.texte, + t_codes_postaux.texte_court, + t_codes_postaux.longitude, + t_codes_postaux.latitude, + t_codes_postaux.departement_id, + t_codes_postaux.departement_code, + t_codes_postaux.departement_texte + FROM base.t_codes_postaux + LEFT JOIN rh.t_codes_postaux t_codes_postaux_rh ON t_codes_postaux_rh.oid = t_codes_postaux.oid + WHERE t_codes_postaux_rh.oid IS NULL + ; + + UPDATE rh.t_codes_postaux t_codes_postaux_rh + SET + code = t_codes_postaux.code, + texte = t_codes_postaux.texte, + texte_court = t_codes_postaux.texte_court, + longitude = t_codes_postaux.longitude, + latitude = t_codes_postaux.latitude, + departement_id = t_codes_postaux.departement_id, + departement_code = t_codes_postaux.departement_code, + departement_texte = t_codes_postaux.departement_texte + FROM base.t_codes_postaux + WHERE + t_codes_postaux_rh.oid = t_codes_postaux.oid + AND ( + t_codes_postaux_rh.code IS DISTINCT FROM t_codes_postaux.code OR + t_codes_postaux_rh.texte IS DISTINCT FROM t_codes_postaux.texte OR + t_codes_postaux_rh.texte_court IS DISTINCT FROM t_codes_postaux.texte_court OR + t_codes_postaux_rh.longitude IS DISTINCT FROM t_codes_postaux.longitude OR + t_codes_postaux_rh.latitude IS DISTINCT FROM t_codes_postaux.latitude OR + t_codes_postaux_rh.departement_id IS DISTINCT FROM t_codes_postaux.departement_id OR + t_codes_postaux_rh.departement_code IS DISTINCT FROM t_codes_postaux.departement_code OR + t_codes_postaux_rh.departement_texte IS DISTINCT FROM t_codes_postaux.departement_texte + ) + ; + + -- Màj des Depts. + + INSERT INTO rh.t_departements(oid, code, texte, texte_court) + SELECT + t_departements.oid, + t_departements.code, + t_departements.texte, + t_departements.texte_court + FROM base.t_departements + LEFT JOIN rh.t_departements t_departements_rh ON t_departements_rh.oid = t_departements.oid + WHERE t_departements_rh.oid IS NULL + ; + + UPDATE rh.t_departements t_departements_rh + SET + code = t_departements.code, + texte = t_departements.texte, + texte_court = t_departements.texte_court + FROM base.t_departements + WHERE + t_departements_rh.oid = t_departements.oid + AND ( + t_departements_rh.code IS DISTINCT FROM t_departements.code OR + t_departements_rh.texte IS DISTINCT FROM t_departements.texte OR + t_departements_rh.texte_court IS DISTINCT FROM t_departements.texte_court + ) + ; + + -- Màj des Entreprises + INSERT INTO rh.t_entreprises(code, texte, texte_court, code_original, siren) + SELECT + to_char(F0CENT,'FM000'), + F0RSOC, + F0NOM, + to_char(F0CENT,'FM000'), + substring(f1csir,1,9) + FROM prod_shs.rhlib_F0P01 + JOIN w_entreprises_select ON XXCENT = F0CENT + LEFT JOIN rh.t_entreprises ON code_original = to_char(F0CENT,'FM000') + JOIN prod_shs.rhlib_F1P01 ON to_char(F1CENT,'FM000') = to_char(F0CENT,'FM000') + WHERE 1=1 + AND code_original IS NULL + GROUP BY 1,2,3,4,5 + ; + + UPDATE rh.t_entreprises + SET code = code_original + WHERE code <> code_original + ; + + with ent as ( + SELECT + t_entreprises.oid, + substring(f1csir,1,9) AS siren + FROM rh.t_entreprises + JOIN prod_shs.rhlib_F1P01 ON to_char(F1CENT,'FM000') = t_entreprises.code_original) + UPDATE rh.t_entreprises + SET siren = ent.siren + FROM ent + WHERE 1=1 + and t_entreprises.oid = ent.oid + and t_entreprises.siren IS DISTINCT FROM ent.siren + ; + + -- Màj des Etablissements. + INSERT INTO rh.t_etablissements(code, texte, texte_court, code_original, entreprise_id,siret) + SELECT + to_char(F1CETS,'FM000'), + F1NOM, + F1NOM, + to_char(F1CENT,'FM000')||to_char(F1CETS,'FM000'), + t_entreprises.oid, + f1csir + FROM prod_shs.rhlib_F1P01 + JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS + JOIN rh.t_entreprises ON t_entreprises.code_original = lpad(F1CENT, 3, '0') + LEFT JOIN rh.t_etablissements ON t_etablissements.code_original = (to_char(F1CENT,'FM000')||to_char(F1CETS,'FM000')) + WHERE 1=1 + AND t_etablissements.code_original IS NULL + ; + + with eta as ( + SELECT + t_etablissements.oid, + f1csir as siret + FROM rh.t_etablissements + JOIN prod_shs.rhlib_F1P01 on to_char(F1CENT,'FM000')||to_char(F1CETS,'FM000') = t_etablissements.code_original) + UPDATE rh.t_etablissements + SET siret = eta.siret + FROM eta + WHERE 1=1 + and t_etablissements.oid = eta.oid + and t_etablissements.siret IS DISTINCT FROM eta.siret + ; + + -- Code avec entreprise si plusieurs entreprises + UPDATE rh.t_etablissements + SET code = CASE WHEN (SELECT count(DISTINCT substr(code_original,1,3)) FROM rh.t_etablissements) > 1 THEN substr(code_original,1,3) || '-' ELSE '' END || substr(code_original,4,3) + WHERE code <> (CASE WHEN (SELECT count(DISTINCT substr(code_original,1,3)) FROM rh.t_etablissements) > 1 THEN substr(code_original,1,3) || '-' ELSE '' END || substr(code_original,4,3)) + ; + + -- Màj des nationalités + INSERT INTO rh.t_nationalites(code, texte, texte_court, code_original) + SELECT DISTINCT + F3CNAT, F3CNAT, F3CNAT, F3CNAT + FROM prod_shs.rhlib_F3P01 + LEFT JOIN rh.t_nationalites ON (code_original = F3CNAT) + WHERE 1=1 + AND F3CNAT <> '' + AND code_original IS NULL + ; + + -- Màj des situations de famille + INSERT INTO rh.t_situations_famille(code, texte, texte_court, code_original) + SELECT DISTINCT + F3SFAM, F3SFAM, F3SFAM, F3SFAM + FROM + prod_shs.rhlib_F3P01 + LEFT JOIN rh.t_situations_famille ON (code_original = F3SFAM) + WHERE + F3SFAM <> '' AND code_original IS NULL + ; + + -- Màj des statuts + DROP TABLE IF EXISTS w_SHS_statuts; + CREATE TEMP TABLE w_SHS_statuts AS + SELECT F1CENT AS XXCENT, F1CETS AS XXCETS, F1CST0 AS XXCODO, F1CST0 AS XXCODE, F1LST0 AS XXTEXT + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST0 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST1, F1CST1, F1LST1 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST1 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST2, F1CST2, F1LST2 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST2 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST3, F1CST3, F1LST3 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST3 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST4, F1CST4, F1LST4 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST4 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST5, F1CST5, F1LST5 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST5 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST6, F1CST6, F1LST6 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST6 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST7, F1CST7, F1LST7 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST7 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST8, F1CST8, F1LST8 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST8 <> '' + UNION + SELECT F1CENT, F1CETS, F1CST9, F1CST9, F1LST9 + FROM prod_shs.rhlib_F1P01 JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS WHERE F1CST9 <> '' + ; + + SELECT rh.cti_shs_multicode('w_shs_statuts', 'w_cti_statuts') + ; + + INSERT INTO rh.t_statuts(code, texte, texte_court, code_original) + SELECT + MAX(in_code), MAX(in_texte), MAX(in_texte), in_code_original + FROM w_cti_statuts + LEFT JOIN rh.t_statuts ON t_statuts.code_original = in_code_original + WHERE t_statuts.code_original IS NULL + GROUP BY in_code_original + ORDER BY 1 + ; + + UPDATE rh.t_statuts SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_statuts + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code, texte, texte_court, code_original) + SELECT + N0CENR, + MAX(N0LIBE), + MAX(N0LIBE), + N0CENR + FROM + prod_shs.rhlib_n0P01 + JOIN w_entreprises_select ON XXCENT = to_number('0' || N0ENTR, '0000') + LEFT JOIN rh.t_types_contrat ON (code_original = N0CENR) + WHERE n0ctab = 'TCNT' + AND N0TYPE = 2 + AND code_original IS NULL + AND N0CENR <> '' + GROUP BY 1 + ; + + -- Màj des motifs de début de contrat + INSERT INTO rh.t_motifs_debut_contrat(code, texte, texte_court, code_original) + SELECT + N0CENR, + MAX(N0LIBE), + MAX(N0LIBE), + N0CENR + FROM + prod_shs.rhlib_n0P01 + JOIN w_entreprises_select ON XXCENT = to_number('0' || N0ENTR, '0000') + LEFT JOIN rh.t_motifs_debut_contrat ON (code_original = N0CENR) + WHERE N0CTAB = 'MOTD' + AND N0TYPE = '2' + AND code_original IS NULL + AND N0CENR <> '' + GROUP BY 1 + ; + + -- Màj des motifs de fin de contrat + INSERT INTO rh.t_motifs_fin_contrat(code, texte, texte_court, code_original) + SELECT + SUBSTR(N0CENR,4,2), + MAX(N0LIBE), + MAX(N0LIBE), + SUBSTR(N0CENR,4,2) + FROM + prod_shs.rhlib_n0P01 + JOIN w_entreprises_select ON XXCENT = to_number('0' || N0ENTR, '0000') + LEFT JOIN rh.t_motifs_fin_contrat ON (code_original = SUBSTR(N0CENR,4,2)) + WHERE N0CTAB = 'MOTF' + AND N0TYPE = '2' + AND code_original IS NULL + AND N0CENR <> '' + GROUP BY 1 + ; + + -- Màj des qualifications. + -- Le code original est préfixé par les codes Ent. et Ets. car il peut y avoir collision de code d'un établissement à l'autre. + DROP TABLE IF EXISTS w_shs_qualifications; + CREATE TEMP TABLE w_shs_qualifications AS + SELECT + G1CENT AS XXCENT, + G1CETS AS XXCETS, + G1CQUA AS XXCODO, + G1CQUA AS XXCODE, + G1LPAR AS XXTEXT + FROM prod_shs.rhlib_G1P01 + JOIN w_etablissements_select ON XXCENT = G1CENT AND XXCETS = G1CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_qualifications', 'w_cti_qualifications') + ; + + UPDATE w_cti_qualifications + SET in_code_original = subview.new_in_code_original + FROM + ( + SELECT in_code_original, + MIN(to_char(XXCENT, 'FM000') || to_char(XXCETS, 'FM000') || xxcodo) AS new_in_code_original + FROM w_cti_qualifications + GROUP BY 1 + ) subview + WHERE w_cti_qualifications.in_code_original = subview.in_code_original; + + INSERT INTO rh.t_qualifications(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_qualifications + LEFT JOIN rh.t_qualifications ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_qualifications SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_qualifications + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + -- Màj des types de temps de travail + DROP TABLE IF EXISTS w_shs_types_temps_travail + ; + CREATE TEMP TABLE w_shs_types_temps_travail AS + SELECT + XXCENT, + XXCETS, + coalesce(subq.code, N0CENR) AS XXCODO, + coalesce(subq.code, N0CENR) AS XXCODE, + MAX(N0LIBE)||coalesce(subq.libelle, ''::text) AS XXTEXT + FROM prod_shs.rhlib_n0P01 + JOIN w_etablissements_select ON 1=1 + LEFT JOIN (select + F4CTPS, + case when F4CTPS IN ('I', 'P') then F4CTPS||trim(to_char(F4NHRE, '000.00')) else F4CTPS end as code, + ' ' || F4NHRE::text as libelle, + F4CENT, + F4CETS + from prod_shs.rhlib_F4P01 + JOIN w_etablissements_select ON 1=1 + AND XXCENT = F4CENT + AND XXCETS = F4CETS + WHERE F4CTPS IN ('I', 'P') + group by 1,2,3,4,5) as subq on 1=1 + AND subq.F4CTPS = N0CENR + AND subq.F4CENT = XXCENT + AND subq.F4CETS = XXCETS + WHERE 1=1 + AND N0CTAB = 'TTPS' + AND N0TYPE = '2' + GROUP BY 1,2,3,4, subq.libelle + ; + + SELECT rh.cti_shs_multicode('w_shs_types_temps_travail', 'w_cti_types_temps_travail') + ; + + INSERT INTO rh.t_types_temps_travail(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_types_temps_travail + LEFT JOIN rh.t_types_temps_travail ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_types_temps_travail SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_types_temps_travail + WHERE 1=1 + AND in_code_original = code_original + AND (1!=1 + OR code IS DISTINCT FROM in_code + OR texte IS DISTINCT FROM in_texte + OR texte_court IS DISTINCT FROM in_texte) + ; + + -- Màj des catégories socio-professionnelles + DROP TABLE IF EXISTS w_shs_categories; + CREATE TEMP TABLE w_shs_categories AS + SELECT + G4CENT AS XXCENT, + G4CETS AS XXCETS, + G4CCSP AS XXCODO, + G4CCSP AS XXCODE, + G4LPAR AS XXTEXT + FROM prod_shs.rhlib_G4P01 + JOIN w_etablissements_select ON XXCENT = G4CENT AND XXCETS = G4CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_categories', 'w_cti_categories') + ; + + INSERT INTO rh.t_categories_socio_professionnelle(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_categories + LEFT JOIN rh.t_categories_socio_professionnelle ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_categories_socio_professionnelle SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_categories + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + -- Màj des services + DROP TABLE IF EXISTS w_shs_services; + CREATE TEMP TABLE w_shs_services AS + SELECT + G2CENT AS XXCENT, + G2CETS AS XXCETS, + G2SRVC AS XXCODO, + G2SRVC AS XXCODE, + G2LPAR AS XXTEXT + FROM prod_shs.rhlib_G2P01 + JOIN w_etablissements_select ON XXCENT = G2CENT AND XXCETS = G2CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_services', 'w_cti_services') + ; + + INSERT INTO rh.t_services(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_services + LEFT JOIN rh.t_services ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_services SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_services + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + -- Màj des spécialités + DROP TABLE IF EXISTS w_shs_specialites; + CREATE TEMP TABLE w_shs_specialites AS + SELECT + G3CENT AS XXCENT, + G3CETS AS XXCETS, + G3SPEC AS XXCODO, + G3SPEC AS XXCODE, + G3LPAR AS XXTEXT + FROM prod_shs.rhlib_G3P01 + JOIN w_etablissements_select ON XXCENT = G3CENT AND XXCETS = G3CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_specialites', 'w_cti_specialites') + ; + + INSERT INTO rh.t_specialites(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_specialites + LEFT JOIN rh.t_specialites ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_specialites SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_specialites + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + -- Màj des Codes Emploi + DROP TABLE IF EXISTS w_shs_codes_emploi; + CREATE TEMP TABLE w_shs_codes_emploi AS + SELECT + G5CENT AS XXCENT, + G5CETS AS XXCETS, + G5CEMP AS XXCODO, + G5CEMP AS XXCODE, + G5LPAR AS XXTEXT + FROM prod_shs.rhlib_G5P01 + JOIN w_etablissements_select ON XXCENT = G5CENT AND XXCETS = G5CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_codes_emploi', 'w_cti_codes_emploi') + ; + + INSERT INTO rh.t_codes_emploi(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_codes_emploi + LEFT JOIN rh.t_codes_emploi ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_codes_emploi SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_codes_emploi + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + -- Màj des types d'horaire + INSERT INTO rh.t_types_horaire(code, texte, texte_court, code_original) + SELECT DISTINCT + F4CTJN, + F4CTJN, + F4CTJN, + F4CTJN + FROM prod_shs.rhlib_F4P01 + JOIN w_etablissements_select ON XXCENT = f4CENT AND XXCETS = f4CETS + LEFT JOIN rh.t_types_horaire ON (code_original = F4CTJN) + WHERE code_original IS NULL AND F4CTJN <> '' + ; + + -- Màj des sociétés d'interim + INSERT INTO rh.t_societes_interim(code, texte, texte_court, code_original) + SELECT DISTINCT + F4CSOC, + F4CSOC, + F4CSOC, + F4CSOC + FROM prod_shs.rhlib_F4P01 + JOIN w_etablissements_select ON XXCENT = f4CENT AND XXCETS = f4CETS + LEFT JOIN rh.t_societes_interim ON (code_original = F4CSOC) + WHERE F4CSOC <> '' + AND code_original IS NULL + ; + + -- Màj des groupes cotisants. + DROP TABLE IF EXISTS w_shs_groupes_cotisant; + CREATE TEMP TABLE w_shs_groupes_cotisant AS + SELECT + G9CENT AS XXCENT, + G9CETS AS XXCETS, + G9GCOT AS XXCODO, + G9GCOT AS XXCODE, + G9LPAR AS XXTEXT + FROM prod_shs.rhlib_G9P01 + JOIN w_etablissements_select ON XXCENT = G9CENT AND XXCETS = G9CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_groupes_cotisant', 'w_cti_groupes_cotisant') + ; + + INSERT INTO rh.t_groupes_cotisant(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_groupes_cotisant + LEFT JOIN rh.t_groupes_cotisant ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_groupes_cotisant SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_groupes_cotisant + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + -- Màj des grilles + INSERT INTO rh.t_grilles(code, texte, texte_court, code_original) + SELECT DISTINCT + F4GRIE, + F4GRIE, + F4GRIE, + F4GRIE + FROM prod_shs.rhlib_F4P01 + JOIN w_etablissements_select ON XXCENT = f4CENT AND XXCETS = f4CETS + LEFT JOIN rh.t_grilles ON (code_original = F4GRIE) + WHERE code_original IS NULL + AND F4GRIE <> '' + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code, texte, texte_court, code_original) + SELECT DISTINCT + F4GRPE, + F4GRPE, + F4GRPE, + F4GRPE + FROM prod_shs.rhlib_F4P01 + JOIN w_etablissements_select ON XXCENT = f4CENT AND XXCETS = f4CETS + LEFT JOIN rh.t_grilles_groupes ON (code_original = F4GRPE) + WHERE code_original IS NULL + AND F4GRPE <> '' + ; + + -- Màj des sections analytiques de paie + DROP TABLE IF EXISTS w_shs_sections_analytiques_paie; + CREATE TEMP TABLE w_shs_sections_analytiques_paie AS + SELECT + G0CENT AS XXCENT, + G0CETS AS XXCETS, + G0SANA AS XXCODO, + G0SANA AS XXCODE, + G0LPAR AS XXTEXT + FROM prod_shs.rhlib_G0P01 + JOIN w_etablissements_select ON XXCENT = G0CENT AND XXCETS = G0CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_sections_analytiques_paie', 'w_cti_sections_analytiques_paie') + ; + + INSERT INTO rh.t_sections_analytiques_paie(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_sections_analytiques_paie + LEFT JOIN rh.t_sections_analytiques_paie ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_sections_analytiques_paie SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_sections_analytiques_paie + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + -- Màj des sections analytiques (une partie est conditionné à l'existence de ANP01PR). + INSERT INTO rh.t_sections_analytiques(code, texte, texte_court, code_original) + SELECT DISTINCT + G0SCPA, + G0SCPA, + G0SCPA, + G0SCPA + FROM prod_shs.rhlib_G0p01 + JOIN w_etablissements_select ON XXCENT = G0CENT AND XXCETS = G0CETS + LEFT JOIN rh.t_sections_analytiques ON (code_original = G0SCPA) + WHERE code_original IS NULL + ; + + -- Màj des rubriques + DROP TABLE IF EXISTS w_shs_rubriques; + CREATE TEMP TABLE w_shs_rubriques AS + with rubs as ( + select G6CRUB as xxcrub + from prod_shs.rhlib_G6P01 + union + select H0CCOT as xxcrub + from prod_shs.rhlib_H0P01), + cartesian as ( + select + xxcrub, + xxcent, + xxcets + from rubs, w_etablissements_select), + libs_0 as ( + select + g6crub as libcrub, + g6lpar as liblpar + from prod_shs.rhlib_G6P01 + union + select + H0CCOT, + H0lpar + from prod_shs.rhlib_H0P01), + libs as ( + select + libcrub, + max(liblpar) as liblpar + from libs_0 + group by 1) + select + XXCENT, + XXCETS, + xxcrub::text as XXCODO, + to_char(xxcrub,'FM0000') AS XXCODE, + coalesce(G6P01.G6LPAR, H0P01.H0LPAR, libLPAR) AS XXTEXT + from cartesian + left join prod_shs.rhlib_G6P01 as G6P01 ON 1=1 + and XXCENT = G6P01.G6CENT + AND XXCETS = G6P01.G6CETS + and xxcrub = G6P01.G6CRUB + left join prod_shs.rhlib_H0P01 as H0P01 ON 1=1 + and XXCENT = H0P01.H0CENT + AND XXCETS = H0P01.H0CETS + and xxcrub = H0P01.H0CCOT + left join libs ON xxcrub = libcrub + ; + + SELECT rh.cti_shs_multicode('w_shs_rubriques', 'w_cti_rubriques') + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_rubriques + LEFT JOIN rh.t_rubriques ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_rubriques SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_rubriques + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + UPDATE w_cti_rubriques + SET in_id = t_rubriques.oid + FROM rh.t_rubriques + WHERE code_original = in_code_original; + + + + -- Màj des organismes de cotisation + DROP TABLE IF EXISTS w_shs_organismes_cotisation; + CREATE TEMP TABLE w_shs_organismes_cotisation AS + SELECT + I3CENT AS XXCENT, + I3CETS AS XXCETS, + I3NORG::text AS XXCODO, + I3NORG::text AS XXCODE, + I3NOM AS XXTEXT + FROM prod_shs.rhlib_I3P01 + JOIN w_etablissements_select ON XXCENT = I3CENT AND XXCETS = I3CETS + ; + + SELECT rh.cti_shs_multicode('w_shs_organismes_cotisation', 'w_cti_organismes_cotisation') + ; + + INSERT INTO rh.t_organismes_cotisation(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_organismes_cotisation + LEFT JOIN rh.t_organismes_cotisation ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_organismes_cotisation SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_organismes_cotisation + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM in_texte + ) + ; + + UPDATE w_cti_organismes_cotisation + SET in_id = t_organismes_cotisation.oid + FROM rh.t_organismes_cotisation + WHERE code_original = in_code_original; + + -- Màj des listes + + -- Ancienne codification supprimée + DELETE FROM rh.t_listes + WHERE code LIKE 'G8P01%' AND + length(code) <= 10; + + DELETE from rh.t_listes_contenu + WHERE liste_id NOT IN (SELECT oid FROM rh.t_listes) + ; + + + INSERT INTO rh.t_listes( + code, + texte, + table_id, + is_cti, + show_omit, + utilisateur_createur, + est_partagee_modification, + chapitre + ) + SELECT + 'G8P01_' || G8CGRP || '-' || to_char(G8CENT,'FM000') || to_char(G8CETS,'FM000') AS code, + G8LPAR || ' - ' || F1NOM AS texte, + (SELECT oid FROM rh.t_listes_tables WHERE code ='RUP') AS table_id, + '0' AS is_cti, + '0' AS show_omit, + 'cti' AS utilisateur_createur, + '0' AS est_partagee_modification, + 'Listes SHS ' || F1NOM + FROM prod_shs.rhlib_G8P01 + JOIN prod_shs.rhlib_F1P01 ON G8CENT = F1CENT AND G8CETS = F1CETS + JOIN w_etablissements_select ON XXCENT = G8CENT AND XXCETS = G8CETS + WHERE ('G8P01_' || G8CGRP || '-' || to_char(G8CENT,'FM000') || to_char(G8CETS,'FM000') ) NOT IN (SELECT code FROM rh.t_listes); + + UPDATE rh.t_listes SET + texte = G8LPAR || ' - ' || F1NOM, + chapitre = 'Listes SHS ' || F1NOM + FROM prod_shs.rhlib_G8P01 + JOIN prod_shs.rhlib_F1P01 ON G8CENT = F1CENT AND G8CETS = F1CETS + WHERE t_listes.code = ('G8P01_' || G8CGRP || '-' || to_char(G8CENT,'FM000') || to_char(G8CETS,'FM000')) AND + ( + texte IS DISTINCT FROM (G8LPAR || ' - ' || F1NOM) OR + chapitre IS DISTINCT FROM ('Listes SHS ' || F1NOM) + ) + ; + + DROP TABLE IF EXISTS w_G8P01_contenu; + CREATE TEMP TABLE w_G8P01_contenu AS + SELECT + t_listes.code AS liste_code, + G8CENT, + G8CETS, + G8CGRP, + G6CRUB::text AS G8RBXX + FROM prod_shs.rhlib_g8p01 + JOIN w_etablissements_select ON XXCENT = G8CENT AND XXCETS = G8CETS + JOIN rh.t_listes ON + 'G8P01_' || G8CGRP || '-' || to_char(G8CENT,'FM000') || to_char(G8CETS,'FM000') = t_listes.code + JOIN prod_shs.rhlib_G6P01 ON 1=1 + AND G6CENT = G8CENT + AND G6CETS = G8CETS + AND ( + G6CRUB BETWEEN G8FRD1 AND G8FRF1 OR + G6CRUB BETWEEN G8FRD2 AND G8FRF2 OR + G6CRUB BETWEEN G8FRD3 AND G8FRF3 OR + G6CRUB BETWEEN G8FRD4 AND G8FRF4 OR + G6CRUB BETWEEN G8FRD5 AND G8FRF5 OR + G6CRUB = G8RB01 OR + G6CRUB = G8RB02 OR + G6CRUB = G8RB03 OR + G6CRUB = G8RB04 OR + G6CRUB = G8RB05 OR + G6CRUB = G8RB06 OR + G6CRUB = G8RB07 OR + G6CRUB = G8RB08 OR + G6CRUB = G8RB09 OR + G6CRUB = G8RB10 OR + G6CRUB = G8RB11 OR + G6CRUB = G8RB12 OR + G6CRUB = G8RB13 OR + G6CRUB = G8RB14 OR + G6CRUB = G8RB15 OR + G6CRUB = G8RB16 OR + G6CRUB = G8RB17 OR + G6CRUB = G8RB18 OR + G6CRUB = G8RB19 OR + G6CRUB = G8RB20 OR + G6CRUB = G8RB21 OR + G6CRUB = G8RB22 OR + G6CRUB = G8RB23 OR + G6CRUB = G8RB24 OR + G6CRUB = G8RB25 OR + G6CRUB = G8RB26 OR + G6CRUB = G8RB27 OR + G6CRUB = G8RB28 OR + G6CRUB = G8RB29 OR + G6CRUB = G8RB30 OR + G6CRUB = G8RB31 OR + G6CRUB = G8RB32 OR + G6CRUB = G8RB33 OR + G6CRUB = G8RB34 OR + G6CRUB = G8RB35 OR + G6CRUB = G8RB36 OR + G6CRUB = G8RB37 OR + G6CRUB = G8RB38 OR + G6CRUB = G8RB39 OR + G6CRUB = G8RB40 OR + G6CRUB = G8RB41 OR + G6CRUB = G8RB42 OR + G6CRUB = G8RB43 OR + G6CRUB = G8RB44 OR + G6CRUB = G8RB45 OR + G6CRUB = G8RB46 OR + G6CRUB = G8RB47 OR + G6CRUB = G8RB48 OR + G6CRUB = G8RB49 OR + G6CRUB = G8RB50 + ) + ; + + UPDATE w_G8P01_contenu + SET G8RBXX = in_code_original + FROM w_cti_rubriques + WHERE G8CENT = XXCENT AND + G8CETS = XXCETS AND + G8RBXX = XXCODO AND + G8RBXX <> in_code_original + ; + + DELETE FROM rh.t_listes_contenu + WHERE liste_id IN (SELECT oid FROM rh.t_listes WHERE code LIKE 'G8P01_%') + ; + + INSERT INTO rh.t_listes_contenu (liste_id, to_id) + SELECT t_listes.oid, t_rubriques.oid + FROM w_G8P01_contenu + JOIN rh.t_listes ON t_listes.code = liste_code + JOIN rh.t_rubriques ON t_rubriques.code_original = G8RBXX + GROUP BY 1,2; + + -- Màj des motifs d'arret + INSERT INTO rh.t_motifs_arret(code, texte, texte_court, code_original) + SELECT DISTINCT + N6MOTA, + N6MOTA, + N6MOTA, + N6MOTA + FROM prod_shs.rhlib_N6P01 + JOIN w_etablissements_select ON XXCENT = N6CENT AND XXCETS = N6CETS + LEFT JOIN rh.t_motifs_arret ON (code_original = N6MOTA) + WHERE 1=1 + AND code_original IS NULL + AND (select valeur = '0' from rh.t_divers where code = 'SHS_MOTIF') + ; + + -- Màj des précisions du motif d'arrêt + DROP TABLE IF EXISTS w_shs_precisions_motif_arret; + CREATE TEMP TABLE w_shs_precisions_motif_arret AS + SELECT + to_number('0' || N0ENTR, '0000') AS XXCENT, + to_number('0' || N0ETAB, '0000') AS XXCETS, + N0CENR::text AS XXCODO, + N0CENR::text AS XXCODE, + N0LIBE AS XXTEXT + FROM prod_shs.rhlib_N0P11 + JOIN w_etablissements_select ON XXCENT = to_number('0' || N0ENTR, '0000') AND XXCETS = to_number('0' || N0ETAB, '0000') + WHERE N0CTAB = 'ATMO' + AND N0TYPE = '2' + ; + + SELECT rh.cti_shs_multicode('w_shs_precisions_motif_arret', 'w_cti_precisions_motif_arret') + ; + + INSERT INTO rh.t_precisions_motif_arret(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + SUBSTR(MAX(in_texte),1,50), + in_code_original + FROM w_cti_precisions_motif_arret + LEFT JOIN rh.t_precisions_motif_arret ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_precisions_motif_arret SET + code = in_code, + texte = in_texte, + texte_court = substr(in_texte,1,50) + FROM w_cti_precisions_motif_arret + WHERE in_code_original = code_original AND + ( + code IS DISTINCT FROM in_code OR + texte IS DISTINCT FROM in_texte OR + texte_court IS DISTINCT FROM substr(in_texte,1,50) + ) + ; + + -- Màj des motifs de visite médicale + INSERT INTO rh.t_motifs_visite(code_original, code, texte, texte_court) + SELECT + N0CENR, + N0CENR, + MAX(N0LIBE), + substr(MAX(N0LIBE), 1, 50) + FROM prod_shs.rhlib_n0p01 + JOIN w_entreprises_select ON XXCENT = to_number('0' || N0ENTR, '0000') + WHERE 1=1 + AND n0ctab = 'MDVI' + AND n0type = '2' + AND N0CENR NOT IN (SELECT code_original FROM rh.t_motifs_visite) + GROUP BY 1,2 + ; + + ]]> + + + + + + + + + + + + = to_char(rhp('rhprovider_start')::date, 'YYYY') + AND (1!=1 + OR F1NBSA <> 0 + OR F1BRUT <> 0 + OR F1NBHR <> 0) + GROUP BY 1,2,3 + ; + + + INSERT INTO rh.p_chiffrier_production (entreprise_id, etablissement_id, mois, nombre_salaries, montant_brut, nombre_heures) + SELECT + t_etablissements.entreprise_id, + t_etablissements.oid AS etablissement_id, + f1DFPA * 100 + f1DFPM AS mois, + 0 AS nombre_contrats, + 0 AS montant_brut, + 0 AS nombre_heures + FROM prod_shs.rhlib_F1P01 + JOIN w_etablissements_select ON XXCENT = F1CENT AND XXCETS = F1CETS + LEFT JOIN rh.t_etablissements ON lpad(F1CENT, 3, '0')||lpad(F1CETS, 3, '0') = t_etablissements.code_original + LEFT JOIN rh.p_chiffrier_production ON 1=1 + AND p_chiffrier_production.entreprise_id = t_etablissements.entreprise_id + AND p_chiffrier_production.etablissement_id = t_etablissements.oid + AND p_chiffrier_production.mois = (f1DFPA * 100 + f1DFPM) + WHERE 1=1 + AND f1DFPA >= to_char(rhp('rhprovider_start')::date, 'YYYY') + AND p_chiffrier_production.entreprise_id IS NULL + GROUP BY 1,2,3 + ; + + ]]> + + + + + + + 0 THEN rh.cti_to_date(F4DC9A, F4DC9M, F4DC9J) ELSE now() END)::date - rh.cti_to_date(F4DC1A, F4DC1M, F4DC1J) + 1 AS duree -- Pour ancienneté iCTI. + FROM prod_shs.rhlib_F4P01 F4P01 + JOIN w_etablissements_select ON XXCENT = F4CENT AND XXCETS = F4CETS + JOIN (select valeur = '0' as calcul_shs from rh.t_divers where code = 'SHS_ANCIENNETE' LIMIT 1) as shs_anciennete ON 1=1 + LEFT JOIN prod_shs.rhlib_g0p01 ON 1=1 + AND F4CENT = G0CENT + AND F4CETS = G0CETS + AND F4SANA = G0SANA + ; + + -- Services multi etablissements ? + UPDATE w_F4P01 + SET F4SRVC_profil = in_code_original + FROM w_cti_services + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4SRVC = XXCODO AND + F4SRVC_profil <> in_code_original + ; + + -- Qualifications multi etablissements ? + UPDATE w_F4P01 + SET F4CQUA_profil = in_code_original + FROM w_cti_qualifications + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4CQUA = XXCODO AND + F4CQUA_profil <> in_code_original + ; + + -- Catégories multi etablissements ? + UPDATE w_F4P01 + SET F4CCSP_profil = in_code_original + FROM w_cti_categories + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4CCSP = XXCODO AND + F4CCSP_profil <> in_code_original + ; + + -- Statuts différents par établissement ? + UPDATE w_F4P01 + SET F4CSTT_profil = in_code_original + FROM w_cti_statuts + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4CSTT = XXCODE AND + F4CSTT_profil <> in_code_original + ; + + -- spéfialités différents par établissement ? + UPDATE w_F4P01 + SET F4SPEC_profil = in_code_original + FROM w_cti_specialites + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4SPEC = XXCODE AND + F4SPEC_profil <> in_code_original + ; + + -- Codes emploi différents par établissement ? + UPDATE w_F4P01 + SET F4CEMP_profil = in_code_original + FROM w_cti_codes_emploi + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4CEMP = XXCODE AND + F4CEMP_profil <> in_code_original + ; + + -- Groupes cotisant différents par établissement ? + UPDATE w_F4P01 + SET F4GCOT_profil = in_code_original + FROM w_cti_groupes_cotisant + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4GCOT = XXCODE AND + F4GCOT_profil <> in_code_original + ; + + -- Sections analytiques différents par établissement ? + UPDATE w_F4P01 + SET F4SANA_profil = in_code_original + FROM w_cti_sections_analytiques_paie + WHERE F4CENT = XXCENT AND + F4CETS = XXCETS AND + F4SANA = XXCODE AND + F4SANA_profil <> in_code_original + ; + + CREATE INDEX w_F4P01_i1 ON w_F4P01 USING btree(F4CMAT) + ; + + + + -- Contrats fictifs + DELETE FROM w_F4P01 + USING + ( + SELECT w_F4P01.ctid + FROM w_F4P01 + LEFT JOIN prod_shs.rhlibH_J0P01 ON + F4CENT = J0CENT AND + F4CETS = J0CETS AND + F4CMAT = J0CMAT AND + F4NCNT = J0NCNT + WHERE F4SUSP = '9' AND + J0CMAT IS NULL + ) SUBVIEW + WHERE w_F4P01.ctid = subview.ctid + ; + + + UPDATE w_F4P01 + SET + F4DC1A = F3DE1A, + F4DC1M = F3DE1M, + F4DC1J = F3DE1J + FROM prod_shs.rhlib_F3P01 + JOIN w_entreprises_select ON XXCENT = F3CENT + WHERE 1=1 + AND F4CENT = F3CENT + AND F4CMAT = F3CMAT + AND F4DC1A = 0 + AND F4DC1M = 0 + AND F4DC1J = 0 + ; + + -- Correction etablissement dans lignes de paie (contrat avec autre etablissement dans f4p01) + DROP TABLE IF EXISTS wh_J0P01 + ; + CREATE TEMP TABLE wh_J0P01 AS + SELECT *, + to_char(J0CENT,'FM000') || to_char(J0CETS,'FM000') || J0CMAT::text || to_char(J0NCNT,'FM0000') || to_char(J0DFPA,'FM0000') || to_char(J0DFPM,'FM00') AS J0SMKEY + FROM prod_shs.rhlibH_J0P01 + JOIN w_etablissements_select ON XXCENT = J0CENT AND XXCETS = J0CETS + WHERE J0DFPA >= to_char(rhp('rhprovider_start')::date, 'YYYY') + ; + + CREATE INDEX wh_J0P01_i1 ON wh_J0P01 USING btree(J0CMAT) + ; + + CREATE INDEX wh_J0P01_i2 ON wh_J0P01 USING btree(J0CRUB) + ; + + CREATE INDEX wh_J0P01_i3 ON wh_J0P01 USING btree(J0NORG) + ; + + CREATE INDEX wh_J0P01_i4 ON wh_J0P01 USING btree(J0SMKEY) + ; + + DROP TABLE IF EXISTS w_J0P01_pbcnt + ; + CREATE TEMP TABLE w_J0P01_pbcnt AS + SELECT + F4P01.F4CENT, + F4P01.F4CMAT, + F4P01.F4NCNT, + min(F4P01.F4CETS) AS F4CETS + FROM wh_J0P01 + JOIN prod_shs.rhlib_F4P01 F4P01 ON 1=1 + AND J0CENT = F4P01.F4CENT + AND J0CMAT = F4P01.F4CMAT + AND J0NCNT = F4P01.F4NCNT + LEFT JOIN prod_shs.rhlib_F4P01 F4P01_2 ON 1=1 + AND J0CENT = F4P01_2.F4CENT + AND J0CETS = F4P01_2.F4CETS + AND J0CMAT = F4P01_2.F4CMAT + AND J0NCNT = F4P01_2.F4NCNT + WHERE 1=1 + AND F4P01_2.F4CMAT IS NULL + GROUP BY 1,2,3 + ; + + UPDATE wh_J0P01 + SET J0CETS = F4CETS, + J0SMKEY = to_char(J0CENT,'FM000') || to_char(F4CETS,'FM000') || J0CMAT::text || to_char(J0NCNT,'FM0000') || to_char(J0DFPA,'FM0000') || to_char(J0DFPM,'FM00') + FROM w_J0P01_pbcnt + WHERE 1=1 + AND J0CENT = F4CENT -- entreprise + AND J0CMAT = F4CMAT -- matricule + AND J0NCNT = F4NCNT -- contrat + ; + + -- #specifique Spécifiques Les Cèdres 984 (on renseigne dans nombre le nombre d'heures à inscrire dans le champ d'HP base). + with coeff as ( + select + t_rubriques.code_original, + t_rubriques.coefficient_nombre + from rh.t_listes + join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + join rh.t_rubriques on t_rubriques.oid = t_listes_contenu.to_id + where t_listes.code = 'CED_FORFAITS') + UPDATE wh_J0P01 SET + J0BASE = coefficient_nombre + FROM coeff + WHERE 1=1 + AND current_database() = 'icti_984' + AND J0CRUB = coeff.code_original + ; + + -- #specifique global I et P à 0.00 : on prend depuis les rubriques d'heures contrat. + with rub_hcnt as ( + select + t_rubriques.code_original + from rh.t_listes + join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid + join rh.t_rubriques on t_rubriques.oid = t_listes_contenu.to_id + where t_listes.code = 'CTI_HCNT' + ) + ,hcnt as ( + select + J0CENT, + J0CETS, + J0CMAT, + J0NCNT, + max(J0BASE) as J0BASE + FROM wh_J0P01 + join rub_hcnt on rub_hcnt.code_original = wh_J0P01.J0CRUB + where current_database() in ('icti_984', 'icti_971') + group by 1,2,3,4) + UPDATE w_F4P01 SET + F4NHRE = J0BASE + FROM hcnt + where 1=1 + and current_database() in ('icti_984', 'icti_971') + AND J0CENT = F4CENT + AND J0CETS = F4CETS + AND J0CMAT = F4CMAT + AND J0NCNT = F4NCNT + and F4CTPS in ('I', 'P') + and F4NHRE = 0 + ; + + -- #specifique 984 par matricule. + UPDATE w_F4P01 SET + F4NHRE = 151.67 + WHERE 1=1 + AND current_database() = 'icti_984' + AND f4cmat = '2398G' + ; + + UPDATE w_F4P01 SET + F4NHRE = 113.75 + WHERE 1=1 + AND current_database() = 'icti_984' + AND f4cmat = '1215W' + ; + + UPDATE wh_J0P01 SET + J0BASE = 113.75 + WHERE 1=1 + AND current_database() = 'icti_984' + AND J0CMAT = '1215W' + AND J0CRUB = '1072' + ; + + UPDATE wh_J0P01 SET + J0BASE = 27.30 + WHERE 1=1 + AND current_database() = 'icti_984' + AND J0CMAT = '2299Z' + AND J0CRUB = '1072' + ; + + UPDATE wh_J0P01 SET + J0BASE = 75.84 + WHERE 1=1 + AND current_database() = 'icti_984' + AND J0CMAT = '1192W' + AND J0CRUB = '1070' + ; + + -- #specifique Spécifiques Archette 162 (on renseigne dans nombre le nombre d'heures à inscrire dans le champ d'HP base). + UPDATE wh_J0P01 SET + J0BASE = 151.67 + WHERE 1=1 + AND current_database() = 'icti_162' + AND J0CRUB = '1011' + ; + + UPDATE wh_J0P01 SET + J0BASE = 60.7 + WHERE 1=1 + AND current_database() = 'icti_162' + AND J0CRUB = '1015' + ; + + -- #specifique INKERMANN : on prend depuis les heures forfait depuis les rubriques les rubriques d'heures contrat. + with id as ( -- idenfication des bulletins avec rubrique 1070. + select J0SMKEY + from wh_J0P01 + where true + AND current_database() = 'icti_848' + and J0CRUB = '1070'), + valeur as ( -- Récupération de la base de la 0099 à intégrer dans celle de la 1070. + select + wh_J0P01.J0BASE, + wh_J0P01.J0SMKEY + from wh_J0P01 + join id on id.J0SMKEY = wh_J0P01.J0SMKEY + where true + AND current_database() = 'icti_848' + and J0CRUB = '0099') + UPDATE wh_J0P01 SET + J0BASE = valeur.J0BASE + FROM valeur + WHERE 1=1 + AND current_database() = 'icti_848' + AND wh_J0P01.J0CRUB = '1070' -- Rubrique de forfait dont la base n'est pas alimentée en heures. + AND wh_J0P01.J0SMKEY = valeur.J0SMKEY + ; + + -- Màj des types de temps de travail + DROP TABLE IF EXISTS w_shs_types_temps_travail + ; + CREATE TEMP TABLE w_shs_types_temps_travail AS + SELECT + XXCENT, + XXCETS, + coalesce(subq.code, N0CENR) AS XXCODO, + coalesce(subq.code, N0CENR) AS XXCODE, + MAX(N0LIBE)||coalesce(subq.libelle, ''::text) AS XXTEXT + FROM prod_shs.rhlib_n0P01 + JOIN w_etablissements_select ON 1=1 + LEFT JOIN (select + F4CTPS, + case when F4CTPS IN ('I', 'P') then F4CTPS||trim(to_char(F4NHRE, '000.00')) else F4CTPS end as code, + ' ' || F4NHRE::text as libelle, + F4CENT, + F4CETS + from w_F4P01 + JOIN w_etablissements_select ON 1=1 + AND XXCENT = F4CENT + AND XXCETS = F4CETS + WHERE F4CTPS IN ('I', 'P') + group by 1,2,3,4,5) as subq on 1=1 + AND subq.F4CTPS = N0CENR + AND subq.F4CENT = XXCENT + AND subq.F4CETS = XXCETS + WHERE 1=1 + AND N0CTAB = 'TTPS' + AND N0TYPE = '2' + GROUP BY 1,2,3,4, subq.libelle + ; + + SELECT rh.cti_shs_multicode('w_shs_types_temps_travail', 'w_cti_types_temps_travail') + ; + + INSERT INTO rh.t_types_temps_travail(code, texte, texte_court, code_original) + SELECT + MAX(in_code), + MAX(in_texte), + MAX(in_texte), + in_code_original + FROM w_cti_types_temps_travail + LEFT JOIN rh.t_types_temps_travail ON (code_original = in_code_original) + WHERE code_original IS NULL + GROUP BY 4 + ; + + UPDATE rh.t_types_temps_travail SET + code = in_code, + texte = in_texte, + texte_court = in_texte + FROM w_cti_types_temps_travail + WHERE 1=1 + AND in_code_original = code_original + AND (1!=1 + OR code IS DISTINCT FROM in_code + OR texte IS DISTINCT FROM in_texte + OR texte_court IS DISTINCT FROM in_texte) + ; + + TRUNCATE rh.p_profils + ; + + ALTER SEQUENCE rh.s_profils RESTART WITH 1 + ; + + INSERT INTO rh.p_profils( + type_contrat_code_original, + type_horaire_code_original, + motif_debut_code_original, + motif_fin_code_original, + qualification_code_original, + service_code_original, + specialite_code_original, + type_temps_travail_code_original, + categorie_socio_professionnelle_code_original, + statut_code_original, + code_emploi_code_original, + societe_interim_code_original, + section_analytique_paie_code_original, + section_analytique_code_original, + grille_code_original, + grille_groupe_code_original, + groupe_cotisant_code_original + ) + SELECT + F4TCNT AS type_contrat_code_original, + F4CTJN AS type_horaire_code_original, + F4MOTD AS motif_debut_code_original, + F4MOTF AS motif_fin_code_original, + F4CQUA_profil AS qualification_code_original, + F4SRVC_profil AS service_code_original, + F4SPEC_profil AS specialite_code_original, + F4CTTT AS type_temps_travail_code_original, + F4CCSP_profil AS categorie_socio_professionnelle_code_original, + F4CSTT_profil AS statut_code_original, + F4CEMP_profil AS code_emploi_code_original, + F4CSOC AS societe_interim_code_original, + F4SANA_profil AS section_analytique_paie_code_original, + F4SCPA AS section_analytique_code_original, + F4GRIE AS grille_code_original, + F4GRPE AS grille_groupe_code_original, + F4GCOT_profil AS groupe_cotisant_code_original + FROM w_F4P01 + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 + ; + + DROP TABLE IF EXISTS w_J0P01_0 + ; + CREATE TEMP TABLE w_J0P01_0 AS + SELECT + J0SMKEY AS J0SMKEY_0, + J0CENT AS J0CENT_0, + J0CETS AS J0CETS_0, + J0CMAT AS J0CMAT_0, + to_char(J0CENT,'FM000')|| J0CMAT AS salarie_code_original, + J0NCNT AS J0NCNT_0, + F4CMATNCNT AS J0CMATNCNT_0, + w_F4P01.code_original AS contrat_code_original, + J0DFPA AS J0DFPA_0, + J0DFPM AS J0DFPM_0, + J0DFPA * 100 + J0DFPM AS mois_paie, + rh.cti_to_date(J0DFPA, J0DFPM, 1::numeric) + interval '1 month' - interval '1 day' AS date_paie, + F4TCNT AS J0TCNT_0, + F4CTJN AS J0CTJN_0, + F4MOTD AS J0MOTD_0, + F4MOTF AS J0MOTF_0, + F4CSOC AS J0CSOC_0, + F4GRIE AS J0GRIE_0, + F4GRPE AS J0GRPE_0, + F4GCOT AS J0GCOT_0, + F4GCOT::text AS J0GCOT_0_profil, + case when F4CTPS IN ('I', 'P') then F4CTPS||trim(to_char(F4NHRE, '000.00')) else F4CTPS end as J0CTTT_0, + CASE WHEN F4CTPS = 'C' THEN 1 ELSE round(F4NHRE / 151.67, 7) END ratio_temps_travail, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CQUA]))[2] AS J0CQUA_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CQUA]))[2]::text AS J0CQUA_0_profil, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0SRVC]))[2] AS J0SRVC_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0SRVC]))[2]::text AS J0SRVC_0_profil, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0SPEC]))[2] AS J0SPEC_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0SPEC]))[2]::text AS J0SPEC_0_profil, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CTPS]))[2] AS J0CTPS_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CCSP]))[2] AS J0CCSP_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CCSP]))[2]::text AS J0CCSP_0_profil, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CSTT]))[2] AS J0CSTT_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CSTT]))[2]::text AS J0CSTT_0_profil, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CEMP]))[2] AS J0CEMP_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0CEMP]))[2]::text AS J0CEMP_0_profil, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0SANA]))[2] AS J0SANA_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),J0SANA]))[2]::text AS J0SANA_0_profil, + ''::text AS J0SCPA_0, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),(rh.cti_to_date(J0DA1A, J0DA1M, J0DA1J))::text]))[2]::date AS date_debut, + (MIN(ARRAY[to_char(J0CRUB,'FM0000'),(rh.cti_to_date(J0DA9A, J0DA9M, J0DA9J))::text]))[2]::date AS date_fin, + 0::bigint AS salarie_id, + 0::bigint AS contrat_id, + 0::bigint AS contrat_mois_id, + 0::bigint AS profil_id, + 'H'::text AS est_historique + FROM wh_J0P01 + LEFT JOIN w_F4P01 ON 1=1 + AND J0CENT = F4CENT + AND J0CETS = F4CETS + AND J0CMAT = F4CMAT + AND J0NCNT = F4NCNT + WHERE 1=1 + AND J0CRUB >= 5 + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 + ; + + + INSERT INTO w_J0P01_0 + SELECT + to_char(F9CENT,'FM000') || to_char(F9CETS,'FM000') || F9CMAT::text || to_char(F9NCNT,'FM0000') || to_char(F1DFPA,'FM0000') || to_char(F1DFPM,'FM00') AS J0SMKEY_0, + F9CENT AS J0CENT_0, + F9CETS AS J0CETS_0, + F9CMAT AS J0CMAT_0, + to_char(F9CENT,'FM000')|| F9CMAT AS salarie_code_original, + F9NCNT AS J0NCNT_0, + F4CMATNCNT AS J0CMATNCNT_0, + w_F4P01.code_original AS contrat_code_original, + F1DFPA AS J0DFPA_0, + F1DFPM AS J0DFPM_0, + F1DFPA * 100 + F1DFPM AS mois_paie, + rh.cti_to_date(F1DFPA, F1DFPM, 1::numeric) + interval '1 month' - interval '1 day' AS date_paie, + F4TCNT AS J0TCNT_0, + F4CTJN AS J0CTJN_0, + F4MOTD AS J0MOTD_0, + F4MOTF AS J0MOTF_0, + F4CSOC AS J0CSOC_0, + F4GRIE AS J0GRIE_0, + F4GRPE AS J0GRPE_0, + F4GCOT AS J0GCOT_0, + F4GCOT AS J0GCOT_0_profil, + case when F4CTPS IN ('I', 'P') then F4CTPS||trim(to_char(F4NHRE, '000.00')) else F4CTPS end as J0CTTT_0, + CASE WHEN F4CTPS = 'C' THEN 1 ELSE round(F4NHRE / 151.67, 7) END ratio_temps_travail, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CQUA]))[2] AS J0CQUA_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CQUA]))[2] AS J0CQUA_0_profil, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9SRVC]))[2] AS J0SRVC_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9SRVC]))[2] AS J0SRVC_0_profil, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9SPEC]))[2] AS J0SPEC_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9SPEC]))[2] AS J0SPEC_0_profil, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CTPS]))[2] AS J0CTPS_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CCSP]))[2] AS J0CCSP_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CCSP]))[2] AS J0CCSP_0_profil, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CSTT]))[2] AS J0CSTT_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CSTT]))[2] AS J0CSTT_0_profil, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CEMP]))[2] AS J0CEMP_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9CEMP]))[2] AS J0CEMP_0_profil, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9SANA]))[2] AS J0SANA_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),F9SANA]))[2] AS J0SANA_0_profil, + ''::text AS J0SCPA_0, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),(rh.cti_to_date(F9DA1A, F9DA1M, F9DA1J))::text]))[2]::date AS date_debut, + (MIN(ARRAY[to_char(F9CRUB,'FM0000'),(rh.cti_to_date(F9DA9A, F9DA9M, F9DA9J))::text]))[2]::date AS date_fin, + 0::bigint AS salarie_id, + 0::bigint AS contrat_id, + 0::bigint AS contrat_mois_id, + 0::bigint AS profil_id, + ''::text AS est_historique + FROM prod_shs.rhlib_F9P01 + JOIN w_etablissements_select ON XXCENT = F9CENT AND XXCETS = F9CETS + JOIN prod_shs.rhlib_F1P01 ON 1=1 + AND F9CENT = F1CENT + AND F9CETS = F1CETS + LEFT JOIN w_F4P01 ON 1=1 + AND F9CENT = F4CENT + AND F9CETS = F4CETS + AND F9CMAT = F4CMAT + AND F9NCNT = F4NCNT + WHERE 1=1 + AND F9CRUB >= 5 + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 + ; + + CREATE INDEX w_J0P01_0_i1 ON w_J0P01_0 USING btree (J0CMAT_0) + ; + CREATE INDEX w_J0P01_0_i2 ON w_J0P01_0 USING btree (salarie_code_original) + ; + CREATE INDEX w_J0P01_0_i3 ON w_J0P01_0 USING btree (J0SMKEY_0) + ; + + UPDATE w_J0P01_0 + SET + salarie_id = p_salaries.oid + FROM rh.p_salaries + WHERE salarie_code_original = p_salaries.code_original + ; + + UPDATE w_J0P01_0 + SET J0SCPA_0 = G0SCPA + FROM prod_shs.rhlib_g0p01 + WHERE 1=1 + AND J0CENT_0 = G0CENT + AND J0CETS_0 = G0CETS + AND J0SANA_0 = G0SANA + ; + + -- Services multi etablissements ? + UPDATE w_J0P01_0 + SET J0SRVC_0_profil = in_code_original + FROM w_cti_services + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0SRVC_0 = XXCODO AND + J0SRVC_0_profil <> in_code_original + ; + + -- Qualifications multi etablissements ? + UPDATE w_J0P01_0 + SET J0CQUA_0_profil = in_code_original + FROM w_cti_qualifications + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0CQUA_0 = XXCODO AND + J0CQUA_0_profil <> in_code_original + ; + + -- Catégories multi etablissements ? + UPDATE w_J0P01_0 + SET J0CCSP_0_profil = in_code_original + FROM w_cti_categories + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0CCSP_0 = XXCODO AND + J0CCSP_0_profil <> in_code_original + ; + + -- Statuts différents par établissement ? + UPDATE w_J0P01_0 + SET J0CSTT_0_profil = in_code_original + FROM w_cti_statuts + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0CSTT_0 = XXCODE AND + J0CSTT_0_profil <> in_code_original + ; + + -- Spécialités différents par établissement ? + UPDATE w_J0P01_0 + SET J0SPEC_0_profil = in_code_original + FROM w_cti_specialites + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0SPEC_0 = XXCODE AND + J0SPEC_0_profil <> in_code_original + ; + + -- Codes emplois différents par établissement ? + UPDATE w_J0P01_0 + SET J0CEMP_0_profil = in_code_original + FROM w_cti_codes_emploi + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0CEMP_0 = XXCODE AND + J0CEMP_0_profil <> in_code_original + ; + + -- Groupes cotisants différents par établissement ? + UPDATE w_J0P01_0 + SET J0GCOT_0_profil = in_code_original + FROM w_cti_groupes_cotisant + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0GCOT_0 = XXCODE AND + J0GCOT_0_profil <> in_code_original + ; + + -- Sections analytiques différents par établissement ? + UPDATE w_J0P01_0 + SET J0SANA_0_profil = in_code_original + FROM w_cti_sections_analytiques_paie + WHERE J0CENT_0 = XXCENT AND + J0CETS_0 = XXCETS AND + J0SANA_0 = XXCODE AND + J0SANA_0_profil <> in_code_original + ; + + INSERT INTO rh.p_profils( + type_contrat_code_original, + type_horaire_code_original, + motif_debut_code_original, + motif_fin_code_original, + qualification_code_original, + service_code_original, + specialite_code_original, + type_temps_travail_code_original, + categorie_socio_professionnelle_code_original, + statut_code_original, + code_emploi_code_original, + societe_interim_code_original, + section_analytique_paie_code_original, + section_analytique_code_original, + grille_code_original, + grille_groupe_code_original, + groupe_cotisant_code_original + ) + SELECT + J0TCNT_0 AS type_contrat_code_original, + J0CTJN_0 AS type_horaire_code_original, + J0MOTD_0 AS motif_debut_code_original, + J0MOTF_0 AS motif_fin_code_original, + J0CQUA_0_profil AS qualification_code_original, + J0SRVC_0_profil AS service_code_original, + J0SPEC_0_profil AS specialite_code_original, + J0CTTT_0 AS type_temps_travail_code_original, + J0CCSP_0_profil AS categorie_socio_professionnelle_code_original, + J0CSTT_0_profil AS statut_code_original, + J0CEMP_0_profil AS code_emploi_code_original, + J0CSOC_0 AS societe_interim_code_original, + J0SANA_0_profil AS section_analytique_paie_code_original, + J0SCPA_0 AS section_analytique_code_original, + J0GRIE_0 AS grille_code_original, + J0GRPE_0 AS grille_groupe_code_original, + J0GCOT_0_profil AS groupe_cotisant_code_original + FROM w_J0P01_0 + LEFT JOIN rh.p_profils ON 1=1 + AND J0TCNT_0 = type_contrat_code_original + AND J0CTJN_0 = type_horaire_code_original + AND J0MOTD_0 = motif_debut_code_original + AND J0MOTF_0 = motif_fin_code_original + AND J0CQUA_0_profil = qualification_code_original + AND J0SRVC_0_profil = service_code_original + AND J0SPEC_0_profil = specialite_code_original + AND J0CTTT_0 = type_temps_travail_code_original + AND J0CCSP_0_profil = categorie_socio_professionnelle_code_original + AND J0CSTT_0_profil = statut_code_original + AND J0CEMP_0_profil = code_emploi_code_original + AND J0CSOC_0 = societe_interim_code_original + AND J0SANA_0_profil = section_analytique_paie_code_original + AND J0SCPA_0 = section_analytique_code_original + AND J0GRIE_0 = grille_code_original + AND J0GRPE_0 = grille_groupe_code_original + AND J0GCOT_0_profil = groupe_cotisant_code_original + WHERE p_profils.oid IS NULL + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 + ; + + UPDATE w_J0P01_0 + SET profil_id = p_profils.oid + FROM rh.p_profils + WHERE 1=1 + AND J0TCNT_0 = type_contrat_code_original + AND J0CTJN_0 = type_horaire_code_original + AND j0MOTD_0 = motif_debut_code_original + AND j0MOTF_0 = motif_fin_code_original + AND J0CQUA_0_profil = qualification_code_original + AND J0SRVC_0_profil = service_code_original + AND J0SPEC_0_profil = specialite_code_original + AND J0CTTT_0 = type_temps_travail_code_original + AND J0CCSP_0_profil = categorie_socio_professionnelle_code_original + AND J0CSTT_0_profil = statut_code_original + AND J0CEMP_0_profil = code_emploi_code_original + AND J0CSOC_0 = societe_interim_code_original + AND J0SANA_0_profil = section_analytique_paie_code_original + AND J0SCPA_0 = section_analytique_code_original + AND J0GRIE_0 = grille_code_original + AND J0GRPE_0 = grille_groupe_code_original + AND J0GCOT_0_profil = groupe_cotisant_code_original + ; + + ]]> + + + 0 THEN rh.cti_to_date(F4DC9A, F4DC9M, F4DC9J) ELSE '20991231' END AS date_fin, + F4CMATNCNT AS numero_contrat, + COALESCE(t_etablissements.oid,0) AS etablissement_id, + p_profils.oid AS profil_id, + -- Dans le cas où SHS_ANCIENNETE est à 0 (calcul SHS), F4MAXX et F4JMAXX sont bien renseignés. + -- Sinon ils sont à -1 ce qui signifie qu'anciennete_anterieure_mois/jours seront toujours à 0. + -- Et cela ne permturbera pas le mode de calcul iCTI lors de la ventilation par mois des contrats. + CASE WHEN F4MAXX/12 BETWEEN 0 AND 50 THEN F4MAXX ELSE 0 END AS anciennete_anterieure_mois, + CASE WHEN F4MAXX/12 BETWEEN 0 AND 50 THEN F4JAXX ELSE 0 END AS anciennete_anterieure_jours + FROM w_F4P01 + JOIN rh.t_etablissements ON lpad(F4CENT, 3, '0')||lpad(F4CETS, 3, '0') = t_etablissements.code_original + JOIN rh.p_salaries ON w_F4P01.salarie_code_original = p_salaries.code_original + JOIN rh.p_profils ON 1=1 + AND F4TCNT = type_contrat_code_original + AND F4CTJN = type_horaire_code_original + AND F4MOTD = motif_debut_code_original + AND F4MOTF = motif_fin_code_original + AND F4CQUA_profil = qualification_code_original + AND F4SRVC_profil = service_code_original + AND F4SPEC_profil = specialite_code_original + AND F4CTTT = type_temps_travail_code_original + AND F4CCSP_profil = categorie_socio_professionnelle_code_original + AND F4CSTT_profil = statut_code_original + AND F4CEMP_profil = code_emploi_code_original + AND F4CSOC = societe_interim_code_original + AND F4SANA_profil = section_analytique_paie_code_original + AND F4SCPA = section_analytique_code_original + AND F4GRIE = grille_code_original + AND F4GRPE = grille_groupe_code_original + AND F4GCOT_profil = groupe_cotisant_code_original + LEFT JOIN rh.p_contrats ON w_F4P01.code_original = p_contrats.code_original + WHERE p_contrats.oid IS NULL + ; + + -- #correction Correction de l'ancienneté SHS antérieure. + UPDATE rh.p_contrats SET + anciennete_anterieure_mois = 0, + anciennete_anterieure_jours = 0 + FROM rh.p_salaries + WHERE 1=1 + AND salarie_id = p_salaries.oid + AND ((p_contrats.date_debut - date_naissance) / 30) - anciennete_anterieure_mois < 150 + ; + + -- #correction @todo : à mettre soit dans un t_divers + expert. + -- Si les dates d'entrée/sortie d'établissement semblent incohérentes par rapports aux dates des contrats, les corriger. + UPDATE rh.p_salaries + SET date_entree_ets = date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND date_entree_ets > date_debut_contrat + ; + + -- #correction @todo : à mettre soit dans un t_divers + expert. + UPDATE rh.p_salaries + SET date_entree_ets = date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND to_char(date_entree_ets, 'YYYY')::numeric >= 2009 + AND date_entree_ets < date_debut_contrat + ; + + -- #correction @todo : à mettre soit dans un t_divers + expert. + UPDATE rh.p_salaries + SET date_sortie_ets = date_fin_contrat + FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND p_salaries.oid = s.salarie_id + AND date_fin_contrat > date_sortie_ets + ; + + UPDATE rh.p_salaries + SET date_entree_ets = s.date_debut_contrat + FROM (SELECT salarie_id, min(date_debut) AS date_debut_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND (select valeur = '1' from rh.t_divers where code = 'CORRECTION_DE_ETS' LIMIT 1) + AND p_salaries.oid = s.salarie_id + AND p_salaries.date_entree_ets != s.date_debut_contrat + AND date_entree_ets = '1900-01-01'::date -- uniquement pour les salariés où la date n'est pas renseignée. + ; + + UPDATE rh.p_salaries + SET date_sortie_ets = s.date_fin_contrat + FROM (SELECT salarie_id, max(date_fin) AS date_fin_contrat from rh.p_contrats group by 1) AS s + WHERE 1=1 + AND (select valeur = '1' from rh.t_divers where code = 'CORRECTION_DS_ETS' LIMIT 1) + AND p_salaries.oid = s.salarie_id + AND p_salaries.date_sortie_ets != s.date_fin_contrat + AND p_salaries.date_sortie_ets = '2099-12-31'::date -- uniquement pour les salariés où la date n'est pas renseignée. + ; + + -- Màj des salariés. + UPDATE rh.p_salaries + SET + date_debut = subview.date_debut, + date_fin = subview.date_fin, + profil_id = subview.profil_id + FROM + ( + SELECT salarie_id, + MIN(date_debut) AS date_debut, + MAX(date_fin) AS date_fin, + ((base.cti_last(ARRAY[p_contrats.date_fin::text, p_contrats.profil_id::text]))[2])::bigint As profil_id + FROM rh.p_contrats + GROUP BY salarie_id + ) AS subview + WHERE 1=1 + AND p_salaries.oid = subview.salarie_id + AND (1!=1 + OR p_salaries.date_debut IS DISTINCT FROM subview.date_debut + OR p_salaries.date_fin IS DISTINCT FROM subview.date_fin + OR p_salaries.profil_id IS DISTINCT FROM subview.profil_id + ) + ; + + -- Calcul ancienneté SHS. + -- Pas la peine d'alimenter comme dans les autres cas (SHS_ANCIENNETE à 1 ou 2) les 2 champs + -- anciennete_anterieure_jours et anciennete_anterieure_mois car ils sont déjà bien alimentés + -- dans le INSERT INTO rh.p_contrats plus haut. + UPDATE rh.p_contrats SET + anciennete_anterieure_calculee_mois = COALESCE(( + SELECT floor(SUM(p_contrats_anterieurs.date_fin - p_contrats_anterieurs.date_debut + 1) / 30) + FROM rh.p_contrats p_contrats_anterieurs + WHERE p_contrats_anterieurs.salarie_id = p_contrats.salarie_id AND p_contrats_anterieurs.date_fin < p_contrats.date_debut + ), 0), + anciennete_anterieure_calculee_jours = COALESCE(( + SELECT floor(SUM(p_contrats_anterieurs.date_fin - p_contrats_anterieurs.date_debut + 1)) + FROM rh.p_contrats p_contrats_anterieurs + WHERE p_contrats_anterieurs.salarie_id = p_contrats.salarie_id AND p_contrats_anterieurs.date_fin < p_contrats.date_debut + ), 0) + WHERE (select valeur = '0' from rh.t_divers where code = 'SHS_ANCIENNETE' LIMIT 1) + ; + + -- Calcul ancienneté iCTI (au début de contrat). + UPDATE rh.p_contrats SET + anciennete_anterieure_jours = subq.anciennete_jours, + anciennete_anterieure_calculee_jours = subq.anciennete_jours, + anciennete_anterieure_mois = subq.anciennete_mois, + anciennete_anterieure_calculee_mois = subq.anciennete_mois + FROM ( + SELECT + t1.code_original, + sum(t2.duree) AS anciennete_jours, + sum(t2.duree) / 30 AS anciennete_mois + FROM w_F4P01 AS t1 + JOIN w_F4P01 AS t2 ON 1=1 + AND t2.f4cent = t1.f4cent + AND t2.f4cmat = t1.f4cmat + AND t2.f4ncnt < t1.f4ncnt + group by 1 + ) AS subq + WHERE 1=1 + AND p_contrats.code_original = subq.code_original + AND anciennete_anterieure_calculee_jours != subq.anciennete_jours + AND (select valeur = '1' from rh.t_divers where code = 'SHS_ANCIENNETE' LIMIT 1) + ; + + -- Calcul ancienneté iCTI (par rapport à date de début d'entrée ets. SHS sans prendre en compte les contrats). + with anciennete_2 as ( + select + p_contrats.oid as contrat_id, + greatest(coalesce(p_contrats.date_debut - p_salaries.date_anciennete, 0), 0) as anciennete_jours, + greatest(round(coalesce(p_contrats.date_debut - p_salaries.date_anciennete, 0) / 30.0), 0) as anciennete_mois + from rh.p_contrats + join rh.p_salaries on p_salaries.oid = p_contrats.salarie_id) + UPDATE rh.p_contrats SET + anciennete_anterieure_jours = anciennete_2.anciennete_jours, + anciennete_anterieure_calculee_jours = anciennete_2.anciennete_jours, + anciennete_anterieure_mois = anciennete_2.anciennete_mois, + anciennete_anterieure_calculee_mois = anciennete_2.anciennete_mois + FROM anciennete_2 + WHERE 1=1 + AND p_contrats.oid = anciennete_2.contrat_id + AND anciennete_anterieure_calculee_jours != anciennete_2.anciennete_jours + AND (select valeur = '2' from rh.t_divers where code = 'SHS_ANCIENNETE' LIMIT 1) + ; + + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, + present_debut_mois, + present_fin_mois, + equivalent_temps_plein, + nombre_heures, + ratio_temps_travail, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id + ) + SELECT + p_salaries.oid AS salarie_id, + p_contrats.oid AS contrat_id, + p_calendrier_mois.mois AS mois, + GREATEST(p_calendrier_mois.date_debut, p_contrats.date_debut) AS date_debut, + LEAST(p_calendrier_mois.date_fin, p_contrats.date_fin) AS date_fin, + CASE WHEN p_salaries.date_entree_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_entrees, + CASE WHEN p_salaries.date_sortie_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_departs, + CASE WHEN p_contrats.date_debut BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_contrat, + CASE WHEN p_contrats.date_fin BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_contrat, + '0' AS est_hors_periode, + CASE WHEN p_calendrier_mois.date_debut BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_debut_mois, + CASE WHEN p_calendrier_mois.date_fin BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + CASE WHEN F4CTPS = 'C' THEN 1 ELSE round(F4NHRE / 151.67,7) END AS equivalent_temps_plein, -- FIXME Prendre depuis la rubrique 1000 + CASE WHEN F4CTPS = 'C' THEN 151.67 ELSE F4NHRE END as nombre_heures, -- FIXME prendre depuis la rubrique 1000 + CASE WHEN F4CTPS = 'C' THEN 1 ELSE round(F4NHRE / 151.67,7) END ratio_temps_travail, + base.cti_age(LEAST(p_calendrier_mois.date_fin, p_contrats.date_fin), p_salaries.date_naissance, 'ny') AS age_id, + LEAST(p_calendrier_mois.date_fin, p_contrats.date_fin)::date - p_salaries.date_naissance AS age_jours, + (least(p_calendrier_mois.date_fin, p_contrats.date_fin) - p_contrats.date_debut) + + greatest(p_contrats.anciennete_anterieure_jours, p_contrats.anciennete_anterieure_calculee_jours) + + 1 + AS anciennete_jours, + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + greatest(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + AS anciennete_mois, + floor( + ( + base.cti_months_between(p_contrats.date_debut, p_calendrier_mois.date_fin) + + greatest(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + ) / 12 + ) AS anciennete_annee_id + FROM rh.p_contrats + JOIN rh.p_salaries ON (p_contrats.salarie_id = p_salaries.oid) + JOIN rh.t_etablissements ON p_contrats.etablissement_id = t_etablissements.oid + JOIN rh.t_entreprises ON t_etablissements.entreprise_id = t_entreprises.oid + JOIN w_F4P01 ON 1=1 + AND p_contrats.code_original = w_F4P01.code_original + AND lpad(F4CENT, 3, '0') = t_entreprises.code_original + JOIN prod_shs.rhlib_F1P01 ON lpad(F1CENT, 3, '0')||lpad(F1CETS, 3, '0') = t_etablissements.code_original + JOIN base.p_calendrier_mois ON 1=1 + AND p_contrats.date_debut <= p_calendrier_mois.date_fin + AND p_contrats.date_fin >= p_calendrier_mois.date_debut + WHERE 1=1 + AND p_calendrier_mois.mois >= to_char(rhp('rhprovider_start')::date, 'YYYYMM') + AND p_calendrier_mois.mois <= (F1DFPA * 100 + F1DFPM) + ORDER BY numero_contrat, p_calendrier_mois.mois + ; + + -- Affection du contrat_id nouvelle créé à la table temp des paies (version contrat _0). + UPDATE w_J0P01_0 + SET contrat_id = p_contrats.oid + FROM rh.p_contrats + WHERE contrat_code_original = p_contrats.code_original + ; + + -- Le n° de contrat a disparu (remplacé par un autre) + UPDATE w_J0P01_0 + SET contrat_id = p_contrats.oid + FROM rh.p_salaries + JOIN rh.p_contrats ON p_salaries.oid = p_contrats.salarie_id + WHERE 1=1 + AND w_J0P01_0.contrat_id = 0 + AND salarie_code_original = p_salaries.code_original + AND w_J0P01_0.date_debut BETWEEN p_contrats.date_debut AND p_contrats.date_fin + ; + + UPDATE w_J0P01_0 + SET contrat_id = p_contrats.oid + FROM rh.p_salaries + JOIN rh.p_contrats ON p_salaries.oid = p_contrats.salarie_id + WHERE 1=1 + AND w_J0P01_0.contrat_id = 0 + AND salarie_code_original = p_salaries.code_original + AND w_J0P01_0.date_fin BETWEEN p_contrats.date_debut AND p_contrats.date_fin + ; + + -- Màj du contrat_mois_id. + UPDATE w_J0P01_0 + SET contrat_mois_id = p_contrats_mois.oid + FROM rh.p_contrats_mois + WHERE 1=1 + AND contrat_mois_id = 0 + AND w_J0P01_0.contrat_id = p_contrats_mois.contrat_id + AND mois_paie = p_contrats_mois.mois_activite + ; + + INSERT INTO rh.p_contrats_mois( + contrat_id, + salarie_id, + mois_activite, + date_debut, + date_fin, + nombre_debut_contrat, + nombre_fin_contrat, + equivalent_temps_plein, + nombre_heures, + ratio_temps_travail, + age_id, + age_jours, + est_hors_periode, + present_fin_mois, + anciennete_jours, + anciennete_mois, + anciennete_annee_id) + SELECT + contrat_id, + p_contrats.salarie_id, + mois_paie AS mois_activite, + GREATEST(w_J0P01_0.date_debut, date(date_trunc('month',w_J0P01_0.date_fin))) AS date_debut, + w_J0P01_0.date_fin, + 0 AS nombre_debut_contrat, + 0 AS nombre_fin_contrat, + 0 AS equivalent_temps_plein, + 0 as nombre_heures, + ratio_temps_travail, + base.cti_age(w_J0P01_0.date_fin, p_salaries.date_naissance, 'ny') AS age_id, + w_J0P01_0.date_fin::date - p_salaries.date_naissance AS age_jours, + '1' AS est_hors_periode, + 0 AS present_fin_mois, + (w_J0P01_0.date_fin::date - p_contrats.date_debut::date) + + + p_contrats.anciennete_anterieure_jours + + 1 + AS anciennete_jours, + base.cti_age( + date_trunc('month',w_J0P01_0.date_fin)::date, + date_trunc('month',p_contrats.date_debut)::date, + 'nm' + ) + + + GREATEST( + p_contrats.anciennete_anterieure_mois, + p_contrats.anciennete_anterieure_calculee_mois + ) + 1 + AS anciennete_mois, + floor((base.cti_age(date_trunc('month',w_J0P01_0.date_fin::date)::date, date_trunc('month',p_contrats.date_debut)::date, 'nm') + + GREATEST(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + 1) / 12) AS anciennete_annee_id + FROM w_J0P01_0 + JOIN rh.p_salaries ON w_J0P01_0.salarie_id = p_salaries.oid + JOIN rh.p_contrats ON w_J0P01_0.contrat_id = p_contrats.oid + WHERE contrat_mois_id = 0 + ; + + UPDATE w_J0P01_0 + SET contrat_mois_id = p_contrats_mois.oid + FROM rh.p_contrats_mois + WHERE 1=1 + AND contrat_mois_id = 0 + AND w_J0P01_0.contrat_id = p_contrats_mois.contrat_id + AND mois_paie = p_contrats_mois.mois_activite + ; + + UPDATE w_J0P01_0 + SET contrat_mois_id = p_contrats_mois.oid + FROM rh.p_contrats_mois + WHERE 1=1 + AND contrat_mois_id = 0 + AND w_J0P01_0.contrat_id = p_contrats_mois.contrat_id + AND mois_paie = p_contrats_mois.mois_activite + ; + + -- Salariés remplacés + DROP TABLE IF EXISTS w_remplacements + ; + CREATE TEMP TABLE w_remplacements AS + SELECT + p_contrats.oid AS contrat_id, + (MIN(Array[to_char(F5NLIG,'FM000'), p_salaries.oid::text]))[2]::bigint AS salarie_remplace_id + FROM rh.p_contrats + JOIN prod_shs.rhlib_F5P01 ON 1=1 + AND p_contrats.code_original = to_char(F5CENT,'FM000') || to_char(F5CETS,'FM000') || F5CMAT || '-' || to_char(F5NCNT,'FM000') + AND F5NLIG = 1 + JOIN w_etablissements_select ON XXCENT = F5CENT AND XXCETS = F5CETS + JOIN rh.p_salaries ON (to_char(F5CENT,'FM000') || F5AMAT) = p_salaries.code_original + WHERE 1=1 + AND F5AMAT IN ( + SELECT F4CMAT + FROM prod_shs.rhlib_F4P01 + JOIN w_etablissements_select ON XXCENT = F4CENT AND XXCETS = F4CETS + WHERE F4SUSP <> 9 ) + GROUP BY 1 + ; + + UPDATE rh.p_contrats + SET salarie_remplace_id = w_remplacements.salarie_remplace_id + FROM w_remplacements + WHERE 1=1 + AND p_contrats.oid = w_remplacements.contrat_id + AND p_contrats.salarie_remplace_id IS DISTINCT FROM w_remplacements.salarie_remplace_id + ; + + UPDATE rh.p_contrats + SET salarie_remplace_id = 0 + WHERE 1=1 + AND salarie_remplace_id IS DISTINCT FROM 0 + AND oid NOT IN (SELECT contrat_id FROM w_remplacements) + ; + + -- Contrats suspendus + UPDATE rh.p_contrats_mois + SET + est_hors_periode = CASE WHEN subq.present_debut_mois = 0 AND subq.present_fin_mois = 0 THEN 1 ELSE 0 END, + present_debut_mois = subq.present_debut_mois, + present_fin_mois = subq.present_fin_mois + FROM ( + SELECT + p_calendrier_mois.mois, + p_contrats.oid AS contrat_id, + CASE WHEN p_calendrier_mois.date_debut >= rh.cti_to_date(f4ddsa,f4ddsm,f4ddsj)::date then 1 else 0 end AS present_debut_mois, + CASE WHEN p_calendrier_mois.date_fin <= rh.cti_to_date(f4dfsa,f4dfsm,f4dfsj)::date then 1 else 0 end AS present_fin_mois + FROM w_F4P01 + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_F4P01.code_original + JOIN base.p_calendrier_mois ON base.cti_overlaps( + p_calendrier_mois.date_debut, + p_calendrier_mois.date_fin, + rh.cti_to_date(f4ddsa,f4ddsm,f4ddsj)::date, + rh.cti_to_date(f4dfsa,f4dfsm,f4dfsj)::date) + WHERE 1=1 + AND f4susp != 0 -- qui a un motif de suspension renseigné + GROUP BY 1,2,3,4 + ) AS subq + WHERE 1=1 + AND p_contrats_mois.contrat_id = subq.contrat_id + AND p_contrats_mois.mois_activite = subq.mois + ; + + -- Pour info : trouver l'"effectif inscrit" : + /* + + select f4tcnt,count(* ) + from prod_shs.piprso226_f4p01 + where 1=1 + and '2005-11-30'::date between (f4dc1a::text||'-'||f4dc1m::text||'-'||f4dc1j::text)::date and (case when (f4dc9a::text||f4dc9m::text||f4dc9j::text) = '000' then '2099-12-31' else (f4dc9a::text||'-'||f4dc9m::text||'-'||f4dc9j::text) end)::date + and case when f4susp != 0 then ('2005-11-30'::date not between (f4ddsa||'-'||f4ddsm||'-'||f4ddsj)::date and (f4dfsa||'-'||f4dfsm||'-'||f4dfsj)::date) else true end + and f4cets = 0 + and f4cent = 0 + group by 1 + order by 1 + + -- Correction date depart non saisie selon code sortie et date dernier contrat + UPDATE rh.p_salaries + SET date_sortie_ets = subview.date_sortie_ets + FROM + ( + SELECT p_salaries.oid, MAX(p_contrats.date_fin) AS date_sortie_ets + FROM rh.p_salaries + JOIN rh.p_contrats ON p_contrats.salarie_id = p_salaries.oid + JOIN prod_shs.rhlib_F3P01 ON p_salaries.code_original = (to_char(F3CENT,'FM000')||F3CMAT) AND F3CPST = '1' + WHERE date_sortie_ets = '20991231' + GROUP BY 1 + ) subview + WHERE p_salaries.oid = subview.oid + + */ + + DROP TABLE IF EXISTS w_departs + ; + + CREATE TEMP TABLE w_departs AS + SELECT + F3CMAT, + p_salaries.oid AS salarie_id, + (MAX(ARRAY[p_contrats_mois.date_fin::text, p_contrats_mois.oid::text]))[2]::bigint AS oid + FROM rh.p_contrats_mois + JOIN rh.p_contrats ON p_contrats_mois.contrat_id = p_contrats.oid AND nombre_fin_contrat = 1 + JOIN rh.p_salaries ON p_contrats.salarie_id = p_salaries.oid + JOIN prod_shs.rhlib_F3P01 ON p_salaries.code_original = (to_char(F3CENT,'FM000')||F3CMAT) AND F3CPST = '1' + JOIN w_entreprises_select ON XXCENT = F3CENT + WHERE 1=1 + AND rh.cti_to_date(F3DS9A, F3DS9M, F3DS9J) >= p_contrats_mois.date_fin + GROUP BY 1,2 + ; + + UPDATE rh.p_contrats_mois + SET nombre_departs = 1 + FROM w_departs + WHERE p_contrats_mois.oid = w_departs.oid + ; + + ]]> + + + 9000) THEN 0 - j0mont ELSE 0 END AS montant_cotisation_salarie, + CASE WHEN j0chap = '20' THEN j0tpat ELSE 0 END AS taux_cotisation_patronale, + CASE WHEN j0chap = '20' OR t_rubriques.code_calcul = '8' THEN j0mpat ELSE 0 END AS montant_cotisation_patronale, + CASE + WHEN j0chap = '20' AND (j0crub BETWEEN 7000 AND 8999 OR j0crub > 9000) THEN 0 - j0mont + WHEN j0chap = '30' THEN 0 - j0mont + ELSE 0 + END AS montant_od_net_salarie, + CASE WHEN t_rubriques.code_calcul = '7' THEN j0mpat ELSE 0 END + + CASE + WHEN j0chap = '10' THEN j0mont + WHEN j0chap = '20' AND (j0crub BETWEEN 4000 AND 6999 OR j0crub > 9000) THEN j0mont + ELSE 0 + END AS montant_net_imposable_salarie, + CASE + WHEN j0chap = '10' AND (CASE WHEN rhp('opt_avt_nature') = '1' THEN (J0CRUB NOT BETWEEN 3000 AND 3499) ELSE true END) THEN j0mont + WHEN j0chap = '20' THEN j0mont + WHEN j0chap = '30' THEN j0mont + ELSE 0 + END AS montant_net_a_payer_salarie + FROM wh_J0P01 -- Historique de paie des mois clôturés + JOIN w_J0P01_0 ON 1=1 + AND wh_J0P01.J0SMKEY = w_J0P01_0.J0SMKEY_0 + AND est_historique = 'H' + JOIN w_cti_rubriques ON + J0CENT = w_cti_rubriques.XXCENT AND + J0CETS = w_cti_rubriques.XXCETS AND + J0CRUB = w_cti_rubriques.XXCODO + JOIN rh.t_rubriques ON t_rubriques.code_original = w_cti_rubriques.in_code_original + LEFT JOIN w_cti_organismes_cotisation ON + J0CENT = w_cti_organismes_cotisation.XXCENT AND + J0CETS = w_cti_organismes_cotisation.XXCETS AND + J0NORG = w_cti_organismes_cotisation.XXCODO + WHERE wh_J0P01.j0dfpa >= to_char(rhp('rhprovider_start')::date, 'YYYY') + ; + + + -- La table principale pour les mois non clotures est F9P01 mais il peut aussi y avoir quelques rubriques dans F6P01 + -- F6CGEN = '6' et F6MONT > 0 sont des garde-fous + DROP TABLE IF EXISTS w_F69P01; CREATE TEMP TABLE w_F69P01 AS + ( + SELECT + F9BASE, + F9CENT, + F9CETS, + F9CHAP, + F9CMAT, + F9CRUB, + F9MONT, + F9MPAT, + F9NCNT, + F9NORG, + F9PRIX, + F9TPAT, + F9CENT::text || F9CETS::text || F9CRUB::text || F9CMAT::text || F9DA1A::text || F9DA1M::text || F9DA9A::text || F9DA9M::text as F9CKEY + FROM + prod_shs.rhlib_F9P01 + ); + INSERT INTO w_F69P01 + SELECT + F6BASE, + F6CENT, + F6CETS, + '10'::text AS F9CHAP, + F6CMAT, + F6CRUB, + F6MONT, + 0 AS F9MPAT, + F6NCNT, + '' AS F9NORG, + F6PRIX, + 0 AS F6TPAT, + '' as F9CKEY + FROM + prod_shs.rhlib_F6P01 + WHERE 1=1 + AND F6CGEN = '6' + AND F6MONT > 0 + AND F6CENT::text || F6CETS::text || F6CRUB::text || F6CMAT::text || F6DA1A::text || F6DA1M::text || F6DA9A::text || F6DA9M::text != ALL (ARRAY(SELECT F9CKEY FROM w_F69P01 GROUP BY 1)::text[]); + + INSERT INTO rh.p_historique_paie( + salarie_id, + contrat_id, + contrat_mois_id, + profil_id, + mois_activite, + date_debut, + date_fin, + mois_paie, + date_paie, + rubrique_id, + organisme_cotisation_id, + base, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_net_imposable_salarie, + montant_net_a_payer_salarie + ) + SELECT + w_J0P01_0.salarie_id, + w_J0P01_0.contrat_id, + w_J0P01_0.contrat_mois_id, + w_J0P01_0.profil_id, + date_part('year',w_J0P01_0.date_fin) * 100 + date_part('month',w_J0P01_0.date_fin), + w_J0P01_0.date_debut, + w_J0P01_0.date_fin, + w_J0P01_0.mois_paie, + w_J0P01_0.date_paie, + COALESCE(w_cti_rubriques.in_id,0) AS rubrique_id, + COALESCE(w_cti_organismes_cotisation.in_id,0) AS organisme_cotisation_id, + F9BASE AS base, + CASE WHEN F9chap = '10' AND F9CRUB < 3000 THEN F9mont ELSE 0 END AS montant_brut, + CASE WHEN F9chap = '10' AND F9CRUB BETWEEN 3000 AND 3499 THEN F9mont ELSE 0 END AS montant_avantage_nature, + CASE WHEN F9chap = '10' AND F9CRUB BETWEEN 3500 AND 3999 THEN F9mont ELSE 0 END AS montant_frais_imposables, + CASE WHEN F9chap = '10' THEN F9prix WHEN F9chap = '20' THEN F9prix ELSE 0 END as taux_cotisation_salarie, + CASE WHEN F9chap = '20' AND (F9crub BETWEEN 4000 AND 6999 OR F9crub > 9000) THEN 0 - F9mont ELSE 0 END AS montant_cotisation_salarie, + CASE WHEN F9chap = '20' THEN F9tpat ELSE 0 END AS taux_cotisation_patronale, + CASE WHEN F9chap = '20' OR t_rubriques.code_calcul = '8' THEN F9mpat ELSE 0 END AS montant_cotisation_patronale, + CASE + WHEN F9chap = '20' AND (F9crub BETWEEN 7000 AND 8999 OR F9crub > 9000) THEN 0 - F9mont + WHEN F9chap = '30' THEN 0 - F9mont + ELSE 0 + END AS montant_od_net_salarie, + CASE WHEN t_rubriques.code_calcul = '7' THEN F9tpat ELSE 0 END + + CASE + WHEN F9chap = '10' THEN F9mont + WHEN F9chap = '20' AND (F9crub BETWEEN 4000 AND 6999 OR F9crub > 9000) THEN F9mont + ELSE 0 + END AS montant_net_imposable_salarie, + CASE + WHEN F9chap = '10' AND (CASE WHEN rhp('opt_avt_nature') = '1' THEN (F9CRUB NOT BETWEEN 3000 AND 3499) ELSE true END) THEN F9mont + WHEN F9chap = '20' THEN F9mont + WHEN F9chap = '30' THEN F9mont + ELSE 0 + END AS montant_net_a_payer_salarie + FROM w_F69P01 -- mois non clôturé + JOIN prod_shs.rhlib_F1P01 ON 1=1 + AND F9CENT = F1CENT + AND F9CETS = F1CETS + JOIN w_J0P01_0 ON 1=1 + AND w_F69P01.F9CENT = w_J0P01_0.J0CENT_0 + AND w_F69P01.F9CETS = w_J0P01_0.J0CETS_0 + AND w_F69P01.F9CMAT = w_J0P01_0.J0CMAT_0 + AND w_F69P01.F9NCNT = w_J0P01_0.J0NCNT_0 + AND rhlib_F1p01.F1DFPA = w_J0P01_0.J0DFPA_0 + AND rhlib_F1p01.F1DFPM = w_J0P01_0.J0DFPM_0 + AND est_historique = '' + JOIN w_cti_rubriques ON + F9CENT = w_cti_rubriques.XXCENT AND + F9CETS = w_cti_rubriques.XXCETS AND + F9CRUB = w_cti_rubriques.XXCODO + JOIN rh.t_rubriques ON t_rubriques.code_original = w_cti_rubriques.in_code_original + LEFT JOIN w_cti_organismes_cotisation ON + F9CENT = w_cti_organismes_cotisation.XXCENT AND + F9CETS = w_cti_organismes_cotisation.XXCETS AND + F9NORG = w_cti_organismes_cotisation.XXCODO + ; + + -- Correction des périodes incohérentes. + UPDATE rh.p_historique_paie + SET date_debut = date_fin + WHERE date_debut > date_fin + ; + + -- Re-activation des index + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + -- Mise à 0 de l'ETP si pas d'heures payées. + UPDATE rh.p_contrats_mois + SET equivalent_temps_plein = 0 + WHERE 1=1 + AND equivalent_temps_plein <> 0 + AND oid NOT IN + (SELECT contrat_mois_id + FROM rh.p_historique_paie + WHERE rubrique_id IN + (SELECT oid FROM rh.t_rubriques WHERE code = '0099')) + ; + + -- Renseigner les heures contrats à partir de la rubriques d'heures salaire de base conventionnel lorsque le nombre d'heures contrat n'est pas renseigné. + UPDATE rh.p_contrats_mois SET + nombre_heures = 0 + ; + + UPDATE rh.p_contrats_mois SET + nombre_heures = subq.nombre_heures + FROM ( + SELECT + contrat_mois_id, + sum(base) as nombre_heures + FROM rh.p_historique_paie + WHERE rubrique_id IN (SELECT oid FROM rh.t_rubriques WHERE code = '1000') + GROUP BY 1) as subq + WHERE 1=1 + AND p_contrats_mois.oid = subq.contrat_mois_id + AND p_contrats_mois.nombre_heures = 0 + ; + + -- Appliquer le type de temps de travail pour les rubriques de paie ayant une base != valeur absolue de 1. + -- UPDATE rh.p_historique_paie SET + + -- FROM () as subq + -- WHERE 1=1 + -- AND p_contrats_mois.oid = subq.contrat_mois_id + -- AND p_contrats_mois.nombre_heures = 0 + -- ; + + ]]> + + + + + + in_code_original + ; + + INSERT INTO rh.p_arrets_travail( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + date_reprise, + motif_arret_id, + precision_motif_arret_id, + nb_jours + ) + SELECT + p_salaries.oid AS salarie_id, + (max(ARRAY[extract(epoch from p_contrats.date_debut), p_contrats.oid]))[2] AS contrat_id, + N6D1AA * 100 + N6D1AM AS mois_activite, + rh.cti_to_date(N6D1AA, N6D1AM, N6D1AJ) AS date_debut, + CASE WHEN N6D9AA <> 0 THEN rh.cti_to_date(N6D9AA, N6D9AM, N6D9AJ) ELSE '20991231' END AS date_fin, + CASE + WHEN N6DREA BETWEEN 1900 AND 2020 THEN rh.cti_to_date(N6DREA, N6DREM, N6DREJ) + WHEN N6D9AA <> 0 THEN rh.cti_to_date(N6D9AA, N6D9AM, N6D9AJ)::date + 1 + ELSE '20991231' END AS date_reprise, + COALESCE(t_motifs_arret.oid, 0) AS motif_arret_id, + COALESCE(t_precisions_motif_arret.oid, 0) AS precision_motif_arret_id, + N6NJOU AS nb_jours + FROM w_N6p01 + JOIN w_etablissements_select ON XXCENT = N6CENT AND XXCETS = N6CETS + JOIN rh.p_salaries ON (to_char(N6CENT,'FM000')||N6CMAT) = p_salaries.code_original + JOIN rh.p_contrats ON 1=1 + AND p_contrats.salarie_id = p_salaries.oid + AND base.cti_overlaps( + p_contrats.date_debut, + p_contrats.date_fin, + rh.cti_to_date(N6D1AA, N6D1AM, N6D1AJ), + CASE WHEN N6D9AA <> 0 THEN rh.cti_to_date(N6D9AA, N6D9AM, N6D9AJ) ELSE '20991231' END) + LEFT JOIN rh.t_motifs_arret ON (N6MOTA = t_motifs_arret.code_original) + LEFT JOIN rh.t_precisions_motif_arret ON (N6MOPR_code_original = t_precisions_motif_arret.code_original) + GROUP BY 1,3,4,5,6,7,8,9 + ; + + -- Correction des dates de reprises saisies entre les dates de début/fin des arrêts. + -- #correction + UPDATE rh.p_arrets_travail + SET date_reprise = date_fin + 1 + WHERE base.cti_overlaps(date_reprise, date_reprise, date_debut, date_fin) + ; + + -- Màj des dates de reprise à date_fin + 1 lorsque plusieurs arrêts consécutifs ont tous la même date de reprise. + -- Le drapeau nb_reprise_apres_arret dans p_arrets_travail_mois sera tout de même positionné à 0 afin qu'un seul arrêt + -- donne lieu à une seule reprise. + /* EXEMPLE : + Avant : + debut fin reprise drapeau + 2005-02-28 2005-03-13 2005-02-05 1 + 2005-03-14 2005-03-27 2005-02-05 1 + 2005-03-28 2005-07-17 2005-02-05 1 + + Après : + debut fin reprise drapeau + 2005-02-28 2005-03-13 2005-03-14 0 + 2005-03-14 2005-03-27 2005-03-28 0 + 2005-03-28 2005-07-17 2005-02-05 1 + + */ + UPDATE rh.p_arrets_travail + SET date_reprise = subq.date_reprise + FROM ( + SELECT + t1.oid, + t1.mois_activite, + min(case when t1.date_fin + '1 day'::interval = t2.date_debut THEN t1.date_fin + '1 day'::interval ELSE t1.date_reprise END) AS date_reprise + FROM rh.p_arrets_travail AS t1 + LEFT JOIN rh.p_arrets_travail AS t2 ON 1=1 + AND t1.salarie_id = t2.salarie_id + AND t1.date_debut != t2.date_debut + AND t1.date_fin != t2.date_fin + GROUP BY t1.oid, t1.mois_activite + ORDER BY 2 + ) AS subq + WHERE 1=1 + AND p_arrets_travail.oid = subq.oid + AND p_arrets_travail.mois_activite = subq.mois_activite + ; + + TRUNCATE rh.p_arrets_travail_mois + ; + + INSERT INTO rh.p_arrets_travail_mois( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + nb_arret, + nb_debut_arret, + nb_fin_arret, + nb_reprise_apres_arret, + date_debut, + date_fin, + nb_jours + ) + SELECT + arr.oid AS arret_travail_id, + arr.salarie_id AS salarie_id, + cnt.contrat_id AS contrat_id, + cnt.oid AS contrat_mois_id, + cal.mois AS mois_activite, + CASE WHEN base.cti_overlaps(arr.date_debut, arr.date_fin, cnt.date_debut, cnt.date_fin) THEN 1 ELSE 0 END AS nb_arret, + CASE WHEN arr.date_debut BETWEEN cnt.date_debut AND cnt.date_fin THEN 1 ELSE 0 END AS nb_debut_arret, + CASE WHEN arr.date_fin BETWEEN cnt.date_debut AND cnt.date_fin THEN 1 ELSE 0 END AS nb_fin_arret, + CASE WHEN arr.date_reprise BETWEEN cal.date_debut AND cal.date_fin THEN 1 ELSE 0 END AS nb_reprise_apres_arret, + CASE + WHEN base.cti_overlaps(arr.date_debut, arr.date_fin, cal.date_debut, cal.date_fin) + THEN GREATEST(cnt.date_debut, arr.date_debut) + ELSE arr.date_reprise + END AS date_debut, + CASE + WHEN base.cti_overlaps(arr.date_debut, arr.date_fin, cal.date_debut, cal.date_fin) + THEN LEAST(cnt.date_fin, arr.date_fin) + ELSE arr.date_reprise + END AS date_fin, + CASE + WHEN base.cti_overlaps(arr.date_debut, arr.date_fin, cal.date_debut, cal.date_fin) + THEN + CASE WHEN LEAST(cnt.date_fin, arr.date_fin)::date >= GREATEST(cnt.date_debut, arr.date_debut)::date + THEN LEAST(cnt.date_fin, arr.date_fin)::date - GREATEST(cnt.date_debut, arr.date_debut)::date + 1 + ELSE 0 + END + ELSE 0 + END AS nb_jours + FROM base.p_calendrier_mois AS cal + JOIN rh.p_arrets_travail AS arr ON 1!=1 + OR base.cti_overlaps(arr.date_debut, arr.date_fin, cal.date_debut, cal.date_fin) + OR (1=1 + AND arr.date_reprise BETWEEN cal.date_debut AND cal.date_fin + AND arr.date_reprise != '2099-12-31') + JOIN rh.p_contrats_mois AS cnt ON 1=1 + AND cnt.salarie_id = arr.salarie_id + AND base.cti_overlaps(cnt.date_debut, cnt.date_fin, cal.date_debut, cal.date_fin) + AND base.cti_overlaps(cnt.date_debut, cnt.date_fin, arr.date_debut, arr.date_reprise) + AND est_hors_periode = '0' + AND fictif = '0' + WHERE 1=1 + AND cal.mois >= to_char(rhp('rhprovider_start')::date, 'YYYYMM') + ; + + -- Màj des ventil d'arrêts hors contrat (contrat_mois_id IS NULL) + /* + :: DEV EN COURS :: DEV EN COURS :: DEV EN COURS :: DEV EN COURS :: DEV EN COURS :: + UPDATE rh.p_arrets_travail_mois + SET contrat_mois_id = subq.contrat_mois_id + FROM + :: DEV EN COURS :: DEV EN COURS :: DEV EN COURS :: DEV EN COURS :: DEV EN COURS :: DEV EN COURS :: + */ + + -- Màj des reprises. + /*UPDATE rh.p_arrets_travail_mois + SET nb_reprise_apres_arret = subq.nb_reprise_apres_arret + FROM ( + SELECT + t1.arret_travail_id, + t1.mois_activite, + min(case when p_arrets_travail.date_reprise between t2.date_debut AND t2.date_fin then 0 else 1 end) AS nb_reprise_apres_arret + FROM rh.p_arrets_travail_mois AS t1 + JOIN rh.p_arrets_travail ON p_arrets_travail.oid = t1.arret_travail_id + LEFT JOIN rh.p_arrets_travail_mois AS t2 ON 1=1 + AND t1.salarie_id = t2.salarie_id + AND t1.date_debut != t2.date_debut + AND t1.date_fin != t2.date_fin + GROUP BY t1.arret_travail_id, t1.mois_activite + ORDER BY 2 DESC + ) AS subq + WHERE 1=1 + AND p_arrets_travail_mois.arret_travail_id = subq.arret_travail_id + AND p_arrets_travail_mois.mois_activite = subq.mois_activite + ;*/ + + ]]> + + + + + + + = to_char(rhp('rhprovider_start')::date, 'YYYY') + GROUP BY 1,2,3,4,5,6,9 + ; + + -- Peuplement de rh.p_visites_medicales + TRUNCATE rh.p_visites_medicales + ; + + ALTER SEQUENCE rh.s_visites_medicales RESTART WITH 1 + ; + + INSERT INTO rh.p_visites_medicales( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date, + motif_visite_id + ) + SELECT + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date, + motif_visite_id + FROM w_visites + ; + + ]]> + + + + + + + + + + + + + 1) subview + WHERE p_contrats_mois.salarie_id = subview.salarie_id AND + p_contrats_mois.nombre_entrees = 1 AND + p_contrats_mois.oid <> oid_ok + ; + + ]]> + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SHSPUB.XML b/import_rh/iCTI_import_rh_SHSPUB.XML new file mode 100644 index 0000000..8974ef8 --- /dev/null +++ b/import_rh/iCTI_import_rh_SHSPUB.XML @@ -0,0 +1,2270 @@ + + + + + + + + + + + = 200901 + AND ocdrub IN ('005', '499') + AND ocdagt != '101413' -- Fiche Régime-Imputation incohérente au niveau des dates, agent en Fin de Contrat + GROUP BY 1,2,3,4 + HAVING sum(CASE WHEN ocdrub = '499' THEN omtcal ELSE 0 END) != 0 + ) AS subq + GROUP BY 1,2,3 + ; + + ]]> + + + infos diverses + DROP TABLE IF EXISTS w_grade_divers + ; + + CREATE TEMP TABLE w_grade_divers AS + SELECT + dcdgrd AS grade, + ddtinf AS date_debut, + CASE + WHEN ddsinf = 'O' THEN '20991231' + ELSE (SELECT to_char(to_date(min(ddtinf), 'YYYYMMDD') - '1 day'::interval, 'YYYYMMDD')::numeric FROM prod_shspub.pippub184_gdinfp AS sq WHERE sq.dcdgrd = gdinfp.dcdgrd AND sq.ddtinf > gdinfp.ddtinf) + END AS date_fin, + dcdgcp, -- commission_paritaire, + dcdcem, -- cadre_emploi, + dcdfil, -- filiere, + dcdcas -- categorie_statutaire + FROM prod_shspub.pippub184_gdinfp AS gdinfp + WHERE 1=1 + AND dcdgrd != '' + ORDER BY 1, 2 + ; + + -- Création d'une table d'association grade<=>métier + DROP TABLE IF EXISTS w_grade_metier + ; + + CREATE TEMP TABLE w_grade_metier AS + SELECT + xcdsuf AS grade, + xlbpar AS metier + FROM prod_shspub.pippub184_paramp + WHERE xtyrad = 'MET_GRD' + ; + + -- Création d'une table avec le dernier historique de la fiche cotisation par agent + DROP TABLE IF EXISTS w_cotisation + ; + + CREATE TEMP TABLE w_cotisation AS + SELECT + acdagt AS matricule, + acdbud AS ent, + acdsbd AS eta, + atycot AS code_cotisation, + amatre AS matricule_retraite + FROM prod_shspub.pippub184_agcotp + WHERE 1=1 + AND aamfco = 20991231 + AND acdsbd = (SELECT eta_code FROM w_finess) + AND acdbud = (SELECT ent_code FROM w_finess) + ; + + -- Création de la table de correspondance Rubrique <=> Régime Statutaire <=> Compte d'imputation. + -- Utilisée pour la paye uniquement (associer une rubrique à un compte). + DROP TABLE IF EXISTS w_cor + ; + + CREATE TEMP TABLE w_cor AS + SELECT + rcdrub AS rubrique, + rcdbud AS entreprise, + rcdsbd AS etablissement, + rcdrgs AS statut, -- Régime statutaire + rcdcha AS compte -- Compte d'imputation + FROM prod_shspub.pippub184_rbimpp + JOIN rh.t_types_contrat ON t_types_contrat.code_original = pippub184_rbimpp.rcdrgs + WHERE 1=1 + AND rcdsbd IN (SELECT eta_code FROM w_finess) + AND rcdbud IN (SELECT ent_code FROM w_finess) + AND t_types_contrat.oid > 0 + ORDER BY 1,4,5 DESC + ; + + UPDATE w_cor + SET compte = subq.rcdcha + FROM ( + SELECT + rcdrub, + rcdcha + FROM prod_shspub.pippub184_rbimpp + WHERE 1=1 + AND rcdsbd = '' + AND rcdbud ='' + AND rcdcha != '' + ) AS subq + WHERE 1=1 + AND rubrique = subq.rcdrub + AND compte = '' + ; + + -- Création d'un table avec les "éléments variables" saisis par salariés + DROP TABLE IF EXISTS w_ev + ; + + CREATE TEMP TABLE w_ev AS + SELECT + ecdagt AS agent, + ecdbud AS entreprise, + ecdsbd AS etablissement, + ecdrub AS rubrique, + to_date(edtdeb,'YYYYMMDD') AS date_debut, + (CASE WHEN edtfin != 20991231 + THEN to_date(edtfin,'YYYYMMDD') + ELSE to_date(edtdeb,'YYYYMMDD') + interval '1 month' - interval '1 day' END + )::date AS date_fin, + substr(edtdeb, 1, 6) AS mois, + ecdbax AS lettre_budgetaire_code_original, + ecdser AS service_code_original, + ecduf AS unite_fonctionnelle_code_original + FROM prod_shspub.pippub184_elagtp + WHERE 1=1 + AND ecduf != '' + AND ecdbud IN (SELECT ent_code FROM w_finess) + AND ecdsbd IN (SELECT eta_code FROM w_finess) + ; + + ]]> + + + 0 THEN 1 ELSE 0 END AS etp_theorique, + base.cti_unnest3(array[anbse1,anbse2,anbse3,anbse4,anbse5]) / 100 AS pct, -- Pourcentage d'affectation + base.cti_unnest3(array[ + CASE WHEN anbse1 > 0 THEN 1 ELSE NULL END, + CASE WHEN anbse2 > 0 THEN 2 ELSE NULL END, + CASE WHEN anbse3 > 0 THEN 3 ELSE NULL END, + CASE WHEN anbse4 > 0 THEN 4 ELSE NULL END, + CASE WHEN anbse5 > 0 THEN 5 ELSE NULL END + ]) AS rang, -- Rang d'affectation + to_date(ag.adtent, 'YYYYMMDD') AS date_entree_ets, + -- Codes originaux + greatest(w_grade_metier.metier,chr(1)||'*') AS categorie_socio_professionnelle_code_original, -- Métier + greatest(pa.aagtyp,chr(1)||'*') AS code_emploi_code_original, -- Type de paie + greatest(av.acdgrd,chr(1)||'*') AS grille_code_original, -- Grade + greatest(av.acdech,chr(1)||'*') AS grille_groupe_code_original, -- Echelon + greatest(pa.asspay,chr(1)||'*') AS groupe_cotisant_code_original, -- Sous-type de paie + greatest(ag.amoent,chr(1)||'*') AS motif_debut_code_original, -- Motif debut d'entree ets + greatest(ag.amosor,chr(1)||'*') AS motif_fin_code_original, -- Motif sortie ets + base.cti_unnest2(array[acduf1,acduf2,acduf3,acduf4,acduf5]) AS unite_fonctionnelle_code_original, -- UF + greatest(ho.acdcat,chr(1)||'*') AS categorie_conge_code_original, -- Catégorie congé + greatest(ri.acdcha,chr(1)||'*') AS compte_salarie_code_original, -- Compte d'imputation + base.cti_unnest2(array[acdse1,acdse2,acdse3,acdse4,acdse5]) AS service_code_original, -- CR + greatest(wgd.dcdgcp,chr(1)||'*') AS commission_paritaire_code_original, -- Groupe de commission paritaire + base.cti_unnest2(array[acdax1,acdax2,acdax3,acdax4,acdax5]) AS lettre_budgetaire_code_original, -- Lettre budgétaire + greatest(pa.pacpos,chr(1)||'*') AS statut_code_original, -- Position + greatest(ri.acdrgs,chr(1)||'*') AS type_contrat_code_original, -- Régime statutaire + greatest(ho.atyhor,chr(1)||'*') AS type_horaire_code_original, -- Idem + greatest(tp.acdtra,chr(1)||'*') AS type_temps_travail_code_original, -- Type de contrat + greatest(wgd.dcdcem,chr(1)||'*') AS cadre_emploi_code_original, -- Cadre emploi + greatest(wgd.dcdfil,chr(1)||'*') AS filiere_code_original, -- Filiere + greatest(wgd.dcdcas,chr(1)||'*') AS categorie_statutaire_code_original, -- Categorie statutaire + (chr(1)||'*')::text AS qualification_code_original, + (chr(1)||'*')::text AS section_analytique_code_original, + (chr(1)||'*')::text AS section_analytique_paie_code_original, + (chr(1)||'*')::text AS societe_interim_code_original, + (chr(1)||'*')::text AS specialite_code_original + FROM prod_shspub.pippub184_agentp AS ag + -- Fiche "Avancement" + LEFT JOIN prod_shspub.pippub184_agavap AS av ON 1=1 + AND av.acdagt = ag.acdagt + -- Fiche "Temps-effectif-service" + LEFT JOIN prod_shspub.pippub184_agtpsp AS tp ON 1=1 + AND tp.acdagt = av.acdagt + AND tp.acdsbd = av.acdsbd + AND tp.acdbud = av.acdbud + AND base.cti_overlaps(to_date(av.adtpec, 'YYYYMMDD'), to_date(av.adtfpc, 'YYYYMMDD'), to_date(tp.adttps, 'YYYYMMDD'), to_date(tp.adtftp, 'YYYYMMDD')) + -- Fiche "Horaire" + LEFT JOIN prod_shspub.pippub184_aghorp AS ho ON 1=1 + AND ho.acdagt = av.acdagt + AND ho.acdsbd = av.acdsbd + AND ho.acdbud = av.acdbud + AND base.cti_overlaps(to_date(av.adtpec, 'YYYYMMDD'), to_date(av.adtfpc, 'YYYYMMDD'), to_date(ho.adthor, 'YYYYMMDD'), to_date(ho.hofhor, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(tp.adttps, 'YYYYMMDD'), to_date(tp.adtftp, 'YYYYMMDD'), to_date(ho.adthor, 'YYYYMMDD'), to_date(ho.hofhor, 'YYYYMMDD')) + -- Fiche "Imputation-régime" + LEFT JOIN prod_shspub.pippub184_agimpp AS ri ON 1=1 + AND ri.acdagt = av.acdagt + AND ri.acdsbd = av.acdsbd + AND ri.acdbud = av.acdbud + AND base.cti_overlaps(to_date(av.adtpec, 'YYYYMMDD'), to_date(av.adtfpc, 'YYYYMMDD'), to_date(ri.adtimp, 'YYYYMMDD'), to_date(ri.imftim, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(tp.adttps, 'YYYYMMDD'), to_date(tp.adtftp, 'YYYYMMDD'), to_date(ri.adtimp, 'YYYYMMDD'), to_date(ri.imftim, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(ho.adthor, 'YYYYMMDD'), to_date(ho.hofhor, 'YYYYMMDD'), to_date(ri.adtimp, 'YYYYMMDD'), to_date(ri.imftim, 'YYYYMMDD')) + -- Fiche "Type de paye" + LEFT JOIN prod_shspub.pippub184_agpayp AS pa ON 1=1 + AND pa.acdagt = av.acdagt + AND pa.acdsbd = av.acdsbd + AND pa.acdbud = av.acdbud + AND base.cti_overlaps(to_date(av.adtpec, 'YYYYMMDD'), to_date(av.adtfpc, 'YYYYMMDD'), to_date(pa.adtpay, 'YYYYMMDD'), to_date(pa.adtfpa, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(tp.adttps, 'YYYYMMDD'), to_date(tp.adtftp, 'YYYYMMDD'), to_date(pa.adtpay, 'YYYYMMDD'), to_date(pa.adtfpa, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(ho.adthor, 'YYYYMMDD'), to_date(ho.hofhor, 'YYYYMMDD'), to_date(pa.adtpay, 'YYYYMMDD'), to_date(pa.adtfpa, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(ri.adtimp, 'YYYYMMDD'), to_date(ri.imftim, 'YYYYMMDD'), to_date(pa.adtpay, 'YYYYMMDD'), to_date(pa.adtfpa, 'YYYYMMDD')) + -- "Fichier grades (informations diverses)" + LEFT JOIN w_grade_divers AS wgd ON 1=1 + AND wgd.grade = av.acdgrd + AND base.cti_overlaps(to_date(av.adtpec, 'YYYYMMDD'), to_date(av.adtfpc, 'YYYYMMDD'), to_date(wgd.date_debut, 'YYYYMMDD'), to_date(wgd.date_fin, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(tp.adttps, 'YYYYMMDD'), to_date(tp.adtftp, 'YYYYMMDD'), to_date(wgd.date_debut, 'YYYYMMDD'), to_date(wgd.date_fin, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(ho.adthor, 'YYYYMMDD'), to_date(ho.hofhor, 'YYYYMMDD'), to_date(wgd.date_debut, 'YYYYMMDD'), to_date(wgd.date_fin, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(ri.adtimp, 'YYYYMMDD'), to_date(ri.imftim, 'YYYYMMDD'), to_date(wgd.date_debut, 'YYYYMMDD'), to_date(wgd.date_fin, 'YYYYMMDD')) + AND base.cti_overlaps(to_date(pa.adtpay, 'YYYYMMDD'), to_date(pa.adtfpa, 'YYYYMMDD'), to_date(wgd.date_debut, 'YYYYMMDD'), to_date(wgd.date_fin, 'YYYYMMDD')) + LEFT JOIN w_grade_metier ON w_grade_metier.grade = av.acdgrd + WHERE 1=1 + --AND av.acdagt = '100017' + AND av.acdagt NOT IN ('101413','101478') -- @TODO Fiche Régime-Imputation incohérente au niveau des dates, agent en Fin de Contrat + AND afipay = 1 + AND ag.adtent != 0 -- Uniquement les agents qui ont une date d'entrée dans l'établissement + --AND av.adtpec >= ag.adtent -- Uniquement l'historique depuis l'entrée dans l'établissement + AND av.acdsbd = (SELECT eta_code FROM w_finess) + AND av.acdbud = (SELECT ent_code FROM w_finess) + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33 + --order by 6 desc + ; + + ]]> + + + + to_date(agent.adtsor,'YYYYMMDD') + ; + + -- c. màj des date de fin du dernier profil de l'agent <= date de sortie de l'agent + UPDATE w_profils_all + SET date_fin = subq.date_sortie + FROM + ( + SELECT + w_profils_all.agent, + max(w_profils_all.date_debut) AS date_debut, + w_tmp.date_sortie + FROM w_profils_all + JOIN w_tmp ON w_tmp.agent = w_profils_all.agent + GROUP BY 1,3 + ) AS subq + WHERE 1=1 + AND subq.agent = w_profils_all.agent + AND subq.date_debut = w_profils_all.date_debut + ; + + -- Identification des derniers profils des matricule (champ "encours") + -- SELECT * FROM w_profils_all WHERE encours = 1 + UPDATE w_profils_all + SET encours = 1 + FROM + ( + SELECT + w_profils_all.agent, + max(w_profils_all.date_debut) AS date_debut + FROM w_profils_all + GROUP BY 1 + ) AS subq + WHERE 1=1 + AND subq.agent = w_profils_all.agent + AND subq.date_debut = w_profils_all.date_debut + ; + + -- Optimisation de w_profils_all + SELECT base.cti_optimize_table('w_profils_all') + ; + + -- Création d'un table de profil avec 1 seul profil par matricule simultané. + CREATE TEMP TABLE w_profils AS + SELECT * + FROM w_profils_all + WHERE rang = 1 + ; + + ]]> + + + adtsor THEN '2099-12-31'::date ELSE to_date(adtsor, 'YYYYMMDD') END AS date_fin, + to_date(agent.adtent, 'YYYYMMDD') AS date_entree_ets, + CASE WHEN agent.adtadm = 0 + THEN to_date(agent.adtent, 'YYYYMMDD') + ELSE to_date(agent.adtadm, 'YYYYMMDD') + END AS date_entree_fp, + CASE WHEN agent.agdfph = 0 + THEN to_date(agent.adtent, 'YYYYMMDD') + ELSE to_date(agent.agdfph, 'YYYYMMDD') + END AS date_entree_fph, + cp.aadeli AS no_adeli, + coalesce(t_code_cotisation.oid, 0) AS code_cotisation_id, + matricule_retraite + FROM prod_shspub.pippub184_agentp AS agent + LEFT JOIN prod_shspub.pippub184_agencp AS cp ON cp.acdagt = agent.acdagt + LEFT JOIN rh.t_codes_postaux ON t_codes_postaux.code = agent.aadpos + LEFT JOIN rh.t_situations_famille ON t_situations_famille.code_original = agent.asifam + LEFT JOIN w_cotisation ON w_cotisation.matricule = agent.acdagt + LEFT JOIN rh.t_code_cotisation ON t_code_cotisation.code_original = w_cotisation.code_cotisation + LEFT JOIN rh.t_nationalites ON t_nationalites.code_original = agent.acdnat + JOIN w_profils ON 1=1 + AND encours = 1 + AND w_profils.agent = agent.acdagt + WHERE 1=1 + AND aprnma != '' + AND agent.adtent != 0 -- Uniquement les agents qui ont une date d'entrée dans l'établissement + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 + ; + + ]]> + + + + = p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',to_date(p_salaries.date_entree_ets,'YYYYMMDD'))::date, 'nm') AS anciennete_mois, + floor(base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',to_date(p_salaries.date_entree_ets,'YYYYMMDD'))::date, 'ny')) AS anciennete_annee_id, + base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',to_date(p_salaries.date_entree_fp,'YYYYMMDD'))::date, 'nm') AS anciennete_fp_mois, + floor(base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',to_date(p_salaries.date_entree_fp,'YYYYMMDD'))::date, 'ny')) AS anciennete_fp_annee_id, + base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',to_date(p_salaries.date_entree_fph,'YYYYMMDD'))::date, 'nm') AS anciennete_fph_mois, + floor(base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',to_date(p_salaries.date_entree_fph,'YYYYMMDD'))::date, 'ny')) AS anciennete_fph_annee_id + FROM rh.p_contrats + JOIN rh.p_salaries ON p_contrats.salarie_id = p_salaries.oid + JOIN rh.t_etablissements ON p_contrats.etablissement_id = t_etablissements.oid + JOIN rh.t_entreprises ON t_etablissements.entreprise_id = t_entreprises.oid + JOIN base.p_calendrier_mois ON (p_contrats.date_debut <= p_calendrier_mois.date_fin AND p_contrats.date_fin >= p_calendrier_mois.date_debut) + JOIN w_profils ON 1=1 + AND w_profils.agent = p_salaries.matricule + AND p_contrats.date_fin BETWEEN w_profils.date_debut AND w_profils.date_fin + JOIN prod_shspub.pippub184_agentp AS ag ON ag.acdagt = w_profils.agent + WHERE p_calendrier_mois.date_debut < date(now()) + GROUP BY 1,2,3,4,5,7,8,10,11,12,13,14,15,16,17,18,19 + ; + + ]]> + + + = 200901 + AND OCDSBD = (SELECT eta_code FROM w_finess) + AND OCDBUD = (SELECT ent_code FROM w_finess) + ) + UNION ALL + ( -- Heures payées + SELECT + nextval('w_hp_seq') AS oid, + hp.ocdagt AS matricule, + (ommtrt||'01')::date AS date_debut, + ((ommtrt||'01')::date + interval '1 month' - interval '1 day')::date AS date_fin, + ommtrt AS mois, + ommpay, + t_rubriques.oid AS rubrique_id, + ocdrub, + obacal AS base, + 0 AS montant_brut, + 0 AS taux_salarial, + 0 AS montant_salarial, + 0 AS taux_patronal, + 0 AS montant_patronal, + 0 AS net_imposable, + 0 AS net_a_payer, + 0 AS od_net + FROM prod_shspub.pippub184_histop AS hp + JOIN prod_shspub.pippub184_rbentp AS rb ON rb.rcdrub = hp.ocdrub + JOIN rh.t_rubriques ON t_rubriques.code_original = rb.rcdrub + WHERE 1=1 + AND redbul = 0 + AND ocdrub = '005' + --AND ocdagt = '100009' + --AND ommtrt = 201112 + AND ommtrt >= 200901 + AND OCDSBD = (SELECT eta_code FROM w_finess) + AND OCDBUD = (SELECT ent_code FROM w_finess) + ) + UNION ALL + ( -- Effectif payé + SELECT + nextval('w_hp_seq') AS oid, + hp.ocdagt AS matricule, + (ommtrt||'01')::date AS date_debut, + ((ommtrt||'01')::date + interval '1 month' - interval '1 day')::date AS date_fin, + ommtrt AS mois, + ommpay, + t_rubriques.oid AS rubrique_id, + ocdrub, + obacal AS base, + 0 AS montant_brut, + 0 AS taux_salarial, + 0 AS montant_salarial, + 0 AS taux_patronal, + 0 AS montant_patronal, + 0 AS net_imposable, + 0 AS net_a_payer, + 0 AS od_net + FROM prod_shspub.pippub184_histop AS hp + JOIN prod_shspub.pippub184_rbentp AS rb ON rb.rcdrub = hp.ocdrub + JOIN rh.t_rubriques ON t_rubriques.code_original = rb.rcdrub + WHERE 1=1 + AND redbul = 0 + AND ocdrub = 'EFF1' + --AND ocdagt = '100009' + --AND ommtrt = 201112 + AND ommtrt >= 200901 + AND OCDSBD = (SELECT eta_code FROM w_finess) + AND OCDBUD = (SELECT ent_code FROM w_finess) + ) + ; + + -- Suppression des lignes de paie à zéro (sauf la ligne contenant les heures payées '005','EFF1') + DELETE FROM w_hp + WHERE 1=1 + --AND base = 0 + AND montant_brut = 0 + AND montant_salarial = 0 + AND montant_patronal = 0 + AND net_imposable = 0 + AND net_a_payer = 0 + AND od_net = 0 + AND ocdrub != '005' + AND ocdrub != 'EFF1' + ; + + CREATE INDEX i_w_hp_1 + ON w_hp + USING btree (matricule) + ; + + CREATE INDEX i_w_hp_2 + ON w_hp + USING btree (date_fin) + ; + + CREATE INDEX i_w_hp_3 + ON w_hp + USING btree (rubrique_id) + ; + + -- Peuplement de l'historique de la paie + TRUNCATE rh.p_historique_paie + ; + + -- Activation des index + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + INSERT INTO rh.p_historique_paie + ( + age_id, + contrat_id, + contrat_mois_id, + organisme_cotisation_id, + profil_id, + rubrique_id, + salarie_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + montant_brut, + taux_cotisation_salarie, + montant_cotisation_salarie, + taux_cotisation_patronale, + montant_cotisation_patronale, + montant_avantage_nature, + montant_frais_imposables, + montant_od_net_salarie, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + compte_id + ) + SELECT + date_part('year', age(w_hp.date_fin, date_naissance)) AS age_id, + coalesce((max(ARRAY[EXTRACT(EPOCH FROM p_contrats.date_fin),p_contrats.oid]))[2], 0) AS contrat_id, + coalesce((max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.oid]))[2], 0) AS contrat_mois_id, + 0 AS organisme_cotisation_id, + coalesce((max(ARRAY[EXTRACT(EPOCH FROM w_profils.date_fin), w_profils.profil_id]))[2], '0') AS profil_id, + w_hp.rubrique_id, + p_salaries.oid AS salarie_id, + (ommpay||'01')::date AS date_debut, + ((ommpay||'01')::date + interval '1 month' - interval '1 day')::date AS date_fin, + w_hp.date_fin AS date_paie, + w_hp.ommpay AS mois_activite, + w_hp.mois AS mois_paie, + w_hp.base AS base, + w_hp.montant_brut AS montant_brut, + w_hp.taux_salarial AS taux_cotisation_salarie, + w_hp.montant_salarial AS montant_cotisation_salarie, + w_hp.taux_patronal AS taux_cotisation_patronale, + w_hp.montant_patronal AS montant_cotisation_patronale, + 0 AS montant_avantage_nature, + 0 AS montant_frais_imposables, + od_net AS montant_od_net_salarie, + w_hp.net_imposable AS montant_net_imposable_salarie, + w_hp.net_a_payer AS montant_net_a_payer_salarie, + 0 AS compte_id + FROM w_hp + JOIN rh.p_salaries ON p_salaries.matricule = w_hp.matricule + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_salaries.oid + AND p_contrats_mois.mois_activite = w_hp.ommpay + LEFT JOIN rh.p_contrats ON p_contrats.oid = p_contrats_mois.contrat_id + LEFT JOIN w_profils ON w_profils.numero_situation = p_contrats.numero_contrat + GROUP BY 1,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, + w_hp.oid -- permet d'avoir n lignes d'historique de paie lorsqu'il s'agit de retro-activité + ; + + -- Re-activation des index + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + -- Lorsqu'une paye n'est pas couverte par un contrat un mois donné + -- générer une ventilation de contrat supplémentaire pour ce mois. + -- Par la droite. + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + profil_id, + nombre_debut_contrat, + nombre_fin_contrat, + equivalent_temps_plein, + age_id, + age_jours, + est_hors_periode, + present_fin_mois, + anciennete_mois, + anciennete_annee_id, + anciennete_fp_mois, + anciennete_fp_annee_id, + anciennete_fph_mois, + anciennete_fph_annee_id + ) + SELECT + p_historique_paie.salarie_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats.oid]))[2] as contrat_id, + p_historique_paie.mois_activite, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.profil_id]))[2] as profil_id, + 0 AS nombre_debut_contrat, + 0 AS nombre_fin_contrat, + 0 AS equivalent_temps_plein, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.age_id]))[2] AS age_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.age_jours]))[2] AS age_jours, + 1 AS est_hors_periode, + 0 AS present_fin_mois, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.anciennete_mois]))[2] AS anciennete_mois, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.anciennete_annee_id]))[2] AS anciennete_annee_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.anciennete_fp_mois]))[2] AS anciennete_fp_mois, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.anciennete_fp_annee_id]))[2] AS anciennete_fp_annee_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.anciennete_fph_mois]))[2] AS anciennete_fph_mois, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.anciennete_fph_annee_id]))[2] AS anciennete_fph_annee_id + FROM rh.p_historique_paie + JOIN rh.p_contrats ON p_contrats.salarie_id = p_historique_paie.salarie_id + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + WHERE 1=1 + AND + (1!=1 + OR p_historique_paie.contrat_mois_id IS NULL + OR p_historique_paie.contrat_mois_id = 0 + ) + AND p_historique_paie.date_paie > p_contrats_mois.date_fin -- la fin du contrat doit être antérieure au bulletin de paie + GROUP BY 1,3,4,5,7,8,9,12,13 + ; + + -- Associer à l'historique de paie ce nouveau mois ventilé + UPDATE rh.p_historique_paie + SET + contrat_id = p_contrats_mois.contrat_id, + contrat_mois_id = p_contrats_mois.oid, + profil_id = p_contrats_mois.profil_id + FROM rh.p_contrats_mois + WHERE 1=1 + AND p_historique_paie.salarie_id = p_contrats_mois.salarie_id + AND p_historique_paie.mois_activite = p_contrats_mois.mois_activite + AND + (1!=1 + OR p_historique_paie.contrat_mois_id IS NULL + OR p_historique_paie.contrat_mois_id = 0 + ) + ; + + -- Par la gauche. + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + profil_id, + nombre_debut_contrat, + nombre_fin_contrat, + equivalent_temps_plein, + age_id, + age_jours, + est_hors_periode, + present_fin_mois, + anciennete_mois, + anciennete_annee_id, + anciennete_fp_mois, + anciennete_fp_annee_id, + anciennete_fph_mois, + anciennete_fph_annee_id + ) + SELECT + p_historique_paie.salarie_id, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats.oid]))[2] as contrat_id, + p_historique_paie.mois_activite, + p_historique_paie.date_debut, + p_historique_paie.date_fin, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.profil_id]))[2] as profil_id, + 0 AS nombre_debut_contrat, + 0 AS nombre_fin_contrat, + 0 AS equivalent_temps_plein, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.age_id]))[2] AS age_id, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.age_jours]))[2] AS age_jours, + 1 AS est_hors_periode, + 0 AS present_fin_mois, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.anciennete_mois]))[2] AS anciennete_mois, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.anciennete_annee_id]))[2] AS anciennete_annee_id, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.anciennete_fp_mois]))[2] AS anciennete_fp_mois, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.anciennete_fp_annee_id]))[2] AS anciennete_fp_annee_id, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.anciennete_fph_mois]))[2] AS anciennete_fph_mois, + (min(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut),p_contrats_mois.anciennete_fph_annee_id]))[2] AS anciennete_fph_annee_id + FROM rh.p_historique_paie + JOIN rh.p_contrats ON p_contrats.salarie_id = p_historique_paie.salarie_id + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + WHERE 1=1 + AND + (1!=1 + OR p_historique_paie.contrat_mois_id IS NULL + OR p_historique_paie.contrat_mois_id = 0 + ) + AND p_historique_paie.date_paie < p_contrats_mois.date_debut -- le début du contrat doit être postérieur au bulletin de paie + GROUP BY 1,3,4,5,7,8,9,12,13 + ; + + -- Associer à l'historique de paie ce nouveau mois ventilé + UPDATE rh.p_historique_paie + SET + contrat_id = p_contrats_mois.contrat_id, + contrat_mois_id = p_contrats_mois.oid, + profil_id = p_contrats_mois.profil_id + FROM rh.p_contrats_mois + WHERE 1=1 + AND p_historique_paie.salarie_id = p_contrats_mois.salarie_id + AND p_historique_paie.mois_activite = p_contrats_mois.mois_activite + AND + (1!=1 + OR p_historique_paie.contrat_mois_id IS NULL + OR p_historique_paie.contrat_mois_id = 0 + ) + ; + + -- Création d'une table temp qui regroupe tous les totaux à atteindre pour calcul de l'écart + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + SELECT + OCDBUD AS ent, + OCDSBD AS eta, + ocdagt AS agent, + ommtrt AS mois, + -- sum(case when ocdrub = '005' then omtcal else 0 end) AS heures, -- pas utilisé + sum(case when ocdrub = '499' then omtcal else 0 end) AS brut, + sum(case when ocdrub = '950' then omtcal else 0 end) AS cots, + sum(case when ocdrub = '951' then omtcal else 0 end) AS cotp, + sum(case when ocdrub = '700' then omtcal else 0 end) AS netf, + sum(case when ocdrub = '990' then omtcal else 0 end) AS netp, + 0 AS od, + 0 AS fi, + 0 AS an + FROM prod_shspub.pippub184_histop + WHERE 1=1 + AND ommtrt >= 200901 + AND OCDSBD = (SELECT eta_code FROM w_finess) + AND OCDBUD = (SELECT ent_code FROM w_finess) + GROUP BY 1,2,3,4 + ; + + -- Inserer pour chaque bulletin une ligne qui va faire le compte avec le total + INSERT INTO rh.p_historique_paie + ( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + base, + montant_avantage_nature, + montant_brut, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + organisme_cotisation_id, + profil_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id + ) + SELECT + age_id, + contrat_id, + contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 AS base, + sum(an - subq.montant_avantage_nature) AS montant_avantage_nature, + sum(brut - subq.montant_brut) AS montant_brut, + sum(cotp - subq.montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(cots - subq.montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(fi - subq.montant_frais_imposables) AS montant_frais_imposables, + sum(netp - subq.montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(netf - subq.montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(od - subq.montant_od_net_salarie) AS montant_od_net_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS compte_id + FROM + ( + SELECT + max(p_historique_paie.age_id) AS age_id, + (max(ARRAY[p_historique_paie.mois_paie,p_historique_paie.contrat_id]))[2] AS contrat_id, + (max(ARRAY[p_historique_paie.mois_paie,p_historique_paie.contrat_mois_id]))[2] AS contrat_mois_id, + to_date(p_historique_paie.mois_paie, 'YYYYMM') AS date_debut, + (to_date(p_historique_paie.mois_paie, 'YYYYMM') + interval '1 month' - interval '1 day')::date AS date_fin, + p_historique_paie.date_paie, + p_historique_paie.mois_paie AS mois_activite, + p_historique_paie.mois_paie, + 0 AS base, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_brut) AS montant_brut, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(montant_frais_imposables) AS montant_frais_imposables, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(montant_od_net_salarie) AS montant_od_net_salarie, + 0 AS organisme_cotisation_id, + (max(ARRAY[p_historique_paie.mois_paie,p_historique_paie.profil_id]))[2] AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + p_historique_paie.salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie, + 0 AS compte_id + FROM rh.p_historique_paie + JOIN rh.p_salaries ON p_salaries.oid = p_historique_paie.salarie_id + GROUP BY 4,5,6,7,8,9,18,20,21 + ) as subq + JOIN rh.p_salaries ON p_salaries.oid = subq.salarie_id + JOIN w_totaux ON 1=1 + AND w_totaux.agent = p_salaries.matricule + AND w_totaux.mois = subq.mois_paie + WHERE 1!=1 + OR an - subq.montant_avantage_nature != 0 + OR brut - subq.montant_brut != 0 + OR cotp - subq.montant_cotisation_patronale != 0 + OR cots - subq.montant_cotisation_salarie != 0 + OR fi - subq.montant_frais_imposables != 0 + OR netp - subq.montant_net_a_payer_salarie != 0 + OR netf - subq.montant_net_imposable_salarie != 0 + OR od - subq.montant_od_net_salarie != 0 + GROUP BY 1,2,3,4,5,6,7,8,9, 18,19,20,21 + ; + + -- Màj des Comptes + UPDATE rh.p_historique_paie + SET compte_id = t_compte.oid + FROM rh.p_profils, rh.t_rubriques, w_cor, rh.t_compte + WHERE 1=1 + AND p_profils.oid = p_historique_paie.profil_id + AND t_rubriques.oid = p_historique_paie.rubrique_id + AND w_cor.rubrique = t_rubriques.code_original + AND w_cor.statut = p_profils.type_contrat_code_original + AND t_compte.code_original = w_cor.compte + ; + + -- Màj des Comptes : lorsque non renseigné, le compte agent est utilisé + UPDATE rh.p_historique_paie + SET compte_id = p_profils.compte_salarie_id + FROM rh.p_profils + WHERE 1=1 + AND p_profils.oid = p_historique_paie.profil_id + AND p_historique_paie.compte_id = 0 + ; + + ]]> + + + + + + + + + date de reprise). + TRUNCATE rh.p_arrets_travail_mois + ; + + INSERT INTO rh.p_arrets_travail_mois( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + nb_debut_arret, + nb_fin_arret, + nb_reprise_apres_arret, + date_debut, + date_fin, + nb_jours + ) + SELECT + p_arrets_travail.oid AS arret_travail_id, + p_arrets_travail.salarie_id AS salarie_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut), p_contrats_mois.contrat_id]))[2] AS contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_debut), p_contrats_mois.oid]))[2] AS contrat_mois_id, + p_calendrier_mois.mois AS mois_activite, + CASE WHEN p_arrets_travail.date_debut BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_arret, + CASE WHEN p_arrets_travail.date_fin BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_arret, + CASE WHEN p_arrets_travail.date_reprise BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_reprise_apres_arret, + GREATEST(p_calendrier_mois.date_debut, p_arrets_travail.date_debut) AS date_debut, + LEAST(p_calendrier_mois.date_fin, p_arrets_travail.date_fin) AS date_fin, + 0 AS nb_jours + FROM base.p_calendrier_mois + JOIN rh.p_arrets_travail ON base.cti_overlaps(p_arrets_travail.date_debut, p_arrets_travail.date_reprise, p_calendrier_mois.date_debut, p_calendrier_mois.date_fin) + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = p_arrets_travail.salarie_id + AND base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, p_calendrier_mois.date_debut, p_calendrier_mois.date_fin) + --WHERE p_arrets_travail.salarie_id = 9151 + GROUP BY 1,2,5,6,7,8,9,10,11 + --ORDER BY 9 desc, 5 desc + ; + + -- DOIT TOUJOURS TRAITER 0 enregistrement : Suppression des mois sans évènements séparant la date de fin et la date de reprise. + /* + DELETE FROM rh.p_arrets_travail_mois + WHERE 1=1 + AND nb_debut_arret = 0 + AND nb_fin_arret = 0 + AND nb_reprise_apres_arret = 0 + AND date_fin < date_debut + ; + */ + + -- Màj des dates de début/fin pour les reprises isolées sur un mois. + UPDATE rh.p_arrets_travail_mois + SET + date_debut = p_arrets_travail.date_reprise, + date_fin = p_arrets_travail.date_reprise + FROM rh.p_arrets_travail + WHERE 1=1 + AND p_arrets_travail.oid = p_arrets_travail_mois.arret_travail_id + AND nb_debut_arret = 0 + AND nb_fin_arret = 0 + AND nb_reprise_apres_arret = 1 + ; + + -- Calcul de la durée de l'absence "nb_jours". + UPDATE rh.p_arrets_travail_mois + SET nb_jours = date_fin - date_debut + 1 + ; + + -- Lorsque reprise isolée sur un mois, durée à 0. + UPDATE rh.p_arrets_travail_mois + SET nb_jours = 0 + WHERE 1=1 + AND nb_debut_arret = 0 + AND nb_fin_arret = 0 + AND nb_reprise_apres_arret = 1 + ; + + -- Quand absences contigües, ne pas compter comme une reprise (date reprise absence N = date début absence N+1). + UPDATE rh.p_arrets_travail_mois + SET nb_reprise_apres_arret = 0 + FROM rh.p_arrets_travail AS a1, rh.p_arrets_travail AS a2 + WHERE 1=1 + AND arret_travail_id = a1.oid + AND a1.salarie_id = a2.salarie_id + AND a1.date_reprise = a2.date_debut + AND nb_reprise_apres_arret = 1 + ; + + -- Quand reprise idolée sur un mois et sans contrat, la supprimer. + DELETE FROM rh.p_arrets_travail_mois + WHERE p_arrets_travail_mois.contrat_id IS NULL + ; + + ]]> + + + + + + + + + + + + + + + + + 0 ; + + -- Ventilation au 30eme sur le même mois + + -- DROP TABLE IF EXISTS w_contrats_multiples; + -- CREATE TEMP TABLE w_contrats_multiples AS + -- SELECT salarie_id, + -- mois_activite, + -- count(*) AS nb, + -- SUM(date_fin - date_debut + 1) AS nb_jours, + -- (MAX(Array[date_fin::text,p_contrats_mois.oid::text]))[2]::bigint AS contrat_mois_last_id, + -- (MAX(Array[date_fin::text,(date_fin - date_debut + 1)::text]))[2]::bigint AS nb_jours_last + -- FROM rh.p_contrats_mois + -- WHERE fictif IS DISTINCT FROM '1' + -- GROUP BY 1,2 + -- HAVING SUM(CASE WHEN fictif <> 1 THEN 1 ELSE 0 END) > 1; + + -- UPDATE w_contrats_multiples + -- SET nb_jours_last = 30 - nb_jours + nb_jours_last; + + + -- UPDATE rh.p_contrats_mois + -- SET equivalent_temps_plein = CASE WHEN oid <> contrat_mois_last_id THEN equivalent_temps_plein / 30 * (date_fin - date_debut + 1) ELSE equivalent_temps_plein / 30 * nb_jours_last END + -- FROM w_contrats_multiples + -- WHERE w_contrats_multiples.salarie_id = p_contrats_mois.salarie_id AND + -- w_contrats_multiples.mois_activite = p_contrats_mois.mois_activite AND + -- fictif IS DISTINCT FROM '1' ; + + -- Adaptation etp à duree dansle mois + DROP TABLE IF EXISTS w_contrats_mois_partiels; + CREATE TEMP TABLE w_contrats_mois_partiels AS + SELECT salarie_id, + mois_activite, + SUM(p_contrats_mois.date_fin - p_contrats_mois.date_debut + 1) AS nb_jours, + MAX(p_calendrier_mois.date_fin - p_calendrier_mois.date_debut + 1) AS nb_jours_mois + FROM rh.p_contrats_mois + JOIN base.p_calendrier_mois ON mois_activite = p_calendrier_mois.mois + WHERE fictif IS DISTINCT FROM '1' + GROUP BY 1,2; + + + + UPDATE rh.p_contrats_mois + SET equivalent_temps_plein = + equivalent_temps_plein * + (p_contrats_mois.date_fin - p_contrats_mois.date_debut + 1.00) / + CASE WHEN nb_jours <> nb_jours_mois THEN 30 ELSE nb_jours_mois END + FROM base.p_calendrier_mois, + w_contrats_mois_partiels + WHERE + p_contrats_mois.salarie_id = w_contrats_mois_partiels.salarie_id AND + p_contrats_mois.mois_activite = w_contrats_mois_partiels.mois_activite AND + p_contrats_mois.mois_activite = p_calendrier_mois.mois AND + fictif <> 1 AND + ( + p_contrats_mois.date_debut > p_calendrier_mois.date_debut OR + p_contrats_mois.date_fin < p_calendrier_mois.date_fin + ); + + + -- Pas d'etp sur sortis + + DROP TABLE IF EXISTS w_contrats_mois_sortis; + CREATE TEMP TABLE w_contrats_mois_sortis AS + SELECT salarie_id, + p_contrats_mois.oid AS contrat_mois_id, + mois_activite, + p_contrats_mois.date_debut, + p_contrats_mois.date_fin + FROM rh.p_contrats_mois + JOIN rh.p_salaries ON salarie_id = p_salaries.oid + LEFT JOIN prod_shspub.pippub184_agpayp ON matricule = ACDAGT AND + ( + p_contrats_mois.date_debut BETWEEN DATE(adtpay) AND date(ADTFPA) AND ASSPAY <> 3 AND ASSPAY <> 9 OR + p_contrats_mois.date_fin BETWEEN DATE(adtpay) AND date(ADTFPA) AND ASSPAY <> 3 AND ASSPAY <> 9 + ) + WHERE fictif IS DISTINCT FROM '1' AND ACDAGT IS NULL AND + equivalent_temps_plein <> 0; + + + UPDATE rh.p_contrats_mois + SET equivalent_temps_plein = 0 + FROM w_contrats_mois_sortis + WHERE w_contrats_mois_sortis.contrat_mois_id = p_contrats_mois.oid ; + + -- Initialisation de l'ETP ventilé mensuellement à 0 lorsque qu'aucune rubrique d'heures payées + -- n'est présente sur le bulletin de paie du mois. + UPDATE rh.p_contrats_mois + SET equivalent_temps_plein = 0 + WHERE 1=1 + AND equivalent_temps_plein <> 0 + AND oid NOT IN + ( + SELECT contrat_mois_id + FROM rh.p_historique_paie + WHERE rubrique_id IN (SELECT oid FROM rh.t_rubriques WHERE code_calcul = '1') + ) + ; + + -- Report des ratios sur des sorties vers des non sorties + + DROP TABLE IF EXISTS w_profils_contrats_mois_absents; + CREATE TEMP TABLE w_profils_contrats_mois_absents AS + SELECT p_contrats_mois.oid AS contrat_mois_id, + mois_activite, matricule, + MIN(CASE WHEN groupe_cotisant_code NOT IN ('3', '9') THEN p_profil_contrat_mois.profil_id ELSE NULL END) AS profil_id_1, + SUM(CASE WHEN groupe_cotisant_code NOT IN ('3', '9') THEN 1 ELSE 0 END) AS nb_1, + SUM(CASE WHEN groupe_cotisant_code IN ('3', '9') THEN 1 ELSE 0 END) AS nb_9, + SUM(CASE WHEN groupe_cotisant_code NOT IN ('3', '9') THEN ratio ELSE 0 END) AS ratio_1, + SUM(CASE WHEN groupe_cotisant_code IN ('3', '9') THEN ratio ELSE 0 END) AS ratio_9 + FROM rh.p_contrats_mois + JOIN rh.p_salaries on salarie_id = p_salaries.oid + JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid + JOIN rh.p_profils ON p_profil_contrat_mois.profil_id = p_profils.oid + GROUP BY 1,2,3 + HAVING count(*) > 1 AND + SUM(CASE WHEN groupe_cotisant_code IN ('3', '9') THEN 1 ELSE 0 END) <> 0 AND + SUM(CASE WHEN groupe_cotisant_code NOT IN ('3', '9') THEN 1 ELSE 0 END) <> 0; + + UPDATE rh.p_profil_contrat_mois + SET ratio = + CASE WHEN groupe_cotisant_code IN ('3', '9') THEN 0 + WHEN profil_id = profil_id_1 THEN ratio + ratio_9 + ELSE ratio END + FROM rh.p_profils, + w_profils_contrats_mois_absents + + WHERE p_profil_contrat_mois.profil_id = p_profils.oid AND + p_profil_contrat_mois.contrat_mois_id = w_profils_contrats_mois_absents.contrat_mois_id; + + + ]]> + + + + w_MANDAP.compte_id; + + ]]> + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SIGEMS.XML b/import_rh/iCTI_import_rh_SIGEMS.XML new file mode 100644 index 0000000..e1a85b8 --- /dev/null +++ b/import_rh/iCTI_import_rh_SIGEMS.XML @@ -0,0 +1,2779 @@ + + + + + + on remonte toutes les entités. + when (SELECT max(length(rhp_in)) = 9 from (select rhp_in('siren')) as subq) THEN substr(siret, 1, 9) IN (SELECT rhp_in('siren')) -- Un ou des SIREN paramétrés => on remonte toutes les entreprises associées (sur 9 cars). + when (SELECT max(length(rhp_in)) = 2 from (select rhp_in('siren')) as subq) THEN ste IN (SELECT rhp_in('siren')) -- ste + else siret IN (SELECT rhp_in('siren')) -- Un ou des SIRET paramétrés => on remonte tous les établissements associés (sur 14 cars). + end + ; + + -- Màj des Depts. + INSERT INTO rh.t_departements(code, texte, texte_court) + SELECT code_departement, libelle, substr(libelle,1,50) + FROM prod_sigems.departement + WHERE code_departement NOT IN (SELECT code FROM rh.t_departements) + ; + + -- Màj des Entreprises + INSERT INTO rh.t_entreprises(code, texte, texte_court, code_original, siren) + SELECT + etab.ste, + max(etab.nometab1), + max(substr(etab.nometab1, 1, 50)), + etab.ste, + substr(etab.siret, 1, 9) + FROM prod_sigems.etab + JOIN w_ets ON 1=1 + AND w_ets.ste = etab.ste + AND w_ets.etbl = etab.etbl + WHERE etab.ste NOT IN (SELECT code_original FROM rh.t_entreprises) + GROUP BY 1,4,5 + ; + + with ent as ( + SELECT + t_entreprises.oid, + substr(etab.siret, 1, 9) AS siren + FROM rh.t_entreprises + JOIN prod_sigems.etab on etab.ste = t_entreprises.code_original) + UPDATE rh.t_entreprises + SET siren = ent.siren + FROM ent + WHERE 1=1 + and t_entreprises.oid = ent.oid + and t_entreprises.siren IS DISTINCT FROM ent.siren + ; + + -- Màj des Etablissements + INSERT INTO rh.t_etablissements(code, texte, texte_court, code_original, entreprise_id, siret) + SELECT + etab.etbl, + etab.nometab1, + substr(etab.nometab1, 1, 50), + etab.ste||etab.etbl, + t_entreprises.oid, + etab.siret + FROM prod_sigems.etab + JOIN w_ets ON 1=1 + AND w_ets.ste = etab.ste + AND w_ets.etbl = etab.etbl + JOIN rh.t_entreprises ON t_entreprises.code_original = etab.ste + WHERE etab.ste||etab.etbl NOT IN (SELECT code_original FROM rh.t_etablissements) + GROUP BY 1,2,3,4,5,6 + ; + + with eta as ( + SELECT + t_etablissements.oid, + etab.siret as siret + FROM rh.t_etablissements + JOIN prod_sigems.etab on etab.ste||etab.etbl = t_etablissements.code_original) + UPDATE rh.t_etablissements + SET siret = eta.siret + FROM eta + WHERE 1=1 + and t_etablissements.oid = eta.oid + and t_etablissements.siret IS DISTINCT FROM eta.siret + ; + + -- Màj des catégories socio-professionnelles + INSERT INTO rh.t_categories_socio_professionnelle + (code, texte, texte_court, code_original) + SELECT lower(c_pcs), libelpcs, substr(libelpcs,1,50), lower(c_pcs) + FROM prod_sigems.ipcs + WHERE lower(c_pcs) NOT IN (SELECT code_original FROM rh.t_categories_socio_professionnelle) + AND c_pcs != '' + GROUP BY 1,2,3,4 + ; + + -- KO Màj des groupes cotisants. + INSERT INTO rh.t_groupes_cotisant(code, texte, texte_court, code_original) + SELECT c_group,lib_group,substr(lib_group,1,50),c_group + FROM prod_sigems.groupe_fiehp + WHERE c_group NOT IN (SELECT code_original FROM rh.t_groupes_cotisant) + GROUP BY 1,2,3,4 + ; + + -- Màj des motifs de début de contrat + DROP TABLE IF EXISTS w_tmp_mar_0 + ; + + CREATE TEMP TABLE w_tmp_mar_0 AS + SELECT + motif_abs AS libelle, + upper(translate(translate(motif_abs,'éèà','eea'),' -)(','')) AS libellecode + FROM prod_sigems.REMPLACEMENT + GROUP BY 1,2 + ; + + DROP TABLE IF EXISTS w_tmp_mar_1 + ; + + CREATE TEMP TABLE w_tmp_mar_1 AS + SELECT + rpad(substr(libellecode,1,4) || substr(upper(md5(libelle)),1,2),6,'0') as code, + libelle as code_original + FROM w_tmp_mar_0 + ; + + INSERT INTO rh.t_motifs_debut_contrat(code, code_original, texte, texte_court) + SELECT + motif_deb||CASE WHEN motif_abs IS NULL OR trim(motif_abs) = '' THEN '000000' ELSE w_tmp_mar_1.code END as code, + motif_deb||CASE WHEN w_tmp_mar_1.code_original IS NULL THEN '' ELSE w_tmp_mar_1.code_original END as code_original, + CASE WHEN motif_abs IS NULL OR trim(motif_abs) = '' THEN DADSU_TABLES.libelle ELSE substr(DADSU_TABLES.libelle,1,10)||' '||motif_abs END as texte, + substr(CASE WHEN motif_abs IS NULL OR trim(motif_abs) = '' THEN DADSU_TABLES.libelle ELSE substr(DADSU_TABLES.libelle,1,10)||' '||motif_abs END,1,50) as texte_court + FROM prod_sigems.CONTRATS_PB + LEFT JOIN prod_sigems.DADSU_TABLES ON DADSU_TABLES.code = CONTRATS_PB.motif_deb + LEFT JOIN prod_sigems.REMPLACEMENT ON REMPLACEMENT.id_cont = CONTRATS_PB.id_cont + LEFT JOIN w_tmp_mar_1 ON w_tmp_mar_1.code_original = REMPLACEMENT.motif_abs + WHERE 1=1 + AND DADSU_TABLES.code_structure = 'S41.G01.00.002.001' + AND (motif_deb||CASE WHEN w_tmp_mar_1.code_original IS NULL THEN '' ELSE w_tmp_mar_1.code_original END) NOT IN (SELECT code_original FROM rh.t_motifs_debut_contrat) + AND motif_deb IS NOT NULL + AND trim(motif_deb) <> '' + GROUP BY 1,2,3,4 + ORDER BY 1,2 + ; + + -- Màj des motifs de fin de contrat + INSERT INTO rh.t_motifs_fin_contrat(code, texte, texte_court, code_original) + SELECT code, libelle, substr(libelle,1,50), code + FROM prod_sigems.dadsu_tables + WHERE code NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat) + AND code_structure = 'S41.G01.00.004.001' + GROUP BY 1,2,3,4 + ; + + /*SELECT c_motf, libelmotf, substr(libelmotf,1,50), c_motf + FROM prod_sigems.motf + WHERE c_motf NOT IN (SELECT code_original FROM rh.t_motifs_fin_contrat) + GROUP BY 1,2,3,4*/ + + -- Màj des nationalités + INSERT INTO rh.t_nationalites(code, texte, texte_court, code_original) + SELECT c_nati, libelnati, substr(libelnati,1,50), c_nati + FROM prod_sigems.nati + WHERE c_nati NOT IN (SELECT code_original FROM rh.t_nationalites) + GROUP BY 1,2,3,4 + ; + + -- Màj des organismes de cotisation + INSERT INTO rh.t_organismes_cotisation(code, texte, texte_court, code_original) + SELECT code, libelle, substr(libelle,1,50), code + FROM prod_sigems.dadsu_typcont + WHERE code NOT IN (SELECT code_original FROM rh.t_organismes_cotisation) + GROUP BY 1,2,3,4 + ; + + -- Màj des codes emplois + INSERT INTO rh.t_codes_emploi(code, texte, texte_court, code_original) + SELECT c_empl, libelempl, substr(libelempl, 1, 50), c_empl + FROM prod_sigems.empl + WHERE c_empl NOT IN (SELECT code_original FROM rh.t_codes_emploi) + GROUP BY 1,2,3,4 + ; + + -- Màj des qualifications + INSERT INTO rh.t_qualifications(code, texte, texte_court, code_original) + SELECT c_qual, nomqual, substr(nomred,1,50), c_qual + FROM prod_sigems.qual + WHERE 1=1 + AND trim(c_qual) != '' + AND c_qual NOT IN (SELECT code_original FROM rh.t_qualifications) + GROUP BY 1,2,3,4 + ; + + UPDATE rh.t_qualifications + SET texte_court = substr(texte,1,50) + WHERE char_length(trim(texte_court)) = 0 + ; + + -- Màj des rubriques + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT reduitr, libel, substr(libel,1,50), reduitr, ordre + FROM prod_sigems.rub + WHERE reduitr NOT IN (SELECT code_original FROM rh.t_rubriques) + GROUP BY 1,2,3,4,5 + ; + + -- (création des rubriques CTI de cumul) + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C000', 'Ecart cumulé', 'Ecart cumulé', 'C000', -1 + WHERE 'C000' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C007', 'Heures payées', 'Heures payées', 'C007', -1 + WHERE 'C007' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C507', 'Heures travaillées', 'Heures travaillées', 'C507', -1 + WHERE 'C507' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C001', 'Brut', 'Brut', 'C001', -1 + WHERE 'C001' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C003', 'Cotisations salariales', 'Cotisations salariales', 'C003', -1 + WHERE 'C003' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C881', 'Heures payées cadre', 'Heures payées cadre', 'C881', -1 + WHERE 'C881' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C998', 'Cotisations patronales', 'Cotisations patronales', 'C998', -1 + WHERE 'C998' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C005', 'Net imposable', 'Net imposable', 'C005', -1 + WHERE 'C005' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition) + SELECT 'C011', 'Net à payer', 'Net à payer', 'C011', -1 + WHERE 'C011' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + -- Ajout de la rubrique si elle n'existe pas déjà. + INSERT INTO rh.t_rubriques(code_original, code, texte, texte_court, rang_edition) + SELECT 'C714', 'C714', 'Taxe sur les salaires', 'Taxe sur les salaires', -1 + WHERE 1=1 + AND (SELECT valeur = '1' FROM rh.t_divers WHERE code = 'SIGEMS_TS') -- Taxe sur les salaires que si l'option a été définie à 1. + AND 'C714' NOT IN (SELECT code_original FROM rh.t_rubriques) + ; + + -- Mà des Comptes. + INSERT INTO rh.t_compte(code_original, code, texte, texte_court) + SELECT n_cpt, n_cpt, n_cpt, n_cpt + FROM prod_sigems.rub + WHERE 1=1 + and n_cpt NOT IN (SELECT code_original FROM rh.t_compte WHERE code_original IS NOT NULL) + and length(trim(n_cpt)) > 0 + GROUP BY 1,2,3,4 + ; + + -- Màj des situations de famille + INSERT INTO rh.t_situations_famille(code, texte, texte_court, code_original) + SELECT cod_sit, lib_sit, substr(lib_sit,1,50), cod_sit + FROM prod_sigems.situation + WHERE cod_sit NOT IN (SELECT code_original FROM rh.t_situations_famille) + GROUP BY 1,2,3,4 + ; + + INSERT INTO rh.t_situations_famille(code, texte, texte_court, code_original) + SELECT c_sfa, c_sfa, c_sfa, c_sfa + FROM prod_sigems.pers + JOIN w_ets ON w_ets.ste||w_ets.etbl = pers.ste||pers.etb + WHERE + c_sfa IS NOT NULL + AND trim(c_sfa) <> '' + AND c_sfa NOT IN (SELECT code_original FROM rh.t_situations_famille) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de contrat + INSERT INTO rh.t_types_contrat(code, texte, texte_court, code_original) + SELECT typecont, typecont, substr(typecont,1,50), typecont + FROM prod_sigems.contrats_pb + WHERE + typecont NOT IN (SELECT code_original FROM rh.t_types_contrat) + AND typecont <> '' + GROUP BY 1,2,3,4 + ; + + /* + SELECT cod_nat, lib_nat, substr(lib_nat,1,50), cod_nat + FROM prod_sigems.nature_contrat + WHERE cod_nat NOT IN (SELECT code_original FROM rh.t_types_contrat) + GROUP BY 1,2,3,4 + */ + + -- Màj des statuts + INSERT INTO rh.t_statuts(code, texte, texte_court, code_original) + SELECT c_stat, libelstat, substr(libelstat,1,50), c_stat + FROM prod_sigems.stat + WHERE c_stat NOT IN (SELECT code_original FROM rh.t_statuts) + GROUP BY 1,2,3,4 + ; + + -- Màj des types de temps de travail + INSERT INTO rh.t_types_temps_travail(code_original, code, texte, texte_court) + SELECT caract, caract, caract, caract + FROM prod_sigems.contrats_pb + WHERE caract NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + GROUP BY 1,2,3,4 + ; + + /*SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.dadsu_tables + WHERE code NOT IN (SELECT code_original FROM rh.t_types_temps_travail) + AND code_structure ilike 'S41.G01.00.013%' + GROUP BY 1,2,3,4*/ + + -- Màj des services + INSERT INTO rh.t_services(code_original, code, texte, texte_court) + SELECT c_serv, c_serv, nomserv, substr(nomserv,1,50) + FROM prod_sigems.serv + WHERE c_serv NOT IN (SELECT code_original FROM rh.t_services) + GROUP BY 1,2,3,4 + ; + + -- Màj des spécialités + INSERT INTO rh.t_specialites(code_original, code, texte, texte_court) + SELECT cod_spe, cod_spe, lib_spe, substr(lib_spe,1,50) + FROM prod_sigems.specialite + WHERE cod_spe NOT IN (SELECT code_original FROM rh.t_specialites) + GROUP BY 1,2,3,4 + ; + + -- Màj des types d'horaire + INSERT INTO rh.t_types_horaire(code_original, code, texte, texte_court) + -- SELECT cod_hor, cod_hor, lib_hor, substr(lib_hor,1,50) + -- FROM prod_sigems.horaire + -- WHERE cod_hor NOT IN (SELECT code_original FROM rh.t_types_horaire) + -- GROUP BY 1,2,3,4 + SELECT c_ssec, c_ssec, c_ssec, substr(c_ssec, 1, 50) + FROM prod_sigems.contrats_pb + WHERE c_ssec NOT IN (SELECT code_original FROM rh.t_types_horaire) + GROUP BY 1,2,3,4 + ; + + -- Màj des sociétés d'interim + + -- Màj des grilles + + -- Suppression doublons suite à bug (à enlever en mars 2023) + DELETE FROM rh.t_grilles + USING + ( + SELECT code_original, count(*), + MAX(CASE WHEN oid IN (SELECT grille_id FROM rh.p_profils) THEN oid ELSE 0 END) AS last_use, + MIN(oid) AS first_create + FROM rh.t_grilles + WHERE oid <> 0 + GROUP BY 1 + HAVING count(*) > 1 + ) subview + WHERE t_grilles.code_original = subview.code_original AND + ( + t_grilles.oid <> last_use AND last_use > 0 OR + t_grilles.oid <> first_create AND last_use = 0 + ) + ; + + -- Ajout des nouvelles + INSERT INTO rh.t_grilles(code_original, code, texte, texte_court) + SELECT + lpad(c_group,2,'0')||lpad(qualif,4,'0'), + lpad(c_group,2,'0')||lpad(qualif,4,'0'), + lib_group||CASE WHEN qualif <> '' THEN ' Q'||qualif ELSE '' END, + substr(lib_group||CASE WHEN qualif <> '' THEN ' Q'||qualif ELSE '' END,1,50) + FROM prod_sigems.groupe_fiehp + WHERE lpad(c_group,2,'0')||lpad(qualif,4,'0') NOT IN (SELECT code_original FROM rh.t_grilles) + GROUP BY 1,2,3,4 + ; + + -- Màj des groupes de grilles + INSERT INTO rh.t_grilles_groupes(code_original, code, texte, texte_court) + SELECT c_group, c_group, lib_group, substr(lib_group,1,50) + FROM prod_sigems.groupe_fiehp + WHERE c_group NOT IN (SELECT code_original FROM rh.t_grilles_groupes) + GROUP BY 1,2,3,4 + ; + + -- Màj des motifs d'arret + INSERT INTO rh.t_motifs_arret(code_original, code, texte, texte_court) + SELECT code, code, lib, substr(lib,1,50) + FROM prod_sigems.motif_arret + WHERE code NOT IN (SELECT code_original FROM rh.t_motifs_arret) + GROUP BY 1,2,3,4 + ; + + -- Màj des précisions du motif d'arrêt + + -- Màj des motifs de visite médicale + INSERT INTO rh.t_motifs_visite(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.MOTIF_VISMED + WHERE code NOT IN (SELECT code_original FROM rh.t_motifs_visite) + GROUP BY 1,2,3,4 + ; + + -- Màj des circonstances d'accident du travail + INSERT INTO rh.t_accident_circonstance(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.acc_circst + WHERE + code NOT IN (SELECT code_original FROM rh.t_accident_circonstance) + AND code <> '' + AND code IS DISTINCT FROM NULL + GROUP BY 1,2,3,4 + ; + + -- Màj des lieux d'accident du travail + DROP TABLE IF EXISTS w_tmp_lieu_0 + ; + + CREATE TEMP TABLE w_tmp_lieu_0 AS + SELECT + lieu as libelle, + upper(translate(translate(lieu,'éèà','eea'),' ,-)(+/''','')) AS libellecode + FROM prod_sigems.acctravail + WHERE + lieu <> '' + AND lieu IS DISTINCT FROM NULL + ; + + DROP TABLE IF EXISTS w_tmp_lieu_1 + ; + + CREATE TEMP TABLE w_tmp_lieu_1 AS + SELECT + rpad(substr(libellecode,1,4) || substr(upper(md5(libelle)),1,2),6,'0') as code, + libelle as code_original + FROM w_tmp_lieu_0 + ; + + INSERT INTO rh.t_accident_lieu(code_original, code, texte, texte_court) + SELECT code_original, code, code_original, substr(code_original,1,50) + FROM w_tmp_lieu_1 + WHERE + code_original NOT IN (SELECT code_original FROM rh.t_accident_lieu) + GROUP BY 1,2,3,4 + ; + + -- Màj de la nature de l'accident du travail + INSERT INTO rh.t_accident_nature(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.acc_nature + WHERE + code NOT IN (SELECT code_original FROM rh.t_accident_nature) + AND code <> '' + AND code IS DISTINCT FROM NULL + GROUP BY 1,2,3,4 + ; + + -- Màj des sièges d'accident du travail + INSERT INTO rh.t_accident_siege(code_original, code, texte, texte_court) + SELECT code, code, libelle, substr(libelle,1,50) + FROM prod_sigems.acc_siege + WHERE + code NOT IN (SELECT code_original FROM rh.t_accident_siege) + AND code <> '' + AND code IS DISTINCT FROM NULL + GROUP BY 1,2,3,4 + ; + + -- Màj des listes de formations + INSERT INTO rh.t_liste_formations(code_original, code, texte, texte_court) + SELECT id_formation, id_formation, libelfrma, substr(libelfrma,1,50) + FROM prod_sigems.frma + WHERE id_formation NOT IN (SELECT code_original FROM rh.t_liste_formations) + GROUP BY 1,2,3,4 + ; + + ]]> + + + + + + + + + = 2014 + GROUP BY 1,2,3 + ; + + ]]> + + + 1 + ) + SELECT + (CASE WHEN dtdebu IS DISTINCT FROM NULL AND char_length(dtdebu) > 0 THEN dtdebu ELSE '1900-01-01' END)::date AS date_debut, + (CASE WHEN dtsort IS DISTINCT FROM NULL AND char_length(dtsort) > 0 THEN dtsort ELSE '2099-12-31' END)::date AS date_fin, + mat||'-'||id_cont AS u_id_cont, -- Attention : u_id_cont n'est pas forcément chronologique, d'où rang_contrat. + rank() OVER (PARTITION BY mat ORDER BY (CASE WHEN dtdebu IS DISTINCT FROM NULL AND char_length(dtdebu) > 0 THEN dtdebu ELSE '1900-01-01' END)::date) rang_contrat, + contrats_pb.* + FROM prod_sigems.contrats_pb + JOIN w_ets ON 1=1 + AND w_ets.ste = contrats_pb.soc + AND w_ets.etbl = contrats_pb.etb + left join discarded_cnt on discarded_cnt.dc_id_cont = contrats_pb.id_cont + WHERE 1=1 + AND dtdebu IS NOT NULL + AND mat IS DISTINCT FROM NULL + AND mat != '' + AND mat NOT IN (SELECT mat FROM w_exc_mat) + and discarded_cnt.dc_mat is null + ; + + -- #correction Lorsque le statut n'est pas alimenté une seule fois pour un matricule, + -- utiliser le statut de la fiche salarié + UPDATE w_cnt + SET c_stat = pers.c_stat + FROM prod_sigems.pers, w_ets + WHERE 1=1 + AND pers.mat = w_cnt.mat + AND w_ets.ste||w_ets.etbl = pers.ste||pers.etb + AND w_cnt.mat IN ( + SELECT mat + FROM w_cnt + WHERE 1!=1 + OR c_stat IS NULL + OR char_length(c_stat) = 0 + GROUP BY 1) + ; + + + -- Création d'un table propre des remplacements + DROP TABLE IF EXISTS w_rmp + ; + + CREATE TEMP TABLE w_rmp AS + SELECT + id_cont, + max(motif_abs) AS motif_abs + FROM prod_sigems.remplacement + GROUP BY 1 + ; + + -- Création d'un table temp de profils + DROP TABLE IF EXISTS w_profils + ; + + CREATE TEMP TABLE w_profils AS + SELECT + 0 as profil_id, + w_cnt.soc as ste, + w_cnt.etb, + w_cnt.mat, + w_cnt.date_debut as grh_dtdu, + w_cnt.date_fin as grh_dtau, + w_cnt.id_cont, + w_cnt.u_id_cont, + w_cnt.rang_contrat, + w_cnt.nbh_mens, + w_cnt.date_debut as contrat_dtdu, + w_cnt.date_fin as contrat_dtau, + -- Champs dédiés au privé. + COALESCE(lower(pers.c_pcs),chr(1)||'*') AS categorie_socio_professionnelle_code_original, + COALESCE(pers.c_emp, chr(1)||'*') AS code_emploi_code_original, + COALESCE(lpad(groupe_fiehp.c_group, 2, '0')||lpad(groupe_fiehp.qualif, 4, '0'), chr(1)||'*') AS grille_code_original, + COALESCE(groupe_fiehp.c_group, chr(1)||'*') AS grille_groupe_code_original, + chr(1)||'*' AS groupe_cotisant_code_original, + COALESCE(w_cnt.motif_deb||CASE WHEN w_rmp.motif_abs IS NULL THEN '' ELSE w_rmp.motif_abs END, chr(1)||'*') AS motif_debut_code_original, + COALESCE(w_cnt.motif_fin,chr(1)||'*') AS motif_fin_code_original, + COALESCE(pers.c_qual, chr(1)||'*') AS qualification_code_original, + chr(1)||'*' AS section_analytique_code_original, + chr(1)||'*' AS section_analytique_paie_code_original, + COALESCE(nullif(trim(w_cnt.serv), ''), nullif(trim(pers.c_serv), ''), chr(1)||'*') AS service_code_original, + chr(1)||'*' AS societe_interim_code_original, + chr(1)||'*' AS specialite_code_original, + COALESCE(w_cnt.c_stat,chr(1)||'*') AS statut_code_original, + COALESCE(w_cnt.typecont,chr(1)||'*') AS type_contrat_code_original, --GREATEST(w_cnt.nature,chr(1)||'*') AS type_contrat_code_original, + COALESCE(nullif(trim(w_cnt.c_ssec), ''), chr(1)||'*') AS type_horaire_code_original, + COALESCE(w_cnt.caract,chr(1)||'*') AS type_temps_travail_code_original, + -- Champs dédiés au public. + chr(1)||'*' AS unite_fonctionnelle_code_original, + chr(1)||'*' AS categorie_conge_code_original, + chr(1)||'*' AS compte_salarie_code_original, + chr(1)||'*' AS commission_paritaire_code_original, + chr(1)||'*' AS lettre_budgetaire_code_original, + chr(1)||'*' AS cadre_emploi_code_original, + chr(1)||'*' AS filiere_code_original, + chr(1)||'*' AS categorie_statutaire_code_original + FROM w_cnt + LEFT JOIN prod_sigems.pers on 1=1 + AND pers.mat = w_cnt.mat + AND pers.ste = w_cnt.soc + AND pers.etb = w_cnt.etb + LEFT JOIN prod_sigems.groupe_fiehp on 1=1 + AND groupe_fiehp.qualif = pers.c_qual + AND groupe_fiehp.qualif <> '' + AND groupe_fiehp.qualif IS DISTINCT FROM NULL + LEFT JOIN w_rmp ON w_rmp.id_cont = w_cnt.id_cont + WHERE w_cnt.mat NOT IN (SELECT mat FROM w_exc_mat) + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 + ; + + ]]> + + + + 'O' + AND trim(pers.mat) != '' + AND pers.ste != 'XX' + AND pers.etb != 'XX' + AND pers.mat NOT IN (SELECT mat FROM w_exc_mat) + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19,20,21,22,23,24,25,26 + ; + + -- Les dates d'entrée et de sortie établissement sont calculées à partir des contrats. + UPDATE w_salaries + SET date_entree_ets = date_debut, + date_sortie_ets = date_fin + ; + + ]]> + + + + '' + GROUP BY 1,2,3,4,5,6,7 + ; + + -- Ajout des salariés remplacés + UPDATE rh.p_contrats + SET salarie_remplace_id = subq.salarie_remplace_id + FROM ( + SELECT + mat||'-'||id_cont AS u_id_cont, + max(p_salaries.oid) AS salarie_remplace_id + FROM prod_sigems.remplacement + JOIN rh.p_salaries on p_salaries.matricule = remplacement.mat_abs + WHERE 1=1 + AND id_cont <> 0 + AND mat_abs IS NOT NULL + AND mat_abs <> '' + GROUP BY 1 + ) AS subq + WHERE numero_contrat = subq.u_id_cont + ; + + -- Calcul ancienneté au début de contrat + UPDATE rh.p_contrats + SET + anciennete_anterieure_jours = subq.anciennete_anterieure_jours, + anciennete_anterieure_calculee_mois = subq.anciennete_anterieure_calculee_mois + FROM ( + SELECT + t1.u_id_cont AS numero_contrat, + sum(coalesce(t2.contrat_dtau::date, '20991231'::date) - t2.contrat_dtdu::date + 1) AS anciennete_anterieure_jours, + sum(coalesce(t2.contrat_dtau::date, '20991231'::date) - t2.contrat_dtdu::date + 1) / 30 AS anciennete_anterieure_calculee_mois + FROM w_contrats AS t1 + JOIN w_contrats AS t2 ON 1=1 + AND t2.mat = t1.mat + AND t2.rang_contrat < t1.rang_contrat + group by 1 + ) AS subq + WHERE 1=1 + AND p_contrats.numero_contrat = subq.numero_contrat + ; + + -- Ventilation des contrats par mois + TRUNCATE rh.p_contrats_mois + ; + + ALTER SEQUENCE rh.s_contrats_mois RESTART WITH 1 + ; + + INSERT INTO rh.p_contrats_mois( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + nombre_entrees, + nombre_departs, + nombre_debut_contrat, + nombre_fin_contrat, + est_hors_periode, + present_debut_mois, + present_fin_mois, + nombre_heures, + ratio_temps_travail, + equivalent_temps_plein, + age_id, + age_jours, + anciennete_jours, + anciennete_mois, + anciennete_annee_id) + SELECT + p_contrats.salarie_id AS salarie_id, + p_contrats.oid AS contrat_id, + p_calendrier_mois.mois AS mois, + GREATEST(p_calendrier_mois.date_debut, p_contrats.date_debut) AS date_debut, + LEAST(p_calendrier_mois.date_fin, p_contrats.date_fin) AS date_fin, + CASE WHEN p_salaries.date_entree_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_entrees, + CASE WHEN p_salaries.date_sortie_ets BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_departs, + CASE WHEN p_contrats.date_debut BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_contrat, + CASE WHEN p_contrats.date_fin BETWEEN p_calendrier_mois.date_debut AND p_calendrier_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_contrat, + '0' AS est_hors_periode, + CASE WHEN p_calendrier_mois.date_debut BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_debut_mois, + CASE WHEN p_calendrier_mois.date_fin BETWEEN p_contrats.date_debut AND p_contrats.date_fin THEN 1 ELSE 0 END AS present_fin_mois, + w_contrats.nbh_mens::numeric AS nombre_heures, -- /!\ Nombre d'heures a priori non proratisé : correspond au temps de travail. + w_contrats.nbh_mens::numeric / t_etablissements.base_calcul_etp::numeric as ratio_temps_travail, -- Correspond au type de temps de travail : temps complet = 1; mi-temps = 0.5; etc. + (w_contrats.nbh_mens::numeric / t_etablissements.base_calcul_etp::numeric) + * ( + (LEAST(p_calendrier_mois.date_fin, p_contrats.date_fin) - GREATEST(p_calendrier_mois.date_debut, p_contrats.date_debut) + 1)::numeric + / + (p_calendrier_mois.date_fin - p_calendrier_mois.date_debut + 1)::numeric + ) AS equivalent_temps_plein, + base.cti_age(LEAST(p_calendrier_mois.date_fin, p_contrats.date_fin), COALESCE(p_salaries.date_naissance, '1962-04-18'::date), 'ny') AS age_id, + LEAST(p_calendrier_mois.date_fin, p_contrats.date_fin)::date - COALESCE(p_salaries.date_naissance, '1962-04-18'::date) AS age_jours, + -- Ancienneté en jours + p_contrats.anciennete_anterieure_jours + + (p_calendrier_mois.date_fin - p_contrats.date_debut) + + 1 + AS anciennete_jours, + -- Ancienneté en mois + base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',p_contrats.date_debut)::date, 'nm') + + GREATEST(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + + 1 + AS anciennete_mois, + -- Ancienneté en années + floor( + (base.cti_age(date_trunc('month',p_calendrier_mois.date_fin::date)::date, date_trunc('month',p_contrats.date_debut)::date, 'nm') + + GREATEST(p_contrats.anciennete_anterieure_mois, p_contrats.anciennete_anterieure_calculee_mois) + + 1) / 12) + AS anciennete_annee_id + FROM rh.p_contrats + JOIN rh.p_salaries ON p_contrats.salarie_id = p_salaries.oid + JOIN rh.t_etablissements ON p_contrats.etablissement_id = t_etablissements.oid + JOIN rh.t_entreprises ON t_etablissements.entreprise_id = t_entreprises.oid + JOIN base.p_calendrier_mois ON (p_contrats.date_debut <= p_calendrier_mois.date_fin AND p_contrats.date_fin >= p_calendrier_mois.date_debut) + JOIN w_contrats ON w_contrats.u_id_cont = p_contrats.numero_contrat + GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 + ; + + -- Màj des âges négatifs (plage autorisée : 0 -> 110 ans) + UPDATE rh.p_contrats_mois + SET age_id = 0 + WHERE age_id < 0 + ; + + UPDATE rh.p_contrats_mois + SET age_id = (SELECT max(oid) FROM rh.t_ages) + WHERE age_id > (SELECT max(oid) FROM rh.t_ages) + ; + + -- Màj des anciennetés trop grandes (plage autorisée : 0 -> 50 ans) + UPDATE rh.p_contrats_mois + SET anciennete_annee_id = 0 + WHERE anciennete_annee_id < 0 + ; + + UPDATE rh.p_contrats_mois + SET anciennete_annee_id = (SELECT max(oid) FROM rh.t_anciennetes_annee) + WHERE anciennete_annee_id > (SELECT max(oid) FROM rh.t_anciennetes_annee) + ; + + ]]> + + + = '2014-01-01'::date + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + -- Alimentation de la colonne "Taux salarial". + INSERT INTO w_hp_sq + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + mat||'-'||id_contrat AS u_id_cont, + d_hst AS "date", + (date_part('year', d_hst)::text||lpad(date_part('month', d_hst), 2, '0'))::numeric AS mois, + reduitr AS rub_code, + ordre, + n_cpt, + 0, + sum(CASE WHEN typtas = 'G' THEN v_csg ELSE v_cst END), + 0, + 0, + 0 + FROM prod_sigems.phst + JOIN prod_sigems.rub ON rub.c_tas = phst.num + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + JOIN (select valeur = 0 as opt_std_hp from rh.t_divers where code = 'OPT_STD_HP') as t_divers ON true + WHERE 1=1 + AND CASE WHEN t_divers.opt_std_hp THEN typdoc = 'B' ELSE true END + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + AND CASE WHEN typtas = 'G' THEN v_csg ELSE v_cst END != 0 + AND d_hst >= '2014-01-01'::date + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + -- Alimentation de la colonne "Montant salarial". + INSERT INTO w_hp_sq + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + mat||'-'||id_contrat AS u_id_cont, + d_hst AS "date", + (date_part('year', d_hst)::text||lpad(date_part('month', d_hst), 2, '0'))::numeric AS mois, + reduitr AS rub_code, + ordre, + n_cpt, + 0, + 0, + sum(v_rub), + 0, + 0 + FROM prod_sigems.phst + JOIN prod_sigems.rub ON rub.c_rub = phst.num + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + WHERE 1=1 + -- AND (1!=1 + -- OR typdoc = 'B' AND n_cpt::text||c_rub::text != '128' -- @specifique Ste Félicité : on retire la R128 qui n'a pas de comtpe défini. + -- OR typdoc = 'D' AND c_rub = 3034 -- @specifique Ste Félicité : on intégre la 3034 "Réintégration du net imposable". + -- OR typdoc = 'X' AND c_rub IN (129, 130) AND substr(n_cpt, 1, 1) = '1') -- @specifique Ste Félicité : on n'a pas pris la R128 mais prend sa décomposition en R129 + R130. + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + AND v_rub != 0 + AND d_hst >= '2014-01-01'::date + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + -- Alimentation de la colonne "Taux patronal". + INSERT INTO w_hp_sq + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + mat||'-'||id_contrat AS u_id_cont, + d_hst AS "date", + (date_part('year', d_hst)::text||lpad(date_part('month', d_hst), 2, '0'))::numeric AS mois, + reduitr AS rub_code, + ordre, + n_cpt, + 0, + 0, + 0, + sum(CASE WHEN typtap = 'G' THEN v_csg ELSE v_cst END), + 0 + FROM prod_sigems.phst + JOIN prod_sigems.rub ON rub.c_tap = phst.num + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + JOIN (select valeur = 0 as opt_std_hp from rh.t_divers where code = 'OPT_STD_HP') as t_divers ON true + WHERE 1=1 + AND CASE WHEN t_divers.opt_std_hp THEN typdoc = 'B' ELSE true END + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + AND CASE WHEN typtap = 'G' THEN v_csg ELSE v_cst END != 0 + AND d_hst >= '2014-01-01'::date + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + -- Alimentation de la colonne "Montant patronal". + INSERT INTO w_hp_sq + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + mat||'-'||id_contrat AS u_id_cont, + d_hst AS "date", + (date_part('year', d_hst)::text||lpad(date_part('month', d_hst), 2, '0'))::numeric AS mois, + reduitr AS rub_code, + ordre, + n_cpt, + 0, + 0, + 0, + 0, + sum(v_cst) + FROM prod_sigems.phst + JOIN prod_sigems.rub ON rub.c_mtp = phst.num + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + JOIN (select valeur = 0 as opt_std_hp from rh.t_divers where code = 'OPT_STD_HP') as t_divers ON true + WHERE 1=1 + AND CASE WHEN t_divers.opt_std_hp THEN typdoc = 'B' ELSE true END + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + AND v_cst != 0 + AND d_hst >= '2014-01-01'::date + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + -- Alimentation de la rubrique C714 "Taxe sur les salaires". + INSERT INTO w_hp_sq + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + mat||'-'||id_contrat AS u_id_cont, + d_hst AS "date", + (date_part('year',d_hst)::text||lpad (date_part('month',d_hst),2,'0'))::NUMERIC AS mois, + 'C714'::text AS rub_code, + -1, + '99999999', + sum(v_cst), + 0, + 0, + 0, + sum(v_cst) + FROM prod_sigems.phst + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + WHERE 1=1 + AND (SELECT valeur = '1' FROM rh.t_divers WHERE code = 'SIGEMS_TS') -- Taxe sur les salaires que si l'option a été définie à 1. + AND num = 714 + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + AND d_hst >= '2014-01-01'::date + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + -- Alimentation des rubriques de cumul. + INSERT INTO w_hp_sq + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + mat||'-'||id_contrat AS u_id_cont, + d_hst AS "date", + (date_part('year',d_hst)::text||lpad (date_part('month',d_hst),2,'0'))::NUMERIC AS mois, + 'C'::text||lpad(num,3,'0') AS rub_code, + -1, + '99999999', + sum(v_cst), -- base + 0, + sum(case when num IN (7, 507) then 0 else v_cst end), -- sal; pas de montant pour les heures payées et travaillées. + 0, + sum(case when num IN (7, 507) then 0 else v_rub end) -- pat; pas de montant pour les heures payées et travaillées. + FROM prod_sigems.phst + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + WHERE 1=1 + AND num IN (1, 3, 5, 7, 11, 507, 881, 998) + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + AND d_hst >= '2014-01-01'::date + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + DROP TABLE IF EXISTS w_hp + ; + -- Aggrégation des rubriques de paie. + CREATE TEMP TABLE w_hp AS + SELECT * + FROM + ( + SELECT + societe, + etablissement, + matricule, + u_id_cont, + "date"::date, + mois, + rub_code, + ordre, + n_cpt, + sum(base) AS base, + sum(taux_sal) AS taux_sal, + sum(montant_sal) AS montant_sal, + sum(taux_pat) AS taux_pat, + sum(montant_pat) AS montant_pat + FROM w_hp_sq + GROUP BY 1,2,3,4,5,6,7,8,9 + ) AS phst2 + WHERE 1!=1 + OR montant_sal != 0 + OR montant_pat != 0 + OR rub_code IN ('C001','C003','C005','C007','C011', 'C507','C998', 'C714') + ; + + -- #specifique Spécifiques Brétéché Forfait (on renseigne dans base le nombre d'heures à inscrire dans le champ d'HP base). + UPDATE w_hp SET + base = round(base * 151.67 / 206.0, 2) + WHERE 1=1 + AND current_database() = 'icti_171' + AND rub_code = '3017' + ; + + -- #specifique Spécifiques St Louis Forfait (on renseigne dans base le nombre d'heures à inscrire dans le champ d'HP base). + with fj_sal as ( + select + u_id_cont, + date + from w_hp + where true + and rub_code = 'R001' + and to_char(date, 'YYYY') >= 2019 + and base = 0 + and montant_sal != 0 + AND current_database() = 'icti_320' + ) + , new_data_fj as ( + select + w_hp.u_id_cont, + w_hp.date, + w_hp.base + from w_hp + join fj_sal on true + and fj_sal.u_id_cont = w_hp.u_id_cont + and fj_sal.date = w_hp.date + where 1=1 + and w_hp.rub_code = 'C507' + AND current_database() = 'icti_320') + update w_hp set + base = new_data_fj.base + from new_data_fj + where 1=1 + and new_data_fj.u_id_cont = w_hp.u_id_cont + and new_data_fj.date = w_hp.date + and w_hp.rub_code = 'R001' + AND current_database() = 'icti_320' + ; + + CREATE INDEX i_w_hp_1 ON w_hp USING btree (matricule) + ; + CREATE INDEX i_w_hp_2 ON w_hp USING btree ("date") + ; + CREATE INDEX i_w_hp_3 ON w_hp USING btree (rub_code) + ; + + TRUNCATE rh.p_historique_paie + ; + + ]]> + + + + + + + + + + + + + + + 7 + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + UNION ALL + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + d_hst AS "date", + (date_part('year', d_hst)::text||lpad(date_part('month', d_hst), 2, '0'))::NUMERIC AS mois, + 'C012'::text AS rub_code, + v_cst, + v_cst, + v_cst, + v_cst, + v_cst, + -1 + FROM prod_sigems.phst + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + WHERE 1=1 + AND num = 173 + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + UNION ALL + -- Taxe sur les salaires que si l'option a été définie à 1. + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + d_hst AS "date", + (date_part('year', d_hst)::text||lpad(date_part('month', d_hst), 2, '0'))::NUMERIC AS mois, + 'C714'::text AS rub_code, + v_cst, + 0, + 0, + 0, + v_cst, + -1 + FROM prod_sigems.phst + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + WHERE 1=1 + AND (SELECT valeur = '1' FROM rh.t_divers WHERE code = 'SIGEMS_TS') -- Taxe sur les salaires que si l'option a été définie à 1. + AND num = 714 + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + UNION ALL + -- @specifique Compléter le brut standard avec le brut exceptionnel (intéressement). + -- Spécifique Brétéché de juillet 2014 avec comme condition : n_cpt = 'ANNEXE04' and reduitr = '3057'. + -- En espérant que cette condition ne soit jamais rencontré chez un autre client. + SELECT + phst.ste AS societe, + phst.etb AS etablissement, + mat AS matricule, + d_hst AS "date", + (date_part('year', d_hst)::text||lpad(date_part('month', d_hst), 2, '0'))::NUMERIC AS mois, + 'C001' AS rub_code, + v_rub AS base, + v_rub AS taux_sal, + v_rub AS montant_sal, + v_rub AS taux_pat, + v_rub AS montant_pat, + -1 as ordre + FROM prod_sigems.phst + JOIN prod_sigems.rub ON rub.c_rub = phst.num + JOIN w_ets ON 1=1 + AND w_ets.ste = phst.ste + AND w_ets.etbl = phst.etb + WHERE 1=1 + AND (1!=1 + OR substr(n_cpt, 1, 2) = '87' + OR (n_cpt = 'ANNEXE04' and reduitr = '3057')) + AND phst.mat NOT IN (SELECT mat FROM w_exc_mat) + ) as subq + GROUP BY 1,2,3,4,5,6) AS phst2 + WHERE (montant_sal <> 0 OR montant_pat <> 0) + AND "date" >= '2014-01-01' + ; + + DROP TABLE IF EXISTS w_cumul + ; + + CREATE TEMP TABLE w_cumul AS + SELECT + true as total_heures_contrat, + true as total_heures_payees, + true as total_heures_travaillees, + true as total_masse_salariale, + true as total_brut, + true as total_avantage_nature, + true as total_frais_imposables, + true as total_cotisation_salarie, + true as total_cotisation_patronale, + true as total_od_net_salarie, + true as total_od_net_patronale, + true as total_net_imposable, + true as total_net_a_payer + ; + + DROP TABLE IF EXISTS w_totaux + ; + + CREATE TEMP TABLE w_totaux AS + SELECT + societe, + etablissement, + matricule, + "date", + mois, + sum(CASE WHEN rub_code = 'C007' THEN montant_sal ELSE 0 END) AS mnt_hp, + sum(CASE WHEN rub_code = 'C507' THEN montant_sal ELSE 0 END) AS mnt_hw, + sum(CASE WHEN rub_code = 'C001' THEN montant_sal ELSE 0 END) AS mnt_brut, + sum(CASE WHEN rub_code = 'C003' THEN -montant_sal ELSE 0 END) AS mnt_cotisation_salariale, + sum(CASE WHEN rub_code IN ('C012', 'C714') THEN montant_pat ELSE 0 END) AS mnt_cotisation_patronale, + sum(CASE WHEN rub_code = 'C005' THEN montant_sal ELSE 0 END) as mnt_net_imposable_salarie, + sum(CASE WHEN rub_code = 'C011' THEN montant_sal ELSE 0 END) AS mnt_net_a_payer_salarie + FROM w_tmp_totaux + GROUP BY 1,2,3,4,5 + ; + + ]]> + + + + + + + date_fin + ; + + -- Renseigner les heures contrats à partir de la rubriques d'heures salaire de base conventionnel lorsque le nombre d'heures contrat n'est pas renseigné. + UPDATE rh.p_contrats_mois SET + nombre_heures = 0 + WHERE (select count(*) > 0 from rh.t_listes join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid where code = 'CTI_HCNT') + ; + + UPDATE rh.p_contrats_mois SET + nombre_heures = subq.nombre_heures + FROM ( + SELECT + contrat_mois_id, + mois_paie, + sum(base) as nombre_heures + FROM rh.p_historique_paie + WHERE rubrique_id IN (select to_id from rh.t_listes join rh.t_listes_contenu on t_listes_contenu.liste_id = t_listes.oid where code = 'CTI_HCNT') + GROUP BY 1,2) as subq + WHERE 1=1 + AND p_contrats_mois.oid = subq.contrat_mois_id + AND p_contrats_mois.mois_activite = subq.mois_paie + AND nullif(p_contrats_mois.nombre_heures, 0) is null + ; + + ]]> + + + + + + = '2014-01-01' + AND dtdu <= now() + AND ij_arret.mat NOT IN (SELECT mat FROM w_exc_mat) + and ij_arret.id_liencontrat > 0 + GROUP BY 1,2,3,4,5,6,7,8,9 + ; + + TRUNCATE rh.p_arrets_travail + ; + + ALTER SEQUENCE rh.s_arrets_travail RESTART WITH 1 + ; + + INSERT INTO rh.p_arrets_travail( + salarie_id, + contrat_id, + mois_activite, + date_debut, + date_fin, + date_reprise, + motif_arret_id, + precision_motif_arret_id, + nb_jours + ) + SELECT p_salaries.oid, + p_contrats.oid, + w_arrets.mois_activite, + w_arrets.date_debut, + w_arrets.date_fin, + (w_arrets.date_fin + INTERVAL '1 day')::date AS date_reprise, + t_motifs_arret.oid AS motif_arret_id, + 0 AS precision_motif_arret_id, + w_arrets.nbj AS nb_jours + FROM w_arrets + JOIN prod_sigems.contrats_pb on contrats_pb.mat||'-'||contrats_pb.id_cont = w_arrets.u_id_cont + JOIN rh.p_salaries ON p_salaries.matricule = w_arrets.mat + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_arrets.u_id_cont + JOIN rh.t_motifs_arret ON t_motifs_arret.code_original = w_arrets.motif + ; + + TRUNCATE rh.p_arrets_travail_mois + ; + + INSERT INTO rh.p_arrets_travail_mois( + arret_travail_id, + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + nb_debut_arret, + nb_fin_arret, + nb_reprise_apres_arret, + date_debut, + date_fin, + nb_jours, + nb_arret + ) + SELECT + p_arrets_travail.oid AS arret_travail_id, + p_arrets_travail.salarie_id AS salarie_id, + p_arrets_travail.contrat_id AS contrat_id, + p_contrats_mois.oid AS contrat_mois_id, + p_contrats_mois.mois_activite, + CASE WHEN p_arrets_travail.date_debut BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END AS nombre_debut_arret, + CASE WHEN p_arrets_travail.date_fin BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END AS nombre_fin_arret, + CASE WHEN p_arrets_travail.date_reprise BETWEEN p_contrats_mois.date_debut AND p_contrats_mois.date_fin THEN 1 ELSE 0 END AS nombre_reprise_apres_arret, + GREATEST(p_contrats_mois.date_debut, p_arrets_travail.date_debut) AS date_debut, + LEAST(p_contrats_mois.date_fin, p_arrets_travail.date_fin) AS date_fin, + LEAST(p_contrats_mois.date_fin, p_arrets_travail.date_fin)::date - GREATEST(p_contrats_mois.date_debut, p_arrets_travail.date_debut)::date + 1 AS nb_jours, + 1 + FROM rh.p_contrats_mois + JOIN rh.p_arrets_travail ON (p_contrats_mois.contrat_id = p_arrets_travail.contrat_id AND + p_arrets_travail.date_debut <= p_contrats_mois.date_fin AND + p_arrets_travail.date_reprise >= p_contrats_mois.date_debut + ) + ORDER BY arret_travail_id, p_contrats_mois.mois_activite + ; + + ]]> + + + = '2014-01-01' + AND c_anu <> 'S' + AND vis_med.mat NOT IN (SELECT mat FROM w_exc_mat) + GROUP BY 1,2,3,4,5,6 + ; + + -- Peuplement de rh.p_visites_medicales + TRUNCATE rh.p_visites_medicales + ; + + ALTER SEQUENCE rh.s_visites_medicales RESTART WITH 1 + ; + + INSERT INTO rh.p_visites_medicales( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date, + motif_visite_id + ) + SELECT p_salaries.oid, + p_contrats.oid, + p_contrats_mois.oid, + w_visites.mois_activite, + w_visites.date, + t_motifs_visite.oid + FROM w_visites + JOIN rh.p_salaries ON p_salaries.matricule = w_visites.mat + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_visites.u_id_cont + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + AND w_visites.date >= p_contrats_mois.date_debut + AND w_visites.date <= p_contrats_mois.date_fin + JOIN rh.t_motifs_visite ON t_motifs_visite.code_original = w_visites.motif + ; + + ]]> + + + = '2014-01-01' + AND c_anu <> 'S' + AND acctravail.mat NOT IN (SELECT mat FROM w_exc_mat) + GROUP BY 1,2,3,4,5,7,8,9,10 + ; + + -- Peuplement de rh.p_accident_travail + TRUNCATE rh.p_accident_travail + ; + + ALTER SEQUENCE rh.s_accident_travail RESTART WITH 1 + ; + + INSERT INTO rh.p_accident_travail( + salarie_id, + contrat_id, + contrat_mois_id, + mois_activite, + date, + accident_circonstance_id, + accident_lieu_id, + accident_nature_id, + accident_siege_id + ) + SELECT p_salaries.oid, + p_contrats.oid, + p_contrats_mois.oid, + w_accident.mois_activite, + w_accident.date, + t_accident_circonstance.oid, + t_accident_lieu.oid, + t_accident_nature.oid, + t_accident_siege.oid + FROM w_accident + JOIN rh.p_salaries ON p_salaries.matricule = w_accident.mat + JOIN rh.p_contrats ON p_contrats.numero_contrat = w_accident.u_id_cont + JOIN rh.p_contrats_mois ON p_contrats_mois.contrat_id = p_contrats.oid + AND w_accident.date >= p_contrats_mois.date_debut + AND w_accident.date <= p_contrats_mois.date_fin + JOIN rh.t_accident_circonstance ON t_accident_circonstance.code_original = w_accident.circonstance + JOIN rh.t_accident_lieu ON t_accident_lieu.code_original = w_accident.lieu + JOIN rh.t_accident_nature ON t_accident_nature.code_original = w_accident.nature + JOIN rh.t_accident_siege ON t_accident_siege.code_original = w_accident.siege + ; + + ]]> + + + 01 Janvier 2014 et < date actuelle + 2 ans + -- * Si une entrée a un code de formation et une date mais a un nombre d'heures à zéro, + -- force le nombre d'heures à 1.00 + + INSERT INTO w_formation (matricule, ste, etb, code_formation, date_formation, mois_activite, nbre_heures, n_org) + ( + SELECT + pform_pb.mat, + pform_pb.ste, + pform_pb.etb, + pform_pb.id_formation, + pform_pb.d_for, + (date_part('year',pform_pb.d_for::date)::text||lpad(date_part('month', pform_pb.d_for::DATE), 2, '0'))::NUMERIC, + CASE WHEN pform_pb.nb_hr > 0 THEN pform_pb.nb_hr ELSE 1.00 END, + pform_pb.n_org + FROM prod_sigems.pform_pb + JOIN prod_sigems.pers ON 1=1 + AND pers.mat = pform_pb.mat + AND pers.ste = pform_pb.ste + AND pers.etb = pform_pb.etb + JOIN w_cnt ON w_cnt.mat = pform_pb.mat + WHERE 1=1 + AND d_for < (CURRENT_DATE + INTEGER '731') + AND (1!=1 + OR pers.c_anu <> 'S' + OR (1=1 + AND pers.c_anu = 'S' + AND w_cnt.date_fin > CURRENT_DATE)) + AND pform_pb.mat NOT IN (SELECT mat FROM w_exc_mat) + GROUP BY 1,2,3,4,5,6,7,8 + UNION + -- * Insère les données dont la date de formation n'est pas encore renseignée + -- * Force à 0.00 le nombre d'heures de formation + -- * Zappe les employés suspendus sauf ceux dont le contrat est en cours (date de sortie + -- nulle ou supérieure à date actuelle) + -- * Zappe les entrées dont le code de formation n'est pas renseigné + SELECT + pform_pb.mat, + pform_pb.ste, + pform_pb.etb, + pform_pb.id_formation, + pform_pb.d_for, + (date_part('year',pform_pb.d_for::date)::text||lpad(date_part('month',pform_pb.d_for::DATE),2,'0'))::NUMERIC, + 0.00 AS nb_hr, + n_org + FROM prod_sigems.pform_pb + JOIN prod_sigems.pers ON 1=1 + AND pers.mat = pform_pb.mat + AND pers.ste = pform_pb.ste + AND pers.etb = pform_pb.etb + JOIN w_cnt ON w_cnt.mat = pform_pb.mat + WHERE 1=1 + AND pform_pb.d_for IS NULL + AND (1!=1 + OR pers.c_anu <> 'S' + OR (1=1 + AND pers.c_anu = 'S' + AND w_cnt.date_fin > CURRENT_DATE)) + AND pform_pb.mat NOT IN (SELECT mat FROM w_exc_mat) + GROUP BY 1,2,3,4,5,6,7,8 + ) + ; + + + ---------------------------------------------------------------------------------------------------- + -- * Insère la date de début de contrat la plus proche de la date de formation + -- Servira si la date de formation ne rentre dans aucun contrat + + UPDATE w_formation + SET date_debut = + ( + SELECT MAX(dtdebu) + FROM w_cnt + WHERE 1=1 + AND w_cnt.mat = matricule + AND date_formation IS DISTINCT FROM NULL + AND dtdebu < date_formation + ) + ; + + + -- select * from w_formation order by 2 + ---------------------------------------------------------------------------------------------------- + -- * Cherche les lignes qui ont en commun le matricule, le code, la date et les heures + -- * Supprime celle qui a le plus petit id (normalement qui a été saisie en premier) + + DELETE + FROM w_formation + WHERE id NOT IN + ( + SELECT MIN(dup.id) + FROM w_formation AS dup + GROUP BY dup.matricule, dup.code_formation, dup.date_formation, dup.nbre_heures + ) + ; + + + -- select * from w_formation order by 2 + ---------------------------------------------------------------------------------------------------- + -- * Cherche les lignes qui ont en commun le matricule, le code et la date + -- * Supprime celle qui a le plus petit id (normalement qui a été saisie en premier) + + DELETE + FROM w_formation + WHERE id IN + ( + SELECT MIN(id) + FROM w_formation + GROUP BY matricule, code_formation, date_formation + HAVING COUNT(date_formation) > 1 + ORDER BY 1 + ) + ; + + + -- select * from w_formation order by 2 + ---------------------------------------------------------------------------------------------------- + -- * Cherche les entrées où la date de formation n'est comprise dans aucun intervalle de contrat + -- * Remplace la date de formation par la plus récente date de début de contrat antérieure + -- à la date de formation + -- * Recalcule le champ mois_activite avec la nouvelle date + + UPDATE w_formation + SET date_formation = date_debut, mois_activite = (date_part('year',date_formation::date)::text||lpad(date_part('month', date_formation::DATE), 2, '0'))::NUMERIC + WHERE id IN + ( + SELECT id + FROM w_formation + JOIN w_cnt ON w_cnt.mat = w_formation.matricule + JOIN prod_sigems.pers ON 1=1 + AND pers.mat = w_cnt.mat + AND pers.ste = w_cnt.soc + AND pers.etb = w_cnt.etb + WHERE + id NOT IN ( + SELECT id + FROM w_formation + JOIN w_cnt ON w_cnt.mat = w_formation.matricule + GROUP BY w_formation.id, w_formation.date_formation, w_cnt.date_debut, w_cnt.date_fin + HAVING w_formation.date_formation BETWEEN w_cnt.date_debut AND w_cnt.date_fin + ORDER BY 1 + ) + GROUP BY 1 + ORDER BY 1 + ) + AND date_formation IS DISTINCT FROM NULL + ; + + + -- select * from w_formation order by 2 + ---------------------------------------------------------------------------------------------------- + -- * Cherche les cas où un salarié fait au moins deux formations le même jour pour un + -- total d'heures supérieur à 9. On considère alors qu'on est dans le cas d'une + -- formation 'marathon' et on force tous les nombres d'heures de ces formations à 1.00 + + UPDATE w_formation + SET nbre_heures = 1.00 + WHERE id in ( + SELECT id + FROM w_formation + WHERE ARRAY[matricule::text, date_formation::text] in ( + SELECT ARRAY[matricule::text,date_formation::text] + FROM w_formation + WHERE date_formation IS NOT NULL + GROUP BY 1 + HAVING sum (nbre_heures) > 9 AND COUNT (DISTINCT code_formation) > 1 + ) + ) + ; + + + -- select * from w_formation order by 2 + ---------------------------------------------------------------------------------------------------- + -- Peuplement de rh.p_formations + + TRUNCATE rh.p_formations + ; + + ALTER SEQUENCE rh.s_formations RESTART WITH 1 + ; + + INSERT INTO rh.p_formations( + salarie_id, + formation_id, + formation_date, + mois_activite, + nb_heures, + organisateur + ) + SELECT + p_salaries.oid AS "salarie_oid", + t_liste_formations.oid AS "formation_oid", + w_formation.date_formation, + w_formation.mois_activite, + w_formation.nbre_heures, + w_formation.n_org + FROM w_formation + JOIN rh.p_salaries ON p_salaries.matricule = w_formation.matricule + JOIN rh.t_liste_formations ON w_formation.code_formation = t_liste_formations.code + ORDER BY 1,2,3,4 + ; + + + -- select * from rh.p_formations order by 2 + ---------------------------------------------------------------------------------------------------- + -- Rattache une formation qui n'a pas de date au contrat le plus récent du + -- salarié concerné par la formation + -- Met la date de la formation à 2099-12-31 et le mois_activite à 209912 + + UPDATE rh.p_formations toto + SET contrat_id = + ( + SELECT + (MAX(ARRAY[date_debut::text,oid::text]))[2]::bigint + FROM rh.p_contrats cont + WHERE cont.salarie_id = toto.salarie_id + ), + formation_date = '2099-12-31'::DATE, mois_activite = 209912 + WHERE formation_date IS NULL + ; + + + -- SELECT * FROM rh.p_formations order by 2 + ---------------------------------------------------------------------------------------------------- + -- Rattache le numéro de contrat à la formation dont la date est comprise + -- entre les dates de début et de fin dudit contrat + -- Concerne les formations dont la date a été renseignée + + UPDATE rh.p_formations toto + SET contrat_id = + ( + SELECT (MAX(ARRAY[date_debut::text,oid::text]))[2]::bigint + FROM rh.p_contrats cont + WHERE cont.salarie_id = toto.salarie_id + AND toto.formation_date <= cont.date_fin + AND toto.formation_date >= cont.date_debut + ) + WHERE formation_date < '2099-12-31' + ; + + + -- SELECT * FROM rh.p_formations order by 2 + ---------------------------------------------------------------------------------------------------- + -- Rattache le contrat_mois_id de la formation pour les formations dont la date a été + -- renseignée + + UPDATE rh.p_formations toto + SET contrat_mois_id = + ( + SELECT oid + FROM rh.p_contrats_mois cont + WHERE cont.contrat_id = toto.contrat_id + AND cont.mois_activite = toto.mois_activite + ) + WHERE toto.formation_date < '2099-12-31' + ; + + + -- SELECT * FROM rh.p_formations order by 2 + ---------------------------------------------------------------------------------------------------- + -- Rattache le contrat_mois_id de la formation pour les formations dont la date n'a pas été + -- renseignée. On prendra dans ce cas le contrat_mois_id le plus élevé + + UPDATE rh.p_formations toto + SET contrat_mois_id = + ( + SELECT (MAX(ARRAY[date_debut::text,oid::text]))[2]::bigint + FROM rh.p_contrats_mois cont + WHERE cont.contrat_id = toto.contrat_id + ) + WHERE toto.formation_date = '2099-12-31' + ; + + -- select * from rh.p_formations order by 2; + -- BRET00 (1046) + + + ]]> + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_SILAE.XML b/import_rh/iCTI_import_rh_SILAE.XML new file mode 100644 index 0000000..9dc1b16 --- /dev/null +++ b/import_rh/iCTI_import_rh_SILAE.XML @@ -0,0 +1,1518 @@ + + + + + '''' THEN SEM_AFFECT_TYPE3 + WHEN SEM_AFFECT_TYPE1 <> '''' AND + SEM_AFFECT_TYPE1 = LAG(SEM_AFFECT_TYPE1) OVER (PARTITION BY ID_PAISALARIE ORDER BY ID_PAISALARIEEMPLOI) AND + LAG(SEM_AFFECT_TYPE3) OVER (PARTITION BY ID_PAISALARIE ORDER BY ID_PAISALARIEEMPLOI) <> '''' + THEN LAG(SEM_AFFECT_TYPE3) OVER (PARTITION BY ID_PAISALARIE ORDER BY ID_PAISALARIEEMPLOI) + WHEN SEM_AFFECT_TYPE1 <> '''' AND + SEM_AFFECT_TYPE1 = LEAD(SEM_AFFECT_TYPE1) OVER (PARTITION BY ID_PAISALARIE ORDER BY ID_PAISALARIEEMPLOI) + THEN LEAD(SEM_AFFECT_TYPE3) OVER (PARTITION BY ID_PAISALARIE ORDER BY ID_PAISALARIEEMPLOI) + ELSE '''' END AS new_SEM_AFFECT_TYPE3 + FROM w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI + ) subview + WHERE PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI = subview.ID_PAISALARIEEMPLOI AND + COALESCE(PAISALARIEEMPLOI.SEM_AFFECT_TYPE3,'''') IS DISTINCT FROM new_SEM_AFFECT_TYPE3 AND + new_SEM_AFFECT_TYPE3 <> '''' + ',50) + ; + + ]]> + + + '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',1) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',1) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',1) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',1) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',1) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',1) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS code, + COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN SEM_AFFECT_TYPE1 + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN SEM_AFFECT_TYPE2 + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN SEM_AFFECT_TYPE3 + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN SEM_AFFECT_TYPE4 + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN SEM_AFFECT_TYPE5 + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN SEM_AFFECT_TYPE6 + ELSE NULL END, + chr(1)||'*') + AS code_original, + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',2) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',2) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',2) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',2) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',2) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',2) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS texte, + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',2) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',2) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',2) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',2) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',2) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',2) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS texte_court + FROM w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI + JOIN rh.t_divers ON t_divers.code = 'SILAE_SERVICE' + GROUP BY 2 + ; + + -- Identification des specialites + DROP TABLE IF EXISTS temp.x_ref_specialite + ; + + CREATE TABLE temp.x_ref_specialite AS + + SELECT + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',1) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',1) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',1) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',1) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',1) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',1) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS code, + COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN SEM_AFFECT_TYPE1 + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN SEM_AFFECT_TYPE2 + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN SEM_AFFECT_TYPE3 + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN SEM_AFFECT_TYPE4 + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN SEM_AFFECT_TYPE5 + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN SEM_AFFECT_TYPE6 + ELSE NULL END, + chr(1)||'*') + AS code_original, + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',2) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',2) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',2) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',2) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',2) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',2) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS texte, + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',2) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',2) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',2) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',2) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',2) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',2) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS texte_court + FROM w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI + JOIN rh.t_divers ON t_divers.code = 'SILAE_SPECIALITE' + GROUP BY 2 + ; + + -- Identification des codes emploi + DROP TABLE IF EXISTS temp.x_ref_code_emploi + ; + + CREATE TABLE temp.x_ref_code_emploi AS + + SELECT + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',1) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',1) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',1) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',1) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',1) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',1) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS code, + COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN SEM_AFFECT_TYPE1 + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN SEM_AFFECT_TYPE2 + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN SEM_AFFECT_TYPE3 + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN SEM_AFFECT_TYPE4 + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN SEM_AFFECT_TYPE5 + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN SEM_AFFECT_TYPE6 + ELSE NULL END, + chr(1)||'*') + AS code_original, + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',2) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',2) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',2) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE4 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',2) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE5 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',2) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE6 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',2) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS texte, + MAX(COALESCE( + CASE + WHEN t_divers.valeur = 'AFFECT_TYPE1' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE1) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE1,'-',2) ELSE SEM_AFFECT_TYPE1 END + WHEN t_divers.valeur = 'AFFECT_TYPE2' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE2) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE2,'-',2) ELSE SEM_AFFECT_TYPE2 END + WHEN t_divers.valeur = 'AFFECT_TYPE3' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE3) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE3,'-',2) ELSE SEM_AFFECT_TYPE3 END + WHEN t_divers.valeur = 'AFFECT_TYPE4' AND SEM_AFFECT_TYPE1 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE4) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE4,'-',2) ELSE SEM_AFFECT_TYPE4 END + WHEN t_divers.valeur = 'AFFECT_TYPE5' AND SEM_AFFECT_TYPE2 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE5) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE5,'-',2) ELSE SEM_AFFECT_TYPE5 END + WHEN t_divers.valeur = 'AFFECT_TYPE6' AND SEM_AFFECT_TYPE3 <> '' THEN CASE WHEN POSITION('-' IN SEM_AFFECT_TYPE6) BETWEEN 4 AND 7 THEN split_part(SEM_AFFECT_TYPE6,'-',2) ELSE SEM_AFFECT_TYPE6 END + ELSE NULL END, + chr(1)||'*')) + AS texte_court + FROM w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI + JOIN rh.t_divers ON t_divers.code = 'SILAE_CODEEMPLOI' + GROUP BY 2 + ; + + -- Identification des types d'horaire + + -- Identification des grilles + DROP TABLE IF EXISTS temp.x_ref_grille + ; + + CREATE TABLE temp.x_ref_grille AS + SELECT + null::text AS code_original, + null::text AS code, + null::text AS texte, + null::text AS texte_court + limit 0 + ; + + -- Identification des groupes de grilles + + -- Identification des motifs d'arret + + -- Identification des precisions du motif d'arret + + -- Identification des motifs de visite medicale + + -- Identification des circonstances d'accident du travail + + -- Identification des lieux d'accident du travail + + -- Identification de la nature de l'accident du travail + + -- Identification des sieges d'accident du travail + + -- Identification des listes de formations + + -- Sections analytiques + DROP TABLE IF EXISTS w_PAISALARIEREPANASPE; + CREATE TEMP TABLE w_PAISALARIEREPANASPE AS + SELECT *, + 0::bigint AS oid_service, + ''::text AS services, + ''::text AS code_service + FROM prod_silae.PAISALARIEREPANASPE + ; + + UPDATE w_PAISALARIEREPANASPE SET + oid_service = base.cti_to_number(substr(split_part(RAS_AFFECTATION,'-',1),4)), + code_service = substr(split_part(RAS_AFFECTATION,'-',1),4), + services = CASE WHEN RAS_AFFECTATION LIKE '%-%' THEN split_part(RAS_AFFECTATION,'-',2) ELSE substr(split_part(RAS_AFFECTATION,'-',1),4) END + WHERE ( + RAS_AFFECTATION LIKE '%-%' OR + base.cti_to_number(split_part(RAS_AFFECTATION,'-',1)) > 0 + ) AND + length(split_part(RAS_AFFECTATION,'-',1)) = 6 + ; + + UPDATE w_PAISALARIEREPANASPE SET + code_service = RAS_AFFECTATION, + services = RAS_AFFECTATION + WHERE oid_service = 0 + ; + + ANALYSE w_PAISALARIEREPANASPE + ; + + INSERT INTO rh.t_section_analytique(code_original, code, texte, texte_court) + SELECT + code_service, + MAX(code_service), + MAX(services), + MAX(substr(services, 1, 50)) + FROM w_PAISALARIEREPANASPE + WHERE oid_service = 0 AND + code_service <> '' AND + code_service NOT IN (SELECT CODE_ORIGINAL FROM rh.t_section_analytique WHERE code_original IS NOT NULL) + GROUP BY 1 + ; + + UPDATE w_PAISALARIEREPANASPE + SET oid_service = t_section_analytique.oid + FROM rh.t_section_analytique + WHERE code_service = code_original + ; + + DROP TABLE IF EXISTS temp.x_ref_section_analytique + ; + + CREATE TABLE temp.x_ref_section_analytique AS + WITH affectation AS ( + SELECT + oid_service, + code_service, + services + FROM w_PAISALARIEREPANASPE PAISALARIEREPANASPE + GROUP BY 1,2,3 + ) + SELECT + oid_service AS oid, + code_service AS code_original, + code_service AS code, + MAX(services) AS texte, + MAX(services) AS texte_court + FROM affectation + GROUP BY 1,2,3 + ; + + -- Identification des rubriques de paie. + + DROP TABLE IF EXISTS w_hp_0 + ; + + CREATE TEMP TABLE w_hp_0 AS + SELECT + PAIBULLETINLIGNE.ctid::text AS cti_ctid, + BLI_ZONE||'|'||COALESCE(BLI_CODELIBELLE, '-')||'|'||COALESCE(BLI_MARQUE1, '-')||'|'||COALESCE(BLI_MARQUEINTERNE, '-') AS rub, + ID_PAIBULLETINLIGNE, + PAIBULLETINLIGNE.ID_PAIBULLETIN, + BLI_ZONE, + BLI_CODELIBELLE, + BLI_LIBELLE, + BLI_MARQUE1, + BLI_MARQUEINTERNE, + BLI_RESULTATS, + BLI_BASES, + BLI_BASEP, + BLI_TAUXOUMONTANTS, + BLI_TAUXOUMONTANTP, + BLI_RESULTATP + FROM prod_silae.PAIBULLETINLIGNE + JOIN prod_silae.PAIBULLETIN ON PAIBULLETINLIGNE.ID_PAIBULLETIN = PAIBULLETIN.ID_PAIBULLETIN + JOIN w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI ON PAIBULLETIN.ID_PAISALARIEEMPLOI = PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI + WHERE + ( + BLI_RESULTATS <> 0 OR + BLI_BASES <> 0 OR + BLI_BASEP <> 0 OR + BLI_TAUXOUMONTANTS <> 0 OR + BLI_TAUXOUMONTANTP <> 0 OR + BLI_RESULTATP <> 0 + ) + UNION ALL + SELECT + 'SALBAS|'||PAIBULLETIN.ctid::text AS cti_ctid, + '2|SALBAS||' AS rub, + PAIBULLETIN.ID_PAIBULLETIN AS ID_PAIBULLETINLIGNE, + PAIBULLETIN.ID_PAIBULLETIN, + 2 AS BLI_ZONE, + 'SALBAS'::text AS BLI_CODELIBELLE, + 'Salaire de base'::text AS BLI_LIBELLE, + ''::text AS BLI_MARQUE1, + ''::text AS BLI_MARQUEINTERNE, + PAIBULLETIN.BUL_SALAIREDEBASE AS BLI_RESULTATS, + PAIBULLETIN.BUL_NBHC AS BLI_BASES, + 0::numeric AS BLI_BASEP, + PAIBULLETIN.BUL_TAUXHORAIRE AS BLI_TAUXOUMONTANTS, + 0::numeric AS BLI_TAUXOUMONTANTP, + 0::numeric AS BLI_RESULTATP + FROM prod_silae.PAIBULLETIN + JOIN w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI ON PAIBULLETIN.ID_PAISALARIEEMPLOI = PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI + UNION ALL + SELECT + 'TOTHTRAV|'||PAIBULLETIN.ctid::text AS cti_ctid, + '2|TOTHTRAV||' AS rub, + PAIBULLETIN.ID_PAIBULLETIN AS ID_PAIBULLETINLIGNE, + PAIBULLETIN.ID_PAIBULLETIN, + 2 AS BLI_ZONE, + 'TOTHTRAV'::text AS BLI_CODELIBELLE, + 'Total heures travaillees'::text AS BLI_LIBELLE, + ''::text AS BLI_MARQUE1, + ''::text AS BLI_MARQUEINTERNE, + 0::numeric AS BLI_RESULTATS, + PAIBULLETIN.BUL_NBHMN AS BLI_BASES, + 0::numeric AS BLI_BASEP, + 0::numeric AS BLI_TAUXOUMONTANTS, + 0::numeric AS BLI_TAUXOUMONTANTP, + 0::numeric AS BLI_RESULTATP + FROM prod_silae.PAIBULLETIN + JOIN w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI ON PAIBULLETIN.ID_PAISALARIEEMPLOI = PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI + UNION ALL + SELECT + 'BRUT|'||PAIBULLETIN.ctid::text AS cti_ctid, + '2|BRUT||' AS rub, + PAIBULLETIN.ID_PAIBULLETIN AS ID_PAIBULLETINLIGNE, + PAIBULLETIN.ID_PAIBULLETIN, + 2 AS BLI_ZONE, + 'BRUT'::text AS BLI_CODELIBELLE, + 'Salaire Brut'::text AS BLI_LIBELLE, + ''::text AS BLI_MARQUE1, + ''::text AS BLI_MARQUEINTERNE, + PAIBULLETIN.BUL_BRUT AS BLI_RESULTATS, + 0::numeric AS BLI_BASES, + 0::numeric AS BLI_BASEP, + 0::numeric AS BLI_TAUXOUMONTANTS, + 0::numeric AS BLI_TAUXOUMONTANTP, + 0::numeric AS BLI_RESULTATP + FROM prod_silae.PAIBULLETIN + JOIN w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI ON PAIBULLETIN.ID_PAISALARIEEMPLOI = PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI + UNION ALL + SELECT + 'TOTRET|'||PAIBULLETIN.ctid::text AS cti_ctid, + '3|TOTRET||' AS rub, + PAIBULLETIN.ID_PAIBULLETIN AS ID_PAIBULLETINLIGNE, + PAIBULLETIN.ID_PAIBULLETIN, + 3 AS BLI_ZONE, + 'TOTRET'::text AS BLI_CODELIBELLE, + 'Total des retenues'::text AS BLI_LIBELLE, + ''::text AS BLI_MARQUE1, + ''::text AS BLI_MARQUEINTERNE, + PAIBULLETIN.BUL_CUMULRETENUESSD + PAIBULLETIN.BUL_CUMULRETENUESSND AS BLI_RESULTATS, + 0::numeric AS BLI_BASES, + 0::numeric AS BLI_BASEP, + 0::numeric AS BLI_TAUXOUMONTANTS, + 0::numeric AS BLI_TAUXOUMONTANTP, + PAIBULLETIN.bul_cumulretenuesp AS BLI_RESULTATP + FROM prod_silae.PAIBULLETIN + JOIN w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI ON PAIBULLETIN.ID_PAISALARIEEMPLOI = PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI + UNION ALL + SELECT + 'NETIMP|'||PAIBULLETIN.ctid::text AS cti_ctid, + '4|NETIMP||' AS rub, + PAIBULLETIN.ID_PAIBULLETIN AS ID_PAIBULLETINLIGNE, + PAIBULLETIN.ID_PAIBULLETIN, + 4 AS BLI_ZONE, + 'NETIMP'::text AS BLI_CODELIBELLE, + 'Net Imposable'::text AS BLI_LIBELLE, + ''::text AS BLI_MARQUE1, + ''::text AS BLI_MARQUEINTERNE, + PAIBULLETIN.BUL_NETIMPOSABLE AS BLI_RESULTATS, + 0::numeric AS BLI_BASES, + 0::numeric AS BLI_BASEP, + 0::numeric AS BLI_TAUXOUMONTANTS, + 0::numeric AS BLI_TAUXOUMONTANTP, + 0::numeric AS BLI_RESULTATP + FROM prod_silae.PAIBULLETIN + JOIN w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI ON PAIBULLETIN.ID_PAISALARIEEMPLOI = PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI + UNION ALL + SELECT + 'NETAPAYER|'||PAIBULLETIN.ctid::text AS cti_ctid, + '4|NETAPAYER||' AS rub, + PAIBULLETIN.ID_PAIBULLETIN AS ID_PAIBULLETINLIGNE, + PAIBULLETIN.ID_PAIBULLETIN, + 4 AS BLI_ZONE, + 'NETAPAYER'::text AS BLI_CODELIBELLE, + 'Net a Payer'::text AS BLI_LIBELLE, + ''::text AS BLI_MARQUE1, + ''::text AS BLI_MARQUEINTERNE, + PAIBULLETIN.BUL_NETAPAYER AS BLI_RESULTATS, + 0::numeric AS BLI_BASES, + 0::numeric AS BLI_BASEP, + 0::numeric AS BLI_TAUXOUMONTANTS, + 0::numeric AS BLI_TAUXOUMONTANTP, + 0::numeric AS BLI_RESULTATP + FROM prod_silae.PAIBULLETIN + JOIN w_PAISALARIEEMPLOI_ets PAISALARIEEMPLOI ON PAIBULLETIN.ID_PAISALARIEEMPLOI = PAISALARIEEMPLOI.ID_PAISALARIEEMPLOI + ; + ANALYSE w_hp_0 + ; + + -- Formatage rubrique selon texte + DROP TABLE IF EXISTS w_hp_0_rub; + CREATE TEMP TABLE w_hp_0_rub AS + SELECT BLI_ZONE, + BLI_CODELIBELLE, + BLI_LIBELLE, + trim(replace(BLI_LIBELLE,' ',' ')) AS texte, + ''::text AS texte_maj, + ''::text AS code, + ''::text AS code_original, + count(*) AS nb + FROM w_hp_0 + JOIN rh.t_divers ON t_divers.code = 'SILAE_RUBRIQUE' + WHERE t_divers.valeur = '2' + GROUP BY 1,2,3 + ; + + UPDATE w_hp_0_rub + SET texte = trim(left(texte, + LEAST( + CASE WHEN position('(' IN texte) > 5 THEN position('(' IN texte)-1 ELSE 999 END, + CASE WHEN position('0' IN texte) > 5 THEN position('0' IN texte)-1 ELSE 999 END, + CASE WHEN position('1' IN texte) > 5 THEN position('1' IN texte)-1 ELSE 999 END, + CASE WHEN position('2' IN texte) > 5 THEN position('2' IN texte)-1 ELSE 999 END, + CASE WHEN position('3' IN texte) > 5 THEN position('3' IN texte)-1 ELSE 999 END, + CASE WHEN position('4' IN texte) > 5 THEN position('4' IN texte)-1 ELSE 999 END, + CASE WHEN position('5' IN texte) > 5 THEN position('5' IN texte)-1 ELSE 999 END, + CASE WHEN position('6' IN texte) > 5 THEN position('6' IN texte)-1 ELSE 999 END, + CASE WHEN position('7' IN texte) > 5 THEN position('7' IN texte)-1 ELSE 999 END, + CASE WHEN position('8' IN texte) > 5 THEN position('8' IN texte)-1 ELSE 999 END, + CASE WHEN position('9' IN texte) > 5 THEN position('9' IN texte)-1 ELSE 999 END, + CASE WHEN position('Acompte d' IN texte) > 0 THEN position('Acompte de' IN texte)+6 ELSE 999 END, + CASE WHEN position(' jan' IN lower(texte)) > 0 THEN position(' jan' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' fév' IN lower(texte)) > 0 THEN position(' fév' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' mars' IN lower(texte)) > 0 THEN position(' mars' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' avr' IN lower(texte)) > 0 THEN position(' avr' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' mai' IN lower(texte)) > 0 THEN position(' mai' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' juin' IN lower(texte)) > 0 THEN position(' juin' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' juil' IN lower(texte)) > 0 THEN position(' juil' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' aout' IN lower(texte)) > 0 THEN position(' aout' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' sept' IN lower(texte)) > 0 THEN position(' sept' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' oct' IN lower(texte)) > 0 THEN position(' oct' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' nov' IN lower(texte)) > 0 THEN position(' nov' IN lower(texte))-1 ELSE 999 END, + CASE WHEN position(' déc' IN lower(texte)) > 0 THEN position(' déc' IN lower(texte))-1 ELSE 999 END + ))) + WHERE texte like '%0%' OR + texte like '%(%' OR + texte like '%1%' OR + texte like '%2%' OR + texte like '%3%' OR + texte like '%4%' OR + texte like '%5%' OR + texte like '%6%' OR + texte like '%7%' OR + texte like '%8%' OR + texte like '%9%' OR + texte like '%Acompte d%' OR + texte ilike '% jan%' OR + texte ilike '% fév%' OR + texte ilike '% mars%' OR + texte ilike '% avr%' OR + texte ilike '% mai%' OR + texte ilike '% juin%' OR + texte ilike '% juil' OR + texte ilike '% aout%' OR + texte ilike '% sept%' OR + texte ilike '% oct%' OR + texte ilike '% nov%' OR + texte ilike '% déc%' + ; + + UPDATE w_hp_0_rub + SET texte = trim(left(texte,length(texte)-3)) + WHERE texte ilike '% du' OR texte ilike '% de' + ; + + UPDATE w_hp_0_rub + SET texte_maj = translate(upper(base.cti_remove_accent(texte)),'.:/-+''','') + ; + + UPDATE w_hp_0_rub SET + code_original = BLI_ZONE || + COALESCE(BLI_CODELIBELLE,'ZZZ') || + CASE WHEN COALESCE(BLI_CODELIBELLE,'') NOT IN ('SALBAS','TOTHTRAV','BRUT','TOTRET','NETIMP','NETAPAYER') + THEN translate(texte_maj,' ','') + ELSE '' + END, + code = BLI_ZONE || + COALESCE(BLI_CODELIBELLE,'ZZZ') || + CASE WHEN COALESCE(BLI_CODELIBELLE,'') NOT IN ('SALBAS','TOTHTRAV','BRUT','TOTRET','NETIMP','NETAPAYER') + THEN + substr(split_part(texte_maj,' ',1),1,3) || + substr(split_part(texte_maj,' ',2),1,3) || + substr(split_part(texte_maj,' ',3),1,3) || + substr(split_part(texte_maj,' ',4),1,3) || + substr(split_part(texte_maj,' ',5),1,3) + ELSE '' + END + ; + + ANALYSE w_hp_0_rub + ; + + UPDATE w_hp_0 SET + rub = code_original + FROM w_hp_0_rub + WHERE w_hp_0.BLI_ZONE = w_hp_0_rub.BLI_ZONE AND + COALESCE(w_hp_0.BLI_CODELIBELLE,'') = COALESCE(w_hp_0_rub.BLI_CODELIBELLE,'') AND + w_hp_0.BLI_LIBELLE = w_hp_0_rub.BLI_LIBELLE + ; + + DROP TABLE IF EXISTS w_rubriques_2; + CREATE TEMP TABLE w_rubriques_2 AS + SELECT code_original, (max(ARRAY[to_char(nb,'FM00000000'),texte]))[2] AS texte, (max(ARRAY[to_char(nb,'FM00000000'),code]))[2] AS code + FROM + ( + SELECT code_original, texte, code, sum(nb) AS nb + FROM w_hp_0_rub + GROUP BY 1,2,3 + ) subview + GROUP BY 1 + ; + + ANALYSE w_rubriques_2 + ; + + + -- Table des rubriques + DROP TABLE IF EXISTS temp.x_ref_rubrique + ; + + CREATE TABLE temp.x_ref_rubrique AS + WITH rub_det_1 AS ( + SELECT + rub, + (MAX(ARRAY[to_char(ID_PAIBULLETINLIGNE,'FM000000000000000'),BLI_LIBELLE]))[2] AS texte, + BLI_ZONE IN (2, 3, 4) AS p_detail, + BLI_ZONE IN (2, 3, 4) AS p_nombre, + BLI_ZONE IN (2, 3, 4) AS p_base, + false AS p_heures_contrat, + false AS p_heures_payees, + false AS p_heures_travaillees, + rub between 'B000' and 'B999' or rub between 'C100' and 'C999' AS p_masse_salariale, + BLI_ZONE = 2 AS p_brut, + false AS p_avantage_nature, + false AS p_frais_imposables, + BLI_ZONE = 3 AS p_cotisation_salarie, + BLI_ZONE = 3 AS p_cotisation_patronale, + BLI_ZONE = 4 AS p_od_net_salarie, + false AS p_od_net_patronale, + BLI_ZONE IN (2, 3) OR (BLI_ZONE = 4 AND substr(BLI_CODELIBELLE, 1, 1) NOT IN ('K', 'F', 'B', 'A', 'J')) AS p_net_imposable, + BLI_ZONE IN (2, 3, 4) AS p_net_a_payer + FROM w_hp_0 + WHERE rub != '4|K07|-|PAS' + GROUP BY 1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 + ) + SELECT + rub AS code_original, + COALESCE(w_rubriques_2.code,rub) AS code, + COALESCE(w_rubriques_2.texte,rub_det_1.texte) AS texte, + null::text AS texte_court, + -1 AS rang_edition, + false AS p_cumul, + p_detail AS p_detail, + p_nombre AS p_nombre, + 0 AS s_nombre, + 1 AS c_nombre, + p_base AS p_base, + 1 AS s_base, + 1 AS c_base, + p_heures_contrat AS p_heures_contrat, + 0 AS s_heures_contrat, + 1 AS c_heures_contrat, + p_heures_payees AS p_heures_payees, + 0 AS s_heures_payees, + 1 AS c_heures_payees, + p_heures_travaillees AS p_heures_travaillees, + 0 AS s_heures_travaillees, + 1 AS c_heures_travaillees, + p_masse_salariale AS p_masse_salariale, + case when p_cotisation_patronale or p_od_net_patronale then 5 else 3 end AS s_masse_salariale, + 1 AS c_masse_salariale, + p_brut AS p_brut, + 3 AS s_brut, + 1 AS c_brut, + p_avantage_nature AS p_avantage_nature, + 3 AS s_avantage_nature, + 1 AS c_avantage_nature, + p_frais_imposables AS p_frais_imposables, + 3 AS s_frais_imposables, + 1 AS c_frais_imposables, + p_cotisation_salarie AS p_cotisation_salarie, + 3 AS s_cotisation_salarie, + -1 AS c_cotisation_salarie, + p_cotisation_patronale AS p_cotisation_patronale, + 5 AS s_cotisation_patronale, + 1 AS c_cotisation_patronale, + p_od_net_salarie AS p_od_net_salarie, + 3 AS s_od_net_salarie, + 1 AS c_od_net_salarie, + p_od_net_patronale AS p_od_net_patronale, + 5 AS s_od_net_patronale, + 1 AS c_od_net_patronale, + p_net_imposable AS p_net_imposable, + 3 AS s_net_imposable, + case when p_cotisation_salarie then -1 else 1 end AS c_net_imposable, + p_net_a_payer AS p_net_a_payer, + 3 AS s_net_a_payer, + case when p_cotisation_salarie then -1 else 1 end AS c_net_a_payer + FROM rub_det_1 + LEFT JOIN w_rubriques_2 ON rub = w_rubriques_2.code_original + ; + + ]]> + + + x_hst_bulletin.date_debut + WHERE x_hst_bulletin.cnt_code_original is null + GROUP BY 1 + ) + UPDATE temp.x_hst_bulletin set + cnt_code_original = toto.cnt_code_original, + est_hors_periode = 1 + FROM toto + WHERE x_hst_bulletin.row_id = toto.row_id + ; + + -- ICI : Tous les bulletins doivent avoir un contrat de renseigne. + -- A remonter plus tard dans une table speciale avant suppression pour controle expert. + delete FROM temp.x_hst_bulletin + WHERE cnt_code_original is null + ; + + -- HISTORIQUE ETP Theorique contrat. + DROP TABLE IF EXISTS temp.x_hst_etp_contrat + ; + + CREATE TABLE temp.x_hst_etp_contrat AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + etp_contrat + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_categorie_socio_professionnelle + ; + + CREATE TABLE temp.x_hst_categorie_socio_professionnelle AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + categorie_socio_professionnelle_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + + ; + + -- HISTORIQUE Motif de debut. + DROP TABLE IF EXISTS temp.x_hst_motif_debut_contrat + ; + + CREATE TABLE temp.x_hst_motif_debut_contrat AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + motif_debut_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE Motif de fin. + DROP TABLE IF EXISTS temp.x_hst_motif_fin_contrat + ; + + CREATE TABLE temp.x_hst_motif_fin_contrat AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + motif_fin_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + + ; + + -- HISTORIQUE Types de contrat. + DROP TABLE IF EXISTS temp.x_hst_type_contrat + ; + + CREATE TABLE temp.x_hst_type_contrat AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + type_contrat_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_qualification + ; + + CREATE TABLE temp.x_hst_qualification AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + qualification_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE Statut. + DROP TABLE IF EXISTS temp.x_hst_statut + ; + + CREATE TABLE temp.x_hst_statut AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + statut_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_type_temps_travail + ; + + CREATE TABLE temp.x_hst_type_temps_travail AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + type_temps_travail_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_service + ; + + CREATE TABLE temp.x_hst_service AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + service_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_code_emploi + ; + + CREATE TABLE temp.x_hst_code_emploi AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + code_emploi_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE CSP. + DROP TABLE IF EXISTS temp.x_hst_specialite + ; + + CREATE TABLE temp.x_hst_specialite AS + SELECT + ety_code_original, + sal_code_original, + cnt_code_original, + date_debut AS date_effet, + specialite_code_original + FROM temp.x_hst_contrat + GROUP BY 1,2,3,4,5 + ; + + -- HISTORIQUE GRILLE. + DROP TABLE IF EXISTS temp.x_hst_grille + ; + + CREATE TABLE temp.x_hst_grille AS + SELECT + null::text AS ety_code_original, + null::text AS sal_code_original, + null::text AS cnt_code_original, + null::date AS date_effet, + null::text AS grille_code_original + limit 0 + ; + + + ]]> + + + = to_char(rhp('rhprovider_start')::date, 'YYYYMM') + ; + ]]> + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_TALENTIA_RH.XML b/import_rh/iCTI_import_rh_TALENTIA_RH.XML new file mode 100644 index 0000000..3acc78e --- /dev/null +++ b/import_rh/iCTI_import_rh_TALENTIA_RH.XML @@ -0,0 +1,1438 @@ + + + + + + + + + + + + 600600 as p_od_net_salarie, + 3 as s_od_net_salarie, + -1 as c_od_net_salarie, + -- OD/Net patronales + false as p_od_net_patronale, + 5 as s_od_net_patronale, + 1 as c_od_net_patronale, + -- Net imposable + cdde1k in ('G', 'R') and cdrubk::int < 599920 as p_net_imposable, + 3 as s_net_imposable, + 1 as c_net_imposable, + -- Net à payer + cdde1k in ('G', 'R') p_net_a_payer, + 3 as s_net_a_payer, + 1 as c_net_a_payer + from prod_talentia_rh.iptw2fghm_rubrik + ; + + update rh.t_rubriques set + p_cumul = rub.p_cumul, + p_detail = rub.p_detail, + p_nombre = rub.p_nombre, + s_nombre = rub.s_nombre, + c_nombre = rub.c_nombre, + p_base = rub.p_base, + s_base = rub.s_base, + c_base = rub.c_base, + p_heures_payees = rub.p_heures_payees, + s_heures_payees = rub.s_heures_payees, + c_heures_payees = rub.c_heures_payees, + p_heures_travaillees = rub.p_heures_travaillees, + s_heures_travaillees = rub.s_heures_travaillees, + c_heures_travaillees = rub.c_heures_travaillees, + p_masse_salariale = rub.p_masse_salariale, + s_masse_salariale = rub.s_masse_salariale, + c_masse_salariale = rub.c_masse_salariale, + p_brut = rub.p_brut, + s_brut = rub.s_brut, + c_brut = rub.c_brut, + p_avantage_nature = rub.p_avantage_nature, + s_avantage_nature = rub.s_avantage_nature, + c_avantage_nature = rub.c_avantage_nature, + p_frais_imposables = rub.p_frais_imposables, + s_frais_imposables = rub.s_frais_imposables, + c_frais_imposables = rub.c_frais_imposables, + p_cotisation_salarie = rub.p_cotisation_salarie, + s_cotisation_salarie = rub.s_cotisation_salarie, + c_cotisation_salarie = rub.c_cotisation_salarie, + p_cotisation_patronale = rub.p_cotisation_patronale, + s_cotisation_patronale = rub.s_cotisation_patronale, + c_cotisation_patronale = rub.c_cotisation_patronale, + p_od_net_salarie = rub.p_od_net_salarie, + s_od_net_salarie = rub.s_od_net_salarie, + c_od_net_salarie = rub.c_od_net_salarie, + p_od_net_patronale = rub.p_od_net_patronale, + s_od_net_patronale = rub.s_od_net_patronale, + c_od_net_patronale = rub.c_od_net_patronale, + p_net_imposable = rub.p_net_imposable, + s_net_imposable = rub.s_net_imposable, + c_net_imposable = rub.c_net_imposable, + p_net_a_payer = rub.p_net_a_payer, + s_net_a_payer = rub.s_net_a_payer, + c_net_a_payer = rub.c_net_a_payer + from w_rub_affectation as rub + where 1=1 + AND t_rubriques.code_original = rub.cdrubk + AND NOT t_rubriques.user_modified + ; + + ]]> + + + + + + + + + + + + + + + + = 2016 + AND (1!=1 + OR t_rubriques.p_detail + OR t_rubriques.p_cumul) + ; + + TRUNCATE rh.p_historique_paie + ; + + ALTER SEQUENCE rh.s_historique_paie RESTART WITH 1 + ; + + SELECT base.cti_stash_table_indexes('rh', 'p_historique_paie') + ; + + DROP TABLE IF EXISTS w_hp_1 + ; + + CREATE TEMP TABLE w_hp_1 AS + SELECT + nextval('rh.s_historique_paie'::regclass) as oid, + date_part('year', age(w_hp.date_debut, date_naissance)) AS age_id, + w_hp.nombre, + w_hp.base AS base, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.contrat_id]))[2] AS contrat_id, + (max(ARRAY[EXTRACT(EPOCH FROM p_contrats_mois.date_fin),p_contrats_mois.oid]))[2] AS contrat_mois_id, + w_hp.date_debut, + w_hp.date_fin, + w_hp.date_paie, + w_hp.mois_activite, + w_hp.mois_paie, + w_hp.heure_payee, + w_hp.heure_travaillee, + w_hp.montant_avantage_nature, + w_hp.montant_brut, + w_hp.montant_masse_salariale, + w_hp.montant_cotisation_patronale, + w_hp.montant_cotisation_salarie, + w_hp.montant_frais_imposables, + w_hp.montant_net_a_payer_salarie, + w_hp.montant_net_imposable_salarie, + w_hp.montant_od_net_salarie, + w_hp.montant_od_net_patronale, + coalesce(t_organismes_cotisation.oid, 0) AS organisme_cotisation_id, + rubrique_id, + w_hp.mat, + w_hp.salarie_id, + w_hp.taux_cotisation_patronale, + w_hp.taux_cotisation_salarie, + 0 AS compte_id, + nojobo, + norjpo + FROM w_hp + LEFT JOIN w_caisses ON w_caisses.rub = w_hp.rub + LEFT JOIN rh.t_organismes_cotisation ON t_organismes_cotisation.code_original = w_caisses.code_ori + LEFT JOIN rh.p_contrats_mois ON 1=1 + AND p_contrats_mois.salarie_id = w_hp.salarie_id + AND base.cti_overlaps(p_contrats_mois.date_debut, p_contrats_mois.date_fin, w_hp.date_debut, w_hp.date_fin) + WHERE w_hp.p_detail + GROUP BY 1,2,3,4, 7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, w_hp.ctid + ; + + -- Associer les bulletins hors contrat (is null) avec le contrat PRECEDENT. + UPDATE w_hp_1 SET + contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + w_hp_1.oid, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_hp_1 + join rh.p_contrats_mois on true + and p_contrats_mois.salarie_id = w_hp_1.salarie_id + and p_contrats_mois.date_fin < w_hp_1.date_debut + where contrat_mois_id is null + group by 1) as subq + WHERE true + AND w_hp_1.oid = subq.oid + AND w_hp_1.contrat_mois_id is null + ; + + -- Associer les bulletins hors contrat (is null) avec le contrat SUIVANT. + UPDATE w_hp_1 SET + contrat_id = subq.contrat_id, + contrat_mois_id = subq.contrat_mois_id + FROM ( + select + w_hp_1.oid, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.contrat_id]))[2] as contrat_id, + (max(array[extract(epoch from p_contrats_mois.date_fin), p_contrats_mois.oid]))[2] as contrat_mois_id + from w_hp_1 + join rh.p_contrats_mois on true + and p_contrats_mois.salarie_id = w_hp_1.salarie_id + and p_contrats_mois.date_debut > w_hp_1.date_fin + where contrat_mois_id is null + group by 1) as subq + WHERE true + AND w_hp_1.oid = subq.oid + AND w_hp_1.contrat_mois_id is null + ; + + -- Insertion dans la table de production CTI. + INSERT INTO rh.p_historique_paie( + oid, + age_id, + nombre, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + heure_payee, + heure_travaillee, + montant_avantage_nature, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + montant_od_net_patronale, + organisme_cotisation_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id) + SELECT + oid, + age_id, + nombre, + base, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + heure_payee, + heure_travaillee, + montant_avantage_nature, + montant_brut, + montant_masse_salariale, + montant_cotisation_patronale, + montant_cotisation_salarie, + montant_frais_imposables, + montant_net_a_payer_salarie, + montant_net_imposable_salarie, + montant_od_net_salarie, + montant_od_net_patronale, + organisme_cotisation_id, + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie, + compte_id + FROM w_hp_1 + ; + + -- Inserer pour chaque bulletin une ligne qui va faire le compte avec le total (rubrique 'C000' nommée 'Ecart cumulé') + INSERT INTO rh.p_historique_paie( + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + nombre, + base, + heure_payee, + heure_travaillee, + montant_masse_salariale, + montant_brut, + montant_avantage_nature, + montant_frais_imposables, + montant_cotisation_salarie, + montant_cotisation_patronale, + montant_od_net_salarie, + montant_od_net_patronale, + montant_net_imposable_salarie, + montant_net_a_payer_salarie, + organisme_cotisation_id, + profil_id, -- @deprecated + rubrique_id, + salarie_id, + taux_cotisation_patronale, + taux_cotisation_salarie) + SELECT + age_id, + contrat_id, + contrat_mois_id, + subq.date_debut, + subq.date_fin, + subq.date_paie, + subq.mois_activite, + subq.mois_paie, + 0 as nombre, + 0 AS base, + sum(cum.heure_payee - subq.heure_payee) as heure_payee, + sum(cum.heure_travaillee - subq.heure_travaillee) as heure_travaillee, + sum(cum.montant_masse_salariale - subq.montant_masse_salariale) as montant_masse_salariale, + sum(cum.montant_brut - subq.montant_brut) as montant_brut, + sum(cum.montant_avantage_nature - subq.montant_avantage_nature) as montant_avantage_nature, + sum(cum.montant_frais_imposables - subq.montant_frais_imposables) as montant_frais_imposables, + sum(cum.montant_cotisation_salarie - subq.montant_cotisation_salarie) as montant_cotisation_salarie, + sum(cum.montant_cotisation_patronale - subq.montant_cotisation_patronale) as montant_cotisation_patronale, + sum(cum.montant_od_net_salarie - subq.montant_od_net_salarie) as montant_od_net_salarie, + sum(cum.montant_od_net_patronale - subq.montant_od_net_patronale) as montant_od_net_patronale, + sum(cum.montant_net_imposable_salarie - subq.montant_net_imposable_salarie) as montant_net_imposable_salarie, + sum(cum.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie) as montant_net_a_payer_salarie, + subq.organisme_cotisation_id AS organisme_cotisation_id, + subq.profil_id AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000') AS rubrique_id, + subq.salarie_id AS salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM ( + SELECT + w_hp.salarie_id, + w_hp.nojobo, + w_hp.norjpo, + sum(w_hp.heure_payee) as heure_payee, + sum(w_hp.heure_travaillee) as heure_travaillee, + sum(w_hp.montant_avantage_nature) as montant_avantage_nature, + sum(w_hp.montant_brut) as montant_brut, + sum(w_hp.montant_masse_salariale) as montant_masse_salariale, + sum(w_hp.montant_cotisation_patronale) as montant_cotisation_patronale, + sum(w_hp.montant_cotisation_salarie) as montant_cotisation_salarie, + sum(w_hp.montant_frais_imposables) as montant_frais_imposables, + sum(w_hp.montant_net_a_payer_salarie) as montant_net_a_payer_salarie, + sum(w_hp.montant_net_imposable_salarie) as montant_net_imposable_salarie, + sum(w_hp.montant_od_net_salarie) as montant_od_net_salarie, + sum(w_hp.montant_od_net_patronale) as montant_od_net_patronale + FROM w_hp + WHERE w_hp.p_cumul + GROUP BY 1,2,3) as cum + JOIN ( + SELECT + age_id, + contrat_id, + contrat_mois_id, + date_debut, + date_fin, + date_paie, + mois_activite, + mois_paie, + nojobo, + norjpo, + sum(heure_payee) as heure_payee, + sum(heure_travaillee) as heure_travaillee, + sum(montant_masse_salariale) as montant_masse_salariale, + sum(montant_brut) AS montant_brut, + sum(montant_avantage_nature) AS montant_avantage_nature, + sum(montant_frais_imposables) AS montant_frais_imposables, + sum(montant_cotisation_salarie) AS montant_cotisation_salarie, + sum(montant_cotisation_patronale) AS montant_cotisation_patronale, + sum(montant_od_net_salarie) as montant_od_net_salarie, + sum(montant_od_net_patronale) as montant_od_net_patronale, + sum(montant_net_imposable_salarie) AS montant_net_imposable_salarie, + sum(montant_net_a_payer_salarie) AS montant_net_a_payer_salarie, + 0 AS organisme_cotisation_id, + 0 AS profil_id, + (SELECT oid FROM rh.t_rubriques WHERE code = 'C000'), + salarie_id, + 0 AS taux_cotisation_patronale, + 0 AS taux_cotisation_salarie + FROM w_hp_1 + GROUP BY 1,2,3,4,5,6,7,8,9,10, 23,24,25,26,27,28) AS subq ON true + AND subq.salarie_id = cum.salarie_id + AND subq.nojobo = cum.nojobo + AND subq.norjpo = cum.norjpo + GROUP BY 1,2,3,4,5,6,7,8, 23,24,25,26,27,28 + HAVING 1!=1 + OR sum(cum.heure_payee - subq.heure_payee) != 0 + OR sum(cum.heure_travaillee - subq.heure_travaillee) != 0 + OR sum(cum.montant_masse_salariale - subq.montant_masse_salariale) != 0 + OR sum(cum.montant_brut - subq.montant_brut) != 0 + OR sum(cum.montant_avantage_nature - subq.montant_avantage_nature) != 0 + OR sum(cum.montant_frais_imposables - subq.montant_frais_imposables) != 0 + OR sum(cum.montant_cotisation_salarie - subq.montant_cotisation_salarie) != 0 + OR sum(cum.montant_cotisation_patronale - subq.montant_cotisation_patronale) != 0 + OR sum(cum.montant_od_net_salarie - subq.montant_od_net_salarie) != 0 + OR sum(cum.montant_od_net_patronale - subq.montant_od_net_patronale) != 0 + OR sum(cum.montant_net_imposable_salarie - subq.montant_net_imposable_salarie) != 0 + OR sum(cum.montant_net_a_payer_salarie - subq.montant_net_a_payer_salarie) != 0 + ; + + SELECT base.cti_stash_pop_table_indexes('rh', 'p_historique_paie') + ; + + INSERT INTO rh.t_divers (code, texte, valeur, valeur_date, description, show_info_module) + SELECT + 'NOW', + 'Date en-cours', + to_char(date_max, 'YYYYMM'), + date_max, + 'Date non modifiable', + true + FROM + (SELECT date(MAX(date_paie) + interval '1 month') AS date_max FROM rh.p_historique_paie WHERE date_paie <= now()) sub + WHERE 'NOW' NOT IN (SELECT code FROM rh.t_divers); + + + INSERT INTO rh.t_divers (code, texte, valeur, valeur_date, description, show_info_module) + SELECT + 'NOWCLOTURE', + 'Date en-cours', + to_char(date_max, 'YYYYMM'), + date_max, + 'Date non modifiable', + true + FROM + (SELECT date(MAX(date_paie)) AS date_max FROM rh.p_historique_paie WHERE date_paie <= now()) sub + WHERE 'NOWCLOTURE' NOT IN (SELECT code FROM rh.t_divers); + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import_rh/iCTI_import_rh_cti.exe b/import_rh/iCTI_import_rh_cti.exe new file mode 100644 index 0000000..a342139 Binary files /dev/null and b/import_rh/iCTI_import_rh_cti.exe differ diff --git a/import_rh/iCTI_import_rh_cti.php b/import_rh/iCTI_import_rh_cti.php new file mode 100644 index 0000000..d18fead --- /dev/null +++ b/import_rh/iCTI_import_rh_cti.php @@ -0,0 +1,317 @@ +args["-noactualizeprod"]) { + logInfoMsg("CONTRÔLE RÉPLICATION BASE DE DONNÉES PRODUCTION $RHPROVIDER_check"); + $prodhm_exe = realpath("../../../prodsgbd/iCTI_synchronize_prodsgbd_check.exe"); + $extractCmd = "$prodhm_exe -p $RHPROVIDER_check -m rh"; + $return = exec($extractCmd, $output_array); + foreach ($output_array as $output_line) { + if (trim($output_line) != "") { + echo "\r\n$output_line"; + } + } + // Sur QUADRARH, verifier egalement exercice précédent + if ($RHPROVIDER_check == "QUADRARH") { + $RHPROVIDER_checkP = $RHPROVIDER_check . 'P'; + logInfoMsg("Exercice précédent"); + $prodhm_exe = realpath("../../../prodsgbd/iCTI_synchronize_prodsgbd_check.exe"); + $extractCmd = "$prodhm_exe -p $RHPROVIDER_checkP -m rh"; + unset($output_array); + $return = exec($extractCmd, $output_array); + foreach ($output_array as $output_line) { + if (trim($output_line) != "") { + echo "\r\n$output_line"; + } + } + } + logInfoMsg("FIN CONTRÔLE RÉPLICATION BASE DE DONNÉES PRODUCTION $RHPROVIDER_check"); + } + else { + logInfoMsg("RÉPLICATION BASE DE DONNÉES PRODUCTION $RHPROVIDER_check"); + $prodhm_exe = realpath("../../../prodsgbd/iCTI_synchronize_prodsgbd_put.exe"); + $extractCmd = "$prodhm_exe -p $RHPROVIDER_check -m rh"; + $return = exec($extractCmd, $output_array); + foreach ($output_array as $output_line) { + if (trim($output_line) != "") { + echo "\r\n$output_line"; + } + } + // Sur QUADRARH, récupérer egalement exercice précédent + if ($RHPROVIDER_check == "QUADRARH") { + $RHPROVIDER_checkP = $RHPROVIDER_check . 'P'; + logInfoMsg("Exercice précédent"); + $prodhm_exe = realpath("../../../prodsgbd/iCTI_synchronize_prodsgbd_put.exe"); + $extractCmd = "$prodhm_exe -p $RHPROVIDER_checkP -m rh"; + unset($output_array); + $return = exec($extractCmd, $output_array); + foreach ($output_array as $output_line) { + if (trim($output_line) != "") { + echo "\r\n$output_line"; + } + } + } + logInfoMsg("FIN RÉPLICATION BASE DE DONNÉES PRODUCTION $RHPROVIDER_check"); + } + + +} + + + +// récupération historique +function extraction_environnement($RHPROVIDER, $RHPROVIDER_PREFIX, $RHPROVIDER_OID) { + + global $iCTI_connexion; + global $ENV_TYPEETS; + + global $cti_args; + + logInfoMsg("RÉCUPERATION DE LA PRODUCTION $RHPROVIDER"); + + // Paramètres shs + $file = "../../../settings/databases/$RHPROVIDER.XML"; + $xml = simplexml_load_string(file_get_contents($file)); + + $DB_pmsischema = trim($xml['pmsilib']); + $DB_activiteschema = trim($xml['admlib']); + $DB_rhschema = trim($xml['rhlib']); + + $ETAB = trim($xml['idEtab_rh']); + + + // Chargement requetes SQL + $environmentVars=array(); + + + $environmentVars["PMSISCHEMA"] = $DB_pmsischema; + $environmentVars["ACTIVITESCHEMA"] = $DB_activiteschema; + $environmentVars["RHSCHEMA"] = $DB_rhschema; + + $environmentVars["ETAB"] = $ETAB; + $environmentVars["ENV_TYPEETS"] = $ENV_TYPEETS; + + if (strtolower($RHPROVIDER) === 'icti_rh') { + $dbSettings = new EnvironmentDatabaseSettings(); + try { + $dbSettings->readSettings($file); + $environmentVars["DBHOST"] = $dbSettings->getHost(); + $environmentVars["DBPORT"] = $dbSettings->getPort(); + $environmentVars["DBNAME"] = $dbSettings->getName(); + $environmentVars["DBUSER"] = $dbSettings->getUsername(); + $environmentVars["DBPASSWORD"] = $dbSettings->getPassword(); + } catch (Exception $e) { + logErrorMsg($e->getMessage()); + logEndMsg(); + exit(); + } + } + + + + + $sqlOptions=array(); + + //$cti_sqlStatements_share = new CTI_SqlStatements_class("iCTI_import_rh_SHARE.XML",$iCTI_connexion,$environmentVars,$sqlOptions); + + $cti_sqlStatements_provider = new CTI_SqlStatements_class("iCTI_import_rh_$RHPROVIDER.XML",$iCTI_connexion,$environmentVars,$sqlOptions); + + + + $cti_sqlStatements_provider->executeStatementsNode("PARAM"); + + $cti_sqlStatements_provider->executeStatementsNode("PAIE"); + + $cti_sqlStatements_provider->executeStatementsNode("POST"); + + $cti_sqlStatements_provider->executeStatementsNode("VACUUM"); + + + + logInfoMsg("FIN RÉCUPERATION DE LA PRODUCTION $RHPROVIDER"); + +} + +function iCTI_connect() { + +global $iCTI_connexion; +global $ENV_TYPEETS; +global $RHPROVIDER; +global $RHPROVIDER2; +global $RHPROVIDER_PREFIX; +global $RHPROVIDER2_PREFIX; + + $iCTI_connexion = FALSE; + + $file = "../../../settings/settings.XML"; + $settings_xml = simplexml_load_string(file_get_contents($file)); + + $wRHPROVIDER = ""; + $RHPROVIDER_PREFIX = ""; + $wRHPROVIDER_PREFIX = ""; + $wRHPROVIDER2 = ""; + $RHPROVIDER2_PREFIX = ""; + $wRHPROVIDER2_PREFIX = ""; + + foreach ($settings_xml->ENVIRONMENT as $environmentNode) { + foreach ($environmentNode->PROPERTY as $propertyNode) { + if (strtoupper($propertyNode['name']) === 'TYPEETS') { + $ENV_TYPEETS = trim($propertyNode['value']); + } + if (strtoupper($propertyNode['name']) === 'RHPROVIDER') { + $wRHPROVIDER = trim($propertyNode['value']); + } + if (strtoupper($propertyNode['name']) === 'RHPROVIDER2') { + $wRHPROVIDER2 = trim($propertyNode['value']); + } + if (strtoupper($propertyNode['name']) === 'RHPROVIDER_PREFIX') { + $wRHPROVIDER_PREFIX = str_replace('_', '', trim($propertyNode['value'])); + } + if (strtoupper($propertyNode['name']) === 'RHPROVIDER2_PREFIX') { + $wRHPROVIDER2_PREFIX = str_replace('_', '',trim($propertyNode['value'])); + } + } + } + + switch (strtolower($wRHPROVIDER)) { + case 'shs' : + case 'sagex3' : + case 'sage100rh' : + case 'sagei7rh' : + case 'adonix' : + case 'quadrarh' : + case 'qsp' : + case 'sigems' : + case 'cegi' : + case 'icti_rh' : + $RHPROVIDER = strtoupper($wRHPROVIDER); + break; + + default: + $RHPROVIDER = ''; + } + + if ($wRHPROVIDER2 !== '') { + switch (strtolower($wRHPROVIDER2)) { + case 'shs' : + case 'sagex3' : + case 'sage100rh' : + case 'sagei7rh' : + case 'adonix' : + case 'quadrarh' : + case 'qsp' : + case 'sigems' : + case 'cegi' : + $RHPROVIDER2 = strtoupper($wRHPROVIDER2); + break; + + default: + $RHPROVIDER2 = ''; + } + + } + + if ($RHPROVIDER === '') { + logErrorMsg("Prestataire $wRHPROVIDER non traité actuellement"); + return false; + } + + if ($RHPROVIDER2 === '') { + $RHPROVIDER_PREFIX = ''; + $RHPROVIDER2_PREFIX = ''; + } + else { + $RHPROVIDER_PREFIX = $wRHPROVIDER_PREFIX; + $RHPROVIDER2_PREFIX = $wRHPROVIDER2_PREFIX; + if ($RHPROVIDER_PREFIX === '') { + $RHPROVIDER_PREFIX = substr($RHPROVIDER,0,2); + } + $RHPROVIDER_PREFIX = '_' . $RHPROVIDER_PREFIX; + if ($RHPROVIDER2_PREFIX === '') { + $RHPROVIDER2_PREFIX = substr($RHPROVIDER2,0,2); + } + $RHPROVIDER2_PREFIX = '_' . $RHPROVIDER2_PREFIX; + } + + // Chargement des paramètres et connexion BD + $iCTI_connexion = Database2Factory::getInstance(Environnement::PROVIDER_CTI); + $ret = $iCTI_connexion->connect(); + if (!$ret) { + logErrorMsg("La connexion PostgreSQL iCTI a échoué"); + return false; + } + + return true; +} + +function iCTI_disconnect() { + + global $iCTI_connexion; + + $iCTI_connexion->close(); +} diff --git a/import_rh/iCTI_import_rh_init_meta4.php b/import_rh/iCTI_import_rh_init_meta4.php new file mode 100644 index 0000000..b7dc021 --- /dev/null +++ b/import_rh/iCTI_import_rh_init_meta4.php @@ -0,0 +1,103 @@ +connect(); + +$allCsv = ListIn($root); + +$conn->query("DROP SCHEMA prod_meta4 CASCADE;"); +$conn->query("CREATE SCHEMA IF NOT EXISTS prod_meta4;"); + +foreach ($allCsv as $csvFile) { + echo PHP_EOL."TRAITEMENT DE LA TABLE " .$csvFile[0]."/".$csvFile[1]; + $buffer = ''; + $tmpCols = array(); + $tmpCols2 = array(); + $tmpCols3 = array(); + $tmpCols4 = array(); + $colDef = ''; + $colSELECT = ''; + $colSELECT4 = ''; + + $handle = fopen($csvFile[0].DIRECTORY_SEPARATOR.$csvFile[1], "r"); + if ($handle) { + $buffer = fgets($handle); + fclose($handle); + } + + $tmpCols = explode('|', $buffer); + + foreach ($tmpCols as $value) { + if (trim($value) !== '') { + $tmpCols2[] = "''::text as ".$value; + $tmpCols3[] = $value; + $tmpCols4[] = strtolower("'".trim($value)."'"); + } else { + echo " (Colonne en plus)"; + } + } + $colDef= implode(',', $tmpCols2); + $colSELECT = implode(',', $tmpCols3); + $colSELECT4 = implode(',', $tmpCols4); + + // Création de la table de réception de la données si n'existe pas. + $conn->query("create table if not exists prod_meta4.".$csvFile[2]." as select $colDef limit 0"); + + // Ajout des colonnes manquantes. + $toto = $conn->queryFetchAllAssoc("select unnest(ARRAY[$colSELECT4]) as new_col + EXCEPT + select column_name from information_schema.columns where table_schema = 'prod_meta4' and table_name = lower('".$csvFile[2]."'::text)"); + if ($toto !== false) { + foreach ($toto as $value) { + echo PHP_EOL."NOUVELLE colonne : prod_meta4.".$csvFile[2].".".$value['new_col']; + $conn->query("ALTER TABLE prod_meta4.".$csvFile[2]." ADD COLUMN ".$value['new_col']." text"); + } + } + + // Suppression puis création de la table héritée pour le mois donné. + $mois = substr($csvFile[0], -6); + $childTable = $csvFile[2]."_".$mois; + $conn->query("drop table if exists prod_meta4.$childTable; create table if not exists prod_meta4.$childTable() INHERITS (prod_meta4.".$csvFile[2].")"); + + // Création de la table temporaire de chargement de la donnée. + $conn->query("drop table if exists w_meta4_load; create temp table w_meta4_load as select $colDef limit 0"); + $tlt = $conn->query("copy w_meta4_load + from '".$csvFile[0]."/".$csvFile[1]."' + CSV HEADER delimiter '|' encoding 'LATIN9'"); + $conn->query("insert into prod_meta4.$childTable($colSELECT) select $colSELECT from w_meta4_load;"); + if ($tlt === false){ + echo PHP_EOL.$conn->lastError(); + } +} + +// Déconnexion BD +$conn->close(); + +function ListIn($dir) { + $result = array(); + + foreach (scandir($dir) as $f) { + if ($f !== '.' && $f !== '..') { + if (is_dir($dir.DIRECTORY_SEPARATOR.$f)) { + $result = array_merge($result, ListIn($dir.DIRECTORY_SEPARATOR.$f, $f)); + } else { + if (substr($f, -4) === '.csv') { + if (substr($f, 0, 7) == 'CTI_KER') { + $result[] = array($dir, $f, substr($f, 8, -4)); // suppression du prefixe CTI_KER et de l'extension .csv. + } else { + $result[] = array($dir, $f, substr($f, 4, -4)); + } + } + } + } + } + return $result; +} \ No newline at end of file diff --git a/php/Environnement.class.php b/php/Environnement.class.php new file mode 100644 index 0000000..e69de29 diff --git a/php/RH_components.php b/php/RH_components.php new file mode 100644 index 0000000..e059912 --- /dev/null +++ b/php/RH_components.php @@ -0,0 +1,812 @@ += ' . $tmpAge1; + } + if ($tmpAge2 != '') { + $where = ' <= ' . $tmpAge2; + } + if ($tmpAge1 != '' && $tmpAge2 != '') { + $where = ' BETWEEN ' . $tmpAge1 . ' AND ' . $tmpAge2; + } + } + + $subselect_select = ''; + + $field_id = $field_prefixe . "_id"; + $field2_id = $field2_prefixe . "_id"; + $field_section_id = $field_prefixe . "_section_id[" . $section . "]"; + + if ($mode == 'LI') { + $subselect_select = " $field_id = ANY (array(SELECT to_id FROM $module.t_listes_contenu WHERE liste_id = $oid)::bigint[])"; + } + if ($mode == 'SL') { + $subselect_select = " $field_id != ALL (array(SELECT to_id FROM $module.t_listes_contenu WHERE liste_id = $oid)::bigint[])"; + } + if ($mode == 'LS') { + $subselect_select = " $field_section_id = $oid"; + } + if ($mode == 'NV') { + $subselect_select = " $field_id IS DISTINCT FROM 0"; + } + if ($mode == 'DT') { + $subselect_select = " $field_id = $oid"; + } + if ($mode == 'D2') { + $subselect_select = " $field2_id = $oid"; + } + if ($mode == 'C*') { + $subselect_select = " $field_id = ANY (array(SELECT oid FROM $module.$table_name WHERE $where_codes)::bigint[])"; + } + if ($mode == 'IN') { + $subselect_select = " age_id $where"; + } + + if ($subselect_select != '') { + $select = " AND $subselect_select "; + } + } + + return $select; + } + + public static function specific_field_select($field, $value, $dateDebut, $dateFin) + { + $ret = ''; + + switch ($field) { + case 'PRESENCESAL': + switch ($value) { + case '1': + $ret .= " + AND v_rh_view_1.date_debut_activite = '$dateDebut' + "; + break; + case '2': + $ret .= " + AND v_rh_view_1.date_fin_activite = '$dateFin' + "; + break; + case '3': + $ret .= " + AND v_rh_view_1.date_debut_activite = '$dateDebut' + AND v_rh_view_1.date_fin_activite = '$dateFin' + "; + break; + } + break; + case 'PRESENCECNT': + switch ($value) { + case '1': + $ret .= " + AND v_rh_view_1.date_debut_contrat <= '$dateDebut' + "; + break; + case '2': + $ret .= " + AND v_rh_view_1.date_fin_contrat >= '$dateFin' + "; + break; + case '3': + $ret .= " + AND v_rh_view_1.date_debut_contrat <= '$dateDebut' + AND v_rh_view_1.date_fin_contrat >= '$dateFin' + "; + break; + case '4': + $ret .= " + AND v_rh_view_1.present_debut_mois = 1 + "; + break; + case '4a': + $ret .= " + AND (FALSE + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '101' + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '104' + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '107' + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '110') + "; + break; + case '4b': + $ret .= " + AND v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '101' + "; + break; + case '5': + $ret .= " + AND v_rh_view_1.present_fin_mois = 1 + "; + break; + case '5a': + $ret .= " + AND (FALSE + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '103' + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '106' + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '109' + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '112') + "; + break; + case '5b': + $ret .= " + AND v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '112' + "; + break; + case '6': + $ret .= " + AND v_rh_view_1.present_debut_mois = 1 + AND v_rh_view_1.present_fin_mois = 1 + "; + break; + case '6a': + $ret .= " + AND (FALSE + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '101' + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '104' + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '107' + OR v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '110') + AND (FALSE + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '103' + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '106' + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '109' + OR v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '112') + "; + break; + case '6b': + $ret .= " + AND v_rh_view_1.present_debut_mois||v_rh_view_1.mois_only_activite_code = '101' + AND v_rh_view_1.present_fin_mois||v_rh_view_1.mois_only_activite_code = '112' + "; + break; + case '7': + $ret .= " + AND v_rh_view_1.mois_activite_code = to_char('$dateDebut'::date, 'YYYYMM'::text) + AND v_rh_view_1.present_debut_mois = 1 + "; + break; + case '8': + $ret .= " + AND v_rh_view_1.mois_activite_code = to_char('$dateFin'::date, 'YYYYMM'::text) + AND v_rh_view_1.present_fin_mois = 1 + "; + break; + case '9': + $ret .= " + AND v_rh_view_1.mois_activite_code = to_char('$dateDebut'::date, 'YYYYMM'::text) + AND v_rh_view_1.present_debut_mois = 1 + AND v_rh_view_1.mois_activite_code = to_char('$dateFin'::date, 'YYYYMM'::text) + AND v_rh_view_1.present_fin_mois = 1 + "; + break; + } + break; + } + + return $ret; + } + + public static function specific_day_field_select($days) + { + $ret = ''; + + // On effectue le traitement uniquement si une case a été décochée. + if (implode('', $days) != '1111111') { + for ($i = 0; $i < 7; $i++) { + if ($days[$i] == '0') { + $ret .= "\nAND to_char(v_rh_view_1.date_fin_activite, 'ID') != " . ($i + 1); + } + } + } + + return $ret; + } +} diff --git a/php/RH_getTableRecords.php b/php/RH_getTableRecords.php new file mode 100644 index 0000000..b00972d --- /dev/null +++ b/php/RH_getTableRecords.php @@ -0,0 +1,3945 @@ +"; +$httpString .= "\n"; + +if ($tableName == "t_divers") { + $httpString .= getRecords_divers(); +} +if ($tableName == "t_categories_socio_professionnelle") { + $httpString .= getRecords_categories_socio_professionnelle(); +} +if ($tableName == "t_codes_emploi") { + $httpString .= getRecords_codes_emploi(); +} +if ($tableName == "t_entreprises") { + $httpString .= getRecords_entreprises(); +} +if ($tableName == "t_etablissements") { + $httpString .= getRecords_etablissements(); +} +if ($tableName == "t_grilles") { + $httpString .= getRecords_grilles(); + +} +if ($tableName == "t_grilles_groupes") { + $httpString .= getRecords_grilles_groupes(); + +} +if ($tableName == "t_groupes_cotisant") { + $httpString .= getRecords_groupes_cotisant(); + +} +if ($tableName == "t_motifs_arret") { + $httpString .= getRecords_motifs_arret(); + +} +if ($tableName == "t_motifs_debut_contrat") { + $httpString .= getRecords_motifs_debut_contrat(); +} +if ($tableName == "t_motifs_fin_contrat") { + $httpString .= getRecords_motifs_fin_contrat(); +} +if ($tableName == "t_organismes_cotisation") { + $httpString .= getRecords_organismes_cotisation(); +} +if ($tableName == "t_precisions_motif_arret") { + $httpString .= getRecords_precisions_motif_arret(); +} +if ($tableName == "t_qualifications") { + $httpString .= getRecords_qualifications(); +} +if ($tableName == "t_rubriques") { + $httpString .= getRecords_rubriques(); +} +if ($tableName == "t_sections_analytiques") { + $httpString .= getRecords_sections_analytiques(); +} +if ($tableName == "t_sections_analytiques_paie") { + $httpString .= getRecords_sections_analytiques_paie(); +} +if ($tableName == "t_services") { + $httpString .= getRecords_services(); +} +if ($tableName == "t_situations_famille") { + $httpString .= getRecords_situations_famille(); +} +if ($tableName == "t_societes_interim") { + $httpString .= getRecords_societes_interim(); + +} +if ($tableName == "t_specialites") { + $httpString .= getRecords_specialites(); + +} + +if ($tableName == "t_statuts") { + $httpString .= getRecords_statuts(); + +} +if ($tableName == "t_types_contrat") { + $httpString .= getRecords_types_contrat(); +} +if ($tableName == "t_types_horaire") { + $httpString .= getRecords_types_horaire(); + +} +if ($tableName == "t_types_temps_travail") { + $httpString .= getRecords_types_temps_travail(); +} + +if ($tableName == "t_motifs_visite") { + $httpString .= getRecords_motifs_visite(); + +} + +if ($tableName == "t_accident_circonstance") { + $httpString .= getRecords_accident_circonstance(); +} + +if ($tableName == "t_accident_lieu") { + $httpString .= getRecords_accident_lieu(); + +} + +if ($tableName == "t_accident_nature") { + $httpString .= getRecords_accident_nature(); +} + +if ($tableName == "t_accident_siege") { + $httpString .= getRecords_accident_siege(); +} + +if ($tableName == "t_unite_fonctionnelle") { + $httpString .= getRecords_unites_fonctionnelle(); +} + +if ($tableName == "t_lettre_budgetaire") { + $httpString .= getRecords_lettre_budgetaire(); +} + +if ($tableName == "t_commission_paritaire") { + $httpString .= getRecords_commission_paritaire(); +} + +if ($tableName == "t_categorie_conge") { + $httpString .= getRecords_categorie_conge(); +} + +if ($tableName == "t_cadre_emploi") { + $httpString .= getRecords_cadre_emploi(); +} + +if ($tableName == "t_filiere") { + $httpString .= getRecords_filiere(); +} + +if ($tableName == "t_categorie_statutaire") { + $httpString .= getRecords_categorie_statutaire(); +} + +if ($tableName == "t_compte") { + $httpString .= getRecords_compte(); + +} + +if ($tableName == "t_transformation") { + $httpString .= getRecords_transformation(); + $httpString .= getCombo_transformation(); +} + +if ($tableName == "t_expert_controle") { + if ($getOption != "getRefSettings") { + $httpString .= getRecords_expert_controle(); + } + else { + $httpString .= getRecords_expert_controle_refsettings($refPrefix); + } +} + +if ($tableName == "t_planning_service") { + $httpString .= getRecords_planning_service(); + $httpString .= getCombo_planning_service(); +} + +if ($tableName == "t_planning_qualification") { + $httpString .= getRecords_planning_qualification(); + $httpString .= getCombo_planning_qualification(); +} + +if ($tableName == "t_planning_type_absence") { + $httpString .= getRecords_planning_type_absence(); +} + +if ($tableName == "t_data_profile") { + $httpString .= getRecords_data_profile(); +} + +$httpString .= "\n"; + +$httpString = compress64($httpString); + +echo "$httpString"; + + + +function getRecords_divers() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + 1::bigint AS div_id, + code as div_code, + texte as div_texte, + valeur as div_valeur, + description as div_desc, + valeur2 as div_valeur2, + CASE WHEN show_info_module THEN 1 ELSE 0 END AS show_info_module + FROM rh.t_divers + ORDER BY code "; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + $oid = 1; + $code = toHTML(trim($record['div_code'])); + $texte = toHTML(trim($record['div_texte'])); + $valeur = toHTML(trim($record['div_valeur'])); + $description = toHTML(trim($record['div_desc'])); + $valeur2 = toHTML(trim($record['div_valeur2'])); + $show_info_module = toHTML(trim($record['show_info_module'])); + $nbref = 1; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + +function getRecords_categories_socio_professionnelle() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + oid as cat_id, + code as cat_code , + code_original as cat_code_original, + section_code as cat_section_code, + section_id as cat_section_id, + section_texte as cat_section_texte, + texte as cat_texte, + texte_court as cat_texte_court + FROM + rh.t_categories_socio_professionnelle + ORDER BY code "; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + $oid = 1; + $code = toHTML(trim($record['cat_code'])); + $code_original = toHTML(trim($record['cat_code_original'])); + $section_code = toHTML(trim($record['cat_section_code'])); + $section_id = toHTML(trim($record['cat_section_id'])); + $section_texte = toHTML(trim($record['cat_section_texte'])); + $texte = toHTML(trim($record['cat_texte'])); + $texte_court = toHTML(trim($record['cat_texte_court'])); + $nbref = 1; + + $httpString .= "\r\n"; + } + } + } + + + + return $httpString; +} + +function getRecords_codes_emploi() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + code as emp_code, + code_original as emp_code_original, + oid as emp_id, + section_code as emp_section_code, + section_id as emp_section_id, + section_texte as emp_section_texte, + texte as emp_texte, + texte_court as emp_texte_court + FROM rh.t_codes_emploi + ORDER BY code "; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['emp_code'])); + $code_original = toHTML(trim($record['emp_code_original'])); + $oid = 1; + $section_code = toHTML(trim($record['emp_section_code'])); + $section_id = toHTML(trim($record['emp_section_id'])); + $section_texte = toHTML(trim($record['emp_section_texte'])); + $texte = toHTML(trim($record['emp_texte'])); + $texte_court = toHTML(trim($record['emp_texte_court'])); + $nbref = 1; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + +function getRecords_entreprises() { + +global $database; + + $httpString = ""; + + $sqlcmd = "SELECT + code as ent_code, + code_original as ent_code_original, + oid as ent_id, + planning_code as ent_planning_code, + section_code as ent_section_code, + section_id as ent_section_id, + section_texte as ent_section_texte, + texte as ent_texte, + texte_court as ent_texte_court, + subview.xmlnodes as xmlnodes + FROM rh.t_entreprises + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['ent_code'])); + $code_original = toHTML(trim($record['ent_code_original'])); + $oid = $record['ent_id']; + $planning_code = toHTML(trim($record['ent_planning_code'])); + $section_code = toHTML(trim($record['ent_section_code'])); + $section_id = toHTML(trim($record['ent_section_id'])); + $section_texte = toHTML(trim($record['ent_section_texte'])); + $texte = toHTML(trim($record['um_texte'])); + $texte_court = toHTML(trim($record['um_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + $httpString .= "\r\n + > + $xmlHISTO + \r\n"; + } + } + } + + + return $httpString; +} + +function getRecords_etablissements() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + base_calcul_etp as etb_base_calcul_etp, + code as etb_code, + code_original as etb_code_original, + entreprise_id as etb_entreprise_id, + mode_calcul_etp_paye as etb_mode_calcul_etp_paye, + oid as etb_id, + planning_code as etb_planning_code, + section_code as etb_section_code, + section_id as etb_section_id, + section_texte as etb_section_texte, + texte as etb_texte, + texte_court as etb_texte_court, + subview.xmlnodes as xmlnodes + FROM rh.t_etablissements + WHERE oid > 0 + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + $base_calcul_etp = toHTML(trim($record['etb_base_calcul_etp'])); + $code = toHTML(trim($record['etb_code'])); + $code_original = toHTML(trim($record['etb_code_original'])); + $entreprise_id = toHTML(trim($record['etb_entreprise_id'])); + $mode_calcul_etp_paye = toHTML(trim($record['etb_mode_calcul_etp_paye'])); + $oid = $record['etb_id']; + $planning_code = toHTML(trim($record['etb_planning_code'])); + $section_code = toHTML(trim($record['etb_section_code'])); + $section_id = toHTML(trim($record['etb_section_id'])); + $section_texte = toHTML(trim($record['etb_section_texte'])); + $texte = toHTML(trim($record['etb_texte'])); + $texte_court = toHTML(trim($record['etb_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_grilles() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + code as gri_code, + code_original as gri_code_original, + oid as gri_id, + section_code as gri_section_code, + section_id as gri_section_id, + section_texte as gri_section_texte, + texte as gri_texte, + texte_court as gri_texte_court + FROM rh.t_grilles + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['gri_code'])); + $code_original = toHTML(trim($record['gri_code_original'])); + $oid = floatval($record['gri_id']); + $section_code = toHTML(trim($record['gri_section_code'])); + $section_id = toHTML(trim($record['gri_section_id'])); + $section_texte = toHTML(trim($record['gri_section_texte'])); + $texte = toHTML(trim($record['gri_texte'])); + $texte_court = toHTML(trim($record['gri_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_grilles_groupes() { + +global $database; + + $httpString = ""; + $sqlcmd = " SELECT + code as gri_gro_code, + code_original as gri_gro_code_original, + oid as gri_gro_id, + section_code as gri_gro_section_code, + section_id as gri_gro_section_id, + section_texte as gri_gro_section_texte, + texte as gri_gro_texte, + texte_court as gri_gro_texte_court + FROM rh.t_grilles_groupes + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['gri_gro_code'])); + $code_original = toHTML(trim($record['gri_gro_code_original'])); + $oid = floatval($record['gri_gro_id']); + $section_code = toHTML(trim($record['gri_gro_section_code'])); + $section_id = toHTML(trim($record['gri_gro_section_id'])); + $section_texte = toHTML(trim($record['gri_gro_section_texte'])); + $texte = toHTML(trim($record['gri_gro_texte'])); + $texte_court = toHTML(trim($record['gri_gro_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_groupes_cotisant() { + +global $database; + + $httpString = ""; + + $sqlcmd = "SELECT + + code as gro_cot_code, + code_original as gro_cot_code_original, + oid as gro_cot_id, + section_code as gro_cot_section_code, + section_id as gro_cot_section_id, + section_texte as gro_cot_section_texte, + texte as gro_cot_texte, + texte_court as gro_cot_texte_court + FROM rh.t_groupes_cotisant + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['gro_cot_code'])); + $code_original = toHTML(trim($record['gro_cot_code_original'])); + $oid = floatval($record['gro_cot_id']); + $section_code = toHTML(trim($record['gro_cot_section_code'])); + $section_id = toHTML(trim($record['gro_cot_section_id'])); + $section_texte = toHTML(trim($record['gro_cot_section_texte'])); + $texte = toHTML(trim($record['gro_cot_texte'])); + $texte_court = toHTML(trim($record['gro_cot_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_motifs_arret() { + +global $database; + + $httpString = ""; + + $sqlcmd = " + SELECT + code as arr_code, + code_original as arr_code_original, + oid as arr_id, + rang_edition as arr_rang_edition, + section_code as arr_section_code, + section_id as arr_section_id, + section_texte as arr_section_texte, + texte as arr_texte, + texte_court as arr_texte_court + FROM rh.t_motifs_arret + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['arr_code'])); + $code_original = toHTML(trim($record['arr_code_original'])); + $oid = floatval($record['arr_id']); + $rang_edition = toHTML(trim($record['arr_rang_edition'])); + $section_code = toHTML(trim($record['arr_section_code'])); + $section_id = toHTML(trim($record['arr_section_id'])); + $section_texte = toHTML(trim($record['arr_section_texte'])); + $texte = toHTML(trim($record['arr_texte'])); + $texte_court = toHTML(trim($record['arr_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_motifs_debut_contrat() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + code as mot_deb_code, + code_original as mot_deb_code_original, + oid as mot_deb_id, + section_code as mot_deb_section_code, + section_id as mot_deb_section_id, + section_texte as mot_deb_section_texte, + texte as mot_deb_texte, + texte_court as mot_deb_texte_court + FROM rh.t_motifs_debut_contrat + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['mot_deb_code'])); + $code_original = toHTML(trim($record['mot_deb_code_original'])); + $oid = floatval($record['mot_deb_id']); + $rang_edition = toHTML(trim($record['mot_deb_rang_edition'])); + $section_code = toHTML(trim($record['mot_deb_section_code'])); + $section_id = toHTML(trim($record['mot_deb_section_id'])); + $section_texte = toHTML(trim($record['mot_deb_section_texte'])); + $texte = toHTML(trim($record['mot_deb_texte'])); + $texte_court = toHTML(trim($record['mot_deb_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_motifs_fin_contrat() { + +global $database; + + $httpString = ""; + + $sqlcmd = "SELECT + code as mot_fin_code, + code_original as mot_fin_code_original, + oid as mot_fin_id, + section_code as mot_fin_section_code, + section_id as mot_fin_section_id, + section_texte as mot_fin_section_texte, + texte as mot_fin_texte, + texte_court as mot_fin_texte_court + FROM rh.t_motifs_fin_contrat + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['mot_fin_code'])); + $code_original = toHTML(trim($record['mot_fin_code_original'])); + $oid = floatval($record['mot_fin_id']); + $section_code = toHTML(trim($record['mot_fin_section_code'])); + $section_id = toHTML(trim($record['mot_fin_section_id'])); + $section_texte = toHTML(trim($record['mot_fin_section_texte'])); + $texte = toHTML(trim($record['mot_fin_texte'])); + $texte_court = toHTML(trim($record['mot_fin_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_nationalites() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + code as nat_code, + code_original as nat_code_original, + oid as nat_id, + section_code as nat_section_code, + section_id as nat_section_id, + section_texte as nat_section_texte, + texte as nat_texte, + texte_court as nat_texte_court + FROM rh.t_nationalites + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['nat_code'])); + $code_original = toHTML(trim($record['nat_code_original'])); + $oid = floatval($record['nat_id']); + $section_code = toHTML(trim($record['nat_section_code'])); + $section_id = toHTML(trim($record['nat_section_id'])); + $section_texte = toHTML(trim($record['nat_section_texte'])); + $texte = toHTML(trim($record['nat_texte'])); + $texte_court = toHTML(trim($record['nat_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_organismes_cotisation() { + +global $database; + + $httpString = ""; + + $httpString_tmp = ""; + + $sqlcmd = " SELECT + code as org_code, + code_original as org_code_original, + oid as org_id, + section_code as org_section_code, + section_id as org_section_id, + section_texte as org_section_texte, + texte as org_texte, + texte_court as org_texte_court + FROM rh.t_organismes_cotisation + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['org_code'])); + $code_original = toHTML(trim($record['org_code_original'])); + $oid = floatval($record['org_id']); + $section_code = toHTML(trim($record['org_section_code'])); + $section_id = toHTML(trim($record['org_section_id'])); + $section_texte = toHTML(trim($record['org_section_texte'])); + $texte = toHTML(trim($record['org_texte'])); + $texte_court = toHTML(trim($record['org_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_precisions_motif_arret() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + code as pre_mot_code, + code_original as pre_mot_code_original, + oid as pre_mot_id, + rang_edition as pre_mot_rang_edition, + section_code as pre_mot_section_code, + section_id as pre_mot_section_id, + section_texte as pre_mot_section_texte, + texte as pre_mot_texte, + texte_court as pre_mot_texte_court + FROM rh.t_precisions_motif_arret + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['pre_mot_code'])); + $code_original = toHTML(trim($record['pre_mot_code_original'])); + $oid = floatval($record['pre_mot_id']); + $rang_edition = toHTML(trim($record['pre_mot_rang_edition'])); + $section_code = toHTML(trim($record['pre_mot_section_code'])); + $section_id = toHTML(trim($record['pre_mot_section_id'])); + $section_texte = toHTML(trim($record['pre_mot_section_texte'])); + $texte = toHTML(trim($record['pre_mot_texte'])); + $texte_court = toHTML(trim($record['pre_mot_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_qualifications() { + +global $database; + + $httpString = ""; + + $httpString_tmp = ""; + + $sqlcmd = " SELECT + code as qua_code, + code_original as qua_code_original, + oid as qua_id, + section_code as qua_section_code, + section_id as qua_section_id, + section_texte as qua_section_texte, + texte as qua_texte, + texte_court as qua_texte_court + FROM rh.t_qualifications + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['qua_code'])); + $code_original = toHTML(trim($record['qua_code_original'])); + $oid = floatval($record['qua_id']); + $section_code = toHTML(trim($record['qua_section_code'])); + $section_id = toHTML(trim($record['qua_section_id'])); + $section_texte = toHTML(trim($record['qua_section_texte'])); + $texte = toHTML(trim($record['qua_texte'])); + $texte_court = toHTML(trim($record['qua_texte_court'])); + $xmlHISTO = trim($record['xmlnodes']); + $nbref = 0; + + + + $httpString .= + "\r\n + $xmlHISTO + \r\n"; + } + } + } + return $httpString; +} + +function getRecords_rubriques() { + +global $database; + + $httpString = ""; + + $httpString_tmp = ""; + + $sqlcmd = " SELECT + c_avantage_nature as rub_c_avantage_nature, + c_base as rub_c_base, + c_brut as rub_c_brut, + c_cotisation_patronale as rub_c_cotisation_patronale, + c_cotisation_salarie as rub_c_cotisation_salarie, + c_frais_imposables as rub_c_frais_imposables, + c_heures_payees as rub_c_heures_payees, + c_heures_travaillees as rub_c_heures_travaillees, + c_masse_salariale as rub_c_masse_salariale, + c_net_a_payer as rub_c_net_a_payer, + c_net_imposable as rub_c_net_imposable, + c_nombre as rub_c_nombre, + c_od_net_patronale as rub_c_od_net_patronale, + c_od_net_salarie as rub_c_od_net_salarie, + chapitre_bulletin as rub_chapitre bulletin, + code as rub_code, + code_calcul as rub_code_calcul, + code_original as rub_code_original, + coefficient as rub_coefficient, + coefficient_base as rub_coefficient_base, + coefficient_nombre as rub_coefficient_nombre, + coefficient_txp as rub_coefficient_txp, + coefficient_txs as rub_coefficient_txs, + heures_payees as rub_heures_payees, + oid as rub_id, + CASE WHEN p_avantage_nature THEN 1 ELSE 0 END AS rub_p_avantage_nature, + CASE WHEN p_base THEN 1 ELSE 0 END AS rub_p_base, + CASE WHEN p_brut THEN 1 ELSE 0 END AS rub_p_brut, + CASE WHEN p_cotisation_patronale THEN 1 ELSE 0 END AS rub_p_cotisation_patronale, + CASE WHEN p_cotisation_salarie THEN 1 ELSE 0 END AS rub_p_cotisation_salarie, + CASE WHEN p_cumul THEN 1 ELSE 0 END AS rub_p_cumul, + CASE WHEN p_detail THEN 1 ELSE 0 END AS rub_p_detail, + CASE WHEN p_frais_imposables THEN 1 ELSE 0 END AS rub_p_frais_imposables, + CASE WHEN p_heures_payees THEN 1 ELSE 0 END AS rub_p_heures_payees, + CASE WHEN p_heures_travaillees THEN 1 ELSE 0 END AS rub_p_heures_travaillees, + CASE WHEN p_masse_salariale THEN 1 ELSE 0 END AS rub_p_masse_salariale, + CASE WHEN p_net_a_payer THEN 1 ELSE 0 END AS rub_p_net_a_payer, + CASE WHEN p_net_imposable THEN 1 ELSE 0 END AS rub_p_net_imposable, + CASE WHEN p_nombre THEN 1 ELSE 0 END AS rub_p_nombre, + CASE WHEN p_od_net_patronale THEN 1 ELSE 0 END AS rub_p_od_net_patronale, + CASE WHEN p_od_net_salarie THEN 1 ELSE 0 END AS rub_p_od_net_salarie, + rang_edition as rub_rang_edition, + s_avantage_nature as rub_s_avantage_nature, + s_base as rub_s_base, + s_brut as rub_s_brut, + s_cotisation_patronale as rub_s_cotisation_patronale, + s_cotisation_salarie as rub_s_cotisation_salarie, + s_frais_imposables as rub_s_frais_imposables, + s_heures_payees as rub_s_heures_payees, + s_heures_travaillees as rub_heures_travaillees, + s_masse_salariale as rub_s_masse_salariale, + s_net_a_payer as rub_s_net_a_payer, + s_net_imposable as rub_s_net_imposable, + s_nombre as rub_s_nombre, + s_od_net_patronale as rub_s_od_net_patronale, + s_od_net_salarie as rub_s_od_net_salarie, + section_code as rub_section_code, + section_id as rub_section_id, + section_texte as rub_section_texte, + texte as rub_texte, + texte_court as rub_texte_court, + unite as rub_unite, + CASE WHEN user_modified THEN 1 ELSE 0 END AS rub_user_modified + FROM + rh.t_rubriques + ORDER BY code"; + + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $c_avantage_nature=toHTML(trim($record['c_avantage_nature'])); + $c_base=toHTML(trim($record['c_base'])); + $c_brut=toHTML(trim($record['c_brut'])); + $c_cotisation_patronale=toHTML(trim($record['c_cotisation_patronale'])); + $c_cotisation_salarie=toHTML(trim($record['c_cotisation_salarie'])); + $c_frais_imposables=toHTML(trim($record['c_frais_imposables'])); + $c_heures_payees=toHTML(trim($record['c_heures_payees'])); + $c_heures_travaillees=toHTML(trim($record['c_heures_travaillees'])); + $c_masse_salariale=toHTML(trim($record['c_masse_salariale'])); + $c_net_a_payer=toHTML(trim($record['c_net_a_payer'])); + $c_net_imposable=toHTML(trim($record['c_net_imposable'])); + $c_nombre=toHTML(trim($record['c_nombre'])); + $c_od_net_patronale=toHTML(trim($record['c_od_net_patronale'])); + $c_od_net_salarie=toHTML(trim($record['c_od_net_salarie'])); + $chapitre_bulletin=toHTML(trim($record['chapitre_bulletin'])); + $code=toHTML(trim($record['code'])); + $code_calcul=toHTML(trim($record['code_calcul'])); + $code_original=toHTML(trim($record['code_original'])); + $coefficient=toHTML(trim($record['coefficient'])); + $coefficient_base=toHTML(trim($record['coefficient_base'])); + $coefficient_nombre=toHTML(trim($record['coefficient_nombre'])); + $coefficient_txp=toHTML(trim($record['coefficient_txp'])); + $coefficient_txs=toHTML(trim($record['coefficient_txs'])); + $heures_payees=toHTML(trim($record['heures_payees'])); + $oid=toHTML(trim($record['oid'])); + $p_avantage_nature=toHTML(trim($record['p_avantage_nature'])); + $p_base=toHTML(trim($record['p_base'])); + $p_brut=toHTML(trim($record['p_brut'])); + $p_cotisation_patronale=toHTML(trim($record['p_cotisation_patronale'])); + $p_cotisation_salarie=toHTML(trim($record['p_cotisation_salarie'])); + $p_cumul=toHTML(trim($record['p_cumul'])); + $p_detail=toHTML(trim($record['p_detail'])); + $p_frais_imposables=toHTML(trim($record['p_frais_imposables'])); + $p_heures_payees=toHTML(trim($record['p_heures_payees'])); + $p_heures_travaillees=toHTML(trim($record['p_heures_travaillees'])); + $p_masse_salariale=toHTML(trim($record['p_masse_salariale'])); + $p_net_a_payer=toHTML(trim($record['p_net_a_payer'])); + $p_net_imposable=toHTML(trim($record['p_net_imposable'])); + $p_nombre=toHTML(trim($record['p_nombre'])); + $p_od_net_patronale=toHTML(trim($record['p_od_net_patronale'])); + $p_od_net_salarie=toHTML(trim($record['p_od_net_salarie'])); + $rang_edition=toHTML(trim($record['rang_edition'])); + $s_avantage_nature=toHTML(trim($record['s_avantage_nature'])); + $s_base=toHTML(trim($record['s_base'])); + $s_brut=toHTML(trim($record['s_brut'])); + $s_cotisation_patronale=toHTML(trim($record['s_cotisation_patronale'])); + $s_cotisation_salarie=toHTML(trim($record['s_cotisation_salarie'])); + $s_frais_imposables=toHTML(trim($record['s_frais_imposables'])); + $s_heures_payees=toHTML(trim($record['s_heures_payees'])); + $s_heures_travaillees=toHTML(trim($record['s_heures_travaillees'])); + $s_masse_salariale=toHTML(trim($record['s_masse_salariale'])); + $s_net_a_payer=toHTML(trim($record['s_net_a_payer'])); + $s_net_imposable=toHTML(trim($record['s_net_imposable'])); + $s_nombre=toHTML(trim($record['s_nombre'])); + $s_od_net_patronale=toHTML(trim($record['s_od_net_patronale'])); + $s_od_net_salarie=toHTML(trim($record['s_od_net_salarie'])); + $section_code=toHTML(trim($record['section_code'])); + $section_id=toHTML(trim($record['section_id'])); + $section_texte=toHTML(trim($record['section_texte'])); + $texte=toHTML(trim($record['texte'])); + $texte_court=toHTML(trim($record['texte_court'])); + $unite=toHTML(trim($record['unite'])); + $user_modified=toHTML(trim($record['user_modified'])); + $nbref = 0; + + + $httpString_tmp .= "\r\n"; + + + + + } + } + } + + + return $httpString; +} + +function getRecords_sections_analytiques() { + +global $database; + + $httpString = ""; + + $sqlcmd = " SELECT + code as sec_ana_code, + code_original as sec_ana_code_original, + oid as sec_ana_id, + section_code as sec_ana_section_code, + section_id as sec_ana_section_id, + section_texte as sec_ana_section_texte, + texte as sec_ana_texte, + texte_court as sec_ana_texte_court + FROM + rh.t_sections_analytiques + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['sec_ana_code'])); + $code_original = toHTML(trim($record['sec_ana_code_original'])); + $oid = $record['sec_ana_id']; + $section_code = toHTML(trim($record['sec_ana_section_code'])); + $section_id = toHTML(trim($record['sec_ana_section_id'])); + $section_texte = toHTML(trim($record['sec_ana_section_texte'])); + $texte = toHTML(trim($record['sec_ana_texte'])); + $texte_court = toHTML(trim($record['sec_ana_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + +function getRecords_sections_analytiques_paie() { + +global $database; + + $httpString = ""; + + $httpString_tmp = ""; + + $sqlcmd = " SELECT + code as sec_pai_code, + code_original as sec_pai_code_original, + oid as sec_pai_id, + section_code as sec_pai_section_code, + section_id as sec_pai_section_id, + section_texte as sec_pai_section_texte, + texte as sec_pai_texte, + texte_court as sec_pai_texte_court + FROM + rh.t_sections_analytiques_paie + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['sec_pai_code'])); + $code_original = toHTML(trim($record['sec_pai_code_original'])); + $oid = $record['sec_pai_id']; + $section_code = toHTML(trim($record['sec_pai_section_code'])); + $section_id = toHTML(trim($record['sec_pai_section_id'])); + $section_texte = toHTML(trim($record['sec_pai_section_texte'])); + $texte = toHTML(trim($record['sec_pai_texte'])); + $texte_court = toHTML(trim($record['sec_pai_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + +function getRecords_services() { + +global $database; + + $httpString = ""; + + $sqlcmd = " + SELECT + code as ser_code, + code_original as ser_code_original, + oid as ser_id, + section_code as ser_section_code, + section_id as ser_section_id, + section_texte as ser_section_texte, + texte as ser_texte, + texte_court as ser_texte_court + FROM + rh.t_services + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['ser_code'])); + $code_original = toHTML(trim($record['ser_code_original'])); + $oid = $record['ser_id']; + $section_code = toHTML(trim($record['ser_section_code'])); + $section_id = toHTML(trim($record['ser_section_id'])); + $section_texte = toHTML(trim($record['ser_section_texte'])); + $texte = toHTML(trim($record['ser_texte'])); + $texte_court = toHTML(trim($record['ser_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + + +function getRecords_situations_famille() { + +global $database; + + $httpString = ""; + + $sqlcmd = " + SELECT + code as sit_code, + code_original as sit_code_original, + oid as sit_id, + section_code as sit_section_code, + section_id as sit_section_id, + section_texte as sit_section_texte, + texte as sit_texte, + texte_court as sit_texte_court + FROM + rh.t_situations_famille + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['sit_code'])); + $code_original = toHTML(trim($record['sit_code_original'])); + $oid = $record['sit_id']; + $section_code = toHTML(trim($record['sit_section_code'])); + $section_id = toHTML(trim($record['sit_section_id'])); + $section_texte = toHTML(trim($record['sit_section_texte'])); + $texte = toHTML(trim($record['sit_texte'])); + $texte_court = toHTML(trim($record['sit_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_societes_interim() { + +global $database; + + $httpString = ""; + + $sqlcmd = "SELECT + code as soc_code, + code_original as soc_code_original, + oid as soc_id, + section_code as soc_section_code, + section_id as soc_section_id, + section_texte as soc_section_texte, + texte as soc_texte, + texte_court as soc_texte_court + FROM + rh.t_societes_interim + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['soc_code'])); + $code_original = toHTML(trim($record['soc_code_original'])); + $oid = $record['soc_id']; + $section_code = toHTML(trim($record['soc_section_code'])); + $section_id = toHTML(trim($record['soc_section_id'])); + $section_texte = toHTML(trim($record['soc_section_texte'])); + $texte = toHTML(trim($record['soc_texte'])); + $texte_court = toHTML(trim($record['soc_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_specialites() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as spe_code, + code_original as spe_code_original, + oid as spe_id, + section_code as spe_section_code, + section_id as spe_section_id, + section_texte as spe_section_texte, + texte as spe_texte, + texte_court as spe_texte_court + FROM + rh.t_specialites + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['spe_code'])); + $code_original = toHTML(trim($record['spe_code_original'])); + $oid = $record['spe_id']; + $section_code = toHTML(trim($record['spe_section_code'])); + $section_id = toHTML(trim($record['spe_section_id'])); + $section_texte = toHTML(trim($record['spe_section_texte'])); + $texte = toHTML(trim($record['spe_texte'])); + $texte_court = toHTML(trim($record['spe_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + +function getRecords_statuts() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as sta_code, + code_original as sta_code_original, + oid as sta_id, + section_code as sta_section_code, + section_id as sta_section_id, + section_texte as sta_section_texte, + texte as sta_texte, + texte_court as sta_texte_court + FROM + rh.t_statuts + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['sta_code'])); + $code_original = toHTML(trim($record['sta_code_original'])); + $oid = $record['sta_id']; + $section_code = toHTML(trim($record['sta_section_code'])); + $section_id = toHTML(trim($record['sta_section_id'])); + $section_texte = toHTML(trim($record['sta_section_texte'])); + $texte = toHTML(trim($record['sta_texte'])); + $texte_court = toHTML(trim($record['sta_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_types_contrat() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as typ_code, + code_original as typ_code_original, + oid as typ_id, + section_code as typ_section_code, + section_id as typ_section_id, + section_texte as typ_section_texte, + texte as typ_texte, + texte_court as typ_texte_court + FROM + rh.t_types_contrat + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['typ_code'])); + $code_original = toHTML(trim($record['typ_code_original'])); + $oid = $record['typ_id']; + $section_code = toHTML(trim($record['typ_section_code'])); + $section_id = toHTML(trim($record['typ_section_id'])); + $section_texte = toHTML(trim($record['typ_section_texte'])); + $texte = toHTML(trim($record['typ_texte'])); + $texte_court = toHTML(trim($record['typ_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_types_horaire() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as typ_hor_code, + code_original as typ_hor_code_original, + oid as typ_hor_id, + section_code as typ_hor_section_code, + section_id as typ_hor_section_id, + section_texte as typ_hor_section_texte, + texte as typ_hor_texte, + texte_court as typ_hor_texte_court + FROM + rh.t_types_horaire + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['typ_hor_code'])); + $code_original = toHTML(trim($record['typ_hor_code_original'])); + $oid = $record['typ_hor_id']; + $section_code = toHTML(trim($record['typ_hor_section_code'])); + $section_id = toHTML(trim($record['typ_hor_section_id'])); + $section_texte = toHTML(trim($record['typ_hor_section_texte'])); + $texte = toHTML(trim($record['typ_hor_texte'])); + $texte_court = toHTML(trim($record['typ_hor_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + +function getRecords_types_temps_travail() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as typ_tra_code, + code_original as typ_tra_code_original, + oid as typ_tra_id, + section_code as typ_tra_section_code, + section_id as typ_tra_section_id, + section_texte as typ_tra_section_texte, + texte as typ_tra_texte, + texte_court as typ_tra_texte_court + FROM + rh.t_types_temps_travail + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['typ_tra_code'])); + $code_original = toHTML(trim($record['typ_tra_code_original'])); + $oid = $record['typ_tra_id']; + $section_code = toHTML(trim($record['typ_tra_section_code'])); + $section_id = toHTML(trim($record['typ_tra_section_id'])); + $section_texte = toHTML(trim($record['typ_tra_section_texte'])); + $texte = toHTML(trim($record['typ_tra_texte'])); + $texte_court = toHTML(trim($record['typ_tra_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_motifs_visite() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as mot_vis_code, + code_original as mot_vis_code_original, + oid as mot_vis_id, + section_code as mot_vis_section_code, + section_id as mot_vis_section_id, + section_texte as mot_vis_section_texte, + texte as mot_vis_texte, + texte_court as mot_vis_texte_court + FROM + rh.t_motifs_visite + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['mot_vis_code'])); + $code_original = toHTML(trim($record['mot_vis_code_original'])); + $oid = $record['mot_vis_id']; + $section_code = toHTML(trim($record['mot_vis_section_code'])); + $section_id = toHTML(trim($record['mot_vis_section_id'])); + $section_texte = toHTML(trim($record['mot_vis_section_texte'])); + $texte = toHTML(trim($record['mot_vis_texte'])); + $texte_court = toHTML(trim($record['mot_vis_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_accident_circonstance() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as acc_cir_code, + code_original as acc_cir_code_original, + oid as acc_cir_id, + section_code as acc_cir_section_code, + section_id as acc_cir_section_id, + section_texte as acc_cir_section_texte, + texte as acc_cir_texte, + texte_court as acc_cir_texte_court + FROM + rh.t_accident_circonstance + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['acc_cir_code'])); + $code_original = toHTML(trim($record['acc_cir_code_original'])); + $oid = $record['acc_cir_id']; + $section_code = toHTML(trim($record['acc_cir_section_code'])); + $section_id = toHTML(trim($record['acc_cir_section_id'])); + $section_texte = toHTML(trim($record['acc_cir_section_texte'])); + $texte = toHTML(trim($record['acc_cir_texte'])); + $texte_court = toHTML(trim($record['acc_cir_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_accident_lieu() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as acc_lieu_code, + code_original as acc_lieu_code_original, + oid as acc_lieu_id, + section_code as acc_lieu_section_code, + section_id as acc_lieu_section_id, + section_texte as acc_lieu_section_texte, + texte as acc_lieu_texte, + texte_court as acc_lieu_texte_court + FROM + rh.t_accident_lieu + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['acc_lieu_code'])); + $code_original = toHTML(trim($record['acc_lieu_code_original'])); + $oid = $record['acc_lieu_id']; + $section_code = toHTML(trim($record['acc_lieu_section_code'])); + $section_id = toHTML(trim($record['acc_lieu_section_id'])); + $section_texte = toHTML(trim($record['acc_lieu_section_texte'])); + $texte = toHTML(trim($record['acc_lieu_texte'])); + $texte_court = toHTML(trim($record['acc_lieu_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_accident_nature() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as acc_nat_code, + code_original as acc_nat_code_original, + oid as acc_nat_id, + section_code as acc_nat_section_code, + section_id as acc_nat_section_id, + section_texte as acc_nat_section_texte, + texte as acc_nat_texte, + texte_court as acc_nat_texte_court + FROM + rh.t_accident_nature + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['acc_nat_code'])); + $code_original = toHTML(trim($record['acc_nat_code_original'])); + $oid = $record['acc_nat_id']; + $section_code = toHTML(trim($record['acc_nat_section_code'])); + $section_id = toHTML(trim($record['acc_nat_section_id'])); + $section_texte = toHTML(trim($record['acc_nat_section_texte'])); + $texte = toHTML(trim($record['acc_nat_texte'])); + $texte_court = toHTML(trim($record['acc_nat_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_accident_siege() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as acc_sie_code, + code_original as acc_sie_code_original, + oid as acc_sie_id, + section_code as acc_sie_section_code, + section_id as acc_sie_section_id, + section_texte as acc_sie_section_texte, + texte as acc_sie_texte, + texte_court as acc_sie_texte_court + FROM + rh.t_accident_siege + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['acc_sie_code'])); + $code_original = toHTML(trim($record['acc_sie_code_original'])); + $oid = $record['acc_sie_id']; + $section_code = toHTML(trim($record['acc_sie_section_code'])); + $section_id = toHTML(trim($record['acc_sie_section_id'])); + $section_texte = toHTML(trim($record['acc_sie_section_texte'])); + $texte = toHTML(trim($record['acc_sie_texte'])); + $texte_court = toHTML(trim($record['acc_sie_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_unites_fonctionnelle() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as uf_code, + code_original as uf_code_original, + oid as uf_id, + section_code as uf_section_code, + section_id as uf_section_id, + section_texte as uf_section_texte, + texte as uf_texte, + texte_court as uf_texte_court + FROM + rh.t_unite_fonctionnelle + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['uf_code'])); + $code_original = toHTML(trim($record['uf_code_original'])); + $oid = $record['uf_id']; + $section_code = toHTML(trim($record['uf_section_code'])); + $section_id = toHTML(trim($record['uf_section_id'])); + $section_texte = toHTML(trim($record['uf_section_texte'])); + $texte = toHTML(trim($record['uf_texte'])); + $texte_court = toHTML(trim($record['uf_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + +function getRecords_lettre_budgetaire() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as bud_code, + code_original as bud_code_original, + oid as bud_id, + section_code as bud_section_code, + section_id as bud_section_id, + section_texte as bud_section_texte, + texte as bud_texte, + texte_court as bud_texte_court + FROM + rh.t_lettre_budgetaire + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['bud_code'])); + $code_original = toHTML(trim($record['bud_code_original'])); + $oid = $record['bud_id']; + $section_code = toHTML(trim($record['bud_section_code'])); + $section_id = toHTML(trim($record['bud_section_id'])); + $section_texte = toHTML(trim($record['bud_section_texte'])); + $texte = toHTML(trim($record['bud_texte'])); + $texte_court = toHTML(trim($record['bud_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_commission_paritaire() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as com_code, + code_original as com_code_original, + oid as com_id, + section_code as com_section_code, + section_id as com_section_id, + section_texte as com_section_texte, + texte as com_texte, + texte_court as com_texte_court + FROM + rh.t_commission_paritaire + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['com_code'])); + $code_original = toHTML(trim($record['com_code_original'])); + $oid = $record['com_id']; + $section_code = toHTML(trim($record['com_section_code'])); + $section_id = toHTML(trim($record['com_section_id'])); + $section_texte = toHTML(trim($record['com_section_texte'])); + $texte = toHTML(trim($record['com_texte'])); + $texte_court = toHTML(trim($record['com_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + +function getRecords_categorie_conge() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as con_code, + code_original as con_code_original, + oid as con_id, + section_code as con_section_code, + section_id as con_section_id, + section_texte as con_section_texte, + texte as con_texte, + texte_court as con_texte_court + FROM + rh.t_categorie_conge + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['con_code'])); + $code_original = toHTML(trim($record['con_code_original'])); + $oid = $record['con_id']; + $section_code = toHTML(trim($record['con_section_code'])); + $section_id = toHTML(trim($record['con_section_id'])); + $section_texte = toHTML(trim($record['con_section_texte'])); + $texte = toHTML(trim($record['con_texte'])); + $texte_court = toHTML(trim($record['con_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_cadre_emploi() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as cad_emp_code, + code_original as cad_emp_code_original, + oid as cad_emp_id, + section_code as cad_emp_section_code, + section_id as cad_emp_section_id, + section_texte as cad_emp_section_texte, + texte as cad_emp_texte, + texte_court as cad_emp_texte_court + FROM + rh.t_cadre_emploi + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['cad_emp_code'])); + $code_original = toHTML(trim($record['cad_emp_code_original'])); + $oid = $record['cad_emp_id']; + $section_code = toHTML(trim($record['cad_emp_section_code'])); + $section_id = toHTML(trim($record['cad_emp_section_id'])); + $section_texte = toHTML(trim($record['cad_emp_section_texte'])); + $texte = toHTML(trim($record['cad_emp_texte'])); + $texte_court = toHTML(trim($record['cad_emp_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_filiere() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as fil_code, + code_original as fil_code_original, + oid as fil_id, + section_code as fil_section_code, + section_id as fil_section_id, + section_texte as fil_section_texte, + texte as fil_texte, + texte_court as fil_texte_court + FROM + rh.t_filiere + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['fil_code'])); + $code_original = toHTML(trim($record['fil_code_original'])); + $oid = $record['fil_id']; + $section_code = toHTML(trim($record['fil_section_code'])); + $section_id = toHTML(trim($record['fil_section_id'])); + $section_texte = toHTML(trim($record['fil_section_texte'])); + $texte = toHTML(trim($record['fil_texte'])); + $texte_court = toHTML(trim($record['fil_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_categorie_statutaire() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as cat_sta_code, + code_original as cat_sta_code_original, + oid as cat_sta_id, + section_code as cat_sta_section_code, + section_id as cat_sta_section_id, + section_texte as cat_sta_section_texte, + texte as cat_sta_texte, + texte_court as cat_sta_texte_court + FROM + rh.t_categorie_statutaire + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['cat_sta_code'])); + $code_original = toHTML(trim($record['cat_sta_code_original'])); + $oid = $record['cat_sta_id']; + $section_code = toHTML(trim($record['cat_sta_section_code'])); + $section_id = toHTML(trim($record['cat_sta_section_id'])); + $section_texte = toHTML(trim($record['cat_sta_section_texte'])); + $texte = toHTML(trim($record['cat_sta_texte'])); + $texte_court = toHTML(trim($record['cat_sta_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + +function getRecords_compte() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as cpt_code, + code_original as cpt_code_original, + oid as cpt_id, + section_code as cpt_section_code, + section_id as cpt_section_id, + section_texte as cpt_section_texte, + texte as cpt_texte, + texte_court as cpt_texte_court + FROM + rh.t_compte + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['cpt_code'])); + $code_original = toHTML(trim($record['cpt_code_original'])); + $oid = $record['cpt_id']; + $section_code = toHTML(trim($record['cpt_section_code'])); + $section_id = toHTML(trim($record['cpt_section_id'])); + $section_texte = toHTML(trim($record['cpt_section_texte'])); + $texte = toHTML(trim($record['cpt_texte'])); + $texte_court = toHTML(trim($record['cpt_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + + +function getCombo_compte() { + +global $database; + + $httpString = ""; + + + $httpString = $httpString . "\r\n"; + + $httpString = $httpString . "\r\n"; + + $sqlcmd = "SELECT oid, code || ' ' || texte FROM rh.t_compte WHERE oid > 0 ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + + if ($record != FALSE) { + $ok = TRUE; + + $oid = $record[0]; + $texte = toHTML(trim($record[1])); + + $httpString = $httpString . "\r\n"; + + } + } + + + } + + $httpString = $httpString . "\r\n"; + + return $httpString; + + + +} + + +function getRecords_transformation() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + date_debut as tra_date_debut, + date_fin as tra_date_fin, + from_qualification_id as tra_from_qualification_id, + from_service_id as tra_from_service_id, + oid as tra_id), + salarie_id as tra_salarie_id, + texte as tra_texte, + to_qualification_id as tra_to_qualification_id, + to_service_id as tra_to_service_id + FROM + rh.t_transformation + "; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $date_debut = toHTML(trim($record['tra_date_debut'])); + $date_fin = toHTML(trim($record['tra_date_fin'])); + $from_qualification_id = toHTML(trim($record['tra_from_qualification_id'])); + $from_service_id = toHTML(trim($record['tra_from_service_id'])); + $oid = $record['tra_id']; + $salarie_id = toHTML(trim($record['tra_salarie_id'])); + $texte = toHTML(trim($record['tra_texte'])); + $to_qualification_id = toHTML(trim($record['tra_to_qualification_id'])); + $to_service_id = toHTML(trim($record['tra_to_service_id'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + +function getCombo_transformation(){ + + $httpString = ""; + + $httpString_sa = "\r\n"; + $httpString_sa .= "\r\n"; + $sqlcmd = "SELECT oid, nom || ' ' || prenom || ' ('::text || matricule || ')'::text AS texte FROM rh.p_salaries WHERE oid >= 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString_sa .= "\r\n"; + } + } + } + $httpString_sa .= "\r\n"; + + + $httpString_fs = "\r\n"; + $httpString_fs .= "\r\n"; + $httpString_ts = "\r\n"; + $httpString_ts .= "\r\n"; + $sqlcmd = "SELECT oid, texte || ' ('::text || code || ')'::text AS texte FROM rh.t_services WHERE oid >= 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString_fs .= "\r\n"; + $httpString_ts .= "\r\n"; + } + } + } + $httpString_fs .= "\r\n"; + $httpString_ts .= "\r\n"; + + $httpString_fq = "\r\n"; + $httpString_fq .= "\r\n"; + $httpString_tq = "\r\n"; + $httpString_tq .= "\r\n"; + $sqlcmd = "SELECT oid, texte || ' ('::text || code || ')'::text AS texte FROM rh.t_qualifications WHERE oid >= 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString_fq .= "\r\n"; + $httpString_tq .= "\r\n"; + } + } + } + $httpString_fq .= "\r\n"; + $httpString_tq .= "\r\n"; + + $httpString_fd = "\r\n"; + $httpString_fd .= "\r\n"; + $httpString_td = "\r\n"; + $httpString_td .= "\r\n"; + $sqlcmd = "SELECT p_calendrier_annee.date_debut, p_calendrier_annee.date_fin, p_calendrier_annee.texte + FROM rh.p_chiffrier_production + JOIN base.p_calendrier_mois ON (p_chiffrier_production.mois = p_calendrier_mois.mois) + JOIN base.p_calendrier_mois p_calendrier_annee ON (p_calendrier_annee.annee = p_calendrier_mois.annee) + GROUP BY 1,2,3 + ORDER BY 1 DESC"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $date_debut = $record["date_debut"]; + $date_fin = $record["date_fin"]; + $texte = toHTML(trim($record["texte"])); + $httpString_fd .= "\r\n"; + $httpString_td .= "\r\n"; + } + } + } + $httpString_fd .= "\r\n"; + $httpString_td .= "\r\n"; + + + + return $httpString_sa.$httpString_fs.$httpString_ts.$httpString_fq.$httpString_tq.$httpString_fd.$httpString_td; +} + + +function getRecords_expert_controle() { + +global $database; + + $httpString = ""; + $httpString_tmp = ""; + + // Activation module EXPERT + $sqlcmd = " + INSERT INTO rh.t_divers (code, texte, valeur, description) + SELECT + 'EXPERT_ACTIVE', + 'Module EXPERT activ�', + '0', + '1=Activ�' + WHERE 'EXPERT_ACTIVE' NOT IN (SELECT code FROM rh.t_divers); + INSERT INTO rh.t_divers (code, texte, valeur, description, valeur_date) + SELECT + 'EXPERT_DATE_DEBUT', + 'Date données à contrôler', + '20130101', + 'Date de début des données à contrôler', + '20130101' + WHERE 'EXPERT_DATE_DEBUT' NOT IN (SELECT code FROM rh.t_divers);"; + $result = $database->exec($sqlcmd); + + // Correction données antérieures + $sqlcmd = "UPDATE rh.t_expert_controle_rule + SET numero = 1 + WHERE numero NOT IN (1,2,3) OR numero IS NULL; + + UPDATE rh.t_expert_controle + SET gravite_id = 5 + WHERE gravite_id NOT IN (0,5,9) OR gravite_id IS NULL;"; + + $result = $database->exec($sqlcmd); + + // Paramétres généraux + $EXPERT_ACTIVE = "0"; + $EXPERT_DATE_DEBUT = "2013-01-01"; + + $sqlcmd = "SELECT code, valeur, to_char(valeur_date,'DD/MM/YYYY') + FROM rh.t_divers + WHERE code LIKE 'EXPERT%'"; + $result = $database->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + if ($record != FALSE) { + $ok = TRUE; + + switch(trim($record[0])) { + case "EXPERT_ACTIVE" : + $EXPERT_ACTIVE = trim($record[1]); + break; + case "EXPERT_DATE_DEBUT" : + $EXPERT_DATE_DEBUT = trim($record[2]); + break; + } + } + } + } + + // Chargement des Prestataires RH + $sqlcmd = " + (SELECT + -1 as oid, + 'Tous'::text as texte, + 0 as tri + UNION + SELECT + oid, + texte, + 1 as tri + FROM base.t_prestataires + WHERE 'rh' = ANY (modules) + ) + ORDER BY tri,texte"; + $result = $database->exec($sqlcmd); + + if ($result !== false) { + + while ($row = pg_fetch_array($result)) { + + $oid = $row['oid']; + $texte = $row['texte']; + + $httpString .= "" . PHP_EOL; + } + } + + $httpString_tmp .= ""; + + // Liste des controles + $sqlcmd = "SELECT + t_expert_controle.oid as controle_id, + t_expert_controle.code as controle_code, + t_expert_controle.texte as controle_texte, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte) as controle_texte_court, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte,t_expert_controle.texte_abrege) as controle_texte_abrege, + t_expert_controle.description as controle_description, + t_expert_controle.is_cti as controle_is_cti, + t_expert_controle.is_hide as controle_is_hide, + t_expert_controle.gravite_id as controle_gravite, + t_expert_controle.prestataire_id, + t_expert_controle.is_active as controle_is_active, + COALESCE(t_prestataires.texte, 'Tous') as prestataire_texte, + COALESCE(t_expert_controle_rule_1.oid,0) as rule1_oid, + COALESCE(t_expert_controle_rule_1.sqlcmd_where) as rule1_sqlcmd_where, + COALESCE(t_expert_controle_rule_1.sqlcmd_justificatif) as rule1_sqlcmd_justificatif, + COALESCE(TO_CHAR(t_expert_controle_rule_1.last_execution_date,'DD/MM/YYYY'),'') as rule1_last_execution_date, + COALESCE(t_expert_controle_rule_1.last_execution_ok) as rule1_last_execution_ok, + COALESCE(t_expert_controle_rule_1.table_id,0) as rule1_table_id, + COALESCE(subview.nbref, 0) as nb_ref, + COALESCE(t_expert_controle.alert_exp,'0') as is_alert + FROM rh.t_expert_controle + LEFT JOIN base.t_prestataires ON t_prestataires.oid = t_expert_controle.prestataire_id + LEFT JOIN rh.t_expert_controle_rule t_expert_controle_rule_1 ON t_expert_controle_rule_1.controle_id = t_expert_controle.oid AND t_expert_controle_rule_1.numero = 1 + LEFT JOIN (SELECT controle_id, count(*) AS nbref FROM rh.p_expert_controle GROUP BY 1) subview ON t_expert_controle.oid = subview.controle_id + WHERE t_expert_controle.oid > 0 AND is_global <> 1 + ORDER BY t_expert_controle.code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordAssoc(); + + if ($record != FALSE) { + $ok = TRUE; + + $oid = $record['controle_id']; + $code = toHTML(trim($record['controle_code'])); + $texte = toHTML(trim($record['controle_texte'])); + $texte_court = toHTML(trim($record['controle_texte_court'])); + $texte_abrege = toHTML(trim($record['controle_texte_abrege'])); + $description = toHTML(trim($record['controle_description'])); + $is_cti = toHTML(trim($record['controle_is_cti'])); + $is_active = toHTML(trim($record['controle_is_active'])); + $is_hide = toHTML(trim($record['controle_is_hide'])); + $gravite = floatval(trim($record['controle_gravite'])); + $rule_oid1 = floatval(trim($record['rule1_oid'])); + $sqlcmd_where1 = toHTML(trim($record['rule1_sqlcmd_where'])); + $sqlcmd_justificatif1 = toHTML(trim($record['rule1_sqlcmd_justificatif'])); + $table1 = floatval(trim($record['rule1_table_id'])); + $nbref = floatval(trim($record['nb_ref'])); + $last_execution_date = trim($record['rule1_last_execution_date']); + $last_execution_ok = floatval(trim($record['rule1_last_execution_ok'])); + $prestataire_id = floatval(trim($record['prestataire_id'])); + $prestataire_texte = toHTML(trim($record['prestataire_texte'])); + $is_alert = toHTML(trim($record['is_alert'])); + + if ($last_execution_date == "") { + $last_execution_date = "jamais exécuté"; + $last_execution_ok = ""; + } + else { + if ($last_execution_ok == "1") { + $last_execution_ok = "OK"; + } + if ($last_execution_ok == "0") { + $last_execution_ok = "KO"; + } + } + + $complement = ""; + if ($is_cti == "1") { + $complement = "$complement CTI"; + } + else { + $is_cti = "0"; + } + if ($is_hide == "1") { + $complement = "$complement Masqu�"; + } + else { + $is_hide = "0"; + } + if ($is_alert == "1") { + $complement = "$complement Alerte"; + } + else { + $is_alert = "0"; + } + if ($gravite == 0) { + $gravite_texte = "INFO"; + } + else { + if ($gravite == 9) { + $gravite_texte = "ERREUR"; + } + else { + $gravite_texte = "ATT"; + } + } + $is_active_texte = $is_active == "1" ? "Actif" : "Inactif"; + + $md5_def = refmd5("$code$texte$texte_court$texte_abrege$description$is_cti$prestataire_id"); + $md5_sql = refmd5("$code$sqlcmd_where1$sqlcmd_justificatif1$table1"); + + $httpString_tmp .= " + "; + + if (strlen($httpString_tmp) > 64000) { + $httpString .= $httpString_tmp; + $httpString_tmp = ""; + } + } + } + } + + $httpString .= $httpString_tmp; + + // R�f�rence + $httpString .= getRefSettings("t_expert_controle", $httpString); + + return $httpString; +} + +function getRecords_expert_controle_refsettings($refPrefix) { + +global $database; + + $httpString = ""; + $httpString_tmp = ""; + + // Liste des controles + $sqlcmd = "SELECT + t_expert_controle.oid AS controle_id, + t_expert_controle.code AS controle_code, + t_expert_controle.texte AS controle_texte, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte) AS controle_texte_court, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte,t_expert_controle.texte_abrege) AS controle_texte_abrege, + t_expert_controle.description AS controle_description, + t_expert_controle.is_cti AS controle_is_cti, + t_expert_controle.is_hide AS controle_is_hide, + t_expert_controle.gravite_id AS controle_gravite, + t_expert_controle.prestataire_id, + COALESCE(t_prestataires.texte, 'Tous') as prestataire_texte, + COALESCE(t_expert_controle_rule_1.oid,0) AS rule1_oid, + COALESCE(t_expert_controle_rule_1.sqlcmd_where) AS rule1_sqlcmd_where, + COALESCE(t_expert_controle_rule_1.sqlcmd_justificatif) AS rule1_sqlcmd_justificatif, + COALESCE(TO_CHAR(t_expert_controle_rule_1.last_execution_date,'DD/MM/YYYY'),'') AS rule1_last_execution_date, + COALESCE(t_expert_controle_rule_1.last_execution_ok) AS rule1_last_execution_ok, + COALESCE(t_expert_controle_rule_1.table_id,0) AS rule1_table_id, + t_expert_controle.alert_exp as is_alert + FROM rh.t_expert_controle + LEFT JOIN base.t_prestataires ON t_prestataires.oid = t_expert_controle.prestataire_id + LEFT JOIN rh.t_expert_controle_rule t_expert_controle_rule_1 ON t_expert_controle_rule_1.controle_id = t_expert_controle.oid AND t_expert_controle_rule_1.numero = 1 + WHERE t_expert_controle.oid > 0 AND is_global <> 1 AND t_expert_controle.code ILIKE '$refPrefix%' + ORDER BY t_expert_controle.code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + if ($record != FALSE) { + $ok = TRUE; + + $oid = $record['controle_id']; + $code = toHTML(trim($record['controle_code'])); + $texte = toHTML(trim($record['controle_texte'])); + $texte_court = toHTML(trim($record['controle_texte_court'])); + $texte_abrege = toHTML(trim($record['controle_texte_abrege'])); + $description = toHTML(trim($record['controle_description'])); + $is_cti = toHTML(trim($record['controle_is_cti'])); + $is_hide = toHTML(trim($record['controle_is_hide'])); + $gravite = floatval(trim($record['controle_gravite'])); + $rule_oid1 = floatval(trim($record['rule1_oid'])); + $sqlcmd_where1 = toHTML(trim($record['rule1_sqlcmd_where'])); + $sqlcmd_justificatif1 = toHTML(trim($record['rule1_sqlcmd_justificatif'])); + $last_execution_date = toHTML(trim($record['rule1_last_execution_date'])); + $last_execution_ok = toHTML(trim($record['rule1_last_execution_ok'])); + $table1 = floatval(trim($record['rule1_table_id'])); + $prestataire_id = floatval(trim($record['prestataire_id'])); + $prestataire_texte = toHTML(trim($record['prestataire_texte'])); + $is_alert = toHTML(trim($record['is_alert'])); + + if ($last_execution_date == "") { + $last_execution_ok = ""; + } + else { + if ($last_execution_ok == "1") { + $last_execution_ok = "OK"; + } + if ($last_execution_ok == "0") { + $last_execution_ok = "KO"; + } + } + + $complement = ""; + if ($is_cti == "1") { + $complement = "$complement CTI"; + } + else { + $is_cti = "0"; + } + if ($is_hide == "1") { + $complement = "$complement Masqu�"; + } + else { + $is_hide = "0"; + } + if ($gravite == 0) { + $gravite_texte = "INFO"; + } + else { + if ($gravite == 9) { + $gravite_texte = "ERREUR"; + } + else { + $gravite_texte = "ATT"; + } + } + $complement = trim($complement); + + $md5_def = refmd5("$code$texte$texte_court$texte_abrege$description$is_cti$prestataire_id"); + $md5_sql = refmd5("$code$sqlcmd_where1$sqlcmd_justificatif1$table1"); + + $httpString_tmp .= " + "; + + if (strlen($httpString_tmp) > 64000) { + $httpString .= $httpString_tmp; + $httpString_tmp = ""; + } + } + } + } + + $httpString .= $httpString_tmp; + return $httpString; +} + +// recherche des listes de r�ference +function getRefSettings($tableName, $httpString_base) { + + global $getOption; + + $httpString = ""; + + $SETTINGS_file = rootDir() . "settings/settings.XML"; + $SETTINGS_xml = simplexml_load_file($SETTINGS_file); + $REFSETTINGS_URL = getProperty($SETTINGS_xml, "REFSETTINGS", 'URL'); + $REFSETTINGS_PREFIX = getProperty($SETTINGS_xml, "REFSETTINGS", 'PREFIX'); + + if ($REFSETTINGS_URL != "" && extension_loaded('curl')) { + + // Recherche des indicateurs de l'environnement de r�f�rence + $REFSETTINGS_table_url = "$REFSETTINGS_URL/modules/rh/php/RH_getTableRecords.php"; + + // Recherche http pour indicateurs + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $REFSETTINGS_table_url); + curl_setopt($ch, CURLOPT_POST, 2); + curl_setopt($ch, CURLOPT_POSTFIELDS, "tableName=$tableName&getOption=getRefSettings&refPrefix=$REFSETTINGS_PREFIX"); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + $REFSETTINGS_data = @curl_exec($ch); + curl_close($ch); + + if ($REFSETTINGS_data) { + + if (substr($REFSETTINGS_data, 0, 12) == "") { + $REFSETTINGS_data = substr($REFSETTINGS_data, 12, strlen($REFSETTINGS_data) - 25); + } + + $REFSETTINGS_data = uncompress($REFSETTINGS_data); + $REFSETTINGS_data = str_replace("","",$REFSETTINGS_data); + $REFSETTINGS_xml = simplexml_load_string($REFSETTINGS_data); + if ($REFSETTINGS_xml) { + + foreach ($REFSETTINGS_xml->REFRECORD as $recordNode) { + $md5_def = trim($recordNode["md5_def"]); + $md5_sql = trim($recordNode["md5_sql"]); + $recordNode["ok"] = ""; + if (stripos($httpString_base, $md5_def) === false) { + $recordNode["ok"] = "D�finition"; + } + if (stripos($httpString_base, $md5_sql) === false) { + $recordNode["ok"] = "R�gles"; + } + //if ($recordNode["ok"] != "") { + $httpString .= $recordNode->asXML(); + //} + } + } + } + } + return $httpString; +} + + + + +function getRecords_planning_service() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as pla_code, + code_original as pla_code_original, + oid as pla_id, + section_code as pla_section_code, + section_id as pla_section_id, + section_texte as pla_section_texte, + service_code as pla_service_code, + service_id as pla_service_id, + service_section_code as pla_service_section_code, + service_section_id as pla_service_section_id, + service_section_texte pla_service_section_texte, + service_texte as pla_service_texte, + texte as pla_texte, + texte_court as pla_texte_court + FROM + rh.t_planning_service + "; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['pla_code'])); + $code_original = toHTML(trim($record['pla_code_original'])); + $oid = $record['tra_id']; + $section_code = toHTML(trim($record['pla_section_code'])); + $section_id = toHTML(trim($record['pla_section_id'])); + $section_texte = toHTML(trim($record['pla_section_texte'])); + $service_code = toHTML(trim($record['pla_service_code'])); + $service_id = toHTML(trim($record['pla_service_id'])); + $service_section_code = toHTML(trim($record['pla_service_section_code'])); + $service_section_id = toHTML(trim($record['pla_service_section_id'])); + $service_section_texte = toHTML(trim($record['pla_service_section_texte'])); + $service_texte = toHTML(trim($record['pla_service_texte'])); + $texte = toHTML(trim($record['pla_texte'])); + $texte_court = toHTML(trim($record['pla_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + +function getCombos_planning_service() { + + $httpString = "\r\n"; + $httpString .= "\r\n"; + $sqlcmd = "SELECT oid, code || ' '::text || texte AS texte FROM rh.t_services WHERE oid > 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString .= "\r\n"; + } + } + } + $httpString .= "\r\n"; + + return $httpString; +} + + +function getRecords_planning_qualification() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as pla_qua_code, + code_original as pla_qua_code_original, + oid as pla_qua_id, + qualification_code as pla_qua_qualification_code, + qualification_id as pla_qua_qualification_id, + qualification_section_code as pla_qua_qualification_section_code, + qualification_section_id as pla_qua_qualification_section_id, + qualification_section_texte as pla_qua_qualification_section_texte, + qualification_texte as pla_qua_qualification_texte, + section_code as pla_qua_section_code, + section_id as pla_qua_section_id, + section_texte as pla_qua_section_texte, + texte as pla_qua_texte, + texte_court as pla_qua_texte_court + FROM + rh.t_planning_qualification + "; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['pla_qua_code'])); + $code_original = toHTML(trim($record['pla_qua_code_original'])); + $oid = $record['pla_qua_id']; + $qualification_code = toHTML(trim($record['pla_qua_qualification_code'])); + $qualification_id = toHTML(trim($record['pla_qua_qualification_id'])); + $qualification_section_code = toHTML(trim($record['pla_qua_qualification_section_code'])); + $qualification_section_id = toHTML(trim($record['pla_qua_qualification_section_id'])); + $qualification_section_texte = toHTML(trim($record['pla_qua_qualification_section_texte'])); + $qualification_texte = toHTML(trim($record['pla_qua_qualification_texte'])); + $section_code = toHTML(trim($record['pla_qua_section_code'])); + $section_id = toHTML(trim($record['pla_qua_section_id'])); + $section_texte = toHTML(trim($record['pla_qua_section_texte'])); + $texte = toHTML(trim($record['pla_qua_texte'])); + $texte_court = toHTML(trim($record['pla_qua_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + +function getCombos_planning_qualification() { + + $httpString = "\r\n"; + $httpString .= "\r\n"; + $sqlcmd = "SELECT oid, code || ' '::text || texte AS texte FROM rh.t_qualifications WHERE oid > 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString .= "\r\n"; + } + } + } + $httpString .= "\r\n"; + + return $httpString; +} + + + +function getRecords_planning_type_absence() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as pla_abs__code, + code_original as pla_abs_code_original, + oid as pla_abs_id, + section_code as pla_abs_section_code, + section_id as pla_abs_section_id, + section_texte as pla_abs_section_texte, + texte as pla_abs_texte, + texte_court as pla_abs_texte_court + FROM + rh.t_planning_type_absence + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['pla_abs_code'])); + $code_original = toHTML(trim($record['pla_abs_code_original'])); + $oid = $record['pla_abs_id']; + $section_code = toHTML(trim($record['pla_abs_section_code'])); + $section_id = toHTML(trim($record['pla_abs_section_id'])); + $section_texte = toHTML(trim($record['pla_abs_section_texte'])); + $texte = toHTML(trim($record['pla_abs_texte'])); + $texte_court = toHTML(trim($record['pla_abs_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + + +function getRecords_data_profile() { + +global $database; + + $httpString_tmp = ""; + + $sqlcmd = " + SELECT + code as pro_code, + etablissement_exclus as pro_etablissement_exclus, + etablissement_id_as pro_etablissement_id, + etablissement_inclus as pro_etablissement_inclus, + oid as pro_id, + service_exclus as pro_service_exclus, + service_id_as pro_service_id, + service_inclus as pro_service_inclus, + statut_exclus as pro_statut_exclus, + statut_id_as pro_statut_id, + statut_inclus as pro_statut_inclus, + texte as pro_texte, + texte_court as pro_texte_court + FROM + rh.t_data_profile + ORDER BY code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecord(); + + if ($record != FALSE) { + $ok = TRUE; + + + $code = toHTML(trim($record['pro_code'])); + $etablissement_exclus = toHTML(trim($record['pro_etablissement_exclus'])); + $etablissement_id = toHTML(trim($record['pro_etablissement_id'])); + $etablissement_inclus = toHTML(trim($record['pro_etablissement_inclus'])); + $oid = $record['pro_id']; + $service_exclus = toHTML(trim($record['pro_service_exclus'])); + $service_id = toHTML(trim($record['pro_service_id'])); + $service_inclus = toHTML(trim($record['pro_service_inclus'])); + $statut_exclus = toHTML(trim($record['pro_statut_exclus'])); + $statut_id = toHTML(trim($record['pro_statut_id'])); + $statut_inclus = toHTML(trim($record['pro_statut_inclus'])); + $texte = toHTML(trim($record['pro_texte'])); + $texte_court = toHTML(trim($record['pro_texte_court'])); + $nbref = $record['nb_ref'] + 0; + + $httpString .= "\r\n"; + } + } + } + return $httpString; +} + +function refmd5($string) { + $string = str_replace("\r","",$string); + $string = str_replace("\n","",$string); + $string = md5(trim($string)); + return $string; +} + +?> \ No newline at end of file diff --git a/php/RH_setTableRecord.php b/php/RH_setTableRecord.php new file mode 100644 index 0000000..7dd018e --- /dev/null +++ b/php/RH_setTableRecord.php @@ -0,0 +1,3787 @@ +" . utf8_decode($recordXML)); + +$database = new Database("iCTI"); + +$settingsLogger = new SettingsChangesLogger; + +try { + $settingsLogger->logParameterChanges('rh', $tableName, $recordNode, $database); +} catch (Exception $e) { + echo $e->getMessage(); +} + +$httpString = ""; +$httpString = $httpString . ""; +$httpString = $httpString . "\n"; + + +if ($tableName == "t_divers") { + $httpString = $httpString . setRecords_divers(); +} +if ($tableName == "t_categorie_socio_professionnelle") { + $httpString = $httpString . setRecords_categorie_socio_professionnelle(); +} +if ($tableName == "t_codes_emploi") { + $httpString = $httpString . setRecords_codes_emploi(); +} +if ($tableName == "t_entreprises") { + $httpString = $httpString . setRecords_entreprises(); +} +if ($tableName == "t_etablissements") { + $httpString = $httpString . setRecords_etablissements(); +} +if ($tableName == "t_grilles") { + $httpString = $httpString . setRecords_grilles(); +} +if ($tableName == "t_grilles_groupes") { + $httpString = $httpString . setRecords_grilles_groupes(); +} +if ($tableName == "t_groupes_cotisant") { + $httpString = $httpString . setRecords_groupes_cotisant(); +} +if ($tableName == "t_service_motifs_arret") { + $httpString = $httpString . setRecords_motifs_arret(); +} +if ($tableName == "t_motifs_debut_contrat") { + $httpString = $httpString . setRecords_motifs_debut_contrat(); +} +if ($tableName == "t_motifs_fin_contrat") { + $httpString = $httpString . setRecords_motifs_fin_contrat(); +} +if ($tableName == "t_rubriques_nationalites") { + $httpString = $httpString . setRecords_nationalites(); +} +if ($tableName == "t_organismes_cotisation") { + $httpString = $httpString . setRecords_organismes_cotisation(); +} +if ($tableName == "t_precisions_motif_arret") { + $httpString = $httpString . setRecords_precisions_motif_arret(); +} +if ($tableName == "t_qualifications") { + $httpString = $httpString . setRecords_qualifications(); +} +if ($tableName == "t_rubriques") { + $httpString = $httpString . setRecords_rubriques(); +} +if ($tableName == "t_sections_analytiques") { + $httpString = $httpString . setRecords_sections_analytiques(); +} +if ($tableName == "t_sections_analytiques_paie") { + $httpString = $httpString . setRecords_sections_analytiques_paie(); +} + + +if ($tableName == "t_situations_famille") { + $httpString = $httpString . setRecords_situations_famille(); +} +if ($tableName == "t_societes_interim") { + $httpString = $httpString . setRecords_societes_interim(); +} +if ($tableName == "t_specialites") { + $httpString = $httpString . setRecords_specialites(); +} +if ($tableName == "t_statuts") { + $httpString = $httpString . setRecords_statuts(); +} + +if ($tableName == "t_types_contrat") { + $httpString = $httpString . setRecords_types_contrat(); +} + +if ($tableName == "t_types_horaire") { + $httpString = $httpString . setRecords_types_horaire(); +} + +if ($tableName == "t_types_temps_travail") { + $httpString = $httpString . setRecords_types_temps_travail(); +} + + +if ($tableName == "t_motifs_visite") { + $httpString = $httpString . setRecords_motifs_visite(); +} + +if ($tableName == "t_accident_circonstance") { + $httpString = $httpString . setRecords_accident_circonstance(); +} +if ($tableName == "t_accident_lieu") { + $httpString = $httpString . setRecords_accident_lieu(); +} + +if ($tableName == "t_accident_nature") { + $httpString = $httpString . setRecords_accident_nature(); +} + +if ($tableName == "t_accident_siege") { + $httpString = $httpString . setRecords_accident_siege(); +} + +if ($tableName == "t_unite_fonctionnelle") { + $httpString = $httpString . setRecords_unite_fonctionnelle(); +} + +if ($tableName == "t_lettre_budgetaire") { + $httpString = $httpString . setRecords_lettre_budgetaire(); +} + +if ($tableName == "t_commission_paritaire") { + $httpString = $httpString . setRecords_commission_paritaire(); +} + +if ($tableName == "t_categorie_conge") { + $httpString = $httpString . setRecords_categorie_conge(); +} + +if ($tableName == "t_cadre_emploi") { + $httpString = $httpString . setRecords_cadre_emploi(); +} + +if ($tableName == "t_filiere") { + $httpString = $httpString . setRecords_filiere(); +} + +if ($tableName == "t_categorie_statutaire") { + $httpString = $httpString . setRecords_categorie_statutaire(); +} + +if ($tableName == "t_compte") { + $httpString = $httpString . setRecords_compte(); +} + +if ($tableName == "t_transformation") { + $httpString = $httpString . setRecords_transformation(); +} + +if ($tableName == "t_expert_controle") { + $httpString = $httpString . setRecords_expert_controle(); +} + +if ($tableName == "t_planning_service") { + $httpString = $httpString . setRecords_planning_service(); +} + +if ($tableName == "t_planning_qualification") { + $httpString = $httpString . setRecords_planning_qualification(); +} + +if ($tableName == "t_planning_type_absence") { + $httpString = $httpString . setRecords_planning_type_absence(); +} + +if ($tableName == "t_data_profile") { + $httpString = $httpString . setRecords_data_profile(); +} + + + +// Effacer le cache après maj parametre +erase_cache(); + +$httpString = $httpString . "\n"; + +$httpString = compress64($httpString); + + +echo "$httpString"; + +function setRecords_divers() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $texte = utf8_decode($recordNode["texte"]); + $valeur = utf8_decode($recordNode["valeur"]); + $description = utf8_decode($recordNode["description"]); + $valeur_date = utf8_decode($recordNode["valeur_date"]); + $show_info_module = floatval($recordNode["show_info_module"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $texte = toSQL($texte); + $valeur = toSQL($valeur); + $description = toSQL($description); + $show_info_module = floatval($show_info_module); + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_divers SET "; + $sqlcmd = $sqlcmd . "valeur = '$valeur', "; + $sqlcmd = $sqlcmd . "valeur_date = '$valeur_date', "; + $sqlcmd = $sqlcmd . "show_info_module = ($show_info_module = 1) "; + $sqlcmd = $sqlcmd . "WHERE code = '$code'"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + +} + + + + +function setRecords_categorie_socio_professionnelle() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_categorie_socio_professionnelle SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_codes_emploi() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_codes_emploi SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + + +function setRecords_entreprises() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $oid = floatval($recordNode["oid"]); + $planning_code = utf8_decode($recordNode["planning_code"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $planning_code = toSQL($planning_code); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_entreprises SET + code = '$code', + code_original = '$code_original' + planning_code = '$planning_code' + section_code = '$section_code' + section_id = '$section_id' + section_texte = '$section_texte' + texte = '$texte', + texte_court = '$texte_court' + + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } +} + + +function setRecords_etablissements() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + $base_calcul_etp = floatval ($recordNode["base_calcul_etp"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $entreprise_id = floatval($recordNode["entreprise_id"]); + $mode_calcul_etp_paye = utf8_decode($recordNode["mode_calcul_etp_paye"]); + $oid = floatval($recordNode["oid"]); + $planning_code = utf8_decode($recordNode["planning_code"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + + if ($action != "delete" && $action != "copy") { + $base_calcul_etp = toSQL($base_calcul_etp); + $code = toSQL($code); + $code_original = toSQL($code_original); + $entreprise_id = toSQL($entreprise_id); + $mode_calcul_etp_paye = toSQL($mode_calcul_etp_paye); + $planning_code = toSQL($planning_code); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_etablissements SET + base_calcul_etp = '$base_calcul_etp', + code = '$code', + code_original = '$code_original' + entreprise_id = '$entreprise_id' + mode_calcul_etp_paye = '$mode_calcul_etp_paye' + planning_code = '$planning_code' + section_code = '$section_code' + section_id = '$section_id' + section_texte = '$section_texte' + texte = '$texte', + texte_court = '$texte_court' + + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + +} + + +function setRecords_grilles() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_grilles SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} +function setRecords_grilles_groupes() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_grilles_groupes SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_groupes_cotisant() { + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_groupes_cotisant SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_motifs_arret(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $rang_edition = utf8_decode($recordNode["rang_edition"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $rang_edition = toSQL($rang_edition); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_motifs_arret SET + code = '$code', + code_original = '$code_original', + rang_edition = '$rang_edition', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_motifs_debut_contrat(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_motifs_debut_contrat SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_motifs_fin_contrat(){ + +global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_motifs_fin_contrat SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_nationalites(){ + +global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_nationalites SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + + +function setRecords_organismes_cotisation(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_organismes_cotisation SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_precisions_motif_arret(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $rang_edition = utf8_decode($recordNode["rang_edition"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $rang_edition = toSQL($rang_edition); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_motifs_debut_contrat SET + code = '$code', + code_original = '$code_original', + rang_edition = '$rang_edition', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_qualifications(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_motifs_debut_contrat SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_rubriques(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $c_avantage_nature = utf8_decode($recordNode["c_avantage_nature"]); + $c_base = floatval($recordNode["c_base"]); + $c_brut = floatval($recordNode["c_brut"]); + $c_cotisation_patronale = floatval($recordNode["c_cotisation_patronale"]); + $c_cotisation_salarie = floatval($recordNode["c_cotisation_salarie"]); + $c_frais_imposables = floatval($recordNode["c_frais_imposables"]); + $c_heures_payees = floatval($recordNode["c_heures_payees"]); + $c_heures_travaillees = floatval($recordNode["c_heures_travaillees"]); + $c_masse_salariale = floatval($recordNode["c_masse_salariale"]); + $c_net_a_payer = floatval($recordNode["c_net_a_payer"]); + $c_net_imposable = floatval($recordNode["c_net_imposable"]); + $c_nombre = floatval($recordNode["c_nombre"]); + $c_od_net_patronale = floatval($recordNode["c_od_net_patronale"]); + $c_od_net_salarie = floatval($recordNode["c_od_net_salarie"]); + $chapitre_bulletin = utf8_decode($recordNode["chapitre_bulletin"]); + $code_calcul = utf8_decode($recordNode["code_calcul"]); + $code_original = utf8_decode($recordNode["code_original"]); + $coefficient = floatval($recordNode["coefficient"]); + $coefficient_base = floatval($recordNode["coefficient_base"]); + $coefficient_nombre = floatval($recordNode["coefficient_nombre"]); + $coefficient_txp = utf8_decode($recordNode["coefficient_txp"]); + $coefficient_txs = utf8_decode($recordNode["coefficient_txs"]); + $heures_payees = utf8_decode($recordNode["heures_payees"]); + $p_avantage_nature = utf8_decode($recordNode["p_avantage_nature"]); + $p_base = utf8_decode($recordNode["p_base"]); + $p_brut = utf8_decode($recordNode["p_brut"]); + $p_cotisation_patronale = utf8_decode($recordNode["p_cotisation_patronale"]); + $p_cotisation_salarie = utf8_decode($recordNode["p_cotisation_salarie"]); + $p_cumul = utf8_decode($recordNode["p_cumul"]); + $p_detail = utf8_decode($recordNode["p_detail"]); + $p_frais_imposables = utf8_decode($recordNode["p_frais_imposables"]); + $p_heures_payees = utf8_decode($recordNode["p_heures_payees"]); + $p_heures_travaillees = utf8_decode($recordNode["p_heures_travaillees"]); + $p_masse_salariale = utf8_decode($recordNode["p_masse_salariale"]); + $p_net_a_payer = utf8_decode($recordNode["p_net_a_payer"]); + $p_net_imposable = utf8_decode($recordNode["p_net_imposable"]); + $p_nombre = utf8_decode($recordNode["p_nombre"]); + $p_od_net_patronale = utf8_decode($recordNode["p_od_net_patronale"]); + $p_od_net_salarie = utf8_decode($recordNode["p_od_net_salarie"]); + $rang_edition = floatval($recordNode["rang_edition"]); + $s_avantage_nature = floatval($recordNode["s_avantage_nature"]); + $s_base = floatval($recordNode["s_base"]); + $s_brut = floatval($recordNode["s_brut"]); + $s_cotisation_patronale = floatval($recordNode["s_cotisation_patronale"]); + $s_cotisation_salarie = floatval($recordNode["s_cotisation_salarie"]); + $s_frais_imposables = floatval($recordNode["s_frais_imposables"]); + $s_heures_payees = floatval($recordNode["s_heures_payees"]); + $s_heures_travaillees = floatval($recordNode["s_heures_travaillees"]); + $s_masse_salariale = floatval($recordNode["s_masse_salariale"]); + $s_net_a_payer = utf8_decode($recordNode["s_net_a_payer"]); + $s_net_imposable = utf8_decode($recordNode["s_net_imposable"]); + $s_nombre = floatval($recordNode["s_nombre"]); + $s_od_net_patronale = floatval($recordNode["s_od_net_patronale"]); + $s_od_net_salarie = floatval($recordNode["s_od_net_salarie"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + $unite = utf8_decode($recordNode["unite"]); + $user_modified = utf8_decode($recordNode["user_modified"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $c_avantage_nature = toSQL($c_avantage_nature); + $c_base = toSQL($c_base); + $c_brut = toSQL($c_brut); + $c_cotisation_patronale = toSQL($c_cotisation_patronale); + $c_cotisation_salarie = toSQL($c_cotisation_salarie); + $c_frais_imposables = toSQL($c_frais_imposables); + $c_heures_payees = toSQL($c_heures_payees); + $c_heures_travaillees = toSQL($c_heures_travaillees); + $c_masse_salariale = toSQL($c_masse_salariale); + $c_net_a_payer = toSQL($c_net_a_payer); + $c_net_imposable = toSQL($c_net_imposable); + $c_nombre = toSQL($c_nombre); + $c_od_net_patronale = toSQL($c_od_net_patronale); + $c_od_net_salarie = toSQL($c_od_net_salarie); + $chapitre_bulletin = toSQL($chapitre_bulletin); + $code_calcul = toSQL($code_calcul); + $code_original = toSQL($code_original); + $coefficient = toSQL($coefficient); + $coefficient_base = toSQL($coefficient_base); + $coefficient_nombre = toSQL($coefficient_nombre); + $coefficient_txp = toSQL($coefficient_txp); + $coefficient_txs = toSQL($coefficient_txs); + $heures_payees = toSQL($heures_payees); + $p_avantage_nature = toSQL($p_avantage_nature); + $p_base = toSQL($p_base); + $p_brut = toSQL($p_brut); + $p_cotisation_patronale = toSQL($p_cotisation_patronale); + $p_cotisation_salarie = toSQL($p_cotisation_salarie); + $p_cumul = toSQL($p_cumul); + $p_detail = toSQL($p_detail); + $p_frais_imposables = toSQL($p_frais_imposables); + $p_heures_payees = toSQL($p_heures_payees); + $p_heures_travaillees = toSQL($p_heures_travaillees); + $p_masse_salariale = toSQL($p_masse_salariale); + $p_net_a_payer = toSQL($p_net_a_payer); + $p_net_imposable = toSQL($p_net_imposable); + $p_nombre = toSQL($p_nombre); + $p_od_net_patronale = toSQL($p_od_net_patronale); + $p_od_net_salarie = toSQL($p_od_net_salarie); + $rang_edition = toSQL($rang_edition); + $s_avantage_nature = toSQL($s_avantage_nature); + $s_base = toSQL($s_base); + $s_brut = toSQL($s_brut); + $s_cotisation_patronale = toSQL($s_cotisation_patronale); + $s_cotisation_salarie = toSQL($s_cotisation_salarie); + $s_frais_imposables = toSQL($s_frais_imposables); + $s_heures_payees = toSQL($s_heures_payees); + $s_heures_travaillees = toSQL($s_heures_travaillees); + $s_masse_salariale = toSQL($s_masse_salariale); + $s_net_a_payer = toSQL($s_net_a_payer); + $s_net_imposable = toSQL($s_net_imposable); + $s_nombre = toSQL($s_nombre); + $s_od_net_patronale = toSQL($s_od_net_patronale); + $s_od_net_salarie = toSQL($s_od_net_salarie); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + $unite = toSQL($unite); + $user_modified = toSQL($user_modified); + + + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_rubriques SET + + code = '$code', + c_avantage_nature = '$c_avantage_nature', + c_base = '$c_base', + c_brut = '$c_brut', + c_cotisation_patronale = '$c_cotisation_patronale', + c_cotisation_salarie = '$c_cotisation_salarie', + c_frais_imposables = '$c_frais_imposables', + c_heures_payees = '$c_heures_payees', + c_heures_travaillees = '$c_heures_travaillees', + c_masse_salariale = '$c_masse_salariale', + c_net_a_payer = '$c_net_a_payer', + c_net_imposable = '$c_net_imposable', + c_nombre = '$c_nombre', + c_od_net_patronale = '$c_od_net_patronale', + c_od_net_salarie = '$c_od_net_salarie', + chapitre_bulletin = '$chapitre_bulletin', + code_calcul = '$code_calcul', + code_original = '$code_original', + coefficient = '$coefficient', + coefficient_base = '$coefficient_base', + coefficient_nombre = '$coefficient_nombre', + coefficient_txp = '$coefficient_txp', + coefficient_txs = '$coefficient_txs', + heures_payees ='$heures_payees', + p_avantage_nature = '$p_avantage_nature' , + p_base = '$p_base', + p_brut = '$p_brut', + p_cotisation_patronale = '$p_cotisation_patronale', + p_cotisation_salarie = '$p_cotisation_salarie', + p_cumul = '$p_cumul', + p_detail = '$p_detail', + p_frais_imposables = '$p_frais_imposables', + p_heures_payees = '$p_heures_payees', + p_heures_travaillees = '$p_heures_travaillees', + p_masse_salariale = '$p_masse_salariale', + p_net_a_payer = '$p_net_a_payer', + p_net_imposable = '$p_net_imposable', + p_nombre = '$p_nombre', + p_od_net_patronale = '$p_od_net_patronale', + p_od_net_salarie = '$p_od_net_salarie', + rang_edition = '$rang_edition', + s_avantage_nature = '$s_avantage_nature', + s_base = '$s_base', + s_brut = '$s_brut', + s_cotisation_patronale = '$s_cotisation_patronale', + s_cotisation_salarie = '$s_cotisation_salarie', + s_frais_imposables = '$s_frais_imposables', + s_heures_payees = '$s_heures_payees', + s_heures_travaillees = '$s_heures_travaillees', + s_masse_salariale = '$s_masse_salariale', + s_net_a_payer = '$s_net_a_payer', + s_net_imposable = '$s_net_imposable', + s_nombre = '$s_nombre' , + s_od_net_patronale = '$s_od_net_patronale', + s_od_net_salarie = '$s_od_net_salarie', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte' , + texte = '$texte', + texte_court = '$texte_court', + unite = '$unite', + user_modified = '$user_modified' + + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_sections_analytiques(){ + + + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_sections_analytiques SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_sections_analytiques_paie() { + + + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_sections_analytiques_paie SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_services(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_services SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_situations_famille(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_situations_famille SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_societes_interim(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_societes_interim SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_specialites(){ + +global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_specialites SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_statuts(){ + +global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_statuts SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_types_contrat(){ + +global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_types_contrat SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_types_horaire(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_types_horaire SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + + +function setRecords_types_temps_travail(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_types_temps_travail SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_motifs_visite(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_motifs_visite SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_accident_circonstance(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_accident_circonstance SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_accident_lieu(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_accident_lieu SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + +} + + +function setRecords_accident_nature(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_accident_nature SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + +} + + +function setRecords_accident_siege(){ + +global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_accident_siege SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_unite_fonctionnelle(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_unite_fonctionnelle SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_lettre_budgetaire(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_lettre_budgetaire SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_commission_paritaire(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_commission_paritaire SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + +} + + +function setRecords_categorie_conge(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_categorie_conge SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_cadre_emploi(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_cadre_emploi SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_filiere(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_filiere SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_categorie_statutaire(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_categorie_statutaire SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_compte(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_compte SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + if ($propagate != "false") { + $result = $database->exec("SELECT rh.cti_reorganize_profils(); "); + } + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_transformation(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + + $date_debut = utf8_decode($recordNode["date_debut"]); + $date_fin = utf8_decode($recordNode["date_fin"]); + $from_qualification_id = floatval($recordNode["from_qualification_id"]); + $from_service_id = floatval($recordNode["from_service_id"]); + $oid = floatval($recordNode["oid"]); + $salarie_id = floatval($recordNode["salarie_id"]); + $texte = utf8_decode($recordNode["texte"]); + $to_qualification_id = floatval($recordNode["to_qualification_id"]); + $to_service_id = floatval($recordNode["to_service_id"]); + + + if ($action != "delete" && $action != "copy") { + $date_debut = toSQL($date_debut); + $date_fin = toSQL($date_fin); + $from_qualification_id = toSQL($from_qualification_id); + $from_service_id = toSQL($from_service_id); + $salarie_id = toSQL($salarie_id); + $texte = toSQL($texte); + $to_qualification_id = toSQL($to_qualification_id); + $to_service_id = toSQL($to_service_id); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_transformation SET + date_debut = '$date_debut', + date_fin = '$date_fin', + from_qualification_id = '$from_qualification_id', + from_service_id = '$from_service_id', + salarie_id = '$salarie_id', + texte = '$texte', + to_qualification_id = '$to_qualification_id', + to_service_id = '$to_service_id' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_expert_controle() { + + global $database; + global $action; + global $recordNode; + + $httpString = ""; + + $mode = floatval($recordNode["mode"]); + + // Mise à jour controles unitaires + if ($mode == 0) { + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + if ($texte_court == "") { + $texte_court = $texte; + } + $texte_abrege = utf8_decode($recordNode["texte_abrege"]); + if ($texte_abrege == "") { + $texte_abrege = $texte_court; + } + $description = $recordNode["description"]; + $is_cti = utf8_decode($recordNode["is_cti"]); + $is_active = utf8_decode($recordNode["is_active"]); + $is_hide = utf8_decode($recordNode["is_hide"]); + $gravite_id = floatval($recordNode["gravite"]); + $prestataire_id = floatval($recordNode["prestataire"]); + $is_alert = utf8_decode($recordNode["is_alert"]); + + $rule_oid1 = floatval($recordNode["rule_oid1"]); + $sqlcmd_where1 = utf8_decode($recordNode["sqlcmd_where1"]); + $sqlcmd_justificatif1 = utf8_decode($recordNode["sqlcmd_justificatif1"]); + $table1 = floatval($recordNode["table1"]); + + + $code = toSQL($code); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + $texte_abrege = toSQL($texte_abrege); + $description = toSQL($description); + $is_cti = toSQL($is_cti); + $is_hide = toSQL($is_hide); + $is_active = toSQL($is_active); + $sqlcmd_where1 = toSQL($sqlcmd_where1); + $sqlcmd_justificatif1 = toSQL($sqlcmd_justificatif1); + + + if ($action != "delete" && $action != "copy" && $action != "execute_rules" && $action != "purge_history") { + + // creation ou mise à jour de la liste + if ($oid == -1) { + + $sqlcmd = "INSERT INTO rh.t_expert_controle + ( + code, + texte, + texte_court, + texte_abrege, + description, + is_cti, + is_hide, + gravite_id, + prestataire_id, + is_active, + alert_exp + + ) + VALUES( + '$code', + '$texte', + '$texte_court', + '$texte_abrege', + '$description', + '$is_cti', + '$is_hide', + $gravite_id, + $prestataire_id, + '$is_active', + '$is_alert' + + ) "; + $result = $database->exec($sqlcmd); + if ($result == FALSE) { + + } + else { + $result = $database->exec( + "SELECT max(oid) as oid FROM + rh.t_expert_controle + WHERE 1=1 + AND code = '$code' AND texte = '$texte'" + ); + if ($result != false) { + $record = $database->nextRecordInto(); + if ($record != FALSE) { + $oid = $record[0] + 0; + } + } + } + } + + else { + + $sqlcmd = "UPDATE rh.t_expert_controle SET + texte = '$texte', + texte_court = '$texte_court', + texte_abrege = '$texte_abrege', + description = '$description', + is_cti = '$is_cti' , + is_hide = '$is_hide' , + gravite_id = $gravite_id, + prestataire_id = $prestataire_id, + is_active = '$is_active', + alert_exp = '$is_alert' + WHERE oid = $oid; + UPDATE rh.t_expert_controle SET + code = '$code' + WHERE oid = $oid; + "; + $result = $database->exec($sqlcmd); + } + + // Ajout des règles + $sqlcmd = "DELETE FROM rh.t_expert_controle_rule + USING + ( + SELECT t_expert_controle_rule.oid + FROM rh.t_expert_controle_rule + LEFT JOIN rh.t_expert_controle ON t_expert_controle_rule.controle_id = t_expert_controle.oid + WHERE t_expert_controle.oid IS NULL + ) AS subview + WHERE t_expert_controle_rule.oid = subview.oid; + + INSERT INTO rh.t_expert_controle_rule ( + controle_id, + numero, + sqlcmd_where, + sqlcmd_justificatif, + table_id + ) + SELECT t_expert_controle.oid AS controle_id, + 1::bigint AS numero, + '' AS sqlcmd_where, + '' AS sqlcmd_justificatif, + 0::bigint AS table_id + FROM rh.t_expert_controle + LEFT JOIN rh.t_expert_controle_rule ON t_expert_controle_rule.controle_id = t_expert_controle.oid AND t_expert_controle_rule.numero = 1 + WHERE t_expert_controle_rule.oid IS NULL;"; + $result = $database->exec($sqlcmd); + + if ($oid != 0) { + + $sqlcmd = + "UPDATE rh.t_expert_controle_rule + SET sqlcmd_where = '$sqlcmd_where1', + sqlcmd_justificatif = '$sqlcmd_justificatif1', + table_id = $table1 + WHERE controle_id = $oid AND + numero = 1;"; + $result = $database->exec($sqlcmd); + } + } + + if ($action == "copy") { + + $pos = stripos($code, "_"); + if ($pos === false) { + $fromcode = $code . "_"; + } + else { + $fromcode = substr($code,0,$pos) . "_"; + } + + $last_oid = 1; + $result = $database->exec("SELECT max(to_number(substr(code,length('$fromcode')+1,10), '999999')) as oid FROM rh.t_expert_controle WHERE code LIKE '$fromcode%'"); + if ($result != false) { + $record = $database->nextRecordInto(); + if ($record != FALSE) { + $last_oid = $record[0]; + } + } + if ($last_oid == 0) { + $last_oid = 1; + } + $last_oid++; + + $sqlcmd = "INSERT INTO rh.t_expert_controle(code, texte, texte_court) "; + $sqlcmd = $sqlcmd . "SELECT '$fromcode$last_oid', 'Copie de ' || texte , 'Copie de ' || texte_court "; + $sqlcmd = $sqlcmd . "FROM rh.t_expert_controle WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + $oid = 0; + $result = $database->exec( + "SELECT max(oid) as oid FROM + rh.t_expert_controle + WHERE code = '$fromcode$last_oid' " + ); + if ($result != false) { + $record = $database->nextRecordInto(); + if ($record != FALSE) { + $oid = $record[0]; + } + } + } + + if ($action == "delete") { + $sqlcmd = "DELETE FROM rh.t_expert_controle WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + $sqlcmd = "DELETE FROM rh.t_expert_controle_rule WHERE controle_id = $oid"; + $result = $database->exec($sqlcmd); + } + + if ($action == "purge_history") { + $sqlcmd = "DELETE FROM rh.p_expert_controle WHERE controle_id = $oid"; + $result = $database->exec($sqlcmd); + } + } + + + // Mise à jour paramètres généraux + if ($mode == 2) { + $EXPERT_ACTIVE = utf8_decode($recordNode["EXPERT_ACTIVE"]); + $EXPERT_DATE_DEBUT = utf8_decode($recordNode["EXPERT_DATE_DEBUT"]); + + if ($action == "save") { + + $sqlcmd = "UPDATE rh.t_divers + SET valeur = '$EXPERT_ACTIVE' + WHERE code = 'EXPERT_ACTIVE' AND + valeur IS DISTINCT FROM '$EXPERT_ACTIVE'; "; + $result = $database->exec($sqlcmd); + + $sqlcmd = "UPDATE rh.t_divers + SET valeur_date = to_date('$EXPERT_DATE_DEBUT','DD/MM/YYYY'), + valeur = '$EXPERT_DATE_DEBUT' + WHERE code = 'EXPERT_DATE_DEBUT' AND + valeur_date IS DISTINCT FROM to_date('$EXPERT_DATE_DEBUT','DD/MM/YYYY'); "; + $result = $database->exec($sqlcmd); + } + } + + // exécution des règles + if ($action == "create_documentation" || $action == "save" || $action == "delete") { + + $reference_template_file = "../references/iCTI_RH_ExpertControle.template.HTML"; + $reference_file = "../references/iCTI_RH_ExpertControle.HTML"; + if (file_exists($reference_template_file)) { + $reference_template_handle = @fopen($reference_template_file, "r"); + $reference_handle = @fopen($reference_file, "w"); + if ($reference_template_handle) { + $currentIsControle = false; + $controleString = ""; + while (!feof($reference_template_handle)) { + $buffer = fgets($reference_template_handle, 99999); + if (trim($buffer) == "") { + $currentIsControle = true; + } + else { + if (trim($buffer) == "") { + + $sqlcmd = "SELECT + t_expert_controle.oid, + t_expert_controle.code, + t_expert_controle.texte, + t_expert_controle.description, + t_expert_controle.is_cti + FROM rh.t_expert_controle + WHERE t_expert_controle.oid > 0 AND is_global <> 1 AND is_hide <> 1 AND description <> '' + ORDER BY t_expert_controle.code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + if ($record != FALSE) { + $ok = TRUE; + + $oid = $record[0]; + $code = toHTML(trim($record[1])); + $texte = toHTML(trim($record[2])); + $description = trim($record[3]); + $is_cti = toHTML(trim($record[4])); + + if (substr($description,0,3) == "_c_") { + $description = uncompress64(substr($description, 3)); + } + $description = str_replace('SIZE="10"','SIZE="3"',$description); + $description = str_replace('SIZE="12"','SIZE="3"',$description); + $description = str_replace('SIZE="14"','SIZE="3"',$description); + + $controleStringControle = $controleString; + $controleStringControle = str_replace("[CONTROLE_CODE]",$code,$controleStringControle); + $controleStringControle = str_replace("[CONTROLE_TEXT]",$texte,$controleStringControle); + $controleStringControle = str_replace("[CONTROLE_DESCRIPTION]",$description,$controleStringControle); + + fwrite($reference_handle,$controleStringControle); + } + } + } + + $currentIsControle = false; + } + else { + if ($currentIsControle == false) { + fwrite($reference_handle,$buffer); + } + else { + $controleString = "$controleString$buffer"; + } + } + } + } + } + @fclose($reference_template_handle); + @fclose($reference_handle); + } + } + + return $httpString; +} + + +function setRecords_planning_service(){ + +global $database; + global $action; + global $propagate; + global $recordNode; + + + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $oid = floatval($recordNode["oid"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $service_code = utf8_decode($recordNode["service_code"]); + $service_id = floatval($recordNode["service_id"]); + $service_section_code = utf8_decode($recordNode["service_section_code"]); + $service_section_id = floatval($recordNode["service_section_id"]); + $service_section_texte = utf8_decode($recordNode["service_section_texte"]); + $service_texte = utf8_decode($recordNode["service_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $service_code = toSQL($service_code); + $service_id = toSQL($service_id); + $service_section_code = toSQL($service_section_code); + $service_section_id = toSQL($service_section_id); + $service_section_texte = toSQL($service_section_texte); + $service_texte = toSQL($service_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_planning_service SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + service_code = '$service_code', + service_id = '$service_id', + service_section_code = '$service_section_code', + service_section_id = '$service_section_id', + service_section_texte = '$service_section_texte', + service_texte = '$service_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + +function setRecords_planning_qualification(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $oid = floatval($recordNode["oid"]); + $qualification_code = utf8_decode($recordNode["qualification_code"]); + $qualification_id = floatval($recordNode["qualification_id"]); + $qualification_section_code = utf8_decode($recordNode["qualification_section_code"]); + $qualification_section_id = floatval($recordNode["qualification_section_id"]); + $qualification_section_texte = floatval($recordNode["qualification_section_texte"]); + $qualification_texte = utf8_decode($recordNode["qualification_texte"]); + $section_code = floatval($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["service_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $qualification_code = toSQL($qualification_code); + $qualification_id = toSQL($qualification_id); + $qualification_section_code = toSQL($qualification_section_code); + $qualification_section_id = toSQL($qualification_section_id); + $qualification_section_texte = toSQL($qualification_section_texte); + $qualification_texte = toSQL($qualification_texte); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_planning_qualification SET + code = '$code', + code_original = '$code_original', + qualification_code = '$qualification_code', + qualification_id = '$qualification_id', + qualification_section_code = '$qualification_section_code', + qualification_section_id = '$qualification_section_id', + qualification_section_texte = '$qualification_section_texte', + qualification_texte = '$qualification_texte', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_planning_type_absence(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $code_original = utf8_decode($recordNode["code_original"]); + $section_code = utf8_decode($recordNode["section_code"]); + $section_id = floatval($recordNode["section_id"]); + $section_texte = utf8_decode($recordNode["section_texte"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $code_original = toSQL($code_original); + $section_code = toSQL($section_code); + $section_id = toSQL($section_id); + $section_texte = toSQL($section_texte); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_planning_type_absence SET + code = '$code', + code_original = '$code_original', + section_code = '$section_code', + section_id = '$section_id', + section_texte = '$section_texte', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function setRecords_data_profile(){ + + global $database; + global $action; + global $propagate; + global $recordNode; + + + $code = utf8_decode($recordNode["code"]); + $etablissement_exclus = utf8_decode($recordNode["etablissement_exclus"]); + $etablissement_id = floatval($recordNode["etablissement_id"]); + $etablissement_inclus = utf8_decode($recordNode["etablissement_inclus"]); + $oid = floatval($recordNode["oid"]); + $service_exclus = utf8_decode($recordNode["service_exclus"]); + $service_id_array = floatval($recordNode["service_id_array"]); + $service_inclus = utf8_decode($recordNode["service_inclus"]); + $statut_exclus = utf8_decode($recordNode["statut_exclus"]); + $statut_id_array = floatval($recordNode["statut_id_array"]); + $statut_inclus = utf8_decode($recordNode["statut_inclus"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + + + if ($action != "delete" && $action != "copy") { + $code = toSQL($code); + $etablissement_exclus = toSQL($etablissement_exclus); + $etablissement_id = toSQL($etablissement_id); + $etablissement_inclus = toSQL($etablissement_inclus); + $service_exclus = toSQL($service_exclus); + $service_id_array = toSQL($service_id_array); + $service_inclus = toSQL($service_inclus); + $statut_exclus = toSQL($statut_exclus); + $statut_id_array = toSQL($statut_id_array); + $statut_inclus = toSQL($service_inclus); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + + + // creation ou mise à jour de la liste + if ($oid == -1) { + + + } + else { + + $sqlcmd = "UPDATE rh.t_data_profile SET + code = '$code', + etablissement_exclus = '$etablissement_exclus', + etablissement_id = '$etablissement_id', + etablissement_inclus = '$etablissement_inclus', + service_exclus = '$service_exclus', + service_id_array = '$service_id_array', + service_inclus = '$service_inclus', + statut_exclus = '$statut_exclus', + statut_id_array = '$statut_id_array', + statut_inclus = '$statut_inclus', + texte = '$texte', + texte_court = '$texte_court' + WHERE oid = $oid"; + $result = $database->exec($sqlcmd); + + + } + + + } + + if ($action == "copy") { + + + + } + + + if ($action == "delete") { + + } + + + +} + + +function erase_cache() { + + global $database; + + // Ancienne version + if ($database->cticache == "true") { + $sqlcmd = "SELECT cti_cache_erase as result from cache.cti_cache_erase('iCTI_rh')"; + $result = $database->exec($sqlcmd); + } + + // Nouvelle version + cleanAllCache("iCTI_rh"); + + +} + + +?> \ No newline at end of file diff --git a/php/amfphp/index.php b/php/amfphp/index.php new file mode 100644 index 0000000..aea4a18 --- /dev/null +++ b/php/amfphp/index.php @@ -0,0 +1,13 @@ +serviceFolderPaths = array(dirname(__FILE__) . '/services/'); +//$config->pluginsConfig['AmfphpCustomClassConverter'] = array('customClassFolderPaths' => array(dirname(__FILE__) . '/Services/Vo')); +$gateway = Amfphp_Core_HttpRequestGatewayFactory::createGateway($config); +$gateway->service(); +$gateway->output(); + +?> diff --git a/php/amfphp/services/CtiRhBilanSocialService.php b/php/amfphp/services/CtiRhBilanSocialService.php new file mode 100644 index 0000000..8545776 --- /dev/null +++ b/php/amfphp/services/CtiRhBilanSocialService.php @@ -0,0 +1,1269 @@ +getOptBilanSocial(); + } + + /** + * + * @return array liste des erreurs à corriger avant de pouvoir générer un BS. + */ + public function diagnose() { + $ret = array(); + try { + $con = ICTIDB::getInstance(); + $con->beginTransaction(); + $sql = " + select * + from ( + select case when count(oid) != 2 then 'Pas de classe(s) d''âges et/ou d''anciennetés paramétrée(s) dans Divers.' else null end as error_message + from rh.t_classes + join rh.t_divers on t_divers.valeur = t_classes.code + WHERE 1=1 + AND t_divers.code IN ('BS_CLA_AGE', 'BS_CLA_ANC') + UNION + select case when count(oid) = 0 then 'Aucune classe CTI_BS_QUA existante.' else null end as error_message + from rh.t_classes + where code = 'CTI_BS_QUA' + UNION + select case when count(oid) > 1 then 'Plus d''un classe CTI_BS_QUA existante.' else null end as error_message + from rh.t_classes + where code = 'CTI_BS_QUA' + UNION + select case when count(oid) = 1 and max(is_cti) != 0 then 'Classe CTI_BS_QUA ne doit pas être marquée \"CTI\".' else null end as error_message + from rh.t_classes + where code = 'CTI_BS_QUA' + UNION + select + case when count(distinct t_classes.oid) = 1 AND count(distinct t_classes_sections.oid) = 0 then 'Classe CTI_BS_QUA n''a aucune section.' else null end as error_message + from rh.t_classes + left join rh.t_classes_sections on t_classes_sections.classe_id = t_classes.oid + where 1=1 + AND t_classes.code = 'CTI_BS_QUA' + AND t_classes.is_cti = 0 + UNION + SELECT case when count(distinct t_classes.oid) = 1 then 'Classe CTI_BS_QUA définie sur une mauvaise dimension.' else null end as error_message + FROM rh.t_classes + join rh.t_listes_tables on t_listes_tables.oid = t_classes.table_id + WHERE 1=1 + AND t_classes.code = 'CTI_BS_QUA' + AND is_cti = 0 + AND t_listes_tables.name NOT IN ( + 't_qualifications', + 't_categories_socio_professionnelles', + 't_services', + 't_specialites', + 't_statuts') + ) as error_messages + where error_message is not null + "; + foreach ($con->query($sql, PDO::FETCH_ASSOC) as $row) { + $ret[] = $row; + } + $con->commit(); + } catch (Exception $e) { + + } + + return $ret; + } + + /** + * + * @return array liste des entreprises/établissements + */ + public function getEntities() { + $ret = array(); + try { + $con = ICTIDB::getInstance(); + $con->beginTransaction(); + $sql = " + SELECT * + FROM ( + select + t_entreprises.oid AS ent_id, + 0::bigint AS ets_id, + t_entreprises.code_original AS code, + 'Ent. '||t_entreprises.code||' - '||t_entreprises.texte AS texte + from rh.t_entreprises + join rh.t_etablissements on t_etablissements.entreprise_id = t_entreprises.oid + join rh.p_contrats ON p_contrats.etablissement_id = t_etablissements.oid + where 1=1 + and t_entreprises.oid != 0 + UNION + select + t_entreprises.oid AS ent_id, + t_etablissements.oid AS ets_id, + t_etablissements.code_original AS code, + ' - Ets. '||t_etablissements.code||' - '||t_etablissements.texte AS texte + from rh.t_entreprises + join rh.t_etablissements on t_etablissements.entreprise_id = t_entreprises.oid + join rh.p_contrats ON p_contrats.etablissement_id = t_etablissements.oid + where 1=1 + and t_entreprises.oid != 0 + and t_etablissements.oid != 0) AS foo + ORDER BY lpad(code, 6, '0') + "; + foreach ($con->query($sql, PDO::FETCH_ASSOC) as $row) { + $ret[] = $row; + } + $con->commit(); + } catch (Exception $e) { + + } + + return $ret; + } + + public function fileGenerated($filename) { + $tmpDir = __ROOT__ . '/temp/'; + $outputFile = $tmpDir . $filename; + return file_exists($outputFile); + } + + public function deleteFile($filename) { + $tmpDir = __ROOT__ . '/temp/'; + $outputFile = $tmpDir . $filename; + if (file_exists($outputFile)) { + unlink($outputFile); + } + return true; + } + + /** + * + * @param string $annee année à générer + * @param array $entreprise tableau d'entreprises pour lesquelles générer le BS + * @param array $etablissement tableau d'établissements pour lesquels générer le BS + * @return string Description + */ + public function generateExcel($annee, $filename, $entrepriseId = 0, $etablissementId = 0) { + + $tmpDiag = $this->diagnose(); + + if (count($tmpDiag) > 0) { + return "diagnose"; + } + + $tmpDir = __ROOT__ . '/temp/'; + // Test d'existence du dossier 'temp'. + if (!file_exists($tmpDir)) { + mkdir($tmpDir); + } + $outputFile = $tmpDir . $filename; + + if (file_exists($outputFile)) { + unlink($outputFile); + } + + // Récupération des données de définition du Bilan Social + $fBs = __ROOT__ . '/modules/rh/php/amfphp/services/CtiRhBilanSocialService.yaml'; + $data = Spyc::YAMLLoad($fBs); + + $conn = ICTIDB::getInstance(); + $pgVersion = $conn->getAttribute(PDO::ATTR_SERVER_VERSION); + $isPg9 = (intval(substr($pgVersion, 0, 1)) > 8 ? true : false); + + // Les classes d'âges et d'anciennetés sont paramétrées dans la table rh.t_divers. + // Le programme a besoin du n° de séquence pour chacune d'entre elles. + $sequenceAge = 9; + $sequenceAnc = 9; + + $sqlDim = " + SELECT + t_listes_tables.name, + t_classes.sequence + from rh.t_classes + join rh.t_listes_tables on t_listes_tables.oid = t_classes.table_id + join rh.t_divers on t_divers.valeur = t_classes.code + WHERE 1=1 + AND t_divers.code IN ('BS_CLA_AGE', 'BS_CLA_ANC') + "; + + $res = $conn->query($sqlDim); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + foreach ($tmpRes as $tuple) { + switch ($tuple['name']) { + case 't_ages': + $sequenceAge = $tuple['sequence']; + break; + case 't_anciennetes_annee': + $sequenceAnc = $tuple['sequence']; + break; + } + } + + // La classe CTI_BS_QUA peut être faite sur n'importe quelle dimension. + $sqlDim = " + SELECT + t_listes_tables.name, + t_classes.sequence + from rh.t_classes + join rh.t_listes_tables on t_listes_tables.oid = t_classes.table_id + WHERE 1=1 + AND t_classes.code = 'CTI_BS_QUA' + AND is_cti = 0 + LIMIT 1 + "; + + $res = $conn->query($sqlDim); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + $dimension = ""; + $sequence = ""; + + switch ($tmpRes[0]['name']) { + case 't_qualifications' : + $dimension = "qualification"; + break; + case 't_categories_socio_professionnelles' : + $dimension = "categorie_socio_professionnelle"; + break; + case 't_services' : + $dimension = "service"; + break; + case 't_specialites' : + $dimension = "specialite"; + break; + case 't_statuts' : + $dimension = "statut"; + break; + default : + $dimension = "statut"; + break; + } + + $sequence = $tmpRes[0]['sequence']; + + // Traitements SQL + $sqlBase = " + drop table if exists w_bs_contrat + ; + create temp table w_bs_contrat as + select + " . $dimension . "_section_texte[$sequence] AS cti_bs_qua, + * + from rh.v_contrats_mois_1 + where 1=1 + AND mois_activite_id between " . $annee . "01 and " . $annee . "12 + AND est_hors_periode IS DISTINCT FROM '1' + AND fictif <> '1' + " . ($entrepriseId > 0 ? "AND entreprise_id = $entrepriseId" : "") . " + " . ($etablissementId > 0 ? "AND etablissement_id = $etablissementId" : "") . " + ; + + DROP TABLE IF EXISTS w_ep + ; + + CREATE TEMP TABLE w_ep AS + SELECT salarie_id AS efp_salarie_id + FROM w_bs_contrat + WHERE 1=1 + AND present_debut_mois = 1 + AND present_fin_mois = 1 + GROUP BY 1 + HAVING count(DISTINCT + CASE WHEN 1=1 + AND type_contrat_section_code[9] = 'CDI' + AND type_temps_travail_section_code[9] = 'TC' + THEN mois_activite_id + ELSE null + END) = base.cti_months_between('" . $annee . "0101'::date, '" . $annee . "1231'::date) + ; + + DROP TABLE IF EXISTS w_bs_contrat_mois + ; + + CREATE TEMP TABLE w_bs_contrat_mois AS + SELECT + mois_activite_id AS mois, + " . $dimension . "_section_texte[$sequence] AS cti_bs_qua, + count(DISTINCT CASE WHEN present_fin_mois = 1 THEN salarie_id ELSE null END) AS nb_sal_fin_mois + FROM w_bs_contrat + WHERE 1=1 + GROUP BY 1,2 + ; + + DROP TABLE IF EXISTS w_bs_arret_mois + ; + + CREATE TEMP TABLE w_bs_arret_mois AS + SELECT + " . $dimension . "_section_texte[$sequence] AS cti_bs_qua, + * + FROM rh.v_arrets_travail_mois_1 + WHERE 1=1 + AND mois_activite_id between " . $annee . "01 and " . $annee . "12 + " . ($entrepriseId > 0 ? "AND entreprise_id = $entrepriseId" : "") . " + " . ($etablissementId > 0 ? "AND etablissement_id = $etablissementId" : "") . " + ; + + DROP TABLE IF EXISTS w_bs_arret_mal + ; + + CREATE TEMP TABLE w_bs_arret_mal AS + SELECT + cti_bs_qua, + arret_travail_id, + sum(nb_jours_arret) AS nb_jours_arret + FROM w_bs_arret_mois + WHERE 1=1 + AND motif_arret_section_code[9] = 'MAL' + GROUP BY 1,2 + ; + + DROP TABLE IF EXISTS w_bs_arret_mal_duree + ; + + CREATE TEMP TABLE w_bs_arret_mal_duree AS + SELECT + cti_bs_qua, + arret_travail_id, + nb_jours_arret, + CASE + WHEN nb_jours_arret BETWEEN 1 AND 3 THEN 'T01|1 à 3 jours' + WHEN nb_jours_arret BETWEEN 4 AND 10 THEN 'T02|4 à 10 jours' + WHEN nb_jours_arret BETWEEN 10 AND 15 THEN 'T03|10 à 15 jours' + WHEN nb_jours_arret BETWEEN 16 AND 30 THEN 'T04|16 à 30 jours' + WHEN nb_jours_arret BETWEEN 31 AND 60 THEN 'T05|1 à 2 mois' + WHEN nb_jours_arret BETWEEN 61 AND 90 THEN 'T06|2 à 3 mois' + WHEN nb_jours_arret BETWEEN 91 AND 120 THEN 'T07|3 à 4 mois' + WHEN nb_jours_arret BETWEEN 121 AND 150 THEN 'T08|4 à 5 mois' + WHEN nb_jours_arret BETWEEN 151 AND 180 THEN 'T09|5 à 6 mois' + WHEN nb_jours_arret BETWEEN 181 AND 212 THEN 'T10|6 à 7 mois' + WHEN nb_jours_arret BETWEEN 213 AND 244 THEN 'T11|7 à 8 mois' + WHEN nb_jours_arret BETWEEN 245 AND 274 THEN 'T12|8 à 9 mois' + WHEN nb_jours_arret BETWEEN 275 AND 304 THEN 'T13|9 à 10 mois' + WHEN nb_jours_arret BETWEEN 305 AND 334 THEN 'T14|10 à 11 mois' + WHEN nb_jours_arret BETWEEN 335 AND 365 THEN 'T15|11 à 12 mois' + ELSE 'T16|+ d''un an' + END AS tranche_duree + FROM w_bs_arret_mal + ; + + drop table if exists w_bs_paie + ; + create temp table w_bs_paie as + select + " . $dimension . "_section_texte[$sequence] AS cti_bs_qua, + mois_activite_id, + salarie_id, + rubrique_id, + montant_masse_salariale, + montant_net_a_payer_salarie + from rh.v_historique_paie_1 + where 1=1 + AND mois_activite_id between " . $annee . "01 and " . $annee . "12 + " . ($entrepriseId > 0 ? "AND entreprise_id = $entrepriseId" : "") . " + " . ($etablissementId > 0 ? "AND etablissement_id = $etablissementId" : "") . " + ; + + DROP TABLE IF EXISTS w_bs_paie_mois + ; + + CREATE TEMP TABLE w_bs_paie_mois AS + SELECT + mois, + cti_bs_qua, + sum(nb_cnt_salarie_id) AS nb_cnt_salarie_id, + sum(nb_cnt_sal_fin_mois) AS nb_cnt_sal_fin_mois, + sum(montant_masse_salariale) AS montant_masse_salariale + FROM ( + SELECT + mois_activite_id AS mois, + cti_bs_qua, + count(DISTINCT salarie_id) AS nb_cnt_salarie_id, + count(DISTINCT CASE WHEN present_fin_mois = 1 THEN salarie_id ELSE NULL END) AS nb_cnt_sal_fin_mois, + 0 AS montant_masse_salariale + FROM w_bs_contrat + GROUP BY 1,2 + UNION ALL + SELECT + mois_activite_id, + cti_bs_qua, + 0, + 0, + sum(montant_masse_salariale) + FROM w_bs_paie + GROUP BY 1,2 + ) AS subq + GROUP BY 1,2 + ; + "; + + if ($isPg9) { + $sqlBase .= " + -- Spécial paie + DROP TABLE IF EXISTS w_bs_paie_special + ; + + CREATE TEMP TABLE w_bs_paie_special AS + SELECT salarie_id, + foo.cti_bs_qua, + 0::BIGINT AS i, + 0::BIGINT AS j, + sum(montant_masse_salariale) AS montant_masse_salariale, + 0::NUMERIC AS s10m, -- rémunérations représentant 10% des salariés avec les rémunérations les moins élevées + 0::NUMERIC AS s10p, -- rémunérations représentant 10% des salariés avec les rémunérations les plus élevées + 0::NUMERIC AS m10p -- montant des 10 rémunérations les + élevées + FROM w_bs_paie + JOIN w_ep ON efp_salarie_id = salarie_id + JOIN ( + SELECT cti_bs_qua + FROM w_bs_paie + GROUP BY 1 + UNION ALL + SELECT 'Total' + ) AS foo + ON 1 = 1 + WHERE 1!=1 + OR foo.cti_bs_qua = 'Total' + OR foo.cti_bs_qua = w_bs_paie.cti_bs_qua + GROUP BY 1,2,3,4,6,7 + ; + + -- Remplir le rang par cti_bs_qua + UPDATE w_bs_paie_special + SET i = ir, + j=jr + FROM ( + SELECT + rank() OVER (PARTITION BY cti_bs_qua ORDER BY montant_masse_salariale asc) AS ir, + rank() OVER (PARTITION BY cti_bs_qua ORDER BY montant_masse_salariale desc) AS jr, + * + FROM w_bs_paie_special + ) AS foo + WHERE 1 = 1 + AND w_bs_paie_special.salarie_id = foo.salarie_id + AND w_bs_paie_special.cti_bs_qua = foo.cti_bs_qua + ; + + UPDATE w_bs_paie_special + SET s10m = foo1.s10m, + s10p = foo1.s10p, + m10p = foo1.m10p + FROM ( + SELECT salarie_id, + i, + w_bs_paie_special.cti_bs_qua, + foo.cti_bs_qua AS ttt, + CASE WHEN ( + i::NUMERIC / ( + SELECT count(*)::NUMERIC + FROM w_bs_paie_special + WHERE cti_bs_qua = foo.cti_bs_qua + ) * 100::NUMERIC + ) >= 90 THEN montant_masse_salariale ELSE 0 END AS s10p, + CASE WHEN ( + ( + ( + SELECT count(*)::NUMERIC + FROM w_bs_paie_special + WHERE cti_bs_qua = foo.cti_bs_qua + ) - i::NUMERIC + 1 + ) / ( + SELECT count(*)::NUMERIC + FROM w_bs_paie_special + WHERE cti_bs_qua = foo.cti_bs_qua + ) * 100::NUMERIC + ) >= 90 THEN montant_masse_salariale ELSE 0 END AS s10m, + case when j <= 10 then montant_masse_salariale else 0 end as m10p + FROM w_bs_paie_special + JOIN ( + SELECT cti_bs_qua + FROM w_bs_paie + GROUP BY 1 + UNION ALL + SELECT 'Total' + ) AS foo + ON w_bs_paie_special.cti_bs_qua = foo.cti_bs_qua + GROUP BY 1,2,3,4,5,6,7 + ORDER BY 2,4,3 + ) AS foo1 + WHERE 1 = 1 + AND w_bs_paie_special.salarie_id = foo1.salarie_id + AND w_bs_paie_special.cti_bs_qua = foo1.cti_bs_qua + ; + "; + } + + $remplacements = array( + '@annee' => $annee, + '@sequenceAge' => $sequenceAge, + '@sequenceAnc' => $sequenceAnc + ); + + $wBsContratSQL = array(); // requetes sur w_bs_contrat + $wBsContratMoisSQL = array(); // requetes sur w_bs_contrat_mois + $wBsArretMoisSQL = array(); // requetes sur w_bs_arret_mois + $wBsArretMalDureeSQL = array(); // requetes sur w_bs_arret_mal_duree + $wBsPaieSQL = array(); // requetes sur w_bs_paie + $wBsPaieMoisSQL = array(); // requetes sur w_bs_paie_mois + $wBsPaieSpecialSQL = array(); // requetes sur w_bs_paie_special + + $currentTempTable = ""; // Table temporaire associée à l'indicateur + // Parcours de tous les indicateurs pour constituer la requête SQL + foreach ($data['bilanSocial2013'] as $niveau1) { + if (key_exists('e', $niveau1)) { + foreach ($niveau1['e'] as $niveau2) { + if (key_exists('e', $niveau2)) { + foreach ($niveau2['e'] as $indicateur) { + $tmpIndicatorName = $niveau1['i'] . '.' . $niveau2['i'] . '.' . $indicateur['i']; + $tmpNull = "null" . ' AS "' . $tmpIndicatorName . '"'; + // Recherche de la table de travail pour l'indicateur. + if (key_exists('o', $indicateur)) { + $currentTempTable = $indicateur['o']; + } else if (key_exists('o', $niveau2)) { + $currentTempTable = $niveau2['o']; + } else if (key_exists('o', $niveau1)) { + $currentTempTable = $niveau1['o']; + } else { + // ERREUR : pas de table définie... + } + + $wBsContratSQL[] = $tmpNull; + $wBsContratMoisSQL[] = $tmpNull; + $wBsArretMoisSQL[] = $tmpNull; + $wBsArretMalDureeSQL[] = $tmpNull; + $wBsPaieSQL[] = $tmpNull; + $wBsPaieMoisSQL[] = $tmpNull; + $wBsPaieSpecialSQL[] = $tmpNull; + + if (key_exists('s', $indicateur)) { + $tmp = strtr($indicateur['s'], $remplacements) . ' AS "' . $tmpIndicatorName . '"'; + + switch ($currentTempTable) { + case 'w_bs_contrat' : + $wBsContratSQL[] = $tmp; + break; + case 'w_bs_contrat_mois': + $wBsContratMoisSQL[] = $tmp; + break; + case 'w_bs_arret_mois': + $wBsArretMoisSQL[] = $tmp; + break; + case 'w_bs_arret_mal_duree': + $wBsArretMalDureeSQL[] = $tmp; + break; + case 'w_bs_paie': + $wBsPaieSQL[] = $tmp; + break; + case 'w_bs_paie_mois': + $wBsPaieMoisSQL[] = $tmp; + break; + case 'w_bs_paie_special': + $wBsPaieSpecialSQL[] = $tmp; + break; + } + } + + // Dans le cas d'indicateurs enfants. + if (key_exists('e', $indicateur)) { + foreach ($indicateur['e'] as $indicateurEnfant) { + if (key_exists('s', $indicateurEnfant)) { + $tmpIndicatorName = $niveau1['i'] . '.' . $niveau2['i'] . '.' . $indicateur['i'].'.'.$indicateurEnfant['i']; + $tmpNull = "null" . ' AS "' . $tmpIndicatorName . '"'; + // La table de travail est actuellement celle de l'indicateur parent par défaut. + $tmp = strtr($indicateurEnfant['s'], $remplacements) . ' AS "' . $tmpIndicatorName . '"'; + + $wBsContratSQL[] = $tmpNull; + $wBsContratMoisSQL[] = $tmpNull; + $wBsArretMoisSQL[] = $tmpNull; + $wBsArretMalDureeSQL[] = $tmpNull; + $wBsPaieSQL[] = $tmpNull; + $wBsPaieMoisSQL[] = $tmpNull; + $wBsPaieSpecialSQL[] = $tmpNull; + + switch ($currentTempTable) { + case 'w_bs_contrat' : + $wBsContratSQL[] = $tmp; + break; + case 'w_bs_contrat_mois': + $wBsContratMoisSQL[] = $tmp; + break; + case 'w_bs_arret_mois': + $wBsArretMoisSQL[] = $tmp; + break; + case 'w_bs_arret_mal_duree': + $wBsArretMalDureeSQL[] = $tmp; + break; + case 'w_bs_paie': + $wBsPaieSQL[] = $tmp; + break; + case 'w_bs_paie_mois': + $wBsPaieMoisSQL[] = $tmp; + break; + case 'w_bs_paie_special': + $wBsPaieSpecialSQL[] = $tmp; + break; + } + } + } + } + } + } + } + } + } + + // Exécution de la requête + $sqlCmd = $sqlBase . PHP_EOL; + + // Contrats + $sqlCmd .= " + SELECT + 1 AS level, + cti_bs_qua,"; + $sqlCmd .= implode(',', $wBsContratSQL); + $sqlCmd .= PHP_EOL . "from w_bs_contrat + left join w_ep on w_ep.efp_salarie_id = w_bs_contrat.salarie_id + where 1=1 + group by 1,2 + UNION ALL + select + 0, + 'Total'::text, + "; + $sqlCmd .= implode(',', $wBsContratSQL); + $sqlCmd .= PHP_EOL . "from w_bs_contrat + left join w_ep on w_ep.efp_salarie_id = w_bs_contrat.salarie_id + where 1=1 + group by 1,2 + + ORDER BY 1 DESC, 2 + + "; + + // Contrats mois + $monthlySqlCmd = " + SELECT + 1 AS level, + cti_bs_qua,"; + $monthlySqlCmd .= implode(',', $wBsContratMoisSQL); + $monthlySqlCmd .= PHP_EOL . "from w_bs_contrat_mois + where 1=1 + group by 1,2 + UNION ALL + select + 0, + 'Total'::text, + "; + $monthlySqlCmd .= implode(',', $wBsContratMoisSQL); + $monthlySqlCmd .= PHP_EOL . "from w_bs_contrat_mois + where 1=1 + group by 1,2 + + ORDER BY 1 DESC, 2 + "; + + // Arrets + $arretSqlCmd = " + SELECT + 1 AS level, + cti_bs_qua,"; + $arretSqlCmd .= implode(',', $wBsArretMoisSQL); + $arretSqlCmd .= PHP_EOL . "from w_bs_arret_mois + where 1=1 + group by 1,2 + UNION ALL + select + 0, + 'Total'::text, + "; + $arretSqlCmd .= implode(',', $wBsArretMoisSQL); + $arretSqlCmd .= PHP_EOL . "from w_bs_arret_mois + where 1=1 + group by 1,2 + + ORDER BY 1 DESC, 2 + "; + + // Arrets Maladie Durée + $arretMalDureeSqlCmd = " + SELECT + 1 AS level, + cti_bs_qua,"; + $arretMalDureeSqlCmd .= implode(',', $wBsArretMalDureeSQL); + $arretMalDureeSqlCmd .= PHP_EOL . "from w_bs_arret_mal_duree + where 1=1 + group by 1,2 + UNION ALL + select + 0, + 'Total'::text, + "; + $arretMalDureeSqlCmd .= implode(',', $wBsArretMalDureeSQL); + $arretMalDureeSqlCmd .= PHP_EOL . "from w_bs_arret_mal_duree + where 1=1 + group by 1,2 + + ORDER BY 1 DESC, 2 + "; + + // Paies + $paieSqlCmd = " + SELECT + 1 AS level, + cti_bs_qua,"; + $paieSqlCmd .= implode(',', $wBsPaieSQL); + $paieSqlCmd .= PHP_EOL . "from w_bs_paie + left join w_ep on w_ep.efp_salarie_id = w_bs_paie.salarie_id + where 1=1 + group by 1,2 + UNION ALL + select + 0, + 'Total'::text, + "; + $paieSqlCmd .= implode(',', $wBsPaieSQL); + $paieSqlCmd .= PHP_EOL . "from w_bs_paie + left join w_ep on w_ep.efp_salarie_id = w_bs_paie.salarie_id + where 1=1 + group by 1,2 + + ORDER BY 1 DESC, 2 + "; + + // Paies Mois + $paieMoisSqlCmd = " + SELECT + 1 AS level, + cti_bs_qua,"; + $paieMoisSqlCmd .= implode(',', $wBsPaieMoisSQL); + $paieMoisSqlCmd .= PHP_EOL . "from w_bs_paie_mois + where 1=1 + group by 1,2 + UNION ALL + select + 0, + 'Total'::text, + "; + $paieMoisSqlCmd .= implode(',', $wBsPaieMoisSQL); + $paieMoisSqlCmd .= PHP_EOL . "from w_bs_paie_mois + where 1=1 + group by 1,2 + + ORDER BY 1 DESC, 2 + "; + + if ($isPg9) { + // Paies Special + $paieSpecialSqlCmd = " + SELECT + 1 AS level, + cti_bs_qua,"; + $paieSpecialSqlCmd .= implode(',', $wBsPaieSpecialSQL); + $paieSpecialSqlCmd .= PHP_EOL . "from w_bs_paie_special + where 1=1 + group by 1,2 + UNION ALL + select + 0, + 'Total'::text, + "; + $paieSpecialSqlCmd .= implode(',', $wBsPaieSpecialSQL); + $paieSpecialSqlCmd .= PHP_EOL . "from w_bs_paie_special + where 1=1 + group by 1,2 + + ORDER BY 1 DESC, 2 + "; + } + + // Traitement des résultat Contrat + $res = $conn->query($sqlCmd); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + $nbDataCol = count($tmpRes); + + $iDataRes = array(); + foreach ($tmpRes as $value) { + foreach ($value as $key1 => $value1) { + if ($key1 != 'level' || $key1 != 'cti_bs_qua') { + $iDataRes[$key1][$value['cti_bs_qua']] = $value1; + } + } + } + + // Traitement des résultat Contrats mois + $res = $conn->query($monthlySqlCmd); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + foreach ($tmpRes as $value) { + foreach ($value as $key1 => $value1) { + if ($key1 != 'level' || $key1 != 'cti_bs_qua') { + if (!isset($iDataRes[$key1][$value['cti_bs_qua']])) { + $iDataRes[$key1][$value['cti_bs_qua']] = $value1; + } + } + } + } + + // Traitement des résultat Arrets. + $res = $conn->query($arretSqlCmd); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + foreach ($tmpRes as $value) { + foreach ($value as $key1 => $value1) { + if ($key1 != 'level' || $key1 != 'cti_bs_qua') { + if (!isset($iDataRes[$key1][$value['cti_bs_qua']])) { + $iDataRes[$key1][$value['cti_bs_qua']] = $value1; + } + } + } + } + + // Traitement des résultat Arrets maladie durée. + $res = $conn->query($arretMalDureeSqlCmd); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + foreach ($tmpRes as $value) { + foreach ($value as $key1 => $value1) { + if ($key1 != 'level' || $key1 != 'cti_bs_qua') { + if (!isset($iDataRes[$key1][$value['cti_bs_qua']])) { + $iDataRes[$key1][$value['cti_bs_qua']] = $value1; + } + } + } + } + + // Traitement des résultat Paies. + $res = $conn->query($paieSqlCmd); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + foreach ($tmpRes as $value) { + foreach ($value as $key1 => $value1) { + if ($key1 != 'level' || $key1 != 'cti_bs_qua') { + if (!isset($iDataRes[$key1][$value['cti_bs_qua']])) { + $iDataRes[$key1][$value['cti_bs_qua']] = $value1; + } + } + } + } + + // Traitement des résultat Paies Mois. + $res = $conn->query($paieMoisSqlCmd); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + foreach ($tmpRes as $value) { + foreach ($value as $key1 => $value1) { + if ($key1 != 'level' || $key1 != 'cti_bs_qua') { + if (!isset($iDataRes[$key1][$value['cti_bs_qua']])) { + $iDataRes[$key1][$value['cti_bs_qua']] = $value1; + } + } + } + } + + // Traitement des résultat Paies Spéciales. + if ($isPg9) { + $res = $conn->query($paieSpecialSqlCmd); + $tmpRes = $res->fetchAll(PDO::FETCH_ASSOC); + + foreach ($tmpRes as $value) { + foreach ($value as $key1 => $value1) { + if ($key1 != 'level' || $key1 != 'cti_bs_qua') { + if (!isset($iDataRes[$key1][$value['cti_bs_qua']])) { + $iDataRes[$key1][$value['cti_bs_qua']] = $value1; + } + } + } + } + } + + // Génération du fichier Excel + $objPHPExcel = new PHPExcel(); + + $objPHPExcel->getProperties()->setCreator("CTI Santé"); + $objPHPExcel->getProperties()->setLastModifiedBy("CTI Santé"); + $objPHPExcel->getProperties()->setTitle("Bilan social $annee"); + $objPHPExcel->getProperties()->setSubject("Bilan social $annee"); + $objPHPExcel->getProperties()->setDescription("Bilan social $annee - CTI Santé"); + + $objPHPExcel->removeSheetByIndex(); // Suppression feuille par défaut "Worksheet" + + $sheetIndex = 0; + + $gras = array( + 'font' => array( + 'size' => 12, + 'bold' => true, + 'color' => array( + 'rgb' => 'FFFFFF' + ) + ) + ); + + $gras2 = array( + 'font' => array( + 'bold' => true + ) + ); + + $fill = array( + 'type' => PHPExcel_Style_Fill::FILL_SOLID, + 'color' => array('rgb' => '012b43') + ) + ; + + $dataOddFill = array( + 'type' => PHPExcel_Style_Fill::FILL_SOLID, + 'color' => array('rgb' => 'EEEEEE') + ) + ; + + $totalOddFill = array( + 'type' => PHPExcel_Style_Fill::FILL_SOLID, + 'color' => array('rgb' => 'CCCCCC') + ) + ; + + $totalEvenFill = array( + 'type' => PHPExcel_Style_Fill::FILL_SOLID, + 'color' => array('rgb' => 'EEEEEE') + ) + ; + + $NRFont = array( + 'font' => array( + 'color' => array( + 'rgb' => 'FF552A' + ) + ) + ); + + $alignmentVC = array( + 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER + ); + + $alignmentHCVC = array( + 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, + 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER + ); + + $alignmentHCW = array( + 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, + 'wrap' => true + ); + + $alignmentW = array('wrap' => true); + + $alignmentVT = array('vertical' => PHPExcel_Style_Alignment::VERTICAL_TOP); + + foreach ($data['bilanSocial2013'] as $niveau1) { + //echo PHP_EOL . $niveau1['t']; + + $sheetName = utf8_encode($niveau1['i'] . '. ' . $niveau1['t']); + $objPHPExcel->createSheet($sheetIndex); + $objPHPExcel->setActiveSheetIndex($sheetIndex); + $sheet = $objPHPExcel->getActiveSheet(); + + $sheet->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); + $sheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); + //$sheet->getPageSetup()->setScale(20); + $sheet->getPageSetup()->setFitToPage(true); + $sheet->getPageSetup()->setFitToWidth(1); + $sheet->getPageSetup()->setFitToHeight(0); + $sheet->getPageSetup()->setHorizontalCentered(true); + $sheet->getPageSetup()->setVerticalCentered(true); + + //$sheet->getHeaderFooter()->setOddHeader('&A'); + $sheet->getHeaderFooter()->setOddHeader("Bilan Social $annee " . html_entity_decode("• ", ENT_COMPAT | ENT_HTML401, 'UTF-8') . ' ' . utf8_encode($niveau1['i'] . '. ' . $niveau1['xt'])); + $sheet->getHeaderFooter()->setOddFooter('Page &P de &N'); + //$sheet->getHeaderFooter()->setEvenFooter('Page &P de &N'); + + $sheet->setTitle($sheetName); + + $sheet->getColumnDimensionByColumn(0)->setWidth(5); + $sheet->getColumnDimensionByColumn(1)->setWidth(50); + + for ($i = 2; $i <= (count($iDataRes["cti_bs_qua"]) + 1); $i++) { + $sheet->getColumnDimensionByColumn($i)->setWidth(15); + } + + $c = 1; + $r = 1; + + if (key_exists('e', $niveau1)) { + foreach ($niveau1['e'] as $niveau2) { + + $sheet->setCellValueExplicit($this->cvt(1, $r), utf8_encode($niveau1['i'] . '.' . $niveau2['i']), PHPExcel_Cell_DataType::TYPE_STRING); + $sheet->setCellValueExplicit($this->cvt(2, $r), utf8_encode($niveau2['t']), PHPExcel_Cell_DataType::TYPE_STRING); + + $sheet->getStyle($this->cvt(1, $r, $nbDataCol + 2, $r))->getAlignment()->applyFromArray($alignmentVC); + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->getAlignment()->applyFromArray($alignmentHCW); + $sheet->getStyle($this->cvt(1, $r, $nbDataCol + 2, $r))->applyFromArray($gras); + $sheet->getStyle($this->cvt(1, $r, $nbDataCol + 2, $r))->getFill()->applyFromArray($fill); + if (key_exists('c', $niveau2)) { + $sheet->getComment($this->cvt(2, $r))->getText()->createTextRun(utf8_encode($niveau2['c'])); + } + + // Ecriture de l'entête de tableau + $i = 2; + foreach ($iDataRes["cti_bs_qua"] as $value) { + $sheet->setCellValueExplicitByColumnAndRow($i, $r, utf8_encode($value), PHPExcel_Cell_DataType::TYPE_STRING); + $i++; + } + + $sheet->getRowDimension($r)->setRowHeight(30); + + $r++; + + if (key_exists('e', $niveau2)) { + foreach ($niveau2['e'] as $indicateur) { + + $indicateurNom = $niveau1['i'] . '.' . $niveau2['i'] . '.' . $indicateur['i']; + + $sheet->setCellValueExplicitByColumnAndRow(0, $r, utf8_encode($indicateurNom), PHPExcel_Cell_DataType::TYPE_STRING); + $sheet->setCellValueExplicitByColumnAndRow(1, $r, utf8_encode($indicateur['t']), PHPExcel_Cell_DataType::TYPE_STRING); + + if ($this->is_odd($r)) { + $sheet->getStyle($this->cvt(1, $r, $nbDataCol + 1, $r))->getFill()->applyFromArray($dataOddFill); + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->getFill()->applyFromArray($totalOddFill); + $sheet->getStyle($this->cvt(1, $r, 2, $r))->getFill()->applyFromArray($totalOddFill); + } else { + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->getFill()->applyFromArray($totalEvenFill); + $sheet->getStyle($this->cvt(1, $r, 2, $r))->getFill()->applyFromArray($totalEvenFill); + } + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->applyFromArray($gras2); + + if (key_exists('c', $indicateur)) { + $sheet->getCommentByColumnAndRow(1, $r)->getText()->createTextRun(utf8_encode($indicateur['c'])); + } + + // Rechercher le format du nombre à appliquer. + if (key_exists('f', $indicateur)) { + $format = html_entity_decode(utf8_encode($indicateur['f']), ENT_COMPAT | ENT_HTML401, 'UTF-8'); + } else if (key_exists('f', $niveau2)) { + $format = html_entity_decode(utf8_encode($niveau2['f']), ENT_COMPAT | ENT_HTML401, 'UTF-8'); + } else if (key_exists('f', $niveau1)) { + $format = html_entity_decode(utf8_encode($niveau1['f']), ENT_COMPAT | ENT_HTML401, 'UTF-8'); + } else { + // ERREUR : pas de format défini... + } + + // Détecter si plusieurs sous niveau + $subLevelType = 0; + + // Traitement des valeurs encapsulées dans {} + if (substr($iDataRes[$indicateurNom]['Total'], 0, 2) == '{{') { + $subLevelType = 1; + } + + // Traitements des enfants non numérotés + if (key_exists('e', $indicateur)) { + $subLevelType = 2; + } + + // Si indicateur standard (sans sous-niveau) ou + // si indicateur avec enfants (définis à la main avec noeud de type e:) et avec une définition SQL, + // alors on inscrit le résultat, sinon rien. + if ($subLevelType === 0 || ($subLevelType === 2 && key_exists('s', $indicateur))) { + $sheet->getStyleByColumnAndRow(0, $r)->getAlignment()->applyFromArray($alignmentVT); + $sheet->getStyleByColumnAndRow(1, $r)->getAlignment()->applyFromArray($alignmentW); + + $rowNR = true; + $i = 2; + foreach ($iDataRes[$indicateurNom] as $header => $value) { + $sheet->setCellValueExplicitByColumnAndRow($i, $r, utf8_encode($value), PHPExcel_Cell_DataType::TYPE_NUMERIC); + + if (isset($value)) { + $rowNR = false; + } + + $i++; + } + + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->getAlignment()->applyFromArray($alignmentHCVC); + if ($rowNR) { + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->applyFromArray($NRFont); + } else { + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->getNumberFormat()->setFormatCode($format); + } + } + + // Traitement des sous-niveaux. + switch ($subLevelType) { + case 1: + $tmpDba = array(); + foreach ($iDataRes[$indicateurNom] as $header => $value2) { + $tmpVal = preg_split("/({{|},{|}})/", $value2, -1, PREG_SPLIT_NO_EMPTY); + + foreach ($tmpVal as $value4) { + $tmpSubLevelValue = explode(',', $value4); + $tmpDba[$tmpSubLevelValue[0]][$header] = $tmpSubLevelValue[1]; + } + } + + if (key_exists('sort', $indicateur)) { + if ($indicateur['sort'] == "asc") { + uksort($tmpDba, array($this, "classeSectionCompareAsc")); + } else { + uksort($tmpDba, array($this, "classeSectionCompareDesc")); + } + } + + foreach ($tmpDba as $cHeader => $value3) { + $tmp = explode('|', $cHeader); + $header = trim($tmp[1], "\""); + + $r++; + + $sheet->setCellValueExplicitByColumnAndRow(1, $r, html_entity_decode("• ", ENT_COMPAT | ENT_HTML401, 'UTF-8') . utf8_encode($header), PHPExcel_Cell_DataType::TYPE_STRING); + $sheet->getStyleByColumnAndRow(0, $r)->getAlignment()->applyFromArray($alignmentVT); + $sheet->getStyleByColumnAndRow(1, $r)->getAlignment()->applyFromArray($alignmentW); + + if ($this->is_odd($r)) { + $sheet->getStyle($this->cvt(1, $r, $nbDataCol + 1, $r))->getFill()->applyFromArray($dataOddFill); + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->getFill()->applyFromArray($totalOddFill); + $sheet->getStyle($this->cvt(1, $r, 2, $r))->getFill()->applyFromArray($totalOddFill); + } else { + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->getFill()->applyFromArray($totalEvenFill); + $sheet->getStyle($this->cvt(1, $r, 2, $r))->getFill()->applyFromArray($totalEvenFill); + } + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->applyFromArray($gras2); + + $rowNR = true; + $i = 2; + foreach ($iDataRes[$indicateurNom] as $header => $value) { + $sheet->setCellValueExplicitByColumnAndRow($i, $r, utf8_encode($value3[$header]), PHPExcel_Cell_DataType::TYPE_NUMERIC); + + if (isset($value3[$header])) { + $rowNR = false; + } + + $i++; + } + + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->getAlignment()->applyFromArray($alignmentHCVC); + if ($rowNR) { + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->applyFromArray($NRFont); + } else { + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->getNumberFormat()->setFormatCode($format); + } + } + break; + case 2: + foreach ($indicateur['e'] as $subChild) { + $r++; + + $sheet->setCellValueExplicitByColumnAndRow(1, $r, html_entity_decode("• ", ENT_COMPAT | ENT_HTML401, 'UTF-8') . utf8_encode($subChild['t']), PHPExcel_Cell_DataType::TYPE_STRING); + $sheet->getStyleByColumnAndRow(0, $r)->getAlignment()->applyFromArray($alignmentVT); + $sheet->getStyleByColumnAndRow(1, $r)->getAlignment()->applyFromArray($alignmentW); + + if ($this->is_odd($r)) { + $sheet->getStyle($this->cvt(1, $r, $nbDataCol + 1, $r))->getFill()->applyFromArray($dataOddFill); + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->getFill()->applyFromArray($totalOddFill); + $sheet->getStyle($this->cvt(1, $r, 2, $r))->getFill()->applyFromArray($totalOddFill); + } else { + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->getFill()->applyFromArray($totalEvenFill); + $sheet->getStyle($this->cvt(1, $r, 2, $r))->getFill()->applyFromArray($totalEvenFill); + } + $sheet->getStyleByColumnAndRow($nbDataCol + 1, $r)->applyFromArray($gras2); + + // clef "c" : commentaire de cellule. + if (key_exists('c', $subChild)) { + $sheet->getCommentByColumnAndRow(1, $r)->getText()->createTextRun(utf8_encode($subChild['c'])); + } + + // clef "v" : visibilité de ligne. + if (key_exists('v', $subChild)) { + $sheet->getRowDimension($r)->setVisible($subChild['v'] === 'true'); + } + + $rowNR = true; + $i = 2; + foreach ($iDataRes[$indicateurNom.'.'.$subChild['i']] as $header => $value) { + $sheet->setCellValueExplicitByColumnAndRow($i, $r, utf8_encode($value), PHPExcel_Cell_DataType::TYPE_NUMERIC); + + if (isset($value)) { + $rowNR = false; + } + + $i++; + } + + $subChildFormat = $format; + if (key_exists('f', $subChild)) { + $subChildFormat = html_entity_decode(utf8_encode($subChild['f']), ENT_COMPAT | ENT_HTML401, 'UTF-8'); + } + + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->getAlignment()->applyFromArray($alignmentHCVC); + if ($rowNR) { + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->applyFromArray($NRFont); + } else { + $sheet->getStyle($this->cvt(3, $r, $nbDataCol + 2, $r))->getNumberFormat()->setFormatCode($subChildFormat); + } + } + break; + default: + // Pas de comportement par défaut. + break; + } + + $r++; + } + } + } + } + $sheetIndex++; + } + + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); + //$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); + $objWriter->save($outputFile); + + return $outputFile; + } + + private function cvt($c, $r, $c1 = null, $r1 = null) { + if ($c1 == null) { + return PHPExcel_Calculation_LookupRef::CELL_ADDRESS($r, $c, 4); + } else { + return PHPExcel_Calculation_LookupRef::CELL_ADDRESS($r, $c, 4) . ':' . PHPExcel_Calculation_LookupRef::CELL_ADDRESS($r1, $c1, 4); + } + } + + private function is_odd($n) { + return (boolean) ($n % 2); + } + + public function classeSectionCompareAsc($s1, $s2) { + return $this->classeSectionCompare($s1, $s2, "asc"); + } + + public function classeSectionCompareDesc($s1, $s2) { + return $this->classeSectionCompare($s1, $s2, "desc"); + } + + private function classeSectionCompare($s1, $s2, $dir = "asc") { + $tmp1 = explode('|', $s1); + $a = trim($tmp1[0], "\""); + + $tmp2 = explode('|', $s2); + $b = trim($tmp2[0], "\""); + + if ($a == $b) { + $r = 0; + } else { + if ($dir == "asc") { + $r = ($a > $b) ? 1 : -1; + } else { + $r = ($b > $a) ? 1 : -1; + } + } + + return $r; + } + +} diff --git a/php/amfphp/services/CtiRhBilanSocialService.yaml b/php/amfphp/services/CtiRhBilanSocialService.yaml new file mode 100644 index 0000000..bf06b57 --- /dev/null +++ b/php/amfphp/services/CtiRhBilanSocialService.yaml @@ -0,0 +1,618 @@ +--- +bilanSocial2013: + - i: 1 + t: Emploi + xt: Emploi + o: w_bs_contrat + f: General + e: + - i: 1 + t: Effectif + e: + - i: a + t: Effectif total au 31/12 + c: "Effectif total : tout salarié inscrit à l'effectif au 31/12 quelle que soit la nature de son contrat de travail." + s: count(DISTINCT CASE WHEN mois_activite_id = @annee12 AND present_fin_mois = 1 THEN salarie_id ELSE null END) + - i: b + t: Effectif permanent + c: "Effectif permanent : les salariés à temps plein, inscrits à l'effectif pendant toute l'année considérée et titulaires d'un contrat de travail à durée indéterminée." + s: count(DISTINCT efp_salarie_id) + - i: c + t: Effectif mensuel moyen de l'année considérée + c: Somme des effectifs totaux mensuels/12 (on entend par effectif total tout salarié inscrit à l'effectif au dernier jour du mois considéré). + o: w_bs_contrat_mois + s: round(sum(nb_sal_fin_mois) / 12, 2) + - i: d + t: Répartition par sexe de l'effectif total au 31/12 + s: base.cti_d2_array_count_distinct(distinct array[sexe_code::text||'|'||sexe_texte::text, (CASE WHEN mois_activite_id = @annee12 AND present_fin_mois = 1 THEN salarie_id ELSE null END)::text]) + sort: asc + - i: e + t: Répartition par âge de l'effectif total au 31/12 + c: La répartition retenue est celle habituellement utilisée dans l'entreprise à condition de distinguer au moins quatre catégories, dont les jeunes de moins de vingt-cinq ans. + s: base.cti_d2_array_count_distinct(distinct array[age_section_code[@sequenceAge]::text||'|'||age_section_texte[@sequenceAge]::text, (CASE WHEN mois_activite_id = @annee12 AND present_fin_mois = 1 THEN salarie_id ELSE null END)::text]) + sort: asc + - i: f + t: Répartition de l'effectif total au 31/12 selon l'ancienneté + c: La répartition selon l'ancienneté est celle habituellement retenue dans l'entreprise. + s: base.cti_d2_array_count_distinct(distinct array[anciennete_annee_section_code[@sequenceAnc]::text||'|'||anciennete_annee_section_texte[@sequenceAnc]::text, (CASE WHEN mois_activite_id = @annee12 AND present_fin_mois = 1 THEN salarie_id ELSE null END)::text]) + sort: asc + - i: g + t: Répartition de l'effectif total au 31/12 selon la nationalité + s: base.cti_d2_array_count_distinct(distinct array[nationalite_section_code[9]::text||'|'||nationalite_section_texte[9]::text, (CASE WHEN mois_activite_id = @annee12 AND present_fin_mois = 1 THEN salarie_id ELSE null END)::text]) + sort: desc + - i: h + t: Répartition de l'effectif total au 31/12 selon une structure de qualification détaillée + s: count(DISTINCT CASE WHEN mois_activite_id = @annee12 AND present_fin_mois = 1 THEN salarie_id ELSE null END) + - i: 2 + t: Travailleurs extérieurs + e: + - i: a + t: Travailleurs extérieurs + - i: b + t: Nombre de salariés appartenant à une entreprise extérieure + c: "Il s'agit des catégories de travailleurs extérieurs dont l'entreprise connaît le nombre, soit parce qu'il figure dans le contrat signé avec l'entreprise extérieure, soit parce que ces travailleurs sont inscrits aux effectifs. Exemple : démonstrateurs dans le commerce..." + - i: c + t: Nombre de stagiaires (écoles, universités...) + c: Stages supérieurs à une semaine. + - i: d + t: Nombre moyen mensuel de salariés temporaires + c: Est considérée comme salarié temporaire toute personne mise à la disposition de l'entreprise, par une entreprise de travail temporaire. + - i: e + t: Durée moyenne des contrats de travail temporaire + - i: 3 + t: Embauches + e: + - i: a + t: Nombre d'embauches par contrats de travail à durée indéterminée + s: count(DISTINCT CASE WHEN nombre_entrees = 1 AND type_contrat_section_code[9] = 'CDI' THEN salarie_id ELSE null END) + - i: b + t: Nombre d'embauches par contrats de travail à durée déterminée (dont nombre de contrats de travailleurs saisonniers) + s: count(DISTINCT CASE WHEN nombre_entrees = 1 AND type_contrat_section_code[9] = 'CDD' THEN salarie_id ELSE null END) + - i: c + t: Nombre d'embauches de salariés de moins de vingt-cinq ans + s: count(DISTINCT CASE WHEN nombre_entrees = 1 AND age_section_code[@sequenceAge] = 'S1' THEN salarie_id ELSE null END) + - i: 4 + t: Départs + e: + - i: a + t: Total des départs + s: count(DISTINCT CASE WHEN nombre_departs = 1 THEN salarie_id ELSE null END) + - i: b + t: Nombre de démissions + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND motif_fin_section_code[9] = 'DEM' THEN contrat_id ELSE null END) + - i: c + t: Nombre de licenciements pour motif économique, dont départs en retraite et préretraite + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND motif_fin_section_code[9] = 'LRP' THEN contrat_id ELSE null END) + - i: d + t: Nombre de licenciements pour d'autres causes + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND motif_fin_section_code[9] = 'LAC' THEN contrat_id ELSE null END) + - i: e + t: Nombre de fins de contrats de travail à durée déterminée + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND type_contrat_section_code[9] = 'CDD' THEN contrat_id ELSE null END) + - i: f + t: Nombre de départs au cours de la période d'essai + c: À ne remplir que si ces départs sont comptabilisés dans le total des départs. + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND motif_fin_section_code[9] = 'DPE' THEN contrat_id ELSE null END) + - i: g + t: Nombre de mutations d'un établissement à un autre + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND motif_fin_section_code[9] = 'MUT' THEN contrat_id ELSE null END) + - i: h + t: Nombre de départs volontaires en retraite et préretraite + c: Distinguer les différents systèmes légaux et conventionnels de toute nature. + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND motif_fin_section_code[9] = 'RPR' THEN contrat_id ELSE null END) + - i: i + t: Nombre de décès + s: count(DISTINCT CASE WHEN nombre_fin_contrat = 1 AND motif_fin_section_code[9] = 'DEC' THEN contrat_id ELSE null END) + - i: 5 + t: Promotions + e: + - i: a + t: Nombre de salariés promus dans l'année dans une catégorie supérieure + c: Utiliser les catégories de la nomenclature détaillée + - i: 6 + t: Chômage + e: + - i: a + t: Nombre de salariés mis en chômage partiel pendant l'année considérée + - i: b + t: Nombre total d'heures de chômage partiel pendant l'année considérée + c: Y compris les heures indemnisées au titre du chômage total en cas d'arrêt de plus de quatre semaines consécutives. + e: + - i: 1 + t: Indemnisées + - i: 2 + t: Non indemnisées + - i: c + t: Nombre de salariés mis en chômage intempéries pendant l'année considérée + - i: d + t: Nombre total d'heures de chômage intempéries pendant l'année considérée + e: + - i: 1 + t: Indemnisées + - i: 2 + t: Non indemnisées + - i: 7 + t: Handicapés + o: w_bs_handicap + e: + - i: a + t: Nombre de travailleurs handicapés au 31 mars de l'année considérée + c: Tel qu'il résulte de la déclaration obligatoire prévue à l'article R.5212-2 du code du travail. + - i: b + t: Nombre de travailleurs handicapés à la suite d'accidents du travail intervenus dans l'entreprise, employés au 31 mars de l'année considérée + - i: 8 + t: Absentéisme + o: w_bs_arret_mois + e: + - i: a + t: Nombre de journées d'absence + c: "Ne sont pas comptés parmi les absences : les diverses sortes de congés, les conflits et le service national." + s: sum(CASE WHEN motif_arret_section_code[9] = 'ABS' THEN nb_jours_arret ELSE 0 END) + - i: b + t: Nombre de journées théoriques travaillées + - i: c + t: Nombre de journées d'absence pour maladie + s: sum(CASE WHEN motif_arret_section_code[9] = 'MAL' THEN nb_jours_arret ELSE 0 END) + - i: d + t: Répartition des absences pour maladie selon leur durée + c: Les tranches choisies sont laissées au choix des entreprises. + o: w_bs_arret_mal_duree + s: base.cti_d2_array_count_distinct(distinct array[tranche_duree::text, arret_travail_id::text]) + sort: asc + - i: e + t: Nombre de journées d'absence pour accidents du travail et de trajet ou maladies professionnelles + s: sum(CASE WHEN motif_arret_section_code[9] = 'ACT' THEN nb_jours_arret ELSE 0 END) + - i: f + t: Nombre de journées d'absence pour maternité + s: sum(CASE WHEN motif_arret_section_code[9] = 'MAT' THEN nb_jours_arret ELSE 0 END) + - i: g + t: Nombre de journées d'absence pour congés autorisés (événements familiaux, congés spéciaux pour les femmes...) + s: sum(CASE WHEN motif_arret_section_code[9] = 'COA' THEN nb_jours_arret ELSE 0 END) + - i: h + t: Nombre de journées d'absence imputables à d'autres causes + s: sum(CASE WHEN motif_arret_section_code[9] = 'AUT' THEN nb_jours_arret ELSE 0 END) + - i: 2 + t: Rémunérations + xt: Rémunérations et charges accessoires + o: w_bs_paie + f: "# ### ### ##0.00_-[$€ ]" + e: + - i: 1 + t: Montant des rémunérations + c: On entend par rémunération la somme des salaires effectivement perçus pendant l'année par le salarié (au sens de la déclaration annuelle des salaires). + e: + - i: a + t: Rapport entre la masse salariale annuelle et l'effectif mensuel moyen + c: Masse salariale annuelle totale, au sens de la déclaration annuelle de salaire. + o: w_bs_paie_mois + s: base.cti_division(sum(montant_masse_salariale), (sum(nb_cnt_sal_fin_mois) / 12)) + e: + - i: 1 + t: Somme de la masse salariale annuelle + o: w_bs_paie_mois + s: sum(montant_masse_salariale) + v: false + - i: 2 + t: Effectif mensuel moyen (cf. 1.1.c) + c: Somme des salarié ayant un contrat à fin de mois divisé par 12 + o: w_bs_paie_mois + s: sum(nb_cnt_sal_fin_mois) / 12 + f: "#" + v: false + - i: b + t: Rémunération moyenne du mois de décembre (effectif permanent) hors primes à périodicité non mensuelle - base 35 heures + s: | + sum(CASE WHEN 1=1 + AND mois_activite_id = @annee12 + AND efp_salarie_id IS NOT NULL + AND rubrique_id NOT IN ( + select to_id + from rh.t_listes + join rh.t_listes_contenu ON t_listes_contenu.liste_id = t_listes.oid + join rh.t_listes_tables ON t_listes_tables.oid = t_listes.table_id + WHERE 1=1 + AND t_listes_tables.code = 'RUP' + AND t_listes.code = 'CTI_BS_PPNM' + AND is_cti = '1' + ) + THEN montant_net_a_payer_salarie + ELSE 0 END + ) + - i: c + t: Rémunération mensuelle moyenne + c: "Rémunération mensuelle moyenne : 1/2 somme (masse salariale du mois i) / (effectif du mois i)." + o: w_bs_paie_mois + s: base.cti_division(sum(montant_masse_salariale), sum(nb_cnt_salarie_id)) + - i: d + t: Part des primes à périodicité non mensuelle dans la déclaration de salaire + s: | + base.cti_division( + sum(CASE WHEN + rubrique_id IN ( + select to_id + from rh.t_listes + join rh.t_listes_contenu ON t_listes_contenu.liste_id = t_listes.oid + join rh.t_listes_tables ON t_listes_tables.oid = t_listes.table_id + WHERE 1=1 + AND t_listes_tables.code = 'RUP' + AND t_listes.code = 'CTI_BS_PPNM' + AND is_cti = '1' + ) THEN montant_masse_salariale + ELSE 0 + END), + sum(montant_masse_salariale) + ) + f: "0.00%" + - i: e + t: Grille des rémunérations + c: Faire une grille des rémunérations en distinguant au moins six tranches. + - i: 2 + t: Hiérarchie des rémunérations + c: On entend par rémunération la somme des salaires effectivement perçus pendant l'année par le salarié (au sens de la déclaration annuelle des salaires). + o: w_bs_paie_special + e: + - i: a + t: Rapport entre la moyenne des rémunérations des 10 % des salariés touchant les rémunérations les plus élevées et celle correspondant au 10 % des salariés touchant les rémunérations les moins élevées + s: base.cti_division(avg(s10p), avg(s10m)) + f: "# ##0.##" + - i: b + t: Rapport entre la moyenne des rémunérations des cadres ou assimilés (y compris cadres supérieurs et dirigeants) et la moyenne des rémunérations des ouvriers non qualifiés ou assimilés + c: Pour être prises en compte, les catégories concernées doivent comporter au minimum dix salariés. + - i: c + t: Montant global des dix rémunérations les plus élevées + s: sum(m10p) + - i: 3 + t: Mode de calcul des rémunérations + e: + - i: a + t: Pourcentage des salariés dont le salaire dépend, en tout ou partie, du rendement + c: Distinguer les primes individuelles et les primes collectives. + - i: b + t: Pourcentage des ouvriers et employés payés au mois sur la base de l'horaire affiché + - i: 4 + t: Charges accessoires + e: + - i: a + t: Avantages sociaux dans l'entreprise + c: Pour chaque avantage préciser le niveau de garantie pour les catégories retenues pour les effectifs + e: + - i: 1 + t: Indemnisation de la maladie + - i: 2 + t: Indemnisation des jours fériés + - i: 3 + t: Préavis et indemnités de licenciement + - i: 4 + t: Préavis de démission + - i: 5 + t: Prime d'ancienneté + - i: 6 + t: Congé de maternité + - i: 7 + t: Congés payés + - i: 8 + t: Congés pour événements familiaux + - i: 9 + t: Primes de départ en retraite, etc. + - i: b + t: Montant des versements réalisés à des entreprises extérieures pour mise à la disposition de personnel + e: + - i: 1 + t: Entreprise de travail temporaire + - i: 2 + t: Autres entreprises + c: Prestataires de services, régies... + - i: 5 + t: Charge salariale globale + e: + - i: a + t: Frais de personnel + c: "Frais de personnel : ensemble des rémunérations et des cotisations sociales mises légalement ou conventionnellement à la charge de l'entreprise." + - i: b + t: Valeur ajoutée ou chiffre d'affaires. + - i: 6 + t: Participation financière des salariés + e: + - i: a + t: Montant global de la réserve de participation + c: Le montant global de la réserve de participation est le montant de la réserve dégagée - ou de la provision constituée - au titre de la participation sur les résultats de l'exercice considéré. + - i: b + t: Montant moyen de la participation et / ou de l'intéressement par salarié bénéficiaire + c: La participation est envisagée ici au sens du titre II du livre III de la partie III du code du travail. + - i: c + t: Part du capital détenu par les salariés grâce à un système de participation (participation aux résultats, intéressement, actionnariat...) + c: Non compris les dirigeants. + - i: 3 + t: Santé et sécurité + xt: Santé et sécurité au travail + e: + - i: 1 + t: Accidents de travail et de trajet + e: + - i: a + t: Taux de fréquence des accidents du travail + e: + - i: 1 + t: Nombre d'accidents avec arrêts de travail + - i: 2 + t: Nombre d'heures travaillées + - i: 3 + t: Nombre d'accidents de travail avec arrêt × 10^6 / Nombre d'heures travaillées + - i: b + t: Taux de gravité des accidents du travail + e: + - i: 1 + t: Nombre des journées perdues + - i: 2 + t: Nombre d'heures travaillées + - i: 3 + t: Nombre des journées perdues × 10^3 / Nombre d'heures travaillées + - i: c + t: Nombre d'incapacités permanentes (partielles et totales) notifiées à l'entreprise au cours de l'année considérée (distinguer français et étrangers) + todo: "FAIRE ICI en sorte qu'on ai part-fr, part-etr, tot-fr et top-etr" + - i: d + t: Nombre d'accidents mortels + e: + - i: 1 + t: De travail + - i: 2 + t: De trajet + - i: e + t: Nombre d'accidents de trajet ayant entraîné un arrêt de travail + - i: f + t: Nombre d'accidents dont sont victimes les salariés temporaires ou de prestations de services dans l'entreprise + - i: g + t: Cotisation sécurité sociale d'accidents de travail + e: + - i: 1 + t: Taux + - i: 2 + t: Montant + - i: 2 + t: Répartition des accidents par éléments matériels + c: Faire référence aux codes de classification des éléments matériels des accidents (arrêté du 10 octobre 1974). + e: + - i: a + t: Nombre d'accidents liés à l'existence de risques graves - codes 32 à 40 + - i: b + t: Nombre d'accidents liés à des chutes avec dénivellation - code 02 + - i: c + t: Nombre d'accidents occasionnés par des machines (à l'exception de ceux liés aux risques ci-dessus) - codes 09 à 30 + - i: d + t: Nombre d'accidents de circulation-manutention-stockage - codes 01, 03, 04 et 06, 07, 08 + - i: e + t: Nombre d'accidents occasionnés par des objets, masses, particules en mouvement accidentel - code 05 + - i: f + t: Autres cas + - i: 3 + t: Maladies professionnelles + e: + - i: a + t: Nombre et dénomination des maladies professionnelles déclarées à la sécurité sociale au cours de l'année + - i: b + t: Nombre de salariés atteints par des affections pathologiques à caractère professionnel et caractérisation de celles-ci + - i: c + t: Nombre de déclarations par l'employeur de procédés de travail susceptibles de provoquer des maladies professionnelles + c: En application de l'article L. 461-4 du code de la sécurité sociale. + - i: 4 + t: Comité d'hygiène, de sécurité et des conditions de travail + e: + - i: a + t: Existence et nombre de comité d'hygiène, de sécurité et des conditions de travail + - i: b + t: Nombre de réunions par comité d'hygiène, de sécurité et des conditions de travail + - i: 5 + t: Dépenses en matière de sécurité + e: + - i: a + t: Effectif formé à la sécurité dans l'année + - i: b + t: Montant des dépenses de formation à la sécurité réalisées dans l'entreprise + - i: c + t: Taux de réalisation du programme de sécurité présenté l'année précédente + - i: d + t: Existence et nombre de plans spécifiques de sécurité + - i: 4 + t: Autres conditions + xt: Autres conditions de travail + e: + - i: 1 + t: Durée et aménagement du temps de travail + e: + - i: a + t: Horaire hebdomadaire moyen affiché des ouvriers et employés ou catégories assimilées + c: Il est possible de remplacer cet indicateur par la somme des heures travaillées durant l'année. + - i: b + t: Nombre de salariés ayant bénéficié d'un repos compensateur + e: + - i: 1 + t: au titre du présent code + c: Au sens des dispositions du présent code et du code rural et de la pêche maritime instituant un repos compensateur en matière d'heures supplémentaires. + - i: 2 + t: au titre d'un régime conventionnel + - i: c + t: Nombre de salariés bénéficiant d'un système d'horaires individualisés + c: Au sens de l'article L.3122-23. + - i: d + t: Nombre de salariés employés à temps partiel + e: + - i: 1 + t: entre 20 et 30 heures + c: Au sens de l'article L.3123-1. + - i: 2 + t: autres formes de temps partiel + - i: e + t: Nombre de salariés ayant bénéficié tout au long de l'année considérée de deux jours de repos hebdomadaire consécutifs + - i: f + t: Nombre moyen de jours de congés annuels (non compris le repos compensateur) + c: Cet indicateur peut être calculé sur la dernière période de référence + - i: g + t: Nombre de jours fériés payés + c: Préciser, le cas échéant, les conditions restrictives. + - i: 2 + t: Organisation et contenu du travail + e: + - i: a + t: Nombre de personnes occupant des emplois à horaires alternant ou de nuit + - i: b + t: Nombre de personnes occupant des emplois à horaires alternant ou de nuit de plus de cinquante ans + - i: c + t: Salarié affecté à des tâches répétitives au sens de la définition du travail à la chaîne résultant du décret n° 76-404 du 10 mai 1976 (distinguer femmes-hommes). + c: | + "Article 70-3 c du décret du 29 décembre 1945 : Sont considérés comme travaux à la chaîne : + - les travaux effectués dans une organisation comportant un dispositif automatique d'avancement à cadence constante des pièces en cours de fabrication ou de montage en vue de la réalisation d'opérations élémentaires et successives aux différents postes de travail ; + - les travaux effectués sur des postes de travail indépendants consistant en la conduite ou l'approvisionnement de machines à cycle automatique et à cadence préréglée en vue de la réalisation d'opérations élémentaires et successives aux différents postes de travail ; + - les travaux effectués sur des postes indépendants sans dispositif automatique d'avancement des pièces où la cadence est imposée par le mode de rémunération ou le temps alloué pour chaque opération élémentaire." + - i: 3 + t: Conditions physiques de travail + e: + - i: a + t: Nombre de personnes exposées de façon habituelle et régulière à plus de 85 dbs à leur poste de travail + - i: b + t: Réaliser une carte du son par atelier + c: Cette carte n'est à réaliser que par les établissements qui ont une réponse non nulle à l'indicateur précédent. + - i: c + t: Nombre de salariés exposés à la chaleur au sens de la définition contenue dans le décret n° 76-404 du 10 mai 1976 + c: "Article 70-3 d du décret du 29 décembre 1945 : Sont considérés comme travaux au four, les travaux exposant de façon habituelle et régulière à une forte chaleur ambiante ou rayonnante résultant de l'utilisation d'un traitement thermique, d'un processus de cuisson, de la transformation de produits en état de fusion, d'ignition ou d'incandescence ou de la production d'énergie thermique." + - i: d + t: Nombre de salariés travaillant aux intempéries de façon habituelle et régulière, au sens de la définition contenue dans le décret n°76-404 du 10 mai 1976 + c: "Article 70-3 e du décret du 29 décembre 1945 : Sont considérés comme travaux exposant aux intempéries sur les chantiers, les travaux soumis au régime d'indemnisation définie aux articles L.5424-11 et suivants du code du travail ainsi que les travaux effectués de façon habituelle et régulière sur les chantiers souterrains ou subaquatiques, ou en plein air sur les constructions et ouvrages, les aires de stockage et de manutention." + - i: e + t: Nombre de prélèvements, d'analyses de produits toxiques et mesures + c: Renseignements tirés du rapport annuel du médecin du travail (arrêté du 10 décembre 1971). + - i: 4 + t: Transformation de l'organisation du travail + e: + - i: a + t: Expériences de transformation de l'organisation du travail en vue d'en améliorer le contenu + c: Pour l'explication de ces expériences d'amélioration du contenu du travail, donner le nombre de salariés concernés. + - i: 5 + t: Dépenses d'amélioration de conditions de travail + e: + - i: a + t: Montant des dépenses consacrées à l'amélioration des conditions de travail dans l'entreprise + c: Non compris l'évaluation des dépenses en matière de santé et de sécurité. + - i: b + t: Taux de réalisation du programme d'amélioration des conditions de travail dans l'entreprise l'année précédente. + - i: 6 + t: Médecine du travail + c: Renseignements tirés du rapport annuel du médecin du travail (arrêté du 10 décembre 1971). + e: + - i: a + t: Nombre d'examens cliniques (distinguer les travailleurs soumis à surveillance médicale et les autres) + - i: b + t: Nombre d'examens complémentaires (distinguer les travailleurs soumis à surveillance et les autres) + - i: c + t: Part du temps consacré par le médecin du travail à l'analyse et à l'intervention en milieu de travail + - i: 7 + t: Travailleurs inaptes + e: + - i: a + t: Nombre de salariés déclarés définitivement inaptes à leur emploi par le médecin du travail + - i: b + t: Nombre de salariés reclassés dans l'entreprise à la suite d'une inaptitude + - i: 5 + t: Formation + xt: Formation + e: + - i: 1 + t: Formation professionnelle continue + c: Conformément à la déclaration annuelle des employeurs 2483 relative au financement de la formation professionnelle continue. + e: + - i: a + t: Pourcentage de la masse salariale afférent à la formation continue. + - i: b + t: Montant consacré à la formation continue + - i: c + t: Formation interne ; formation effectuée en application de conventions ; versement à des fonds assurance formation ; versement auprès d'organismes agréés ; Trésor et autres ; total + - i: d + t: Nombre de stagiaires + - i: e + t: Nombre d'heures de stage + e: + - i: 1 + t: Rémunérées + - i: 2 + t: Non rémunérées + - i: f + t: "Décomposition par type de stages à titre d'exemple : adaptation, formation professionnelle, entretien ou perfectionnement des connaissances." + - i: 2 + t: Congés formation + e: + - i: a + t: Nombre de salariés ayant bénéficié d'un congé formation rémunéré + - i: b + t: Nombre de salariés ayant bénéficié d'un congé formation non rémunéré + - i: c + t: Nombre de salariés auxquels a été refusé un congé formation + - i: 3 + t: Apprentissage + e: + - i: a + t: Nombre de contrats d'apprentissage conclus dans l'année + - i: 6 + t: Relations + xt: Relations professionnelles + e: + - i: 1 + t: Représentants du personnel et délégués syndicaux + e: + - i: a + t: Composition des comités d'entreprise et/ou d'établissement avec indication, s'il y a lieu, de l'appartenance syndicale + - i: b + t: Participation aux élections (par collège) par catégories de représentants du personnel + - i: c + t: Volume global des crédits d'heures utilisés pendant l'année considérée + - i: d + t: Nombre de réunions avec les représentants du personnel et les délégués syndicaux pendant l'année considérée + - i: e + t: Dates et signatures et objet des accords conclus dans l'entreprise pendant l'année considérée + - i: f + t: Nombre de personnes bénéficiaires d'un congé d'éducation ouvrière + c: Au sens des articles L.3142-7 et suivants. + - i: 2 + t: Information et communication + e: + - i: a + t: Nombre d'heures consacrées aux différentes formes de réunion du personnel + c: On entend par réunion du personnel, les réunions régulières de concertation, concernant les relations et conditions de travail organisées par l'entreprise. + - i: b + t: Éléments caractéristiques du système d'accueil + - i: c + t: Éléments caractéristiques du système d'information ascendante ou descendante et niveau d'application. + - i: d + t: Éléments caractéristiques du système d'entretiens individuels + c: Préciser leur périodicité. + - i: 3 + t: Différends concernant l'application du droit du travail + c: Avec indication de la nature du différend et, le cas échéant, de la solution qui y a mis fin. + e: + - i: a + t: Nombre de recours à des modes de solution non juridictionnels engagés dans l'année + - i: b + t: Nombre d'instances judiciaires engagées dans l'année et où l'entreprise est en cause + - i: c + t: Nombre de mises en demeure et nombre de procès-verbaux de l'inspecteur du travail pendant l'année considérée + - i: 7 + t: Autres + xt: Autres conditions de vie relevant de l'entreprise + e: + - i: 1 + t: Activités sociales + e: + - i: a + t: Contributions au financement, le cas échéant, du comité d'entreprise et des comités d'établissement. + - i: b + t: "Autres dépenses directement supportées par l'entreprise : logement, transport, restauration, loisirs, vacances, divers, total" + c: Dépenses consolidées de l'entreprise. La répartition est indiquée ici à titre d'exemple. + - i: 2 + t: Autres charges sociales + e: + - i: a + t: Coût pour l'entreprise des prestations complémentaires (maladie, décès) + c: Versements directs ou par l'intermédiaire d'assurances. + - i: b + t: Coût pour l'entreprise des prestations complémentaires (vieillesse) + c: Versements directs ou par l'intermédiaire d'assurances. + - i: c + t: Équipements réalisés par l'entreprise et touchant aux conditions de vie des salariés à l'occasion de l'exécution du travail \ No newline at end of file diff --git a/php/httpService_RH_tableManager_copyRef.php b/php/httpService_RH_tableManager_copyRef.php new file mode 100644 index 0000000..7ad7917 --- /dev/null +++ b/php/httpService_RH_tableManager_copyRef.php @@ -0,0 +1,58 @@ +"; +$httpString = $httpString . "\n"; + +$database = new Database("iCTI"); + +$SETTINGS_file = rootDir() . "settings/settings.XML"; +$SETTINGS_xml = simplexml_load_file($SETTINGS_file); +$REFSETTINGS_URL = getProperty($SETTINGS_xml, "REFSETTINGS", 'URL'); +$REFSETTINGS_PREFIX = getProperty($SETTINGS_xml, "REFSETTINGS", 'PREFIX'); + +if ($REFSETTINGS_URL != "" && extension_loaded('curl')) { + + // Recherche script SQL depuis environnement de référence + $REFSETTINGS_table_url = "$REFSETTINGS_URL/modules/rh/php/httpService_RH_tableManager_getSqlScript.php"; + WebAppLog("","DEBUG",$REFSETTINGS_table_url); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $REFSETTINGS_table_url); + curl_setopt($ch, CURLOPT_POST, 2); + curl_setopt($ch, CURLOPT_POSTFIELDS, "tableName=$tableName&oids=$oids"); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + $REFSETTINGS_script = @curl_exec($ch); + curl_close($ch); + + if ($REFSETTINGS_script) { + $sqlcmd = $REFSETTINGS_script; + $result = $database->exec($sqlcmd); + } + +} + +$httpString = $httpString . "\n"; + + +$httpString = gzcompress($httpString,9); +$httpString = "_c_" . base64_encode($httpString); + +echo "$httpString"; + + + +?> \ No newline at end of file diff --git a/php/httpService_RH_tableManager_getSqlScript.php b/php/httpService_RH_tableManager_getSqlScript.php new file mode 100644 index 0000000..eb1596c --- /dev/null +++ b/php/httpService_RH_tableManager_getSqlScript.php @@ -0,0 +1,288 @@ + '' AND t_expert_controle.oid IN ($oids) + ORDER BY t_expert_controle.code + ;"; + + + $result = $database->exec($sqlcmd); + + if ($result != false) { + + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + + if ($record != FALSE) { + $ok = TRUE; + + $r++; + + $cmd = $record[0]; + + $sqlScript = $sqlScript . "\r\n\t\t$cmd"; + } + } + + } + + if ($cmd == "") { + return "ERREUR. Cette classe ne peux être choisie (Vérifiez le code)"; + } + + $sqlScript = $sqlScript . " + UPDATE rh.t_expert_controle SET + texte = w_dbsetup.texte, + texte_court = w_dbsetup.texte_court, + texte_abrege = w_dbsetup.texte_abrege, + description = w_dbsetup.description, + is_cti = w_dbsetup.is_cti, + is_global = w_dbsetup.is_global, + date_validite_debut = w_dbsetup.date_validite_debut::date, + date_validite_fin = w_dbsetup.date_validite_fin::date, + prestataire_id = COALESCE(t_prestataires.oid, -1) + FROM w_dbsetup + LEFT JOIN base.t_prestataires ON t_prestataires.code = w_dbsetup.prestataire_code + WHERE t_expert_controle.code = w_dbsetup.code + AND ( + t_expert_controle.texte IS DISTINCT FROM w_dbsetup.texte OR + t_expert_controle.texte_court IS DISTINCT FROM w_dbsetup.texte_court OR + t_expert_controle.texte_abrege IS DISTINCT FROM w_dbsetup.texte_abrege OR + t_expert_controle.description IS DISTINCT FROM w_dbsetup.description OR + t_expert_controle.is_cti IS DISTINCT FROM w_dbsetup.is_cti OR + t_expert_controle.is_global IS DISTINCT FROM w_dbsetup.is_global OR + t_expert_controle.date_validite_debut IS DISTINCT FROM w_dbsetup.date_validite_debut::date OR + t_expert_controle.date_validite_fin IS DISTINCT FROM w_dbsetup.date_validite_fin::date OR + t_expert_controle.prestataire_id IS DISTINCT FROM t_prestataires.oid + ); + + + + INSERT INTO rh.t_expert_controle( + code, + texte, + texte_court, + date_validite_debut, + date_validite_fin, + is_global, + texte_abrege, + description, + is_cti, + gravite_id, + is_hide, + prestataire_id) + SELECT + w_dbsetup.code, + w_dbsetup.texte, + w_dbsetup.texte_court, + w_dbsetup.date_validite_debut::date, + w_dbsetup.date_validite_fin::date, + w_dbsetup.is_global, + w_dbsetup.texte_abrege, + w_dbsetup.description, + w_dbsetup.is_cti, + 5, + '0', + COALESCE(t_prestataires.oid, -1) + FROM w_dbsetup + LEFT JOIN base.t_prestataires ON t_prestataires.code = w_dbsetup.prestataire_code + WHERE w_dbsetup.code NOT IN (SELECT code FROM rh.t_expert_controle WHERE code IS NOT NULL); + "; + + + + + + // Règles SQL + + $sqlScript = $sqlScript . " + DROP TABLE IF EXISTS w_dbsetup;"; + $sqlScript = $sqlScript . " + CREATE TEMP TABLE w_dbsetup + ( + controle_code text, + numero text, + sqlcmd_where text, + sqlcmd_justificatif text, + table_id text + );"; + + $sqlcmd = "SELECT + 'INSERT INTO w_dbsetup VALUES(' || + array_to_string(ARRAY[ + quote_literal(t_expert_controle.code), + quote_literal(COALESCE(t_expert_controle_rule.numero, 1)::text), + quote_literal(COALESCE(t_expert_controle_rule.sqlcmd_where, '')), + quote_literal(COALESCE(t_expert_controle_rule.sqlcmd_justificatif, '')), + quote_literal(COALESCE(t_expert_controle_rule.table_id, 0)::text) + ],',') + || ');' AS cmd + FROM rh.t_expert_controle_rule + JOIN rh.t_expert_controle ON controle_id = t_expert_controle.oid + WHERE t_expert_controle.code <> '' AND t_expert_controle.oid IN ($oids) + ORDER BY t_expert_controle.code, t_expert_controle_rule.numero + ;"; + + + $result = $database->exec($sqlcmd); + + if ($result != false) { + + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + + if ($record != FALSE) { + $ok = TRUE; + + $r++; + + $cmd = $record[0]; + + $sqlScript = $sqlScript . "\r\n\t\t$cmd"; + } + } + + } + + + $sqlScript = $sqlScript . " + UPDATE rh.t_expert_controle_rule + SET numero = 1 + WHERE numero IS NULL or NUMERO NOT IN (1,2,3); + + UPDATE rh.t_expert_controle_rule SET + sqlcmd_where = w_dbsetup.sqlcmd_where, + sqlcmd_justificatif = w_dbsetup.sqlcmd_justificatif, + table_id = w_dbsetup.table_id::bigint + FROM w_dbsetup + JOIN rh.t_expert_controle ON t_expert_controle.code = w_dbsetup.controle_code + WHERE t_expert_controle_rule.controle_id = t_expert_controle.oid AND + t_expert_controle_rule.numero = w_dbsetup.numero::numeric AND + ( + t_expert_controle_rule.sqlcmd_where IS DISTINCT FROM w_dbsetup.sqlcmd_where OR + t_expert_controle_rule.sqlcmd_justificatif IS DISTINCT FROM w_dbsetup.sqlcmd_justificatif OR + t_expert_controle_rule.table_id IS DISTINCT FROM w_dbsetup.table_id::bigint + ); + + INSERT INTO rh.t_expert_controle_rule ( + controle_id, + numero, + sqlcmd_where, + sqlcmd_justificatif, + table_id + ) + SELECT + t_expert_controle.oid, + w_dbsetup.numero::numeric, + w_dbsetup.sqlcmd_where, + w_dbsetup.sqlcmd_justificatif, + w_dbsetup.table_id::bigint + FROM w_dbsetup + JOIN rh.t_expert_controle ON t_expert_controle.code = w_dbsetup.controle_code + LEFT JOIN rh.t_expert_controle_rule ON + t_expert_controle_rule.controle_id = t_expert_controle.oid AND + t_expert_controle_rule.numero = w_dbsetup.numero::numeric + WHERE t_expert_controle_rule.oid IS NULL; + "; + + + + + + return $sqlScript; + + + +} + +?> \ No newline at end of file diff --git a/php/httpService_tablesManager_getData.php b/php/httpService_tablesManager_getData.php new file mode 100644 index 0000000..c391423 --- /dev/null +++ b/php/httpService_tablesManager_getData.php @@ -0,0 +1,1110 @@ +"; +$httpString .= "\n"; +if ($tableName == "t_expert_controle") { + if ($getOption != "getRefSettings") { + $httpString .= getRecords_expert_controle(); + } + else { + $httpString .= getRecords_expert_controle_refsettings($refPrefix); + } +} +else { + if ($schema != "" && $tableName != "") { + $httpString .= getRecords($database, $schema, $tableName); + } +} +$httpString .= "\n"; +if ($compress64) { + $httpString = compress64($httpString); +} +echo "$httpString"; + +// DEFINITIONS DE FONCTION + +/** + * + * @param Database $db + * @param string $schema + * @param string $tableName + * @return string + */ +function getRecords($db, $schema, $tableName) { + $httpString = ''; + $sqlColumnAdd = ''; + $sqlTableJoin = ''; + + + + // Gestion des colonnes supplémentaires. + switch ($tableName) { + case 't_rubriques' : + $tmpRubArray = array( + "nombre", + "base", + "heures_contrat", + "heures_payees", + "heures_travaillees", + "masse_salariale", + "brut", + "avantage_nature", + "frais_imposables", + "cotisation_salarie", + "cotisation_patronale", + "od_net_salarie", + "od_net_patronale", + "net_imposable", + "net_a_payer", + "nombre_provisions", + "montant_provisions", + "masse_salariale_provisionnee" + ); + + foreach ($tmpRubArray as $ind) { + $sqlColumnAdd .= ' + ,CASE WHEN (p_cumul OR p_detail) AND p_'.$ind.' THEN \'X\' ELSE \'\' END AS p_'.$ind.' + ,CASE WHEN (p_cumul OR p_detail) AND p_'.$ind.' THEN s_'.$ind.' ELSE null END AS s_'.$ind.' + ,CASE WHEN (p_cumul OR p_detail) AND p_'.$ind.' THEN c_'.$ind.' ELSE null END AS c_'.$ind.' + '; + } + + $sqlColumnAdd .= ' + ,code_calcul + ,unite + ,coefficient + ,coefficient_base + ,coefficient_nombre + ,coefficient_txs + ,coefficient_txp + ,CASE WHEN user_modified THEN \'M\' ELSE \'\' END AS user_modified + ,CASE WHEN p_cumul THEN \'C\' ELSE \'\' END AS p_cumul + ,CASE WHEN p_detail THEN \'D\' ELSE \'\' END AS p_detail + ,CASE WHEN proratiser_conversion THEN \'X\' ELSE \'\' END AS proratiser_conversion + '; + break; + case 't_etablissements' : + $sqlColumnAdd .= ',base_calcul_etp'; + $sqlColumnAdd .= ',planning_code'; + $sqlColumnAdd .= ',finess_id'; + break; + case 't_entreprises' : + $sqlColumnAdd .= ',planning_code'; + break; + case 't_planning_service' : + $sqlColumnAdd .= ",t_planning_service.service_id, COALESCE(t_services.code || ' ' || t_services.texte,'') AS service_paie_associe_texte"; + $sqlTableJoin = "LEFT JOIN rh.t_services ON $tableName.service_id = t_services.oid"; + break; + case 't_planning_qualification' : + $sqlColumnAdd .= ",t_planning_qualification.qualification_id, COALESCE(t_qualifications.code || ' ' || t_qualifications.texte,'') AS qualification_paie_associe_texte"; + $sqlTableJoin = "LEFT JOIN rh.t_qualifications ON $tableName.qualification_id = t_qualifications.oid"; + break; + case 't_population_regle' : + $sqlColumnAdd .= ',t_population_regle.oid'; + $sqlColumnAdd .= ',t_population_regle.code'; + $sqlColumnAdd .= ',t_population_regle.texte'; + $sqlColumnAdd .= ',t_population_regle.priorite'; + $sqlColumnAdd .= ',t_population_regle.population_id as population_id'; + $sqlColumnAdd .= ",t_population.code || ' '::text || t_population.texte as population_texte"; + $sqlColumnAdd .= ", CASE WHEN liste_finess <> '' THEN ' Fin:'::text || liste_finess ELSE ''::text END || + CASE WHEN liste_etablissement <> '' THEN ' Ets:'::text || liste_etablissement ELSE ''::text END || + CASE WHEN liste_service <> '' THEN ' Ser:'::text || liste_service ELSE ''::text END || + CASE WHEN liste_specialite <> '' THEN ' Spe:'::text || liste_specialite ELSE ''::text END || + CASE WHEN liste_section_analytique <> '' THEN ' Ana:'::text || liste_section_analytique ELSE ''::text END || + CASE WHEN liste_section_analytique_paie <> '' THEN ' AnaP:'::text || liste_section_analytique_paie ELSE ''::text END || + CASE WHEN liste_qualification <> '' THEN ' Qua:'::text || liste_qualification ELSE ''::text END || + CASE WHEN liste_grille <> '' THEN ' Grille:'::text || liste_grille ELSE ''::text END || + CASE WHEN liste_code_emploi <> '' THEN ' Emploi:'::text || liste_code_emploi ELSE ''::text END || + CASE WHEN liste_categorie_socio_professionnelle <> '' THEN ' Cat:'::text || liste_categorie_socio_professionnelle ELSE ''::text END || + CASE WHEN liste_statut <> '' THEN ' Statut:'::text || liste_statut ELSE ''::text END + as regle_resume"; + $sqlColumnAdd .= ',liste_finess'; + $sqlColumnAdd .= ',liste_etablissement'; + $sqlColumnAdd .= ',liste_service'; + $sqlColumnAdd .= ',liste_specialite'; + $sqlColumnAdd .= ',liste_section_analytique'; + $sqlColumnAdd .= ',liste_section_analytique_paie'; + $sqlColumnAdd .= ',liste_qualification'; + $sqlColumnAdd .= ',liste_grille'; + $sqlColumnAdd .= ',liste_code_emploi'; + $sqlColumnAdd .= ',liste_categorie_socio_professionnelle'; + $sqlColumnAdd .= ',liste_statut'; + $sqlTableJoin = "LEFT JOIN rh.t_population ON t_population_regle.population_id = t_population.oid"; + break; + } + + // Gestion de la requête exécuter. + switch ($tableName) { + case 't_divers' : + $sqlcmd = " + SELECT + code, + texte, + valeur, + valeur_date, + description, + CASE WHEN show_info_module THEN 1 ELSE 0 END AS show_info_module + FROM $schema.$tableName + ORDER BY code + "; + break; + case 't_transformation' : + $sqlcmd = " + SELECT + t_transformation.oid, + t_transformation.texte, + TRIM( + CASE WHEN t_transformation.date_debut > '00010101' THEN to_char(t_transformation.date_debut,'MM-YYYY') ELSE '' END || + CASE WHEN t_transformation.date_debut > '00010101' AND t_transformation.date_fin < '20990101' THEN ' à ' ELSE '' END || + CASE WHEN t_transformation.date_fin < '20990101' THEN to_char(t_transformation.date_fin,'MM-YYYY') ELSE '' END + ) AS texte_date, + TRIM( + CASE WHEN salarie_id <> -1 THEN ' Salarié ' || p_salaries.nom || ' ' || p_salaries.prenom || ' (' || matricule || ')' ELSE '' END || + CASE WHEN from_service_id <> -1 THEN ' Serv ' || t_services_from.texte || ' (' || t_services_from.code || ')' ELSE '' END || + CASE WHEN from_qualification_id <> -1 THEN ' Qualif ' || t_qualifications_from.texte || ' (' || t_qualifications_from.code || ')' ELSE '' END + ) AS texte_from, + TRIM( + CASE WHEN to_service_id <> -1 AND to_service_id <> from_service_id THEN ' Serv ' || t_services_to.texte || ' (' || t_services_to.code || ')' ELSE '' END || + CASE WHEN to_qualification_id <> -1 AND to_qualification_id <> from_qualification_id THEN ' Qualif ' || t_qualifications_to.texte || ' (' || t_qualifications_to.code || ')' ELSE '' END + ) AS texte_to, + t_transformation.date_debut, + t_transformation.date_fin, + t_transformation.salarie_id, + t_transformation.from_service_id, + t_transformation.to_service_id, + t_transformation.from_qualification_id, + t_transformation.to_qualification_id + FROM rh.t_transformation + LEFT JOIN rh.p_salaries ON salarie_id = p_salaries.oid + LEFT JOIN rh.t_services t_services_from ON from_service_id = t_services_from.oid + LEFT JOIN rh.t_services t_services_to ON to_service_id = t_services_to.oid + LEFT JOIN rh.t_qualifications t_qualifications_from ON from_qualification_id = t_qualifications_from.oid + LEFT JOIN rh.t_qualifications t_qualifications_to ON to_qualification_id = t_qualifications_to.oid + ORDER BY 4,5 + "; + break; + case 't_data_profile' : + $sqlcmd = " + SELECT oid, code, texte, texte_court, + TRIM( + CASE WHEN etablissement_inclus <> '' AND etablissement_inclus IS NOT NULL + THEN ' Etablissements ' || etablissement_inclus || + CASE WHEN etablissement_exclus <> '' AND etablissement_exclus IS NOT NULL THEN ' sauf ' || etablissement_exclus ELSE '' END + ELSE '' END + || + CASE WHEN service_inclus <> '' AND service_inclus IS NOT NULL + THEN ' Services ' || service_inclus || + CASE WHEN service_exclus <> '' AND service_exclus IS NOT NULL THEN ' sauf ' || service_exclus ELSE '' END + ELSE '' END + || + CASE WHEN statut_inclus <> '' AND statut_inclus IS NOT NULL + THEN ' Statuts ' || statut_inclus || + CASE WHEN statut_exclus <> '' AND statut_exclus IS NOT NULL THEN ' sauf ' || statut_exclus ELSE '' END + ELSE '' END + ) AS regles, + etablissement_inclus, + etablissement_exclus, + service_inclus, + service_exclus, + statut_inclus, + statut_exclus + FROM rh.t_data_profile + WHERE oid > 0 + ORDER BY code + "; + break; + case 't_population' : + $sqlcmd = " + SELECT + $tableName.oid + ,$tableName.code + ,$tableName.texte + ,$tableName.texte_court + FROM $schema.$tableName + WHERE $tableName.oid > 0 + ORDER BY code + "; + break; + case 't_population_regle' : + $sqlcmd = " + SELECT + $tableName.oid + ,$tableName.code + ,$tableName.texte + $sqlColumnAdd + FROM $schema.$tableName + $sqlTableJoin + WHERE $tableName.oid > 0 + ORDER BY code + "; + break; + default : + $sqlcmd = " + SELECT + $tableName.oid + ,$tableName.code + ,$tableName.texte + ,$tableName.texte_court + ,$tableName.code_original + $sqlColumnAdd + FROM $schema.$tableName + $sqlTableJoin + WHERE $tableName.oid > 0 + ORDER BY code + "; + break; + } + + $result = $db->exec($sqlcmd); + + if ($result != false) { + // lignes + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $nbref = 0; + $httpString .= "\r\nexec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $httpString .= "\n"; + } + } + } + $httpString .= "\n"; + + + return $httpString; +} + +function getCombos_rh_transformation($db) { + + $httpString = ""; + + $httpString_sa = "\r\n"; + $httpString_sa .= "\r\n"; + $sqlcmd = "SELECT oid, nom || ' ' || prenom || ' ('::text || matricule || ')'::text AS texte FROM rh.p_salaries WHERE oid >= 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString_sa .= "\r\n"; + } + } + } + $httpString_sa .= "\r\n"; + + + $httpString_fs = "\r\n"; + $httpString_fs .= "\r\n"; + $httpString_ts = "\r\n"; + $httpString_ts .= "\r\n"; + $sqlcmd = "SELECT oid, texte || ' ('::text || code || ')'::text AS texte FROM rh.t_services WHERE oid >= 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString_fs .= "\r\n"; + $httpString_ts .= "\r\n"; + } + } + } + $httpString_fs .= "\r\n"; + $httpString_ts .= "\r\n"; + + $httpString_fq = "\r\n"; + $httpString_fq .= "\r\n"; + $httpString_tq = "\r\n"; + $httpString_tq .= "\r\n"; + $sqlcmd = "SELECT oid, texte || ' ('::text || code || ')'::text AS texte FROM rh.t_qualifications WHERE oid >= 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString_fq .= "\r\n"; + $httpString_tq .= "\r\n"; + } + } + } + $httpString_fq .= "\r\n"; + $httpString_tq .= "\r\n"; + + $httpString_fd = "\r\n"; + $httpString_fd .= "\r\n"; + $httpString_td = "\r\n"; + $httpString_td .= "\r\n"; + $sqlcmd = "SELECT p_calendrier_annee.date_debut, p_calendrier_annee.date_fin, p_calendrier_annee.texte + FROM rh.p_chiffrier_production + JOIN base.p_calendrier_mois ON (p_chiffrier_production.mois = p_calendrier_mois.mois) + JOIN base.p_calendrier_mois p_calendrier_annee ON (p_calendrier_annee.annee = p_calendrier_mois.annee) + GROUP BY 1,2,3 + ORDER BY 1 DESC"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $date_debut = $record["date_debut"]; + $date_fin = $record["date_fin"]; + $texte = toHTML(trim($record["texte"])); + $httpString_fd .= "\r\n"; + $httpString_td .= "\r\n"; + } + } + } + $httpString_fd .= "\r\n"; + $httpString_td .= "\r\n"; + + + + return $httpString_sa.$httpString_fs.$httpString_ts.$httpString_fq.$httpString_tq.$httpString_fd.$httpString_td; +} + +function getCombos_rh_planning_service($db) { + + $httpString = ""; + + $httpString = "\r\n"; + $httpString .= "\r\n"; + $sqlcmd = "SELECT oid, code || ' '::text || texte AS texte FROM rh.t_services WHERE oid > 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString .= "\r\n"; + } + } + } + $httpString .= "\r\n"; + + + return $httpString; +} + +function getCombos_rh_planning_qualification($db) { + + $httpString = ""; + + $httpString = "\r\n"; + $httpString .= "\r\n"; + $sqlcmd = "SELECT oid, code || ' '::text || texte AS texte FROM rh.t_qualifications WHERE oid > 0 ORDER BY 2"; + $result = $db->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString .= "\r\n"; + } + } + } + $httpString .= "\r\n"; + + + return $httpString; +} + +function getCombos_rh_finess($db) { + + $httpString = "\r\n"; + $httpString .= "\r\n"; + + $sqlcmd = "SELECT oid, code || ' '::text || texte AS texte FROM base.t_finess WHERE oid > 0 ORDER BY 2 "; + $result = $db->exec($sqlcmd); + + if ($result != false) { + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordAssoc(); + if ($record != FALSE) { + $ok = TRUE; + $oid = $record["oid"]; + $texte = toHTML(trim($record["texte"])); + $httpString .= "\r\n"; + } + } + } + $httpString .= "\r\n"; + + return $httpString; +} + +function getCombo_population($db) { + $httpString = "\r\n\r\n"; + + $sqlcmd = "SELECT oid, code::text || ' '::text || texte::text FROM rh.t_population WHERE oid > 0 ORDER BY code"; + $result = $db->exec($sqlcmd); + + if ($result != false) { + // lignes + $ok = TRUE; + while ($ok == TRUE) { + $ok = FALSE; + $record = $db->nextRecordInto(); + if ($record != FALSE) { + $ok = TRUE; + + $oid = $record[0]; + $texte = toHTML(trim($record[1])); + + $httpString .= "\r\n"; + } + } + } + + $httpString .= "\r\n"; + + return $httpString; +} + + +function getRecords_expert_controle() { + +global $database; + + $httpString = ""; + $httpString_tmp = ""; + + // Activation module EXPERT + $sqlcmd = " + INSERT INTO rh.t_divers (code, texte, valeur, description) + SELECT + 'EXPERT_ACTIVE', + 'Module EXPERT activ?', + '0', + '1=Activ?' + WHERE 'EXPERT_ACTIVE' NOT IN (SELECT code FROM rh.t_divers); + INSERT INTO rh.t_divers (code, texte, valeur, description, valeur_date) + SELECT + 'EXPERT_DATE_DEBUT', + 'Date données à contrôler', + '20130101', + 'Date de début des données à contrôler', + '20130101' + WHERE 'EXPERT_DATE_DEBUT' NOT IN (SELECT code FROM rh.t_divers);"; + $result = $database->exec($sqlcmd); + + // Correction données antérieures + $sqlcmd = "UPDATE rh.t_expert_controle_rule + SET numero = 1 + WHERE numero NOT IN (1,2,3) OR numero IS NULL; + + UPDATE rh.t_expert_controle + SET gravite_id = 5 + WHERE gravite_id NOT IN (0,5,9) OR gravite_id IS NULL;"; + + $result = $database->exec($sqlcmd); + + // Paramétres généraux + $EXPERT_ACTIVE = "0"; + $EXPERT_DATE_DEBUT = "2013-01-01"; + + $sqlcmd = "SELECT code, valeur, to_char(valeur_date,'DD/MM/YYYY') + FROM rh.t_divers + WHERE code LIKE 'EXPERT%'"; + $result = $database->exec($sqlcmd); + if ($result != false) { + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + if ($record != FALSE) { + $ok = TRUE; + + switch(trim($record[0])) { + case "EXPERT_ACTIVE" : + $EXPERT_ACTIVE = trim($record[1]); + break; + case "EXPERT_DATE_DEBUT" : + $EXPERT_DATE_DEBUT = trim($record[2]); + break; + } + } + } + } + + // Chargement des Prestataires RH + $sqlcmd = " + (SELECT + -1 as oid, + 'Tous'::text as texte, + 0 as tri + UNION + SELECT + oid, + texte, + 1 as tri + FROM base.t_prestataires + WHERE 'rh' = ANY (modules) + ) + ORDER BY tri,texte"; + $result = $database->exec($sqlcmd); + + if ($result !== false) { + + while ($row = pg_fetch_array($result)) { + + $oid = $row['oid']; + $texte = $row['texte']; + + $httpString .= "" . PHP_EOL; + } + } + + $httpString_tmp .= ""; + + // Liste des controles + $sqlcmd = "SELECT + t_expert_controle.oid as controle_id, + t_expert_controle.code as controle_code, + t_expert_controle.texte as controle_texte, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte) as controle_texte_court, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte,t_expert_controle.texte_abrege) as controle_texte_abrege, + t_expert_controle.description as controle_description, + t_expert_controle.is_cti as controle_is_cti, + t_expert_controle.is_hide as controle_is_hide, + t_expert_controle.gravite_id as controle_gravite, + t_expert_controle.prestataire_id, + t_expert_controle.is_active as controle_is_active, + COALESCE(t_prestataires.texte, 'Tous') as prestataire_texte, + COALESCE(t_expert_controle_rule_1.oid,0) as rule1_oid, + COALESCE(t_expert_controle_rule_1.sqlcmd_where) as rule1_sqlcmd_where, + COALESCE(t_expert_controle_rule_1.sqlcmd_justificatif) as rule1_sqlcmd_justificatif, + COALESCE(TO_CHAR(t_expert_controle_rule_1.last_execution_date,'DD/MM/YYYY'),'') as rule1_last_execution_date, + COALESCE(t_expert_controle_rule_1.last_execution_ok) as rule1_last_execution_ok, + COALESCE(t_expert_controle_rule_1.table_id,0) as rule1_table_id, + COALESCE(subview.nbref, 0) as nb_ref, + COALESCE(t_expert_controle.alert_exp,'0') as is_alert + FROM rh.t_expert_controle + LEFT JOIN base.t_prestataires ON t_prestataires.oid = t_expert_controle.prestataire_id + LEFT JOIN rh.t_expert_controle_rule t_expert_controle_rule_1 ON t_expert_controle_rule_1.controle_id = t_expert_controle.oid AND t_expert_controle_rule_1.numero = 1 + LEFT JOIN (SELECT controle_id, count(*) AS nbref FROM rh.p_expert_controle GROUP BY 1) subview ON t_expert_controle.oid = subview.controle_id + WHERE t_expert_controle.oid > 0 AND is_global <> 1 + ORDER BY t_expert_controle.code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordAssoc(); + + if ($record != FALSE) { + $ok = TRUE; + + $oid = $record['controle_id']; + $code = toHTML(trim($record['controle_code'])); + $texte = toHTML(trim($record['controle_texte'])); + $texte_court = toHTML(trim($record['controle_texte_court'])); + $texte_abrege = toHTML(trim($record['controle_texte_abrege'])); + $description = toHTML(trim($record['controle_description'])); + $is_cti = toHTML(trim($record['controle_is_cti'])); + $is_active = toHTML(trim($record['controle_is_active'])); + $is_hide = toHTML(trim($record['controle_is_hide'])); + $gravite = floatval(trim($record['controle_gravite'])); + $rule_oid1 = floatval(trim($record['rule1_oid'])); + $sqlcmd_where1 = toHTML(trim($record['rule1_sqlcmd_where'])); + $sqlcmd_justificatif1 = toHTML(trim($record['rule1_sqlcmd_justificatif'])); + $table1 = floatval(trim($record['rule1_table_id'])); + $nbref = floatval(trim($record['nb_ref'])); + $last_execution_date = trim($record['rule1_last_execution_date']); + $last_execution_ok = floatval(trim($record['rule1_last_execution_ok'])); + $prestataire_id = floatval(trim($record['prestataire_id'])); + $prestataire_texte = toHTML(trim($record['prestataire_texte'])); + $is_alert = toHTML(trim($record['is_alert'])); + + if ($last_execution_date == "") { + $last_execution_date = "jamais exécuté"; + $last_execution_ok = ""; + } + else { + if ($last_execution_ok == "1") { + $last_execution_ok = "OK"; + } + if ($last_execution_ok == "0") { + $last_execution_ok = "KO"; + } + } + + $complement = ""; + if ($is_cti == "1") { + $complement = "$complement CTI"; + } + else { + $is_cti = "0"; + } + if ($is_hide == "1") { + $complement = "$complement Masqu?"; + } + else { + $is_hide = "0"; + } + if ($is_alert == "1") { + $complement = "$complement Alerte"; + } + else { + $is_alert = "0"; + } + if ($gravite == 0) { + $gravite_texte = "INFO"; + } + else { + if ($gravite == 9) { + $gravite_texte = "ERREUR"; + } + else { + $gravite_texte = "ATT"; + } + } + $is_active_texte = $is_active == "1" ? "Actif" : "Inactif"; + + $md5_def = refmd5("$code$texte$texte_court$texte_abrege$description$is_cti$prestataire_id"); + $md5_sql = refmd5("$code$sqlcmd_where1$sqlcmd_justificatif1$table1"); + + $httpString_tmp .= " + "; + + if (strlen($httpString_tmp) > 64000) { + $httpString .= $httpString_tmp; + $httpString_tmp = ""; + } + } + } + } + + $httpString .= $httpString_tmp; + + // R?f?rence + $httpString .= getRefSettings("t_expert_controle", $httpString); + + return $httpString; +} + +function getRecords_expert_controle_refsettings($refPrefix) { + +global $database; + + $httpString = ""; + $httpString_tmp = ""; + + // Liste des controles + $sqlcmd = "SELECT + t_expert_controle.oid AS controle_id, + t_expert_controle.code AS controle_code, + t_expert_controle.texte AS controle_texte, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte) AS controle_texte_court, + COALESCE(t_expert_controle.texte_court,t_expert_controle.texte,t_expert_controle.texte_abrege) AS controle_texte_abrege, + t_expert_controle.description AS controle_description, + t_expert_controle.is_cti AS controle_is_cti, + t_expert_controle.is_hide AS controle_is_hide, + t_expert_controle.gravite_id AS controle_gravite, + t_expert_controle.prestataire_id, + COALESCE(t_prestataires.texte, 'Tous') as prestataire_texte, + COALESCE(t_expert_controle_rule_1.oid,0) AS rule1_oid, + COALESCE(t_expert_controle_rule_1.sqlcmd_where) AS rule1_sqlcmd_where, + COALESCE(t_expert_controle_rule_1.sqlcmd_justificatif) AS rule1_sqlcmd_justificatif, + COALESCE(TO_CHAR(t_expert_controle_rule_1.last_execution_date,'DD/MM/YYYY'),'') AS rule1_last_execution_date, + COALESCE(t_expert_controle_rule_1.last_execution_ok) AS rule1_last_execution_ok, + COALESCE(t_expert_controle_rule_1.table_id,0) AS rule1_table_id, + t_expert_controle.alert_exp as is_alert + FROM rh.t_expert_controle + LEFT JOIN base.t_prestataires ON t_prestataires.oid = t_expert_controle.prestataire_id + LEFT JOIN rh.t_expert_controle_rule t_expert_controle_rule_1 ON t_expert_controle_rule_1.controle_id = t_expert_controle.oid AND t_expert_controle_rule_1.numero = 1 + WHERE t_expert_controle.oid > 0 AND is_global <> 1 AND t_expert_controle.code ILIKE '$refPrefix%' + ORDER BY t_expert_controle.code"; + $result = $database->exec($sqlcmd); + + if ($result != false) { + + // lignes + $ok = TRUE; + + while ($ok == TRUE) { + $ok = FALSE; + + $record = $database->nextRecordInto(); + + if ($record != FALSE) { + $ok = TRUE; + + $oid = $record['controle_id']; + $code = toHTML(trim($record['controle_code'])); + $texte = toHTML(trim($record['controle_texte'])); + $texte_court = toHTML(trim($record['controle_texte_court'])); + $texte_abrege = toHTML(trim($record['controle_texte_abrege'])); + $description = toHTML(trim($record['controle_description'])); + $is_cti = toHTML(trim($record['controle_is_cti'])); + $is_hide = toHTML(trim($record['controle_is_hide'])); + $gravite = floatval(trim($record['controle_gravite'])); + $rule_oid1 = floatval(trim($record['rule1_oid'])); + $sqlcmd_where1 = toHTML(trim($record['rule1_sqlcmd_where'])); + $sqlcmd_justificatif1 = toHTML(trim($record['rule1_sqlcmd_justificatif'])); + $last_execution_date = toHTML(trim($record['rule1_last_execution_date'])); + $last_execution_ok = toHTML(trim($record['rule1_last_execution_ok'])); + $table1 = floatval(trim($record['rule1_table_id'])); + $prestataire_id = floatval(trim($record['prestataire_id'])); + $prestataire_texte = toHTML(trim($record['prestataire_texte'])); + $is_alert = toHTML(trim($record['is_alert'])); + + if ($last_execution_date == "") { + $last_execution_ok = ""; + } + else { + if ($last_execution_ok == "1") { + $last_execution_ok = "OK"; + } + if ($last_execution_ok == "0") { + $last_execution_ok = "KO"; + } + } + + $complement = ""; + if ($is_cti == "1") { + $complement = "$complement CTI"; + } + else { + $is_cti = "0"; + } + if ($is_hide == "1") { + $complement = "$complement Masqu?"; + } + else { + $is_hide = "0"; + } + if ($gravite == 0) { + $gravite_texte = "INFO"; + } + else { + if ($gravite == 9) { + $gravite_texte = "ERREUR"; + } + else { + $gravite_texte = "ATT"; + } + } + $complement = trim($complement); + + $md5_def = refmd5("$code$texte$texte_court$texte_abrege$description$is_cti$prestataire_id"); + $md5_sql = refmd5("$code$sqlcmd_where1$sqlcmd_justificatif1$table1"); + + $httpString_tmp .= " + "; + + if (strlen($httpString_tmp) > 64000) { + $httpString .= $httpString_tmp; + $httpString_tmp = ""; + } + } + } + } + + $httpString .= $httpString_tmp; + return $httpString; +} + +function refmd5($string) { + $string = str_replace("\r","",$string); + $string = str_replace("\n","",$string); + $string = md5(trim($string)); + return $string; +} + +// recherche des listes de r?ference +function getRefSettings($tableName, $httpString_base) { + + global $getOption; + + $httpString = ""; + + $SETTINGS_file = rootDir() . "settings/settings.XML"; + $SETTINGS_xml = simplexml_load_file($SETTINGS_file); + $REFSETTINGS_URL = getProperty($SETTINGS_xml, "REFSETTINGS", 'URL'); + $REFSETTINGS_PREFIX = getProperty($SETTINGS_xml, "REFSETTINGS", 'PREFIX'); + + if ($REFSETTINGS_URL != "" && extension_loaded('curl')) { + + // Recherche des indicateurs de l'environnement de r?f?rence + $REFSETTINGS_table_url = "$REFSETTINGS_URL/modules/rh/php/RH_getTableRecords.php"; + + // Recherche http pour indicateurs + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $REFSETTINGS_table_url); + curl_setopt($ch, CURLOPT_POST, 2); + curl_setopt($ch, CURLOPT_POSTFIELDS, "tableName=$tableName&getOption=getRefSettings&refPrefix=$REFSETTINGS_PREFIX"); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + $REFSETTINGS_data = @curl_exec($ch); + curl_close($ch); + + if ($REFSETTINGS_data) { + + if (substr($REFSETTINGS_data, 0, 12) == "") { + $REFSETTINGS_data = substr($REFSETTINGS_data, 12, strlen($REFSETTINGS_data) - 25); + } + + $REFSETTINGS_data = uncompress($REFSETTINGS_data); + $REFSETTINGS_data = str_replace("","",$REFSETTINGS_data); + $REFSETTINGS_xml = simplexml_load_string($REFSETTINGS_data); + if ($REFSETTINGS_xml) { + + foreach ($REFSETTINGS_xml->REFRECORD as $recordNode) { + $md5_def = trim($recordNode["md5_def"]); + $md5_sql = trim($recordNode["md5_sql"]); + $recordNode["ok"] = ""; + if (stripos($httpString_base, $md5_def) === false) { + $recordNode["ok"] = "D?finition"; + } + if (stripos($httpString_base, $md5_sql) === false) { + $recordNode["ok"] = "R?gles"; + } + //if ($recordNode["ok"] != "") { + $httpString .= $recordNode->asXML(); + //} + } + } + } + } + return $httpString; +} + + +?> \ No newline at end of file diff --git a/php/httpService_tablesManager_setData.php b/php/httpService_tablesManager_setData.php new file mode 100644 index 0000000..62b6614 --- /dev/null +++ b/php/httpService_tablesManager_setData.php @@ -0,0 +1,689 @@ + 'type_contrat', + 't_motifs_debut_contrat' => 'motif_debut', + 't_motifs_fin_contrat' => 'motif_fin', + 't_qualifications' => 'qualification', + 't_services' => 'service', + 't_specialites' => 'specialite', + 't_types_temps_travail' => 'type_temps_travail', + 't_categories_socio_professionnelle' => 'categorie_socio_professionnelle', + 't_statuts' => 'statut', + 't_codes_emploi' => 'code_emploi', + 't_societes_interim' => 'societe_interim', + 't_sections_analytiques_paie' => 'section_analytique_paie', + 't_sections_analytiques' => 'section_analytique', + 't_grilles' => 'grille', + 't_grilles_groupes' => 'grille_groupe', + 't_types_horaire' => 'type_horaire', + 't_groupes_cotisant' => 'groupe_cotisant', + 't_cadre_emploi' => 'cadre_emploi', + 't_categorie_conge' => 'categorie_conge', + 't_categorie_statutaire' => 'categorie_statutaire', + 't_commission_paritaire' => 'commission_paritaire', + 't_compte_imputation' => 'compte_imputation', + 't_filiere' => 'filiere', + 't_lettre_budgetaire' => 'lettre_budgetaire', + 't_unite_fonctionnelle' => 'unite_fonctionnelle' +); + +// RECUPERATION DES PARAMETRES HTTP +$softCode = getPOST("softCode"); +$tableName = getPOST("tableName"); +$action = getPOST("action"); +$recordXML = getPOST("recordNode"); + +$recordNode = @simplexml_load_string($recordXML); + +// ECRITURE DE LA REPONSE HTTP +$httpString = ""; +$httpString .= "\n"; +if ($schema != "" && $tableName != "" && $action != "" && $recordNode !== FALSE) { + $httpString .= setRecords($database, $schema, $tableName, $action, $recordNode); +} +if ($action === PER_EXECUTE_RULES) { + $sqlcmd = "SELECT $schema.cti_reorganize_population();"; + $result = $database->exec($sqlcmd); +} +$httpString .= "\n"; +if ($compress64) { + $httpString = compress64($httpString); +} +echo "$httpString"; + +// DEFINITIONS DE FONCTION + +/** + * + * @param Database $db + * @param string $schema + * @param string $tableName + * @param string $action + * @param object $recordNode + */ +function setRecords($db, $schema, $tableName, $action, $recordNode) { + global $rh_profil_tables; + + $oid = floatval($recordNode["oid"]); + $code = utf8_decode($recordNode["code"]); + $texte = utf8_decode($recordNode["texte"]); + $texte_court = utf8_decode($recordNode["texte_court"]); + $code_original = utf8_decode($recordNode["code_original"]); + + switch ($action) { + case SAVE : + $code = toSQL($code); + $texte = toSQL($texte); + $texte_court = toSQL($texte_court); + $code_original = toSQL($code_original); + + // creation ou mise à jour de la liste + if ($oid != -1) { + $sqlcmd = "UPDATE $schema.$tableName SET "; + + $sqlcmd .= "texte = '$texte'"; + + switch ($tableName) { + case "t_divers" : + case "t_transformation" : + case "t_population_regle" : + // Pas de colonne texte_court dans ces 3 tables. + break; + default : + $sqlcmd .= ", texte_court = '$texte_court' "; + break; + } + + switch ($tableName) { + case "t_rubriques" : + $sqlcmd .= ", code_calcul = '".utf8_decode($recordNode["code_calcul"])."' "; + $sqlcmd .= ", unite = '".utf8_decode($recordNode["unite"])."' "; + $sqlcmd .= ", coefficient = ".floatval(utf8_decode($recordNode["coefficient"]))." "; + $sqlcmd .= ", coefficient_base = ".floatval(utf8_decode($recordNode["coefficient_base"]))." "; + $sqlcmd .= ", coefficient_nombre = ".floatval(utf8_decode($recordNode["coefficient_nombre"]))." "; + $sqlcmd .= ", coefficient_txs = ".floatval(utf8_decode($recordNode["coefficient_txs"]))." "; + $sqlcmd .= ", coefficient_txp = ".floatval(utf8_decode($recordNode["coefficient_txp"]))." "; + + $sqlcmd .= ", user_modified = CASE WHEN user_modified THEN ".(utf8_decode($recordNode["user_modified"]) == 'M' ? "true" : "false")." ELSE true END "; // On peut le décocher que s'il était coché. Sinon ça coche. + $sqlcmd .= ", p_cumul = ".(utf8_decode($recordNode["p_cumul"]) == 'C' ? "true" : "false")." "; + $sqlcmd .= ", p_detail = ".(utf8_decode($recordNode["p_detail"]) == 'D' ? "true" : "false")." "; + $sqlcmd .= ", proratiser_conversion = ".(utf8_decode($recordNode["proratiser_conversion"]) == 'X' ? "true" : "false")." "; + + $tmpRubArray = array( + "nombre", + "base", + "heures_contrat", + "heures_payees", + "heures_travaillees", + "masse_salariale", + "brut", + "avantage_nature", + "frais_imposables", + "cotisation_salarie", + "cotisation_patronale", + "od_net_salarie", + "od_net_patronale", + "net_imposable", + "net_a_payer", + "nombre_provisions", + "montant_provisions", + "masse_salariale_provisionnee" + ); + + foreach ($tmpRubArray as $ind) { + $sqlcmd .= ", p_$ind = ".($recordNode["p_$ind"] == 'X' ? "true" : "false")." "; + if ($recordNode["p_$ind"] == 'X') { + $sqlcmd .= ", s_$ind = ".$recordNode["s_$ind"]." "; + $tmpCoeff = 1; + if ($recordNode["c_$ind"] != "") { + $tmpCoeff = floatval($recordNode["c_$ind"]); + } + $sqlcmd .= ", c_$ind = ".$tmpCoeff." "; + } + } + + break; + case "t_etablissements" : + $sqlcmd .= ", base_calcul_etp = '".utf8_decode($recordNode["base_calcul_etp"])."' "; + $sqlcmd .= ", planning_code = '".utf8_decode($recordNode["code_ets_planning"])."' "; + $sqlcmd .= ", finess_id = '".floatval($recordNode["finess_id"])."' "; + break; + case "t_entreprises" : + $sqlcmd .= ", planning_code = '".utf8_decode($recordNode["code_ent_planning"])."' "; + break; + case "t_divers" : + $sqlcmd .= ", valeur = '".utf8_decode($recordNode["valeur"])."' "; + $sqlcmd .= ", show_info_module = (".utf8_decode($recordNode["show_info_module"])." = 1) "; + // On n'a pas de raison de mettre à jour la date dans rh.t_divers. + // Donc la ligne qui suit est commentée. + //$sqlcmd .= ", valeur_date = '" . utf8_decode($recordNode["valeur_date"]) . "'::date "; + break; + case "t_transformation" : + $sqlcmd .= ", date_debut = '".utf8_decode($recordNode["date_debut"])."' "; + $sqlcmd .= ", date_fin = '".utf8_decode($recordNode["date_fin"])."' "; + $sqlcmd .= ", salarie_id = '".utf8_decode($recordNode["salarie_id"])."' "; + $sqlcmd .= ", from_service_id = '".utf8_decode($recordNode["from_service_id"])."' "; + $sqlcmd .= ", to_service_id = '".utf8_decode($recordNode["to_service_id"])."' "; + $sqlcmd .= ", from_qualification_id = '".utf8_decode($recordNode["from_qualification_id"])."' "; + $sqlcmd .= ", to_qualification_id = '".utf8_decode($recordNode["to_qualification_id"])."' "; + break; + case "t_data_profile" : + $sqlcmd .= ", etablissement_inclus = '".toSQL(utf8_decode($recordNode["etablissement_inclus"]))."' "; + $sqlcmd .= ", etablissement_exclus = '".toSQL(utf8_decode($recordNode["etablissement_exclus"]))."' "; + $sqlcmd .= ", service_inclus = '".toSQL(utf8_decode($recordNode["service_inclus"]))."' "; + $sqlcmd .= ", service_exclus = '".toSQL(utf8_decode($recordNode["service_exclus"]))."' "; + $sqlcmd .= ", statut_inclus = '".toSQL(utf8_decode($recordNode["statut_inclus"]))."' "; + $sqlcmd .= ", statut_exclus = '".toSQL(utf8_decode($recordNode["statut_exclus"]))."' "; + break; + case "t_planning_service" : + $sqlcmd .= ", service_id = '".floatval(utf8_decode($recordNode["service_id"]))."' "; + break; + case "t_planning_qualification" : + $sqlcmd .= ", qualification_id = '".floatval(utf8_decode($recordNode["qualification_id"]))."' "; + break; + case 't_population_regle' : + $sqlcmd .= " + ,code = '" . utf8_decode($recordNode['code']) . "' + ,priorite = " . utf8_decode($recordNode['priorite']) . " + ,population_id = " . utf8_decode($recordNode['population_id']) . " + ,liste_finess = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_finess']) . "') + ,liste_etablissement = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_etablissement']) . "') + ,liste_service = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_service']) . "') + ,liste_specialite = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_specialite']) . "') + ,liste_section_analytique = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_section_analytique']) . "') + ,liste_section_analytique_paie = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_section_analytique_paie']) . "') + ,liste_qualification = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_qualification']) . "') + ,liste_grille = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_grille']) . "') + ,liste_code_emploi = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_code_emploi']) . "') + ,liste_categorie_socio_professionnelle = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_categorie_socio_professionnelle']) . "') + ,liste_statut = rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_statut']) . "') + "; + break; + case 't_expert_controle' : + $sqlcmd .= " + ,code = '" . utf8_decode($recordNode['code']) . "' + ,texte_abrege = '" . utf8_decode($recordNode['texte_abrege']) . "' + ,description = '" . utf8_decode($recordNode['description']) . "' + ,is_cti = '" . utf8_decode($recordNode['is_cti']) . "' + ,is_hide = '" . utf8_decode($recordNode['is_hide']) . "' + ,gravite_id = " . utf8_decode($recordNode['gravite']) . " + ,prestataire_id = " . utf8_decode($recordNode['prestataire']) . " + ,is_active = '" . utf8_decode($recordNode['is_active']) . "' + ,alert_exp = '" . utf8_decode($recordNode['is_alert']) . "' + "; + break; + } + + if ($tableName == "t_divers") { + $sqlcmd .= "WHERE code = '$code'"; + } else { + $sqlcmd .= "WHERE oid = $oid"; + } + + if ($tableName != 't_expert_controle') { + $result = $db->exec($sqlcmd); + } + else { + if ($recordNode['mode'] == 2) { + $EXPERT_ACTIVE = utf8_decode($recordNode["EXPERT_ACTIVE"]); + $EXPERT_DATE_DEBUT = utf8_decode($recordNode["EXPERT_DATE_DEBUT"]); + + $sqlcmd = "UPDATE rh.t_divers + SET valeur = '$EXPERT_ACTIVE' + WHERE code = 'EXPERT_ACTIVE' AND + valeur IS DISTINCT FROM '$EXPERT_ACTIVE'; "; + $result = $db->exec($sqlcmd); + + $sqlcmd = "UPDATE rh.t_divers + SET valeur_date = to_date('$EXPERT_DATE_DEBUT','DD/MM/YYYY'), + valeur = '$EXPERT_DATE_DEBUT' + WHERE code = 'EXPERT_DATE_DEBUT' AND + valeur_date IS DISTINCT FROM to_date('$EXPERT_DATE_DEBUT','DD/MM/YYYY'); "; + $result = $db->exec($sqlcmd); + } else { + $result = $db->exec($sqlcmd); + $sqlcmd = + "UPDATE rh.t_expert_controle_rule + SET sqlcmd_where = '" . toSQL(utf8_decode($recordNode['sqlcmd_where1'])) . "', + sqlcmd_justificatif = '" . toSQL(utf8_decode($recordNode['sqlcmd_justificatif1'])) . "', + table_id = " . toSQL(utf8_decode($recordNode['table1'])) . " + WHERE controle_id = ". $oid; + $result = $db->exec($sqlcmd); + } + } + + if (array_key_exists($tableName, $rh_profil_tables)) { + $sqlcmd = "SELECT rh.cti_reorganize_profils_table('$tableName', '".$rh_profil_tables[$tableName]."');"; + $result = $db->exec($sqlcmd); + } + + switch ($tableName) { + case "t_transformation" : + $sqlcmd = "SELECT rh.cti_execute_transform()"; + $result = $db->exec($sqlcmd); + break; + case "t_etablissements" : + $sqlcmd = " + UPDATE rh.t_etablissements SET + finess_code = t_finess.code, + finess_texte = t_finess.texte, + finess_section_id = t_finess.section_id, + finess_section_code = t_finess.section_code, + finess_section_texte = t_finess.section_texte + FROM base.t_finess + WHERE 1=1 + AND t_etablissements.finess_id = t_finess.oid + AND t_etablissements.oid = $oid + "; + $result = $db->exec($sqlcmd); + break; + case "t_data_profile" : + $sqlcmd = "SELECT rh.cti_gen_data_profile_views()"; + $result = $db->exec($sqlcmd); + break; + case "t_divers" : + $sqlcmd = "SELECT rh.cti_hp_create_views()"; + $result = $db->exec($sqlcmd); + break; + case "t_planning_service" : + $sqlcmd = " + UPDATE rh.t_planning_service SET + service_code = t_services.code, + service_texte = t_services.texte_court, + service_section_id = t_services.section_id, + service_section_code = t_services.section_code, + service_section_texte = t_services.section_texte + FROM rh.t_services + WHERE 1=1 + AND t_planning_service.Service_id = t_services.oid + AND (1!=1 + OR service_code IS DISTINCT FROM t_services.code + OR service_texte IS DISTINCT FROM t_services.texte_court + OR service_section_id IS DISTINCT FROM t_services.section_id + OR service_section_code IS DISTINCT FROM t_services.section_code + OR service_section_texte IS DISTINCT FROM t_services.section_texte) + "; + $result = $db->exec($sqlcmd); + break; + case "t_planning_qualification" : + $sqlcmd = " + UPDATE rh.t_planning_qualification SET + qualification_code = t_qualifications.code, + qualification_texte = t_qualifications.texte_court, + qualification_section_id = t_qualifications.section_id, + qualification_section_code = t_qualifications.section_code, + qualification_section_texte = t_qualifications.section_texte + FROM rh.t_qualifications + WHERE 1=1 + AND t_planning_qualification.Service_id = t_qualifications.oid + AND (1!=1 + OR qualification_code IS DISTINCT FROM t_qualifications.code + OR qualification_texte IS DISTINCT FROM t_qualifications.texte_court + OR qualification_section_id IS DISTINCT FROM t_qualifications.section_id + OR qualification_section_code IS DISTINCT FROM t_qualifications.section_code + OR qualification_section_texte IS DISTINCT FROM t_qualifications.section_texte) + "; + $result = $db->exec($sqlcmd); + break; + } + } else { + // Ajouts + if ($tableName == "t_transformation") { + $sqlcmd = "INSERT INTO $schema.$tableName ("; + $sqlcmd .= "texte, "; + $sqlcmd .= "date_debut, "; + $sqlcmd .= "date_fin, "; + $sqlcmd .= "salarie_id, "; + $sqlcmd .= "from_service_id, "; + $sqlcmd .= "to_service_id, "; + $sqlcmd .= "from_qualification_id, "; + $sqlcmd .= "to_qualification_id"; + $sqlcmd .= ") "; + $sqlcmd .= "VALUES ("; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["texte"]))."', "; + $sqlcmd .= "'".utf8_decode($recordNode["date_debut"])."', "; + $sqlcmd .= "'".utf8_decode($recordNode["date_fin"])."', "; + $sqlcmd .= "".utf8_decode($recordNode["salarie_id"]).", "; + $sqlcmd .= "".utf8_decode($recordNode["from_service_id"]).", "; + $sqlcmd .= "".utf8_decode($recordNode["to_service_id"]).", "; + $sqlcmd .= "".utf8_decode($recordNode["from_qualification_id"]).", "; + $sqlcmd .= "".utf8_decode($recordNode["to_qualification_id"])." "; + $sqlcmd .= ")"; + $result = $db->exec($sqlcmd); + + $sqlcmd = "SELECT rh.cti_execute_transform()"; + $result = $db->exec($sqlcmd); + } + // Ajouts + if ($tableName == "t_data_profile") { + $sqlcmd = "INSERT INTO $schema.$tableName ("; + $sqlcmd .= "code, "; + $sqlcmd .= "texte, "; + $sqlcmd .= "texte_court, "; + $sqlcmd .= "etablissement_inclus, "; + $sqlcmd .= "etablissement_exclus, "; + $sqlcmd .= "service_inclus, "; + $sqlcmd .= "service_exclus, "; + $sqlcmd .= "statut_inclus, "; + $sqlcmd .= "statut_exclus"; + $sqlcmd .= ") "; + $sqlcmd .= "VALUES ("; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["code"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["texte"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["texte"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["etablissement_inclus"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["etablissement_exclus"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["service_inclus"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["service_exclus"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["statut_inclus"]))."', "; + $sqlcmd .= "'".toSQL(utf8_decode($recordNode["statut_exclus"]))."' "; + $sqlcmd .= ")"; + $result = $db->exec($sqlcmd); + + $sqlcmd = "SELECT rh.cti_gen_data_profile_views()"; + $result = $db->exec($sqlcmd); + } + + if ($tableName == "t_population") { + $sqlcmd = " + INSERT INTO rh.t_population ( + code, + texte) + VALUES( + '" . utf8_decode($recordNode["code"]) . "', + '" . utf8_decode($recordNode["texte"]) . "') + "; + $result = $db->exec($sqlcmd); + } + + if ($tableName == "t_population_regle") { + $sqlcmd = " + INSERT INTO rh.t_population_regle ( + texte, + code, + priorite, + population_id, + liste_finess, + liste_etablissement, + liste_service, + liste_specialite, + liste_section_analytique, + liste_section_analytique_paie, + liste_qualification, + liste_grille, + liste_code_emploi, + liste_categorie_socio_professionnelle, + liste_statut) + VALUES( + '" . utf8_decode($recordNode["texte"]) . "', + '" . utf8_decode($recordNode["code"]) . "', + " . utf8_decode($recordNode["priorite"]) . ", + " . utf8_decode($recordNode["population_id"]) . ", + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_finess']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_etablissement']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_service']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_specialite']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_section_analytique']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_section_analytique_paie']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_qualification']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_grille']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_code_emploi']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_categorie_socio_professionnelle']) . "'), + rh.cti_util_translate_list('" . utf8_decode($recordNode['liste_statut']) . "')) + "; + $result = $db->exec($sqlcmd); + } + + if ($tableName == 't_expert_controle') { + $sqlcmd = " + INSERT INTO rh.t_expert_controle + ( + code, + texte, + texte_court, + texte_abrege, + description, + is_cti, + is_hide, + gravite_id, + prestataire_id, + is_active, + alert_exp + ) + VALUES( + '" . $code . "' + ,'" . $texte . "' + ,'" . $texte_court . "' + ,'" . utf8_decode($recordNode['texte_abrege']) . "' + ,'" . utf8_decode($recordNode['description']) . "' + ,'" . utf8_decode($recordNode['is_cti']) . "' + ,'" . utf8_decode($recordNode['is_hide']) . "' + ," . utf8_decode($recordNode['gravite']) . " + ," . utf8_decode($recordNode['prestataire']) . " + ,'" . utf8_decode($recordNode['is_active']) . "' + ,'" . utf8_decode($recordNode['is_alert']) . "') + "; + $result = $db->exec($sqlcmd); + if ($result == FALSE) { + + } + else { + $result = $db->exec( + "SELECT max(oid) as oid FROM + rh.t_expert_controle + WHERE code = '" . utf8_decode($recordNode['code']). "' AND texte = '$texte'" + ); + if ($result != false) { + $record = $db->nextRecordInto(); + if ($record != FALSE) { + $oid = $record[0] + 0; + $sqlcmd = " + DELETE FROM rh.t_expert_controle_rule + USING + ( + SELECT t_expert_controle_rule.oid + FROM rh.t_expert_controle_rule + LEFT JOIN rh.t_expert_controle ON t_expert_controle_rule.controle_id = t_expert_controle.oid + WHERE t_expert_controle.oid IS NULL + ) subview + WHERE t_expert_controle_rule.oid = subview.oid; + + INSERT INTO rh.t_expert_controle_rule ( + controle_id, + numero, + sqlcmd_where, + sqlcmd_justificatif, + table_id + ) + VALUES + (" . $oid . ", + 1::bigint, + '" . toSQL(utf8_decode($recordNode['sqlcmd_where1'])) . "', + '" . toSQL(utf8_decode($recordNode['sqlcmd_justificatif1'])) . "', + " . toSQL(utf8_decode($recordNode['table1'])) . ");"; + error_log($sqlcmd);$result = $db->exec($sqlcmd); + } + } + } + } + } + break; + case UPDATE : + // nothing to do yet + break; + case COPY : + // nothing to do yet + if ($tableName == 't_expert_controle') { + $sqlcmd = "SELECT count(*)+1 as index + FROM rh.t_expert_controle + JOIN rh.t_expert_controle tout + ON LEFT(tout.code,LENGTH(t_expert_controle.code)) = t_expert_controle.code + WHERE t_expert_controle.oid = $oid"; + $result = $db->exec($sqlcmd); + $record = $db->nextRecordInto(); + $index = $record[0]; + error_log($index); + $sqlcmd = " + INSERT INTO rh.t_expert_controle + ( + code, + texte, + texte_court, + texte_abrege, + description, + is_cti, + is_hide, + gravite_id, + prestataire_id, + is_active, + alert_exp + ) + SELECT + code || '_' || $index, + 'Copie ' || ($index - 1) || ' de ' || texte, + texte_court, + texte_abrege, + description, + is_cti, + is_hide, + gravite_id, + prestataire_id, + is_active, + alert_exp + FROM rh.t_expert_controle + WHERE oid = $oid"; + $result = $db->exec($sqlcmd); + if ($result == FALSE) { + + } + else { + $record = $db->nextRecordInto(); + $result = $db->exec( + "SELECT max(oid) as oid FROM + rh.t_expert_controle + WHERE code = '" . $code . "_". $index . "'" + ); + if ($result != false) { + $record = $db->nextRecordInto(); + if ($record != FALSE) { + $oid = $record[0] + 0; + $sqlcmd = " + DELETE FROM rh.t_expert_controle_rule + USING + ( + SELECT t_expert_controle_rule.oid + FROM rh.t_expert_controle_rule + LEFT JOIN rh.t_expert_controle ON t_expert_controle_rule.controle_id = t_expert_controle.oid + WHERE t_expert_controle.oid IS NULL + ) subview + WHERE t_expert_controle_rule.oid = subview.oid; + + INSERT INTO rh.t_expert_controle_rule ( + controle_id, + numero, + sqlcmd_where, + sqlcmd_justificatif, + table_id + ) + VALUES + (" . $oid . ", + 1::bigint, + '" . toSQL(utf8_decode($recordNode['sqlcmd_where1'])) . "', + '" . toSQL(utf8_decode($recordNode['sqlcmd_justificatif1'])) . "', + " . toSQL(utf8_decode($recordNode['table1'])) . ");"; + } + } + } + } + + break; + case DELETE : + if ($tableName == "t_transformation") { + $sqlcmd = "DELETE FROM $schema.$tableName WHERE oid = $oid"; + $result = $db->exec($sqlcmd); + + $sqlcmd = "SELECT rh.cti_execute_transform()"; + $result = $db->exec($sqlcmd); + } + if ($tableName == "t_data_profile") { + $sqlcmd = "DELETE FROM $schema.$tableName WHERE oid = $oid"; + $result = $db->exec($sqlcmd); + + $sqlcmd = "SELECT rh.cti_gen_data_profile_views()"; + $result = $db->exec($sqlcmd); + } + if ($tableName == "t_population") { + $sqlcmd = "DELETE FROM $schema.$tableName WHERE oid = $oid"; + $result = $db->exec($sqlcmd); + } + if ($tableName == "t_population_regle") { + $sqlcmd = "DELETE FROM $schema.$tableName WHERE oid = $oid"; + $result = $db->exec($sqlcmd); + } + if ($tableName == "t_expert_controle") { + $sqlcmd = "DELETE FROM $schema.$tableName WHERE oid = $oid"; + $result = $db->exec($sqlcmd); + $sqlcmd = "DELETE FROM $schema." . $tableName ."_rule WHERE controle_id = $oid"; + $result = $db->exec($sqlcmd); + } + break; + case PURGE : + if ($tableName == "t_expert_controle") { + if ($oid != '') { + $sqlcmd = "DELETE FROM $schema.p_expert_controle WHERE controle_id = $oid"; + } + else { + $sqlcmd = "TRUNCATE $schema.p_expert_controle"; + } + $result = $db->exec($sqlcmd); + $sqlcmd = "UPDATE $schema.$tableName" . "_rule SET last_execution_date = null, last_execution_ok = '' WHERE controle_id = $oid"; + $result = $db->exec($sqlcmd); + } + break; + default: + // nothing to do yet + break; + } + erase_cache($db, $schema); +} + +/** + * + * @param Database $db + * @param string $schema + */ +function erase_cache($db, $schema) { + + // Effacer cache ancienne version + if ($db->cticache == "true") { + $sqlcmd = "SELECT cti_cache_erase as result from cache.cti_cache_erase('iCTI_$schema')"; + $result = $db->exec($sqlcmd); + } + + // Effacer cache nouvelle version + cleanAllCache("iCTI_$schema"); +} + +?> \ No newline at end of file diff --git a/settings.XML b/settings.XML new file mode 100644 index 0000000..01abc88 --- /dev/null +++ b/settings.XML @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000001.XML b/settings/RH000001.XML new file mode 100644 index 0000000..dd32a43 --- /dev/null +++ b/settings/RH000001.XML @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000002.XML b/settings/RH000002.XML new file mode 100644 index 0000000..4c21daf --- /dev/null +++ b/settings/RH000002.XML @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000003.XML b/settings/RH000003.XML new file mode 100644 index 0000000..ad143f5 --- /dev/null +++ b/settings/RH000003.XML @@ -0,0 +1,582 @@ + + + + + + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[8]"; + } + + EVAL]]]> + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[4]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000004.XML b/settings/RH000004.XML new file mode 100644 index 0000000..db61662 --- /dev/null +++ b/settings/RH000004.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000005.XML b/settings/RH000005.XML new file mode 100644 index 0000000..920eabf --- /dev/null +++ b/settings/RH000005.XML @@ -0,0 +1,12 @@ + + + + + + + diff --git a/settings/RH000006.XML b/settings/RH000006.XML new file mode 100644 index 0000000..e4f4b0c --- /dev/null +++ b/settings/RH000006.XML @@ -0,0 +1,748 @@ + + + + <![CDATA[ + = + var objet:String = ''; + var periode:String = ''; + if (SELECT.GROUPBY_2 == 'SAL') { + objet = '[DICT.RH.SALARIE#4]'; + periode = ' Présents de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL; + } + if (SELECT.GROUPBY_2 == 'CNT') { + objet = '[DICT.RH.CONTRAT#4]'; + periode = ' Présents de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL; + } + + if (SELECT.GROUPBY != '-1') { + return 'Justificatif des ' + objet + ' par ' + SELECT.GROUPBY_LABEL + ' - ' + periode; + } + else { + return 'Justificatif des ' + objet + ' - ' + periode; + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000007.XML b/settings/RH000007.XML new file mode 100644 index 0000000..0d7f54f --- /dev/null +++ b/settings/RH000007.XML @@ -0,0 +1,485 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000008.XML b/settings/RH000008.XML new file mode 100644 index 0000000..8db913e --- /dev/null +++ b/settings/RH000008.XML @@ -0,0 +1,439 @@ + + + + + + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[3]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000009.XML b/settings/RH000009.XML new file mode 100644 index 0000000..0231e07 --- /dev/null +++ b/settings/RH000009.XML @@ -0,0 +1,1608 @@ + + + + <![CDATA[= + + var toReturn = 'Détail [DICT.RH.SALARIE#2] : '; + + switch (VIEW.ACTION_AFFICHAGE) { + case 'MESSAGE' : + toReturn += 'aucun résultat pour "[EVAL return utf8_decode('[MATRICULE]'); EVAL]"'; + break; + case 'AFFICHER' : + toReturn += VIEW.SALARIE_TEXTE + ' (' + VIEW.SALARIE_CODE + ')'; + break; + case 'LISTER' : + toReturn += 'sélectionnez un salarié dans la liste'; + break; + } + + return toReturn; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000010.XML b/settings/RH000010.XML new file mode 100644 index 0000000..636ac37 --- /dev/null +++ b/settings/RH000010.XML @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000011.XML b/settings/RH000011.XML new file mode 100644 index 0000000..a7fd181 --- /dev/null +++ b/settings/RH000011.XML @@ -0,0 +1,594 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000012.XML b/settings/RH000012.XML new file mode 100644 index 0000000..1295fcd --- /dev/null +++ b/settings/RH000012.XML @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000013.XML b/settings/RH000013.XML new file mode 100644 index 0000000..9569859 --- /dev/null +++ b/settings/RH000013.XML @@ -0,0 +1,575 @@ + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000014.XML b/settings/RH000014.XML new file mode 100644 index 0000000..171013d --- /dev/null +++ b/settings/RH000014.XML @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000015.XML b/settings/RH000015.XML new file mode 100644 index 0000000..31dfb14 --- /dev/null +++ b/settings/RH000015.XML @@ -0,0 +1,778 @@ + + + + + + + + + 0 or v_rh_view_1.heures_payees > 0 then v_rh_view_1.salarie_id else null end)"; + break; + case 'NBETPC': + return "base.cti_division(SUM(v_rh_view_1.etp_contrat), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPCCDI': + return "base.cti_division(SUM(CASE WHEN type_contrat_section_code[9] = 'CDI' THEN v_rh_view_1.etp_contrat ELSE 0 END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPCCDD': + return "base.cti_division(SUM(CASE WHEN type_contrat_section_code[9] = 'CDD' THEN v_rh_view_1.etp_contrat ELSE 0 END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETP': + return "base.cti_division(SUM(v_rh_view_1.etp_paye), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPCDI': + return "base.cti_division(SUM(CASE WHEN type_contrat_section_code[9] = 'CDI' THEN v_rh_view_1.etp_paye ELSE 0 END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPCDD': + return "base.cti_division(SUM(CASE WHEN type_contrat_section_code[9] = 'CDD' THEN v_rh_view_1.etp_paye ELSE 0 END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPT': + return "base.cti_division(SUM(v_rh_view_1.etp_travaille), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPTCDI': + return "base.cti_division(SUM(CASE WHEN type_contrat_section_code[9] = 'CDI' THEN v_rh_view_1.etp_travaille ELSE 0 END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPTCDD': + return "base.cti_division(SUM(CASE WHEN type_contrat_section_code[9] = 'CDD' THEN v_rh_view_1.etp_travaille ELSE 0 END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBHT': + return "SUM(v_rh_view_1.heures_travaillees)"; + break; + case 'MTMASSE': + return 'SUM(v_rh_view_1.montant_masse_salariale)'; + break; + case 'MTHORMOYCHAR': + return 'base.cti_division(SUM(v_rh_view_1.montant_masse_salariale), SUM(v_rh_view_1.heures_payees))'; + break; + case 'MTMASSEMOY': + return " + base.cti_division( + SUM(v_rh_view_1.montant_masse_salariale), + SUM(v_rh_view_1.etp_paye) + ) + "; + break; + case 'MTMASSEPCT': + return " + base.cti_division( + base.cti_division( + SUM(v_rh_view_1.montant_net_a_payer_salarie), + SUM(v_rh_view_1.etp_paye) + ), + base.cti_division( + SUM(v_rh_view_1.montant_masse_salariale), + SUM(v_rh_view_1.etp_paye) + ) + ) * 100 + "; + break; + case 'MTNETAPAYERMOY' : + return "base.cti_division(SUM(v_rh_view_1.montant_net_a_payer_salarie), SUM(v_rh_view_1.etp_paye))"; + break; + case 'MTBRUT': + return 'SUM(v_rh_view_1.montant_brut)'; + break; + case 'MTBRUTMOY': + return "base.cti_division(SUM(v_rh_view_1.montant_brut), SUM(v_rh_view_1.etp_paye))"; + break; + case 'MTBRUTAVANTAGE': + return 'SUM(v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature)'; + break; + case 'MTAVANTAGE': + return 'SUM(v_rh_view_1.montant_avantage_nature)'; + break; + case 'MTFRAISIMPOS': + return 'SUM(v_rh_view_1.montant_frais_imposables)'; + break; + case 'MTODNETSALARIE': + return 'SUM(v_rh_view_1.montant_od_net_salarie)'; + break; + case 'MTODNETPATRONALE': + return 'SUM(v_rh_view_1.montant_od_net_patronale)'; + break; + case 'MTCOTSALARIE': + return 'SUM(v_rh_view_1.montant_cotisation_salarie)'; + break; + case 'MTCOTPATRONALE': + return 'SUM(v_rh_view_1.montant_cotisation_patronale)'; + break; + case 'MTNETIMPOSABLE': + return 'SUM(v_rh_view_1.montant_net_imposable_salarie)'; + break; + case 'MTNETAPAYER': + return 'SUM(v_rh_view_1.montant_net_a_payer_salarie)'; + break; + case 'BASE': + return 'SUM(v_rh_view_1.base)'; + break; + case 'NOMBRE': + return 'SUM(v_rh_view_1.nombre)'; + break; + case 'AGEMOYDJ': + return "base.cti_avg_distinct_on( + DISTINCT + (CASE WHEN 1=1 + AND v_rh_view_1.date_fin_activite BETWEEN '[PERIODE]'::date AND '[TOPERIODE]'::date + THEN ARRAY[salarie_id::numeric, age_id::numeric] + ELSE null END) + ) + "; + break; + case 'NSALH': + return "count(DISTINCT CASE WHEN v_rh_view_1.sexe_code = 'M' THEN v_rh_view_1.salarie_id ELSE null END) + "; + break; + case 'NSALF': + return "count(DISTINCT CASE WHEN v_rh_view_1.sexe_code IS DISTINCT FROM 'M' THEN v_rh_view_1.salarie_id ELSE null END) + "; + break; + case 'NCDI': + return "count(DISTINCT CASE WHEN type_contrat_section_code[9] = 'CDI' THEN contrat_id ELSE null END) + "; + break; + case 'NCDD': + return "count(DISTINCT CASE WHEN type_contrat_section_code[9] = 'CDD' THEN contrat_id ELSE null END) + "; + break; + case 'NSALDJ': + return "count(DISTINCT CASE + WHEN 1=1 + AND v_rh_view_1.present_fin_mois = 1 + AND to_char(v_rh_view_1.date_fin_activite, 'YYYYMM') = to_char('[TOPERIODE]'::date, 'YYYYMM') + THEN v_rh_view_1.salarie_id + ELSE null + END)"; + break; + case 'NSALPJ': + return "count(DISTINCT CASE + WHEN 1=1 + AND v_rh_view_1.present_debut_mois = 1 + AND to_char(v_rh_view_1.date_debut_activite, 'YYYYMM') = to_char('[PERIODE]'::date, 'YYYYMM') + THEN v_rh_view_1.salarie_id + ELSE null + END)"; + break; + case 'NBPROVISIONS': + return 'SUM(v_rh_view_1.nombre_provisions)'; + case 'MTPROVISIONS': + return 'SUM(v_rh_view_1.montant_provisions)'; + break; + case 'MTMASSEPROV': + return 'SUM(v_rh_view_1.montant_masse_salariale_provisionnee)'; + break; + default: + return 'SUM(v_rh_view_1.montant_masse_salariale)'; + } + // ?> + EVAL]]]> + + + 0 or v_rh_view_1.heures_payees > 0) then v_rh_view_1.salarie_id else null end)"; + break; + case 'NBHC': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.heures_contrat ELSE NULL END)"; + break; + case 'NBETPC': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_contrat ELSE NULL END)"; + break; + case 'NBETPCCDI': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND type_contrat_section_code[9] = 'CDI' THEN v_rh_view_1.etp_contrat ELSE NULL END)"; + break; + case 'NBETPCCDD': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND type_contrat_section_code[9] = 'CDD' THEN v_rh_view_1.etp_contrat ELSE NULL END)"; + break; + case 'NBETP': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END)"; + break; + case 'NBETPCDI': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND type_contrat_section_code[9] = 'CDI' THEN v_rh_view_1.etp_paye ELSE NULL END)"; + break; + case 'NBETPCDD': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND type_contrat_section_code[9] = 'CDD' THEN v_rh_view_1.etp_paye ELSE NULL END)"; + break; + case 'NBETPT': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_travaille ELSE NULL END)"; + break; + case 'NBETPTCDI': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND type_contrat_section_code[9] = 'CDI' THEN v_rh_view_1.etp_travaille ELSE NULL END)"; + break; + case 'NBETPTCDD': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND type_contrat_section_code[9] = 'CDD' THEN v_rh_view_1.etp_travaille ELSE NULL END)"; + break; + case 'NBHT': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.heures_travaillees ELSE NULL END)"; + break; + case 'MTMASSE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END)'; + break; + case 'MTHORMOYCHAR': + return 'base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.heures_payees ELSE NULL END))'; + break; + case 'MTMASSEMOY': + return " + base.cti_division( + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END), + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END) + ) + "; + break; + case 'MTMASSEPCT': + return " + base.cti_division( + base.cti_division( + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_a_payer_salarie ELSE NULL END), + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END) + ), + base.cti_division( + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END), + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END) + ) + ) * 100 + "; + break; + case 'MTNETAPAYERMOY' : + return "base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_a_payer_salarie ELSE NULL END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END))"; + break; + case 'MTBRUT': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_brut ELSE NULL END)'; + break; + case 'MTBRUTMOY': + return 'base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_brut ELSE 0 END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE 0 END))'; + break; + case 'MTBRUTAVANTAGE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature ELSE NULL END)'; + break; + case 'MTAVANTAGE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_avantage_nature ELSE NULL END)'; + break; + case 'MTFRAISIMPOS': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_frais_imposables ELSE NULL END)'; + break; + case 'MTODNETSALARIE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_od_net_salarie ELSE NULL END)'; + break; + case 'MTODNETPATRONALE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_od_net_patronale ELSE NULL END)'; + break; + case 'MTCOTSALARIE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_cotisation_salarie ELSE NULL END)'; + break; + case 'MTCOTPATRONALE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_cotisation_patronale ELSE NULL END)'; + break; + case 'MTNETIMPOSABLE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_imposable_salarie ELSE NULL END)'; + break; + case 'MTNETAPAYER': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_a_payer_salarie ELSE NULL END)'; + break; + case 'BASE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.base ELSE NULL END)'; + break; + case 'NOMBRE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.nombre ELSE NULL END)'; + break; + case 'AGEMOYDJ': + return "base.cti_avg_distinct_on( + DISTINCT + (CASE WHEN COLUMNCHECKSEQUENCE + THEN CASE WHEN 1=1 + AND v_rh_view_1.date_fin_activite BETWEEN '[PERIODE]'::date AND '[TOPERIODE]'::date THEN ARRAY[salarie_id::numeric, age_id::numeric] + ELSE null END ELSE null END) + ) + "; + break; + case 'NSALH': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN v_rh_view_1.sexe_code = 'M' THEN v_rh_view_1.salarie_id ELSE null END ELSE null END) + "; + case 'NSALF': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN v_rh_view_1.sexe_code IS DISTINCT FROM 'M' THEN v_rh_view_1.salarie_id ELSE null END ELSE null END) + "; + break; + case 'NCDI': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN type_contrat_section_code[9] = 'CDI' THEN contrat_id ELSE null END ELSE null END) + "; + break; + case 'NCDD': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN type_contrat_section_code[9] = 'CDD' THEN contrat_id ELSE null END ELSE null END) + "; + break; + case 'NSALDJ': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN + CASE WHEN 1=1 + AND v_rh_view_1.present_fin_mois = 1 + AND to_char(v_rh_view_1.date_fin_activite, 'YYYYMM') = to_char('[TOPERIODE]'::date, 'YYYYMM') + THEN v_rh_view_1.salarie_id + ELSE null + END + ELSE null + END)"; + break; + case 'NSALPJ': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN + CASE WHEN 1=1 + AND v_rh_view_1.present_debut_mois = 1 + AND to_char(v_rh_view_1.date_debut_activite, 'YYYYMM') = to_char('[PERIODE]'::date, 'YYYYMM') + THEN v_rh_view_1.salarie_id + ELSE null + END + ELSE null + END)"; + break; + case 'NBPROVISIONS': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.nombre_provisions ELSE NULL END)'; + break; + case 'MTPROVISIONS': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_provisions ELSE NULL END)'; + break; + case 'MTMASSEPROV': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale_provisionnee ELSE NULL END)'; + break; + + default: + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END)'; + } + // ?> + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000016.XML b/settings/RH000016.XML new file mode 100644 index 0000000..698f044 --- /dev/null +++ b/settings/RH000016.XML @@ -0,0 +1,725 @@ + + + + + + + + 0 or v_rh_view_1.heures_payees > 0 then v_rh_view_1.salarie_id else null end)"; + break; + case 'NBETPC': + return "base.cti_division(SUM(v_rh_view_1.etp_contrat), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETP': + return "base.cti_division(SUM(v_rh_view_1.etp_paye), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBETPT': + return "base.cti_division(SUM(v_rh_view_1.etp_travaille), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date))"; + break; + case 'NBHT': + return "SUM(v_rh_view_1.heures_travaillees)"; + break; + case 'MTMASSE': + return 'SUM(v_rh_view_1.montant_masse_salariale)'; + break; + case 'MTHORMOYCHAR': + return 'base.cti_division(SUM(v_rh_view_1.montant_masse_salariale), SUM(v_rh_view_1.heures_payees))'; + break; + case 'MTMASSEMOY': + return "base.cti_division(SUM(v_rh_view_1.montant_masse_salariale), base.cti_division(SUM(v_rh_view_1.etp_paye), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)))"; + break; + case 'MTMASSEMAN': + return "base.cti_division(SUM(v_rh_view_1.montant_masse_salariale), SUM(v_rh_view_1.etp_paye))"; + break; + case 'MTMASSEPCT': + return "base.cti_division(base.cti_division(SUM(v_rh_view_1.montant_net_a_payer_salarie), SUM(v_rh_view_1.etp_paye)), base.cti_division(SUM(v_rh_view_1.montant_masse_salariale), base.cti_division(SUM(v_rh_view_1.etp_paye), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)))) * 100"; + break; + case 'MTNETAPAYERMOY' : + return "base.cti_division(SUM(v_rh_view_1.montant_net_a_payer_salarie), SUM(v_rh_view_1.etp_paye))"; + break; + case 'MTBRUT': + return 'SUM(v_rh_view_1.montant_brut)'; + break; + case 'MTBRUTMOY': + return "base.cti_division(SUM(v_rh_view_1.montant_brut), SUM(v_rh_view_1.etp_paye))"; + break; + case 'MTBRUTAVANTAGE': + return 'SUM(v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature)'; + break; + case 'MTAVANTAGE': + return 'SUM(v_rh_view_1.montant_avantage_nature)'; + break; + case 'MTFRAISIMPOS': + return 'SUM(v_rh_view_1.montant_frais_imposables)'; + break; + case 'MTODNETSALARIE': + return 'SUM(v_rh_view_1.montant_od_net_salarie)'; + break; + case 'MTODNETPATRONALE': + return 'SUM(v_rh_view_1.montant_od_net_patronale)'; + break; + case 'MTCOTSALARIE': + return 'SUM(v_rh_view_1.montant_cotisation_salarie)'; + break; + case 'MTCOTPATRONALE': + return 'SUM(v_rh_view_1.montant_cotisation_patronale)'; + break; + case 'MTNETIMPOSABLE': + return 'SUM(v_rh_view_1.montant_net_imposable_salarie)'; + break; + case 'MTNETAPAYER': + return 'SUM(v_rh_view_1.montant_net_a_payer_salarie)'; + break; + case 'BASE': + return 'SUM(v_rh_view_1.base)'; + break; + case 'NOMBRE': + return 'SUM(v_rh_view_1.nombre)'; + break; + case 'NCDI': + return "count(DISTINCT CASE WHEN type_contrat_section_code[9] = 'CDI' THEN contrat_id ELSE null END)"; + break; + case 'NCDD': + return "count(DISTINCT CASE WHEN type_contrat_section_code[9] = 'CDD' THEN contrat_id ELSE null END)"; + break; + case 'NSALH': + return "count(DISTINCT CASE WHEN v_rh_view_1.sexe_code = 'M' THEN v_rh_view_1.salarie_id ELSE null END)"; + break; + case 'NSALF': + return "count(DISTINCT CASE WHEN v_rh_view_1.sexe_code IS DISTINCT FROM 'M' THEN v_rh_view_1.salarie_id ELSE null END)"; + break; + case 'AGEMOYDJ': + return "base.cti_avg_distinct_on(DISTINCT ARRAY[salarie_id::numeric, age_id::numeric])"; + break; + case 'NSALDJ': + return "count(DISTINCT CASE + WHEN 1=1 + AND v_rh_view_1.present_fin_mois = 1 + AND to_char(v_rh_view_1.date_fin_activite, 'YYYYMM') = to_char('[TOPERIODE]'::date, 'YYYYMM') + THEN v_rh_view_1.salarie_id + ELSE null + END)"; + break; + case 'NBPROVISIONS': + return 'SUM(v_rh_view_1.nombre_provisions)'; + case 'MTPROVISIONS': + return 'SUM(v_rh_view_1.montant_provisions)'; + break; + case 'MTMASSEPROV': + return 'SUM(v_rh_view_1.montant_masse_salariale_provisionnee)'; + break; + default: + return 'SUM(v_rh_view_1.montant_masse_salariale)'; + } + // ?> + EVAL]]]> + + + + 0 or v_rh_view_1.heures_payees > 0) then v_rh_view_1.salarie_id else null end)"; + break; + case 'NBHC': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.heures_contrat ELSE NULL END)"; + break; + case 'NBETP': + return " + base.cti_division( + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE 0 END), + base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)) + "; + case 'NBETPC': + return " + base.cti_division( + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_contrat ELSE 0 END), + base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)) + "; + break; + case 'NBETPT': + return " + base.cti_division( + SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_travaille ELSE 0 END), + base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)) + "; + break; + case 'NBHT': + return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.heures_travaillees ELSE NULL END)"; + break; + case 'MTMASSE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END)'; + break; + case 'MTHORMOYCHAR': + return 'base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.heures_payees ELSE NULL END))'; + break; + case 'MTMASSEMOY': + return "base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END), base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)))"; + break; + case 'MTMASSEMAN': + return "base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END))"; + break; + case 'MTMASSEPCT': + return "base.cti_division(base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_a_payer_salarie ELSE NULL END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END)), base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END), base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)))) * 100"; + break; + case 'MTNETAPAYERMOY' : + return "base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_a_payer_salarie ELSE NULL END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.etp_paye ELSE NULL END))"; + break; + case 'MTBRUT': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_brut ELSE NULL END)'; + break; + case 'MTBRUTMOY': + return "base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_brut ELSE NULL END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN etp_paye ELSE NULL END))"; + break; + case 'MTBRUTAVANTAGE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature ELSE NULL END)'; + break; + case 'MTAVANTAGE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_avantage_nature ELSE NULL END)'; + break; + case 'MTFRAISIMPOS': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_frais_imposables ELSE NULL END)'; + break; + case 'MTODNETSALARIE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_od_net_salarie ELSE NULL END)'; + break; + case 'MTODNETPATRONALE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_od_net_patronale ELSE NULL END)'; + break; + case 'MTCOTSALARIE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_cotisation_salarie ELSE NULL END)'; + break; + case 'MTCOTPATRONALE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_cotisation_patronale ELSE NULL END)'; + break; + case 'MTNETIMPOSABLE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_imposable_salarie ELSE NULL END)'; + break; + case 'MTNETAPAYER': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_net_a_payer_salarie ELSE NULL END)'; + break; + case 'BASE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.base ELSE NULL END)'; + break; + case 'NOMBRE': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.nombre ELSE NULL END)'; + break; + case 'NCDI': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN type_contrat_section_code[9] = 'CDI' THEN contrat_id ELSE null END ELSE null END)"; + break; + case 'NCDD': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN type_contrat_section_code[9] = 'CDD' THEN contrat_id ELSE null END ELSE null END)"; + break; + case 'NSALH': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN v_rh_view_1.sexe_code = 'M' THEN v_rh_view_1.salarie_id ELSE null END ELSE null END)"; + break; + case 'NSALF': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN v_rh_view_1.sexe_code IS DISTINCT FROM 'M' THEN v_rh_view_1.salarie_id ELSE null END ELSE null END)"; + break; + case 'AGEMOYDJ': + return "base.cti_avg_distinct_on(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN ARRAY[salarie_id::numeric, age_id::numeric] else null end)"; + break; + case 'NSALDJ': + return "count(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN + CASE WHEN 1=1 + AND v_rh_view_1.present_fin_mois = 1 + AND to_char(v_rh_view_1.date_fin_activite, 'YYYYMM') = to_char('[TOPERIODE]'::date, 'YYYYMM') + THEN v_rh_view_1.salarie_id + ELSE null + END + ELSE null + END)"; + break; + case 'NBPROVISIONS': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.nombre_provisions ELSE NULL END)'; + break; + case 'MTPROVISIONS': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_provisions ELSE NULL END)'; + break; + case 'MTMASSEPROV': + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale_provisionnee ELSE NULL END)'; + break; + default: + return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_rh_view_1.montant_masse_salariale ELSE NULL END)'; + } + // ?> + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --> + + + + diff --git a/settings/RH000017.XML b/settings/RH000017.XML new file mode 100644 index 0000000..515951f --- /dev/null +++ b/settings/RH000017.XML @@ -0,0 +1,1253 @@ + + + + + + + + + + + + + + 0 or v_rh_view_1.heures_payees > 0 then v_rh_view_1.salarie_id else null end'); + break; + case 'NBETP': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPT': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPTCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPTCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPC': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBHC': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_contrat'); + break; + case 'NBHP': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees'); + break; + case 'NBHT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_travaillees'); + break; + case 'MTMASSE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale'); + break; + case 'MTHORMOYCHAR': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees').')'; + break; + case 'MTMASSEMOY': + $tmp1 = ' + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + '; + break; + case 'MTMASSEPCT': + $tmp1 = ' + base.cti_division( + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ), + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + ) * 100 + '; + break; + case 'MTNETAPAYERMOY' : + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut'); + break; + case 'MTBRUTMOY': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut').','.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature'); + break; + case 'MTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_avantage_nature'); + break; + case 'MTFRAISIMPOS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_frais_imposables'); + break; + case 'MTODNETSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_salarie'); + break; + case 'MTODNETPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_patronale'); + break; + case 'MTCOTSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_salarie'); + break; + case 'MTCOTPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_patronale'); + break; + case 'MTNETIMPOSABLE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_imposable_salarie'); + break; + case 'MTNETAPAYER': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie'); + break; + case 'BASE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.base'); + break; + case 'NOMBRE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre'); + break; + case 'NBPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre_provisions'); + break; + case 'MTPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_provisions'); + break; + case 'MTMASSEPROV': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale_provisionnee'); + break; + default : + $tmp1 = 'null'; + } + + $return = str_replace(array('@date_debut@', '@date_fin@'), array($periodeDebut, $periodeFin), $tmp1) . ',' . str_replace(array('@date_debut@', '@date_fin@'), array($periodePrecDebut, $periodePrecFin), $tmp1); + } else { + $ctiDivision = "base.cti_division(%s, %s)"; + $countDistinctCaseWhen = "count(DISTINCT CASE WHEN v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ %s THEN %s ELSE null END)"; + $periodeDebut = '\'[PERIODE]\'::date'; + $periodeFin = '\'[TOPERIODE]\'::date'; + $periodePrecDebut = '\'[VIEW.PERIODE_D]\'::date'; + $periodePrecFin = '\'[VIEW.TOPERIODE_D]\'::date'; + + switch ($data) { + case 'NSALPJ': + $tmp0 = "AND present_debut_mois = 1 AND to_char(date_debut_activite, 'YYYYMM') = to_char(@date_debut@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NSALH': + $tmp0 = 'AND sexe_code = \'M\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NCDI': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDI\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NCDD': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDD\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NSALF': + $tmp0 = 'AND sexe_code = \'F\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'AGEMOYDJ': + $tmp1 = 'base.cti_avg_distinct_on( + DISTINCT + (CASE WHEN 1=1 + AND v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ + THEN ARRAY[salarie_id::numeric, age_id::numeric] + ELSE null END) + ) + '; + break; + case 'ETPTH': + $tmp1 = ' + sum( + CASE WHEN v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ + THEN equivalent_temps_plein / base.cti_months_between(@date_debut@, @date_fin@) + ELSE 0 END + + )::numeric + + '; + break; + case 'NSALDJ': + $tmp0 = "AND present_fin_mois = 1 AND to_char(date_fin_activite, 'YYYYMM') = to_char(@date_fin@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + default : + $tmp1 = 'null'; + } + + $toReplace = array( + '@date_debut@', + '@date_fin@', + '@date_debut_efp@' + ); + + $curPeriod = array( + $periodeDebut, + $periodeFin, + "[PERIODE]" + ); + + $prevPeriod = array( + $periodePrecDebut, + $periodePrecFin, + "[VIEW.PERIODE_D]" + ); + + $return = str_replace($toReplace, $curPeriod, $tmp1) . ',' . str_replace($toReplace, $prevPeriod, $tmp1); + + } + + return $return; + } + + // ?> + EVAL]]]> + + + + EVAL]]]> + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000018.XML b/settings/RH000018.XML new file mode 100644 index 0000000..40869ce --- /dev/null +++ b/settings/RH000018.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000019.XML b/settings/RH000019.XML new file mode 100644 index 0000000..6533528 --- /dev/null +++ b/settings/RH000019.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000020.XML b/settings/RH000020.XML new file mode 100644 index 0000000..4e7fbde --- /dev/null +++ b/settings/RH000020.XML @@ -0,0 +1,587 @@ + + + <![CDATA[= + + var group_by_label = ''; + if (SELECT.GROUPBY != '-1') { + group_by_label = ' par ' + SELECT.GROUPBY_LABEL; + } + if (SELECT.GROUPBY_2 != '-1') { + group_by_label = group_by_label + ' et ' + SELECT.GROUPBY_2_LABEL; + } + + return SELECT.RAPPORT_LABEL + group_by_label + + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')' + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000021.XML b/settings/RH000021.XML new file mode 100644 index 0000000..7129ec1 --- /dev/null +++ b/settings/RH000021.XML @@ -0,0 +1,386 @@ + + + <![CDATA[= + + var group_by_label = ''; + if (SELECT.GROUPBY != '-1') { + group_by_label = ' par ' + SELECT.GROUPBY_LABEL; + } + if (SELECT.GROUPBY_2 != '-1') { + group_by_label = group_by_label + ' et ' + SELECT.GROUPBY_2_LABEL; + } + + return SELECT.RAPPORT_LABEL + group_by_label + + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')' + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000022.XML b/settings/RH000022.XML new file mode 100644 index 0000000..ce2e1d0 --- /dev/null +++ b/settings/RH000022.XML @@ -0,0 +1,363 @@ + + + <![CDATA[= + + var group_by_label = ''; + if (SELECT.GROUPBY != '-1') { + group_by_label = ' par ' + SELECT.GROUPBY_LABEL; + } + if (SELECT.GROUPBY_2 != '-1') { + group_by_label = group_by_label + ' et ' + SELECT.GROUPBY_2_LABEL; + } + + return SELECT.RAPPORT_LABEL + ' comparatif ' + group_by_label + + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ' vs ' + SELECT.PERIODE_D_LABEL + ' à ' + SELECT.TOPERIODE_D_LABEL + ')' + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000023.XML b/settings/RH000023.XML new file mode 100644 index 0000000..175057b --- /dev/null +++ b/settings/RH000023.XML @@ -0,0 +1,318 @@ + + + + <![CDATA[ + = + var periode:String = ''; + periode = ' de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL; + return 'Analyse population par ' + SELECT.GROUPBY_LABEL + periode; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000024.XML b/settings/RH000024.XML new file mode 100644 index 0000000..ed8f101 --- /dev/null +++ b/settings/RH000024.XML @@ -0,0 +1,328 @@ + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000025.XML b/settings/RH000025.XML new file mode 100644 index 0000000..73d3004 --- /dev/null +++ b/settings/RH000025.XML @@ -0,0 +1,431 @@ + + + + + + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[3]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000026.XML b/settings/RH000026.XML new file mode 100644 index 0000000..256b92e --- /dev/null +++ b/settings/RH000026.XML @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000027.XML b/settings/RH000027.XML new file mode 100644 index 0000000..ed4d2e6 --- /dev/null +++ b/settings/RH000027.XML @@ -0,0 +1,431 @@ + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000028.XML b/settings/RH000028.XML new file mode 100644 index 0000000..474f3c5 --- /dev/null +++ b/settings/RH000028.XML @@ -0,0 +1,415 @@ + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000029.XML b/settings/RH000029.XML new file mode 100644 index 0000000..3a890c9 --- /dev/null +++ b/settings/RH000029.XML @@ -0,0 +1,346 @@ + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000030.XML b/settings/RH000030.XML new file mode 100644 index 0000000..5a22432 --- /dev/null +++ b/settings/RH000030.XML @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000031-2.XML b/settings/RH000031-2.XML new file mode 100644 index 0000000..b144524 --- /dev/null +++ b/settings/RH000031-2.XML @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000031-3.XML b/settings/RH000031-3.XML new file mode 100644 index 0000000..f9e4448 --- /dev/null +++ b/settings/RH000031-3.XML @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000031-4.XML b/settings/RH000031-4.XML new file mode 100644 index 0000000..7a5e571 --- /dev/null +++ b/settings/RH000031-4.XML @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000031.XML b/settings/RH000031.XML new file mode 100644 index 0000000..dfb1d21 --- /dev/null +++ b/settings/RH000031.XML @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000032.XML b/settings/RH000032.XML new file mode 100644 index 0000000..076802e --- /dev/null +++ b/settings/RH000032.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000033.XML b/settings/RH000033.XML new file mode 100644 index 0000000..59fb896 --- /dev/null +++ b/settings/RH000033.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000043.XML b/settings/RH000043.XML new file mode 100644 index 0000000..8a758ad --- /dev/null +++ b/settings/RH000043.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000044.XML b/settings/RH000044.XML new file mode 100644 index 0000000..182f51d --- /dev/null +++ b/settings/RH000044.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000045.XML b/settings/RH000045.XML new file mode 100644 index 0000000..ebfe2da --- /dev/null +++ b/settings/RH000045.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000046.XML b/settings/RH000046.XML new file mode 100644 index 0000000..5aca3a2 --- /dev/null +++ b/settings/RH000046.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000047.XML b/settings/RH000047.XML new file mode 100644 index 0000000..8ede266 --- /dev/null +++ b/settings/RH000047.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000048.XML b/settings/RH000048.XML new file mode 100644 index 0000000..7f0a89b --- /dev/null +++ b/settings/RH000048.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000050.XML b/settings/RH000050.XML new file mode 100644 index 0000000..3252916 --- /dev/null +++ b/settings/RH000050.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000051.XML b/settings/RH000051.XML new file mode 100644 index 0000000..45e185a --- /dev/null +++ b/settings/RH000051.XML @@ -0,0 +1,5 @@ + + + diff --git a/settings/RH000052.XML b/settings/RH000052.XML new file mode 100644 index 0000000..e2cb95c --- /dev/null +++ b/settings/RH000052.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000053.XML b/settings/RH000053.XML new file mode 100644 index 0000000..94f6a61 --- /dev/null +++ b/settings/RH000053.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000054.XML b/settings/RH000054.XML new file mode 100644 index 0000000..a7e83d5 --- /dev/null +++ b/settings/RH000054.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000055.XML b/settings/RH000055.XML new file mode 100644 index 0000000..51e40ec --- /dev/null +++ b/settings/RH000055.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000057.XML b/settings/RH000057.XML new file mode 100644 index 0000000..bc41fd4 --- /dev/null +++ b/settings/RH000057.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000058.XML b/settings/RH000058.XML new file mode 100644 index 0000000..c508aae --- /dev/null +++ b/settings/RH000058.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000059.XML b/settings/RH000059.XML new file mode 100644 index 0000000..96f6211 --- /dev/null +++ b/settings/RH000059.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000060.XML b/settings/RH000060.XML new file mode 100644 index 0000000..87e29a6 --- /dev/null +++ b/settings/RH000060.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000061.XML b/settings/RH000061.XML new file mode 100644 index 0000000..f49df2e --- /dev/null +++ b/settings/RH000061.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000063.XML b/settings/RH000063.XML new file mode 100644 index 0000000..6d3e8de --- /dev/null +++ b/settings/RH000063.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000064.XML b/settings/RH000064.XML new file mode 100644 index 0000000..b689422 --- /dev/null +++ b/settings/RH000064.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000065.XML b/settings/RH000065.XML new file mode 100644 index 0000000..83347dd --- /dev/null +++ b/settings/RH000065.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000066.XML b/settings/RH000066.XML new file mode 100644 index 0000000..5964198 --- /dev/null +++ b/settings/RH000066.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000067.XML b/settings/RH000067.XML new file mode 100644 index 0000000..ccb6cf9 --- /dev/null +++ b/settings/RH000067.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000068.XML b/settings/RH000068.XML new file mode 100644 index 0000000..4a5c950 --- /dev/null +++ b/settings/RH000068.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000069.XML b/settings/RH000069.XML new file mode 100644 index 0000000..c9fa6b7 --- /dev/null +++ b/settings/RH000069.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000070.XML b/settings/RH000070.XML new file mode 100644 index 0000000..592243a --- /dev/null +++ b/settings/RH000070.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000071.XML b/settings/RH000071.XML new file mode 100644 index 0000000..ee61b75 --- /dev/null +++ b/settings/RH000071.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000072.XML b/settings/RH000072.XML new file mode 100644 index 0000000..100e587 --- /dev/null +++ b/settings/RH000072.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000073.XML b/settings/RH000073.XML new file mode 100644 index 0000000..32cb835 --- /dev/null +++ b/settings/RH000073.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000074.XML b/settings/RH000074.XML new file mode 100644 index 0000000..eec41ff --- /dev/null +++ b/settings/RH000074.XML @@ -0,0 +1,4 @@ + + + diff --git a/settings/RH000075.XML b/settings/RH000075.XML new file mode 100644 index 0000000..eaa146f --- /dev/null +++ b/settings/RH000075.XML @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000076.XML b/settings/RH000076.XML new file mode 100644 index 0000000..7c284f7 --- /dev/null +++ b/settings/RH000076.XML @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000078.XML b/settings/RH000078.XML new file mode 100644 index 0000000..0df3921 --- /dev/null +++ b/settings/RH000078.XML @@ -0,0 +1,241 @@ + + + + + + + + EVAL]]]> + + + '2099-01-01')"; + }else{ + $r = "AND v_rh_view_1.formation_date BETWEEN '[PERIODE]' AND '[TOPERIODE]'"; + } + + return $r; + + // ?> + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000079.XML b/settings/RH000079.XML new file mode 100644 index 0000000..d4d966b --- /dev/null +++ b/settings/RH000079.XML @@ -0,0 +1,204 @@ + + + + + + + on prend même les formations sans dates + if('[UNDONE_FORMATIONS]' == 'Y'){ + $r = "AND ((v_rh_view_1.formation_date BETWEEN '[PERIODE]' AND '[TOPERIODE]') OR v_rh_view_1.formation_date > '2099-01-01')"; + }else{ + $r = "AND v_rh_view_1.formation_date BETWEEN '[PERIODE]' AND '[TOPERIODE]'"; + } + + return $r; + + // ?> + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000081.XML b/settings/RH000081.XML new file mode 100644 index 0000000..d4d1862 --- /dev/null +++ b/settings/RH000081.XML @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000082.XML b/settings/RH000082.XML new file mode 100644 index 0000000..7664de3 --- /dev/null +++ b/settings/RH000082.XML @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000087.XML b/settings/RH000087.XML new file mode 100644 index 0000000..b1bbfc1 --- /dev/null +++ b/settings/RH000087.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000088.XML b/settings/RH000088.XML new file mode 100644 index 0000000..6479fa2 --- /dev/null +++ b/settings/RH000088.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000089.XML b/settings/RH000089.XML new file mode 100644 index 0000000..486d695 --- /dev/null +++ b/settings/RH000089.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000090.XML b/settings/RH000090.XML new file mode 100644 index 0000000..ab9f65d --- /dev/null +++ b/settings/RH000090.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000091.XML b/settings/RH000091.XML new file mode 100644 index 0000000..411a1f9 --- /dev/null +++ b/settings/RH000091.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000092.XML b/settings/RH000092.XML new file mode 100644 index 0000000..d234f64 --- /dev/null +++ b/settings/RH000092.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000093.XML b/settings/RH000093.XML new file mode 100644 index 0000000..2ef81b4 --- /dev/null +++ b/settings/RH000093.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000094.XML b/settings/RH000094.XML new file mode 100644 index 0000000..fed7ab5 --- /dev/null +++ b/settings/RH000094.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000095.XML b/settings/RH000095.XML new file mode 100644 index 0000000..5a269b1 --- /dev/null +++ b/settings/RH000095.XML @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000096.XML b/settings/RH000096.XML new file mode 100644 index 0000000..a3c447b --- /dev/null +++ b/settings/RH000096.XML @@ -0,0 +1,1211 @@ + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000097.XML b/settings/RH000097.XML new file mode 100644 index 0000000..da4855b --- /dev/null +++ b/settings/RH000097.XML @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000098.XML b/settings/RH000098.XML new file mode 100644 index 0000000..d4a7176 --- /dev/null +++ b/settings/RH000098.XML @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000099.XML b/settings/RH000099.XML new file mode 100644 index 0000000..f8cae33 --- /dev/null +++ b/settings/RH000099.XML @@ -0,0 +1,652 @@ + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000100.XML b/settings/RH000100.XML new file mode 100644 index 0000000..56dd2ab --- /dev/null +++ b/settings/RH000100.XML @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000101.XML b/settings/RH000101.XML new file mode 100644 index 0000000..172a40c --- /dev/null +++ b/settings/RH000101.XML @@ -0,0 +1,371 @@ + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000102.XML b/settings/RH000102.XML new file mode 100644 index 0000000..df5a244 --- /dev/null +++ b/settings/RH000102.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000103.XML b/settings/RH000103.XML new file mode 100644 index 0000000..04ab386 --- /dev/null +++ b/settings/RH000103.XML @@ -0,0 +1,208 @@ + + + <![CDATA[ + = + var sal:String = ''; + var ets:String = ''; + + if (SELECT.NOM != '') { + sal = ' [DICT.RH.SALARIE#2] ' + SELECT.NOM; + } + if (SELECT.ENT != '') { + ent = ' ent. ' + SELECT.ENT; + } + if (SELECT.ETS != '') { + ets = ' ets. ' + SELECT.ETS; + } + + return 'Suivi CP ' + sal + ent + ets + ' sur période de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000104.XML b/settings/RH000104.XML new file mode 100644 index 0000000..1e3aa28 --- /dev/null +++ b/settings/RH000104.XML @@ -0,0 +1,2 @@ + + diff --git a/settings/RH000105.XML b/settings/RH000105.XML new file mode 100644 index 0000000..22016f2 --- /dev/null +++ b/settings/RH000105.XML @@ -0,0 +1,778 @@ + + + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000106.XML b/settings/RH000106.XML new file mode 100644 index 0000000..5c06025 --- /dev/null +++ b/settings/RH000106.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000107.XML b/settings/RH000107.XML new file mode 100644 index 0000000..67c9977 --- /dev/null +++ b/settings/RH000107.XML @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000108.XML b/settings/RH000108.XML new file mode 100644 index 0000000..0d61eac --- /dev/null +++ b/settings/RH000108.XML @@ -0,0 +1,427 @@ + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000109.XML b/settings/RH000109.XML new file mode 100644 index 0000000..315c532 --- /dev/null +++ b/settings/RH000109.XML @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000110.XML b/settings/RH000110.XML new file mode 100644 index 0000000..190c4de --- /dev/null +++ b/settings/RH000110.XML @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000111.XML b/settings/RH000111.XML new file mode 100644 index 0000000..461b5db --- /dev/null +++ b/settings/RH000111.XML @@ -0,0 +1,599 @@ + + + + + + + + 0 or v_rh_view_1.heures_payees > 0 then v_rh_view_1.salarie_id else null end'); + break; + case 'NBETPC': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETP': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPT': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'MSAL': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale'); + break; + case 'MTBRUT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut'); + break; + case 'MTFRAISIMPOS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_frais_imposables'); + break; + case 'MTCOTSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_salarie'); + break; + case 'MTCOTPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_patronale'); + break; + case 'MTNETIMPOSABLE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_imposable_salarie'); + break; + case 'MTNETAPAYER': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie'); + break; + case 'NBPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre_provisions'); + break; + case 'MTPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_provisions'); + break; + case 'MTMASSEPROV': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale_provisionnee'); + break; + default : + $tmp1 = sprintf($countDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale'); + } + + return str_replace(array('@date_debut@', '@date_fin@'), array($periodeDebut, $periodeFin), $tmp1) . ',' . str_replace(array('@date_debut@', '@date_fin@'), array($periodePrecDebut, $periodePrecFin), $tmp1); + } + + // ?> + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000112.XML b/settings/RH000112.XML new file mode 100644 index 0000000..0179624 --- /dev/null +++ b/settings/RH000112.XML @@ -0,0 +1,835 @@ + + + + + + + + + + 0 or v_rh_view_1.heures_payees > 0 then v_rh_view_1.salarie_id else null end'); + break; + case 'NBETP': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPT': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPTCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPTCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPC': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPCCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBETPCCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@::date, @date_fin@))'; + break; + case 'NBHC': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_contrat'); + break; + case 'NBHP': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees'); + break; + case 'NBHT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_travaillees'); + break; + case 'MTMASSE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale'); + break; + case 'MTHORMOYCHAR': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees').')'; + break; + case 'MTMASSEMOY': + $tmp1 = ' + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + '; + break; + case 'MTMASSEPCT': + $tmp1 = ' + base.cti_division( + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ), + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + ) * 100 + '; + break; + case 'MTNETAPAYERMOY' : + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut'); + break; + case 'MTBRUTMOY': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut').','.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature'); + break; + case 'MTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_avantage_nature'); + break; + case 'MTFRAISIMPOS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_frais_imposables'); + break; + case 'MTODNETSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_salarie'); + break; + case 'MTODNETPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_patronale'); + break; + case 'MTCOTSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_salarie'); + break; + case 'MTCOTPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_patronale'); + break; + case 'MTNETIMPOSABLE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_imposable_salarie'); + break; + case 'MTNETAPAYER': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie'); + break; + case 'BASE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.base'); + break; + case 'NOMBRE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre'); + break; + case 'NBPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre_provisions'); + break; + case 'MTPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_provisions'); + break; + case 'MTMASSEPROV': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale_provisionnee'); + break; + default : + $tmp1 = 'null'; + } + + $return = str_replace(array('@date_debut@', '@date_fin@'), array($periodeDebut, $periodeFin), $tmp1) . ',' . str_replace(array('@date_debut@', '@date_fin@'), array($periodePrecDebut, $periodePrecFin), $tmp1); + } else { + $ctiDivision = "base.cti_division(%s, %s)"; + $countDistinctCaseWhen = "count(DISTINCT CASE WHEN v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ %s THEN %s ELSE null END)"; + if($nb){ + $periodeDebut = "date_trunc('month','[TOPERIODE]'::date)"; + $periodePrecDebut = "date_trunc('month','[VIEW.TOPERIODE_D]'::date)"; + }else { + $periodeDebut = '\'[PERIODE]\'::date'; + $periodePrecDebut = '\'[VIEW.PERIODE_D]\'::date'; + } + $periodeFin = '\'[TOPERIODE]\'::date'; + $periodePrecFin = '\'[VIEW.TOPERIODE_D]\'::date'; + + switch ($data) { + case 'NSALPJ': + $tmp0 = "AND present_debut_mois = 1 AND to_char(date_debut_activite, 'YYYYMM') = to_char(@date_debut@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NSALH': + $tmp0 = 'AND sexe_code = \'M\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NCDI': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDI\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NCDD': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDD\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NSALF': + $tmp0 = 'AND sexe_code = \'F\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NSALH': + $tmp0 = 'AND sexe_code = \'H\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'AGEMOYDJ': + $tmp1 = 'base.cti_avg_distinct_on( + DISTINCT + (CASE WHEN 1=1 + AND v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ + THEN ARRAY[salarie_id::numeric, age_id::numeric] + ELSE null END) + ) + '; + break; + case 'NSALDJ': + $tmp0 = "AND present_fin_mois = 1 AND to_char(date_fin_activite, 'YYYYMM') = to_char(@date_fin@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + default : + $tmp1 = 'null'; + } + + $toReplace = array( + '@date_debut@', + '@date_fin@', + '@date_debut_efp@' + ); + + $curPeriod = array( + $periodeDebut, + $periodeFin, + "[PERIODE]" + ); + + $prevPeriod = array( + $periodePrecDebut, + $periodePrecFin, + "[VIEW.PERIODE_D]" + ); + + $return = str_replace($toReplace, $curPeriod, $tmp1) . ',' . str_replace($toReplace, $prevPeriod, $tmp1); + + } + + return $return; + } + // ?> + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000113.XML b/settings/RH000113.XML new file mode 100644 index 0000000..1d3482c --- /dev/null +++ b/settings/RH000113.XML @@ -0,0 +1,2765 @@ + + + + + + + + + + 0 or v_rh_view_1.heures_payees > 0 then v_rh_view_1.salarie_id else null end'); + break; + case 'NBETP': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_paye').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPT': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPTCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPTCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_travaille').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPC': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCCDI': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBETPCCDD': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_contrat').', base.cti_months_between(@date_debut@, @date_fin@))'; + break; + case 'NBHC': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_contrat'); + break; + case 'NBHP': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees'); + break; + case 'NBHT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_travaillees'); + break; + case 'MTMASSE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale'); + break; + case 'MTHORMOYCHAR': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees').')'; + break; + case 'MTMASSEMOY': + $tmp1 = ' + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + '; + break; + case 'MTMASSEPCT': + $tmp1 = ' + base.cti_division( + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ), + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + ) * 100 + '; + break; + case 'MTNETAPAYERMOY' : + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut'); + break; + case 'MTBRUTMOY': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut').','.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature'); + break; + case 'MTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_avantage_nature'); + break; + case 'MTFRAISIMPOS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_frais_imposables'); + break; + case 'MTODNETSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_salarie'); + break; + case 'MTODNETPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_patronale'); + break; + case 'MTCOTSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_salarie'); + break; + case 'MTCOTPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_patronale'); + break; + case 'MTNETIMPOSABLE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_imposable_salarie'); + break; + case 'MTNETAPAYER': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie'); + break; + case 'BASE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.base'); + break; + case 'NOMBRE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre'); + break; + case 'NBPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre_provisions'); + break; + case 'MTPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_provisions'); + break; + case 'MTMASSEPROV': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale_provisionnee'); + break; + default : + $tmp1 = 'null'; + } + + $return = str_replace(array('@date_debut@', '@date_fin@'), array($periodeDebut, $periodeFin), $tmp1); + } else { + $ctiDivision = "base.cti_division(%s, %s)"; + $countDistinctCaseWhen = "count(DISTINCT CASE WHEN v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ %s THEN %s ELSE null END)"; + $sumDistinctCaseWhen = "sum(CASE WHEN v_rh_view_1.date_paie BETWEEN @date_debut@ AND @date_fin@ THEN %s ELSE 0 END)"; + $sumDistinctCaseWhen2 = "sum(CASE WHEN v_rh_view_1.date_paie BETWEEN @date_debut@ AND @date_fin@ %s THEN %s ELSE 0 END)"; + $periodeDebut = '\'[PERIODE]\'::date'; + $periodeFin = '\'[TOPERIODE]\'::date'; + + switch ($data) { + case 'NSALPJ': + $tmp0 = "AND present_debut_mois = 1 AND to_char(date_debut_activite, 'YYYYMM') = to_char(@date_debut@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NSALH': + $tmp0 = 'AND sexe_code = \'M\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NCDI': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDI\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NCDD': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDD\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NSALF': + $tmp0 = 'AND sexe_code = \'F\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'AGEMOYDJ': + $tmp1 = 'base.cti_avg_distinct_on( + DISTINCT + (CASE WHEN 1=1 + AND v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ + THEN ARRAY[salarie_id::numeric, age_id::numeric] + ELSE null END) + ) + '; + break; + case 'ETPTH': + $tmp1 = ' + sum( + CASE WHEN v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ + THEN equivalent_temps_plein / base.cti_months_between(@date_debut@, @date_fin@) + ELSE 0 END + + )::numeric + + '; + break; + case 'NSALDJ': + $tmp0 = "AND present_fin_mois = 1 AND to_char(date_fin_activite, 'YYYYMM') = to_char(@date_fin@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'ABSMAL': + $tmp0 = 'AND rubrique_section_code[(select sequence from rh.t_classes where code = \'ALM_HRS\')] = \'01\''; + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen2, $tmp0, 'v_rh_view_1.heures_payees * -1.0').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_contrat').') * 100.0'; + break; + default : + $tmp1 = 'null'; + } + + $toReplace = array( + '@date_debut@', + '@date_fin@', + '@date_debut_efp@' + ); + + $curPeriod = array( + $periodeDebut, + $periodeFin, + "[PERIODE]" + ); + + $return = str_replace($toReplace, $curPeriod, $tmp1); + + } + + return $return; + } + + // ?> + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + 0) { + return "DEFAULT"; + } + else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + + + + + + 1){ + $nb_data = $i+1; + } + } + return $nb_data; + EVAL] + ]]> + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + EVAL] + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000114.XML b/settings/RH000114.XML new file mode 100644 index 0000000..3637d5e --- /dev/null +++ b/settings/RH000114.XML @@ -0,0 +1,4628 @@ + + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + 0 or v_rh_view_1.heures_payees > 0 then v_rh_view_1.salarie_id else null end'); + break; + case 'NBETP': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye'); + break; + case 'NBETPCDI': + $tmp1 = sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_paye'); + break; + case 'NBETPCDD': + $tmp1 = sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_paye'); + break; + case 'NBETPT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_travaille'); + break; + case 'NBETPTCDI': + $tmp1 = sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_travaille'); + break; + case 'NBETPTCDD': + $tmp1 = sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_travaille'); + break; + case 'NBETPC': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_contrat'); + break; + case 'NBETPCCDI': + $tmp1 = sprintf($sumDistinctCaseWhenETPCDI, 'v_rh_view_1.etp_contrat'); + break; + case 'NBETPCCDD': + $tmp1 = sprintf($sumDistinctCaseWhenETPCDD, 'v_rh_view_1.etp_contrat'); + break; + case 'NBHC': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_contrat'); + break; + case 'NBHP': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees'); + break; + case 'NBHT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_travaillees'); + break; + case 'MTMASSE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale'); + break; + case 'MTHORMOYCHAR': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.heures_payees').')'; + break; + case 'MTMASSEMOY': + $tmp1 = ' + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + '; + break; + case 'MTMASSEPCT': + $tmp1 = ' + base.cti_division( + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ), + base.cti_division('. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale').','. + sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').' + ) + ) * 100 + '; + break; + case 'MTNETAPAYERMOY' : + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie').', '.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUT': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut'); + break; + case 'MTBRUTMOY': + $tmp1 = 'base.cti_division('.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut').','.sprintf($sumDistinctCaseWhen, 'v_rh_view_1.etp_paye').')'; + break; + case 'MTBRUTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_brut + v_rh_view_1.montant_avantage_nature'); + break; + case 'MTAVANTAGE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_avantage_nature'); + break; + case 'MTFRAISIMPOS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_frais_imposables'); + break; + case 'MTODNETSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_salarie'); + break; + case 'MTODNETPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_od_net_patronale'); + break; + case 'MTCOTSALARIE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_salarie'); + break; + case 'MTCOTPATRONALE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_cotisation_patronale'); + break; + case 'MTNETIMPOSABLE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_imposable_salarie'); + break; + case 'MTNETAPAYER': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_net_a_payer_salarie'); + break; + case 'BASE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.base'); + break; + case 'NOMBRE': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre'); + break; + case 'NBPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.nombre_provisions'); + break; + case 'MTPROVISIONS': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_provisions'); + break; + case 'MTMASSEPROV': + $tmp1 = sprintf($sumDistinctCaseWhen, 'v_rh_view_1.montant_masse_salariale_provisionnee'); + break; + default : + $tmp1 = 'null'; + } + + $return = str_replace(array('@date_debut@', '@date_fin@'), array($periodeDebut, $periodeFin), $tmp1) . ',' . str_replace(array('@date_debut@', '@date_fin@'), array($periodePrecDebut, $periodePrecFin), $tmp1); + } else { + $ctiDivision = "base.cti_division(%s, %s)"; + $countDistinctCaseWhen = "count(DISTINCT CASE WHEN v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ %s THEN %s ELSE null END)"; + $periodeDebut = '\'[PERIODE]\'::date'; + $periodeFin = '\'[TOPERIODE]\'::date'; + $periodePrecDebut = '\'[VIEW.PERIODE_D]\'::date'; + $periodePrecFin = '\'[VIEW.TOPERIODE_D]\'::date'; + + switch ($data) { + case 'NSALPJ': + $tmp0 = "AND present_debut_mois = 1 AND to_char(date_debut_activite, 'YYYYMM') = to_char(@date_debut@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NSALH': + $tmp0 = 'AND sexe_code = \'M\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NCDI': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDI\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NCDD': + $tmp0 = 'AND type_contrat_section_code[9] = \'CDD\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'contrat_id'); + break; + case 'NSALF': + $tmp0 = 'AND sexe_code = \'F\''; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'AGEMOYDJ': + $tmp1 = 'base.cti_avg_distinct_on( + DISTINCT + (CASE WHEN 1=1 + AND v_rh_view_1.date_fin_activite BETWEEN @date_debut@ AND @date_fin@ + THEN ARRAY[salarie_id::numeric, age_id::numeric] + ELSE null END) + ) + '; + break; + case 'NSALDJ': + $tmp0 = "AND present_fin_mois = 1 AND to_char(date_fin_activite, 'YYYYMM') = to_char(@date_fin@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + case 'NSALPJ': + $tmp0 = "AND present_debut_mois = 1 AND to_char(date_debut_activite, 'YYYYMM') = to_char(@date_fin@, 'YYYYMM')"; + $tmp1 = sprintf($countDistinctCaseWhen, $tmp0, 'salarie_id'); + break; + default : + $tmp1 = 'null'; + } + + $toReplace = array( + '@date_debut@', + '@date_fin@', + '@date_debut_efp@' + ); + + $curPeriod = array( + $periodeDebut, + $periodeFin, + "[PERIODE]" + ); + + $prevPeriod = array( + $periodePrecDebut, + $periodePrecFin, + "[VIEW.PERIODE_D]" + ); + + $return = str_replace($toReplace, $curPeriod, $tmp1) . ',' . str_replace($toReplace, $prevPeriod, $tmp1); + + } + + return $return; + } + + // ?> + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000115.XML b/settings/RH000115.XML new file mode 100644 index 0000000..6bb9c03 --- /dev/null +++ b/settings/RH000115.XML @@ -0,0 +1,759 @@ + + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + 0) { + return "DEFAULT"; + } + else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000116.XML b/settings/RH000116.XML new file mode 100644 index 0000000..807ecff --- /dev/null +++ b/settings/RH000116.XML @@ -0,0 +1,801 @@ + + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000117.XML b/settings/RH000117.XML new file mode 100644 index 0000000..b8731ba --- /dev/null +++ b/settings/RH000117.XML @@ -0,0 +1,4471 @@ + + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000118.XML b/settings/RH000118.XML new file mode 100644 index 0000000..d7793c0 --- /dev/null +++ b/settings/RH000118.XML @@ -0,0 +1,2674 @@ + + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + 0) { + return "DEFAULT"; + } + else { + return "indicateurs[1]"; + } + + EVAL]]]> + + + + 1){ + $nb_data = $i+1; + } + } + return $nb_data; + EVAL] + ]]> + + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + EVAL] + ]]> + + + + + ENVIRONMENT as $environmentNode) { + foreach ($environmentNode->PROPERTY as $propertyNode) { + if($propertyNode['name'] == 'OPTRH_BILAN_SOCIAL'){ + $bilan_value = $propertyNode['value']; + } + } + } + return $bilan_value; + EVAL] + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000119.XML b/settings/RH000119.XML new file mode 100644 index 0000000..f0b0f27 --- /dev/null +++ b/settings/RH000119.XML @@ -0,0 +1,1065 @@ + + + + + + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[19]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000120.XML b/settings/RH000120.XML new file mode 100644 index 0000000..6828c5c --- /dev/null +++ b/settings/RH000120.XML @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000121.XML b/settings/RH000121.XML new file mode 100644 index 0000000..6fe5b48 --- /dev/null +++ b/settings/RH000121.XML @@ -0,0 +1,10 @@ + + + diff --git a/settings/RH000122.XML b/settings/RH000122.XML new file mode 100644 index 0000000..60285fa --- /dev/null +++ b/settings/RH000122.XML @@ -0,0 +1,346 @@ + + + + + <![CDATA[= + var title:String = 'Salarié ' + SELECT.NOM + ':'; + + if ('[CNT_ID]' != '') {title = title + ' - Contrat n° ' + SELECT.CNT_ID;} + + if ('[CNTM_ID]' != '') {title = title + ' - Contrat mois n° ' + SELECT.CNTM_ID;} + + return title; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000125.XML b/settings/RH000125.XML new file mode 100644 index 0000000..0182246 --- /dev/null +++ b/settings/RH000125.XML @@ -0,0 +1,12 @@ + + + diff --git a/settings/RH000126.XML b/settings/RH000126.XML new file mode 100644 index 0000000..aaa018a --- /dev/null +++ b/settings/RH000126.XML @@ -0,0 +1,11 @@ + + + diff --git a/settings/RH000127.XML b/settings/RH000127.XML new file mode 100644 index 0000000..4bc21f7 --- /dev/null +++ b/settings/RH000127.XML @@ -0,0 +1,11 @@ + + + diff --git a/settings/RH000128.XML b/settings/RH000128.XML new file mode 100644 index 0000000..e2e6f45 --- /dev/null +++ b/settings/RH000128.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000129.XML b/settings/RH000129.XML new file mode 100644 index 0000000..a4c0dad --- /dev/null +++ b/settings/RH000129.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000130.XML b/settings/RH000130.XML new file mode 100644 index 0000000..0cf3baa --- /dev/null +++ b/settings/RH000130.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000131.XML b/settings/RH000131.XML new file mode 100644 index 0000000..7fd77a7 --- /dev/null +++ b/settings/RH000131.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000132.XML b/settings/RH000132.XML new file mode 100644 index 0000000..0c79697 --- /dev/null +++ b/settings/RH000132.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000133.XML b/settings/RH000133.XML new file mode 100644 index 0000000..17587e3 --- /dev/null +++ b/settings/RH000133.XML @@ -0,0 +1,3 @@ + + + diff --git a/settings/RH000134.XML b/settings/RH000134.XML new file mode 100644 index 0000000..0c64fd8 --- /dev/null +++ b/settings/RH000134.XML @@ -0,0 +1,777 @@ + + + + + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH000135.XML b/settings/RH000135.XML new file mode 100644 index 0000000..6837a2d --- /dev/null +++ b/settings/RH000135.XML @@ -0,0 +1,294 @@ + + + + + + + + + EVAL]]]> + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000136.XML b/settings/RH000136.XML new file mode 100644 index 0000000..55a470d --- /dev/null +++ b/settings/RH000136.XML @@ -0,0 +1,735 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000137.XML b/settings/RH000137.XML new file mode 100644 index 0000000..ab9a281 --- /dev/null +++ b/settings/RH000137.XML @@ -0,0 +1,381 @@ + + + + + + + + EVAL]]]> + + + + $tata = RH000137_calcTablesSQL('[HEURESCONTRAT]', '[HEURESPAYEES]', '[HEURESTRAVAILLEES]') + + var_dump($toto); + var_dump($tata); + + // ?> + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000138.XML b/settings/RH000138.XML new file mode 100644 index 0000000..39b24c0 --- /dev/null +++ b/settings/RH000138.XML @@ -0,0 +1,322 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/RH000139.XML b/settings/RH000139.XML new file mode 100644 index 0000000..de044d7 --- /dev/null +++ b/settings/RH000139.XML @@ -0,0 +1,18 @@ + + + diff --git a/settings/RH000140.XML b/settings/RH000140.XML new file mode 100644 index 0000000..ad9a67c --- /dev/null +++ b/settings/RH000140.XML @@ -0,0 +1,291 @@ + + + + + + + + + 0) { + return "DEFAULT"; + } else { + return "indicateurs[19]"; + } + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH_components.XML b/settings/RH_components.XML new file mode 100644 index 0000000..7b80a58 --- /dev/null +++ b/settings/RH_components.XML @@ -0,0 +1,1918 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = '[SIGNAL_PERIODE]'";} + if ('[SIGNAL_TOPERIODE]' != '-1') {$subselect = "$subselect AND date_signalement <= '[SIGNAL_TOPERIODE]'";} + + if ('[CORRECT_PERIODE]' != '-1') {$subselect = "$subselect AND date_correction >= '[CORRECT_PERIODE]'";} + if ('[CORRECT_TOPERIODE]' != '-1') {$subselect = "$subselect AND date_correction <= '[CORRECT_TOPERIODE]'";} + + return "$subselect"; + + EVAL]]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = parseInt(mois_toperiode)) { + return SELECT.TOPERIODE; + } + else { + return annee + mois_fin_string; + } + } + } + else if (SELECT.GROUPBY == 'TRIMACT' || SELECT.GROUPBY == 'TRIMCAL') { + if (ROW.COD == ROW.COD2) { + if (parseInt(ROW.COD2) <= parseInt(mois_toperiode)) { + return annee_toperiode + ROW.COD2 + } + else { + return (parseInt(annee_toperiode) - 1).toString() + ROW.COD2; + } + } + else { + if (mois_fin <= parseInt(mois_toperiode)) { + return annee_toperiode + mois_fin_string; + } + else { + + if (mois_debut <= parseInt(mois_toperiode)) { + return SELECT.TOPERIODE; + } + else { + return (parseInt(annee_toperiode) - 1).toString() + mois_fin_string; + } + } + } + } + else if (parseInt(row_cod) < parseInt(mois_toperiode)) { + return annee_toperiode + row_cod; + } + else { + if (ROW.COD == ROW.COD2) { + if (parseInt(ROW.COD2) <= parseInt(mois_toperiode)) { + return annee_toperiode + ROW.COD2; + } + else { + return (parseInt(annee_toperiode) - 1).toString() + ROW.COD2; + } + } + else { + return SELECT.TOPERIODE; + } + } + } + } + else if (SELECT.GROUPBY == 'ATRIMACT' || SELECT.GROUPBY_2 == 'ATRIMACT' || SELECT.GROUPBY == 'ATRIMCAL' || SELECT.GROUPBY_2 == 'ATRIMCAL') { + if (SELECT.GROUPBY == 'ATRIMACT' || SELECT.GROUPBY == 'ATRIMCAL') { + + annee = ROW.COD1.substr(0,4); + mois_fin = 3 * parseInt(ROW.COD1.substr(-1)); + mois_fin_string = mois_fin < 10 ? '0' + mois_fin.toString() : mois_fin.toString(); + + if (annee == annee_periode && mois_fin >= parseInt(mois_toperiode)) { + return SELECT.TOPERIODE; + } + else { + return annee + mois_fin_string; + } + } + else { + + annee = ROW.COD2.substr(0,4); + mois_fin = 3 * parseInt(ROW.COD2.substr(-1)); + mois_fin_string = mois_fin < 10 ? '0' + mois_fin.toString() : mois_fin.toString(); + + if (ROW.COD == ROW.COD2) { + + if (annee == annee_toperiode && mois_fin >= parseInt(mois_toperiode)) { + return SELECT.TOPERIODE; + } + else { + return annee + mois_fin_string; + } + } + else { + + if ((SELECT.GROUPBY == 'AACT' || SELECT.GROUPBY == 'ACAL') && ROW.COD1 != annee_toperiode) { + return ROW.COD1 + '12'; + } + else { + return SELECT.TOPERIODE; + } + } + } + } + if (SELECT.GROUPBY == 'TRIMACT' || SELECT.GROUPBY_2 == 'TRIMACT' || SELECT.GROUPBY == 'TRIMCAL' || SELECT.GROUPBY_2 == 'TRIMCAL') { + mois_debut = 1 + 3 * (parseInt(ROW.COD2.substr(-1)) - 1); + mois_fin = 3 * parseInt(ROW.COD2.substr(-1)); + mois_fin_string = mois_fin < 10 ? '0' + mois_fin.toString() : mois_fin.toString(); + + if (SELECT.GROUPBY == 'TRIMACT' || SELECT.GROUPBY == 'TRIMCAL') { + + mois_debut = 1 + 3 * (parseInt(ROW.COD1.substr(-1)) - 1); + mois_fin = 3 * parseInt(ROW.COD1.substr(-1)); + mois_fin_string = mois_fin < 10 ? '0' + mois_fin.toString() : mois_fin.toString(); + + if (mois_fin <= parseInt(mois_toperiode)) { + return annee_toperiode + mois_fin_string; + } + else { + + if (mois_debut <= parseInt(mois_toperiode)) { + return SELECT.TOPERIODE; + } + else { + return (parseInt(annee_toperiode) -1).toString() + mois_fin_string; + } + } + } + else if (SELECT.GROUPBY == 'AACT' || SELECT.GROUPBY == 'ACAL') { + + if (ROW.COD == ROW.COD2) { + + if (ROW.COD1 == annee_toperiode && mois_fin >= parseInt(mois_toperiode)) { + return SELECT.TOPERIODE; + } + else { + return ROW.COD1 + mois_fin_string; + } + } + else { + + if (ROW.COD1 == annee_toperiode) { + return SELECT.TOPERIODE; + } + else { + return ROW.COD1 + '12'; + } + } + } + else { + + if (ROW.COD == ROW.COD2) { + + if (mois_fin <= parseInt(mois_toperiode)) { + return annee_toperiode + mois_fin_string; + } + else { + + if (mois_debut <= mois_toperiode) { + return SELECT.TOPERIODE; + } + else { + return (parseInt(annee_toperiode) -1).toString() + mois_fin_string; + } + } + } + else { + return SELECT.TOPERIODE; + } + } + } + else if (SELECT.GROUPBY == 'AACT'|| SELECT.GROUPBY_2 == 'AACT' || SELECT.GROUPBY == 'ACAL'|| SELECT.GROUPBY_2 == 'ACAL') { + + row_cod = (SELECT.GROUPBY == 'AACT'|| SELECT.GROUPBY == 'ACAL') ? ROW.COD1 : ROW.COD2; + + if (row_cod == annee_toperiode) { + return SELECT.TOPERIODE; + } + else { + return row_cod + '12'; + } + } + else { + if (COLUMN.NAME == 'N1') {return VIEW.COLF1} + if (COLUMN.NAME == 'N2') {return VIEW.COLF2} + if (COLUMN.NAME == 'N3') {return VIEW.COLF3} + if (COLUMN.NAME == 'N4') {return VIEW.COLF4} + if (COLUMN.NAME == 'N5') {return VIEW.COLF5} + if (COLUMN.NAME == 'N6') {return VIEW.COLF6} + if (COLUMN.NAME == 'N7') {return VIEW.COLF7} + if (COLUMN.NAME == 'N8') {return VIEW.COLF8} + if (COLUMN.NAME == 'N9') {return VIEW.COLF9} + if (COLUMN.NAME == 'N10') {return VIEW.COLF10} + if (COLUMN.NAME == 'N11') {return VIEW.COLF11} + if (COLUMN.NAME == 'N12') {return VIEW.COLF12} + if (COLUMN.NAME == 'N13') {return VIEW.COLD13} + if (COLUMN.NAME == 'N14') {return VIEW.COLD14} + if (COLUMN.NAME == 'N15') {return VIEW.COLD15} + if (COLUMN.NAME == 'N16') {return VIEW.COLD16} + if (COLUMN.NAME == 'N17') {return VIEW.COLD17} + if (COLUMN.NAME == 'N18') {return VIEW.COLD18} + if (COLUMN.NAME == 'N19') {return VIEW.COLD19} + if (COLUMN.NAME == 'N20') {return VIEW.COLD20} + if (COLUMN.NAME == 'N21') {return VIEW.COLD21} + if (COLUMN.NAME == 'N22') {return VIEW.COLD22} + if (COLUMN.NAME == 'N23') {return VIEW.COLD23} + if (COLUMN.NAME == 'N24') {return VIEW.COLD24} + if (COLUMN.NAME == 'N25') {return VIEW.COLD25} + if (COLUMN.NAME == 'N26') {return VIEW.COLD26} + if (COLUMN.NAME == 'N27') {return VIEW.COLD27} + if (COLUMN.NAME == 'N28') {return VIEW.COLD28} + if (COLUMN.NAME == 'N29') {return VIEW.COLD29} + if (COLUMN.NAME == 'N30') {return VIEW.COLD30} + if (COLUMN.NAME == 'N31') {return VIEW.COLD31} + return SELECT.TOPERIODE; + } + + ]]> + + + + 0) { + if (SELECT.GROUPBY_2.substr(3, 3) != "CLS") { + tmpGroupBy2 = SELECT.GROUPBY_2; + GROUPBY_2_OID = 'DT' + ROW.OID2; + if (tmpGroupBy2 == 'CPD') { + GROUPBY_2_OID = 'D2' + ROW.OID2; + } + if (tmpGroupBy2 == 'ETS') { + GROUPBY_2_OID = 'D2' + ROW.OID2; + } + } else { + tmpGroupBy2 = SELECT.GROUPBY_2.substr(0, 3); + GROUPBY_2_OID = 'LS' + SELECT.GROUPBY_2.substr(6, 2) + ROW.OID2; + } + } + + // Group by 3. + if (Number(ROW.OID3) > 0) { + if (SELECT.GROUPBY_3.substr(3, 3) != "CLS") { + tmpGroupBy3 = SELECT.GROUPBY_3; + GROUPBY_3_OID = 'DT' + ROW.OID3; + if (tmpGroupBy3 == 'CPD') { + GROUPBY_3_OID = 'D2' + ROW.OID3; + } + if (tmpGroupBy3 == 'ETS') { + GROUPBY_3_OID = 'D2' + ROW.OID3; + } + } else { + tmpGroupBy3 = SELECT.GROUPBY_3.substr(0, 3); + GROUPBY_3_OID = 'LS' + SELECT.GROUPBY_3.substr(6, 2) + ROW.OID3; + } + } + + LINKVARIABLES['GROUPBY'] = '-1' + LINKVARIABLES['GROUPBY_2'] = 'SAL' + LINKVARIABLES['GROUPBY_TAB'] = 'AUTO' + + var groupByAssoc:Array = new Array(); + groupByAssoc['AN1'] = 'SECTION_ANALYTIQUE_NG_4_1'; // Specificite pour ces sections analytiques cf. groupByAssoc2 plus bas. + groupByAssoc['AN2'] = 'SECTION_ANALYTIQUE_NG_4_2'; // idem. + groupByAssoc['AN3'] = 'SECTION_ANALYTIQUE_NG_4_3'; // idem. + groupByAssoc['AGE'] = 'AGE'; + groupByAssoc['ANC'] = 'ANCIENNETE'; + groupByAssoc['ATC'] = 'ACCIDENT_CIRCONSTANCE'; + groupByAssoc['ATL'] = 'ACCIDENT_LIEU'; + groupByAssoc['ATN'] = 'ACCIDENT_NATURE'; + groupByAssoc['ATS'] = 'ACCIDENT_SIEGE'; + groupByAssoc['CAC'] = 'CATEGORIE_CONGE'; + groupByAssoc['CAE'] = 'CADRE_EMPLOI'; + groupByAssoc['CAS'] = 'CATEGORIE_STATUTAIRE'; + groupByAssoc['CEM'] = 'CODE_EMPLOI'; + groupByAssoc['COI'] = 'COMPTE_SALARIE'; + groupByAssoc['CPD'] = 'CODE_POSTAL'; + groupByAssoc['CPO'] = 'CODE_POSTAL'; + groupByAssoc['CPT'] = 'COMPTE'; + groupByAssoc['CSC'] = 'CATEGORIE_SOCIO_PRO'; + groupByAssoc['ENT'] = 'ETABLISSEMENT'; + groupByAssoc['ETS'] = 'ETABLISSEMENT'; + groupByAssoc['FIL'] = 'FILIERE'; + groupByAssoc['FOR'] = 'FORMATION'; + groupByAssoc['GCP'] = 'COMMISSION_PARITAIRE'; + groupByAssoc['GCT'] = 'GROUPE_COTISANT'; + groupByAssoc['GRG'] = 'GRILLE_GROUPE'; + groupByAssoc['GRI'] = 'GRILLE'; + groupByAssoc['LEB'] = 'LETTRE_BUDGETAIRE'; + groupByAssoc['MOA'] = 'MOTIF_ARRET'; + groupByAssoc['MPA'] = 'PRECISION_MOTIF_ARRET'; + groupByAssoc['MTD'] = 'MOTIF_DEBUT_CONTRAT'; + groupByAssoc['MTF'] = 'MOTIF_FIN_CONTRAT'; + groupByAssoc['NAT'] = 'NATIONALITE'; + groupByAssoc['NIR'] = 'SALARIE'; // L'oid du NIR correspond à l'oid du salarié + groupByAssoc['ORC'] = 'ORGANISME_COTISATION'; + groupByAssoc['PAB'] = 'PLANNING_TYPE_ABSENCE'; + groupByAssoc['PEP'] = 'PLANNING_ETABLISSEMENT'; + groupByAssoc['PNI'] = 'PLANNING_NIVEAU'; + groupByAssoc['PQP'] = 'PLANNING_QUALIFICATION'; + groupByAssoc['PQU'] = 'PLANNING_QUALIFICATION_SOURCE'; + groupByAssoc['PSE'] = 'PLANNING_SERVICE_SOURCE'; + groupByAssoc['PSP'] = 'PLANNING_SERVICE'; + groupByAssoc['QUA'] = 'QUALIFICATION'; + groupByAssoc['RUP'] = 'RUBRIQUE'; + groupByAssoc['SAC'] = 'SECTION_ANALYTIQUE_COMPTA'; + groupByAssoc['SAL'] = 'SALARIE'; + groupByAssoc['SAP'] = 'SECTION_ANALYTIQUE_PAIE'; + groupByAssoc['SER'] = 'SERVICE'; + groupByAssoc['POL'] = 'POLE'; + groupByAssoc['POP'] = 'POPULATION'; + groupByAssoc['SEX'] = 'SEXE'; + groupByAssoc['SFA'] = 'SITUATION_FAMILLE'; + groupByAssoc['SIN'] = 'SOCIETE_INTERIM'; + groupByAssoc['SPE'] = 'SPECIALITE'; + groupByAssoc['SRP'] = 'SALARIE_REMPLACE'; + groupByAssoc['STA'] = 'STATUT'; + groupByAssoc['TCN'] = 'TYPE_CONTRAT'; + groupByAssoc['THO'] = 'TYPE_HORAIRE'; + groupByAssoc['TTT'] = 'TYPE_TEMPS_TRAVAIL'; + groupByAssoc['UNF'] = 'UNITE_FONCTIONNELLE'; + + if (groupByAssoc[tmpGroupBy] !== undefined) { + LINKVARIABLES[groupByAssoc[tmpGroupBy]] = GROUPBY_OID; + } + if (groupByAssoc[tmpGroupBy2] !== undefined) { + LINKVARIABLES[groupByAssoc[tmpGroupBy2]] = GROUPBY_2_OID; + } + if (groupByAssoc[tmpGroupBy3] !== undefined) { + LINKVARIABLES[groupByAssoc[tmpGroupBy3]] = GROUPBY_3_OID; + } + + var groupByAssoc2:Array = new Array(); + groupByAssoc2['AN1'] = 'PLAN_ANALYTIQUE_4'; // Specificite pour ces sections analytiques. + groupByAssoc2['AN2'] = 'PLAN_ANALYTIQUE_4'; // idem. + groupByAssoc2['AN3'] = 'PLAN_ANALYTIQUE_4'; // idem. + + if (groupByAssoc2[tmpGroupBy] !== undefined) { + LINKVARIABLES[groupByAssoc2[tmpGroupBy]] = 1; + } + if (groupByAssoc2[tmpGroupBy2] !== undefined) { + LINKVARIABLES[groupByAssoc2[tmpGroupBy2]] = 2; + } + if (groupByAssoc2[tmpGroupBy3] !== undefined) { + LINKVARIABLES[groupByAssoc2[tmpGroupBy3]] = 3; + } + + return 'OK'; + + ]]> + + + + + + diff --git a/settings/RH_dboptimizer.XML b/settings/RH_dboptimizer.XML new file mode 100644 index 0000000..5301356 --- /dev/null +++ b/settings/RH_dboptimizer.XML @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings/RH_globals.XML b/settings/RH_globals.XML new file mode 100644 index 0000000..be88292 --- /dev/null +++ b/settings/RH_globals.XML @@ -0,0 +1,2439 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/SP000001.XML b/settings/SP000001.XML new file mode 100644 index 0000000..06625f6 --- /dev/null +++ b/settings/SP000001.XML @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/SP000002.XML b/settings/SP000002.XML new file mode 100644 index 0000000..584802f --- /dev/null +++ b/settings/SP000002.XML @@ -0,0 +1,400 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/SP_globals.XML b/settings/SP_globals.XML new file mode 100644 index 0000000..c14982c --- /dev/null +++ b/settings/SP_globals.XML @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/dashboard_indicators/iCTI_import_planning.XML b/settings/dashboard_indicators/iCTI_import_planning.XML new file mode 100644 index 0000000..e8c0c83 --- /dev/null +++ b/settings/dashboard_indicators/iCTI_import_planning.XML @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/settings/dashboard_indicators/iCTI_import_rh.XML b/settings/dashboard_indicators/iCTI_import_rh.XML new file mode 100644 index 0000000..50f0502 --- /dev/null +++ b/settings/dashboard_indicators/iCTI_import_rh.XML @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/settings/dashboard_indicators/iCTI_import_rh_consolidation.XML b/settings/dashboard_indicators/iCTI_import_rh_consolidation.XML new file mode 100644 index 0000000..8ceda70 --- /dev/null +++ b/settings/dashboard_indicators/iCTI_import_rh_consolidation.XML @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/settings/dashboard_indicators/iCTI_paie_SHS.XML b/settings/dashboard_indicators/iCTI_paie_SHS.XML new file mode 100644 index 0000000..0deb44f --- /dev/null +++ b/settings/dashboard_indicators/iCTI_paie_SHS.XML @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/settings/dashboard_indicators/iCTI_rh_integrite_tables.XML b/settings/dashboard_indicators/iCTI_rh_integrite_tables.XML new file mode 100644 index 0000000..af21aaf --- /dev/null +++ b/settings/dashboard_indicators/iCTI_rh_integrite_tables.XML @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + diff --git a/settings/dashboard_indicators/iCTI_rh_nouveau_parametre.XML b/settings/dashboard_indicators/iCTI_rh_nouveau_parametre.XML new file mode 100644 index 0000000..e7c1aba --- /dev/null +++ b/settings/dashboard_indicators/iCTI_rh_nouveau_parametre.XML @@ -0,0 +1,25 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/swf/CTI_RH_Synchronize.mxml b/swf/CTI_RH_Synchronize.mxml new file mode 100644 index 0000000..ada5a05 --- /dev/null +++ b/swf/CTI_RH_Synchronize.mxml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/swf/CTI_RH_TablesManager.mxml b/swf/CTI_RH_TablesManager.mxml new file mode 100644 index 0000000..4e26c9b --- /dev/null +++ b/swf/CTI_RH_TablesManager.mxml @@ -0,0 +1,2149 @@ + + + + 0) { + has_refsettings = true; + } + + // Charge la liste des prestataires RH + _prestataire_collection = new CTI_ArrayCollection(); + _prestataire_collection.loadXMLList(resultatService.PRESTATAIRE); + } + + + + searchChange(); + setTimeout(setBuildComplete, 1000); + } + } + + private function setBuildComplete():void { + buildComplete = true; + } + + private function resize():void { + } + + private function searchChange():void { + if (list_collection.filterFunction == null) { + list_collection.filterFunction = filterFunction; + } + list_collection.refresh(); + } + + // Filter function + public function filterFunction(item:Object):Boolean { + var result:Boolean = true; + + if (Number(item.oid) >= 0) { + if (textSearch_GUI.text != "") { + result = false + + for each (var attributeName:String in list_collection.attributesArray) { + if (item[attributeName].toString().toUpperCase().indexOf(textSearch_GUI.text.toUpperCase()) >= 0) { + result=true; + break; + } + } + + } + if (result == true) { + if (refSearch_GUI.selected == true) { + if (item.hasOwnProperty("nbref")) { + if (Number(item.nbref.toString()) <= 0) { + if (item.hasOwnProperty("nbref2")) { + if (Number(item.nbref.toString()) <= 0) { + result = false; + } + } + else { + result = false; + } + } + } + + } + } + if (result == true) { + if (code_calcul_search_GUI.selected == true) { + if (item.hasOwnProperty("code_calcul")) { + if (Number(item.code_calcul.toString()) <= 0) { + result = false; + } + }else { + result = false; + } + } + } + } + return result; + } + + public function clearSearchText():void { + textSearch_GUI.text = ""; + searchChange(); + } + + public function getRecord():void { + if (recordUpdated == true) { + return; + } + if (tableCode == "POP") { + if (POP_list_GUI.selectedIndex < 0) { + return; + } + currendRecordItem = POP_list_GUI.selectedItem as Object; + } else if (tableCode == "PER") { + if (PER_list_GUI.selectedIndex < 0) { + return; + } + currendRecordItem = PER_list_GUI.selectedItem as Object; + } else if (tableCode == "EXC") { + /*if (event.columnIndex == 0) { + return; + }*/ + if (qimport) { + return; + } + if (EXC_list_GUI.selectedIndex < 0) { + return; + } + currendRecordItem = EXC_list_GUI.selectedItem as Object; + } else { + if (list_GUI.selectedIndex < 0) { + return; + } + currendRecordItem = list_GUI.selectedItem as Object; + } + + showDetail(); + } + + public function addRecord():void { + + if (currendRecordItem == null) { + + currendRecordItem = new Object(); + currendRecordItem.oid = "-1"; + currendRecordItem.code = ""; + currendRecordItem.code_original = ""; + currendRecordItem.texte = ""; + currendRecordItem.texte_court = ""; + currendRecordItem.nbref = 0; + + currendRecordItem.valeur = ""; + currendRecordItem.valeur_date = ""; + currendRecordItem.code_calcul = ""; + currendRecordItem.base_calcul_etp = ""; + currendRecordItem.code_ets_planning = ""; + currendRecordItem.code_ent_planning = ""; + currendRecordItem.unite = ""; + currendRecordItem.coefficient = ""; + currendRecordItem.coefficient_base = ""; + currendRecordItem.coefficient_nombre = ""; + currendRecordItem.coefficient_txs = ""; + currendRecordItem.coefficient_txp = ""; + currendRecordItem.coefficient_nombre = ""; + currendRecordItem.user_modified = ""; + + currendRecordItem.p_cumul = ""; + currendRecordItem.p_detail = ""; + currendRecordItem.p_nombre = ""; + currendRecordItem.s_nombre = ""; + currendRecordItem.c_nombre = ""; + currendRecordItem.p_base = ""; + currendRecordItem.s_base = ""; + currendRecordItem.c_base = ""; + currendRecordItem.p_heures_contrat = ""; + currendRecordItem.s_heures_contrat = ""; + currendRecordItem.c_heures_contrat = ""; + currendRecordItem.p_heures_payees = ""; + currendRecordItem.s_heures_payees = ""; + currendRecordItem.c_heures_payees = ""; + currendRecordItem.p_heures_travaillees = ""; + currendRecordItem.s_heures_travaillees = ""; + currendRecordItem.c_heures_travaillees = ""; + currendRecordItem.p_masse_salariale = ""; + currendRecordItem.s_masse_salariale = ""; + currendRecordItem.c_masse_salariale = ""; + currendRecordItem.p_brut = ""; + currendRecordItem.s_brut = ""; + currendRecordItem.c_brut = ""; + currendRecordItem.p_avantage_nature = ""; + currendRecordItem.s_avantage_nature = ""; + currendRecordItem.c_avantage_nature = ""; + currendRecordItem.p_frais_imposables = ""; + currendRecordItem.s_frais_imposables = ""; + currendRecordItem.c_frais_imposables = ""; + currendRecordItem.p_cotisation_salarie = ""; + currendRecordItem.s_cotisation_salarie = ""; + currendRecordItem.c_cotisation_salarie = ""; + currendRecordItem.p_cotisation_patronale = ""; + currendRecordItem.s_cotisation_patronale = ""; + currendRecordItem.c_cotisation_patronale = ""; + currendRecordItem.p_od_net_salarie = ""; + currendRecordItem.s_od_net_salarie = ""; + currendRecordItem.c_od_net_salarie = ""; + currendRecordItem.p_od_net_patronale = ""; + currendRecordItem.s_od_net_patronale = ""; + currendRecordItem.c_od_net_patronale = ""; + currendRecordItem.p_net_imposable = ""; + currendRecordItem.s_net_imposable = ""; + currendRecordItem.c_net_imposable = ""; + currendRecordItem.p_net_a_payer = ""; + currendRecordItem.s_net_a_payer = ""; + currendRecordItem.c_net_a_payer = ""; + + + switch (tableCode) { + + case "ETA" : + currendRecordItem.finess_id = "0"; + break; + + case "TRF" : + + currendRecordItem.texte_date = ""; + currendRecordItem.texte_from = ""; + currendRecordItem.texte_to = ""; + currendRecordItem.date_debut = "0001-01-01"; + currendRecordItem.date_fin = "2099-12-31"; + currendRecordItem.salarie_id = "-1"; + currendRecordItem.from_service_id = "-1"; + currendRecordItem.to_service_id = "-1"; + currendRecordItem.from_qualification_id = "-1"; + currendRecordItem.to_qualification_id = "-1"; + break; + + case "DPR" : + + currendRecordItem.etablissement_inclus + currendRecordItem.etablissement_exclus + currendRecordItem.service_inclus + currendRecordItem.service_exclus + currendRecordItem.statut_inclus + currendRecordItem.statut_exclus + break; + case "POP" : + currendRecordItem.oid = "-1"; + currendRecordItem.nbref = 0; + currendRecordItem.code = ""; + currendRecordItem.texte = ""; + case "PER" : + currendRecordItem.oid = "-1"; + currendRecordItem.texte = ""; + currendRecordItem.priorite = "5000"; + currendRecordItem.population_id = "0"; + currendRecordItem.liste_finess = ""; + currendRecordItem.liste_etablissement = ""; + currendRecordItem.liste_service = ""; + currendRecordItem.liste_specialite = ""; + currendRecordItem.liste_section_analytique = ""; + currendRecordItem.liste_section_analytique_paie = ""; + currendRecordItem.liste_qualification = ""; + currendRecordItem.liste_grille = ""; + currendRecordItem.liste_code_emploi = ""; + currendRecordItem.liste_categorie_socio_professionnelle = ""; + currendRecordItem.liste_statut = ""; + case "EXC" : + currendRecordItem.oid = "-1"; + currendRecordItem.nbref = 0; + currendRecordItem.code = ""; + currendRecordItem.texte = ""; + currendRecordItem.texte_abrege = ""; + currendRecordItem.description = ""; + currendRecordItem.is_hide = "0"; + currendRecordItem.is_active = "1"; + currendRecordItem.is_cti = "0"; + currendRecordItem.gravite = "0"; + currendRecordItem.gravite_texte = ""; + currendRecordItem.complement = ""; + currendRecordItem.rule_oid1 = "0"; + currendRecordItem.sqlcmd_where1 = ""; + currendRecordItem.sqlcmd_justificatif1 = ""; + currendRecordItem.table1 = "0"; + currendRecordItem.last_execution_date1 = ""; + currendRecordItem.last_execution_ok1 = ""; + currendRecordItem.prestataire_id = "-1"; + currendRecordItem.prestataire_texte = "Tous"; + currendRecordItem.is_alert = "0"; + } + + showDetail(); + } + } + + public function getRecordExpert(event:ListEvent = null):void { + // Spécial Controles Expert + + if (tableCode == "EXC") { + /*if (event.columnIndex == 0) { + return; + }*/ + if (qimport) { + return; + } + } + if (recordUpdated == true) { + return; + } + if (EXC_list_GUI.selectedIndex < 0) { + return; + } + currendRecordItem = EXC_list_GUI.selectedItem as Object; + showDetail(); + } + + public function showDetail():void { + var i:Number; + var item:Object; + if (currendRecordItem == null) { + return; + } + + if (tableCode == "EXC"){ + fillFields(new Array("oid", "code", "texte", "texte_court", "texte_abrege", "description", + "rule_oid1", "sqlcmd_where1", "sqlcmd_justificatif1", + "is_hide", "is_cti", "is_active", "is_alert" + )); + setSelectedIndex(EXC_gravite_GUI, currendRecordItem.gravite.toString()); + setSelectedIndex(EXC_prestataire_GUI, currendRecordItem.prestataire_id.toString()); + setSelectedIndex(EXC_table1_GUI, currendRecordItem.table1.toString()); + EXC_is_alert_GUI.selected = currendRecordItem.is_alert.toString() == '1' ? true : false; + EXC_sqlcmd_where1_GUI.setStyle("backgroundColor", null); + EXC_sqlcmd_justificatif1_GUI.setStyle("backgroundColor", null); + + } else { + oid_GUI.text = currendRecordItem.oid.toString(); + nbref_GUI.text = currendRecordItem.nbref.toString(); + code_GUI.text = currendRecordItem.code.toString(); + texte_GUI.text = currendRecordItem.texte.toString(); + texte_court_GUI.text = currendRecordItem.texte_court.toString(); + valeur_GUI.text = currendRecordItem.valeur.toString(); + valeur_date_GUI.text = currendRecordItem.valeur_date.toString(); + code_original_GUI.text = currendRecordItem.code_original.toString(); + code_calcul_GUI.selectedIndex = currendRecordItem.code_calcul.toString(); + base_calcul_etp_GUI.text = currendRecordItem.base_calcul_etp.toString(); + code_ets_planning_GUI.text = currendRecordItem.code_ets_planning.toString(); + code_ent_planning_GUI.text = currendRecordItem.code_ent_planning.toString(); + unite_GUI.selectedIndex = currendRecordItem.unite.toString(); + coefficient_GUI.text = currendRecordItem.coefficient.toString(); + coefficient_base_GUI.text = currendRecordItem.coefficient_base.toString(); + coefficient_nombre_GUI.text = currendRecordItem.coefficient_nombre.toString(); + coefficient_txs_GUI.text = currendRecordItem.coefficient_txs.toString(); + coefficient_txp_GUI.text = currendRecordItem.coefficient_txp.toString(); + } + if (tableCode == "RUB") { + user_modified_GUI.selected = (currendRecordItem.user_modified.toString() == "M"); + p_cumul_GUI.selected = (currendRecordItem.p_cumul.toString() == "C"); + p_detail_GUI.selected = (currendRecordItem.p_detail.toString() == "D"); + proratiser_conversion_GUI.selected = (currendRecordItem.proratiser_conversion.toString() == "X"); + + p_nombre_GUI.selected = (currendRecordItem.p_nombre.toString() == "X"); + s_nombre_GUI.selectedIndex = currendRecordItem.s_nombre; + c_nombre_GUI.text = currendRecordItem.c_nombre; + p_base_GUI.selected = (currendRecordItem.p_base.toString() == "X"); + s_base_GUI.selectedIndex = currendRecordItem.s_base; + c_base_GUI.text = currendRecordItem.c_base; + p_heures_contrat_GUI.selected = (currendRecordItem.p_heures_contrat.toString() == "X"); + s_heures_contrat_GUI.selectedIndex = currendRecordItem.s_heures_contrat; + c_heures_contrat_GUI.text = currendRecordItem.c_heures_contrat; + p_heures_payees_GUI.selected = (currendRecordItem.p_heures_payees.toString() == "X"); + s_heures_payees_GUI.selectedIndex = currendRecordItem.s_heures_payees; + c_heures_payees_GUI.text = currendRecordItem.c_heures_payees; + p_heures_travaillees_GUI.selected = (currendRecordItem.p_heures_travaillees.toString() == "X"); + s_heures_travaillees_GUI.selectedIndex = currendRecordItem.s_heures_travaillees; + c_heures_travaillees_GUI.text = currendRecordItem.c_heures_travaillees; + p_masse_salariale_GUI.selected = (currendRecordItem.p_masse_salariale.toString() == "X"); + s_masse_salariale_GUI.selectedIndex = currendRecordItem.s_masse_salariale; + c_masse_salariale_GUI.text = currendRecordItem.c_masse_salariale; + p_brut_GUI.selected = (currendRecordItem.p_brut.toString() == "X"); + s_brut_GUI.selectedIndex = currendRecordItem.s_brut; + c_brut_GUI.text = currendRecordItem.c_brut; + p_avantage_nature_GUI.selected = (currendRecordItem.p_avantage_nature.toString() == "X"); + s_avantage_nature_GUI.selectedIndex = currendRecordItem.s_avantage_nature; + c_avantage_nature_GUI.text = currendRecordItem.c_avantage_nature; + p_frais_imposables_GUI.selected = (currendRecordItem.p_frais_imposables.toString() == "X"); + s_frais_imposables_GUI.selectedIndex = currendRecordItem.s_frais_imposables; + c_frais_imposables_GUI.text = currendRecordItem.c_frais_imposables; + p_cotisation_salarie_GUI.selected = (currendRecordItem.p_cotisation_salarie.toString() == "X"); + s_cotisation_salarie_GUI.selectedIndex = currendRecordItem.s_cotisation_salarie; + c_cotisation_salarie_GUI.text = currendRecordItem.c_cotisation_salarie; + p_cotisation_patronale_GUI.selected = (currendRecordItem.p_cotisation_patronale.toString() == "X"); + s_cotisation_patronale_GUI.selectedIndex = currendRecordItem.s_cotisation_patronale; + c_cotisation_patronale_GUI.text = currendRecordItem.c_cotisation_patronale; + p_od_net_salarie_GUI.selected = (currendRecordItem.p_od_net_salarie.toString() == "X"); + s_od_net_salarie_GUI.selectedIndex = currendRecordItem.s_od_net_salarie; + c_od_net_salarie_GUI.text = currendRecordItem.c_od_net_salarie; + p_od_net_patronale_GUI.selected = (currendRecordItem.p_od_net_patronale.toString() == "X"); + s_od_net_patronale_GUI.selectedIndex = currendRecordItem.s_od_net_patronale; + c_od_net_patronale_GUI.text = currendRecordItem.c_od_net_patronale; + p_net_imposable_GUI.selected = (currendRecordItem.p_net_imposable.toString() == "X"); + s_net_imposable_GUI.selectedIndex = currendRecordItem.s_net_imposable; + c_net_imposable_GUI.text = currendRecordItem.c_net_imposable; + p_net_a_payer_GUI.selected = (currendRecordItem.p_net_a_payer.toString() == "X"); + s_net_a_payer_GUI.selectedIndex = currendRecordItem.s_net_a_payer; + c_net_a_payer_GUI.text = currendRecordItem.c_net_a_payer; + } + + if (tableCode == "ETA") { + setComboSelectedIndex(ETA_finess_id_GUI, currendRecordItem.finess_id) + } + if (tableCode == "TRF") { + setComboSelectedIndex(TRF_date_debut_GUI, currendRecordItem.date_debut) + setComboSelectedIndex(TRF_date_fin_GUI, currendRecordItem.date_fin) + + setComboSelectedIndex(TRF_salarie_id_GUI, currendRecordItem.salarie_id) + setComboSelectedIndex(TRF_from_service_id_GUI, currendRecordItem.from_service_id) + setComboSelectedIndex(TRF_to_service_id_GUI, currendRecordItem.to_service_id) + setComboSelectedIndex(TRF_from_qualification_id_GUI, currendRecordItem.from_qualification_id) + setComboSelectedIndex(TRF_to_qualification_id_GUI, currendRecordItem.to_qualification_id) + } + + if (tableCode == "PSE") { + setComboSelectedIndex(PSE_service_id_GUI, currendRecordItem.service_id) + } + if (tableCode == "DIV") { + show_info_module_GUI.selected = (currendRecordItem.show_info_module.toString() == "1"); + } + if (tableCode == "PQU") { + setComboSelectedIndex(PQU_qualification_id_GUI, currendRecordItem.qualification_id) + } + + if (tableCode == "DPR") { + DPR_etablissement_inclus_GUI.text = currendRecordItem.etablissement_inclus; + DPR_etablissement_exclus_GUI.text = currendRecordItem.etablissement_exclus; + DPR_service_inclus_GUI.text = currendRecordItem.service_inclus; + DPR_service_exclus_GUI.text = currendRecordItem.service_exclus; + DPR_statut_inclus_GUI.text = currendRecordItem.statut_inclus; + DPR_statut_exclus_GUI.text = currendRecordItem.statut_exclus; + } + + if (tableCode == "POP") { + POP_oid_GUI.text = currendRecordItem.oid.toString(); + POP_nbref_GUI.text = currendRecordItem.nbref.toString(); + POP_code_GUI.text = currendRecordItem.code.toString(); + POP_texte_GUI.text = currendRecordItem.texte.toString(); + } + + if (tableCode == "PER") { + PER_oid_GUI.text = currendRecordItem.oid.toString(); + PER_code_GUI.text = currendRecordItem.code.toString(); + PER_texte_GUI.text = currendRecordItem.texte.toString(); + PER_priorite_GUI.text = currendRecordItem.priorite.toString(); + PER_RH_liste_service_GUI.text = currendRecordItem.liste_service.toString(); + PER_RH_liste_specialite_GUI.text = currendRecordItem.liste_specialite.toString(); + PER_RH_liste_section_analytique_GUI.text = currendRecordItem.liste_section_analytique.toString(); + PER_RH_liste_section_analytique_paie_GUI.text = currendRecordItem.liste_section_analytique_paie.toString(); + PER_RH_liste_qualification_GUI.text = currendRecordItem.liste_qualification.toString(); + PER_RH_liste_grille_GUI.text = currendRecordItem.liste_grille.toString(); + PER_RH_liste_code_emploi_GUI.text = currendRecordItem.liste_code_emploi.toString(); + PER_RH_liste_categorie_socio_professionnelle_GUI.text = currendRecordItem.liste_categorie_socio_professionnelle.toString(); + PER_RH_liste_statut_GUI.text = currendRecordItem.liste_statut.toString(); + PER_RH_liste_finess_GUI.text = currendRecordItem.liste_finess.toString(); + PER_RH_liste_etablissement_GUI.text = currendRecordItem.liste_etablissement.toString(); + PER_RH_Qliste_service_GUI.selected = PER_RH_liste_service_GUI.text != "" ? true : false; + PER_RH_Qliste_specialite_GUI.selected = PER_RH_liste_specialite_GUI.text != "" ? true : false; + PER_RH_Qliste_section_analytique_GUI.selected = PER_RH_liste_section_analytique_GUI.text != "" ? true : false; + PER_RH_Qliste_section_analytique_paie_GUI.selected = PER_RH_liste_section_analytique_paie_GUI.text != "" ? true : false; + PER_RH_Qliste_qualification_GUI.selected = PER_RH_liste_qualification_GUI.text != "" ? true : false; + PER_RH_Qliste_grille_GUI.selected = PER_RH_liste_grille_GUI.text != "" ? true : false; + PER_RH_Qliste_code_emploi_GUI.selected = PER_RH_liste_code_emploi_GUI.text != "" ? true : false; + PER_RH_Qliste_categorie_socio_professionnelle_GUI.selected = PER_RH_liste_categorie_socio_professionnelle_GUI.text != ""? true : false; + PER_RH_Qliste_statut_GUI.selected = PER_RH_liste_statut_GUI.text != ""? true : false; + PER_RH_Qliste_finess_GUI.selected = PER_RH_liste_finess_GUI.text != "" ? true : false; + PER_RH_Qliste_etablissement_GUI.selected = PER_RH_liste_etablissement_GUI.text != "" ? true : false; + setComboSelectedIndex(PER_population_id_GUI, currendRecordItem.population_id.toString()); + } + + recordUpdated = false; + if (tableCode == "POP") { + POP_detailBox_GUI.height = 500; + } else if (tableCode == "PER") { + PER_detailBox_GUI.height = 500; + } else if (tableCode == "EXC") { + EXC_detailBox_GUI.height = 500; + } else { + detailBox_GUI.height = 535; + } + } + + private function askCancel():void { + if (recordUpdated == false) { + hideRecord(); + return; + } + Alert.yesLabel = "OUI"; + Alert.noLabel = "NON"; + var alert:Alert = Alert.show("Les données ont été changées, désirez vous les annuler ?", title, 3, this, alertClickHandler, question_class); + + function alertClickHandler(event:CloseEvent):void { + if (event.detail==Alert.YES) { + hideRecord(); + } + } + } + + private function hideRecord():void { + if (tableCode == "POP") { + POP_detailBox_GUI.height = 0 + } else if (tableCode == "PER") { + PER_detailBox_GUI.height = 0 + } else if (tableCode == "EXC") { + EXC_detailBox_GUI.height = 0 + if (EXC_mode == 2) { + EXC_mode = 0; + } + } + else { + detailBox_GUI.height = 0 + } + + currendRecordItem = null; + recordUpdated = false; + } + + private function askDelete():void { + Alert.yesLabel = "OUI"; + Alert.noLabel = "NON"; + var alert:Alert = Alert.show("Désirez vous vraiment supprimer " + texte_GUI.text + " ?", title, 3, this, alertClickHandler, question_class); + + + function alertClickHandler(event:CloseEvent):void { + if (event.detail==Alert.YES) { + deleteRecord() + } + } + } + + public function deleteRecord():void { + updateRecord("delete"); + } + + private function askPurge():void { + + var alert:Alert; + + Alert.yesLabel = "OUI"; + Alert.noLabel = "NON"; + + if (currendRecordItem == null) { + Alert.show("Désirez vous vraiment supprimer l'historique de TOUS les contrôles experts ?", title, 3, this, alertClickHandler, question_class); + } + else { + Alert.show("Désirez vous vraiment supprimer l'historique de " + EXC_texte_GUI.text + " ?", title, 3, this, alertClickHandler, question_class); + } + function alertClickHandler(event:CloseEvent):void { + if (event.detail == Alert.YES) { + purgeHistory(); + } + } + } + + public function purgeHistory():void { + + updateRecord("purge_history"); + + } + + + public function copyRecord():void { + updateRecord("copy"); + } + + public function saveRecord():void { + updateRecord("save"); + } + + public function updateRecord(action:String):void { + var urlVariables:URLVariables = new URLVariables() + urlVariables.tableName = tableName; + urlVariables.action = action; + urlVariables.softCode = softCode; + var recordNode:XML = new XML(); + recordNode.@oid = oid_GUI.text; + recordNode.@code = code_GUI.text; + recordNode.@texte = texte_GUI.text; + recordNode.@texte_court = texte_court_GUI.text; + recordNode.@valeur = valeur_GUI.text; + recordNode.@valeur_date = valeur_date_GUI.text; + recordNode.@show_info_module = (show_info_module_GUI.selected ? "1" : "0"); + recordNode.@code_original = code_original_GUI.text; + recordNode.@code_calcul = code_calcul_GUI.selectedIndex; + recordNode.@base_calcul_etp = base_calcul_etp_GUI.text; + recordNode.@code_ets_planning = code_ets_planning_GUI.text; + recordNode.@code_ent_planning = code_ent_planning_GUI.text; + recordNode.@unite = unite_GUI.selectedIndex; + recordNode.@coefficient = coefficient_GUI.text; + recordNode.@coefficient_base = coefficient_base_GUI.text; + recordNode.@coefficient_nombre = coefficient_nombre_GUI.text; + recordNode.@coefficient_txs = coefficient_txs_GUI.text; + recordNode.@coefficient_txp = coefficient_txp_GUI.text; + + recordNode.@user_modified = (user_modified_GUI.selected ? "M" : ""); + recordNode.@p_cumul = (p_cumul_GUI.selected ? "C" : ""); + recordNode.@p_detail = (p_detail_GUI.selected ? "D" : ""); + recordNode.@proratiser_conversion = (proratiser_conversion_GUI.selected ? "X" : ""); + + recordNode.@p_nombre = (p_nombre_GUI.selected ? "X" : ""); + recordNode.@s_nombre = s_nombre_GUI.selectedIndex; + recordNode.@c_nombre = c_nombre_GUI.text; + recordNode.@p_base = (p_base_GUI.selected ? "X" : ""); + recordNode.@s_base = s_base_GUI.selectedIndex; + recordNode.@c_base = c_base_GUI.text; + recordNode.@p_heures_contrat = (p_heures_contrat_GUI.selected ? "X" : ""); + recordNode.@s_heures_contrat = s_heures_contrat_GUI.selectedIndex; + recordNode.@c_heures_contrat = c_heures_contrat_GUI.text; + recordNode.@p_heures_payees = (p_heures_payees_GUI.selected ? "X" : ""); + recordNode.@s_heures_payees = s_heures_payees_GUI.selectedIndex; + recordNode.@c_heures_payees = c_heures_payees_GUI.text; + recordNode.@p_heures_travaillees = (p_heures_travaillees_GUI.selected ? "X" : ""); + recordNode.@s_heures_travaillees = s_heures_travaillees_GUI.selectedIndex; + recordNode.@c_heures_travaillees = c_heures_travaillees_GUI.text; + recordNode.@p_masse_salariale = (p_masse_salariale_GUI.selected ? "X" : ""); + recordNode.@s_masse_salariale = s_masse_salariale_GUI.selectedIndex; + recordNode.@c_masse_salariale = c_masse_salariale_GUI.text; + recordNode.@p_brut = (p_brut_GUI.selected ? "X" : ""); + recordNode.@s_brut = s_brut_GUI.selectedIndex; + recordNode.@c_brut = c_brut_GUI.text; + recordNode.@p_avantage_nature = (p_avantage_nature_GUI.selected ? "X" : ""); + recordNode.@s_avantage_nature = s_avantage_nature_GUI.selectedIndex; + recordNode.@c_avantage_nature = c_avantage_nature_GUI.text; + recordNode.@p_frais_imposables = (p_frais_imposables_GUI.selected ? "X" : ""); + recordNode.@s_frais_imposables = s_frais_imposables_GUI.selectedIndex; + recordNode.@c_frais_imposables = c_frais_imposables_GUI.text; + recordNode.@p_cotisation_salarie = (p_cotisation_salarie_GUI.selected ? "X" : ""); + recordNode.@s_cotisation_salarie = s_cotisation_salarie_GUI.selectedIndex; + recordNode.@c_cotisation_salarie = c_cotisation_salarie_GUI.text; + recordNode.@p_cotisation_patronale = (p_cotisation_patronale_GUI.selected ? "X" : ""); + recordNode.@s_cotisation_patronale = s_cotisation_patronale_GUI.selectedIndex; + recordNode.@c_cotisation_patronale = c_cotisation_patronale_GUI.text; + recordNode.@p_od_net_salarie = (p_od_net_salarie_GUI.selected ? "X" : ""); + recordNode.@s_od_net_salarie = s_od_net_salarie_GUI.selectedIndex; + recordNode.@c_od_net_salarie = c_od_net_salarie_GUI.text; + recordNode.@p_od_net_patronale = (p_od_net_patronale_GUI.selected ? "X" : ""); + recordNode.@s_od_net_patronale = s_od_net_patronale_GUI.selectedIndex; + recordNode.@c_od_net_patronale = c_od_net_patronale_GUI.text; + recordNode.@p_net_imposable = (p_net_imposable_GUI.selected ? "X" : ""); + recordNode.@s_net_imposable = s_net_imposable_GUI.selectedIndex; + recordNode.@c_net_imposable = c_net_imposable_GUI.text; + recordNode.@p_net_a_payer = (p_net_a_payer_GUI.selected ? "X" : ""); + recordNode.@s_net_a_payer = s_net_a_payer_GUI.selectedIndex; + recordNode.@c_net_a_payer = c_net_a_payer_GUI.text; + + if (tableCode == "ETA") { + recordNode.@finess_id = ETA_finess_id_GUI.selectedItem.@oid + } + if (tableCode == "TRF") { + recordNode.@date_debut = TRF_date_debut_GUI.selectedItem.@oid + recordNode.@date_fin = TRF_date_fin_GUI.selectedItem.@oid + recordNode.@salarie_id = TRF_salarie_id_GUI.selectedItem.@oid + recordNode.@from_service_id = TRF_from_service_id_GUI.selectedItem.@oid + recordNode.@to_service_id = TRF_to_service_id_GUI.selectedItem.@oid + recordNode.@from_qualification_id = TRF_from_qualification_id_GUI.selectedItem.@oid + recordNode.@to_qualification_id = TRF_to_qualification_id_GUI.selectedItem.@oid + } + if (tableCode == "PSE") { + recordNode.@service_id = PSE_service_id_GUI.selectedItem.@oid + } + if (tableCode == "PQU") { + recordNode.@qualification_id = PQU_qualification_id_GUI.selectedItem.@oid + } + + if (tableCode == "DPR") { + recordNode.@etablissement_inclus = DPR_etablissement_inclus_GUI.text + recordNode.@etablissement_exclus = DPR_etablissement_exclus_GUI.text + recordNode.@service_inclus = DPR_service_inclus_GUI.text + recordNode.@service_exclus = DPR_service_exclus_GUI.text + recordNode.@statut_inclus = DPR_statut_inclus_GUI.text + recordNode.@statut_exclus = DPR_statut_exclus_GUI.text + } + + if (tableCode == "POP") { + recordNode.@oid = POP_oid_GUI.text + recordNode.@code = POP_code_GUI.text + recordNode.@texte = POP_texte_GUI.text + } + + if (tableCode == "PER") { + recordNode.@oid = PER_oid_GUI.text + recordNode.@code = PER_code_GUI.text + recordNode.@texte = PER_texte_GUI.text + recordNode.@priorite = PER_priorite_GUI.text + recordNode.@liste_service = PER_RH_liste_service_GUI.text + recordNode.@liste_specialite = PER_RH_liste_specialite_GUI.text + recordNode.@liste_section_analytique = PER_RH_liste_section_analytique_GUI.text + recordNode.@liste_section_analytique_paie = PER_RH_liste_section_analytique_paie_GUI.text + recordNode.@liste_qualification = PER_RH_liste_qualification_GUI.text + recordNode.@liste_grille = PER_RH_liste_grille_GUI.text + recordNode.@liste_code_emploi = PER_RH_liste_code_emploi_GUI.text + recordNode.@liste_categorie_socio_professionnelle = PER_RH_liste_categorie_socio_professionnelle_GUI.text + recordNode.@liste_statut = PER_RH_liste_statut_GUI.text + recordNode.@liste_finess = PER_RH_liste_finess_GUI.text + recordNode.@liste_etablissement = PER_RH_liste_etablissement_GUI.text + recordNode.@population_id = PER_population_id_GUI.selectedItem.@oid; + } + + if (tableCode == "EXC") { + // Controles normaux + if (EXC_mode == 0) { + recordNode.@mode = EXC_mode; + recordNode = readFields(new Array( + "oid", "code", "texte", "texte_court", "texte_abrege", "description", + "rule_oid1", "sqlcmd_where1", "sqlcmd_justificatif1", + "prestataire", + "gravite", "table1", + "is_active","is_alert", "is_hide", "is_cti" + ), recordNode); + } + // Paramètres généraux + if (EXC_mode == 2) { + recordNode.@mode = EXC_mode; + recordNode.@EXPERT_ACTIVE = EXC_EXPERT_ACTIVE_GUI.selected == true ? "1" : "0"; + recordNode.@EXPERT_DATE_DEBUT = EXC_EXPERT_DATE_DEBUT_GUI.text; + EXC_mode = 0; + } + } + + urlVariables.recordNode = recordNode.toXMLString(); + CTI_Utilitaires.startRequestHTTP("modules/rh/php/httpService_tablesManager_setData.php",urlVariables,exec,true,this.parentApplication) + function exec(resultatService:XML):void { + getData(); + if (tableCode == "POP") { + POP_detailBox_GUI.height = 0 + } else if (tableCode == "PER") { + PER_detailBox_GUI.height = 0 + } else if (tableCode == "EXC") { + EXC_detailBox_GUI.height = 0 + } else { + detailBox_GUI.height = 0 + } + currendRecordItem = null; + recordUpdated = false; + } + + + } + + public function print():void { + var printReport:CTI_Print = new CTI_Print(); + if (printReport.start("RH_TablesManager", titlePrint) == false) { + return; + } + printReport.addAdvancedDataGrid(list_GUI) + printReport.print(); + } + + public function exportExcel():void { + var xml:XML = new XML(); + var ongletNode:XML; + var similiTabNode:XML; + var selectionsNode:XML; + var datagridNode:XML; + var columnNode:XML; + var dataNode:XML; + var rowNode:XML; + xml.@viewName = this.viewName; + xml.@title = this.title; + selectionsNode = new XML(); + selectionsNode.displayText = ""; + if (refSearch_GUI.selected == true) { + selectionsNode.@displayText = selectionsNode.displayText + "Uniquement les codes référencés. "; + } + if (textSearch_GUI.text != "") { + selectionsNode.@displayText = selectionsNode.displayText + "(Filtre : " + textSearch_GUI.text + ") "; + } + xml.appendChild(selectionsNode); + ongletNode = new XML(); + ongletNode.@excelLabel = tableCode; + xml.appendChild(ongletNode); + similiTabNode = new XML(); + similiTabNode.@excelLabel = "Liste"; + ongletNode.appendChild(similiTabNode); + datagridNode = new XML(); + datagridNode.@total = "false"; + ongletNode.appendChild(datagridNode); + for each (var column:AdvancedDataGridColumn in list_GUI.columns) { + columnNode = new XML(); + columnNode.@dataField = column.dataField; + columnNode.@headerText = column.headerText; + columnNode.@type = "Char"; + columnNode.@textAlign = column.getStyle("textAlign"); + datagridNode.appendChild(columnNode); + } + dataNode = new XML(); + similiTabNode.appendChild(dataNode); + for each (var itemNode:Object in list_collection) { + if (itemNode.oid != "-1") { + rowNode = new XML() + var c:int = 0; + for each (column in list_GUI.columns) { + c++; + rowNode.@["c" + c.toString()] = itemNode[column.dataField] + } + dataNode.appendChild(rowNode); + } + } + CTI_ExcelUtilitaires.exportExcel(xml); + } + + public function exportPDF():void { + var xml:XML = new XML(); + var ongletNode:XML; + var selectionsNode:XML; + var datagridNode:XML; + var columnNode:XML; + var dataNode:XML; + var rowNode:XML; + xml.@viewName = this.viewName; + xml.@title = this.title; + selectionsNode = new XML(); + selectionsNode.displayText = ""; + if (refSearch_GUI.selected == true) { + selectionsNode.displayText = selectionsNode.displayText + "Uniquement les codes référencés. "; + } + if (textSearch_GUI.text != "") { + selectionsNode.displayText = selectionsNode.displayText + "(Filtre : " + textSearch_GUI.text + ") "; + } + xml.appendChild(selectionsNode); + ongletNode = new XML(); + ongletNode.@excelLabel = tableCode; + xml.appendChild(ongletNode); + datagridNode = new XML(); + datagridNode.@total = "false"; + ongletNode.appendChild(datagridNode); + for each (var column:AdvancedDataGridColumn in list_GUI.columns) { + columnNode = new XML(); + columnNode.@dataField = column.dataField; + columnNode.@headerText = column.headerText; + columnNode.@type = "Char"; + columnNode.@textAlign = column.getStyle("textAlign"); + datagridNode.appendChild(columnNode); + } + dataNode = new XML(); + ongletNode.appendChild(dataNode); + for each (var itemNode:Object in list_collection) { + if (itemNode.oid != "-1") { + rowNode = new XML() + var c:int = 0; + for each (column in list_GUI.columns) { + c++; + rowNode.@["c" + c.toString()] = itemNode[column.dataField] + } + dataNode.appendChild(rowNode); + } + } + CTI_PDFUtilitaires.exportPDF(xml); + xml = null; + } + + public function copyRefSettings():void { + + var urlVariables:URLVariables = new URLVariables(); + urlVariables.tableName = tableName; + urlVariables.oids = ""; + for each (var item:Object in ref_list_collection) { + if (item.selected == "1") { + if (urlVariables.oids != "") { + urlVariables.oids = urlVariables.oids + ", "; + } + urlVariables.oids = urlVariables.oids + item.oid; + } + } + + if (urlVariables.oids == "") { + CTI_Utilitaires.alert_error("Import de données", "Vous devez d'abord choisir les données à récupérer"); + return; + } + + CTI_Utilitaires.startRequestHTTP("modules/rh/php/httpService_RH_tableManager_copyRef.php", urlVariables, exec, true, this.parentApplication); + + function exec(resultatService:XML):void { + + getData(); + + detailBox_GUI.visible = false; + detailBox_GUI.includeInLayout = false; + currendRecordItem = null; + toggleUpdate(false); + } + } + + + + + + + private function setComboSelectedIndex(cb:Object, str:String):void { + for (var idx:int = 0; idx < cb.dataProvider.length; idx++){ + if (cb.dataProvider.getItemAt(idx).@oid == str){ + cb.selectedIndex = idx; + } + } + } + + private function setSelectedIndex(cb:Object, str:String, field:String='data'):void { + for (var idx:int = 0, len:int = cb.dataProvider.length; idx < len; idx++) { + if (cb.dataProvider.getItemAt(idx)[field] == str) { + cb.selectedIndex = idx; + } + } + } + + private function fillFields(fields:Array):void { + var dobj:DisplayObject; + var field:String; + for each (field in fields) { + dobj = findChild(EXC_detailBox_GUI, tableCode + "_" + field + "_GUI"); + if (dobj is RichTextEditor) { + if (currendRecordItem[field].toString() != "") { + (dobj as RichTextEditor).htmlText = CTI_Utilitaires.uncompress64(currendRecordItem[field].toString()); + } + else { + (dobj as RichTextEditor).htmlText = ""; + } + } + else if (dobj is TextArea) { + (dobj as TextArea).text = currendRecordItem[field].toString(); + } + else if (dobj is DateField) { + (dobj as DateField).selectedDate = DateField.stringToDate(currendRecordItem[field].toString(), 'DD/MM/YYYY'); + } + else if (dobj is CheckBox) { + (dobj as CheckBox).selected = currendRecordItem[field].toString() == "1" ? true : false; + } + } + dobj = null; + } + + private function readFields(fields:Array, recordNode:XML):XML { + + var dobj:DisplayObject; + var field:String; + for each (field in fields) { + + dobj = findChild(EXC_detailBox_GUI, tableCode + "_" + field + "_GUI"); + if (dobj is RichTextEditor) { + if ((dobj as RichTextEditor).text != "") { + recordNode.@[field] = CTI_Utilitaires.compress64((dobj as RichTextEditor).htmlText); + } + else { + recordNode.@[field] = ""; + } + } + else if (dobj is TextArea) { + recordNode.@[field] = (dobj as TextArea).text; + } + else if (dobj is DateField) { + recordNode.@[field] = DateField.dateToString((dobj as DateField).selectedDate, 'DD/MM/YYYY'); + } + else if (dobj is ComboBox) { + recordNode.@[field] = (dobj as ComboBox).selectedItem.data; + } + else if (dobj is CheckBox) { + recordNode.@[field] = (dobj as CheckBox).selected ? "1" : "0"; + } + + } + dobj = null; + return recordNode; + } + + private function EXC_show_generalSettings():void { + + EXC_mode = 2; + detailBox_GUI.visible = true; + detailBox_GUI.includeInLayout = true; + } + + public function EXC_execute_rules(controle_id:String=null):void { + + var urlVariables:URLVariables = new URLVariables() + urlVariables.tableName = tableName; + urlVariables.action = 'execute_rules'; + + if (controle_id != null) { + urlVariables.oids = controle_id + } + else { + urlVariables.oids = ""; + // for each (var item:Object in list_collection) { + // if (item.selected == "1") { + // if (urlVariables.oids != "") { + // urlVariables.oids = urlVariables.oids + ", " + // } + // urlVariables.oids = urlVariables.oids + item.oid + // } + // } + } + + CTI_Utilitaires.startRequestHTTP("modules/rh/php/RH_setTableRecord.php", urlVariables, exec, true, this.parentApplication); + + function exec(resultatService:XML):void { + + if (resultatService.RETURN.@code.toString() != "KO") { + CTI_Utilitaires.alert_info("Exécution règles Expert", "Exécution terminée : " + resultatService.RETURN.@message.toString()); + } + else { + CTI_Utilitaires.alert_error("Exécution règles Expert", "Exécution terminée avec ERREURS : " + resultatService.RETURN.@message.toString()); + } + + getData(); + + detailBox_GUI.visible = false + detailBox_GUI.includeInLayout = false + currendRecordItem = null; + recordUpdated = false; + } + } + + public function EXC_getSQL(controle_id:String=null):void { + + var urlVariables:URLVariables = new URLVariables(); + urlVariables.tableName = tableName; + if (controle_id != null) { + urlVariables.oids = controle_id; + } + else { + urlVariables.oids = ""; + for each (var item:Object in list_collection) { + if (item.selected == "1") { + if (urlVariables.oids != "") { + urlVariables.oids = urlVariables.oids + ", "; + } + urlVariables.oids = urlVariables.oids + item.oid; + } + } + } + + if (urlVariables.oids == "") { + CTI_Utilitaires.alert_error("Export SQL", "Vous devez d'abord choisir les contrôles à exporter"); + return; + } + + // @todo + CTI_Utilitaires.openURL("modules/rh/php/httpService_RH_tableManager_getSqlScript.php", urlVariables, "iCTI_expert_controle.SQL"); + } + + /** + * Fonction qui cherche un displayObject par son nom dans toute l'arboresence d'un + * container. Cette fonction supplante la fonction getChildByName dans le sens où elle + * ne se cantonne pas au premier niveau de l'arboresence mais inspecte tous les niveaux + * + * @param container Container dans lequel chercher l'enfant + * @param childname Nom de l'enfant à chercher + * @return L'élement trouvé dans l'arborescence + */ + private function findChild(container:DisplayObjectContainer, childname:String ):DisplayObject { + + if (container == null) { + container = this; + } + + for (var j:int = 0; j < container.numChildren; ++j) { + + var obj:DisplayObject = container.getChildAt(j) as DisplayObject; + if (obj.name == childname) { + return obj; + } + if (obj is DisplayObjectContainer) { + var doc:DisplayObjectContainer = obj as DisplayObjectContainer; + if (doc.numChildren > 0) { + var ret:DisplayObject = findChild( doc, childname ); + if (ret != null) { + return ret; + } + } + } + } + return null; + } + + public function toggleUpdate(value:Boolean):void { + recordUpdated = value; + } + + public function PER_execute_regles():void { + var urlVariables:URLVariables = new URLVariables() + urlVariables.tableName = tableName; + urlVariables.softCode = softCode + urlVariables.action = 'PER_execute_regles'; + CTI_Utilitaires.startRequestHTTP("modules/rh/php/httpService_tablesManager_setData.php", urlVariables, exec, true, this.parentApplication); + function exec(resultatService:XML):void { + getData(); + } + } + + public function getRefSettings():void { + detailBox_GUI.visible = false; + detailBox_GUI.includeInLayout = false; + qimport = true; + } + + public function hideRefSettings():void { + detailBox_GUI.visible = true; + detailBox_GUI.includeInLayout = true; + qimport = false; + } + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/swf/CtiRhBilanSocial.bat b/swf/CtiRhBilanSocial.bat new file mode 100644 index 0000000..6c5bafa --- /dev/null +++ b/swf/CtiRhBilanSocial.bat @@ -0,0 +1,9 @@ +@echo off +SET ori_path=%cd% +CD ..\..\base\swf +SET sources_path=%cd% +CD %ori_path% +:: sources_path permet d'inclure le répertoire CTI qui contient les composants maison +SET OPTS=-use-network=false -optimize=true -debug=true -source-path="%sources_path%" +C:\flex_sdk_350\bin\mxmlc.exe %OPTS% .\CtiRhBilanSocial.mxml -output ..\..\..\CtiRhBilanSocial.swf +PAUSE \ No newline at end of file diff --git a/swf/CtiRhBilanSocial.mxml b/swf/CtiRhBilanSocial.mxml new file mode 100644 index 0000000..68364c5 --- /dev/null +++ b/swf/CtiRhBilanSocial.mxml @@ -0,0 +1,345 @@ + + + + Bilan Social"; + + [Bindable] + public var bsSubLabel:String = "Défini par l'article R. 2323-17 du code du travail."; + + [Bindable] + public var hasHelp:Boolean = false; + + [Bindable] + public var imports_list:ArrayCollection = new ArrayCollection(); + + [Bindable] + public var annees:Array = new Array(2015, 2014, 2013, 2012, 2011); + + [Bindable] + public var entites:Array = new Array(); + + [Bindable] + public var diagnoseList:Array = new Array(); + + public var entitiesAll:Array = new Array(); + + public var _enabled:Boolean = true; + + private var downloadURL:URLRequest; + private var fileRef:FileReference; + + private var filename:String; + + public var _disabledMessage:String = "Le bilan social nécessite une visite de validation de CTI Santé pour démarrer cette fonctionnalité."; + + public function showEventHandle():void { + if (!this._enabled) { + Alert.show(this._disabledMessage, "Message de CTI Santé", Alert.OK, this, null, info_icon_class); + application.closeCurrentWindow(); + } + } + + public function onCreationComplete():void { + var _secureAMF:Boolean = this.url.indexOf('https') >= 0 ? true : false; + _ro = application.ctiRemoteObjectProvider.getRemoteObject("rh", "CtiRhBilanSocialService", _secureAMF); + + isBsEnabled(); + } + + private function isBsEnabled():void { + _ro.addEventListener(ResultEvent.RESULT, handleBsEnabledResult); + _ro.addEventListener(FaultEvent.FAULT, handleBsEnabledFault); + _ro.isBsEnabled(); + } + + private function handleBsEnabledResult(event:ResultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleBsEnabledResult); + _ro.removeEventListener(FaultEvent.FAULT, handleBsEnabledFault); + _enabled = event.result as Boolean; + + if (_enabled) { + getEntities(); + } else { + Alert.show(this._disabledMessage, "Message de CTI Santé", Alert.OK, this, null, info_icon_class); + application.closeCurrentWindow(); + } + } + + private function handleBsEnabledFault(event:FaultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleBsEnabledResult); + _ro.removeEventListener(FaultEvent.FAULT, handleBsEnabledFault); + _ro.disconnect(); + Alert.show(this._disabledMessage, "Message de CTI Santé", Alert.OK, this, null, info_icon_class); + application.closeCurrentWindow(); + } + + private function getEntities():void { + _ro.addEventListener(ResultEvent.RESULT, handleEntitiesResult); + _ro.addEventListener(FaultEvent.FAULT, handleEntitiesFault); + _ro.getEntities(); + } + + private function handleEntitiesResult(event:ResultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleEntitiesResult); + _ro.removeEventListener(FaultEvent.FAULT, handleEntitiesFault); + entitiesAll = event.result as Array; + for each(var o:Object in entitiesAll) { + entites.push(o.texte); + } + if (entitiesAll.length > 0) { + cbEntity.selectedIndex = 0; + diagnose(); + } else { + Alert.show("Impossible de lister les entreprises/établissements.", "Bilan Social."); + } + } + + private function handleEntitiesFault(event:FaultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleEntitiesResult); + _ro.removeEventListener(FaultEvent.FAULT, handleEntitiesFault); + _ro.disconnect(); + Alert.show("Impossible de lister les entreprises/établissements.", "Bilan Social."); + } + + private function generer():void { + btnTelecharger.enabled = false; + + btnGenerer.label = "Génération en cours..."; + btnGenerer.enabled = false; + cbYear.enabled = false; + cbEntity.enabled = false; + + filename = "BilanSocial_"+cbYear.selectedItem+"_"+entitiesAll[cbEntity.selectedIndex].code+".xlsx"; + + _ro.addEventListener(ResultEvent.RESULT, handleDataListResult); + _ro.addEventListener(FaultEvent.FAULT, handleDataListFault); + _ro.generateExcel(cbYear.selectedItem, filename, entitiesAll[cbEntity.selectedIndex].ent_id, entitiesAll[cbEntity.selectedIndex].ets_id); + } + + private function handleDataListResult(event:ResultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleDataListResult); + _ro.removeEventListener(FaultEvent.FAULT, handleDataListFault); + var res:String = event.result as String; + + if (res == "diagnose") { + diagnose(); + } else { + checkIfRealError(); + } + } + + private function handleDataListFault(event:FaultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleDataListResult); + _ro.removeEventListener(FaultEvent.FAULT, handleDataListFault); + _ro.disconnect(); + + /* + Etant donné que PHP 5.2.5 fait planter Apache mais que malgré tout le fichier est bien + généré, on considère qu'on a une chance de le récupérer si amfPHP est en erreur. + */ + checkIfRealError(); + } + + private function checkIfRealError():void { + _ro.addEventListener(ResultEvent.RESULT, handleFgResult); + _ro.addEventListener(FaultEvent.FAULT, handleFgFault); + _ro.fileGenerated(filename); + } + + private function handleFgResult(event:ResultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleFgResult); + _ro.removeEventListener(FaultEvent.FAULT, handleFgFault); + var res:Boolean = event.result as Boolean; + + btnGenerer.label = "Générer"; + btnGenerer.enabled = true; + cbYear.enabled = true; + cbEntity.enabled = true; + + if(res) { + btnTelecharger.enabled = true; + } else { + Alert.show("Impossible de générer le Bilan Social. Fichier non généré.", "Bilan Social."); + } + } + + private function handleFgFault(event:FaultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleFgResult); + _ro.removeEventListener(FaultEvent.FAULT, handleFgFault); + _ro.disconnect(); + + btnGenerer.label = "Générer"; + btnGenerer.enabled = true; + cbYear.enabled = true; + cbEntity.enabled = true; + + Alert.show("Impossible de générer le Bilan Social.", "Bilan Social."); + } + + private function telecharger():void { + var appUrl:String = Application.application.url.replace("CTI.swf", "temp/"); + downloadURL = new URLRequest(); + downloadURL.url = appUrl + filename; + fileRef = new FileReference(); + configureListeners(fileRef); + fileRef.download(downloadURL, filename); + } + + private function configureListeners(dispatcher:IEventDispatcher):void { + dispatcher.addEventListener(Event.CANCEL, cancelHandler); + dispatcher.addEventListener(Event.COMPLETE, completeHandler); + dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + dispatcher.addEventListener(Event.OPEN, openHandler); + dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler); + dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); + dispatcher.addEventListener(Event.SELECT, selectHandler); + } + + private function cancelHandler(event:Event):void { + trace("cancelHandler: " + event); + } + + private function completeHandler(event:Event):void { + trace("completeHandler: " + event); + Alert.show(filename + " téléchargé.", "Bilan Social."); + } + + private function ioErrorHandler(event:IOErrorEvent):void { + trace("ioErrorHandler: " + event); + Alert.show("Impossible de télécharger le Bilan Social.\nVous n'êtes peut-être pas connecté au réseau ou vous essayer d'écraser un fichier actuellement ouvert sur votre ordinateur.", "Bilan Social."); + } + + private function openHandler(event:Event):void { + trace("openHandler: " + event); + } + + private function progressHandler(event:ProgressEvent):void { + var file:FileReference = FileReference(event.target); + trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal); + } + + private function securityErrorHandler(event:SecurityErrorEvent):void { + trace("securityErrorHandler: " + event); + Alert.show("Impossible de télécharger le Bilan Social. Mettez à jour votre plugin Flash Player du navigateur.", "Bilan Social."); + } + + private function selectHandler(event:Event):void { + var file:FileReference = FileReference(event.target); + trace("selectHandler: name=" + file.name + " URL=" + downloadURL.url); + } + + private function diagnose():void { + btnVerifier.label = "Vérification en cours..."; + btnVerifier.enabled = false; + + _ro.addEventListener(ResultEvent.RESULT, handleDiagnoseResult); + _ro.addEventListener(FaultEvent.FAULT, handleDiagnoseFault); + _ro.diagnose(); + } + + private function handleDiagnoseResult(event:ResultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleDiagnoseResult); + _ro.removeEventListener(FaultEvent.FAULT, handleDiagnoseFault); + var res:Array = event.result as Array; + + diagnoseList = res; + + if (diagnoseList.length > 0){ + excelVBox.visible = false; + excelVBox.includeInLayout = false; + } else { + excelVBox.visible = true; + excelVBox.includeInLayout = true; + } + + btnVerifier.label = "Relancer la vérification"; + btnVerifier.enabled = true; + + btnGenerer.label = "Générer"; + btnGenerer.enabled = true; + } + + private function handleDiagnoseFault(event:FaultEvent):void { + _ro.removeEventListener(ResultEvent.RESULT, handleDiagnoseResult); + _ro.removeEventListener(FaultEvent.FAULT, handleDiagnoseFault); + _ro.disconnect(); + + Alert.show("Impossible de vérifier les pré-requis pour la génération du Bilan Social.", "Bilan Social."); + + btnVerifier.label = "Relancer la vérification"; + btnVerifier.enabled = true; + } + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swf/buildCTI_RH_Synchronize.bat b/swf/buildCTI_RH_Synchronize.bat new file mode 100644 index 0000000..1f6f22e --- /dev/null +++ b/swf/buildCTI_RH_Synchronize.bat @@ -0,0 +1,9 @@ +@echo off +SET ori_path=%cd% +CD ..\..\base\swf +SET sources_path=%cd% +CD %ori_path% +:: sources_path permet d'inclure le répertoire CTI qui contient les composants maison +SET OPTS=-use-network=false -optimize=true -debug=true -source-path="%sources_path%" +C:\flex_sdk_350\bin\mxmlc.exe %OPTS% .\CTI_RH_Synchronize.mxml -output ..\..\..\CTI_RH_Synchronize.swf +PAUSE \ No newline at end of file diff --git a/swf/buildCTI_RH_TablesManager.bat b/swf/buildCTI_RH_TablesManager.bat new file mode 100644 index 0000000..55f6526 --- /dev/null +++ b/swf/buildCTI_RH_TablesManager.bat @@ -0,0 +1,9 @@ +@echo off +SET ori_path=%cd% +CD ..\..\base\swf +SET sources_path=%cd% +CD %ori_path% +:: sources_path permet d'inclure le répertoire CTI qui contient les composants maison +SET OPTS=-use-network=false -optimize=true -debug=true -source-path="%sources_path%" +C:\flex_sdk_350\bin\mxmlc.exe %OPTS% .\CTI_RH_TablesManager.mxml -output ..\..\..\CTI_RH_TablesManager.swf +PAUSE \ No newline at end of file diff --git a/swf/build_rh.bat b/swf/build_rh.bat new file mode 100644 index 0000000..9a6e3b9 --- /dev/null +++ b/swf/build_rh.bat @@ -0,0 +1,5 @@ +@echo off + +CALL build_rh_silently.bat + +PAUSE \ No newline at end of file diff --git a/swf/build_rh_silently.bat b/swf/build_rh_silently.bat new file mode 100644 index 0000000..0227765 --- /dev/null +++ b/swf/build_rh_silently.bat @@ -0,0 +1,12 @@ +@echo off +SET ori_path=%cd% +CD ..\..\base\swf +SET sources_path=%cd% +CD %ori_path% +:: sources_path permet d'inclure le répertoire CTI qui contient les composants maison +SET OPTS=-use-network=false -optimize=true -debug=false -source-path="%sources_path%" + +FOR /r . %%F IN (*.mxml) DO ( + IF EXIST "%%~nF.mxml" echo %%~nF.mxml + IF EXIST "%%~nF.mxml" C:\flex_sdk_350\bin\mxmlc.exe %OPTS% .\%%~nF.mxml -output ..\..\..\%%~nF.swf +)