
=============================================================================
== MARIUSM_AUTO DDL EXPORT — start
== Data rulare: 4/11/2026
=============================================================================


-- ============================================================
-- === SECTION: TABLES ===
-- ============================================================
-- Gasite: 29 obiecte

-- --- TABLE: ACT ---

  CREATE TABLE "MARIUSM_AUTO"."ACT" 
   (	"ID_ACT" NUMBER(20,0) NOT NULL ENABLE, 
	"LUNA" NUMBER(2,0) DEFAULT 0 NOT NULL ENABLE, 
	"AN" NUMBER(4,0) DEFAULT 0 NOT NULL ENABLE, 
	"COD" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATAIREG" DATE, 
	"NRACT" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATAACT" DATE, 
	"EXPLICATIA" VARCHAR2(100), 
	"SCD" VARCHAR2(4), 
	"ASCD" VARCHAR2(4), 
	"SCC" VARCHAR2(4), 
	"ASCC" VARCHAR2(4), 
	"SUMA" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE, 
	"ID_FACTD" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_FACTC" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"PERECHED" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"PERECHEC" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"SUMA_VAL" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE, 
	"CURS" NUMBER(12,6) DEFAULT 0 NOT NULL ENABLE, 
	"DATASCAD" DATE, 
	"NEIMPOZAB" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE, 
	"NNIR" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTIL" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATAORA" DATE, 
	"ID_UTILS" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATAORAS" DATE, 
	"ID_RESPONSABIL" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_VENCHELT" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_SECTIE" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_SET" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_FACT" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_PARTD" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_PARTC" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_SUCURSALA" NUMBER(5,0) DEFAULT null, 
	"ID_FDOC" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"EXPLICATIA4" VARCHAR2(100), 
	"EXPLICATIA5" VARCHAR2(100), 
	"ID_LUCRARE" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_GESTIN" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_GESTOUT" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_VALUTA" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"PROC_TVA" NUMBER(5,2) DEFAULT 0 NOT NULL ENABLE, 
	"ID_CTR" NUMBER(8,0), 
	"ID_JTVA_COLOANA" NUMBER(4,0), 
	"SERIE_ACT" VARCHAR2(10), 
	"VALIDAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTILV" NUMBER(10,0), 
	"DATAORAV" DATE, 
	"TAXCODE" NUMBER(6,0), 
	"PAYMENTCODE" VARCHAR2(9), 
	 CONSTRAINT "FK_ACT_001" FOREIGN KEY ("ID_SUCURSALA")
	  REFERENCES "CONTAFIN_ORACLE"."NOM_FIRME" ("ID_FIRMA") ENABLE, 
	 CONSTRAINT "FK_ACT_002" FOREIGN KEY ("TAXCODE")
	  REFERENCES "MARIUSM_AUTO"."SAFT_TAXTABLE" ("TAXCODE") ENABLE, 
	 CONSTRAINT "FK_ACT_003" FOREIGN KEY ("PAYMENTCODE")
	  REFERENCES "MARIUSM_AUTO"."SAFT_MECANISME_PLATI" ("MECHANISMCODE") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_ACT" ON "MARIUSM_AUTO"."ACT" ("ID_ACT") 
  ;
ALTER TABLE "MARIUSM_AUTO"."ACT" ADD CONSTRAINT "PK_ACT" PRIMARY KEY ("ID_ACT")
  USING INDEX "MARIUSM_AUTO"."PK_ACT"  ENABLE;

-- --- TABLE: CALENDAR ---

  CREATE TABLE "MARIUSM_AUTO"."CALENDAR" 
   (	"ID_CALENDAR" NUMBER(5,0), 
	"NL" VARCHAR2(2), 
	"AN" VARCHAR2(4), 
	"CTVAI" NUMBER(7,3), 
	"CTVAM" NUMBER(7,3), 
	"PLAFON_CASA" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"INCHIS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"PLAFON_PLATI" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"PLAFON_FURNIZORI" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"ANUL" NUMBER(4,0) DEFAULT 0 NOT NULL ENABLE, 
	"LUNA" NUMBER(2,0) DEFAULT 0 NOT NULL ENABLE, 
	"LUNA_INITIALA" NUMBER(1,0), 
	"TVA_INCASARE" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"IMPOZIT_PROFIT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_CALENDAR" ON "MARIUSM_AUTO"."CALENDAR" ("ID_CALENDAR") 
  ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."UK_CALENDAR_001" ON "MARIUSM_AUTO"."CALENDAR" ("ANUL", "LUNA") 
  ;
ALTER TABLE "MARIUSM_AUTO"."CALENDAR" ADD CONSTRAINT "PK_CALENDAR" PRIMARY KEY ("ID_CALENDAR")
  USING INDEX "MARIUSM_AUTO"."PK_CALENDAR"  ENABLE;
ALTER TABLE "MARIUSM_AUTO"."CALENDAR" ADD CONSTRAINT "UK_CALENDAR_001" UNIQUE ("ANUL", "LUNA")
  USING INDEX "MARIUSM_AUTO"."UK_CALENDAR_001"  ENABLE;

-- --- TABLE: CONTRACTE ---

  CREATE TABLE "MARIUSM_AUTO"."CONTRACTE" 
   (	"ID_CTR" NUMBER(8,0) NOT NULL ENABLE, 
	"ID_PART" NUMBER(10,0), 
	"DATA" DATE DEFAULT SYSDATE, 
	"NUMAR" VARCHAR2(100), 
	"STERS" NUMBER(1,0) DEFAULT 0, 
	"ID_UTIL" NUMBER(8,0), 
	"DATAORA" DATE DEFAULT sysdate, 
	"ID_UTILS" NUMBER(8,0), 
	"DATAORAS" DATE, 
	"ID_TIP_CTR" NUMBER(4,0) NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"VALFTVA" NUMBER(16,4), 
	"VALCTVA" NUMBER(16,4), 
	"ID_VALUTA" NUMBER(5,0), 
	"VAL_DISCOUNT" NUMBER(16,4), 
	"PROC_TVA" NUMBER(6,2) DEFAULT 19 NOT NULL ENABLE, 
	"INCETAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATA_INCEPUT" DATE, 
	"DATA_SFARSIT" DATE, 
	"DURATA" NUMBER(5,0), 
	"DATA_INCETAT" DATE, 
	"MOTIV_INCETAT" VARCHAR2(200), 
	"SCADENTA_INCASARE" NUMBER(3,0) DEFAULT 15 NOT NULL ENABLE, 
	"COEF_PENALITATI" NUMBER(6,2), 
	"ID_RESPONSABIL" NUMBER(10,0), 
	"ID_SECTIE" NUMBER(5,0), 
	"SEMNAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"OBSERVATII" CLOB, 
	"OPT_FACTURARE" NUMBER(4,0), 
	"TEXT_STANDARD" NUMBER(1,0), 
	"ID_NOTA" NUMBER(10,0), 
	"ID_AGENT" NUMBER(20,0), 
	"DESCRIERE" VARCHAR2(250), 
	"ID_SELECTIE" NUMBER(4,0), 
	"GRNT_PROC_RET" NUMBER(2,0), 
	"GRNT_VAL_RET" NUMBER(10,4), 
	"GRNT_ALERTA1" NUMBER(4,0), 
	"GRNT_PROC_ALERTA1" NUMBER(3,0), 
	"GRNT_PV_NR" NUMBER(10,0), 
	"GRNT_PV_DATA" DATE, 
	"NUMAR_INTERN" VARCHAR2(20), 
	"DATA_INTERN" DATE, 
	"OFERTANTI" VARCHAR2(200), 
	"TIP_ISTORIC" VARCHAR2(1) DEFAULT 'C' NOT NULL ENABLE, 
	"ID_TATA" NUMBER(8,0), 
	"ACTIV" NUMBER(1,0) DEFAULT 0, 
	"ID_ACT_ADITIONAL" NUMBER(8,0), 
	"GRNT_PERIOADA" NUMBER(2,0) DEFAULT 12, 
	"CURS" NUMBER(22,6), 
	"ID_SUCURSALA" NUMBER(5,0), 
	"SUSPENDAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"AFISARE_SCADENTA" NUMBER(1,0) DEFAULT 1 NOT NULL ENABLE, 
	"TIP_CURS" NUMBER(2,0) DEFAULT 0 NOT NULL ENABLE, 
	"COEF_PENALITATI2" NUMBER(6,2), 
	"ZILE_PENALITATI" NUMBER(4,0), 
	"ZILE_PENALITATI2" NUMBER(4,0), 
	"ZILE_GRATIE_PENALITATI" NUMBER(4,0), 
	 CONSTRAINT "FK_CONTRACTE_001" FOREIGN KEY ("ID_SUCURSALA")
	  REFERENCES "CONTAFIN_ORACLE"."NOM_FIRME" ("ID_FIRMA") ENABLE, 
	 CONSTRAINT "FK_CONTRACTE_004" FOREIGN KEY ("ID_SELECTIE")
	  REFERENCES "MARIUSM_AUTO"."CTR_SELECTII" ("ID_SELECTIE") ENABLE, 
	 CONSTRAINT "FK_CONTRACTE_003" FOREIGN KEY ("ID_AGENT")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE, 
	 CONSTRAINT "FK_CONTRACTE_002" FOREIGN KEY ("ID_TIP_CTR")
	  REFERENCES "MARIUSM_AUTO"."TIPURI_CONTRACTE" ("ID_TIP_CTR") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_CONTRACTE" ON "MARIUSM_AUTO"."CONTRACTE" ("ID_CTR") 
  ;
ALTER TABLE "MARIUSM_AUTO"."CONTRACTE" ADD CONSTRAINT "PK_CONTRACTE" PRIMARY KEY ("ID_CTR")
  USING INDEX "MARIUSM_AUTO"."PK_CONTRACTE"  ENABLE;

-- --- TABLE: CTR_ARTICOLE ---

  CREATE TABLE "MARIUSM_AUTO"."CTR_ARTICOLE" 
   (	"ID_CTR_ART" NUMBER(5,0) NOT NULL ENABLE, 
	"ID_CTR" NUMBER(5,0), 
	"ID_POL_ART" NUMBER(5,0), 
	"PRET_UNITAR" NUMBER(20,4), 
	"CANT" NUMBER(10,4), 
	"COEF_DISCOUNT" NUMBER(10,4), 
	"VAL_DISCOUNT" NUMBER(20,4), 
	"ID_VALUTA" NUMBER(5,0), 
	"EXPLICATIE" VARCHAR2(100), 
	"UM" VARCHAR2(10), 
	"ID_ARTICOL" NUMBER(20,0), 
	"PRET_CU_TVA" NUMBER(1,0) DEFAULT 0, 
	"ID_LOCATIA" NUMBER(5,0), 
	"PROC_TVAV" NUMBER(5,2), 
	"VALOARE" NUMBER(20,4), 
	 CONSTRAINT "FK_CTR_ART_001" FOREIGN KEY ("ID_CTR")
	  REFERENCES "MARIUSM_AUTO"."CONTRACTE" ("ID_CTR") ENABLE, 
	 CONSTRAINT "FK_CTR_ART_002" FOREIGN KEY ("ID_POL_ART")
	  REFERENCES "MARIUSM_AUTO"."CRM_POLITICI_PRET_ART" ("ID_POL_ART") ENABLE, 
	 CONSTRAINT "FK_CTR_ART_003" FOREIGN KEY ("ID_ARTICOL")
	  REFERENCES "MARIUSM_AUTO"."NOM_ARTICOLE" ("ID_ARTICOL") ENABLE, 
	 CONSTRAINT "FK_CTR_ART_004" FOREIGN KEY ("ID_LOCATIA")
	  REFERENCES "MARIUSM_AUTO"."NOM_LOCATII" ("ID") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_CTR_ART" ON "MARIUSM_AUTO"."CTR_ARTICOLE" ("ID_CTR_ART") 
  ;
ALTER TABLE "MARIUSM_AUTO"."CTR_ARTICOLE" ADD CONSTRAINT "PK_CTR_ART" PRIMARY KEY ("ID_CTR_ART")
  USING INDEX "MARIUSM_AUTO"."PK_CTR_ART"  ENABLE;

-- --- TABLE: DEV_ESTIMARI_PRODUSE ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_ESTIMARI_PRODUSE" 
   (	"ID_DEV_ESTIMARE_PROD" NUMBER(20,0) NOT NULL ENABLE, 
	"ID_LUCRARE" NUMBER(20,0) NOT NULL ENABLE, 
	"ID_ARTICOL" NUMBER(20,0), 
	"CANTITATE" NUMBER(20,4) NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTIL" NUMBER(20,0) NOT NULL ENABLE, 
	"DATAORA" DATE DEFAULT SYSDATE NOT NULL ENABLE, 
	"ID_UTILS" NUMBER(20,0), 
	"DATAORAS" DATE, 
	"DIMENSIUNI" NUMBER(20,6), 
	"EXPLICATIE" VARCHAR2(240), 
	"PROC_PIERDERITEHN" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE, 
	"LUNGIME" NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE, 
	"LATIME" NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE, 
	"PRET" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE, 
	"PRET_CU_TVA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_PROD_003" FOREIGN KEY ("ID_UTIL")
	  REFERENCES "CONTAFIN_ORACLE"."UTILIZATORI" ("ID_UTIL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_PROD_004" FOREIGN KEY ("ID_UTILS")
	  REFERENCES "CONTAFIN_ORACLE"."UTILIZATORI" ("ID_UTIL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_PROD_002" FOREIGN KEY ("ID_ARTICOL")
	  REFERENCES "MARIUSM_AUTO"."NOM_ARTICOLE" ("ID_ARTICOL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_PROD_001" FOREIGN KEY ("ID_LUCRARE")
	  REFERENCES "MARIUSM_AUTO"."NOM_LUCRARI" ("ID_LUCRARE") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_DEV_ESTIMARI_PROD" ON "MARIUSM_AUTO"."DEV_ESTIMARI_PRODUSE" ("ID_DEV_ESTIMARE_PROD") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_ESTIMARI_PRODUSE" ADD CONSTRAINT "PK_DEV_ESTIMARI_PROD" PRIMARY KEY ("ID_DEV_ESTIMARE_PROD")
  USING INDEX "MARIUSM_AUTO"."PK_DEV_ESTIMARI_PROD"  ENABLE;

-- --- TABLE: DEV_ESTIMARI_REP ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_ESTIMARI_REP" 
   (	"ID_DEV_ESTIMARE_REP" NUMBER(20,0) NOT NULL ENABLE, 
	"ID_LUCRARE" NUMBER(20,0) NOT NULL ENABLE, 
	"ID_NORME" NUMBER(20,0), 
	"ID_ARTICOL" NUMBER(20,0), 
	"CANTITATE" NUMBER(20,4) NOT NULL ENABLE, 
	"PRET" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTIL" NUMBER(20,0) NOT NULL ENABLE, 
	"DATAORA" DATE DEFAULT SYSDATE NOT NULL ENABLE, 
	"ID_UTILS" NUMBER(20,0), 
	"DATAORAS" DATE, 
	"PRET_CU_TVA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"COTA_TVA" NUMBER(10,0) DEFAULT null, 
	"ID_SECTIE" NUMBER(10,0), 
	"ID_POL" NUMBER(20,0), 
	"ID_DEV_ESTIMARE_PROD" NUMBER(20,0), 
	"ID_ARTICOL_GRUPARE" NUMBER(20,0), 
	"CU_PIERDERI" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_VALUTA" NUMBER(10,0), 
	"SEMIFABRICAT_ALES" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"SEMIFABRICAT_ID" NUMBER(10,0), 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_004" FOREIGN KEY ("ID_UTIL")
	  REFERENCES "CONTAFIN_ORACLE"."UTILIZATORI" ("ID_UTIL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_005" FOREIGN KEY ("ID_UTILS")
	  REFERENCES "CONTAFIN_ORACLE"."UTILIZATORI" ("ID_UTIL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_008" FOREIGN KEY ("ID_POL")
	  REFERENCES "MARIUSM_AUTO"."CRM_POLITICI_PRETURI" ("ID_POL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_002" FOREIGN KEY ("ID_NORME")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_NORME" ("ID_NORME") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_003" FOREIGN KEY ("ID_ARTICOL")
	  REFERENCES "MARIUSM_AUTO"."NOM_ARTICOLE" ("ID_ARTICOL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_009" FOREIGN KEY ("ID_ARTICOL_GRUPARE")
	  REFERENCES "MARIUSM_AUTO"."NOM_ARTICOLE" ("ID_ARTICOL") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_001" FOREIGN KEY ("ID_LUCRARE")
	  REFERENCES "MARIUSM_AUTO"."NOM_LUCRARI" ("ID_LUCRARE") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_007" FOREIGN KEY ("ID_SECTIE")
	  REFERENCES "MARIUSM_AUTO"."NOM_SECTII" ("ID_SECTIE") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_010" FOREIGN KEY ("ID_VALUTA")
	  REFERENCES "MARIUSM_AUTO"."NOM_VALUTE" ("ID_VALUTA") ENABLE, 
	 CONSTRAINT "FK_DEV_ESTIMARI_REP_006" FOREIGN KEY ("ID_DEV_ESTIMARE_PROD")
	  REFERENCES "MARIUSM_AUTO"."DEV_ESTIMARI_PRODUSE" ("ID_DEV_ESTIMARE_PROD") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_DEV_ESTIMARI_REP" ON "MARIUSM_AUTO"."DEV_ESTIMARI_REP" ("ID_DEV_ESTIMARE_REP") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_ESTIMARI_REP" ADD CONSTRAINT "PK_DEV_ESTIMARI_REP" PRIMARY KEY ("ID_DEV_ESTIMARE_REP")
  USING INDEX "MARIUSM_AUTO"."PK_DEV_ESTIMARI_REP"  ENABLE;

-- --- TABLE: DEV_MASINICLIENTI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_MASINICLIENTI" 
   (	"ID_MASINICLIENT" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_TIPMOTOR" NUMBER(5,0), 
	"ID_FURNIZOR" NUMBER(5,0), 
	"ID_MASINA" NUMBER(5,0), 
	"ID_PARTENER" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"NRINMAT" VARCHAR2(40) NOT NULL ENABLE, 
	"SERIES" VARCHAR2(17), 
	"SERIEM" VARCHAR2(18), 
	"CULOARE" VARCHAR2(30), 
	"KMINT" NUMBER(10,0), 
	"DATAACHI" DATE, 
	"NRACHI" NUMBER(16,0), 
	"SERIEF" VARCHAR2(20), 
	"SERIECV" VARCHAR2(20), 
	"ANFABRICATIE" NUMBER(4,0), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"CILINDREE" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"PUTERECP" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"PUTEREKW" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"ORE_FUNCTIONARE" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	 CONSTRAINT "FK_FURNIZOR" FOREIGN KEY ("ID_FURNIZOR")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_FURNIZORIMASINI" ("ID_FURNIZOR") ENABLE NOVALIDATE, 
	 CONSTRAINT "FK_MASINA" FOREIGN KEY ("ID_MASINA")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_MASINI" ("ID_MASINA") ENABLE NOVALIDATE, 
	 CONSTRAINT "FK_TIPMOTOR" FOREIGN KEY ("ID_TIPMOTOR")
	  REFERENCES "MARIUSM_AUTO"."DEV_TIPURI_MOTOARE" ("ID_TIPMOTOR") ENABLE NOVALIDATE, 
	 CONSTRAINT "FK_ID_PARTENER" FOREIGN KEY ("ID_PARTENER")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE NOVALIDATE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_MASINICLIENT" ON "MARIUSM_AUTO"."DEV_MASINICLIENTI" ("ID_MASINICLIENT") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_MASINICLIENTI" ADD CONSTRAINT "PK_MASINICLIENT" PRIMARY KEY ("ID_MASINICLIENT")
  USING INDEX "MARIUSM_AUTO"."PK_MASINICLIENT"  ENABLE;

-- --- TABLE: DEV_MECANICI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_MECANICI" 
   (	"ID_MECANIC" NUMBER(5,0) NOT NULL ENABLE, 
	"ID_SECTIE" NUMBER(5,0), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_PART" NUMBER(20,0), 
	 CONSTRAINT "FK_DEV_MECANICI_001" FOREIGN KEY ("ID_PART")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE, 
	 CONSTRAINT "FK_DEV_MECANICI_002" FOREIGN KEY ("ID_SECTIE")
	  REFERENCES "MARIUSM_AUTO"."NOM_SECTII" ("ID_SECTIE") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_MECANICI" ON "MARIUSM_AUTO"."DEV_MECANICI" ("ID_MECANIC") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_MECANICI" ADD CONSTRAINT "PK_MECANICI" PRIMARY KEY ("ID_MECANIC")
  USING INDEX "MARIUSM_AUTO"."PK_MECANICI"  ENABLE;

-- --- TABLE: DEV_NOM_ANSAMBLE ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_ANSAMBLE" 
   (	"ID_ANSAMBLU" NUMBER(5,0) NOT NULL ENABLE, 
	"DENUMIRE" VARCHAR2(100), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_ANSAMBLE" ON "MARIUSM_AUTO"."DEV_NOM_ANSAMBLE" ("ID_ANSAMBLU") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_ANSAMBLE" ADD CONSTRAINT "PK_ANSAMBLE" PRIMARY KEY ("ID_ANSAMBLU")
  USING INDEX "MARIUSM_AUTO"."PK_ANSAMBLE"  ENABLE;

-- --- TABLE: DEV_NOM_ASIGURATORI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_ASIGURATORI" 
   (	"ID_ASIGURATOR" NUMBER(5,0) NOT NULL ENABLE, 
	"ASIGURATOR_VECHI" VARCHAR2(24), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_PART" NUMBER(10,0) NOT NULL ENABLE, 
	 CONSTRAINT "FK_ASIGURATORI_001" FOREIGN KEY ("ID_PART")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_ASIGURATORI" ON "MARIUSM_AUTO"."DEV_NOM_ASIGURATORI" ("ID_ASIGURATOR") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_ASIGURATORI" ADD CONSTRAINT "PK_ASIGURATORI" PRIMARY KEY ("ID_ASIGURATOR")
  USING INDEX "MARIUSM_AUTO"."PK_ASIGURATORI"  ENABLE;

-- --- TABLE: DEV_NOM_DELEGATI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_DELEGATI" 
   (	"ID_NOM_DELEGATI" NUMBER(5,0) NOT NULL ENABLE, 
	"DELEGAT" VARCHAR2(64), 
	"ELIBERATDE" VARCHAR2(64), 
	"ID_PARTENER" NUMBER(10,0) NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"BI" VARCHAR2(10), 
	"TELEFON1" VARCHAR2(20), 
	"TELEFON2" VARCHAR2(20), 
	 CONSTRAINT "FK_PARTENER" FOREIGN KEY ("ID_PARTENER")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE NOVALIDATE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_DELEGAT" ON "MARIUSM_AUTO"."DEV_NOM_DELEGATI" ("ID_NOM_DELEGATI") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_DELEGATI" ADD CONSTRAINT "PK_DELEGAT" PRIMARY KEY ("ID_NOM_DELEGATI")
  USING INDEX "MARIUSM_AUTO"."PK_DELEGAT"  ENABLE;

-- --- TABLE: DEV_NOM_FURNIZORIMASINI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_FURNIZORIMASINI" 
   (	"ID_FURNIZOR" NUMBER(5,0) NOT NULL ENABLE, 
	"DENUMIRE" VARCHAR2(50), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_FURNIZOR" ON "MARIUSM_AUTO"."DEV_NOM_FURNIZORIMASINI" ("ID_FURNIZOR") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_FURNIZORIMASINI" ADD CONSTRAINT "PK_FURNIZOR" PRIMARY KEY ("ID_FURNIZOR")
  USING INDEX "MARIUSM_AUTO"."PK_FURNIZOR"  ENABLE;

-- --- TABLE: DEV_NOM_INSPECTORI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_INSPECTORI" 
   (	"ID_INSPECTOR" NUMBER(5,0) NOT NULL ENABLE, 
	"INSPECTOR" VARCHAR2(24), 
	"ID_ASIGURATOR" NUMBER(5,0), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	 CONSTRAINT "FK_NOM_ASIGURATORI" FOREIGN KEY ("ID_ASIGURATOR")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_ASIGURATORI" ("ID_ASIGURATOR") ENABLE NOVALIDATE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_NOM_INSPECTORI" ON "MARIUSM_AUTO"."DEV_NOM_INSPECTORI" ("ID_INSPECTOR") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_INSPECTORI" ADD CONSTRAINT "PK_NOM_INSPECTORI" PRIMARY KEY ("ID_INSPECTOR")
  USING INDEX "MARIUSM_AUTO"."PK_NOM_INSPECTORI"  ENABLE;

-- --- TABLE: DEV_NOM_MARCI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_MARCI" 
   (	"ID_MARCA" NUMBER(5,0) NOT NULL ENABLE, 
	"MARCA" VARCHAR2(24), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_MARCA" ON "MARIUSM_AUTO"."DEV_NOM_MARCI" ("ID_MARCA") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_MARCI" ADD CONSTRAINT "PK_MARCA" PRIMARY KEY ("ID_MARCA")
  USING INDEX "MARIUSM_AUTO"."PK_MARCA"  ENABLE;

-- --- TABLE: DEV_NOM_MASINI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_MASINI" 
   (	"ID_MASINA" NUMBER(5,0) NOT NULL ENABLE, 
	"ID_MARCA" NUMBER(5,0) NOT NULL ENABLE, 
	"MASINA" VARCHAR2(20), 
	"SCTIP" VARCHAR2(100), 
	"CLASA" VARCHAR2(10), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"COMBUSTIBIL" VARCHAR2(50), 
	"CLINDREE" NUMBER(10,0), 
	"PUTERE_KW" NUMBER(10,0), 
	"PUTERE_CP" NUMBER(10,0), 
	"CUTIE_VITEZE" VARCHAR2(50), 
	"TRACTIUNE" VARCHAR2(50), 
	"ECHIPARE" VARCHAR2(50), 
	 CONSTRAINT "FK_MARCA" FOREIGN KEY ("ID_MARCA")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_MARCI" ("ID_MARCA") ENABLE NOVALIDATE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_MASINA" ON "MARIUSM_AUTO"."DEV_NOM_MASINI" ("ID_MASINA") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_MASINI" ADD CONSTRAINT "PK_MASINA" PRIMARY KEY ("ID_MASINA")
  USING INDEX "MARIUSM_AUTO"."PK_MASINA"  ENABLE;

-- --- TABLE: DEV_NOM_NORME ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_NORME" 
   (	"ID_NORME" NUMBER(5,0) NOT NULL ENABLE, 
	"ID_ANSAMBLU" NUMBER(5,0) DEFAULT null, 
	"ID_MASINA" NUMBER(5,0) DEFAULT null, 
	"DENOP" VARCHAR2(100), 
	"CODOP" VARCHAR2(10), 
	"TIMPN" NUMBER(7,3) DEFAULT 0 NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	 CONSTRAINT "FK_ANSAMBLE" FOREIGN KEY ("ID_ANSAMBLU")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_ANSAMBLE" ("ID_ANSAMBLU") ENABLE NOVALIDATE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_NORME" ON "MARIUSM_AUTO"."DEV_NOM_NORME" ("ID_NORME") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_NORME" ADD CONSTRAINT "PK_NORME" PRIMARY KEY ("ID_NORME")
  USING INDEX "MARIUSM_AUTO"."PK_NORME"  ENABLE;

-- --- TABLE: DEV_NOM_PRETURI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_NOM_PRETURI" 
   (	"ID_PRET" NUMBER(5,0) NOT NULL ENABLE, 
	"ID_MARCA" NUMBER(5,0), 
	"ID_ASIGURATOR" NUMBER(5,0), 
	"PRET" NUMBER(18,4) DEFAULT 0 NOT NULL ENABLE, 
	"PRET_VAL" NUMBER(10,4) DEFAULT 0 NOT NULL ENABLE, 
	"ID_VALUTA" NUMBER(5,0), 
	"CURS" NUMBER(14,6) DEFAULT 0 NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	 CONSTRAINT "FK_ASIGURATOR" FOREIGN KEY ("ID_ASIGURATOR")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_ASIGURATORI" ("ID_ASIGURATOR") ENABLE, 
	 CONSTRAINT "FK_MARCA1" FOREIGN KEY ("ID_MARCA")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_MARCI" ("ID_MARCA") ENABLE NOVALIDATE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_PRETURI" ON "MARIUSM_AUTO"."DEV_NOM_PRETURI" ("ID_PRET") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_NOM_PRETURI" ADD CONSTRAINT "PK_PRETURI" PRIMARY KEY ("ID_PRET")
  USING INDEX "MARIUSM_AUTO"."PK_PRETURI"  ENABLE;

-- --- TABLE: DEV_OPER ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_OPER" 
   (	"ID_OPER" NUMBER(10,0) NOT NULL ENABLE, 
	"ID_ORDL" NUMBER(10,0) NOT NULL ENABLE, 
	"ID_NORME" NUMBER(10,0), 
	"TIMPN" NUMBER(8,3) DEFAULT 0 NOT NULL ENABLE, 
	"PRET" NUMBER(17,4) DEFAULT 0 NOT NULL ENABLE, 
	"DATAI" DATE DEFAULT sysdate NOT NULL ENABLE, 
	"ID_SECTIE" NUMBER(5,0), 
	"ID_UTIL" NUMBER(5,0), 
	"DATAORA" DATE, 
	"ID_UTILS" NUMBER(5,0), 
	"DATAORAS" DATE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"VALIDAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"NOU" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTILI" NUMBER(5,0), 
	"ID_ARTICOL" NUMBER(20,0), 
	"ID_DEV_ESTIMARE_REP" NUMBER(20,0), 
	"ID_FACT" NUMBER(20,0), 
	"ID_RUL_AUX" NUMBER(20,0), 
	 CONSTRAINT "FK_DEV_OPER_006" FOREIGN KEY ("ID_DEV_ESTIMARE_REP")
	  REFERENCES "MARIUSM_AUTO"."DEV_ESTIMARI_REP" ("ID_DEV_ESTIMARE_REP") ENABLE, 
	 CONSTRAINT "FK_DEV_OPER_002" FOREIGN KEY ("ID_NORME")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_NORME" ("ID_NORME") ENABLE, 
	 CONSTRAINT "FK_DEV_OPER_001" FOREIGN KEY ("ID_ORDL")
	  REFERENCES "MARIUSM_AUTO"."DEV_ORDL" ("ID_ORDL") ENABLE, 
	 CONSTRAINT "FK_DEV_OPER_007" FOREIGN KEY ("ID_FACT")
	  REFERENCES "MARIUSM_AUTO"."DOCUMENTE" ("ID_DOC") DISABLE, 
	 CONSTRAINT "FK_DEV_OPER_004" FOREIGN KEY ("ID_ARTICOL")
	  REFERENCES "MARIUSM_AUTO"."NOM_ARTICOLE" ("ID_ARTICOL") ENABLE, 
	 CONSTRAINT "FK_DEV_OPER_003" FOREIGN KEY ("ID_SECTIE")
	  REFERENCES "MARIUSM_AUTO"."NOM_SECTII" ("ID_SECTIE") ENABLE, 
	 CONSTRAINT "FK_DEV_OPER_005" FOREIGN KEY ("ID_RUL_AUX")
	  REFERENCES "MARIUSM_AUTO"."RUL_AUXILIAR" ("ID_RUL_AUX") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_OPER" ON "MARIUSM_AUTO"."DEV_OPER" ("ID_OPER") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_OPER" ADD CONSTRAINT "PK_OPER" PRIMARY KEY ("ID_OPER")
  USING INDEX "MARIUSM_AUTO"."PK_OPER"  ENABLE;

-- --- TABLE: DEV_OPER_MECANICI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_OPER_MECANICI" 
   (	"ID_OPERMECANIC" NUMBER(10,0) NOT NULL ENABLE, 
	"ID_MECANIC" NUMBER(5,0) NOT NULL ENABLE, 
	"ID_OPER" NUMBER(10,0) NOT NULL ENABLE, 
	"ORE" NUMBER(8,3) DEFAULT 0 NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_DEV_OPER_MECANICI" ON "MARIUSM_AUTO"."DEV_OPER_MECANICI" ("ID_OPERMECANIC") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_OPER_MECANICI" ADD CONSTRAINT "PK_DEV_OPER_MECANICI" PRIMARY KEY ("ID_OPERMECANIC")
  USING INDEX "MARIUSM_AUTO"."PK_DEV_OPER_MECANICI"  ENABLE;

-- --- TABLE: DEV_ORDL ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_ORDL" 
   (	"ID_ORDL" NUMBER(10,0) NOT NULL ENABLE, 
	"LUNA" NUMBER(2,0) DEFAULT 0 NOT NULL ENABLE, 
	"AN" NUMBER(4,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_INSPECTOR" NUMBER(5,0) DEFAULT null, 
	"ID_LUCRARE" NUMBER(10,0) NOT NULL ENABLE, 
	"TERMEN" DATE, 
	"DATAI" DATE, 
	"ORAI" NUMBER(5,0), 
	"DATAE" DATE, 
	"ORAE" NUMBER(5,0), 
	"VALIDAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTIL_AD" NUMBER(5,0) DEFAULT null NOT NULL ENABLE, 
	"ID_UTIL_VALID" NUMBER(5,0) DEFAULT null, 
	"DATAORAAD" DATE, 
	"DATAORAVALID" DATE, 
	"ID_UTILS" NUMBER(5,0) DEFAULT null, 
	"DATAORAS" DATE, 
	"ID_MASINICLIENT" NUMBER(5,0) DEFAULT null, 
	"ID_ASIGURATOR" NUMBER(5,0) DEFAULT null, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_TIP" NUMBER(5,0) DEFAULT 1 NOT NULL ENABLE, 
	"INCHIS_FORTAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"KMINT" NUMBER(10,0), 
	"NR_DOSAR" VARCHAR2(40), 
	"SOLICITARI_CLIENT" CLOB, 
	"PROC_TVAV" NUMBER(10,4), 
	"ID_PART" NUMBER(10,0), 
	"COADA_DEVIZ" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"OBSERVATII" VARCHAR2(1000), 
	"DATA_CURS" DATE, 
	"IN_LUCRU" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_VALUTA_DEVIZ" NUMBER(10,0), 
	"FACTUREZMIX" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATA_IN_LUCRU" DATE, 
	"DATAORAINLUCRU" DATE, 
	"ID_AGENT" NUMBER(10,0), 
	"ID_UTIL_INCHIS" NUMBER(5,0), 
	"DATAORAINCHIS" DATE, 
	"ID_PART_REF" NUMBER(10,0), 
	"ORE_FUNCTIONARE" NUMBER(10,0), 
	"DEFECTIUNI" VARCHAR2(200), 
	 CONSTRAINT "FK_DEV_ORDL_001" FOREIGN KEY ("ID_INSPECTOR")
	  REFERENCES "MARIUSM_AUTO"."DEV_NOM_INSPECTORI" ("ID_INSPECTOR") ENABLE, 
	 CONSTRAINT "FK_DEV_ORDL_002" FOREIGN KEY ("ID_LUCRARE")
	  REFERENCES "MARIUSM_AUTO"."NOM_LUCRARI" ("ID_LUCRARE") ENABLE, 
	 CONSTRAINT "FK_DEV_ORDL_005" FOREIGN KEY ("ID_AGENT")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE, 
	 CONSTRAINT "FK_DEV_ORDL_003" FOREIGN KEY ("ID_PART")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE, 
	 CONSTRAINT "FK_DEV_ORDL_006" FOREIGN KEY ("ID_PART_REF")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE, 
	 CONSTRAINT "FK_DEV_ORDL_004" FOREIGN KEY ("ID_VALUTA_DEVIZ")
	  REFERENCES "MARIUSM_AUTO"."NOM_VALUTE" ("ID_VALUTA") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_ORDL" ON "MARIUSM_AUTO"."DEV_ORDL" ("ID_ORDL") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_ORDL" ADD CONSTRAINT "PK_DEV_ORDL" PRIMARY KEY ("ID_ORDL")
  USING INDEX "MARIUSM_AUTO"."PK_ORDL"  ENABLE;

-- --- TABLE: DEV_RAPOARTE_PROD_DET ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_RAPOARTE_PROD_DET" 
   (	"ID_DEV_RAP_PROD_DET" NUMBER(20,0) NOT NULL ENABLE, 
	"ID_ARTICOL" NUMBER(20,0) NOT NULL ENABLE, 
	"CANTITATE" NUMBER(20,4) NOT NULL ENABLE, 
	"PRET" NUMBER(20,4) NOT NULL ENABLE, 
	"ID_FACT" NUMBER(20,0), 
	"ID_RUL_AUX" NUMBER(20,0) NOT NULL ENABLE, 
	 CONSTRAINT "FK_DEV_RAP_PROD_DET_002" FOREIGN KEY ("ID_FACT")
	  REFERENCES "MARIUSM_AUTO"."DOCUMENTE" ("ID_DOC") ENABLE, 
	 CONSTRAINT "FK_DEV_RAP_PROD_DET_001" FOREIGN KEY ("ID_ARTICOL")
	  REFERENCES "MARIUSM_AUTO"."NOM_ARTICOLE" ("ID_ARTICOL") ENABLE, 
	 CONSTRAINT "FK_DEV_RAP_PROD_DET_003" FOREIGN KEY ("ID_RUL_AUX")
	  REFERENCES "MARIUSM_AUTO"."RUL_AUXILIAR" ("ID_RUL_AUX") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_DEV_RAP_PROD_DET" ON "MARIUSM_AUTO"."DEV_RAPOARTE_PROD_DET" ("ID_DEV_RAP_PROD_DET") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_RAPOARTE_PROD_DET" ADD CONSTRAINT "PK_DEV_RAP_PROD_DET" PRIMARY KEY ("ID_DEV_RAP_PROD_DET")
  USING INDEX "MARIUSM_AUTO"."PK_DEV_RAP_PROD_DET"  ENABLE;

-- --- TABLE: DEV_TIPURI_MOTOARE ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_TIPURI_MOTOARE" 
   (	"ID_TIPMOTOR" NUMBER(5,0) NOT NULL ENABLE, 
	"DENUMIRE" VARCHAR2(50), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_TIPMOTOR" ON "MARIUSM_AUTO"."DEV_TIPURI_MOTOARE" ("ID_TIPMOTOR") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_TIPURI_MOTOARE" ADD CONSTRAINT "PK_TIPMOTOR" PRIMARY KEY ("ID_TIPMOTOR")
  USING INDEX "MARIUSM_AUTO"."PK_TIPMOTOR"  ENABLE;

-- --- TABLE: DEV_TIP_DEVIZ ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_TIP_DEVIZ" 
   (	"ID_TIP" NUMBER(5,0) NOT NULL ENABLE, 
	"DENUMIRE" VARCHAR2(50) NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"INCH_VALIDARE" NUMBER(1,0) DEFAULT 1 NOT NULL ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_TIP_DEVIZ" ON "MARIUSM_AUTO"."DEV_TIP_DEVIZ" ("ID_TIP") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_TIP_DEVIZ" ADD CONSTRAINT "PK_TIP_DEVIZ" PRIMARY KEY ("ID_TIP")
  USING INDEX "MARIUSM_AUTO"."PK_TIP_DEVIZ"  ENABLE;

-- --- TABLE: DEV_UTILIZATORI_CODURI ---

  CREATE TABLE "MARIUSM_AUTO"."DEV_UTILIZATORI_CODURI" 
   (	"ID_UTIL_COD" NUMBER(5,0) NOT NULL ENABLE, 
	"ID_UTIL" NUMBER(5,0) NOT NULL ENABLE, 
	"COD" VARCHAR2(44), 
	 CONSTRAINT "FK_DEV_UTILIZATORI_CODURI001" FOREIGN KEY ("ID_UTIL")
	  REFERENCES "CONTAFIN_ORACLE"."UTILIZATORI" ("ID_UTIL") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_DEV_UTILIZATORI_CODURI" ON "MARIUSM_AUTO"."DEV_UTILIZATORI_CODURI" ("ID_UTIL_COD") 
  ;
ALTER TABLE "MARIUSM_AUTO"."DEV_UTILIZATORI_CODURI" ADD CONSTRAINT "PK_DEV_UTILIZATORI_CODURI" PRIMARY KEY ("ID_UTIL_COD")
  USING INDEX "MARIUSM_AUTO"."PK_DEV_UTILIZATORI_CODURI"  ENABLE;

-- --- TABLE: NOM_ARTICOLE ---

  CREATE TABLE "MARIUSM_AUTO"."NOM_ARTICOLE" 
   (	"ID_ARTICOL" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"CODMAT" VARCHAR2(50), 
	"DENUMIRE" VARCHAR2(100), 
	"UM" VARCHAR2(20), 
	"CONT" VARCHAR2(4), 
	"ACONT" VARCHAR2(4), 
	"DEP" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_SUBGRUPA" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"CANT_BAX" NUMBER(9,4) DEFAULT 1 NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_MOD" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"CODBARE" VARCHAR2(50), 
	"IN_STOC" NUMBER(1,0) DEFAULT 1 NOT NULL ENABLE, 
	"IN_CRM" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"DNF" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"DESCRIERE" VARCHAR2(500), 
	"UM2" VARCHAR2(10), 
	"ID_UTIL" NUMBER(5,0), 
	"DATAORA" DATE DEFAULT sysdate, 
	"CODMATF" VARCHAR2(50), 
	"CONDITII_PASTRARE" VARCHAR2(500), 
	"ID_PART" NUMBER(10,0), 
	"PRETACHCTVA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"TAXA_RECONDITIONARE" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE, 
	"ID_ARTICOL_GENERAL" NUMBER(20,0), 
	"LISTARE_CODBARE" NUMBER(1,0) DEFAULT 0, 
	"TIP" NUMBER(1,0) DEFAULT 0, 
	"TIMPN" NUMBER(7,3) DEFAULT 0, 
	"COMPUS" NUMBER(1,0) DEFAULT 0, 
	"CODNC8" VARCHAR2(20), 
	"ID_TARA_ORIGINE" NUMBER(4,0), 
	"GREUTATE" NUMBER(12,4) DEFAULT 0 NOT NULL ENABLE, 
	"CODCPV" VARCHAR2(20)
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_ARTICOL" ON "MARIUSM_AUTO"."NOM_ARTICOLE" ("ID_ARTICOL") 
  ;
ALTER TABLE "MARIUSM_AUTO"."NOM_ARTICOLE" ADD CONSTRAINT "PK_ARTICOL" PRIMARY KEY ("ID_ARTICOL")
  USING INDEX "MARIUSM_AUTO"."PK_ARTICOL"  ENABLE;

-- --- TABLE: NOM_LUCRARI ---

  CREATE TABLE "MARIUSM_AUTO"."NOM_LUCRARI" 
   (	"ID_LUCRARE" NUMBER(10,0) NOT NULL ENABLE, 
	"NRORD" VARCHAR2(50), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_MOD" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"FACTURATA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_TATA" NUMBER(10,0) DEFAULT null, 
	"ID_FACT" NUMBER(20,0)
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_LUCRARE" ON "MARIUSM_AUTO"."NOM_LUCRARI" ("ID_LUCRARE") 
  ;
ALTER TABLE "MARIUSM_AUTO"."NOM_LUCRARI" ADD CONSTRAINT "PK_LUCRARE" PRIMARY KEY ("ID_LUCRARE")
  USING INDEX "MARIUSM_AUTO"."PK_LUCRARE"  ENABLE;

-- --- TABLE: NOM_PARTENERI ---

  CREATE TABLE "MARIUSM_AUTO"."NOM_PARTENERI" 
   (	"ID_PART" NUMBER(10,0) NOT NULL ENABLE, 
	"NUME" VARCHAR2(100), 
	"COD_FISCAL" VARCHAR2(30), 
	"REG_COMERT" VARCHAR2(30), 
	"ADRESA" VARCHAR2(150), 
	"ID_LOC_BCKP" NUMBER(5,0), 
	"BANCA" VARCHAR2(60), 
	"CONT_BANCA" VARCHAR2(60), 
	"ZONA" VARCHAR2(16), 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_MOD" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"INACTIV" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"TELEFON2" VARCHAR2(32), 
	"TELEFON3" VARCHAR2(32), 
	"EMAIL" VARCHAR2(32), 
	"FAX" VARCHAR2(32), 
	"DENUMIRE" VARCHAR2(100), 
	"PRENUME" VARCHAR2(100), 
	"PREFIX" VARCHAR2(30), 
	"SUFIX" VARCHAR2(30), 
	"MOTIV_INACTIV" VARCHAR2(100), 
	"TIP_PERSOANA" NUMBER(1,0) DEFAULT 1 NOT NULL ENABLE, 
	"ID_UTIL" NUMBER(8,0), 
	"DATAORA" DATE DEFAULT sysdate, 
	"ID_UTILS" NUMBER(8,0), 
	"DATAORAS" DATE, 
	"ELIBERATDE" VARCHAR2(64), 
	"DATAELIBERAT" DATE, 
	"ID_CATEGORIE_ENTITATE" NUMBER(10,0), 
	"BLOC" VARCHAR2(8), 
	"SCARA" VARCHAR2(8), 
	"APARTAMENT" VARCHAR2(8), 
	"TELEFON" VARCHAR2(1000), 
	"COD_FISCAL_VECHI" VARCHAR2(1000), 
	"ID_LOC" NUMBER(10,0), 
	"COD_FISCAL2" VARCHAR2(30), 
	"SWIFT_BANCA" VARCHAR2(11), 
	"ADRESA_BANCA" VARCHAR2(150), 
	"INSTITUTIE_PUBLICA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ENTITATE_AFILIATA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	 CONSTRAINT "FK_NOM_PARTENERI_001" FOREIGN KEY ("ID_CATEGORIE_ENTITATE")
	  REFERENCES "MARIUSM_AUTO"."NOM_CATEGORII_ENTITATI" ("ID_CATEGORIE_ENTITATE") ENABLE, 
	 CONSTRAINT "FK_NOM_PARTENERI_002" FOREIGN KEY ("ID_LOC")
	  REFERENCES "CONTAFIN_ORACLE"."NOM_LOCALITATI" ("ID_LOC") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_ID_PART" ON "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") 
  ;
ALTER TABLE "MARIUSM_AUTO"."NOM_PARTENERI" ADD CONSTRAINT "PK_ID_PART" PRIMARY KEY ("ID_PART")
  USING INDEX "MARIUSM_AUTO"."PK_ID_PART"  ENABLE;

-- --- TABLE: RUL ---

  CREATE TABLE "MARIUSM_AUTO"."RUL" 
   (	"ID_RUL" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"AN" NUMBER(4,0) DEFAULT 0 NOT NULL ENABLE, 
	"LUNA" NUMBER(2,0) DEFAULT 0 NOT NULL ENABLE, 
	"COD" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"NNIR" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_ARTICOL" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_GESTIUNE" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"PRET" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"PRETV" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"TVA" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"TVAV" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"CANT" NUMBER(14,3) DEFAULT 0 NOT NULL ENABLE, 
	"CANTE" NUMBER(14,3) DEFAULT 0 NOT NULL ENABLE, 
	"CONT" VARCHAR2(4) NOT NULL ENABLE, 
	"ADAOS" NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE, 
	"ID_LUCRARE" NUMBER(20,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_RESPONSABIL" NUMBER(10,0) DEFAULT 0, 
	"DATAACT" DATE, 
	"PROCENT" NUMBER(10,3) DEFAULT 0 NOT NULL ENABLE, 
	"CURS" NUMBER(16,6) DEFAULT 0 NOT NULL ENABLE, 
	"PRETD" NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTIL" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATAORA" DATE, 
	"ID_SECTIE" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
	"ALCOOLTUTUN" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"PRETVTVA" NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE, 
	"ACONT" VARCHAR2(4), 
	"DATAIN" DATE, 
	"DATAOUT" DATE, 
	"PROC_DISC" NUMBER(7,3) DEFAULT 0 NOT NULL ENABLE, 
	"DISCUNITAR" NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE, 
	"PROC_TVA" NUMBER(5,2) DEFAULT 0 NOT NULL ENABLE, 
	"ID_FACT" NUMBER(20,0) DEFAULT 0, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"DISCOUNT_TVA" NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE, 
	"ADAOS_TVA" NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE, 
	"PROC_TVAV" NUMBER(5,2) DEFAULT 0 NOT NULL ENABLE, 
	"VALOARE" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"VALOAREV" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"VALTVA" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"VALTVAV" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"VALOARE_ADAOS" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"VALTVA_ADAOS" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"VALOARE_DISCOUNT" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"VALTVA_DISCOUNT" NUMBER(16,4) DEFAULT 0 NOT NULL ENABLE, 
	"ID_GESTIUNEC" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_RESPONSABILC" NUMBER(5,0) DEFAULT 0, 
	"ID_TIP_RULAJ" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_RETETA" NUMBER(10,0), 
	"ID_SET" NUMBER(20,0), 
	"ID_SUCURSALA" NUMBER(5,0), 
	"ID_OBIECT_DEPOZIT" NUMBER(10,0), 
	"ID_RUL_AUX" NUMBER(10,0), 
	"NRACT" NUMBER(20,0), 
	"ID_UTILS" NUMBER(10,0), 
	"DATAORAS" DATE, 
	"SERIE" VARCHAR2(100), 
	"ID_VALUTA" NUMBER(10,0), 
	"SERIE_ACT" VARCHAR2(10), 
	"LOT" VARCHAR2(20), 
	"ADATA_EXPIRARE" DATE, 
	"ID_PART_REZ" NUMBER(10,0), 
	"ID_LUCRARE_REZ" NUMBER(10,0), 
	"ID_RUL_AUX_INFO" NUMBER(10,0), 
	"ID_JTVA_COLOANA" NUMBER(4,0), 
	"TAXCODE" NUMBER(6,0), 
	 CONSTRAINT "FK_RUL_004" FOREIGN KEY ("ID_SUCURSALA")
	  REFERENCES "CONTAFIN_ORACLE"."NOM_FIRME" ("ID_FIRMA") ENABLE, 
	 CONSTRAINT "FK_RUL_006" FOREIGN KEY ("ID_LUCRARE_REZ")
	  REFERENCES "MARIUSM_AUTO"."NOM_LUCRARI" ("ID_LUCRARE") DISABLE, 
	 CONSTRAINT "FK_RUL_002" FOREIGN KEY ("ID_OBIECT_DEPOZIT")
	  REFERENCES "MARIUSM_AUTO"."NOM_OBIECTE_DEPOZITARE" ("ID_OBIECT_DEPOZIT") DISABLE, 
	 CONSTRAINT "FK_RUL_005" FOREIGN KEY ("ID_PART_REZ")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") DISABLE, 
	 CONSTRAINT "FK_RUL_001" FOREIGN KEY ("ID_TIP_RULAJ")
	  REFERENCES "MARIUSM_AUTO"."NOM_TIP_RULAJ" ("ID_TIP_RULAJ") ENABLE, 
	 CONSTRAINT "FK_RUL_003" FOREIGN KEY ("ID_RUL_AUX")
	  REFERENCES "MARIUSM_AUTO"."RUL_AUXILIAR" ("ID_RUL_AUX") DISABLE, 
	 CONSTRAINT "FK_RUL_007" FOREIGN KEY ("ID_RUL_AUX_INFO")
	  REFERENCES "MARIUSM_AUTO"."RUL_AUXILIAR" ("ID_RUL_AUX") DISABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_RUL" ON "MARIUSM_AUTO"."RUL" ("ID_RUL") 
  ;
ALTER TABLE "MARIUSM_AUTO"."RUL" ADD CONSTRAINT "PK_RUL" PRIMARY KEY ("ID_RUL")
  USING INDEX "MARIUSM_AUTO"."PK_RUL"  ENABLE;

-- --- TABLE: VANZARI ---

  CREATE TABLE "MARIUSM_AUTO"."VANZARI" 
   (	"ID_VANZARE" NUMBER(10,0) NOT NULL ENABLE, 
	"ID_UTIL" NUMBER(10,0) NOT NULL ENABLE, 
	"DATAORA" DATE DEFAULT SYSDATE NOT NULL ENABLE, 
	"STERS" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_UTILS" NUMBER(10,0), 
	"DATAORAS" DATE, 
	"ID_LUCRARE" NUMBER(10,0) DEFAULT 0, 
	"ID_PART" NUMBER(10,0) DEFAULT 0, 
	"NUMAR_ACT" NUMBER(20,0) DEFAULT 0, 
	"NR_PERSOANE" NUMBER(10,0) DEFAULT 0, 
	"NRINMAT" VARCHAR2(20), 
	"FACTURAT" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"DATA_FACTURAT" DATE, 
	"ID_UTILFACT" NUMBER(10,0), 
	"ID_PUNCTVANZARE" NUMBER(5,0) DEFAULT 0, 
	"ID_COMANDA" NUMBER(20,0), 
	"TIP" NUMBER(2,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_GESTIUNE" NUMBER(20,0), 
	"COD" NUMBER(20,0), 
	"ID_DELEGAT" NUMBER(20,0), 
	"ID_MASINA" NUMBER(20,0), 
	"DATA_ACT" DATE, 
	"ID_AGENT" NUMBER(20,0), 
	"DISCOUNT" NUMBER(20,4), 
	"DISCOUNT_EVIDENTIAT" NUMBER(1,0), 
	"TEXT_ADITIONAL" VARCHAR2(1000), 
	"IN_VALUTA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"SERIE_ACT" VARCHAR2(10), 
	"ID_SUCURSALA" NUMBER(5,0), 
	"ID_RUTA" NUMBER(10,0), 
	"ID_SECTIE" NUMBER(10,0), 
	"DIFTOTFTVA" NUMBER(20,4), 
	"DIFTOTTVA" NUMBER(20,4), 
	"ID_VANZARE2" VARCHAR2(32), 
	"DATAORA_EXP" DATE DEFAULT SYSDATE NOT NULL ENABLE, 
	"ID_FACT_DESCARCAT" NUMBER(10,0), 
	"DATAORA_DESCARCAT" DATE, 
	"ID_CASA_MARCAT_Z" NUMBER(20,0), 
	"AFISARE_SCADENTA" NUMBER(1,0) DEFAULT 1 NOT NULL ENABLE, 
	"COEFICIENT_K" NUMBER(5,2), 
	"ID_ORDL" NUMBER(10,0), 
	"TVA_INCASARE" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"ID_FACTURARE" NUMBER(10,0), 
	"LISTARE_DETALIATA" NUMBER(1,0) DEFAULT 0, 
	"DISCOUNT_TVA" NUMBER(20,4), 
	"VALOARE_ACHIZITIE" NUMBER(20,4), 
	"TOTAL_FARA_TVA" NUMBER(20,4), 
	"TOTAL_TVA" NUMBER(20,4), 
	"TOTAL_CU_TVA" NUMBER(20,4), 
	"SERIE_INCASAT" VARCHAR2(10), 
	"NR_INCASAT" NUMBER(20,0), 
	"SUMA_INCASAT" NUMBER(20,4), 
	"TIP_INCASAT" NUMBER(2,0), 
	"AVIZE" VARCHAR2(1000), 
	"ID_VALUTA" NUMBER(10,0), 
	"CURS" NUMBER(22,6), 
	"MULTIPLICATOR" NUMBER(10,0), 
	"ID_FACT" NUMBER(20,0), 
	"DATA_SCAD" DATE, 
	"ID_CTR" NUMBER(10,0), 
	"VALVAL" NUMBER(20,4), 
	"TVAVAL" NUMBER(20,4), 
	"TOTVAL" NUMBER(20,4), 
	"TIP_FACTURA" NUMBER(2,0), 
	"ID_BENEFICIAR" NUMBER(10,0), 
	"EPROFORMA" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE, 
	"TIP_SAFT" NUMBER(3,0), 
	"EFACTURA" NUMBER(1,0), 
	 CONSTRAINT "FK_VANZARI_007" FOREIGN KEY ("ID_SUCURSALA")
	  REFERENCES "CONTAFIN_ORACLE"."NOM_FIRME" ("ID_FIRMA") ENABLE, 
	 CONSTRAINT "FK_VANZARI_009" FOREIGN KEY ("ID_CASA_MARCAT_Z")
	  REFERENCES "MARIUSM_AUTO"."CASE_MARCAT_Z" ("ID_CASA_MARCAT_Z") ENABLE, 
	 CONSTRAINT "FK_VANZARI_001" FOREIGN KEY ("ID_COMANDA")
	  REFERENCES "MARIUSM_AUTO"."COMENZI" ("ID_COMANDA") ENABLE, 
	 CONSTRAINT "FK_VANZARI_008" FOREIGN KEY ("ID_RUTA")
	  REFERENCES "MARIUSM_AUTO"."FACT_NOM_RUTE" ("ID_RUTA") ENABLE, 
	 CONSTRAINT "FK_VANZARI_004" FOREIGN KEY ("ID_MASINA")
	  REFERENCES "MARIUSM_AUTO"."NOM_MASINI" ("ID_MASINA") ENABLE, 
	 CONSTRAINT "FK_VANZARI_003" FOREIGN KEY ("ID_DELEGAT")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE, 
	 CONSTRAINT "FK_VANZARI_005" FOREIGN KEY ("ID_AGENT")
	  REFERENCES "MARIUSM_AUTO"."NOM_PARTENERI" ("ID_PART") ENABLE
   ) ;
  CREATE UNIQUE INDEX "MARIUSM_AUTO"."PK_VANZARI" ON "MARIUSM_AUTO"."VANZARI" ("ID_VANZARE") 
  ;
ALTER TABLE "MARIUSM_AUTO"."VANZARI" ADD CONSTRAINT "PK_VANZARI" PRIMARY KEY ("ID_VANZARE")
  USING INDEX "MARIUSM_AUTO"."PK_VANZARI"  ENABLE;


-- ============================================================
-- === SECTION: VIEWS ===
-- ============================================================
-- Gasite: 88 obiecte

-- --- VIEW: AUTO_ANALIZA_COMENZI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_ANALIZA_COMENZI" ("NRORD", "ID_PART", "NUME", "COD_FISCAL", "DATAI", "ASIGURATOR", "INSPECTOR", "BANCA", "CONT_BANCA", "ADRESA", "EMAIL", "TELEFON1", "TELEFON2", "NR_DOSAR", "VALIDAT", "ID_MASINICLIENT", "NRINMAT", "SERIES", "SERIEM", "CULOARE", "KMINT", "ID_MASINA", "ID_MARCA", "MARCA", "MASINA", "SEMN", "ID_LUCRARE", "CODMAT", "DENUMIRE", "CANTE", "PRET", "DATA", "ID") AS 
  select l.nrord,
       p.id_part,
       p.denumire         as nume,
       p.cod_fiscal,
       ord.datai,
       asig1.denumire     as asigurator,
       ins.inspector,
       p.banca,
       p.cont_banca,
       ap.adresa,
       ap.email,
       ap.telefon1,
       ap.telefon2,
       ord.nr_dosar,
       ord.validat,
       mc.id_masiniclient,
       mc.nrinmat,
       mc.series,
       mc.seriem,
       mc.culoare,
       ord.kmint,
       mc.id_masina,
       mm.id_marca,
       mm.marca,
       ms.masina,
       ro.semn,
       ro.id_lucrare,
       ro.codmat,
       ro.denumire,
       ro.cante,
       ro.pret,
       ro.data,
       ro.id
  from dev_masiniclienti mc
  join dev_ordl ord
    on ord.id_masiniclient = mc.id_masiniclient
  join (select 'A' as semn,
                    r.id_lucrare,
                    art.codmat,
                    art.denumire,
                    r.cante,
                    r.pretv as pret,
                    r.dataact as data,
                    r.id_rul as id
               from rul r
               join nom_articole art
                 on r.id_articol = art.id_articol
              where r.sters = 0
                and r.cante <> 0
             union all
             select 'B' as semn,
                    o.id_lucrare,
                    n.codop as codmat,
                    n.denop as denumire,
                    op.timpn as cante,
                    (case op.nou
                      when 0 then
                       round(op.pret / 10000, 2)
                      else
                       op.pret
                    end) as pret,
                    op.datai as data,
                    op.id_oper as id
               from dev_ordl o
               join dev_oper op
                 on op.id_ordl = o.id_ordl
               join dev_nom_norme n
                 on op.id_norme = n.id_norme) ro
    on ro.id_lucrare = ord.id_lucrare
  join nom_lucrari l
    on ord.id_lucrare = l.id_lucrare
  left join nom_parteneri p
    on mc.id_partener = p.id_part
  left join vadrese_parteneri ap
    on p.id_part = ap.id_part
   and ap.principala = 1
  left join dev_nom_asiguratori asig
    on ord.id_asigurator = asig.id_asigurator
  left join nom_parteneri asig1
    on asig.id_part = asig1.id_part
  left join dev_nom_inspectori ins
    on ord.id_inspector = ins.id_inspector
  left join dev_nom_masini ms
    on mc.id_masina = ms.id_masina
  left join dev_nom_marci mm
    on ms.id_marca = mm.id_marca
 where nvl(ord.sters,0) = 0
   and mc.sters = 0
   and p.sters = 0;

-- --- VIEW: AUTO_ANALIZA_MANASIG ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_ANALIZA_MANASIG" ("TIP", "ASIG", "LUNA", "TIMP_N") AS 
  Select decode(a.id_tip, 1, 'POST GARANTIE', 2, 'GARANTIE', 'REGIE') As tip,
       NVL(a.asigurator, 'FARA ASIGURATOR') as asig,
       decode(a.id_tip,
              1,
              last_day(trunc(a.datafact)),
              last_day(trunc(a.dataoravalid))) as luna,
       Nvl(Sum(round(b.timpn, 3)), 0) As timp_n
  From auto_istoric_comenzi a
  Left Join dev_oper b
    On a.id_ordl = b.id_ordl
 Where ((a.validat = 1 and a.id_tip > 1) or
       (a.facturat = 1 and a.id_tip = 1))
   and b.sters = 0
 Group By a.asigurator,
          a.id_tip,
          decode(a.id_tip,
                 1,
                 last_day(trunc(a.datafact)),
                 last_day(trunc(a.dataoravalid)));

-- --- VIEW: AUTO_ANALIZA_SALARII ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_ANALIZA_SALARII" ("ID_ORDL", "ID_TIP") AS 
  select a.id_ordl, a.id_tip
  from dev_ordl a
  left join auto_vordl_facturate b
    on a.id_lucrare = b.id_lucrare
  left join dev_tip_deviz c
    on a.id_tip = c.id_tip
 where a.sters = 0
   and ((c.inch_validare = 0 and
       (b.facturat = 1 and (b.dataact between pack_auto.get_datai() and
       pack_auto.get_dataf()))) or
       (c.inch_validare = 1 and
       (a.validat = 1 and (a.dataoravalid between pack_auto.get_datai() and
       pack_auto.get_dataf()))));

-- --- VIEW: AUTO_ANALIZA_SALARII_REG ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_ANALIZA_SALARII_REG" ("ID_MECANIC", "NUME", "ORE", "MANOPERA", "ORE_REG", "MANOPERA_REG") AS 
  select d.id_mecanic,
       e.denumire as nume,
       sum(case
             when a.id_tip = 1 then
              c.ore
             else
              0
           end) as ore,
       sum(case
             when a.id_tip = 1 then
              round(b.pret * c.ore, 2)
             else
              0
           end) as manopera,
       sum(case
             when a.id_tip != 1 then
              c.ore
             else
              0
           end) as ore_reg,
       sum(case
             when a.id_tip != 1 then
              round(b.pret * c.ore, 2)
             else
              0
           end) as manopera_reg
  from auto_analiza_salarii a
  left join dev_oper b on a.id_ordl = b.id_ordl
  left join dev_oper_mecanici c on b.id_oper = c.id_oper
  left join dev_mecanici d on c.id_mecanic = d.id_mecanic
  left join nom_parteneri e on d.id_part = e.id_part
 where b.sters = 0
   and c.sters = 0
 group by d.id_mecanic, e.denumire;

-- --- VIEW: AUTO_ANALIZA_SALARII_VAL ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_ANALIZA_SALARII_VAL" ("ID_MECANIC", "NUME", "ORE", "MANOPERA", "ORE_REG", "MANOPERA_REG") AS 
  select d.id_mecanic,
       e.denumire as nume,
       sum(case
             when a.id_tip = 1 then
              c.ore
             else
              0
           end) as ore,
       sum(case
             when a.id_tip = 1 then
              round(b.pret * c.ore, 2)
             else
              0
           end) as manopera,
       sum(case
             when a.id_tip != 1 then
              c.ore
             else
              0
           end) as ore_reg,
       sum(case
             when a.id_tip != 1 then
              round(b.pret * c.ore, 2)
             else
              0
           end) as manopera_reg
  from dev_ordl a
  left join dev_oper b on a.id_ordl = b.id_ordl
  left join dev_oper_mecanici c on b.id_oper = c.id_oper
  left join dev_mecanici d on c.id_mecanic = d.id_mecanic
  left join nom_parteneri e on d.id_part = e.id_part
 where a.sters = 0
   and a.validat = 1
   and a.dataoravalid between pack_auto.get_datai() and
       pack_auto.get_dataf()
   and b.sters = 0
   and c.sters = 0
 group by d.id_mecanic, e.denumire;

-- --- VIEW: AUTO_COMENZI_VALIDATE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_COMENZI_VALIDATE" ("ID_ORDL", "ID_LUCRARE", "ID_MASINICLIENT", "ID_TIP", "DATAI", "ID_INSPECTOR", "ID_ASIGURATOR", "NR_DOSAR", "KMINT", "ORE_FUNCTIONARE", "PROC_TVAV", "VALIDAT", "DATAORAVALID", "UTIL_VALID", "NRORD", "INCHIS_FORTAT", "DATAORAINCHIS", "UTIL_INCHIS", "ID_PART_REF") AS 
  select a.id_ordl,
       a.id_lucrare,
       a.id_masiniclient,
       a.id_tip,
       a.datai,
       a.id_inspector,
       a.id_asigurator,
       a.nr_dosar,
       a.kmint,
       a.ore_functionare,
       a.proc_tvav,
       (case
         when extract(month from a.dataoravalid) +
              extract(year from a.dataoravalid) * 12 <=
              pack_sesiune.getluna() + pack_sesiune.getan() * 12 then
          1
         else
          0
       end) as validat,
       (case
         when extract(month from a.dataoravalid) +
              extract(year from a.dataoravalid) * 12 <=
              pack_sesiune.getluna() + pack_sesiune.getan() * 12 then
          a.dataoravalid
         else
          null
       end) as dataoravalid,
       (case
         when extract(month from a.dataoravalid) +
              extract(year from a.dataoravalid) * 12 <=
              pack_sesiune.getluna() + pack_sesiune.getan() * 12 then
          b.utilizator
         else
          null
       end) as util_valid,
       c.nrord,
       a.inchis_fortat,
       (case
         when extract(month from a.dataorainchis) +
              extract(year from a.dataorainchis) * 12 <=
              pack_sesiune.getluna() + pack_sesiune.getan() * 12 then
          a.dataorainchis
         else
          null
       end) as dataorainchis,
       (case
         when extract(month from a.dataorainchis) +
              extract(year from a.dataorainchis) * 12 <=
              pack_sesiune.getluna() + pack_sesiune.getan() * 12 then
          d.utilizator
         else
          null
       end) as util_inchis,
       a.id_part_ref
  from dev_ordl a
  left join syn_utilizatori b
    on a.id_util_valid = b.id_util
  left join nom_lucrari c
    on a.id_lucrare = c.id_lucrare
  left join syn_utilizatori d
    on a.id_util_inchis = d.id_util
 where a.sters = 0;

-- --- VIEW: AUTO_DATE_SUPLIMENTARE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_DATE_SUPLIMENTARE" ("ID_ORDL", "KMINT", "ORE_FUNCTIONARE", "SOLICITARI_CLIENT", "OBSERVATII", "DEFECTIUNI", "TERMEN", "ASIGURATOR", "INSPECTOR", "ID_PARTENER", "SERIES", "MASINA", "MARCA", "ID_MARCA") AS 
  select a.id_ordl,
       a.kmint,
       a.ore_functionare,
       a.solicitari_client,
       a.observatii,
       a.defectiuni,
       a.termen,
       b1.denumire as asigurator,
       c.inspector,
       d.id_partener,
       d.series,
       e.masina,
       f.marca,
       f.id_marca
  from dev_ordl a
  left join dev_nom_asiguratori b
    on a.id_asigurator = b.id_asigurator
  left join nom_parteneri b1
    on b.id_part = b1.id_part
  left join dev_nom_inspectori c
    on a.id_inspector = c.id_inspector
  left join dev_masiniclienti d
    on a.id_masiniclient = d.id_masiniclient
  left join dev_nom_masini e
    on d.id_masina = e.id_masina
  left join dev_nom_marci f
    on e.id_marca = f.id_marca
 where a.sters = 0;

-- --- VIEW: AUTO_DATE_SUPLIMENTARE_RAP ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_DATE_SUPLIMENTARE_RAP" ("ID_ORDL", "TERMEN", "KMINT", "ORE_FUNCTIONARE", "SOLICITARI_CLIENT", "OBSERVATII", "DEFECTIUNI", "ASIGURATOR", "INSPECTOR", "SERIEM", "NRINMAT", "SERIES", "ANFABRICATIE", "NRACHI", "DATAACHI", "MASINA", "MARCA", "TELEFON", "COD_FISCAL", "ADRESA", "FURNIZOR") AS 
  select a.id_ordl,
       a.termen,
       a.kmint,
       a.ore_functionare,
       a.solicitari_client,
       a.observatii,
       a.defectiuni,
       b1.denumire         as asigurator,
       c.inspector,
       d.seriem,
       d.nrinmat,
       d.series,
       d.anfabricatie,
       d.nrachi,
       d.dataachi,
       e.masina,
       f.marca,
       g.telefon,
       g.cod_fiscal,
       g.adresa,
       h.denumire          as furnizor
  from dev_ordl a
  left join dev_nom_asiguratori b
    on a.id_asigurator = b.id_asigurator
  left join nom_parteneri b1
    on b.id_part = b1.id_part
  left join dev_nom_inspectori c
    on a.id_inspector = c.id_inspector
  left join dev_masiniclienti d
    on a.id_masiniclient = d.id_masiniclient
  left join dev_nom_masini e
    on d.id_masina = e.id_masina
  left join dev_nom_marci f
    on e.id_marca = f.id_marca
  left join vnom_parteneri g
    on d.id_partener = g.id_part
  left join dev_nom_furnizorimasini h
    on d.id_furnizor = h.id_furnizor
 where a.sters = 0;

-- --- VIEW: AUTO_DETALII_COMENZI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_DETALII_COMENZI" ("ID_ORDL", "VALIDAT", "DATAORAVALID", "ID_TIP", "FACTURAT", "DATAFACT", "NRFACT") AS 
  select a.id_ordl,
       a.validat,
       a.dataoravalid,
       a.id_tip,
       nvl(b.facturat, 0) as facturat,
       b.dataact as datafact,
       nvl(b.nract, 0) as nrfact
  from dev_ordl a
  left join auto_vordl_facturi b
    on a.id_lucrare = b.id_lucrare
 where a.sters = 0;

-- --- VIEW: AUTO_FACTURI_ASIG ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_FACTURI_ASIG" ("DATAI", "NR_DOSAR", "ASIGURATOR", "NRACT", "DATAACT", "MANOPERA", "MATERIALE", "VALCTVA", "NUME", "NRORD") AS 
  select a.datai,
       a.nr_dosar,
       c1.denumire as asigurator,
       b.nract,
       b.dataact,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron
         else
          b.manopera_rol
       end) as manopera,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.materiale_ron
         else
          b.materiale_rol
       end) as materiale,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron + b.materiale_ron + b.tva_ron
         else
          b.manopera_rol + b.materiale_rol + b.tva_rol
       end) as valctva,
       e.denumire as nume,
       f.nrord
  from dev_ordl a
  join mv_ordl_sume_act b
    on a.id_lucrare = b.id_lucrare
  left join dev_nom_asiguratori c
    on a.id_asigurator = c.id_asigurator
  left join nom_parteneri c1
    on c.id_part = c1.id_part
  left join dev_masiniclienti d
    on a.id_masiniclient = d.id_masiniclient
  left join nom_parteneri e
    on d.id_partener = e.id_part
  left join vnom_lucrari f
    on a.id_lucrare = f.id_lucrare
 where NVL(a.id_asigurator, 0) <> 0
   and a.sters = 0
   and b.id_set not in (31006, 31007)
 order by c1.denumire, b.dataact;

-- --- VIEW: AUTO_FACTURI_CLIENTI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_FACTURI_CLIENTI" ("DATAI", "NUME", "TELEFON", "NRACT", "DATAACT", "MANOPERA", "MATERIALE", "VALCTVA", "NRORD") AS 
  select a.datai,
       d.denumire as nume,
       d.telefon,
       b.nract,
       b.dataact,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron
         else
          b.manopera_rol
       end) as manopera,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.materiale_ron
         else
          b.materiale_rol
       end) as materiale,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron + b.materiale_ron + b.tva_ron
         else
          b.manopera_rol + b.materiale_rol + b.tva_rol
       end) as valctva,
       e.nrord
  from dev_ordl a
  join mv_ordl_sume_act b
    on a.id_lucrare = b.id_lucrare
  left join dev_masiniclienti c
    on a.id_masiniclient = c.id_masiniclient
  left join vnom_parteneri d
    on c.id_partener = d.id_part
  left join vnom_lucrari e
    on a.id_lucrare = e.id_lucrare
 where a.sters = 0
   and b.id_set not in (31006, 31007)
 order by b.dataact;

-- --- VIEW: AUTO_FACTURI_EMISE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_FACTURI_EMISE" ("NRCRT", "DATAORAVALID", "DATAFACT", "VALIDAT", "FACTURAT", "INSPECTOR", "ASIGURATOR", "ID_TIP", "ID_LUCRARE", "NRORD", "DATAI", "NR_DOSAR", "NUME", "TELEFON", "NRACT", "DATAACT", "MANOPERA_DEVIZ", "MATERIALE_DEVIZ", "MANOPERA", "MATERIALE", "NRINMAT", "VALCTVA", "ID_PART_REF", "PART_REF") AS 
  select row_number() over(partition by a.nrord order by a.datai, a.nrord) as nrcrt,
       a.dataoravalid,
       a1.dataact as datafact,
       nvl(a.validat, 0) as validat,
       nvl(a1.facturat, 0) as facturat,
       e.inspector,
       f1.denumire as asigurator,
       a.id_tip,
       a.id_lucrare,
       a.nrord,
       a.datai,
       a.nr_dosar,
       d.denumire as nume,
       d.telefon,
       b.nract,
       b.dataact,
       NVL(a1.manopera, 0) as manopera_deviz,
       NVL(a2.materiale, 0) as materiale_deviz,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron
         else
          b.manopera_rol
       end) as manopera,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.materiale_ron
         else
          b.materiale_rol
       end) as materiale,
       c.nrinmat,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron + b.materiale_ron + b.tva_ron
         else
          b.manopera_rol + b.materiale_rol + b.tva_rol
       end) as valctva,
       a.id_part_ref,
       g.denumire as part_ref
  from auto_comenzi_validate a
  left join auto_vordl_facturate a1
    on a.id_lucrare = a1.id_lucrare
  join mv_ordl_sume_act b
    on a.id_lucrare = b.id_lucrare
  left join auto_vordl_man a1
    on a.id_ordl = a1.id_ordl
  left join auto_vordl_mat a2
    on a.id_lucrare = a2.id_lucrare
  left join dev_masiniclienti c
    on a.id_masiniclient = c.id_masiniclient
  left join vnom_parteneri d
    on c.id_partener = d.id_part
  left join dev_nom_inspectori e
    on a.id_inspector = e.id_inspector
  left join dev_nom_asiguratori f
    on a.id_asigurator = f.id_asigurator
  left join nom_parteneri f1
    on f.id_part = f1.id_part
left join nom_parteneri g
    on a.id_part_ref = g.id_part
 where b.id_set not in (31006, 31007);

-- --- VIEW: AUTO_FACTURI_EMISE_VECHI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_FACTURI_EMISE_VECHI" ("NRCRT", "DATAORAVALID", "DATAFACT", "VALIDAT", "FACTURAT", "INSPECTOR", "ASIGURATOR", "ID_TIP", "NRORD", "DATAI", "NR_DOSAR", "NUME", "TELEFON", "NRACT", "DATAACT", "MANOPERA_DEVIZ", "MATERIALE_DEVIZ", "MANOPERA", "MATERIALE", "NRINMAT", "VALCTVA", "ID_PART_REF", "PART_REF") AS 
  select row_number() over(partition by a.nrord order by a.datai, a.nrord) as nrcrt,
       a.dataoravalid,
       a.datafact,
       a.validat,
       a.facturat,
       e.inspector,
       f1.denumire as asigurator,
       a.id_tip,
       a.nrord,
       a.datai,
       a.nr_dosar,
       d.denumire as nume,
       d.telefon,
       b.nract,
       b.dataact,
       NVL(a1.manopera, 0) as manopera_deviz,
       NVL(a2.materiale, 0) as materiale_deviz,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron
         else
          b.manopera_rol
       end) as manopera,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.materiale_ron
         else
          b.materiale_rol
       end) as materiale,
       a.nrinmat,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron + b.materiale_ron + b.tva_ron
         else
          b.manopera_rol + b.materiale_rol + b.tva_rol
       end) as valctva,
       a.id_part_ref,
       a.part_ref
  from auto_normare_comenzi a
  join mv_ordl_sume_act b
    on a.id_lucrare = b.id_lucrare
  left join auto_vordl_man a1
    on a.id_ordl = a1.id_ordl
  left join auto_vordl_mat a2
    on a.id_lucrare = a2.id_lucrare
  left join dev_masiniclienti c
    on a.id_masiniclient = c.id_masiniclient
  left join vnom_parteneri d
    on c.id_partener = d.id_part
  left join dev_nom_inspectori e
    on a.id_inspector = e.id_inspector
  left join dev_nom_asiguratori f
    on a.id_asigurator = f.id_asigurator
  left join nom_parteneri f1
    on f.id_part = f1.id_part
 where b.id_set not in (31006, 31007)
 order by b.dataact;

-- --- VIEW: AUTO_FACTURI_TOATE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_FACTURI_TOATE" ("NRORD", "DATAI", "NUME", "NR_DOSAR", "ASIGURATOR", "NRACT", "DATAACT", "MANOPERA", "MATERIALE", "VALCTVA") AS 
  select f.nrord,
       a.datai,
       e.denumire as nume,
       a.nr_dosar,
       c1.denumire as asigurator,
       b.nract,
       b.dataact,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron
         else
          b.manopera_rol
       end) as manopera,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.materiale_ron
         else
          b.materiale_rol
       end) as materiale,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          b.manopera_ron + b.materiale_ron + b.tva_ron
         else
          b.manopera_rol + b.materiale_rol + b.tva_rol
       end) as valctva
  from dev_ordl a
  join mv_ordl_sume_act b
    on a.id_lucrare = b.id_lucrare
  left join dev_nom_asiguratori c
    on a.id_asigurator = c.id_asigurator
  left join nom_parteneri c1
    on c.id_part = c1.id_part
  left join dev_masiniclienti d
    on a.id_masiniclient = d.id_masiniclient
  left join nom_parteneri e
    on d.id_partener = e.id_part
  left join vnom_lucrari f
    on a.id_lucrare = f.id_lucrare
 where a.sters = 0
   and b.id_set not in (31006, 31007)
 order by c1.denumire, b.dataact;

-- --- VIEW: AUTO_INCHIDERE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_INCHIDERE" ("NRCRT", "DATAORAVALID", "DATAFACT", "VALIDAT", "FACTURAT", "ID_TIP", "NRORD", "DATAI", "NR_DOSAR", "NUME", "NRACT", "DATAACT", "MANOPERA", "MATERIALE", "NRINMAT", "TOTALFTVA", "ID_SET") AS 
  select row_number() over(partition by a.nrord order by a.datai, a.nrord) as nrcrt,
       a.dataoravalid,
       a.datafact,
       a.validat,
       a.facturat,
       a.id_tip,
       a.nrord,
       a.datai,
       a.nr_dosar,
       d.denumire as nume,
       b.nract,
       b.dataact,
       NVL(a1.manopera, 0) as manopera,
       NVL(a2.materiale, 0) as materiale,
       a.nrinmat,
       NVL(a1.manopera, 0) + NVL(a2.materiale, 0) as totalftva,
       b.id_set
  from auto_normare_comenzi a
  join mv_ordl_sume_act b
    on a.id_lucrare = b.id_lucrare
  left join auto_vordl_man a1
    on a.id_ordl = a1.id_ordl
  left join auto_vordl_mat a2
    on a.id_lucrare = a2.id_lucrare
  left join dev_masiniclienti c
    on a.id_masiniclient = c.id_masiniclient
  left join nom_parteneri d
    on c.id_partener = d.id_part
 where b.id_set in (31006, 31007)
 order by b.dataact;

-- --- VIEW: AUTO_ISTORIC_COMENZI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_ISTORIC_COMENZI" ("ID_ORDL", "ID_LUCRARE", "ID_MASINICLIENT", "ID_TIP", "DATAI", "NR_DOSAR", "VALIDAT", "DATAORAVALID", "UTIL_VALID", "NRORD", "PROC_TVAV", "FACTURAT", "DATAFACT", "NRFACT", "VALCTVA_FACTURA", "VAL_MANOPERA_FACTURA", "VAL_MATERIALE_FACTURA", "VAL_MATERIALE_ACH", "VAL_MATERIALE_VZ", "ORE_MANOPERA", "VAL_MANOPERA", "ID_PARTENER", "NRINMAT", "SERIES", "CILINDREE", "PUTERECP", "PUTEREKW", "MASINA", "MARCA", "NUME", "ASIGURATOR", "INSPECTOR", "TIP_COMANDA", "KMINT", "ORE_FUNCTIONARE", "INCHIS_FORTAT", "DATAORAINCHIS", "UTIL_INCHIS", "ID_PART_REF", "PART_REF") AS 
  select a.id_ordl,
       a.id_lucrare,
       a.id_masiniclient,
       a.id_tip,
       a.datai,
       a.nr_dosar,
       nvl(a.validat, 0) as validat,
       a.dataoravalid,
       a.util_valid,
       a.nrord,
       a.proc_tvav,
       nvl(c.facturat, 0) as facturat,
       c.dataact as datafact,
       nvl(c.nract, 0) as nrfact,
       c.valctva as valctva_factura,
       c.valfactmanopera as val_manopera_factura,
       c.valfactmateriale as val_materiale_factura,
       (select sum(round(pret * cante, 2)) as valoarea from rul where sters = 0 and id_lucrare = a.id_lucrare) as val_materiale_ach,
       (select sum(round(pretv * cante, 2)) as valoarea from rul where sters = 0 and id_lucrare = a.id_lucrare) as val_materiale_vz,
       (select sum(b1.timpn) as ore from dev_ordl a1 left join dev_oper b1 on a1.id_ordl = b1.id_ordl where a1.id_lucrare = a.id_lucrare and a1.sters = 0 and b1.sters = 0) as ore_manopera,
       (select sum(round(b1.timpn * b1.pret, 2)) as valoare_manopera from dev_ordl a1 left join dev_oper b1 on a1.id_ordl = b1.id_ordl where a1.id_lucrare = a.id_lucrare and a1.sters = 0 and b1.sters = 0) as val_manopera,
       d.id_partener,
       d.nrinmat,
       d.series,
       d.cilindree,
       d.puterecp,
       d.puterekw,
       b.masina,
       b1.marca,
       e.denumire as nume,
       g1.denumire as asigurator,
       h.inspector,
       i.denumire as tip_comanda,
       a.kmint,
       a.ore_functionare,
       a.inchis_fortat,
       a.dataorainchis,
       a.util_inchis,
       a.id_part_ref,
       j.denumire as part_ref
  from auto_comenzi_validate a
  left join auto_vordl_facturi c
    on a.id_lucrare = c.id_lucrare
  left join dev_masiniclienti d
    on a.id_masiniclient = d.id_masiniclient
  left join dev_nom_masini b
    on d.id_masina = b.id_masina
  left join dev_nom_marci b1
    on b.id_marca = b1.id_marca
  left join nom_parteneri e
    on d.id_partener = e.id_part
  left join dev_nom_asiguratori g
    on a.id_asigurator = g.id_asigurator
  left join nom_parteneri g1
    on g.id_part = g1.id_part
  left join dev_nom_inspectori h
    on a.id_inspector = h.id_inspector
  left join dev_tip_deviz i
    on a.id_tip = i.id_tip
  left join nom_parteneri j
    on a.id_part_ref = j.id_part
;

-- --- VIEW: AUTO_LISTARE_MAN_ANFABR ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_LISTARE_MAN_ANFABR" ("DATAI", "NRORD", "TIP_COMANDA", "ID_SECTIE", "SECTIE", "ANFABRICATIE", "DENUMIRE", "TOTAL") AS 
  select b.datai,
       g.nrord,
       c.denumire as tip_comanda,
       d.id_sectie,
       e.sectie,
       f.anfabricatie,
       h.denumire,
       sum(round(d.timpn * d.pret, 2)) as total
  from auto_analiza_salarii a
  left join dev_ordl b on a.id_ordl = b.id_ordl
  left join dev_tip_deviz c on a.id_tip = c.id_tip
  left join dev_oper d on b.id_ordl = d.id_ordl
                      and d.sters = 0
  left join nom_sectii e on d.id_sectie = e.id_sectie
  left join dev_masiniclienti f on b.id_masiniclient = f.id_masiniclient
  left join vnom_lucrari g on b.id_lucrare = g.id_lucrare
  left join nom_parteneri h on f.id_partener = h.id_part
 group by d.id_sectie,
          e.sectie,
          c.denumire,
          f.anfabricatie,
          b.datai,
          g.nrord,
          h.denumire;

-- --- VIEW: AUTO_LISTARE_MAN_SECTII ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_LISTARE_MAN_SECTII" ("ID_SECTIE", "SECTIE", "TOTAL_ORE", "TOTAL_VALOARE") AS 
  select NVL(d.id_sectie, -99) as id_sectie,
       NVL(e.sectie, '<FARA SECTIE>') as sectie,
       sum(NVL(d.timpn, 0)) as total_ore,
       sum(round(NVL(d.timpn, 0) *
                 NVL(pack_sesiune.suma_ron(d.pret, d.datai), 0),
                 2)) as total_valoare
  from auto_analiza_salarii a
  left join dev_ordl b on a.id_ordl = b.id_ordl
  left join dev_oper d on b.id_ordl = d.id_ordl
                      and d.sters = 0
  left join nom_sectii e on d.id_sectie = e.id_sectie
 group by d.id_sectie, e.sectie;

-- --- VIEW: AUTO_LISTARE_MAN_TOT_COM ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_LISTARE_MAN_TOT_COM" ("ORE", "ID_MECANIC", "VALOARE", "NUME", "PRENUME", "NRORD", "DATAI", "SECTIE") AS 
  select sum(d.ore) as ore,
       d.id_mecanic,
       sum(round(c.pret * d.ore, 2)) as valoare,
       d.nume,
       d.prenume,
       f.nrord,
       a.datai,
       d.sectie
  from dev_ordl a
  left join auto_vordl_facturate b
    on a.id_lucrare = b.id_lucrare
  left join auto_voper_preturi c
    on a.id_ordl = c.id_ordl
  left join auto_voper_mecanici d
    on c.id_oper = d.id_oper
  left join dev_tip_deviz e
    on a.id_tip = e.id_tip
  left join vnom_lucrari f
    on a.id_lucrare = f.id_lucrare
 where a.sters = 0
   and ((extract(month from a.dataoravalid) = pack_sesiune.getluna() and
       extract(year from a.dataoravalid) = pack_sesiune.getan() and
       a.validat = 1 and e.inch_validare = 1) or
       (extract(month from b.dataact) = pack_sesiune.getluna() and
       extract(year from b.dataact) = pack_sesiune.getan() and
       b.facturat = 1 and e.inch_validare = 0))
 group by a.id_ordl,
          f.nrord,
          d.id_mecanic,
          d.nume,
          d.prenume,
          a.datai,
          d.sectie
 order by d.id_mecanic;

-- --- VIEW: AUTO_LISTARE_MAN_TOT_DESF ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_LISTARE_MAN_TOT_DESF" ("ID_OPERMECANIC", "ID_OPER", "ORE", "INACTIV", "ID_MECANIC", "NUME", "PRENUME", "MARCA", "SECTIE", "ID_ORDL", "PRET", "DATAI", "NRACT", "DATAFACT", "DENOP", "TIMPN", "NRORD") AS 
  select d.id_opermecanic,
       d.id_oper,
       d.ore,
       d.inactiv,
       d.id_mecanic,
       d.nume,
       d.prenume,
       d.marca,
       d.sectie,
       a.id_ordl,
       c.pret,
       a.datai,
       b.nract          as nract,
       b.dataact        as datafact,
       c.denop,
       c.timpn,
       f.nrord
  from dev_ordl a
  left join auto_vordl_facturate b
    on a.id_lucrare = b.id_lucrare
  left join auto_voper_preturi c
    on a.id_ordl = c.id_ordl
  left join auto_voper_mecanici d
    on c.id_oper = d.id_oper
  left join dev_tip_deviz e
    on a.id_tip = e.id_tip
  left join vnom_lucrari f
    on a.id_lucrare = f.id_lucrare
 where a.sters = 0
   and ((extract(month from a.dataoravalid) = pack_sesiune.getluna() and
       extract(year from a.dataoravalid) = pack_sesiune.getan() and
       a.validat = 1 and e.inch_validare = 1) or
       (extract(month from b.dataact) = pack_sesiune.getluna() and
       extract(year from b.dataact) = pack_sesiune.getan() and
       e.inch_validare = 0 and b.facturat = 1));

-- --- VIEW: AUTO_NORMARE_COMENZI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_NORMARE_COMENZI" ("ID_ORDL", "ID_LUCRARE", "ID_TIP", "DATAI", "ID_INSPECTOR", "ID_ASIGURATOR", "NR_DOSAR", "PROC_TVAV", "VALIDAT", "DATAORAVALID", "NRORD", "ID_MASINICLIENT", "FACTURAT", "DATAFACT", "NRFACT", "NRINMAT", "SERIES", "NUME", "TIP_COMANDA", "INCH_VALIDARE", "INCHIS_FORTAT", "DATAORAINCHIS", "ID_PART_REF", "PART_REF", "KMINT", "ORE_FUNCTIONARE", "CILINDREE", "PUTERECP", "PUTEREKW") AS 
  select a.id_ordl,
       a.id_lucrare,
       a.id_tip,
       a.datai,
       a.id_inspector,
       a.id_asigurator,
       a.nr_dosar,
       a.proc_tvav,
       nvl(a.validat, 0) as validat,
       a.dataoravalid,
       a.nrord,
       a.id_masiniclient,
       nvl(b.facturat, 0) as facturat,
       b.dataact as datafact,
       b.nract as nrfact,
       d.nrinmat,
       d.series,
       e.denumire as nume,
       i.denumire as tip_comanda,
       i.inch_validare,
       a.inchis_fortat,
       a.dataorainchis,
       a.id_part_ref,
       j.denumire as part_ref,
       a.kmint,
       a.ore_functionare,
       d.cilindree,
       d.puterecp,
       d.puterekw
  from auto_comenzi_validate a
  left join auto_vordl_facturi b
    on a.id_lucrare = b.id_lucrare
  left join dev_masiniclienti d
    on a.id_masiniclient = d.id_masiniclient
  left join nom_parteneri e
    on d.id_partener = e.id_part
  left join dev_tip_deviz i
    on a.id_tip = i.id_tip
  left join nom_parteneri j
    on a.id_part_ref = j.id_part;

-- --- VIEW: AUTO_ORDL_FACTURARE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_ORDL_FACTURARE" ("ID_ORDL", "ID_LUCRARE", "DATAI", "ID_MASINICLIENT", "NR_DOSAR", "ID_INSPECTOR", "ID_ASIGURATOR", "PROC_TVAV", "NRORD", "ID_PARTENER", "NRINMAT", "NUME", "MASINA", "MARCA", "ASIGURATOR", "INSPECTOR") AS 
  select a.id_ordl,
       a.id_lucrare,
       a.datai,
       a.id_masiniclient,
       a.nr_dosar,
       a.id_inspector,
       a.id_asigurator,
       a.proc_tvav,
       b.nrord,
       c.id_partener,
       c.nrinmat,
       d.nume,
       e.masina,
       f.marca,
       g1.denumire as asigurator,
       h.inspector
  from dev_ordl a
  left join nom_lucrari b
    on a.id_lucrare = b.id_lucrare
  left join dev_masiniclienti c
    on a.id_masiniclient = c.id_masiniclient
  left join nom_parteneri d
    on c.id_partener = d.id_part
  left join dev_nom_masini e
    on c.id_masina = e.id_masina
  left join dev_nom_marci f
    on e.id_marca = f.id_marca
  left join dev_nom_asiguratori g
    on a.id_asigurator = g.id_asigurator
  left join nom_parteneri g1
    on g.id_part = g1.id_part
  left join dev_nom_inspectori h
    on a.id_inspector = h.id_inspector
 where a.sters = 0;

-- --- VIEW: AUTO_VALIDARE_COMENZI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VALIDARE_COMENZI" ("ID_ORDL", "ID_LUCRARE", "ID_MASINICLIENT", "ID_TIP", "NR_DOSAR", "DATAI", "VALIDAT", "DATAORAVALID", "UTIL_VALID", "NRORD", "PROC_TVAV", "MANOPERA", "MATERIALE", "FACTURAT", "DATAFACT", "NRFACT", "VALCTVA", "ID_PARTENER", "NRINMAT", "SERIES", "CILINDREE", "PUTERECP", "PUTEREKW", "NUME", "ID_PART_ASIG", "ASIGURATOR", "INSPECTOR", "TIP_COMANDA", "INCH_VALIDARE", "KMINT", "ORE_FUNCTIONARE", "INCHIS_FORTAT", "DATAORAINCHIS", "UTIL_INCHIS", "ID_PART_REF", "PART_REF") AS 
  select a.id_ordl,
       a.id_lucrare,
       a.id_masiniclient,
       a.id_tip,
       a.nr_dosar,
       a.datai,
       nvl(a.validat, 0) as validat,
       a.dataoravalid,
       a.util_valid,
       a.nrord,
       a.proc_tvav,
       nvl(b.manopera, 0) as manopera,
       nvl(b1.materiale, 0) as materiale,
       nvl(c.facturat, 0) as facturat,
       c.dataact as datafact,
       nvl(c.nract, 0) as nrfact,
       c.valctva,
       d.id_partener,
       d.nrinmat,
       d.series,
       d.cilindree,
       d.puterecp,
       d.puterekw,
       e.denumire as nume,
       g.id_part as id_part_asig,
       g1.denumire as asigurator,
       h.inspector,
       i.denumire as tip_comanda,
       i.inch_validare,
       a.kmint,
       a.ore_functionare,
       nvl(a.inchis_fortat, 0) as inchis_fortat,
       a.dataorainchis,
       a.util_inchis,
       a.id_part_ref,
       j.denumire as part_ref
  from auto_comenzi_validate a
  left join auto_vordl_man b
    on a.id_ordl = b.id_ordl
  left join auto_vordl_mat b1
    on a.id_lucrare = b1.id_lucrare
  left join auto_vordl_facturi c
    on a.id_lucrare = c.id_lucrare
  left join dev_masiniclienti d
    on a.id_masiniclient = d.id_masiniclient
  left join nom_parteneri e
    on d.id_partener = e.id_part
  left join dev_nom_asiguratori g
    on a.id_asigurator = g.id_asigurator
  left join nom_parteneri g1
    on g.id_part = g1.id_part
  left join dev_nom_inspectori h
    on a.id_inspector = h.id_inspector
  left join dev_tip_deviz i
    on a.id_tip = i.id_tip
  left join nom_parteneri j
    on a.id_part_ref = j.id_part
 order by a.datai, a.nrord;

-- --- VIEW: AUTO_VANSAMBLE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VANSAMBLE" ("ID_ANSAMBLU", "DENUMIRE", "INACTIV") AS 
  select a.id_ansamblu, a.denumire, a.inactiv
  from dev_nom_ansamble a
 where a.sters = 0;

-- --- VIEW: AUTO_VASIGURATORI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VASIGURATORI" ("ID_ASIGURATOR", "ID_PART", "ASIGURATOR", "INACTIV", "BLOCAT") AS 
  select a.id_asigurator,
       a.id_part,
       b.denumire as asigurator,
       decode(b.inactiv, 0, a.inactiv, b.inactiv) as inactiv,
       b.inactiv as blocat
  from dev_nom_asiguratori a
  left join nom_parteneri b
    on a.id_part = b.id_part
 where a.sters = 0;

-- --- VIEW: AUTO_VCLIENTIMASINI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VCLIENTIMASINI" ("ID_PART", "DENUMIRE", "NUME", "PRENUME", "COD_FISCAL", "REG_COMERT", "ID_LOC_INREG", "ID_CATEGORIE_ENTITATE", "LOCALITATE_INREG", "PREFIX", "SUFIX", "TIP_PERSOANA", "BANCA", "CONT_BANCA", "MOTIV_INACTIV", "CLIENT_INACTIV", "ELIBERATDE", "DATAELIBERAT", "ID_ADRESA", "ADRESA", "TELEFON", "TELEFON2", "ID_LOC", "LOCALITATE", "JUDET", "ID_JUDET", "SECTOR", "APART", "ETAJ", "SCARA", "BLOC", "STRADA", "NUMAR", "CODPOSTAL", "CATEGORIE_ENTITATE", "ID_MASINICLIENT", "ID_TIPMOTOR", "ID_FURNIZOR", "ID_MASINA", "ID_PARTENER", "NRINMAT", "SERIES", "SERIEM", "CULOARE", "KMINT", "DATAACHI", "NRACHI", "SERIEF", "SERIECV", "ANFABRICATIE", "MASINA_INACTIV", "CILINDREE", "PUTERECP", "PUTEREKW", "ORE_FUNCTIONARE", "TIP_MOTOR", "ID_MARCA", "FURNIZOR", "MARCA", "MASINA") AS 
  SELECT
    b.id_part,
    b.denumire,
    b.nume,
    b.prenume,
    b.cod_fiscal,
    b.reg_comert,
    b.id_loc_inreg,
    b.id_categorie_entitate,
    b.localitate_inreg,
    b.prefix,
    b.sufix,
    b.tip_persoana,
    b.banca,
    b.cont_banca,
    b.motiv_inactiv,
    b.inactiv AS client_inactiv,
    b.eliberatde,
    b.dataeliberat,
    b.id_adresa,
    b.adresa,
    b.telefon,
    b.telefon2,
    b.id_loc,
    b.localitate,
    b.judet,
    b.id_judet,
    b.sector,
    b.apart,
    b.etaj,
    b.scara,
    b.bloc,
    b.strada,
    b.numar,
    b.codpostal,
    b.categorie_entitate,
    mc.id_masiniclient,
    mc.id_tipmotor,
    mc.id_furnizor,
    mc.id_masina,
    mc.id_partener,
    mc.nrinmat,
    mc.series,
    mc.seriem,
    mc.culoare,
    mc.kmint,
    mc.dataachi,
    mc.nrachi,
    mc.serief,
    mc.seriecv,
    mc.anfabricatie,
    mc.inactiv AS masina_inactiv,
    mc.cilindree,
    mc.puterecp,
    mc.puterekw,
    mc.ore_functionare,
    tm.denumire AS tip_motor,
    mm.id_marca,
    fm.denumire AS furnizor,
    mm.marca,
    m.masina
FROM vnom_parteneri b JOIN dev_masiniclienti mc ON b.id_part = mc.id_partener AND mc.sters = 0
LEFT JOIN dev_tipuri_motoare tm ON mc.id_tipmotor = tm.id_tipmotor
LEFT JOIN dev_nom_furnizorimasini fm ON mc.id_furnizor = fm.id_furnizor
LEFT JOIN dev_nom_masini m ON mc.id_masina = m.id_masina
LEFT JOIN dev_nom_marci mm ON m.id_marca = mm.id_marca
;

-- --- VIEW: AUTO_VESTIMARI_REP ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VESTIMARI_REP" ("ID_DEV_ESTIMARE_REP", "ID_LUCRARE", "NRORD", "ID_NORME", "ID_ARTICOL", "PRET_CU_TVA", "DENUMIRE", "COD", "UM", "CANTITATE", "PRETFTVA", "PRETCTVA", "COTA_TVA", "VALFTVA", "VALTVA", "VALOARE") AS 
  select a.id_dev_estimare_rep,
       a.id_lucrare,
       b.nrord,
       a.id_norme,
       a.id_articol,
       A.PRET_CU_TVA,
       nvl2(a.id_norme, c.denop, d.denumire) as denumire,
       nvl2(a.id_norme, c.codop, d.codmat) as cod,
       nvl2(a.id_norme, 'ORA', d.um) as um,
       a.cantitate,
       pack_sesiune.calculeaza_pret_fara_tva(a.pret,
                                             1,
                                             Null,
                                             (a.cota_tva + 100) / 100,
                                             a.pret_cu_tva,
                                             2) as pretftva,
       pack_sesiune.calculeaza_pret_cu_tva(a.pret,
                                           1,
                                           Null,
                                           (a.cota_tva + 100) / 100,
                                           a.pret_cu_tva,
                                           2) AS pretctva,
       a.cota_tva,
       pack_sesiune.calculeaza_total_fara_tva(a.pret,
                                              0,
                                              1,
                                              0,
                                              1,
                                              a.cantitate,
                                              a.pret_cu_tva,
                                              (a.cota_tva + 100) / 100,
                                              null,
                                              null) as valftva,
       pack_sesiune.calculeaza_total_tva(a.pret,
                                         0,
                                         1,
                                         0,
                                         1,
                                         a.cantitate,
                                         a.pret_cu_tva,
                                         (a.cota_tva + 100) / 100,
                                         null,
                                         null) as valtva,
       pack_sesiune.calculeaza_total_cu_tva(a.pret,
                                            0,
                                            1,
                                            0,
                                            1,
                                            a.cantitate,
                                            a.pret_cu_tva,
                                            (a.cota_tva + 100) / 100,
                                            null,
                                            null) as valoare
  from dev_estimari_rep a
  left join nom_lucrari b
    on a.id_lucrare = b.id_lucrare
  left join auto_vnorme c
    on a.id_norme = c.id_norme
  left join nom_articole d
    on a.id_articol = d.ID_ARTICOL
  left join syn_utilizatori e
    on a.id_util = e.id_util
 where a.sters = 0;

-- --- VIEW: AUTO_VFURNIZORI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VFURNIZORI" ("ID_FURNIZOR", "DENUMIRE", "INACTIV") AS 
  select f.id_furnizor, f.denumire, f.inactiv
  from dev_nom_furnizorimasini f
 where f.sters = 0;

-- --- VIEW: AUTO_VINSPECTORI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VINSPECTORI" ("ID_INSPECTOR", "INSPECTOR", "ID_ASIGURATOR", "INACTIV") AS 
  select i.id_inspector, i.inspector, i.id_asigurator, i.inactiv
  from dev_nom_inspectori i
 where i.sters = 0;

-- --- VIEW: AUTO_VMARCI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VMARCI" ("ID_MARCA", "MARCA", "INACTIV") AS 
  select m.id_marca, m.marca, m.inactiv
  from dev_nom_marci m
 where m.sters = 0;

-- --- VIEW: AUTO_VMASINI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VMASINI" ("ID_MASINA", "ID_MARCA", "MASINA", "SCTIP", "CLASA", "INACTIV", "MARCA") AS 
  select m.id_masina,
       m.id_marca,
       m.masina,
       m.sctip,
       m.clasa,
       m.inactiv,
       s.marca
  from dev_nom_masini m
  left join dev_nom_marci s
    on m.id_marca = s.id_marca
 where m.sters = 0;

-- --- VIEW: AUTO_VMASINICLIENTI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VMASINICLIENTI" ("ID_MASINICLIENT", "ID_TIPMOTOR", "ID_FURNIZOR", "ID_MASINA", "ID_PARTENER", "NRINMAT", "SERIES", "SERIEM", "CULOARE", "KMINT", "DATAACHI", "NRACHI", "SERIEF", "SERIECV", "ANFABRICATIE", "INACTIV", "TIP_MOTOR", "ID_MARCA", "FURNIZOR", "MARCA", "MASINA", "PARTENER", "CILINDREE", "PUTERECP", "PUTEREKW", "ORE_FUNCTIONARE") AS 
  select mc.id_masiniclient,
       mc.id_tipmotor,
       mc.id_furnizor,
       mc.id_masina,
       mc.id_partener,
       mc.nrinmat,
       mc.series,
       mc.seriem,
       mc.culoare,
       mc.kmint,
       mc.dataachi,
       mc.nrachi,
       mc.serief,
       mc.seriecv,
       mc.anfabricatie,
       mc.inactiv,
       tm.denumire as tip_motor,
       m.id_marca,
       fm.denumire as furnizor,
       mm.marca,
       m.masina,
       p.denumire as partener,
       mc.cilindree,
       mc.puterecp,
       mc.puterekw,
       mc.ore_functionare
  from dev_masiniclienti mc
  left join dev_tipuri_motoare tm
    on mc.id_tipmotor = tm.id_tipmotor
  left join dev_nom_furnizorimasini fm
    on mc.id_furnizor = fm.id_furnizor
  left join dev_nom_masini m
    on mc.id_masina = m.id_masina
  left join dev_nom_marci mm
    on m.id_marca = mm.id_marca
  left join nom_parteneri p
    on mc.id_partener = p.id_part
 where mc.sters = 0;

-- --- VIEW: AUTO_VMASINICLIENTI_SIMPLU ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VMASINICLIENTI_SIMPLU" ("ID_MASINICLIENT", "NRINMAT", "SERIES", "SERIEM", "CULOARE", "KMINT", "MARCA", "MASINA", "PARTENER", "COD_FISCAL", "ADRESA") AS 
  select mc.id_masiniclient,
       mc.nrinmat,
       mc.series,
       mc.seriem,
       mc.culoare,
       mc.kmint,
       mm.marca,
       m.masina,
       p.denumire as partener,
       p.cod_fiscal,
       p.adresa
  from dev_masiniclienti mc
  left join dev_nom_masini m
    on mc.id_masina = m.id_masina
  left join dev_nom_marci mm
    on m.id_marca = mm.id_marca
  left join vnom_parteneri p
    on mc.id_partener = p.id_part
 where mc.sters = 0
   and p.inactiv = 0;

-- --- VIEW: AUTO_VMECANICI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VMECANICI" ("ID_MECANIC", "ID_SECTIE", "INACTIV", "SECTIE", "MARCA", "NUME", "PRENUME", "ID_PART") AS 
  select m.id_mecanic,
       m.id_sectie,
       m.inactiv,
       s.sectie,
       p.marca,
       a.nume,
       a.prenume,
       a.id_part
  from dev_mecanici m
  left join nom_sectii s
    on m.id_sectie = s.id_sectie
  left join sal_personal p
    on m.id_part = p.id_part
   and p.sters = 0
  left join nom_parteneri a
    on m.id_part = a.id_part
 where m.sters = 0;

-- --- VIEW: AUTO_VNOM_MASINI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VNOM_MASINI" ("ID_MASINA", "ID_MARCA", "MASINA", "SCTIP", "CLASA", "INACTIV") AS 
  select m.id_masina, m.id_marca, m.masina, m.sctip, m.clasa, m.inactiv
  from dev_nom_masini m
 where m.sters = 0;

-- --- VIEW: AUTO_VNOM_SALARIATI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VNOM_SALARIATI" ("ID_SALARIAT", "MARCA", "INACTIV", "NUME", "PRENUME", "ID_PART") AS 
  select id_salariat, marca, inactiv, nume, prenume, id_part
  from vnom_parteneri_sal;

-- --- VIEW: AUTO_VNORME ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VNORME" ("ID_NORME", "ID_ANSAMBLU", "ID_MASINA", "DENOP", "CODOP", "TIMPN", "INACTIV", "ANSAMBLU", "MASINA", "MARCA") AS 
  select n.id_norme,
       n.id_ansamblu,
       n.id_masina,
       n.denop,
       n.codop,
       n.timpn,
       n.inactiv,
       a.denumire as ansamblu,
       m.masina,
       mar.marca
  from dev_nom_norme n
  left join dev_nom_ansamble a
    on n.id_ansamblu = a.id_ansamblu
  left join dev_nom_masini m
    on n.id_masina = m.id_masina
  left join dev_nom_marci mar
    on m.id_marca = mar.id_marca
 where n.sters = 0;

-- --- VIEW: AUTO_VOPER ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VOPER" ("TIMPN", "ID_ORDL", "ID_OPER", "DATAORA", "ID_SECTIE", "DATAI", "PRET", "VALIDAT", "NOU", "DENOP", "TIMP_NOM", "CODOP", "ANSAMBLU", "MASINA", "SECTIE", "NSECTIE", "UTIL") AS 
  select op.timpn,
       op.id_ordl,
       op.id_oper,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              extract(year from op.dataora) * 12 +
              extract(month from op.dataora) then
          op.dataora
         else
          null
       end) as dataora,
       op.id_sectie,
       op.datai,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() <
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          op.pret
         else
          (case op.nou
            when 0 then
             round(op.pret / 10000, 2)
            else
             op.pret
          end)
       end) as pret,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              extract(year from op.dataora) * 12 +
              extract(month from op.dataora) then
          op.validat
         else
          0
       end) as validat,
       op.nou,
       n.denop,
       n.timpn as timp_nom,
       n.codop,
       a.denumire as ansamblu,
       m.masina,
       s.sectie,
       s.nsectie,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              extract(year from op.dataora) * 12 +
              extract(month from op.dataora) then
          ut.utilizator
         else
          null
       end) as util
  from dev_oper op
  left join dev_nom_norme n
    on op.id_norme = n.id_norme
  left join dev_nom_ansamble a
    on n.id_ansamblu = a.id_ansamblu
  left join dev_nom_masini m
    on n.id_masina = m.id_masina
  left join nom_sectii s
    on op.id_sectie = s.id_sectie
  left join syn_utilizatori ut
    on op.id_util = ut.id_util
 where op.sters = 0;

-- --- VIEW: AUTO_VOPER_DETALII_M ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VOPER_DETALII_M" ("ID_OPERMECANIC", "ID_OPER", "ORE", "ID_MECANIC", "NUME", "PRENUME") AS 
  select a.id_opermecanic, a.id_oper, a.ore, a.id_mecanic, c.nume, c.prenume
  from dev_oper_mecanici a
  left join dev_mecanici b
    on a.id_mecanic = b.id_mecanic
  left join nom_parteneri c
    on b.id_part = c.id_part
 where a.sters = 0;

-- --- VIEW: AUTO_VOPER_MECANICI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VOPER_MECANICI" ("ID_OPERMECANIC", "ID_OPER", "ORE", "INACTIV", "ID_MECANIC", "NUME", "PRENUME", "MARCA", "SECTIE") AS 
  select a.id_opermecanic,
       a.id_oper,
       a.ore,
       a.inactiv,
       a.id_mecanic,
       e.nume,
       e.prenume,
       c.marca,
       d.sectie
  from dev_oper_mecanici a
  left join dev_mecanici b
    on a.id_mecanic = b.id_mecanic
  left join sal_personal c
    on b.id_part = c.id_part
   and c.sters = 0
  left join nom_sectii d
    on b.id_sectie = d.id_sectie
  left join nom_parteneri e
    on b.id_part = e.id_part
 where a.sters = 0;

-- --- VIEW: AUTO_VOPER_PRETURI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VOPER_PRETURI" ("TIMPN", "ID_ORDL", "ID_OPER", "DATAORA", "DATAI", "PRET", "VALIDAT", "DENOP") AS 
  select op.timpn,
       op.id_ordl,
       op.id_oper,
       op.dataora,
       op.datai,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() <
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          op.pret
         else
          (case op.nou
            when 0 then
             round(op.pret / 10000, 2)
            else
             op.pret
          end)
       end) as pret,
       op.validat,
       n.denop
  from dev_oper op
  left join dev_nom_norme n
    on op.id_norme = n.id_norme
 where op.sters = 0;

-- --- VIEW: AUTO_VOPER_SIMPLU ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VOPER_SIMPLU" ("TIMPN", "ID_ORDL", "ID_OPER", "DATAORA", "DATAI", "ID_SECTIE", "VALIDAT", "ID_NORME", "SECTIE", "NSECTIE") AS 
  select op.timpn,
       op.id_ordl,
       op.id_oper,
       op.dataora,
       op.datai,
       op.id_sectie,
       op.validat,
       op.id_norme,
       s.sectie,
       s.nsectie
  from dev_oper op
  left join nom_sectii s
    on op.id_sectie = s.id_sectie
 where op.sters = 0;

-- --- VIEW: AUTO_VORDL ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VORDL" ("ID_ORDL", "LUNA", "AN", "ID_INSPECTOR", "ID_LUCRARE", "TERMEN", "DATAI", "ORAI", "DATAE", "ORAE", "VALIDAT", "ID_UTIL_AD", "ID_UTIL_VALID", "DATAORAAD", "DATAORAVALID", "ID_MASINICLIENT", "ID_ASIGURATOR", "ID_TIP", "NR_DOSAR", "INCHIS_FORTAT", "KMINT", "ORE_FUNCTIONARE", "SOLICITARI_CLIENT", "OBSERVATII", "DEFECTIUNI", "NUME", "COD_FISCAL", "ADRESA", "TELEFON", "BANCA", "CONT_BANCA", "REG_COMERT", "TIP_PERSOANA", "NRORD", "NRINMAT", "SERIES", "SERIEM", "NRACHI", "ANFABRICATIE", "ASIGURATOR", "MARCA", "MASINA", "INSPECTOR", "UTIL_VALID", "TIP_COMANDA", "INCH_VALIDARE", "FURNIZOR") AS 
  select o.id_ordl,
       o.luna,
       o.an,
       o.id_inspector,
       o.id_lucrare,
       o.termen,
       o.datai,
       o.orai,
       o.datae,
       o.orae,
       o.validat,
       o.id_util_ad,
       o.id_util_valid,
       o.dataoraad,
       o.dataoravalid,
       o.id_masiniclient,
       o.id_asigurator,
       o.id_tip,
       o.nr_dosar,
       o.inchis_fortat,
       o.kmint,
       o.ore_functionare,
       o.solicitari_client,
       o.observatii,
       o.defectiuni,
       p.denumire          as nume,
       p.cod_fiscal,
       p.adresa,
       p.telefon,
       p.banca,
       p.cont_banca,
       p.reg_comert,
       p.tip_persoana,
       l.nrord,
       m.nrinmat,
       m.series,
       m.seriem,
       m.nrachi,
       m.anfabricatie,
       asig1.denumire      as asigurator,
       mar.marca,
       mas.masina,
       ins.inspector,
       ut.utilizator       as util_valid,
       k.denumire          as tip_comanda,
       k.inch_validare,
       h.denumire          as furnizor
  from dev_ordl o
  left join dev_masiniclienti m
    on o.id_masiniclient = m.id_masiniclient
  left join vnom_parteneri p
    on m.id_partener = p.id_part
  left join dev_nom_furnizorimasini h
    on m.id_furnizor = h.id_furnizor
  left join nom_lucrari l
    on o.id_lucrare = l.id_lucrare
  left join dev_nom_asiguratori asig
    on o.id_asigurator = asig.id_asigurator
  left join nom_parteneri asig1
    on asig.id_part = asig1.id_part
  left join dev_nom_masini mas
    on m.id_masina = mas.id_masina
  left join dev_nom_marci mar
    on mas.id_marca = mar.id_marca
  left join dev_nom_inspectori ins
    on o.id_inspector = ins.id_inspector
  left join dev_tip_deviz k
    on o.id_tip = k.id_tip
  left join syn_vutilizatori ut
    on o.id_util_valid = ut.id_util
 where o.sters = 0;

-- --- VIEW: AUTO_VORDL_FACTURATE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VORDL_FACTURATE" ("ID_LUCRARE", "DATAACT", "NRACT", "FACTURAT") AS 
  select distinct b.id_lucrare,
                max(b.dataact) keep(dense_rank first order by b.id_set desc) over(partition by b.id_lucrare) as dataact,
                max(b.nract) keep(dense_rank first order by b.id_set desc, b.dataact desc) over(partition by b.id_lucrare) as nract,
                max(case
                      when b.id_set in (31003,
                                        31004,
                                        31005,
                                        31006,
                                        31007,
                                        31011,
                                        31012,
                                        31013) then
                       1
                      else
                       0
                    end) over(partition by b.id_lucrare) as facturat
  from mv_ordl_sume_act b
 where extract(month from b.dataact) + extract(year from b.dataact) * 12 <=
       pack_sesiune.getluna() + pack_sesiune.getAn() * 12;

-- --- VIEW: AUTO_VORDL_FACTURI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VORDL_FACTURI" ("ID_LUCRARE", "VALFACTMANOPERA", "VALFACTMATERIALE", "VALCTVA", "DATAACT", "NRACT", "FACTURAT") AS 
  select a.id_lucrare,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          NVL(b.manopera_ron, -1.000)
         else
          NVL(b.manopera_rol, -1.000)
       end) as valfactmanopera,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          NVL(b.materiale_ron, -1.000)
         else
          NVL(b.materiale_rol, -1.000)
       end) as valfactmateriale,
       (case
         when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
              pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
          NVL(b.manopera_ron + b.materiale_ron + b.tva_ron, -1.000)
         else
          NVL(b.manopera_rol + b.materiale_rol + b.tva_rol, -1.000)
       end) as valctva,
       a.dataact,
       a.nract,
       a.facturat
  from auto_vordl_facturate a
  left join mv_ordl_sume_act b
    on a.nract = b.nract
   and a.id_lucrare = b.id_lucrare
   and a.dataact = b.dataact
;

-- --- VIEW: AUTO_VORDL_MAN ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VORDL_MAN" ("ID_ORDL", "MANOPERA") AS 
  select a.id_ordl,
       sum((case
             when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
                  pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
              a.manopera_ron
             else
              a.manopera_rol
           end)) as manopera
  from mv_ordl_man a
 where a.luni <= pack_sesiune.getluna() + pack_sesiune.getan() * 12
 group by a.id_ordl;

-- --- VIEW: AUTO_VORDL_MAT ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VORDL_MAT" ("ID_LUCRARE", "MATERIALE") AS 
  select a.id_lucrare,
       sum((case
             when pack_sesiune.getAn() * 12 + pack_sesiune.getLuna() >=
                  pack_sesiune.GET_ANRON() * 12 + pack_sesiune.GET_LUNARON() then
              a.materiale_ron
             else
              a.materiale_rol
           end)) as materiale
  from mv_ordl_mat a
 where a.luna + a.an * 12 <= pack_sesiune.getluna() + pack_sesiune.getan() * 12
 group by a.id_lucrare;

-- --- VIEW: AUTO_VPRETURI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."AUTO_VPRETURI" ("ID_PRET", "ID_MARCA", "ID_ASIGURATOR", "PRET", "PRET_VAL", "ID_VALUTA", "CURS", "STERS", "INACTIV", "MARCA", "ASIGURATOR", "NUME_VAL") AS 
  select p."ID_PRET",p."ID_MARCA",p."ID_ASIGURATOR",p."PRET",p."PRET_VAL",p."ID_VALUTA",p."CURS",p."STERS",p."INACTIV", m.marca, a1.denumire as asigurator, v.nume_val
  from dev_nom_preturi p
  left join dev_nom_marci m
    on p.id_marca = m.id_marca
  left join dev_nom_asiguratori a
    on p.id_asigurator = a.id_asigurator
  left join nom_parteneri a1
    on a.id_part = a1.id_part
  left join nom_valute v
    on p.id_valuta = v.id_valuta
 where p.sters = 0;

-- --- VIEW: VCOMENZI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VCOMENZI" ("ID_COMANDA", "ID_LUCRARE", "NR_COMANDA", "DATA_COMANDA", "ID_PART", "DATA_LIVRARE", "NR_LIVRARE", "ID_AGENT", "ID_DELEGAT", "ID_MASINA", "INTERNA", "TIP_COMANDA", "NUME", "ID_UTIL", "ID_GESTIUNE", "DATAORA", "DATA_LIVRAT", "PROC_DISCOUNT", "NRORD", "NUME_AGENT", "NUME_DELEGAT", "SERIE_BI", "NUMAR_BI", "ELIBERATDE", "NRINMAT", "UTILIZATOR", "FACTURAT", "INCHISA", "ID_SECTIE", "ID_SECTIE2", "ID_FACTURARE", "ID_LIVRARE", "COMANDA_EXTERNA", "ID_CODCLIENT", "ID_SUCURSALA", "ID_CTR", "NUMAR_CONTRACT", "ID_UTIL_UM", "DATAORA_UM") AS 
  SELECT a.id_comanda,
       a.id_lucrare,
       a.nr_comanda,
       a.data_comanda,
       a.id_part,
       a.data_livrare,
       a.nr_livrare,
       a.id_agent,
       a.id_delegat,
       a.id_masina,
       a.interna,
       (CASE a.interna
         WHEN 1 THEN 'INTERNA'
         WHEN 2 THEN 'EXTERNA - SIMPLA'
         WHEN 3 THEN 'GESTIUNE'
         WHEN 4 THEN 'SECTIE'
         WHEN 5 THEN 'EXTERNA - PE BAZA DE CONTRACT'
       END) AS tip_comanda,
       (CASE a.interna
         WHEN 1 THEN 'INTERNA'
         WHEN 2 THEN c.denumire
         WHEN 3 THEN j.nume_gestiune
         WHEN 4 THEN l.sectie
         WHEN 5 THEN c.denumire
       END) AS nume,
       a.id_util,
       a.id_gestiune,
       a.dataora,
       a.data_livrat,
       a.proc_discount,
       b.nrord,
       d.denumire AS nume_agent,
       e.denumire AS nume_delegat,
       SUBSTR(TRIM(e.reg_comert), 1, 2) AS serie_bi,
       SUBSTR(TRIM(e.reg_comert), 3) AS numar_bi,
       k.localitate AS eliberatde,
       f.nrinmat,
       g.utilizator,
       (CASE
         WHEN NVL(ce.cant_cmd, -1) - NVL(vf.cant_vanz, 0) = 0 THEN 1
         ELSE 0
       END) AS facturat,
       (CASE
         WHEN i.termen_executie <=
              sysdate + (pack_comenzi.citeste_ore_inchidere(a.id_sectie) / 24) THEN 1
         ELSE 0
       END) AS inchisa,
       a.id_sectie,
       a.id_sectie2,
       a.id_facturare,
       a.id_livrare,
       a.COMANDA_EXTERNA,
       a.id_codclient,
       a.id_sucursala,
       a.id_ctr,
       NVL2(m.numar, m.numar || '/' || TO_CHAR(m.data, 'DD.MM.YYYY'), NULL) AS numar_contract,
       a.id_util_um,
       a.dataora_um
  FROM comenzi a
  LEFT JOIN nom_lucrari b ON a.id_lucrare = b.id_lucrare
  LEFT JOIN nom_parteneri c ON a.id_part = c.id_part
  LEFT JOIN nom_parteneri d ON a.id_agent = d.id_part
  LEFT JOIN nom_parteneri e ON a.id_delegat = e.id_part
  LEFT JOIN nom_masini f ON a.id_masina = f.id_masina
  LEFT JOIN syn_utilizatori g ON a.id_util = g.id_util
  LEFT JOIN lucrari_detalii i ON a.id_lucrare = i.id_lucrare
  LEFT JOIN nom_gestiuni j ON a.id_gestiune = j.id_gestiune
  LEFT JOIN syn_nom_localitati k ON e.id_loc = k.id_loc
  LEFT JOIN nom_sectii l ON a.id_sectie2 = l.id_sectie
  LEFT JOIN contracte m ON a.id_ctr = m.id_ctr
  LEFT JOIN (SELECT id_comanda,
                    SUM(cantitate) AS cant_cmd
               FROM comenzi_elemente
              WHERE sters = 0
              GROUP BY id_comanda) ce ON ce.id_comanda = a.id_comanda
  LEFT JOIN (SELECT v.id_comanda,
                    SUM(vd.cantitate) AS cant_vanz
               FROM vanzari v
               JOIN vanzari_detalii vd ON vd.id_vanzare = v.id_vanzare
                                      AND vd.sters = 0
              WHERE v.sters = 0
              GROUP BY v.id_comanda) vf ON vf.id_comanda = a.id_comanda
 WHERE a.sters = 0;

-- --- VIEW: VNOM_AGENTI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_AGENTI" ("ID_RESPONSABIL", "NUME_AGENT", "BI", "CNP", "ELIBERATDE", "TELEFON1", "TELEFON2", "INACTIV", "FUNCTIE", "ALES") AS 
  select a.id_part as id_responsabil,
       a.denumire as nume_agent,
       a.reg_comert as bi,
       a.cod_fiscal as cnp,
       a.localitate_inreg as eliberatde,
       a.telefon as telefon1,
       a.telefon2,
       a.inactiv,
       '' as functie,
       0 as ales
  from vnom_parteneri a
  join coresp_tip_part b on a.ID_PART = b.id_part
 where b.id_tip_part = -42;

-- --- VIEW: VNOM_ARTICOLE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_ARTICOLE" ("ID_ARTICOL", "CODBARE", "CODMAT", "DENUMIRE", "DESCRIERE", "UM", "UM2", "UM_ISO", "COD_UM_ISO", "CONT", "ACONT", "DEP", "CANT_BAX", "ID_MOD", "INACTIV", "ID_SUBGRUPA", "SUBGRUPA", "ID_GRUPA", "GRUPA", "DNF", "IN_CRM", "IN_STOC", "CODMATF", "CONDITII_PASTRARE", "ID_PART", "PRETACHCTVA", "TAXA_RECONDITIONARE", "PARTENER", "ID_ARTICOL_GENERAL", "ARTICOL_GENERAL", "LISTARE_CODBARE", "TIP", "TIMPN", "COMPUS", "CODNC8", "ID_TARA_ORIGINE", "COD_TARA_ORIGINE", "TARA_ORIGINE", "GREUTATE", "CODCPV") AS 
  select A.ID_ARTICOL,
       A.CODBARE,
       A.CODMAT,
       A.DENUMIRE,
       A.DESCRIERE,
       A.UM,
       A.UM2,
       u.um_iso,
       u.cod_um_iso,
       A.CONT,
       A.ACONT,
       A.DEP,
       A.CANT_BAX,
       A.ID_MOD,
       A.INACTIV,
       A.ID_SUBGRUPA,
       B.SUBGRUPA,
       B.ID_GRUPA,
       B.GRUPA,
       A.DNF,
       A.IN_CRM,
       a.in_stoc,
       a.codmatf,
       a.conditii_pastrare,
       a.id_part,
       a.pretachctva,
       a.taxa_reconditionare,
       (select denumire from nom_parteneri c where c.id_part = a.id_part) as partener,
       a.id_articol_general,
       c.denumire as articol_general,
       a.listare_codbare,
       a.tip,
       CASE A.COMPUS WHEN 0 THEN a.timpn ELSE   (select sum(decode(connect_by_isleaf, 1, timpn, 0)) as timpn
from
(select ad.id_articolp, ad.id_articol, ac.timpn
            from nom_articole_detalii ad
            join nom_articole ap
              on ad.id_articolp = ap.id_articol
            join nom_articole ac
              on ad.id_articol = ac.id_articol
           where ad.sters = 0)
           start with id_articolp = A.ID_ARTICOL
          connect by prior id_articol = id_articolp) END AS TIMPN,
       a.compus,
       a.codnc8,
       a.id_tara_origine,
       d.prescurtare as cod_tara_origine,
       d.tara as tara_origine,
       a.greutate,
       a.codcpv
  from NOM_ARTICOLE A
  LEFT JOIN VGEST_ART_SBGR B ON A.ID_SUBGRUPA = B.ID_SUBGRUPA
  left join nom_articole c on a.id_articol_general = c.id_articol
  left join syn_nom_tari D ON A.ID_TARA_ORIGINE = D.ID_TARA
  left join vnom_um u on a.um = u.um
 where a.STERS = 0;

-- --- VIEW: VNOM_ARTICOLE_CRM ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_ARTICOLE_CRM" ("ID_ARTICOL", "CODMAT", "DENUMIRE", "CONT", "ACONT", "UM", "COMISION", "INACTIV", "CODBARE", "IN_STOC", "IN_CRM", "CANT_BAX", "UM2", "CODMATF", "CONDITII_PASTRARE", "PRETACHCTVA", "ID_ARTICOL_GENERAL", "ARTICOL_GENERAL", "LISTARE_CODBARE", "TIP", "TIMPN", "COMPUS") AS 
  SELECT A.ID_ARTICOL,
       A.CODMAT,
       A.DENUMIRE,
       A.CONT,
       A.ACONT,
       A.UM,
       0 AS COMISION,
       A.INACTIV,
       A.CODBARE,
       A.IN_STOC,
       A.IN_CRM,
       A.CANT_BAX,
       A.UM2,
       a.codmatf,
       a.conditii_pastrare,
       a.pretachctva,
       a.id_articol_general,
       b.denumire as articol_general,
       a.listare_codbare,
       a.tip,
       CASE A.COMPUS
         WHEN 0 THEN
          a.timpn
         ELSE
          (select sum(decode(connect_by_isleaf, 1, timpn, 0)) as timpn
             from (select ad.id_articolp, ad.id_articol, ac.timpn
                     from nom_articole_detalii ad
                     join nom_articole ap
                       on ad.id_articolp = ap.id_articol
                     join nom_articole ac
                       on ad.id_articol = ac.id_articol
                    where ad.sters = 0)
            start with id_articolp = A.ID_ARTICOL
           connect by prior id_articol = id_articolp)
       END AS TIMPN,
       a.compus
  FROM NOM_ARTICOLE A
  left join nom_articole b
    on a.id_articol_general = b.id_articol
 WHERE A.STERS = 0
   AND A.INACTIV = 0
   AND A.IN_CRM = 1;

-- --- VIEW: VNOM_ARTICOLE_DEP_NIR ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_ARTICOLE_DEP_NIR" ("ID_ARTICOL", "CODBARE", "CODMAT", "DENUMIRE", "UM", "UM2", "CONT", "ACONT", "DEP", "CANT_BAX", "ID_MOD", "INACTIV", "ID_SUBGRUPA", "SUBGRUPA", "ID_GRUPA", "GRUPA", "DNF", "IN_CRM", "IN_STOC", "CODMATF", "CONDITII_PASTRARE", "ID_PART", "ID_ARTICOL_GENERAL", "PARTENER", "CANTITATE", "NUMARACT", "DATAACT", "ND_ID", "ARTICOL_GENERAL", "LISTARE_CODBARE", "TIP", "TIMPN", "COMPUS") AS 
  select A.ID_ARTICOL,
       A.CODBARE,
       A.CODMAT,
       A.DENUMIRE,
       A.UM,
       A.UM2,
       A.CONT,
       A.ACONT,
       A.DEP,
       A.CANT_BAX,
       A.ID_MOD,
       A.INACTIV,
       A.ID_SUBGRUPA,
       B.SUBGRUPA,
       B.ID_GRUPA,
       B.GRUPA,
       A.DNF,
       A.IN_CRM,
       A.in_stoc,
       A.codmatf,
       A.conditii_pastrare,
       A.id_part,
       a.id_articol_general,
       (select denumire from nom_parteneri C where C.id_part = A.id_part) as partener,
       ND.Cantitate,
       N.NUMARACT,
       N.DATAACT,
       ND.ID AS ND_ID,
       c.denumire as articol_general,
       a.listare_codbare,
       a.tip,
       CASE A.COMPUS
         WHEN 0 THEN
          a.timpn
         ELSE
          (select sum(decode(connect_by_isleaf, 1, timpn, 0)) as timpn
             from (select ad.id_articolp, ad.id_articol, ac.timpn
                     from nom_articole_detalii ad
                     join nom_articole ap
                       on ad.id_articolp = ap.id_articol
                     join nom_articole ac
                       on ad.id_articol = ac.id_articol
                    where ad.sters = 0)
            start with id_articolp = A.ID_ARTICOL
           connect by prior id_articol = id_articolp)
       END AS TIMPN,
       a.compus
  from NOM_ARTICOLE A
  LEFT JOIN VGEST_ART_SBGR B
    ON A.ID_SUBGRUPA = B.ID_SUBGRUPA
  left join nom_articole c
    on a.id_articol_general = c.id_articol
  JOIN DEP_NIR_DETALII ND
    ON A.ID_ARTICOL = ND.ID_ARTICOL
  JOIN DEP_NIR N
    ON ND.ID_NIR = N.ID
 WHERE A.STERS = 0
;

-- --- VIEW: VNOM_ARTICOLE_DETALII ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_ARTICOLE_DETALII" ("ID", "ID_ARTICOLP", "ID_ARTICOL", "DENUMIREP", "CODMATP", "DENUMIRE", "CODMAT", "TIP", "TIMPN", "COMPUS") AS 
  select A.ID,
       A.ID_ARTICOLP,
       A.ID_ARTICOL,
       P.DENUMIRE AS DENUMIREP,
       P.CODMAT AS CODMATP,
       D.DENUMIRE,
       D.CODMAT,
       D.TIP,
       CASE D.COMPUS
         WHEN 0 THEN
          D.timpn
         ELSE
          (select sum(decode(connect_by_isleaf, 1, timpn, 0)) as timpn
             from (select ad.id_articolp, ad.id_articol, ac.timpn
                     from nom_articole_detalii ad
                     join nom_articole ap
                       on ad.id_articolp = ap.id_articol
                     join nom_articole ac
                       on ad.id_articol = ac.id_articol
                    where ad.sters = 0)
            start with id_articolp = D.ID_ARTICOL
           connect by prior id_articol = id_articolp)
       END AS TIMPN,
       D.COMPUS
  from NOM_ARTICOLE_DETALII A
  JOIN NOM_ARTICOLE P
    ON A.ID_ARTICOLP = P.ID_ARTICOL
  JOIN NOM_ARTICOLE D
    ON A.ID_ARTICOL = D.ID_ARTICOL
  LEFT JOIN VGEST_ART_SBGR B
    ON D.ID_SUBGRUPA = B.ID_SUBGRUPA
  left join nom_articole c
    on D.id_articol_general = c.id_articol
 where A.STERS = 0
   AND P.STERS = 0
   AND D.STERS = 0
;

-- --- VIEW: VNOM_ARTICOLE_FRUNZE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_ARTICOLE_FRUNZE" ("ID_ARTICOL", "TIMPN", "ID_RADACINA", "ID_ARTICOLP") AS 
  SELECT ID_ARTICOL, TIMPN, ID_RADACINA, ID_ARTICOLP
  FROM (SELECT A.ID_ARTICOL,
               A.TIMPN,
               A.ID_ARTICOLP,
               CONNECT_BY_ISLEAF AS FRUNZA,
               CONNECT_BY_ROOT(A.ID_ARTICOL) as ID_RADACINA
          FROM (SELECT A1.ID_ARTICOL, A1.TIMPN, A2.ID_ARTICOLP
                  FROM NOM_ARTICOLE A1
                  LEFT JOIN NOM_ARTICOLE_DETALII A2 ON A1.ID_ARTICOL =
                                                       A2.ID_ARTICOL
                                                   AND A2.STERS = 0
                 WHERE A1.STERS = 0
                UNION
                SELECT B1.ID_ARTICOL, B1.TIMPN, NULL AS ID_ARTICOLP
                  FROM NOM_ARTICOLE B1
                 WHERE B1.STERS = 0
                   AND B1.COMPUS = 1) A
         START WITH A.ID_ARTICOLP IS NULL
        CONNECT BY PRIOR A.ID_ARTICOL = A.ID_ARTICOLP)
 WHERE FRUNZA = 1
;

-- --- VIEW: VNOM_ARTICOLE_TOATE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_ARTICOLE_TOATE" ("ID_ARTICOL", "CODBARE", "CODMAT", "DENUMIRE", "UM", "UM2", "UM_ISO", "COD_UM_ISO", "CONT", "ACONT", "DEP", "CANT_BAX", "ID_MOD", "INACTIV", "ID_SUBGRUPA", "SUBGRUPA", "ID_GRUPA", "GRUPA", "DNF", "IN_CRM", "IN_STOC", "CODMATF", "CONDITII_PASTRARE", "ID_PART", "PRETACHCTVA", "TAXA_RECONDITIONARE", "PARTENER", "ID_ARTICOL_GENERAL", "INDICATIV", "ARTICOL_GENERAL", "LISTARE_CODBARE", "TIP", "TIMPN", "COMPUS", "CODNC8", "ID_TARA_ORIGINE", "COD_TARA_ORIGINE", "TARA_ORIGINE", "GREUTATE", "CODCPV") AS 
  select A.ID_ARTICOL,
       A.CODBARE,
       A.CODMAT,
       A.DENUMIRE,
       A.UM,
       A.UM2,
       u.um_iso,
       u.cod_um_iso,
       A.CONT,
       A.ACONT,
       A.DEP,
       A.CANT_BAX,
       A.ID_MOD,
       A.INACTIV,
       A.ID_SUBGRUPA,
       B.SUBGRUPA,
       B.ID_GRUPA,
       B.GRUPA,
       A.DNF,
       A.IN_CRM,
       a.in_stoc,
       a.codmatf,
       a.conditii_pastrare,
       a.id_part,
       a.pretachctva,
       a.taxa_reconditionare,
       (select denumire from nom_parteneri c where c.id_part = a.id_part) as partener,
       a.id_articol_general,
       b.indicativ,
       c.denumire as articol_general,
       a.listare_codbare,
       a.tip,
       CASE A.COMPUS
         WHEN 0 THEN
          a.timpn
         ELSE
          (select sum(decode(connect_by_isleaf, 1, timpn, 0)) as timpn
             from (select ad.id_articolp, ad.id_articol, ac.timpn
                     from nom_articole_detalii ad
                     join nom_articole ap
                       on ad.id_articolp = ap.id_articol
                     join nom_articole ac
                       on ad.id_articol = ac.id_articol
                    where ad.sters = 0)
            start with id_articolp = A.ID_ARTICOL
           connect by prior id_articol = id_articolp)
       END AS TIMPN,
       a.compus,
       a.codnc8,
       a.id_tara_origine,
       d.prescurtare as cod_tara_origine,
       d.tara as tara_origine,
       a.greutate,
       a.codcpv
  from NOM_ARTICOLE A
  LEFT JOIN VGEST_ART_SBGR B
    ON A.ID_SUBGRUPA = B.ID_SUBGRUPA
  left join nom_articole c
    on a.id_articol_general = c.id_articol
  left join syn_nom_tari D ON A.ID_TARA_ORIGINE = D.ID_TARA
  left join vnom_um u on a.um = u.um
 WHERE A.STERS = 0;

-- --- VIEW: VNOM_CASA_LEI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_CASA_LEI" ("ID_PART", "NUME") AS 
  select a.id_part, b.denumire as nume
  from coresp_tip_part a
  left join nom_parteneri b on a.id_part = b.id_part
 where a.id_tip_part = 22;

-- --- VIEW: VNOM_CATEGORII_ENTITATI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_CATEGORII_ENTITATI" ("ID_CATEGORIE_ENTITATE", "CATEGORIE_ENTITATE", "INACTIV") AS 
  select a.id_categorie_entitate, a.categorie_entitate, a.inactiv
  from nom_categorii_entitati a
 where a.sters = 0;

-- --- VIEW: VNOM_DELEGATI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_DELEGATI" ("ID_RESPONSABIL", "NUME", "BI", "CNP", "ELIBERATDE", "TELEFON1", "TELEFON2", "INACTIV", "FUNCTIE", "ALES", "ID_PART") AS 
  select a.id_part as id_responsabil,
       a.denumire as nume,
       a.reg_comert as bi,
       a.cod_fiscal as cnp,
       a.localitate_inreg as eliberatde,
       a.telefon as telefon1,
       a.telefon2,
       a.inactiv,
       '' as functie,
       0 as ales,
       0 as id_part
  from vnom_parteneri a
  join coresp_tip_part b on a.ID_PART = b.id_part
 where b.id_tip_part = -44;

-- --- VIEW: VNOM_DELEGATI_PART ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_DELEGATI_PART" ("ID_RESPONSABIL", "NUME", "BI", "CNP", "ELIBERATDE", "TELEFON1", "TELEFON2", "INACTIV", "FUNCTIE", "ALES", "ID_PART") AS 
  select a.id_part as id_responsabil,
       a.denumire as nume,
       a.reg_comert as bi,
       a.cod_fiscal as cnp,
       a.localitate_inreg as eliberatde,
       a.telefon as telefon1,
       a.telefon2,
       a.inactiv,
       '' as functie,
       0 as ales,
       c.id_part
  from vnom_parteneri a
  join coresp_tip_part b on a.ID_PART = b.id_part
  left join coresp_delegati_part c on b.id_part = c.id_delegat
                                  and c.sters = 0
 where b.id_tip_part = -44;

-- --- VIEW: VNOM_FDOC ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_FDOC" ("ID_FDOC", "ID_FDOC2", "FEL_DOCUMENT", "ID_MOD", "INACTIV", "TIP_DOC", "DESCRIERE", "PAYMENTCODE", "METHODCODE", "PAYMENTMETHOD", "PAYMENTNAME") AS 
  select a.id_fdoc,
       a.id_fdoc as id_fdoc2,
       a.fel_document,
       a.id_mod,
       a.inactiv,
       a.tip_doc,
       b.descriere,
       a.paymentcode,
       sp.methodcode,
       sp.methodname as paymentmethod,
       sp.paymentname
  from NOM_FDOC A
  LEFT JOIN NOM_TIP_DOC B
    ON A.TIP_DOC = B.TIP
  left join vsaft_mecanisme_plati sp
    on a.paymentcode = sp.mechanismcode
 where STERS = 0;

-- --- VIEW: VNOM_GESTIUNI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_GESTIUNI" ("ID_GESTIUNE", "NUME_GESTIUNE", "INACTIV", "CONT", "ACONT", "NR_PAG", "CGEST", "ID_SUCURSALA", "DESCRIERE", "NUME_TIP", "SUCURSALA", "ID_RESPONSABIL", "DENUMIRE", "ID_SECTIE", "SECTIE", "ACONT_ADAOS", "ACONT_CHELTUIALA", "ID_LUCRARE", "NRORD", "GESTIONAR", "COMISIE_RECEPTIE1", "COMISIE_RECEPTIE2", "COMISIE_RECEPTIE3") AS 
  select g.ID_GESTIUNE,
       g.NUME_GESTIUNE,
       g.INACTIV,
       g.CONT,
       g.ACONT,
       g.NR_PAG,
       g.CGEST,
       g.id_sucursala,
       g.descriere,
       t.nume_tip,
       a.sucursala,
       g.id_responsabil,
       p.denumire,
       s.id_sectie,
       s.sectie,
       g.acont_adaos,
       g.acont_cheltuiala,
       g.id_lucrare,
       l.nrord,
       g.gestionar,
       g.comisie_receptie1,
       g.comisie_receptie2,
       g.comisie_receptie3
  from NOM_gestiuni g
  left join tipuri_gestiuni t on g.nr_pag = t.id_tipgest
  left join vnom_sucursale a on g.id_sucursala = a.id_sucursala
  left join nom_parteneri p on g.id_responsabil = p.id_part
  left join nom_sectii s on s.id_sectie = g.id_sectie
  left join nom_lucrari l on g.id_lucrare = l.id_lucrare
 where g.STERS = 0;

-- --- VIEW: VNOM_INTRET ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_INTRET" ("ID_PERS", "NUME", "PRENUME", "CODPERS", "ID_DEDUCERE", "ID_HANDICAP", "ID_STAT", "STERS") AS 
  select i.*
  from sal_persintret i
  left join sal_stat s on i.id_stat = s.id_stat
 where s.luna = pack_sesiune.getLuna()
   and s.an = pack_sesiune.getAn();

-- --- VIEW: VNOM_LOCATII ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_LOCATII" ("ID", "DENUMIRE", "STERS", "INACTIV", "ID_UTIL", "DATAORA", "ID_UTILS", "DATAORAS") AS 
  select id, denumire, sters, inactiv, id_util, dataora, id_utils, dataoras
  from nom_locatii
 where sters = 0
;

-- --- VIEW: VNOM_LOCURI_DEPOZITARE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_LOCURI_DEPOZITARE" ("ID_LOC_DEPOZIT", "DENUMIRE", "INACTIV") AS 
  select id_loc_depozit, denumire, inactiv
  from nom_locuri_depozitare
 where sters = 0;

-- --- VIEW: VNOM_LUCRARI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_LUCRARI" ("ID_LUCRARE", "NRORD", "TATA", "STERS", "ID_MOD", "INACTIV", "ID_TATA", "ID_FACT") AS 
  select id_lucrare,
       cast(substr(sys_connect_by_path(nrord, '//'), 3) as varchar2(100)) as nrord,
       cast(substr(sys_connect_by_path(nrord, '//'),
                   3,
                   instr(sys_connect_by_path(nrord, '//'), '//', 1, level) - 3) as
            varchar2(100)) as tata,
       sters,
       id_mod,
       inactiv,
       id_tata,
       id_fact
  from nom_lucrari
 where sters = 0
 start with id_tata is null
connect by prior id_lucrare = id_tata;

-- --- VIEW: VNOM_LUCRARI_COMPLET ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_LUCRARI_COMPLET" ("ID_LUCRARE", "NRORD", "CALE", "ID_TATA", "NIVEL", "TIP", "ID_RADACINA") AS 
  select id_lucrare,
       nrord,
       cast(substr(sys_connect_by_path(nrord, '//'),
                   3) as
            varchar2(100)) as cale,
       id_tata,
       level as nivel,
       connect_by_isleaf as tip,
       connect_by_root(id_lucrare) as id_radacina
  from nom_lucrari
 start with id_tata is null
connect by prior id_lucrare = id_tata and sters = 0;

-- --- VIEW: VNOM_LUCRARI_RADACINI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_LUCRARI_RADACINI" ("ID_LUCRARE", "ID_RADACINA", "NRORD_RADACINA") AS 
  select id_lucrare,
       connect_by_root(id_lucrare) as id_radacina,
       connect_by_root(nrord) as nrord_radacina
  from nom_lucrari
 where sters = 0
 start with id_tata is null
connect by prior id_lucrare = id_tata;

-- --- VIEW: VNOM_MARCI_MASINI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_MARCI_MASINI" ("ID_MARCA_MASINA", "MARCA_MASINA", "INACTIV") AS 
  select a.id_marca_masina, a.marca_masina, a.inactiv
 from nom_marci_masini a
 where a.sters=0;

-- --- VIEW: VNOM_MASINI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_MASINI" ("ID_MASINA", "ID_PART", "ID_FURNIZOR", "ID_MODEL_MASINA", "NRINMAT", "SERIES", "SERIEM", "CULOARE", "KMINT", "DATAACHI", "NRACHI", "SERIEF", "SERIECV", "ANFABRICATIE", "INACTIV", "FURNIZOR", "MODEL_MASINA", "MARCA_MASINA", "ID_MARCA_MASINA", "CLIENT") AS 
  select a.id_masina,
       a.id_part,
       a.id_furnizor,
       a.id_model_masina,
       a.nrinmat,
       a.series,
       a.seriem,
       a.culoare,
       a.kmint,
       a.dataachi,
       a.nrachi,
       a.serief,
       a.seriecv,
       a.anfabricatie,
       a.inactiv,
       b.denumire as furnizor,
       c.model_masina,
       d.marca_masina,
       d.id_marca_masina,
       e.denumire as client
  from nom_masini a
  left join nom_parteneri b on a.id_furnizor = b.id_part
  left join nom_modele_masini c on a.id_model_masina = c.id_model_masina
  left join nom_marci_masini d on c.id_marca_masina = d.id_marca_masina
  left join nom_parteneri e on a.id_part = e.id_part
 where a.sters = 0;

-- --- VIEW: VNOM_MEDII_TRANSMISIE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_MEDII_TRANSMISIE" ("ID_MEDIU", "MEDIU_TRANSMISIE", "STERS", "ID_UTIL", "DATAORA", "ID_UTILS", "DATAORAS") AS 
  select "ID_MEDIU","MEDIU_TRANSMISIE","STERS","ID_UTIL","DATAORA","ID_UTILS","DATAORAS"
    from nom_medii_transmisie
    where sters = 0;

-- --- VIEW: VNOM_MODELE_MASINI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_MODELE_MASINI" ("ID_MODEL_MASINA", "MODEL_MASINA", "ID_MARCA_MASINA", "INACTIV", "MARCA_MASINA") AS 
  select a.id_model_masina, a.model_masina, a.id_marca_masina, a.inactiv, b.marca_masina
 from nom_modele_masini a
 join vnom_marci_masini b on a.id_marca_masina=b.id_marca_masina
 where a.sters=0


;

-- --- VIEW: VNOM_OBIECTE_DEPOZITARE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_OBIECTE_DEPOZITARE" ("ID_OBIECT_DEPOZIT", "DENUMIRE", "INACTIV", "ID_LOC_DEPOZIT", "CAPACITATE", "UM", "LOC_DEPOZIT", "ID_GESTIUNE", "NUME_GESTIUNE") AS 
  select a.id_obiect_depozit,
       a.denumire,
       a.inactiv,
       a.id_loc_depozit,
       a.capacitate,
       a.um,
       b.denumire as loc_depozit,
       a.id_gestiune,
       c.nume_gestiune
  from NOM_OBIECTE_DEPOZITARE A
  left join NOM_LOCURI_DEPOZITARE B on a.id_loc_depozit = b.id_loc_depozit
  left join NOM_GESTIUNI C on a.id_gestiune = c.id_gestiune
 where a.sters = 0;

-- --- VIEW: VNOM_PARTENERI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_PARTENERI" ("ID_PART", "DENUMIRE", "NUME", "PRENUME", "COD_FISCAL", "COD_FISCAL2", "REG_COMERT", "ID_LOC_INREG", "ID_CATEGORIE_ENTITATE", "LOCALITATE_INREG", "PREFIX", "SUFIX", "TIP_PERSOANA", "BANCA", "CONT_BANCA", "MOTIV_INACTIV", "INACTIV", "ELIBERATDE", "DATAELIBERAT", "EMAIL", "WEB", "FAX", "ID_ADRESA", "ADRESA", "TELEFON", "TELEFON2", "ID_LOC", "LOCALITATE", "JUDET", "ID_JUDET", "COD_JUDET", "INDICATIV_JUDET", "SECTOR", "APART", "ETAJ", "SCARA", "BLOC", "STRADA", "NUMAR", "CODPOSTAL", "ID_TARA", "TARA", "COD_TARA", "ID_CETATENIE", "CATEGORIE_ENTITATE", "DATAORA", "UTILIZATOR", "SWIFT_BANCA", "ADRESA_BANCA", "INSTITUTIE_PUBLICA", "ENTITATE_AFILIATA") AS 
  SELECT P.ID_PART,
       P.DENUMIRE,
       P.NUME,
       P.PRENUME,
       P.COD_FISCAL,
       P.COD_FISCAL2,
       P.REG_COMERT,
       P.ID_LOC                AS ID_LOC_INREG,
       P.ID_CATEGORIE_ENTITATE,
       L.LOCALITATE            AS LOCALITATE_INREG,
       P.PREFIX,
       P.SUFIX,
       P.TIP_PERSOANA,
       P.BANCA,
       P.CONT_BANCA,
       P.MOTIV_INACTIV,
       P.INACTIV,
       P.ELIBERATDE,
       P.DATAELIBERAT,
       A.EMAIL,
       A.WEB,
       A.FAX,
       A.ID_ADRESA,
       A.ADRESA,
       A.TELEFON,
       A.TELEFON2,
       A.ID_LOC,
       A.LOCALITATE,
       A.JUDET,
       A.ID_JUDET,
       A.COD_JUDET,
       A.INDICATIV_JUDET,
       A.SECTOR,
       A.APART,
       A.ETAJ,
       A.SCARA,
       A.BLOC,
       A.STRADA,
       A.NUMAR,
       A.CODPOSTAL,
       A.ID_TARA,
       A.TARA,
       A.COD_TARA,
       A.ID_CETATENIE,
       E.CATEGORIE_ENTITATE,
       P.DATAORA,
       UA.UTILIZATOR,
       P.SWIFT_BANCA,
       P.ADRESA_BANCA,
       P.INSTITUTIE_PUBLICA,
       P.ENTITATE_AFILIATA
  FROM NOM_PARTENERI P
  LEFT JOIN SYN_NOM_LOCALITATI L ON L.ID_LOC = P.ID_LOC
  LEFT JOIN (SELECT ID_PART,
                    ID_ADRESA,
                    ADRESA,
                    TELEFON1 AS TELEFON,
                    TELEFON2,
                    ID_LOC,
                    LOCALITATE,
                    ID_JUDET,
                    JUDET,
                    COD_JUDET,
                    INDICATIV AS INDICATIV_JUDET,
                    SECTOR,
                    APART,
                    ETAJ,
                    SCARA,
                    BLOC,
                    STRADA,
                    NUMAR,
                    CODPOSTAL,
                    ID_TARA,
                    TARA,
                    PRESCURTARE AS COD_TARA,
                    FAX,
                    EMAIL,
                    WEB,
                    ID_CETATENIE
               FROM VADRESE_PARTENERI
              WHERE PRINCIPALA = 1) A ON P.ID_PART = A.ID_PART
  LEFT JOIN VNOM_CATEGORII_ENTITATI E ON P.ID_CATEGORIE_ENTITATE =
                                         E.ID_CATEGORIE_ENTITATE
  LEFT JOIN SYN_VUTILIZATORI UA ON P.ID_UTIL = UA.ID_UTIL
 WHERE P.STERS = 0;

-- --- VIEW: VNOM_PARTENERI_EXTINS ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_PARTENERI_EXTINS" ("ID_PART", "DENUMIRE", "NUME", "PRENUME", "COD_FISCAL", "REG_COMERT", "ID_LOC_INREG", "LOCALITATE_INREG", "PREFIX", "SUFIX", "TIP_PERSOANA", "BANCA", "CONT_BANCA", "MOTIV_INACTIV", "INACTIV", "ID_ADRESA", "ADRESA", "TELEFON", "TELEFON2", "LOCALITATE", "JUDET") AS 
  SELECT DISTINCT P.id_part,
                  P.denumire,
                  P.nume,
                  P.prenume,
                  P.cod_fiscal,
                  P.reg_comert,
                  P.id_loc_inreg,
                  P.localitate_inreg,
                  P.prefix,
                  P.sufix,
                  P.tip_persoana,
                  P.banca,
                  P.cont_banca,
                  P.motiv_inactiv,
                  P.inactiv,
                  P.id_adresa,
                  P.adresa,
                  P.telefon,
                  P.telefon2,
                  P.localitate,
                  P.judet
    from vnom_parteneri P
    LEFT JOIN CORESP_TIP_PART C ON P.ID_PART = C.ID_PART
;

-- --- VIEW: VNOM_PARTENERI_SAL ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_PARTENERI_SAL" ("ID_SALARIAT", "MARCA", "INACTIV", "NUME", "PRENUME", "ID_PART") AS 
  select c.id_salariat, c.marca, b.inactiv, b.nume, b.prenume, a.id_part
  from (select id_part from coresp_tip_part where id_tip_part = -11) a
  left join nom_parteneri b
    on a.id_part = b.id_part
  left join sal_personal c
    on a.id_part = c.id_part
   and c.sters = 0
   and c.inactiv = 0
 where b.sters = 0
   and b.inactiv = 0;

-- --- VIEW: VNOM_PLCONT ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_PLCONT" ("ID_PLCONT", "ACONT", "EXPLICATIE", "CONT", "CONT_ALT", "COD", "TIP_SOLD", "AN", "TIP_CONT", "ID_MOD", "INACTIV", "NEFOLOSIT", "EXPLICATIES") AS 
  select ID_PLCONT,
       ACONT,
       EXPLICATIE,
       CONT,
       CONT_ALT,
       COD,
       TIP_SOLD,
       AN,
       TIP_CONT,
       ID_MOD,
       INACTIV,
       NEFOLOSIT,
       EXPLICATIES
  from PLCONT;

-- --- VIEW: VNOM_RESPONSABILI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_RESPONSABILI" ("ID_RESPONSABIL", "NUME", "BI", "CNP", "ELIBERATDE", "TELEFON1", "TELEFON2", "INACTIV", "FUNCTIE", "ALES", "MARCA", "ID_FORMATIE", "FORMATIE", "ID_MESERIE", "MESERIE") AS 
  select a.id_part as id_responsabil,
       a.denumire as nume,
       a.reg_comert as bi,
       a.cod_fiscal as cnp,
       a.localitate_inreg as eliberatde,
       a.telefon as telefon1,
       a.telefon2,
       a.inactiv,
       '' as functie,
       0 as ales,
       cast(nvl(p.marca, 0) as INTEGER) as marca,
       p.id_formatie,
       p.formatie,
       p.id_meserie,
       p.meserie
  from vnom_parteneri a
  join coresp_tip_part b on a.ID_PART = b.id_part
  left join vobinv_pers_sal p on p.id_part = a.ID_PART
 where b.id_tip_part = -41;

-- --- VIEW: VNOM_RETETAR ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_RETETAR" ("ID_RETETA", "COD", "ID_ARTICOL", "PRINCIPALA", "EXPLICATIE", "NR_PORTII", "PROC_PIERDERITEHN", "LUNGIME", "LATIME", "ID_UTIL", "DATAORA", "INACTIV", "RETETA", "DENUMIRE", "UM", "CODMAT", "UM2") AS 
  select a.id_reteta,
       a.cod,
       a.id_articol,
       a.principala,
       a.explicatie,
       a.nr_portii,
       a.proc_pierderitehn,
       a.lungime,
       a.latime,
       a.id_util,
       a.dataora,
       a.inactiv,
       a.cod as reteta,
       b.denumire,
       b.um,
       b.codmat,
       b.um2
  from nom_retetar a
  left join nom_articole b on a.id_articol = b.id_articol
 where a.sters = 0

;

-- --- VIEW: VNOM_RETETAR_ELEMENTE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_RETETAR_ELEMENTE" ("ID_RETETA_ELEM", "ID_RETETA", "ID_ARTICOL", "CANTITATE", "ID_SECTIE", "ID_ARTICOL_GRUPARE", "CU_PIERDERI", "DENUMIRE", "UM", "CONT", "CODMAT", "TIP", "DENUMIRE_SEMIFABRICAT", "SECTIE", "SEMIFABRICAT_ALES", "SEMIFABRICAT_ID") AS 
  select a.id_reteta_elem,
       a.id_reteta,
       a.id_articol,
       a.cantitate,
       a.id_sectie,
       a.id_articol_grupare,
       a.cu_pierderi,
       b.denumire,
       b.um,
       b.cont,
       b.codmat,
       (case
         when a.semifabricat_id is not null then
          -1
         else
          b.tip
       end) as tip,
       c.denumire as denumire_semifabricat,
       d.sectie,
       a.semifabricat_ales,
       a.semifabricat_id
  from nom_retetar_elemente a
  left join nom_articole b on a.id_articol = b.id_articol
  left join nom_articole c on a.id_articol_grupare = c.id_articol
  left join nom_sectii d on a.id_sectie = d.id_sectie
 where a.sters = 0
;

-- --- VIEW: VNOM_SECTII ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_SECTII" ("ID_SECTIE", "SECTIE", "ID_MOD", "INACTIV", "NSECTIE", "CSECTIE", "ID_SUCURSALA", "SUCURSALA", "CAEN") AS 
  select a.id_sectie,
       a.sectie,
       a.id_mod,
       a.inactiv,
       a.nsectie,
       a.csectie,
       a.id_sucursala,
       b.firma as sucursala,
       a.caen
  from nom_sectii a
  left join syn_nom_firme b on a.id_sucursala = b.id_firma
 where a.sters = 0;

-- --- VIEW: VNOM_SOFERI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_SOFERI" ("ID_RESPONSABIL", "NUME", "BI", "CNP", "ELIBERATDE", "TELEFON1", "TELEFON2", "INACTIV", "FUNCTIE", "ALES") AS 
  select a.id_part as id_responsabil,
       a.denumire as nume,
       a.reg_comert as bi,
       a.cod_fiscal as cnp,
       a.localitate_inreg as eliberatde,
       a.telefon as telefon1,
       a.telefon2,
       a.inactiv,
       '' as functie,
       0 as ales
  from vnom_parteneri a
  join coresp_tip_part b on a.ID_PART = b.id_part
 where b.id_tip_part = -43;

-- --- VIEW: VNOM_SUCURSALE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_SUCURSALE" ("ID_SUCURSALA", "SUCURSALA", "STERS", "ID_MOD", "INACTIV", "ID_MAMA", "E_MAMA") AS 
  SELECT ID_FIRMA AS ID_SUCURSALA,
       FIRMA AS SUCURSALA,
       STERS,
       0 AS ID_MOD,
       0 AS INACTIV,
       ID_MAMA,
       E_MAMA
  from syn_nom_firme
 WHERE STERS = 0
 and schema = user;

-- --- VIEW: VNOM_TIP_PARTENERI ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_TIP_PARTENERI" ("ID_TIP_PART", "TIP_PARTENER", "PARENT_ID", "INACTIV") AS 
  SELECT A.ID_TIP_PART, A.TIP_PARTENER, A.PARENT_ID, A.INACTIV
  FROM NOM_TIP_PARTENERI A
 WHERE A.STERS = 0;

-- --- VIEW: VNOM_TIP_RULAJ ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_TIP_RULAJ" ("ID_TIP_RULAJ", "DESCRIERE") AS 
  SELECT ID_TIP_RULAJ, DESCRIERE FROM NOM_TIP_RULAJ WHERE STERS = 0;

-- --- VIEW: VNOM_UM ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_UM" ("ID", "UM", "COD_UM_ISO", "UM_ISO", "INACTIV", "STERS", "DATAORA", "ID_UTIL", "DATAORAS", "ID_UTILS") AS 
  select a.id,
       a.um,
       a.cod_um_iso,
       b.um_iso,
       a.inactiv,
       a.sters,
       a.dataora,
       a.id_util,
       a.dataoras,
       a.id_utils
  from nom_um a
  left join syn_vnom_um_iso b
    on a.cod_um_iso = b.cod_um_iso
 where a.sters = 0;

-- --- VIEW: VNOM_VALUTE ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_VALUTE" ("ID_VALUTA", "NUME_VAL", "ID_VALUTA2", "NUME_VAL2", "ID_VALUTA3", "NUME_VAL3", "INACTIV", "MONEDA_NATIONALA") AS 
  select a.id_valuta,
       a.nume_val,
       b.id_valuta_iso as id_valuta2,
       b.iso_valuta as nume_val2,
       a.id_valuta as id_valuta3,
       a.nume_val as nume_val3,
       a.inactiv,
       a.moneda_nationala
  from nom_valute a
  left join syn_vnom_valute_iso b on a.id_valuta_iso = b.id_valuta_iso
 where a.sters = 0;

-- --- VIEW: VNOM_VENCHEL ---

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARIUSM_AUTO"."VNOM_VENCHEL" ("ID_VENCHELT", "ID_TATA", "TIP_VENCHELT", "EXPLICATIE", "EXPLICATIE_FIU", "EXPLICATIE_TATA", "INACTIV", "ID_MOD") AS 
  select id_venchelt,
       id_tata,
       tip_venchelt,
       cast(substr(sys_connect_by_path(explicatie, ' \ '), 4) as
            varchar2(200)) as explicatie,
       explicatie as explicatie_fiu,
       (case
         when id_tata is null then
          null
         else
          connect_by_root explicatie
       end) as explicatie_tata,
       inactiv,
       id_mod
  from nom_venit_cheltuieli
 where sters = 0
 start with id_tata is null
connect by prior id_venchelt = id_tata;


-- ============================================================
-- === SECTION: TRIGGERS ===
-- ============================================================
-- Gasite: 38 obiecte

-- --- TRIGGER: TRG_DEV_ESTIMARI_REP_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_ESTIMARI_REP_BEFOINS" 
  BEFORE INSERT ON DEV_ESTIMARI_REP
  REFERENCING OLD AS OLD NEW AS NEW
  FOR EACH ROW
BEGIN
  SELECT SEQ_DEV_ESTIMARI_REP.NEXTVAL
    INTO :NEW.ID_DEV_ESTIMARE_REP
    FROM DUAL;
END;


/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_ESTIMARI_REP_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_ESTIMARI_REP_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_ESTIMARI_REP_BEFOUPD" 
  BEFORE UPDATE ON dev_estimari_rep
  REFERENCING OLD AS OLD NEW AS NEW
  FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_DEV_ESTIMARE_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          :NEW.ID_DEV_ESTIMARE_REP);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_LUCRARE',
                          :OLD.ID_LUCRARE,
                          :NEW.ID_LUCRARE);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_NORME',
                          :OLD.ID_NORME,
                          :NEW.ID_NORME);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_ARTICOL',
                          :OLD.ID_ARTICOL,
                          :NEW.ID_ARTICOL);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'CANTITATE',
                          :OLD.CANTITATE,
                          :NEW.CANTITATE);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'PRET',
                          :OLD.PRET,
                          :NEW.PRET);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'PRET_CU_TVA',
                          :OLD.PRET_CU_TVA,
                          :NEW.PRET_CU_TVA);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'COTA_TVA',
                          :OLD.COTA_TVA,
                          :NEW.COTA_TVA);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_SECTIE',
                          :OLD.ID_SECTIE,
                          :NEW.ID_SECTIE);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_POL',
                          :OLD.ID_POL,
                          :NEW.ID_POL);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_DEV_ESTIMARE_PROD',
                          :OLD.ID_DEV_ESTIMARE_PROD,
                          :NEW.ID_DEV_ESTIMARE_PROD);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_ARTICOL_GRUPARE',
                          :OLD.ID_ARTICOL_GRUPARE,
                          :NEW.ID_ARTICOL_GRUPARE);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'CU_PIERDERI',
                          :OLD.CU_PIERDERI,
                          :NEW.CU_PIERDERI);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_VALUTA',
                          :OLD.ID_VALUTA,
                          :NEW.ID_VALUTA);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'SEMIFABRICAT_ID',
                          :OLD.SEMIFABRICAT_ID,
                          :NEW.SEMIFABRICAT_ID);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'SEMIFABRICAT_ALES',
                          :OLD.SEMIFABRICAT_ALES,
                          :NEW.SEMIFABRICAT_ALES);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_UTIL',
                          :OLD.ID_UTIL,
                          :NEW.ID_UTIL);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'DATAORA',
                          :OLD.DATAORA,
                          :NEW.DATAORA);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'ID_UTILS',
                          :OLD.ID_UTILS,
                          :NEW.ID_UTILS);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'DATAORAS',
                          :OLD.DATAORAS,
                          :NEW.DATAORAS);

  pack_audit.verifica_val('DEV_ESTIMARI_REP',
                          :OLD.ID_DEV_ESTIMARE_REP,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

end;


/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_ESTIMARI_REP_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_EST_PROD_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_EST_PROD_BEFOINS" 
before insert on DEV_ESTIMARI_PRODUSE
referencing old as old new as new
for each row
begin
    select SEQ_DEV_EST_PROD.nextval into :new.ID_DEV_ESTIMARE_PROD from dual;
end;

/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_EST_PROD_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_FURNIZORI ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_FURNIZORI" 
  before insert on dev_nom_furnizorimasini
  for each row
declare
  -- local variables here
begin
  select SEQ_dev_nom_FURNIZORIMASINI.NEXTVAL into :new.id_FURNIZOR from dual;
end TRG_DEV_FURNIZORI;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_FURNIZORI" ENABLE;

-- --- TRIGGER: TRG_DEV_MASINICLIENTI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_MASINICLIENTI_BEFOINS" 
before insert on dev_masiniclienti
referencing old as old new as new
for each row
begin
select SEQ_dev_masiniclienti.NEXTVAL into :new.id_masiniclient from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_MASINICLIENTI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_MASINICLIENT_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_MASINICLIENT_BEFOUPD" 
BEFORE UPDATE ON DEV_MASINICLIENTI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'ID_MASINICLIENT',
                          :OLD.ID_MASINICLIENT,
                          :NEW.ID_MASINICLIENT);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'ID_TIPMOTOR',
                          :OLD.ID_TIPMOTOR,
                          :NEW.ID_TIPMOTOR);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'ID_FURNIZOR',
                          :OLD.ID_FURNIZOR,
                          :NEW.ID_FURNIZOR);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'ID_MASINA',
                          :OLD.ID_MASINA,
                          :NEW.ID_MASINA);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'ID_PARTENER',
                          :OLD.ID_PARTENER,
                          :NEW.ID_PARTENER);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'NRINMAT',
                          :OLD.NRINMAT,
                          :NEW.NRINMAT);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'SERIES',
                          :OLD.SERIES,
                          :NEW.SERIES);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'SERIEM',
                          :OLD.SERIEM,
                          :NEW.SERIEM);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'CULOARE',
                          :OLD.CULOARE,
                          :NEW.CULOARE);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'KMINT',
                          :OLD.KMINT,
                          :NEW.KMINT);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'DATAACHI',
                          :OLD.DATAACHI,
                          :NEW.DATAACHI);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'NRACHI',
                          :OLD.NRACHI,
                          :NEW.NRACHI);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'SERIEF',
                          :OLD.SERIEF,
                          :NEW.SERIEF);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'SERIECV',
                          :OLD.SERIECV,
                          :NEW.SERIECV);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'ANFABRICATIE',
                          :OLD.ANFABRICATIE,
                          :NEW.ANFABRICATIE);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_MASINICLIENTI',
                          :OLD.ID_MASINICLIENT,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_MASINICLIENT_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_MECANICI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_MECANICI_BEFOINS" 
