CREATE TABLE R5USERLINEARPREFERENCES(
				ULP_USERCODE nvarchar(30) NOT NULL,
                ULP_LOLINEARREF nvarchar(1) NULL,
                ULP_LOPOINTSOFINT nvarchar(1) NULL,
                ULP_LORELATEDEQ nvarchar(1) NULL,
                ULP_LORELATEDPART nvarchar(1) NULL,
                ULP_LODEFAULTCOLOR nvarchar(6) NULL,
                ULP_LODEFAULTFILTER nvarchar(4) NULL,
                ULP_LOINCLUDERELATED nvarchar(1) NULL,            
                DMLTYPE nchar(1) NULL DEFAULT ('N'),
                PRIMARY KEY(ULP_USERCODE));

CREATE TABLE R5UDGTABLES (
UDG_TABLE VARCHAR(30) NOT NULL,
PRIMARY KEY (UDG_TABLE)
);

CREATE TABLE R5CREWS (
CRW_CODE        nvarchar(15) NOT NULL,
CRW_DESC         nvarchar(80) NOT NULL,
CRW_ORG          nvarchar(15) NOT NULL,
CRW_CLASS       nvarchar(8),
CRW_CLASS_ORG           nvarchar(15),
CRW_NOTUSED                nvarchar(1),
CRW_SCHEDGROUP       nvarchar(30),
DMLTYPE             nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (CRW_CODE, CRW_ORG));

CREATE TABLE R5CREWEMPLOYEES (
CRE_PK                                numeric(38, 0)   NOT NULL,
CRE_CREW          nvarchar(15)      NOT NULL,
CRE_CREW_ORG              nvarchar(15)      NOT NULL,
CRE_PERSON     nvarchar(15),
CRE_START         datetime,
CRE_END             datetime,
DMLTYPE             nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (CRE_PK)
);
CREATE TABLE R5MRCTOOLS (
MRT_MRC          nvarchar(15) NOT NULL,
MRT_TOOL         nvarchar(12) NOT NULL,
MRT_QTY            numeric(24,6),
MRT_TARIFF      numeric(24,6),
MRT_HOURS     numeric(5,2),
MRT_ORG           nvarchar(15) NOT NULL,
DMLTYPE             nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (MRT_MRC, MRT_TOOL, MRT_ORG)
);

CREATE TABLE R5GRIDCACHE (
GRC_GRIDNAME nvarchar(20) NOT NULL,
GRC_TABLENAME nvarchar(60) NOT NULL,
GRC_DELINSUPD nvarchar(2) NOT NULL,
GRC_TEXT BLOB NOT NULL
);


CREATE TABLE R5TOOLUSAGE (
TOU_MRC nvarchar(15) NOT NULL,
TOU_TOOL nvarchar(12) NOT NULL,
TOU_EVENT nvarchar(30) NOT NULL,
TOU_ACT numeric(8,0) NOT NULL,
TOU_DATEBOOKED datetime NULL,
TOU_DATEUSED datetime NOT NULL,
TOU_HOURS numeric(12,2) NULL, 
TOU_TARIFF numeric(24,6) NULL,
TOU_COST numeric(24,6) NULL,
TOU_QTY numeric(24,6) NULL,
TOU_GLTRANSFERFLAG nvarchar(1) NULL,
TOU_TRANSCODE nvarchar(4) NULL,
TOU_TRANSORGID int NULL,
TOU_TRANSGROUP int NULL,
TOU_ACD int NULL,
TOU_GLTRANSFER datetime NULL,
TOU_ORIGHOURS numeric(12,2) NULL,
TOU_ROUTEREC nvarchar(1) NULL,
TOU_JECATEGORY nvarchar(25) NULL,
TOU_JESOURCE nvarchar(25) NULL,
TOU_SPLITUSAGE nvarchar(1) NULL,
TOU_ALIAS nvarchar(45) NULL,
TOU_INVOICE nvarchar(30) NULL,
TOU_INVOICE_ORG nvarchar(15) NULL,
TOU_INVOICE_REVISION numeric(8,0) NULL,
TOU_INVOICELINE numeric(8,0) NULL,
DMLTYPE nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (TOU_MRC, TOU_TOOL, TOU_EVENT, TOU_ACT, TOU_DATEUSED)
);

CREATE TABLE R5TOOLS (
TOO_CODE            nvarchar(12) NOT NULL,
TOO_DESC            nvarchar(80) NULL,
TOO_CLASS           nvarchar(8) NULL,
TOO_ORG               nvarchar(15)  NULL,
TOO_CLASS_ORG  nvarchar(15) NULL,
DMLTYPE             nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (TOO_CODE)
);


