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

CREATE TABLE R5REVCNTRLSETUP(
RCS_PAGENAME    nvarchar(40) NOT NULL,
RCS_ELEMENTID    nvarchar(40) NOT NULL,
RCS_DDTABLENAME    nvarchar(80),
RCS_DDFIELDNAME    nvarchar(80),
RCS_PROTECTED    nvarchar(1),
DMLTYPE nchar(1) NULL DEFAULT ('N'),
PRIMARY KEY (RCS_PAGENAME, RCS_ELEMENTID)
);
INSERT INTO R5SYSCOLUMNS VALUES('R5REVCNTRLSETUP','RCS_PAGENAME','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');
INSERT INTO R5SYSCOLUMNS VALUES('R5REVCNTRLSETUP','RCS_ELEMENTID','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

INSERT INTO R5LISTENTITY  (LET_DATAGRID, LET_SEQNO, LET_GROUPID, LET_DELINSUPD, LET_FILTER, LET_TABLENAME, LET_ORGKEY, LET_CONNECTEDMODE, LET_ALWAYSDOWNLOAD, LET_CATEGORY, LET_CLEARCONDITION) VALUES('BCREVC_IPAD', 21, 0, 6, NULL, 'R5REVCNTRLSETUP', NULL, '-', '-', NULL, NULL);

UPDATE R5CONFIGSETTINGS
SET CFS_XMLCONFIG = '{
   "sections":[
      {
         "name":"Permit To Work",
         "fields":[
            {
               "id":"PTW_CODE",
               "lbl":"Permit To Work",
               "type":"CHAR",
               "def":"",
               "ro":"YES",
               "rq":"NO",
               "len":"30",
               "hid":"NO"
            },
            {
               "id":"PTW_DESC",
               "lbl":"Description",
               "type":"CHAR",
               "def":"",
               "ro":"NO",
               "rq":"NO",
               "len":"80",
               "hid":"NO"
            },
            {
               "id":"PTW_OBJECT",
               "lbl":"Equipment",
               "type":"LOV-2",
               "def":"",
               "ro":"YES",
               "rq":"NO",
               "len":"80",
               "hid":"NO"
            },
            {
               "id":"PTW_STATUS",
               "lbl":"Status",
               "type":"LOV-2",
               "def":"",
               "ro":"NO",
               "rq":"YES",
               "len":"",
               "hid":"NO"
            },
            {
               "id":"PTW_LOCKOUTBOX",
               "lbl":"Lockout Box",
               "type":"LOV-2",
               "def":"",
               "ro":"NO",
               "rq":"NO",
               "len":"",
               "hid":"NO"
            },
            {
               "id":"PTW_NOTE",
               "lbl":"Note",
               "type":"MEMO-1",
               "def":"",
               "ro":"NO",
               "rq":"NO",
               "len":"256",
               "hid":"NO"
            },
            {
               "id":"PTW_LOCATIONNOTE",
               "lbl":"Location Note",
               "type":"MEMO-1",
               "def":"",
               "ro":"NO",
               "rq":"NO",
               "len":"256",
               "hid":"NO"
            }
         ]
      },
      {
         "name":"Tracking Details",
         "fields":[
            {
               "id":"PTW_ASSIGNEDTO",
               "lbl":"Assigned To",
               "type":"LOV-1",
               "def":"",
               "ro":"NO",
               "rq":"NO",
               "len":"",
               "hid":"NO"
            }
         ]
      },
      {
         "name":"Scheduling Details",
         "fields":[
            {
               "id":"PTW_DATEREQUIRED",
               "lbl":"Date Required",
               "type":"DATI",
               "def":"",
               "ro":"YES",
               "rq":"NO",
               "len":"",
               "hid":"NO"
            },
            {
               "id":"PTW_DURATION",
               "lbl":"Duration (Hrs.)",
               "type":"NUM",
               "def":"",
               "ro":"YES",
               "rq":"NO",
               "len":"30",
               "hid":"NO"
            },
            {
               "id":"PTW_EXTENSION",
               "lbl":"Extension (Hrs.)",
               "type":"NUM",
               "def":"",
               "ro":"YES",
               "rq":"NO",
               "len":"30",
               "hid":"NO"
            },
            {
               "id":"PTW_SUSPENSIONREASON",
               "lbl":"Suspension Reason",
               "type":"CHAR",
               "def":"",
               "ro":"NO",
               "rq":"NO",
               "len":"30",
               "hid":"NO"
            }
         ]
      }
   ]
}'
WHERE CFS_CODE = 'TCPMTW_IPAD';
 
