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('WCWOSF_IPAD',280,0,3,'WCJOBS','R5WORKSAFETY',NULL,'-','-','EVNT','AND KSF_RENTITY=''EVNT''');
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('WCWOSF_MEC_IPAD',281,0,3,'WCJOBS','R5WORKSAFETY',NULL,'-','-','EVNT','AND 1=2');

UPDATE R5LISTENTITY SET LET_CLEARCONDITION = 'AND KSF_RENTITY=''PTW''' WHERE LET_DATAGRID='WCPKSF_IPAD';

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('BCMENS_IPAD',282,0,6,NULL ,'R5MOBILEENTITYSETUP',NULL,'-','-',NULL,NULL);
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('BCMENV_IPAD',283,0,6,NULL,'R5DESCRIPTIONS',NULL,'-','-',NULL,NULL);

CREATE TABLE R5MOBILEENTITYSETUP(
    MBE_RENTITY     NVARCHAR(4) NOT NULL,
    MBE_ENTITY      NVARCHAR(4) NOT NULL,
    DMLTYPE         NCHAR(1) NULL DEFAULT ('N'),
    PRIMARY KEY (MBE_RENTITY)
);
INSERT INTO R5SYSCOLUMNS VALUES('R5MOBILEENTITYSETUP',' MBE_RENTITY','+',NULL,NULL,NULL,NULL,NULL,NULL,'N');