CREATE TABLE R5TOOLPLAN (
TPL_TOOL              nvarchar(12) NOT NULL,
TPL_EVENT            nvarchar(30) NOT NULL,
TPL_ACT                numeric(8,0) NOT NULL,
TPL_MRC               nvarchar(15) NOT NULL,
TPL_QTY                numeric(24,6) NULL,
TPL_HOURS           numeric(12,2) NULL,
DMLTYPE               nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (TPL_TOOL,TPL_EVENT, TPL_ACT, TPL_MRC)
);

--new table for r5objlinearref

CREATE TABLE R5OBJLINEARREF(
LRF_ID numeric(38, 0) NOT NULL,
LRF_OBJCODE nvarchar(30) NULL,
LRF_OBJORG nvarchar(15) NULL,
LRF_REFRTYPE nvarchar(4) NULL,
LRF_REFTYPE nvarchar(4) NULL,
LRF_REFDESC nvarchar(80) NULL,
LRF_RE_OBJCODE nvarchar(30) NULL,
LRF_RE_OBJORG nvarchar(15) NULL,
LRF_FROMPOINT numeric(24, 6) NULL,
LRF_TOPOINT numeric(24, 6) NULL,
LRF_GEOREF nvarchar(1000) NULL,
LRF_CREATED datetime NULL,
LRF_UPDATED datetime NULL,
LRF_CLASS nvarchar(8) NULL,
LRF_CLASS_ORG nvarchar(15) NULL,
LRF_PART nvarchar(30) NULL,
LRF_PART_ORG nvarchar(15) NULL,
LRF_CONDITION nvarchar(20) NULL,
LRF_DATEEFFECTIVE datetime NULL,
LRF_DATEEXPIRED datetime NULL,
LRF_INSPECTIONDIRECTION nvarchar(8) NULL,
LRF_FLOW nvarchar(8) NULL,
LRF_APPLYTOCHILDREN nvarchar(1) NULL,
LRF_REPEATEVERYLENGTH numeric(24, 6) NULL,
LRF_REPEATEVERYUOM nvarchar(10) NULL,
LRF_STARTINGSEQUENCE numeric(18, 0) NULL,
LRF_SETID nvarchar(30) NULL,
LRF_DISPLAYONOVERVIEW nvarchar(1) NULL,
LRF_COLOR nvarchar(6) NULL,
LRF_ICON nvarchar(30) NULL,
LRF_ICONPATH nvarchar(1000) NULL,
LRF_RELATIONSHIPTYPE nvarchar(8) NULL,
LRF_HORIZONTALOFFSET numeric(24, 6) NULL,
LRF_HORIZONTALOFFSETUOM nvarchar(10) NULL,
LRF_HORIZONTALOFFSETTYPE nvarchar(8) NULL,
LRF_VERTICALOFFSET numeric(24, 6) NULL,
LRF_VERTICALOFFSETUOM nvarchar(10) NULL,
LRF_VERTICALOFFSETTYPE nvarchar(8) NULL,
LRF_QTYPERUOM numeric(24, 6) NULL,
LRF_QTYUOM nvarchar(10) NULL,
LRF_WIDTH numeric(24, 6) NULL,
LRF_WIDTHUOM nvarchar(10) NULL,
LRF_HEIGHT numeric(24, 6) NULL,
LRF_HEIGHTUOM nvarchar(10) NULL,
LRF_CREATEDBY nvarchar(30) NULL,
LRF_UPDATEDBY nvarchar(30) NULL,
DMLTYPE  nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (LRF_ID)
);

--UOM conversion Table

create table R5UOMConversionMobile(fromuom nvarchar(30), touom nvarchar(30),value numeric(24,18), PRIMARY KEY(fromuom,touom));

insert into R5UOMConversionMobile(fromuom,touom,value) values('FEET','FEET',1.0);
insert into R5UOMConversionMobile(fromuom,touom,value) values('FEET','METERS',0.3048);
insert into R5UOMConversionMobile(fromuom,touom,value) values('FEET','KILOMETERS',0.0003048);
insert into R5UOMConversionMobile(fromuom,touom,value) values('FEET','MILES',0.000189394);

insert into R5UOMConversionMobile(fromuom,touom,value) values('METERS','FEET',3.28083989501312);
insert into R5UOMConversionMobile(fromuom,touom,value) values('METERS','METERS',1);
insert into R5UOMConversionMobile(fromuom,touom,value) values('METERS','KILOMETERS',0.001);
insert into R5UOMConversionMobile(fromuom,touom,value) values('METERS','MILES',0.000621371192);

insert into R5UOMConversionMobile(fromuom,touom,value) values('KILOMETERS','FEET',3280.83989501312);
insert into R5UOMConversionMobile(fromuom,touom,value) values('KILOMETERS','METERS',1000);
insert into R5UOMConversionMobile(fromuom,touom,value) values('KILOMETERS','KILOMETERS',1);
insert into R5UOMConversionMobile(fromuom,touom,value) values('KILOMETERS','MILES',0.621371192);