before insert on dev_mecanici
referencing old as old new as new
for each row
begin
select SEQ_dev_mecanici.NEXTVAL into :new.id_mecanic from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_MECANICI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_MECANICI_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_MECANICI_BEFOUPD" 
BEFORE UPDATE ON DEV_MECANICI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_MECANICI',
                          :OLD.ID_MECANIC,
                          'ID_MECANIC',
                          :OLD.ID_MECANIC,
                          :NEW.ID_MECANIC);

  pack_audit.verifica_val('DEV_MECANICI',
                          :OLD.ID_MECANIC,
                          'ID_SECTIE',
                          :OLD.ID_SECTIE,
                          :NEW.ID_SECTIE);

  pack_audit.verifica_val('DEV_MECANICI',
                          :OLD.ID_MECANIC,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_MECANICI',
                          :OLD.ID_MECANIC,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_MECANICI_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_ANSAMBLE_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_ANSAMBLE_BEFOINS" 
before insert on dev_nom_ansamble
referencing old as old new as new
for each row
begin
select SEQ_dev_nom_ansamble.NEXTVAL into :new.id_ansamblu from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_ANSAMBLE_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_ANSAMBLE_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_ANSAMBLE_BEFOUPD" 
BEFORE UPDATE ON DEV_NOM_ANSAMBLE
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_NOM_ANSAMBLE',
                          :OLD.ID_ANSAMBLU,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_NOM_ANSAMBLE',
                          :OLD.ID_ANSAMBLU,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('DEV_NOM_ANSAMBLE',
                          :OLD.ID_ANSAMBLU,
                          'ID_ANSAMBLU',
                          :OLD.ID_ANSAMBLU,
                          :NEW.ID_ANSAMBLU);

  pack_audit.verifica_val('DEV_NOM_ANSAMBLE',
                          :OLD.ID_ANSAMBLU,
                          'DENUMIRE',
                          :OLD.DENUMIRE,
                          :NEW.DENUMIRE);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_ANSAMBLE_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_FURNIZOR_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_FURNIZOR_BEFOUPD" 
BEFORE UPDATE ON DEV_NOM_FURNIZORIMASINI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_NOM_FURNIZORIMASINI',
                          :OLD.ID_FURNIZOR,
                          'ID_FURNIZOR',
                          :OLD.ID_FURNIZOR,
                          :NEW.ID_FURNIZOR);

  pack_audit.verifica_val('DEV_NOM_FURNIZORIMASINI',
                          :OLD.ID_FURNIZOR,
                          'DENUMIRE',
                          :OLD.DENUMIRE,
                          :NEW.DENUMIRE);

  pack_audit.verifica_val('DEV_NOM_FURNIZORIMASINI',
                          :OLD.ID_FURNIZOR,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_NOM_FURNIZORIMASINI',
                          :OLD.ID_FURNIZOR,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_FURNIZOR_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_INSPECTORI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_INSPECTORI_BEFOINS" 
before insert on dev_nom_inspectori
referencing old as old new as new
for each row
begin
select SEQ_dev_nom_inspectori.NEXTVAL into :new.id_inspector from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_INSPECTORI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_INSPECTO_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_INSPECTO_BEFOUPD" 
BEFORE UPDATE ON DEV_NOM_INSPECTORI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_NOM_INSPECTORI',
                          :OLD.ID_INSPECTOR,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_NOM_INSPECTORI',
                          :OLD.ID_INSPECTOR,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('DEV_NOM_INSPECTORI',
                          :OLD.ID_INSPECTOR,
                          'ID_INSPECTOR',
                          :OLD.ID_INSPECTOR,
                          :NEW.ID_INSPECTOR);

  pack_audit.verifica_val('DEV_NOM_INSPECTORI',
                          :OLD.ID_INSPECTOR,
                          'INSPECTOR',
                          :OLD.INSPECTOR,
                          :NEW.INSPECTOR);

  pack_audit.verifica_val('DEV_NOM_INSPECTORI',
                          :OLD.ID_INSPECTOR,
                          'ID_ASIGURATOR',
                          :OLD.ID_ASIGURATOR,
                          :NEW.ID_ASIGURATOR);
end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_INSPECTO_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_MARCI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MARCI_BEFOINS" 
before insert on dev_nom_marci
referencing old as old new as new
for each row
begin
select SEQ_dev_nom_marci.NEXTVAL into :new.id_marca from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MARCI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_MARCI_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MARCI_BEFOUPD" 
BEFORE UPDATE ON DEV_NOM_MARCI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_NOM_MARCI',
                          :OLD.ID_MARCA,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_NOM_MARCI',
                          :OLD.ID_MARCA,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('DEV_NOM_MARCI',
                          :OLD.ID_MARCA,
                          'ID_MARCA',
                          :OLD.ID_MARCA,
                          :NEW.ID_MARCA);

  pack_audit.verifica_val('DEV_NOM_MARCI',
                          :OLD.ID_MARCA,
                          'MARCA',
                          :OLD.MARCA,
                          :NEW.MARCA);
end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MARCI_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_MASINI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MASINI_BEFOINS" 
before insert on dev_nom_masini
referencing old as old new as new
for each row
begin
select SEQ_dev_nom_masini.NEXTVAL into :new.id_masina from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MASINI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_MASINI_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MASINI_BEFOUPD" 
BEFORE UPDATE ON DEV_NOM_MASINI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'ID_MASINA',
                          :OLD.ID_MASINA,
                          :NEW.ID_MASINA);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'ID_MARCA',
                          :OLD.ID_MARCA,
                          :NEW.ID_MARCA);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'MASINA',
                          :OLD.MASINA,
                          :NEW.MASINA);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'SCTIP',
                          :OLD.SCTIP,
                          :NEW.SCTIP);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'CLASA',
                          :OLD.CLASA,
                          :NEW.CLASA);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'COMBUSTIBIL',
                          :OLD.COMBUSTIBIL,
                          :NEW.COMBUSTIBIL);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'CLINDREE',
                          :OLD.CLINDREE,
                          :NEW.CLINDREE);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'PUTERE_KW',
                          :OLD.PUTERE_KW,
                          :NEW.PUTERE_KW);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'PUTERE_CP',
                          :OLD.PUTERE_CP,
                          :NEW.PUTERE_CP);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'CUTIE_VITEZE',
                          :OLD.CUTIE_VITEZE,
                          :NEW.CUTIE_VITEZE);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'TRACTIUNE',
                          :OLD.TRACTIUNE,
                          :NEW.TRACTIUNE);

  pack_audit.verifica_val('DEV_NOM_MASINI',
                          :OLD.ID_MASINA,
                          'ECHIPARE',
                          :OLD.ECHIPARE,
                          :NEW.ECHIPARE);
