ALTER TABLE R5BOILERTEXTS ADD COLUMN BOT_FLD2 nvarchar(24);

ALTER TABLE R5OBJECTS ADD COLUMN OBJ_COMPLOCATION nvarchar(80);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_PROFILE nvarchar(30);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_PROFILE_ORG nvarchar(15);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_PARENT nvarchar(30);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_PARENT_ORG nvarchar(15);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_GISLAYER nvarchar(60);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_GISMAP nvarchar(30);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_GISMAP_ORG nvarchar(15);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_XLOCATION numeric (24, 6);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_YLOCATION numeric (24, 6);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_LENGTH numeric (24, 6);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_LENGTHUOM nvarchar(10);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_LINEARREFUOM nvarchar(10);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_LINEARREFPRECISION numeric (2);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_GEOREF nvarchar(1000);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_INSPECTIONDIRECTION nvarchar(8);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_FLOW nvarchar(8);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_GISPROFILE	nvarchar(1);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_LINKGISWO nvarchar(1);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_GIS_UPDATECOUNT numeric(24,6);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_GIS_SYNCCOUNT numeric(24,6);
ALTER TABLE R5OBJECTS ADD COLUMN OBJ_IMAGEURL nvarchar(1000);

ALTER TABLE R5UCODES ADD COLUMN UCO_NOTUSED nvarchar(1);
ALTER TABLE R5UCODES ADD COLUMN UCO_ICON nvarchar(30);
ALTER TABLE R5UCODES ADD COLUMN UCO_ICONPATH nvarchar(1000);
ALTER TABLE R5UCODES ADD COLUMN UCO_WEIGHT numeric(24,6);
ALTER TABLE R5UCODES ADD COLUMN UCO_COLOR nvarchar(6);

ALTER TABLE R5TASKS ADD COLUMN TSK_COMPLOCATION nvarchar(80);

ALTER TABLE R5ACTIVITIES ADD COLUMN ACT_COMPLOCATION nvarchar(80);

ALTER TABLE R5STRUCTURES ADD COLUMN STC_ROLLDOWN	nvarchar(1);
ALTER TABLE R5STRUCTURES ADD COLUMN STC_ROLLUP	nvarchar(1);
ALTER TABLE R5STRUCTURES ADD COLUMN STC_EQUIVALENT	nvarchar(1);
ALTER TABLE R5STRUCTURES ADD COLUMN STC_DOWNTIME	nvarchar(1);


ALTER TABLE R5EVENTS ADD COLUMN EVT_MP nvarchar(30);
ALTER TABLE R5EVENTS ADD COLUMN EVT_MP_SEQ numeric(8,0);

--Local table for component location
CREATE TABLE R5COMPONENTLOCATIONS (
	COMPLOCATION	nvarchar(80) NOT NULL,
	DMLTYPE             nchar(1) NULL DEFAULT ('N'),
	PRIMARY KEY (COMPLOCATION)
);