insert into R5UOMConversionMobile(fromuom,touom,value) values('MILES','FEET',5280);
insert into R5UOMConversionMobile(fromuom,touom,value) values('MILES','METERS',1609.344);
insert into R5UOMConversionMobile(fromuom,touom,value) values('MILES','KILOMETERS',1.609344);
insert into R5UOMConversionMobile(fromuom,touom,value) values('MILES','MILES',1);


--ALTER STATEMENTS ------------------------------------------------------------
ALTER TABLE R5PROPERTYVALUES ADD COLUMN PRV_NOTUSED varchar(1);
--R5EVENTOBJECTS
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_EVENT_DESC  nvarchar(80);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_FROMPOINT numeric(24,6);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_TOPOINT numeric(24,6);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_MRC nvarchar(15);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_TARGET datetime;
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_RSTATUS nvarchar(4);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_JOBTYPE nvarchar(8);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_CLASS nvarchar(8);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_CLASS_ORG nvarchar(15);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_PRIORITY nvarchar(8);
ALTER TABLE R5EVENTOBJECTS ADD COLUMN EOB_REPORTED datetime;

--R5OBJLINEARREF
ALTER TABLE R5OBJLINEARREF ADD COLUMN LRF_SEQUENCE numeric(24,6);

--Oct 12 2016------------------
ALTER TABLE R5CLASSES ADD COLUMN CLS_ICON nvarchar(30);
ALTER TABLE R5CLASSES ADD COLUMN CLS_ICONPATH nvarchar(1000);
-----------------Oct 12 2016------------------------

ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_PARENT NVARCHAR(1);
ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_CHILD NVARCHAR(1);
ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_SINCEINSTALL NUMERIC(24,6);
ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_SINCELASTWORK NUMERIC(24,6);
ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_CREATED DATETIME;
ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_UPDATED DATETIME;
ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_UPDOWNMETER NVARCHAR(1);
---Oct 14 ------------------
--ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN OUD_TYPEOFMETER VARCHAR(20);
--ALTER TABLE R5OBJUSAGEDEFS ADD COLUMN MET_MAX NUMERIC(24,6);
ALTER TABLE R5READINGS ADD COLUMN REA_RELATEDEVENT NVARCHAR(30);
ALTER TABLE R5READINGS ADD COLUMN REA_OBTYPE NVARCHAR(4);
ALTER TABLE R5READINGS ADD COLUMN REA_OBRTYPE NVARCHAR(4);
ALTER TABLE R5READINGS ADD COLUMN REA_CREATED DATETIME;
ALTER TABLE R5READINGS ADD COLUMN REA_UPDATED DATETIME;
ALTER TABLE R5READINGS ADD COLUMN REA_EVENT NVARCHAR(30);
--ALTER TABLE R5READINGS ADD COLUMN REA_PARENT NVARCHAR(30);
ALTER TABLE R5READINGS ADD COLUMN REA_TYPE NVARCHAR(1);
 


---------R5ACTSCHEDULES-----------------------------------------------------------
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_MRC nvarchar(15);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_TRADE nvarchar(15);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_OBJECT nvarchar(30);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_STARTTIME numeric(24,6);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_ENDTIME numeric(24,6);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_HOURS  numeric(24,6);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_SHIFT nvarchar(4);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_SCHEDULER  nvarchar(30);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_FROZEN nvarchar(1);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_OBJECT_ORG nvarchar(15);
ALTER TABLE R5ACTSCHEDULES ADD COLUMN  ACS_SHIFTSCHEDULESESSION numeric(18,0);


--R5events table
ALTER TABLE R5EVENTS ADD COLUMN EVT_FROMPOINT numeric(13,24);
ALTER TABLE R5EVENTS ADD COLUMN EVT_FROMREFDESC nvarchar(160);
ALTER TABLE R5EVENTS ADD COLUMN EVT_FROMGEOREF nvarchar(2000);
ALTER TABLE R5EVENTS ADD COLUMN EVT_TOPOINT numeric(13,24);
ALTER TABLE R5EVENTS ADD COLUMN EVT_TOREFDESC nvarchar(160);
ALTER TABLE R5EVENTS ADD COLUMN EVT_TOGEOREF nvarchar(2000);
ALTER TABLE R5EVENTS ADD COLUMN EVT_FLOW nvarchar(16);
ALTER TABLE R5EVENTS ADD COLUMN EVT_INSPECTIONDIRECTION nvarchar(16);

--R5ACTIVITIES table
ALTER TABLE R5ACTIVITIES ADD COLUMN ACT_FROMPOINT numeric(13,24);
ALTER TABLE R5ACTIVITIES ADD COLUMN ACT_FROMREFDESC nvarchar(160);
ALTER TABLE R5ACTIVITIES ADD COLUMN ACT_FROMGEOREF nvarchar(2000);
ALTER TABLE R5ACTIVITIES ADD COLUMN ACT_TOPOINT numeric(13,24);
ALTER TABLE R5ACTIVITIES ADD COLUMN ACT_TOREFDESC nvarchar(160);
ALTER TABLE R5ACTIVITIES ADD COLUMN ACT_TOGEOREF nvarchar(2000);

