replace into opl_prefFormParam(var,listOrder,name,val) values
    ('allowOutstandingBalance',0,'no override','0'),
    ('allowOutstandingBalance',1,'override with question','1'),
    ('allowOutstandingBalance',2,'override automatically without approval','2'),

    ('showQRCode',0,'on',1),
    ('showQRCode',1,'off',0),
    ('unionExportExcludeTypes',25,'pdf','pdf'),
    ('searchResultDisplay',0,'List view','list'),
    ('searchResultDisplay',1,'Gallery view','gallery'),
    ('reservationSysType',0,'Basic reserve system',0),
    ('reservationSysType',1,'enhanced request reserve management system',1),
    ('SIF_enable',0,'disable',0),
    ('SIF_enable',1,'enable',1),
    ('SIF_version',0,'2.0r1','2.0r1'),
    ('SIF_version',1,'2.4','2.4')
    ;

replace into opl_preference(var,val,valShow,opt,varType,description,gid,gOrder) values
   ('allowOutstandingBalance',2,'override automatically without approval','integer','select','Loan restriction for patron with outstanding balance.   No override / Override with question / Override automatically without approval',3,1),  

   ('showQRCode',1,'on','0|1','radio','On / Off QR code display in home menu',1,15),  
   ('reservationSysType',0,'Basic reserve system','0|1','radio','Reservation system policy setting',2,5),
   ('searchResultDisplay','list','List view','list|gallery','radio','Default display type in result page.',5,31),
   ('SIF_enable','0','disable',NULL,'radio','Enable/disable SIF agent',11,14),
   ('SIF_zis_url','','',NULL,'text','ZIS address',11,14),
   ('SIF_sourceId','','',NULL,'text','SIF agent source ID',11,14),
   ('SIF_version','','',NULL,'text','SIF version',11,14),
   ('SIF_schoolLocalId','','',NULL,'text','School local ID of the student record',11,14);


insert into opl_prefGroup set id=11,title='SIF Agent';

ALTER TABLE opl_reserve 
        add `priority` int(6) unsigned DEFAULT '1000' after `uid` ,  
        add `suspendFrom` datetime DEFAULT NULL , 
        add `suspendUntil` datetime DEFAULT NULL;


CREATE TABLE `opl_requestReserve` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `numCopyRequest` tinyint(4) DEFAULT '1',
  `idReserve` int(10) unsigned DEFAULT NULL,
  `rid` int(10) unsigned NOT NULL DEFAULT '0',
  `uid` int(10) unsigned NOT NULL DEFAULT '0',
  `email` varchar(60) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `dateRequest` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `dateExpiry` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `dateProcess` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `status` enum('cancel','ready','reject','reserve','hold','waiting') DEFAULT 'waiting',
  `noticeType` varchar(60) DEFAULT 'phone',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


CREATE TABLE `opl_reqReserveHistory` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `reqId` int(10) unsigned NOT NULL,
  `uid` int(10) unsigned NOT NULL,
  `dateLog` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `action` varchar(100) DEFAULT NULL,
  `log` text,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
alter table opl_user add `SIF_refId` varchar(50) DEFAULT NULL after userbarcode;
alter table opl_template add `sysDefinedType` varchar(100) default NULL after name;


alter table sip_session add debug enum('true','false') default 'false' after ipaddress;

drop table if exists  tmp_template ; create table  tmp_template like opl_template;
insert into tmp_template(rank,sysDefinedType,name,content) select rank+1,'PDF_DOC','Catalog / Upload PDF Document','<record>\n  <leader>00496nmm  2200157 i 4500</leader>\n  <controlfield tag=\"001\">0</controlfield>\n  <controlfield tag=\"005\">20030913094031.0</controlfield>\n  <controlfield tag=\"007\">cr</controlfield>\n  <controlfield tag=\"008\">960618s1973    xxu        b  000 0 eng d</controlfield>\n  <controlfield tag=\"006\"></controlfield>\n  <datafield tag=\"040\" ind1=\" \" ind2=\" \">\n    <subfield code=\"a\"></subfield>\n    <subfield code=\"b\">eng</subfield>\n    <subfield code=\"c\"></subfield>\n    <subfield code=\"e\">rda</subfield>\n    <subfield code=\"d\">ScGrWPC</subfield>\n  </datafield>\n  <datafield tag=\"100\" ind1=\"1\" ind2=\" \">\n    <subfield code=\"a\"></subfield>\n    <subfield code=\"e\"></subfield>\n  </datafield>\n  <datafield tag=\"245\" ind1=\"1\" ind2=\"0\">\n    <subfield code=\"a\"></subfield>\n    <subfield code=\"b\"></subfield>\n    <subfield code=\"c\"></subfield>\n  </datafield>\n  <datafield tag=\"264\" ind1=\" \" ind2=\"1\">\n    <subfield code=\"a\"></subfield>\n    <subfield code=\"b\"></subfield>\n    <subfield code=\"c\"></subfield>\n  </datafield>\n  <datafield tag=\"336\" ind1=\" \" ind2=\" \">\n    <subfield code=\"2\">rdacontent</subfield>\n    <subfield code=\"a\">text</subfield>\n    <subfield code=\"b\">txt</subfield>\n  </datafield>\n  <datafield tag=\"337\" ind1=\" \" ind2=\" \">\n    <subfield code=\"a\">computer</subfield>\n    <subfield code=\"b\">c</subfield>\n    <subfield code=\"2\">rdamedia</subfield>\n  </datafield>\n  <datafield tag=\"338\" ind1=\" \" ind2=\" \">\n    <subfield code=\"2\">rdacarrier</subfield>\n    <subfield code=\"a\">online resource</subfield>\n    <subfield code=\"b\">cr</subfield>\n  </datafield>\n  <datafield tag=\"347\" ind1=\" \" ind2=\" \">\n    <subfield code=\"2\">rda</subfield>\n    <subfield code=\"a\">text file</subfield>\n    <subfield code=\"b\">PDF</subfield>\n  </datafield>\n  <datafield tag=\"520\" ind1=\" \" ind2=\" \">\n    <subfield code=\"a\"></subfield>\n  </datafield>\n  <datafield tag=\"538\" ind1=\" \" ind2=\" \">\n    <subfield code=\"a\">System requirements: Adobe Reader or other PDF reader.</subfield>\n  </datafield>\n  <datafield tag=\"650\" ind1=\" \" ind2=\" \">\n    <subfield code=\"a\"></subfield>\n    <subfield code=\"x\"></subfield>\n  </datafield>\n  <datafield tag=\"651\" ind1=\" \" ind2=\" \">\n    <subfield code=\"a\"></subfield>\n    <subfield code=\"x\"></subfield>\n  </datafield>\n  <datafield tag=\"690\" ind1=\" \" ind2=\" \">\n    <subfield code=\"a\"></subfield>\n  </datafield>\n  <datafield tag=\"852\" ind1=\"1\" ind2=\" \">\n    <subfield code=\"c\"></subfield>\n    <subfield code=\"k\"></subfield>\n    <subfield code=\"h\"></subfield>\n    <subfield code=\"i\"></subfield>\n    <subfield code=\"p\"></subfield>\n    <subfield code=\"3\">G</subfield>\n    <subfield code=\"9\"></subfield>\n    <subfield code=\"a\">__852_a__</subfield>\n    <subfield code=\"b\">__852_b__</subfield>\n  </datafield>\n</record>'  from  opl_template  order by rank desc limit 1;
insert into opl_template(rank,sysDefinedType,name,content) select rank,sysDefinedType,name,content from tmp_template;