​ALTER TABLE R5PERMITTOWORK ADD COLUMN PTW_UDFNOTE01 NVARCHAR (2000);
ALTER TABLE R5PERMITTOWORK ADD COLUMN PTW_UDFNOTE02 NVARCHAR (2000);

UPDATE r5configsettings
SET cfs_xmlconfig = '{ "sections": [{ "name": "Nonconformity", "fields": [{ "id": "NCF_ISLINEAR", "lbl": "Linear", "type": "BOOL", "def": "", "ro": "NO", "rq": "NO", "len": "2", "hid": "NO" }, { "id": "NCO_PK", "lbl": "Observation PK", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_CODE", "lbl": "Nonconformity", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_DESC", "lbl": "Description", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "NO" }, { "id": "NCF_ORG", "lbl": "Organization", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_OBSERVATION", "lbl": "Observation", "type": "NUM", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_OBJECT", "lbl": "Equipment", "type": "LOV-2", "def": "", "ro": "NO", "rq": "YES", "len": "30", "hid": "NO" }, { "id": "NCF_OBJECT_CRITICALITY", "lbl": "Equipment Criticality", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_OBJECT_SAFETY", "lbl": "Equipment Safety", "type": "BOOL", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_LOCATION", "lbl": "Location", "type": "LOV-2", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_PART", "lbl": "Part", "type": "LOV-2", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_MRC", "lbl": "Department", "type": "LOV-2", "def": "", "ro": "NO", "rq": "YES", "len": "30", "hid": "YES" }, { "id": "NCF_CLASS", "lbl": "Class", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_CLASS_ORG", "lbl": "Class Organization", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_TASK", "lbl": "Task Plan for Checklist", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_TASKREV", "lbl": "Task Plan for Checklist Revision", "type": "NUM", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_SYSLEVEL_DISP", "lbl": "System Level", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_ASMLEVEL_DISP", "lbl": "Assembly Level", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_COMPLEVEL_DISP", "lbl": "Component Level", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_EMRS_DESC", "lbl": "EMRS Description", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_MATLTYPE", "lbl": "Material Type", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCO_STATUS", "lbl": "Observation Status", "type": "PICKER", "def": "", "ro": "NO", "rq": "YES", "len": "30", "hid": "NO" }, { "id": "NCF_NCTTYPE", "lbl": "Type", "type": "LOV-2", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCF_PRIORITY", "lbl": "Priority", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCO_SEVERITY", "lbl": "Severity", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCO_SIZE", "lbl": "Size", "type": "NUM", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCO_INTENSITY", "lbl": "Intensity", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCO_IMPORTANCE", "lbl": "Importance", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCF_STATUS", "lbl": "Status", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_SEVERITY", "lbl": "Nonconformity Severity", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_INTENSITY", "lbl": "Nonconformity Intensity", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_SIZE", "lbl": "Nonconformity Size", "type": "NUM", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_IMPORTANCE", "lbl": "Nonconformity Importance", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_CONDITIONSCORE", "lbl": "Nonconformity Condition Score", "type": "NUM", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCF_CONDITIONINDEX", "lbl": "Nonconformity Condition Index", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCO_RECORDEDBY", "lbl": "Recorded By", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCO_RECORDED", "lbl": "Date Recorded", "type": "DATI", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_CONDITIONSCORE", "lbl": "Condition Score", "type": "NUM", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCO_CONDITIONINDEX", "lbl": "Condition Index", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }, { "id": "NCO_NEXTINSPECTDATE", "lbl": "Next Inspection Date", "type": "DATE", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "NO" }, { "id": "NCO_NEXTINSPECTDATEOVERRIDE", "lbl": "Next Inspection Date Override", "type": "DATE", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "NO" }, { "id": "NCF_RECOMMREPAIRDATE", "lbl": "Recommended Repair Date.", "type": "DATE", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_ESTLABORCOST", "lbl": "Estimated Labor Costs", "type": "NUMDESC", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCF_ESTMATLCOST", "lbl": "Estimated Material Costs", "type": "NUMDESC", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCF_ESTMISCCOST", "lbl": "Estimated Misc. Costs", "type": "NUMDESC", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }, { "id": "NCF_TOTALCOST", "lbl": "Total Estimated Costs", "type": "NUMDESC", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "NO" },{"id": "NCF_NOTE","lbl": "Nonconformity Note","type": "MEMO-1","def": "","ro": "NO","rq": "NO","len": "256","hid": "YES"}, { "id": "NCO_NOTE", "lbl": "Observation Note", "type": "MEMO-1", "def": "", "ro": "NO", "rq": "NO", "len": "256", "hid": "NO" }, { "id": "NCO_WORKORDER", "lbl": "Work Order", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_CREATEDBY", "lbl": "Created By", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_CREATED", "lbl": "Date Created", "type": "DATE", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_UPDATEDBY", "lbl": "Updated By", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCO_UPDATED", "lbl": "Date Updated", "type": "DATE", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_FROMPOINT", "lbl": "From Point", "type": "LOV-3", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_FROMREFDESC", "lbl": "From Ref. Description", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_FROMGEOREF", "lbl": "From Geographical Ref.", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_TOPOINT", "lbl": "To Point", "type": "LOV-3", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_TOREFDESC", "lbl": "To Ref. Description", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_TOGEOREF", "lbl": "To Geographical Ref.", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_INSPECTIONDIRECTION", "lbl": "Inspection Direction", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }, { "id": "NCF_FLOW", "lbl": "Flow", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "YES" }] }, { "name": "COMMENTS", "sectype": "COMMENTS", "fields": [] }, { "name": "Documents", "sectype": "DOCUMENTS", "fields": [] }, { "name": "LOCATION", "sectype": "LOCATION", "fields": [{ "id": "BUTTON_LOCATION", "lbl": "Set Map Location", "type": "LOCATION", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "NO" }]}]}'
WHERE cfs_code = 'TCGNCF_IPAD';