--R5EVENTPOINTS
ALTER TABLE R5EVENTPOINTS ADD COLUMN EPO_OBTYPE nvarchar(4);
ALTER TABLE R5EVENTPOINTS ADD COLUMN EPO_FROMPOINT numeric(13,24);
ALTER TABLE R5EVENTPOINTS ADD COLUMN EPO_FROMREFDESC nvarchar(160);
ALTER TABLE R5EVENTPOINTS ADD COLUMN EPO_FROMGEOREF nvarchar(2000);
ALTER TABLE R5EVENTPOINTS ADD COLUMN EPO_TOPOINT numeric(13,24);
ALTER TABLE R5EVENTPOINTS ADD COLUMN EPO_TOREFDESC nvarchar(160);
ALTER TABLE R5EVENTPOINTS ADD COLUMN EPO_TOGEOREF nvarchar(2000);

--R5ACTCHECKLISTS
ALTER TABLE R5ACTCHECKLISTS ADD COLUMN ACK_FROMPOINT numeric(13,24);
ALTER TABLE R5ACTCHECKLISTS ADD COLUMN ACK_FROMREFDESC nvarchar(160);
ALTER TABLE R5ACTCHECKLISTS ADD COLUMN ACK_FROMGEOREF nvarchar(2000);
ALTER TABLE R5ACTCHECKLISTS ADD COLUMN ACK_TOPOINT numeric(13,24);
ALTER TABLE R5ACTCHECKLISTS ADD COLUMN ACK_TOREFDESC nvarchar(160);
ALTER TABLE R5ACTCHECKLISTS ADD COLUMN ACK_TOGEOREF nvarchar(2000);

---PRIMARY KEY ADDITIONS-----------------------------------------
INSERT INTO "R5SYSCOLUMNS" VALUES('R5USERLINEARPREFERENCES','ULP_USERCODE','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5CREWEMPLOYEES','CRE_PK','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5CREWS','CRW_CODE','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5CREWS','CRW_ORG','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

INSERT INTO "R5SYSCOLUMNS" VALUES('R5MRCTOOLS','MRT_MRC','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5MRCTOOLS','MRT_TOOL','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5MRCTOOLS','MRT_ORG','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');


INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLUSAGE','TOU_MRC','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLUSAGE','TOU_TOOL','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLUSAGE','TOU_EVENT','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLUSAGE','TOU_ACT','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLUSAGE','TOU_DATEUSED','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLS','TOO_CODE','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLPLAN','TPL_TOOL','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLPLAN','TPL_EVENT','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLPLAN','TPL_ACT','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5TOOLPLAN','TPL_MRC','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

INSERT INTO "R5SYSCOLUMNS" VALUES('R5OBJLINEARREF','LRF_ID','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

INSERT INTO "R5SYSCOLUMNS" VALUES('R5UOMConversionMobile','fromuom','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO "R5SYSCOLUMNS" VALUES('R5UOMConversionMobile','touom','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
-------------------------------------------------------------
---R5CONFIGSETTINGS ADDITIONS------------------
INSERT INTO R5CONFIGSETTINGS (CFS_CODE,CFS_GROUP,CFS_USER,CFS_COMPTYPE,CFS_CONFIG,CFS_DESK,CFS_XMLCONFIG,CFS_UPDATED,CFS_USERTAG,DMLTYPE)
VALUES('TCJSCH_IPAD','*','*','U','1','1','{"sections" :[{"name"   : "Schedule Labor","fields" :  [{"id":"ACS_ACTIVITY","lbl":"Activity","type":"LOV-1","def":"","ro":"YES","rq":"YES","len":"","hid":"NO"},{"id":"ACS_RESPONSIBLE","lbl":"Employee","type":"LOV-1","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"ACS_SCHED","lbl":"Scheduled Date","type":"DATE","def":"","ro":"NO","rq":"YES","len":"30","hid":"NO"},{"id":"ACS_HOURS","lbl":"Scheduled Hours","type":"NUM","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"ACS_SCHEDULER","lbl":"Scheduled By","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"ACS_TRADE","lbl":"Trade","type":"LOV-1","def":"","ro":"NO","rq":"YES","len":"30","hid":"NO"},{"id":"ACS_SHIFT","lbl":"Shift","type":"LOV-1","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"ACS_EST_HRS","lbl":"Act. Sched. Hours","type":"CHAR","def":"","ro":"YES","rq":"NO","len":"30","hid":"NO"},{"id":"ACS_ACT_HRS","lbl":"Act. Actual Hours","type":"CHAR","def":"","ro":"YES","rq":"NO","len":"30","hid":"NO"}]}]}','2016-10-06','1','N');


INSERT INTO R5CONFIGSETTINGS VALUES ('TCJTOU_IPAD','*','*','U','1','1','{"sections": [{"name": "","fields": [{"id": "TOU_TOOL","lbl": "Tool","type": "LOV-1","def": "", "ro": "NO","rq": "YES","len": "","hid": "NO"},{"id": "TOU_EQUIP","lbl": "Equipment","type": "LOV-1","def": "","ro": "NO","rq": "NO","len": "","hid": "NO"},{"id":"TOU_RELATED_WO","lbl":"Related Work Order","type":"CHAR","def":"","ro":"YES","rq":"NO","len":"20","hid":"NO"
},{"id": "TOU_MRC","lbl": "Department","type": "LOV-1","def": "","ro": "NO","rq": "YES","len": "","hid": "NO"},{"id": "TOU_DATEUSED","lbl": "Date Used","type": "DATI","def": "","ro": "NO","rq": "YES","len": "","hid": "NO"},{"id": "TOU_ACT","lbl": "Activity","type": "CHAR","def": "","ro": "YES","rq": "YES","len": "","hid": "NO"},{"id": "TOU_QTY","lbl": "Quantity","type": "NUM","def": "","ro": "NO","rq": "YES","len": "","hid": "NO"},{"id": "TOU_HOURS","lbl": "Hours Used","type": "NUM","def": "","ro": "NO","rq": "YES","len": "","hid": "NO"},{"id": "TOU_TARIFF","lbl": "Rate", "type": "CHAR","def": "","ro": "YES","rq": "NO","len": "","hid": "NO"},{"id": "TOU_COST","lbl": "Cost","type": "CHAR","def": "","ro": "YES","rq": "NO","len": "","hid": "NO"}]}]}','2016-09-30','1','N');