end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_MASINI_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_NORME_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_NORME_BEFOINS" 
before insert on dev_nom_norme
referencing old as old new as new
for each row
begin
select SEQ_dev_nom_norme.NEXTVAL into :new.id_norme from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_NORME_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_NORME_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_NORME_BEFOUPD" 
BEFORE UPDATE ON DEV_NOM_NORME
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'ID_NORME',
                          :OLD.ID_NORME,
                          :NEW.ID_NORME);

  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'ID_ANSAMBLU',
                          :OLD.ID_ANSAMBLU,
                          :NEW.ID_ANSAMBLU);

  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'ID_MASINA',
                          :OLD.ID_MASINA,
                          :NEW.ID_MASINA);

  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'DENOP',
                          :OLD.DENOP,
                          :NEW.DENOP);

  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'CODOP',
                          :OLD.CODOP,
                          :NEW.CODOP);

  pack_audit.verifica_val('DEV_NOM_NORME',
                          :OLD.ID_NORME,
                          'TIMPN',
                          :OLD.TIMPN,
                          :NEW.TIMPN);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_NORME_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_PRETURI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_PRETURI_BEFOINS" 
before insert on dev_nom_preturi
referencing old as old new as new
for each row
begin
select SEQ_dev_nom_preturi.NEXTVAL into :new.id_pret from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_PRETURI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_PRETURI_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_PRETURI_BEFOUPD" 
BEFORE UPDATE ON DEV_NOM_PRETURI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'ID_PRET',
                          :OLD.ID_PRET,
                          :NEW.ID_PRET);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'ID_MARCA',
                          :OLD.ID_MARCA,
                          :NEW.ID_MARCA);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'ID_ASIGURATOR',
                          :OLD.ID_ASIGURATOR,
                          :NEW.ID_ASIGURATOR);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'PRET',
                          :OLD.PRET,
                          :NEW.PRET);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'PRET_VAL',
                          :OLD.PRET_VAL,
                          :NEW.PRET_VAL);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'ID_VALUTA',
                          :OLD.ID_VALUTA,
                          :NEW.ID_VALUTA);

  pack_audit.verifica_val('DEV_NOM_PRETURI',
                          :OLD.ID_PRET,
                          'CURS',
                          :OLD.CURS,
                          :NEW.CURS);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_PRETURI_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_NOM_PROC_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_PROC_BEFOINS" 