ALTER TABLE R5OBJECTS ADD COLUMN OBJ_PREVENTEVTCOMP NVARCHAR(1);
ALTER TABLE R5OBJECTSWO ADD COLUMN OBJ_PREVENTEVTCOMP NVARCHAR(1);
UPDATE R5LISTENTITY SET LET_UPDATED = NULL WHERE LET_DATAGRID='OCOBJCWO_IPAD';

UPDATE r5configsettings
SET cfs_xmlconfig='{ "sections":[{ "name": "Operator CheckList","fields":[{ "id": "OCK_ORG", "lbl": "Organization", "type": "LOV-1", "def": "", "ro": "YES", "rq": "YES", "len": "30", "hid": "NO" },{ "id": "OCK_CODE", "lbl": "Operator CheckList Number", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "NO" },{ "id": "OCK_OBJECT", "lbl": "Equipment", "type": "LOV-2", "def": "", "ro": "NO", "rq": "YES", "len": "30", "hid": "NO" },{ "id": "OCK_OBJECT_ORG", "lbl": "Equipment Org.", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" },{ "id": "OCK_OBJECT_CLASS", "lbl": "Equipment Class", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "NO" },{ "id": "OCK_OBJECT_CLASS_ORG", "lbl": "Equipment Class Org.", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "NO" },{ "id": "OCK_TASK", "lbl": "Task Plan", "type": "LOV-2", "def": "", "ro": "NO", "rq": "YES", "len": "30", "hid": "NO" },{ "id": "OCK_TASKREV", "lbl": "Task Plan Revision", "type": "NUM", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" },{ "id": "OCK_CONDITION_AS_FOUND", "lbl": "Condition As Found", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "30","hid":"NO"},{ "id": "OCK_CREATEDBY", "lbl": "Created By", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" },{ "id": "OCK_CREATEDBY_DESC", "lbl": "Created By Name", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "80", "hid": "YES" },{ "id": "OCK_STATUS", "lbl": "Status", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" },{ "id": "OCK_STARTDATE", "lbl": "Start Date/Time", "type": "DATI", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" },{ "id": "OCK_ENDDATE", "lbl": "End Date/Time", "type": "DATI", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" },{ "id": "OCK_PERFORMBYRESPCODE", "lbl": "Perform By Responsibility", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" },{ "id": "OCK_REVIEWRESPCODE", "lbl": "Review Responsibility", "type": "CHAR", "def": "", "ro": "YES", "rq": "NO", "len": "30", "hid": "YES" }]}]}'
WHERE cfs_code='TCOPCL_IPAD';

ALTER TABLE R5EVENTS ADD COLUMN EVT_CLOSINGLATITUDE NUMERIC(24,6);
ALTER TABLE R5EVENTS ADD COLUMN EVT_CLOSINGLONGITUDE NUMERIC(24,6);