insert into r5configsettings (CFS_CODE,CFS_GROUP,CFS_USER,CFS_COMPTYPE,CFS_CONFIG,CFS_DESK,CFS_XMLCONFIG,CFS_USERTAG,DMLTYPE) values
('TCJWOEQR_IPAD','*','*','U',1,1,'{"sections":[{ "name":"Equipment", "fields":[{"id":"EVT_OBJECT", "lbl":"Equipment", "type":"LOV-1", "def":"", "ro":"NO", "rq":"YES", "len":"30", "hid":"NO" }, {"id":"EVT_OBJECT_DESC", "lbl":"Description", "type":"CHAR", "def":"", "ro":"YES", "rq":"NO", "len":"80", "hid":"NO" }, {"id":"EVT_OBTYPE", "lbl":"Type", "type":"CHAR", "def":"", "ro":"YES", "rq":"NO", "len":"8", "hid":"YES" }, {"id":"EVT_MRC", "lbl":"Department", "type":"LOV-1", "def":"", "ro":"NO", "rq":"YES", "len":"15", "hid":"YES" }, {"id":"EVT_LOCATION", "lbl":"Location", "type":"LOV-1", "def":"", "ro":"NO", "rq":"NO", "len":"30", "hid":"YES" }, {"id":"EVT_COSTCODE", "lbl":"Cost Code", "type":"LOV-1", "def":"", "ro":"NO", "rq":"NO", "len":"30", "hid":"YES" }, {"id":"EVT_SAFETY", "lbl":"Safety", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"2", "hid":"YES" }, {"id":"EVT_WARRANTY", "lbl":"Warranty", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"2", "hid":"YES" },{"id":"EVT_CODE", "lbl":"Related Work Order", "type":"CHAR", "def":"", "ro":"YES", "rq":"NO", "len":"30", "hid":"YES" }, {"id":"EVT_STATUS", "lbl":"Status", "type":"CHAR", "def":"", "ro":"YES", "rq":"NO", "len":"8", "hid":"YES" },{"id":"EVT_FROMPOINT","lbl":"From Point","type":"LOV-3","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"EVT_FROMREFDESC","lbl":"Ref. Description","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},{"id":"EVT_FROMGEOREF","lbl":"Geographical Ref.","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},{"id":"EVT_TOPOINT","lbl":"To Point","type":"LOV-3","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"EVT_TOREFDESC","lbl":"Ref. Description","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},{"id":"EVT_TOGEOREF","lbl":"Geographical Ref.","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},{"id":"EVT_INSPECTIONDIRECTION","lbl":"Inspection Direction","type":"PICKER","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"EVT_FLOW","lbl":"Flow", "type":"PICKER","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"}]}]}',0,'N')