INSERT INTO "R5SYSCOLUMNS" VALUES('R5COMPONENTLOCATIONS','COMPLOCATION','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

CREATE TABLE R5REPAIRBINS (
	RPB_PK	int NOT NULL,
	RPB_REQ	nvarchar(30),
	RPB_REQLINE	numeric(8,0),
	RPB_EVENT	nvarchar(30),
	RPB_STORE	nvarchar(15),
	RPB_PART	nvarchar(30),
	RPB_PART_ORG	nvarchar(15),
	RPB_BIN		nvarchar(15),
	RPB_LOT		nvarchar(12),
	RPB_OBJECT	nvarchar(30),	
	RPB_OBJECT_ORG	nvarchar(15),
	RPB_QTY		numeric(24,6),
	DMLTYPE             nchar(1) NULL DEFAULT ('N'),
	PRIMARY KEY (RPB_PK)
);
INSERT INTO "R5SYSCOLUMNS" VALUES('R5REPAIRBINS','RPB_PK','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

-- list entities
INSERT INTO "R5LISTENTITY" VALUES ('BCBOIL_EXT_IPAD',19,NULL,NULL,NULL,NULL,2,NULL,'R5BOILERTEXTS',NULL,NULL,'parameter.language','+','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('BCCMPLOC_IPAD',177,NULL,NULL,NULL,NULL,6,NULL,'R5COMPONENTLOCATIONS',NULL,NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('SCREBIN_IPAD',178,NULL,NULL,NULL,NULL,6,NULL,'R5REPAIRBINS',NULL,NULL,NULL,'-','-',NULL,NULL,NULL);
UPDATE R5LISTENTITY SET LET_DATAGRID = 'OCOBJC_FULL_IPAD' WHERE LET_DATAGRID = 'OCOBJC_IPAD';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'OCCATLOC_FULL_IPAD' WHERE LET_DATAGRID = 'OCCATLOC_IPAD';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'BCUCOD_IPAD' WHERE LET_DATAGRID='BCUCOD';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'WCTASK_FULL_IPAD' WHERE LET_DATAGRID='WCTASK_IPAD';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'WCACTJ_FULL_IPAD' WHERE LET_DATAGRID='WCACTJ_IPAD';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'OCSTRU_FULL_IPAD' WHERE LET_DATAGRID='OCSTRU';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'WCJOBS_FULL_IPAD' WHERE LET_DATAGRID='WCJOBS_IPAD';

-- new equipment screen
insert into  r5configsettings (CFS_CODE,CFS_GROUP,CFS_USER,CFS_COMPTYPE,CFS_CONFIG,CFS_XMLCONFIG,CFS_UPDATED,CFS_DESK)
values('TCOBJA_IPAD','*','*','U',1, '{
	"sections": [{
		"name": "Equipment",
		"fields": [{
			"id": "OBJ_OBTYPE",
			"lbl": "Type",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "YES",
			"len": "30",
			"hid": "NO"
		}, {
			"id": "OBJ_CODE",
			"lbl": "Equipment",
			"type": "CHAR",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}, {
			"id": "OBJ_DESC",
			"lbl": "Description",
			"type": "CHAR",
			"def": "",
			"ro": "NO",
			"rq": "YES",
			"len": "80",
			"hid": "NO"
		}, {
			"id": "OBJ_ORG",
			"lbl": "Organization",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "YES",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_STATUS",
			"lbl": "Status",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "YES",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_MRC",
			"lbl": "Department",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "YES",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_CLASS",
			"lbl": "Class",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_CATEGORY",
			"lbl": "Category",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_COSTCODE",
			"lbl": "Cost Code",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_COMMISS",
			"lbl": "Commission Date",
			"type": "DATE",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_CRITICALITY",
			"lbl": "Criticality",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_DORMSTART",
			"lbl": "Dormant Start",
			"type": "DATE",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_DORMEND",
			"lbl": "Dormant End",
			"type": "DATE",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_SYSLEVEL",
			"lbl": "System Level",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_ASMLEVEL",
			"lbl": "Assembly Level",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_COMPLEVEL",
			"lbl": "Component Level",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_VMRS_DESC",
			"lbl": "VMRS Description",
			"type": "CHAR",
			"def": "",
			"ro": "YES",
			"rq": "NO",
			"len": "80",
			"hid": "NO"
		}, {
			"id": "OBJ_COMPLOCATION",
			"lbl": "Component Location",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}, {
			"id": "OBJ_PROFILE",
			"lbl": "Profile",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		},{
			"id": "OBJ_SAFETY",
			"lbl": "Safety",
			"type": "BOOL",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		},{
			"id": "OBJ_NOTUSED",
			"lbl": "Out of Service",
			"type": "BOOL",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}]
	}, {
		"name": "Tracking Details",
		"fields": [{
			"id": "OBJ_MANUFACT",
			"lbl": "Manufacturer",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_SERIALNO",
			"lbl": "Serial Number",
			"type": "CHAR",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_MANUFACTMODEL",
			"lbl": "Model",
			"type": "CHAR",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}]
	}, {
		"name": "Part Association",
		"fields": [{
			"id": "OBJ_PART",
			"lbl": "Part",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_STORE",
			"lbl": "Store",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_BIN",
			"lbl": "Bin",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_LOT",
			"lbl": "Lot",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}]
	}, {
		"name": "Hierarchy",
		"fields": [{
			"id": "OBJ_PARENT",
			"lbl": "Parent Asset",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}, {
			"id": "OBJ_PARENT_DEPEND",
			"lbl": "Dependent",
			"type": "BOOL",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "2",
			"hid": "NO"
		}, {
			"id": "OBJ_PARENT_COST_ROLL_UP",
			"lbl": "Cost Roll-up",
			"type": "BOOL",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "2",
			"hid": "NO"
		}, {
			"id": "OBJ_POSITION",
			"lbl": "Position",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}, {
			"id": "OBJ_POSITION_DEPEND",
			"lbl": "Dependent",
			"type": "BOOL",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "2",
			"hid": "NO"
		}, {
			"id": "OBJ_POSITION_COST_ROLL_UP",
			"lbl": "Cost Roll-up",
			"type": "BOOL",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "2",
			"hid": "NO"
		}, {
			"id": "OBJ_LOCATION",
			"lbl": "Location",
			"type": "LOV-1",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}]
	}, {
		"name": "GIS Details",
		"fields": [{
			"id": "OBJ_GISOBJID",
			"lbl": "GIS ID",
			"type": "CHAR",
			"def": "",
			"ro": "YES",
			"rq": "NO",
			"len": "38",
			"hid": "NO"
		}, {
			"id": "OBJ_GISLAYER",
			"lbl": "Layer",
			"type": "CHAR",
			"def": "",
			"ro": "YES",
			"rq": "NO",
			"len": "60",
			"hid": "NO"
		}, {
			"id": "OBJ_GISMAP",
			"lbl": "Map",
			"type": "CHAR",
			"def": "",
			"ro": "YES",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}, {
			"id": "OBJ_GISMAP_ORG",
			"lbl": "Map Org.",
			"type": "CHAR",
			"def": "",
			"ro": "YES",
			"rq": "NO",
			"len": "15",
			"hid": "NO"
		}, {
			"id": "OBJ_XLOCATION",
			"lbl": "Location X",
			"type": "NUM",
			"def": "",
			"ro": "YES",
			"rq": "NO",
			"len": "24",
			"hid": "NO"
		}, {
			"id": "OBJ_YLOCATION",
			"lbl": "Location Y",
			"type": "NUM",
			"def": "",
			"ro": "YES",
			"rq": "NO",
			"len": "24",
			"hid": "NO"
		}]
	}, {
		"name": "Linear Reference Details",
		"fields": [{
			"id": "OBJ_LENGTH",
			"lbl": "Equipment Length",
			"type": "NUM",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "24",
			"hid": "NO"
		}, {
			"id": "OBJ_LENGTHUOM",
			"lbl": "Equip. Length UOM",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "10",
			"hid": "NO"
		}, {
			"id": "OBJ_LINEARREFUOM",
			"lbl": "Linear Ref. UOM",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "10",
			"hid": "NO"
		}, {
			"id": "OBJ_LINEARREFPRECISION",
			"lbl": "Ref. Precision",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "2",
			"hid": "NO"
		}, {
			"id": "OBJ_GEOREF",
			"lbl": "Geographical Ref.",
			"type": "CHAR",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "1000",
			"hid": "NO"
		}, {
			"id": "OBJ_INSPECTIONDIRECTION",
			"lbl": "Inspection Direction",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}, {
			"id": "OBJ_FLOW",
			"lbl": "Flow",
			"type": "PICKER",
			"def": "",
			"ro": "NO",
			"rq": "NO",
			"len": "30",
			"hid": "NO"
		}]
	}]
}',NULL,1);


UPDATE R5APPSETTINGS SET AST_VALUE = '11203' WHERE AST_NAME='DBVERSION';

