/*ALIAS>prop_db*/

/*SQLstart>1380*/
	ALTER TABLE DOCUMENTS
	ADD DOC_APP SMALLINT,
	ADD DOC_DELETED CHAR(1),
	ADD DOC_VALUECALCID INTEGER,
	ADD DOC_VALUECALCSMETID INTEGER,
    ADD DOC_ADDPRICE REAL3,
    ADD DOC_ADDSMETPRICE NUMERIC(15,3),
    ADD DOC_ONESUM REAL3,
    ADD DOC_FREE CHAR(1) DEFAULT 'F',
    ADD DOC_ADV_SIDE CHAR(1) CHARACTER SET WIN1251 DEFAULT 'N' COLLATE WIN1251; 
/*SQLstop>1380*/

/*SQLstart>1381*/
	ALTER TABLE IMOT
	ADD IM_APP SMALLINT;
/*SQLstop>1381*/

/*SQLstart>1382*/
	ALTER TABLE DT_KL
	ADD DT_APP SMALLINT;
/*SQLstop>1382*/

/*SQLstart>1383*/
	ALTER TABLE RENTTYPES
	ADD RT_APP SMALLINT,
    add RT_VALUECALCID integer,
    ADD RT_VALUECALC_BO_ID INTEGER,
    ADD RT_REQUIREDEDITS SMALLINT;
/*SQLstop>1383*/

/*SQLstart>1384*/
	ALTER TABLE VI_KL
	ADD VI_APP SMALLINT;
/*SQLstop>1384*/

/*SQLstart>1385*/
	ALTER TABLE OBJTYPE_KL
	ADD OT_APP SMALLINT;
/*SQLstop>1385*/

/*SQLstart>1386*/
	UPDATE VI_KL SET VI_APP = 1;
/*SQLstop>1386*/

/*SQLStart>1387*/
	UPDATE DOCUMENTS SET DOC_APP = 1, DOC_DELETED = 'F', DOC_FREE = 'F';
/*SQLStop>1387*/

/*SQLStart>1388*/
	UPDATE IMOT SET IM_APP = 1;
/*SQLStop>1388*/

/*SQLStart>1389*/
	UPDATE DT_KL SET DT_APP = 1;
/*SQLStop>1389*/

/*SQLStart>1390*/
	UPDATE RENTTYPES SET RT_APP = 1;
/*SQLStop>1390*/

/*SQLStart>1391*/
	UPDATE OBJTYPE_KL SET OT_APP = 1;
/*SQLStop>1391*/

/*SQLStart>1392*/
create table VALUES_CALC (
  VC_ID integer not null primary key, 
  VC_DTID integer,
  VC_DESC varchar(80),
  VC_PHPCODE blob sub_type 1 character set win1251,
  VC_FOR SMALLINT,
  VC_APP SMALLINT);
/*SQLStop>1392*/

/*SQLStart>1393*/
grant all on values_calc to public
/*SQLStop>1393*/

/*SQLStart>1394*/
CREATE TABLE CHARACTERISTICS(
    CH_ID INTEGER NOT NULL PRIMARY KEY,
    CH_TEXT CHAR(80) CHARACTER SET WIN1251,
    CH_VARNAME CHAR(20),
    CH_VALUE CHAR(10),
    CH_NO_USE_VALUE CHAR(10),
    CH_APP SMALLINT)
/*SQLStop>1394*/

/*SQLStart>1395*/
CREATE GENERATOR CH_ID_GEN
/*SQLStop>1395*/

/*SQLStart>1396*/
CREATE TRIGGER CHARACTERISTICS_BI0 FOR CHARACTERISTICS
ACTIVE BEFORE INSERT POSITION 0
AS
begin
  new.CH_ID=gen_id(CH_ID_GEN,1);
end
/*SQLStop>1396*/

/*SQLStart>1397*/
grant all on CHARACTERISTICS to public
/*SQLStop>1397*/

/*SQLStart>1398*/
CREATE TABLE CHARACTERISTICS_DOC(
    CD_DOCID INTEGER NOT NULL,
    CD_CHID INTEGER NOT NULL,
    CD_VALUE CHAR(10))
/*SQLStop>1398*/

/*SQLStart>1399*/
GRANT ALL ON CHARACTERISTICS_DOC TO PUBLIC
/*SQLStop>1399*/

/*SQLStart>1400*/
    CREATE TABLE NUMKINDPER_NOM(
    NUMKIND_ID SMALLINT NOT NULL PRIMARY KEY,
    NUMKIND_PREFIX VARCHAR(10),
    NUMKIND_ACTIVE CHAR(1) DEFAULT "T",
    NUMKIND_VALUE INTEGER,
    NUMKIND_NAME VARCHAR(30))
/*SQLStop>1400*/

/*SQLStart>1401*/
    CREATE GENERATOR NUMKINDPER_ID_GEN
/*SQLStop>1401*/

/*SQLStart>1402*/
    grant all on NUMKINDPER_NOM to public
/*SQLStop>1402*/

/*SQLStart>1403*/
    ALTER TABLE ANECS
    ADD AN_ADDPRICE REAL3,
    ADD AN_ADDSMETPRICE NUMERIC(15,3)
/*SQLStop>1403*/

/*SQLStart>1404*/
CREATE TABLE RENTKONS (
    RT_ID      INTEGER,
    TAX_ID     INTEGER,
    KONS_TEXT  VARCHAR(80),
    VC_ID      INTEGER
)
/*SQLStop>1404*/

/*SQLStart>1405*/
    GRANT ALL ON RENTKONS TO public
/*SQLStop>1405*/

/*SQLstart>1406*/
	ALTER TABLE ZONE_KL
	ADD ZONE_APP SMALLINT;
/*SQLstop>1406*/

/*SQLstart>1407*/
    update ZONE_KL set ZONE_APP = 1;
/*SQLstop>1407*/

/*SQLstart>1408*/
    ALTER TABLE INTDOC_TEMPL
    ADD IDT_APP SMALLINT
/*SQLstop>1408*/

/*SQLstart>1409*/
    update intdoc_templ set idt_app = 1
/*SQLstop>1409*/