INSERT INTO R5CONFIGSETTINGS (CFS_CODE,CFS_GROUP,CFS_USER,CFS_COMPTYPE,CFS_CONFIG,CFS_DESK,CFS_XMLCONFIG,CFS_UPDATED,CFS_USERTAG,DMLTYPE)
VALUES('TCMETR_IPAD','*','*','U','1','1','{"sections" :[{"name":"Meter Details","fields": 
 [{"id":"OUD_UOM","lbl":"UOM","type":"LOV-2","def":"","ro":"NO","rq":"YES","len":"3","hid":"NO"},
{"id":"OUD_TYPEOFMETER","lbl":"Type of Meter","type":"PICKER","def":"","ro":"NO","rq":"YES","len":"80","hid":"NO"},
{"id":"OUD_METER","lbl":"Physical Meter","type":"LOV-2","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},
{"id":"OUD_TOTALUSAGE","lbl":"Total Usage","type":"NUM","def":"","ro":"NO","rq":"NO","len":"15","hid":"NO"},
{"id":"MET_MAX","lbl":"Meter Rollover","type":"NUM","def":"","ro":"YES","rq":"NO","len":"8","hid":"NO"},
{"id":"OUD_SINCEINSTALL","lbl":"Usage Since Install","type":"NUM","def":"","ro":"NO","rq":"NO","len":"20","hid":"NO"},
{"id":"OUD_READDATE","lbl":"Last Reading Date","type":"DATE","def":"","ro":"YES","rq":"NO","len":"20","hid":"NO"},
{"id":"OUD_SINCELASTWORK","lbl":"Usage Since Last WO","type":"NUM","def":"","ro":"YES","rq":"NO","len":"80","hid":"NO"},
{"id":"OUD_UPDOWNMETER","lbl":"Up/Down Meter","type":"BOOL","def":"","ro":"NO","rq":"NO","len":"2","hid":"NO"}]}]}',
'2016-09-19','1','N') ;



INSERT INTO R5CONFIGSETTINGS (CFS_CODE,CFS_GROUP,CFS_USER,CFS_COMPTYPE,CFS_CONFIG,CFS_DESK,CFS_XMLCONFIG,CFS_UPDATED,CFS_USERTAG,DMLTYPE)
VALUES('TCREAD_IPAD','*','*','U','1','1','{"sections" :[{"name" : "Meter Reading","fields" :  
[{"id":"REA_METER","lbl":"Physical Meter","type":"CHAR","def":"","ro":"YES","rq":"NO","len":"80","hid":"NO"},
{"id":"REA_UOM","lbl":"UOM","type":"CHAR","def":"","ro":"YES","rq":"NO","len":"80","hid":"NO"},
{"id":"REA_LASTREADING","lbl":"Last Reading","type":"NUM","def":"","ro":"YES","rq":"NO","len":"30","hid":"NO"},
{"id":"REA_TYPE","lbl":"Entity Type","type":"PICKER","def":"","ro":"NO","rq":"YES","len":"80","hid":"NO"},
{"id":"REA_DATE","lbl":"Date/Time","type":"DATI","def":"","ro":"NO","rq":"YES","len":"80","hid":"NO"},
{"id":"REA_READING","lbl":"Value","type":"NUM","def":"","ro":"NO","rq":"YES","len":"30","hid":"NO"},
{"id":"REA_EVENT","lbl":"Work Order","type":"LOV-1","def":"","ro":"NO","rq":"NO","len":"15","hid":"NO"},
{"id":"REA_RELATEDEVENT","lbl":"Related Work Order","type":"NUM","def":"","ro":"YES","rq":"NO","len":"15","hid":"NO"}]}]}',
'2016-09-29','1','N')


INSERT INTO R5CONFIGSETTINGS (CFS_CODE,CFS_GROUP,CFS_USER,CFS_COMPTYPE,CFS_CONFIG,CFS_DESK,CFS_XMLCONFIG,CFS_UPDATED,CFS_USERTAG,DMLTYPE)
VALUES('TCJTPL_IPAD','*','*','U','1','1','{"sections": [{"name":"Tool Plan","fields": [{"id":"TPL_ACT","lbl":"Activity","type":"LOV-1","def":"","ro":"YES","rq":"NO","len":"","hid":"NO"},{ "id":"TPL_TOOL","lbl":"Tool","type":"LOV-2","def":"","ro":"NO","rq":"YES","len":"","hid":"NO"}, {"id":"TPL_HOURS","lbl":"Hours Requested","type":"NUM","def":"","ro":"NO","rq":"YES","len":"","hid":"NO"},{"id":"TPL_QTY","lbl":"Qty. Required","type":"NUM","def":"","ro":"NO","rq":"YES","len":"","hid":"NO"},{"id":"TPL_TOTAL_HOURS_REQUIRED","lbl":"Total Hours Required","type":"CHAR","def":"","ro":"NO","rq":"YES","len":"","hid":"NO"},{"id":"TPL_ACT_DURATION","lbl":"Activity Duration","type":"CHAR","def":"","ro":"NO","rq":"YES","len":"","hid":"NO"},{"id":"TPL_MRC","lbl":"Department","type":"LOV-1","def":"","ro":"NO","rq":"YES","len":"","hid":"NO"},{"id":"TPL_DAILY_CAPACITY","lbl":"Daily Capacity","type":"CHAR","def":"","ro":"NO","rq":"YES","len":"","hid":"NO"}]}]}','2016-09-29','1','N');