before insert on DEVIZE_NOM_PROCENTE
referencing old as old new as new
for each row
begin
    select SEQ_DEVIZE_NOM_PROCENTE.nextval into :new.ID_DEV_NOM_PROCENT from dual;
end;

/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_NOM_PROC_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_OPER_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_BEFOINS" 
BEFORE INSERT ON DEV_OPER
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  select SEQ_dev_oper.NEXTVAL into :new.id_oper from dual;
  pack_sesiune.dev_idOper := :new.id_oper;
end;




/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_OPER_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_BEFOUPD" 
BEFORE UPDATE ON DEV_OPER
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'ID_OPER',
                          :OLD.ID_OPER,
                          :NEW.ID_OPER);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'ID_ORDL',
                          :OLD.ID_ORDL,
                          :NEW.ID_ORDL);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'ID_NORME',
                          :OLD.ID_NORME,
                          :NEW.ID_NORME);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'TIMPN',
                          :OLD.TIMPN,
                          :NEW.TIMPN);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'PRET',
                          :OLD.PRET,
                          :NEW.PRET);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'DATAI',
                          :OLD.DATAI,
                          :NEW.DATAI);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'ID_SECTIE',
                          :OLD.ID_SECTIE,
                          :NEW.ID_SECTIE);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'ID_UTIL',
                          :OLD.ID_UTIL,
                          :NEW.ID_UTIL);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'DATAORA',
                          :OLD.DATAORA,
                          :NEW.DATAORA);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'ID_UTILS',
                          :OLD.ID_UTILS,
                          :NEW.ID_UTILS);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'DATAORAS',
                          :OLD.DATAORAS,
                          :NEW.DATAORAS);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'VALIDAT',
                          :OLD.VALIDAT,
                          :NEW.VALIDAT);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'NOU',
                          :OLD.NOU,
                          :NEW.NOU);

  pack_audit.verifica_val('DEV_OPER',
                          :OLD.ID_OPER,
                          'ID_UTILI',
                          :OLD.ID_UTILI,
                          :NEW.ID_UTILI);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_OPER_MECANICI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_MECANICI_BEFOINS" 