INSERT INTO R5CONFIGSETTINGS(CFS_CODE, CFS_GROUP, CFS_USER, CFS_COMPTYPE, CFS_CONFIG, CFS_XMLCONFIG, CFS_UPDATED, CFS_DESK)
VALUES('TCLOTO_IPAD', '*', '*', 'U', 1,
'{ "sections":
[{ "name": "Lockout/Tagout",
"fields": [
{ "id": "PWL_SEQUENCE", "lbl": "Sequence", "type": "NUM", "def": "", "ro": "NO", "rq": "YES", "len": "30", "hid": "NO" },
{ "id": "PWL_STEPNUMBER", "lbl": "Step Number", "type": "NUM", "def": "", "ro": "NO", "rq": "NO", "len": "80", "hid": "NO" },
{ "id": "PWL_ISOLATIONSTEP", "lbl": "Isolation Step", "type": "BOOL", "def": "", "ro": "NO", "rq": "NO", "len": "2", "hid": "NO" },
{ "id": "PWL_ISOLATIONMETHOD", "lbl": "Isolation Method", "type": "LOV-2", "def": "", "ro": "NO", "rq": "YES", "len": "30", "hid": "NO" },
{ "id": "PWL_ISOLATIONPOINT", "lbl": "Isolation Point", "type": "LOV-2", "def": "", "ro": "NO", "rq": "NO", "len": "", "hid": "NO" },
{ "id": "PWL_ENERGYSOURCE", "lbl": "Energy Source", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_RESIDUALENERGY", "lbl": "Residual Energy", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_RESIDUALENERGY2", "lbl": "Secondary Residual Energy", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_KEY", "lbl": "Key References", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_NOTE", "lbl": "Note", "type": "MEMO-1", "def": "", "ro": "NO", "rq": "NO", "len": "200", "hid": "NO" },
{ "id": "PWL_LOCATIONNOTE", "lbl": "Location Note", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_COMPLETE", "lbl": "Complete", "type": "BOOL", "def": "", "ro": "NO", "rq": "NO", "len": "2", "hid": "NO" },
{ "id": "PWL_UNABLETOCOMPLETE", "lbl": "Unable to Complete", "type": "PICKER", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_REPLACESLOTO", "lbl": "Replaces LOTO", "type": "LOV-1", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }] },
{ "name": "Permit to Work Tags",
"fields": [
{ "id": "PWL_NUMBEROFTAGS", "lbl": "Number of Tags", "type": "NUM", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_TAGHEADER", "lbl": "Tag Header", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_TAGLINE1", "lbl": "Tag Line 1", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_TAGLINE2", "lbl": "Tag Line 2", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_TAGLINE3", "lbl": "Tag Line 3", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" },
{ "id": "PWL_TAGLINE4", "lbl": "Tag Line 4", "type": "CHAR", "def": "", "ro": "NO", "rq": "NO", "len": "30", "hid": "NO" }] } ]}',
date('now'),1);

UPDATE R5CONFIGSETTINGS SET CFS_XMLCONFIG = '{"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":"NO" },
{"id":"EVT_MRC", "lbl":"Department", "type":"LOV-1", "def":"", "ro":"NO", "rq":"YES", "len":"15", "hid":"NO" },
{"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":"NO" },
{"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":"From Ref. Description","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},
{"id":"EVT_FROMGEOREF","lbl":"From 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":"To Ref. Description","type":"CHAR","def":"","ro":"NO","rq":"NO","len":"80","hid":"NO"},
{"id":"EVT_TOGEOREF","lbl":"To 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"},
{"id":"EVT_RELATIONSHIP_TYPE", "lbl":"Relationship Type", "type":"LOV-1", "def":"", "ro":"NO", "rq":"NO", "len":"30", "hid":"YES" }]}]}'
WHERE CFS_CODE ='TCJWOEQR_IPAD';

UPDATE R5LISTENTITY SET LET_UPDATED = NULL WHERE LET_TABLENAME='R5USERDEFINEDFIELDLOVVALS';
UPDATE R5LISTENTITY SET LET_UPDATED = NULL WHERE LET_TABLENAME='R5BOOKEDHOURS';

ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR01 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR02 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR03 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR04 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR05 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR06 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR07 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR08 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR09 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR10 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR11 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR12 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR13 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR14 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR15 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR16 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR17 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR18 NVARHCAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR19 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR20 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR21 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR22 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR23 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR24 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR25 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR26 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR27 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR28 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR29 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHAR30 NVARCHAR (80);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFNUM01 NUMERIC (24, 6);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFNUM02 NUMERIC (24, 6);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFNUM03 NUMERIC (24, 6);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFNUM04 NUMERIC (24, 6);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFNUM05 NUMERIC (24, 6);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFDATE01 DATETIME;
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFDATE02 DATETIME;
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFDATE03 DATETIME;
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFDATE04 DATETIME;
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFDATE05 DATETIME;
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHKBOX01 NVARCHAR (1);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHKBOX02 NVARCHAR (1);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHKBOX03 NVARCHAR (1);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHKBOX04 NVARCHAR (1);
ALTER TABLE R5BOOKEDHOURS ADD COLUMN BOO_UDFCHKBOX05 NVARCHAR (1);

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

DELETE FROM r5mobiletexts WHERE mot_number > 1611;
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1612 , 'Copy Source', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1613 , 'Depending on the selected Record Type, the system will select all nonconformities or nonconformity observations of the work order with a status equal to the selected From Status and will update the status of these records with the selected To Status.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1614 , 'In Progress', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1615 , 'Options', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1616 , 'Features', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1617 , 'Switch Basemap', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1618 , 'Success', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1619 , 'Failed', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1620 , 'The work order :PARAM1 Activity :PARAM2 that was previously started, does not exist on the device. That transaction will be ignored, and the current activity will be started.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1621 , 'Labor must be manually booked for work order :PARAM1 Activity :PARAM2 before starting this activity. Please navigate to :PARAM1 Activity :PARAM2 to manually stop or reset it.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1622 , 'System booked :PARAM1 hours for :PARAM2 on Work Order :PARAM3 Activity :PARAM4.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1623 , 'Work is currently under progress on Work Order :PARAM1 Activity :PARAM2. Do you want the system to automatically book :PARAM3 hours?', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1624 , 'Work is currently under progress on Work Order :PARAM1 Activity :PARAM2. You must stop this activity before starting a new one.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1625 , 'Build', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1626 , 'LOTO', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1627 , 'Isolation Step', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1628 , 'Isolation Point', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1629 , 'De-Isolated', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1630 , 'Step Number', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1631 , 'Isolation Method', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1632 , 'Energy Source', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1633 , 'Residual Energy', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1634 , 'Secondary Residual Energy', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1635 , 'Key References', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1636 , 'Unable to Complete', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1637 , 'Replaces LOTO', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1638 , 'Permit to Work Tags', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1639 , 'Number of Tags', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1640 , 'Tag Header', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1641 , 'Tag Line 1', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1642 , 'Tag Line 2', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1643 , 'Tag Line 3', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1644 , 'Tag Line 4', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1645 , 'Method Revision', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1646 , 'Isolation Point Revision', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1647 , 'Enter your electronic signature credentials to confirm Isolation.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1648 , 'The current Status does not allow changes.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1649 , 'Delete LOTO Record', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1650 , 'Lockout/Tagout', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1651 , 'Sequence must be an integer in a range of 1 to 999999. ', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1652 , 'Number of Tags must be an integer in a range of 0 to 999999.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1653 , 'Step Number must be an integer in a range of 1 to 999999.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1654 , 'Checklist Attached', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1655 , 'LOTO Status', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1656 , 'Add LOTO', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1657 , 'LOTO Details', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1658 , 'No LOTO found', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1659 , 'This LOTO record is replaced with another on this permit to work. Selecting Complete is not allowed.', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1660 , 'Isolation Point Documents', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1661 , 'Isolation Method Documents', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1662 , 'Isolation Point Comments', 'EN');
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (1663 , 'Isolation Method Comments', 'EN');