----Oct 14--------------
-------------------------------------------------------------------
----LISTEntity -------------------------------------------
UPDATE r5listentity SET let_mastertable = NULL WHERE let_datagrid ='WCACTJ_FULL_IPAD';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'BCCLAS_IPAD' WHERE LET_DATAGRID = 'BCCLAS';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'BCPROMV_IPAD' WHERE LET_DATAGRID = 'BCPROMV';
UPDATE R5LISTENTITY SET LET_DATAGRID = 'OCUSGD_IPAD' WHERE LET_DATAGRID = 'OCUSGD';
update r5listentity set let_tablename='R5CREWEMPLOYEES' where let_datagrid='WCCREMP_IPAD'

INSERT INTO "R5LISTENTITY" VALUES('BCCOMPPM_IPAD',99,NULL,NULL,NULL,NULL,3,'WCJOBS','R5ADDETAILS',NULL,NULL,NULL,'-','-',NULL,'R5EVENTS',NULL);
INSERT INTO "R5LISTENTITY" VALUES ('BCSHIFT_IPAD',76,NULL,NULL,NULL,NULL,3,NULL,'R5SHIFTS','SHF_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO R5LISTENTITY(LET_DATAGRID,LET_SEQNO,LET_GROUPID,LET_DELINSUPD,LET_FILTER,
LET_TABLENAME,LET_ORGKEY,LET_CONNECTEDMODE,LET_ALWAYSDOWNLOAD)
VALUES('OCREAD_IPAD',925,0,3,'OCREAD','R5READINGS','REA_OBJECT_ORG','-','-')