before insert on DEV_OPER_MECANICI
referencing old as old new as new
for each row
begin
select SEQ_DEV_OPER_MECANICI.NEXTVAL into :new.ID_OPERMECANIC from dual;
end;




/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_MECANICI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_OPER_MECANIC_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_MECANIC_BEFOUPD" 
BEFORE UPDATE ON DEV_OPER_MECANICI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_OPER_MECANICI',
                          :OLD.ID_OPERMECANIC,
                          'ID_OPERMECANIC',
                          :OLD.ID_OPERMECANIC,
                          :NEW.ID_OPERMECANIC);

  pack_audit.verifica_val('DEV_OPER_MECANICI',
                          :OLD.ID_OPERMECANIC,
                          'ID_MECANIC',
                          :OLD.ID_MECANIC,
                          :NEW.ID_MECANIC);

  pack_audit.verifica_val('DEV_OPER_MECANICI',
                          :OLD.ID_OPERMECANIC,
                          'ID_OPER',
                          :OLD.ID_OPER,
                          :NEW.ID_OPER);

  pack_audit.verifica_val('DEV_OPER_MECANICI',
                          :OLD.ID_OPERMECANIC,
                          'ORE',
                          :OLD.ORE,
                          :NEW.ORE);

  pack_audit.verifica_val('DEV_OPER_MECANICI',
                          :OLD.ID_OPERMECANIC,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_OPER_MECANICI',
                          :OLD.ID_OPERMECANIC,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_OPER_MECANIC_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_ORDL_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_ORDL_BEFOINS" 
BEFORE INSERT ON DEV_ORDL
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  select SEQ_DEV_ORDL.NEXTVAL into :new.ID_ORDL from dual;
  pack_sesiune.dev_idOrdl := :new.id_ordl;
end;




/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_ORDL_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_ORDL_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_ORDL_BEFOUPD" 
  BEFORE UPDATE ON DEV_ORDL
  REFERENCING OLD AS OLD NEW AS NEW
  FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_ORDL',
                          :OLD.ID_ORDL,
                          :NEW.ID_ORDL);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'LUNA',
                          :OLD.LUNA,
                          :NEW.LUNA);

  pack_audit.verifica_val('DEV_ORDL', :OLD.ID_ORDL, 'AN', :OLD.AN, :NEW.AN);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_INSPECTOR',
                          :OLD.ID_INSPECTOR,
                          :NEW.ID_INSPECTOR);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_LUCRARE',
                          :OLD.ID_LUCRARE,
                          :NEW.ID_LUCRARE);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'TERMEN',
                          :OLD.TERMEN,
                          :NEW.TERMEN);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATAI',
                          :OLD.DATAI,
                          :NEW.DATAI);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ORAI',
                          :OLD.ORAI,
                          :NEW.ORAI);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATAE',
                          :OLD.DATAE,
                          :NEW.DATAE);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ORAE',
                          :OLD.ORAE,
                          :NEW.ORAE);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'VALIDAT',
                          :OLD.VALIDAT,
                          :NEW.VALIDAT);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_UTIL_AD',
                          :OLD.ID_UTIL_AD,
                          :NEW.ID_UTIL_AD);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_UTIL_VALID',
                          :OLD.ID_UTIL_VALID,
                          :NEW.ID_UTIL_VALID);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATAORAAD',
                          :OLD.DATAORAAD,
                          :NEW.DATAORAAD);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATAORAVALID',
                          :OLD.DATAORAVALID,
                          :NEW.DATAORAVALID);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_UTILS',
                          :OLD.ID_UTILS,
                          :NEW.ID_UTILS);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATAORAS',
                          :OLD.DATAORAS,
                          :NEW.DATAORAS);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_MASINICLIENT',
                          :OLD.ID_MASINICLIENT,
                          :NEW.ID_MASINICLIENT);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_ASIGURATOR',
                          :OLD.ID_ASIGURATOR,
                          :NEW.ID_ASIGURATOR);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'NR_DOSAR',
                          :OLD.NR_DOSAR,
                          :NEW.NR_DOSAR);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_TIP',
                          :OLD.ID_TIP,
                          :NEW.ID_TIP);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'INCHIS_FORTAT',
                          :OLD.INCHIS_FORTAT,
                          :NEW.INCHIS_FORTAT);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'KMINT',
                          :OLD.KMINT,
                          :NEW.KMINT);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'SOLICITARI_CLIENT',
                          :OLD.SOLICITARI_CLIENT,
                          :NEW.SOLICITARI_CLIENT);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'PROC_TVAV',
                          :OLD.PROC_TVAV,
                          :NEW.PROC_TVAV);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_PART',
                          :OLD.ID_PART,
                          :NEW.ID_PART);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'COADA_DEVIZ',
                          :OLD.COADA_DEVIZ,
                          :NEW.COADA_DEVIZ);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'OBSERVATII',
                          :OLD.OBSERVATII,
                          :NEW.OBSERVATII);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATA_CURS',
                          :OLD.DATA_CURS,
                          :NEW.DATA_CURS);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'IN_LUCRU',
                          :OLD.IN_LUCRU,
                          :NEW.IN_LUCRU);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_VALUTA_DEVIZ',
                          :OLD.ID_VALUTA_DEVIZ,
                          :NEW.ID_VALUTA_DEVIZ);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'FACTUREZMIX',
                          :OLD.FACTUREZMIX,
                          :NEW.FACTUREZMIX);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATA_IN_LUCRU',
                          :OLD.DATA_IN_LUCRU,
                          :NEW.DATA_IN_LUCRU);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATAORAINLUCRU',
                          :OLD.DATAORAINLUCRU,
                          :NEW.DATAORAINLUCRU);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_AGENT',
                          :OLD.ID_AGENT,
                          :NEW.ID_AGENT);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_UTIL_INCHIS',
                          :OLD.ID_UTIL_INCHIS,
                          :NEW.ID_UTIL_INCHIS);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'DATAORAINCHIS',
                          :OLD.DATAORAINCHIS,
                          :NEW.DATAORAINCHIS);

  pack_audit.verifica_val('DEV_ORDL',
                          :OLD.ID_ORDL,
                          'ID_PART_REF',
                          :OLD.ID_PART_REF,
                          :NEW.ID_PART_REF);