INSERT INTO "R5LISTENTITY" VALUES ('OCULPREF_IPAD',185,NULL,NULL,NULL,NULL,3,'OCOBJC','R5USERLINEARPREFERENCES',NULL,NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('WCMRCT_IPAD',180,NULL,NULL,NULL,NULL,3,NULL,'R5MRCTOOLS','MRT_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('WCCREW_IPAD',181,NULL,NULL,NULL,NULL,3,NULL,'R5CREWS','CRW_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('WCCREMP_IPAD',182,NULL,NULL,NULL,NULL,3,NULL,'R5CREWEMPLOYLEES','CRE_CREW_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('OCEQLREF_IPAD',183,NULL,NULL,NULL,NULL,3,'OCOBJC','R5OBJLINEARREF','LRF_OBJORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('OCEVTOBJ_IPAD',184,NULL,NULL,NULL,NULL,3,'OCOBJC','R5EVENTOBJECTS','EOB_EVENT_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);

----Oct 17 2016-----------------
INSERT INTO R5LISTENTITY (LET_DATAGRID, LET_SEQNO, LET_MASK, LET_DOWNCAT, LET_GROUPID, LET_BLOCKSIZE, LET_DELINSUPD, LET_FILTER, LET_TABLENAME, LET_ORGKEY, LET_DOWNGROUP, LET_FILTERPARAMS, LET_CONNECTEDMODE, LET_ALWAYSDOWNLOAD, LET_UPDATED, LET_MASTERTABLE, ROWIDENTITY) VALUES ('GCGRID', 158, NULL, NULL, NULL, NULL, 6, NULL, 'R5GRID', NULL, NULL, NULL, '-', '-', NULL, NULL, NULL);

INSERT INTO R5LISTENTITY (LET_DATAGRID, LET_SEQNO, LET_MASK, LET_DOWNCAT, LET_GROUPID, LET_BLOCKSIZE, LET_DELINSUPD, LET_FILTER, LET_TABLENAME, LET_ORGKEY, LET_DOWNGROUP, LET_FILTERPARAMS, LET_CONNECTEDMODE, LET_ALWAYSDOWNLOAD, LET_UPDATED, LET_MASTERTABLE, ROWIDENTITY) VALUES ('GCDSPY', 159, NULL, NULL, NULL, NULL, 6, NULL, 'R5DDDATASPY', NULL, NULL, NULL, '-', '-', NULL, NULL, NULL);

INSERT INTO R5LISTENTITY (LET_DATAGRID, LET_SEQNO, LET_MASK, LET_DOWNCAT, LET_GROUPID, LET_BLOCKSIZE, LET_DELINSUPD, LET_FILTER, LET_TABLENAME, LET_ORGKEY, LET_DOWNGROUP, LET_FILTERPARAMS, LET_CONNECTEDMODE, LET_ALWAYSDOWNLOAD, LET_UPDATED, LET_MASTERTABLE, ROWIDENTITY) VALUES ('GCQFLD', 160, NULL, NULL, NULL, NULL, 6, NULL, 'R5QUERYFIELD', NULL, NULL, NULL, '-', '-', NULL, NULL, NULL);
------Oct 17 2016--------------------

INSERT INTO "R5LISTENTITY" VALUES ('WCTOOL_IPAD',107,NULL,NULL,NULL,NULL,3,'WCJOBS','R5TOOLS','TOO_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('WCJTPL_IPAD',108,NULL,NULL,NULL,NULL,3,'WCJOBS','R5TOOLPLAN','EVT_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('WCJTOU_IPAD',109,NULL,NULL,NULL,NULL,3,'WCJOBS','R5TOOLUSAGE','EVT_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('WCJTOU_MEC_IPAD',110,NULL,NULL,NULL,NULL,2,'WCJOBS','R5TOOLUSAGE','EVT_ORG',NULL,NULL,'-','-',NULL,NULL,NULL);

UPDATE R5LISTENTITY SET LET_DATAGRID = 'WCSCHED_IPAD' WHERE LET_DATAGRID = 'WCSCHED';

INSERT INTO R5LISTENTITY(LET_DATAGRID,LET_SEQNO,LET_GROUPID,LET_DELINSUPD,LET_FILTER,LET_TABLENAME,LET_ORGKEY,
LET_CONNECTEDMODE,LET_ALWAYSDOWNLOAD)
VALUES('OCMETR',924,0,3,'OCMETR','R5METERS','MET_ORG','-','-');


-------Jan 12, 2017-------------------
UPDATE R5CONFIGSETTINGS
SET CFS_XMLCONFIG='{"sections":[{ "name":"Inspection", "fields":[ {"id":"EPO_OBJECT", "lbl":"Equipment", "type":"LOV-1", "def":"", "ro":"NO", "rq":"YES", "len":"30", "hid":"NO" }, {"id":"EPO_ASPECT", "lbl":"Aspect", "type":"LOV-1", "def":"", "ro":"NO", "rq":"YES", "len":"4", "hid":"NO" }, {"id":"EPO_POINTTYPE", "lbl":"Point Type", "type":"CHAR", "def":"", "ro":"YES", "rq":"NO", "len":"4", "hid":"NO" }, {"id":"EPO_POINT", "lbl":"Point", "type":"LOV-2", "def":"", "ro":"YES", "rq":"NO", "len":"3", "hid":"NO" }, {"id":"EPO_VALUE", "lbl":"Value", "type":"NUM", "def":"", "ro":"NO", "rq":"NO", "len":"24", "hid":"NO" }, {"id":"EPO_UOM", "lbl":"UOM", "type":"LOV-1", "def":"", "ro":"YES", "rq":"NO", "len":"15", "hid":"NO" }, {"id":"EPO_METHOD", "lbl":"Method", "type":"LOV-1", "def":"", "ro":"NO", "rq":"NO", "len":"20", "hid":"NO" }, {"id":"EPO_FINDING", "lbl":"Finding", "type":"LOV-1", "def":"", "ro":"NO", "rq":"NO", "len":"4", "hid":"NO" }, {"id":"EPO_RESULT_DESC", "lbl":"Result", "type":"PICKER", "def":"", "ro":"NO", "rq":"YES", "len":"20", "hid":"NO" }, {"id":"EPO_DATE", "lbl":"Date", "type":"DATI", "def":"", "ro":"NO", "rq":"YES", "len":"20", "hid":"NO" }, {"id":"EPO_COMPLETED", "lbl":"Completed", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"20", "hid":"NO" }, {"id":"EPO_LOCATION", "lbl":"Location", "type":"CHAR", "def":"", "ro":"NO", "rq":"NO", "len":"70", "hid":"NO" }, {"id":"EPO_COMMENT", "lbl":"Note", "type":"CHAR", "def":"", "ro":"NO", "rq":"NO", "len":"70", "hid":"NO" }, {"id":"EPO_INSPECTOR", "lbl":"Inspector", "type":"LOV-1", "def":"", "ro":"NO", "rq":"NO", "len":"15", "hid":"NO" }, {"id":"EPO_STWO", "lbl":"Standard WO", "type":"LOV-1", "def":"", "ro":"NO", "rq":"NO", "len":"20", "hid":"NO" }, {"id":"EPO_CREATE", "lbl":"New WO Required", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"20", "hid":"NO" }] },{"name":"Linear Reference Details", "hid" : "YES", "ro" : "YES", "mode" : "CON", "fields":[{"id":"EPO_FROMPOINT","lbl":"From Point","type":"LOV-3","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"EPO_FROMREFDESC","lbl":"Ref. Description","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},{"id":"EPO_FROMGEOREF","lbl":"Geographical Ref.","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},{"id":"EPO_TOPOINT","lbl":"To Point","type":"LOV-3","def":"","ro":"NO","rq":"NO","len":"30","hid":"NO"},{"id":"EPO_TOREFDESC","lbl":"Ref. Description","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},{"id":"EPO_TOGEOREF","lbl":"Geographical Ref.","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"}]}]}'
WHERE CFS_CODE='TCJEPO_IPAD';

----------------------------------------------------------------------------------------

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