end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_ORDL_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_PROC_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_PROC_BEFOINS" 
before insert on DEVIZE_PROCENTE
referencing old as old new as new
for each row
begin
    select SEQ_DEVIZE_PROCENTE.nextval into :new.ID_DEV_PROCENT from dual;
end;

/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_PROC_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_RAP_PROD_DET_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_RAP_PROD_DET_BEFOINS" 
before insert on DEV_RAPOARTE_PROD_DET
referencing old as old new as new
for each row
begin
  if :new.ID_DEV_RAP_PROD_DET is null then
    select SEQ_DEV_RAP_PROD_DET.NEXTVAL into :new.ID_DEV_RAP_PROD_DET from dual;
  end if;
end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_RAP_PROD_DET_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_TIPURI_MOTOARE_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIPURI_MOTOARE_BEFOINS" 
before insert on dev_tipuri_motoare
referencing old as old new as new
for each row
begin
select SEQ_dev_tipuri_motoare.NEXTVAL into :new.id_tipmotor from dual;
end;



/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIPURI_MOTOARE_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_TIPURI_MOTOA_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIPURI_MOTOA_BEFOUPD" 
BEFORE UPDATE ON DEV_TIPURI_MOTOARE
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_TIPURI_MOTOARE',
                          :OLD.ID_TIPMOTOR,
                          'DENUMIRE',
                          :OLD.DENUMIRE,
                          :NEW.DENUMIRE);

  pack_audit.verifica_val('DEV_TIPURI_MOTOARE',
                          :OLD.ID_TIPMOTOR,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('DEV_TIPURI_MOTOARE',
                          :OLD.ID_TIPMOTOR,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('DEV_TIPURI_MOTOARE',
                          :OLD.ID_TIPMOTOR,
                          'ID_TIPMOTOR',
                          :OLD.ID_TIPMOTOR,
                          :NEW.ID_TIPMOTOR);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIPURI_MOTOA_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_TIP_DEVIZ ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIP_DEVIZ" 
before insert on DEV_TIP_DEVIZ
referencing old as old new as new
for each row
begin
select SEQ_DEV_TIP_DEVIZ.NEXTVAL into :new.ID_TIP from dual;
end;




/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIP_DEVIZ" ENABLE;

-- --- TRIGGER: TRG_DEV_TIP_DEVIZ_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIP_DEVIZ_BEFOUPD" 
  BEFORE UPDATE ON DEV_TIP_DEVIZ
  REFERENCING OLD AS OLD NEW AS NEW
  FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_TIP_DEVIZ',
                          :OLD.ID_TIP,
                          'ID_TIP',
                          :OLD.ID_TIP,
                          :NEW.ID_TIP);

  pack_audit.verifica_val('DEV_TIP_DEVIZ',
                          :OLD.ID_TIP,
                          'DENUMIRE',
                          :OLD.DENUMIRE,
                          :NEW.DENUMIRE);

  pack_audit.verifica_val('DEV_TIP_DEVIZ',
                          :OLD.ID_TIP,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_TIP_DEVIZ_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_DEV_UTIL_CODURI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_UTIL_CODURI_BEFOINS" 
before insert on DEV_UTILIZATORI_CODURI
referencing old as old new as new
for each row
begin
select SEQ_DEV_UTILIZATORI_CODURI.NEXTVAL into :new.ID_UTIL_COD from dual;
end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_UTIL_CODURI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_DEV_UTIL_CODURI_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_DEV_UTIL_CODURI_BEFOUPD" 
BEFORE UPDATE ON DEV_UTILIZATORI_CODURI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('DEV_UTILIZATORI_CODURI',
                          :OLD.ID_UTIL_COD,
                          'ID_UTIL',
                          :OLD.ID_UTIL,
                          :NEW.ID_UTIL);

  pack_audit.verifica_val('DEV_MECANICI',
                          :OLD.ID_UTIL_COD,
                          'COD',
                          :OLD.COD,
                          :NEW.COD);


end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_DEV_UTIL_CODURI_BEFOUPD" ENABLE;

-- --- TRIGGER: TRG_NOM_LUCRARI_BEFOINS ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_NOM_LUCRARI_BEFOINS" 
BEFORE INSERT ON NOM_LUCRARI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  select SEQ_NOM_LUCRARI.NEXTVAL into :new.ID_LUCRARE from dual;
  pack_sesiune.dev_idLucrare := :new.id_lucrare;
end;




/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_NOM_LUCRARI_BEFOINS" ENABLE;

-- --- TRIGGER: TRG_NOM_LUCRARI_BEFOUPD ---

  CREATE OR REPLACE EDITIONABLE TRIGGER "MARIUSM_AUTO"."TRG_NOM_LUCRARI_BEFOUPD" 
BEFORE UPDATE ON NOM_LUCRARI
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
  pack_audit.verifica_val('NOM_LUCRARI',
                          :OLD.ID_LUCRARE,
                          'ID_LUCRARE',
                          :OLD.ID_LUCRARE,
                          :NEW.ID_LUCRARE);

  pack_audit.verifica_val('NOM_LUCRARI',
                          :OLD.ID_LUCRARE,
                          'NRORD',
                          :OLD.NRORD,
                          :NEW.NRORD);

  pack_audit.verifica_val('NOM_LUCRARI',
                          :OLD.ID_LUCRARE,
                          'STERS',
                          :OLD.STERS,
                          :NEW.STERS);

  pack_audit.verifica_val('NOM_LUCRARI',
                          :OLD.ID_LUCRARE,
                          'ID_MOD',
                          :OLD.ID_MOD,
                          :NEW.ID_MOD);

  pack_audit.verifica_val('NOM_LUCRARI',
                          :OLD.ID_LUCRARE,
                          'INACTIV',
                          :OLD.INACTIV,
                          :NEW.INACTIV);

  pack_audit.verifica_val('NOM_LUCRARI',
                          :OLD.ID_LUCRARE,
                          'FACTURATA',
                          :OLD.FACTURATA,
                          :NEW.FACTURATA);

  pack_audit.verifica_val('NOM_LUCRARI',
                          :OLD.ID_LUCRARE,
                          'ID_TATA',
                          :OLD.ID_TATA,
                          :NEW.ID_TATA);
end;
/
ALTER TRIGGER "MARIUSM_AUTO"."TRG_NOM_LUCRARI_BEFOUPD" ENABLE;


