<?
  include "../../../mainfile.php";
?>
<?
  $qchk = "SHOW COLUMNS FROM xoops_pc_timetable";
  $rchk = mysql_query($qchk);
  $nchk = mysql_num_rows($rchk);
  $i=0;
  $update = 1;
  while($i<$nchk){
  
    if( mysql_result($rchk,$i,"field") === "secid" ){
	  $update = "0";
	}
  
    $i++;
  }
?>
<?
  //-- if update is needed...
  if($update>0){
  
    $query = "ALTER TABLE `xoops_pc_holiday` CHANGE `holDate` `holDateFm` DATE NOT NULL DEFAULT '0000-00-00'";
	mysql_query($query);
	
    $query = "ALTER TABLE `xoops_pc_holiday` ADD `holDateTo` DATE NOT NULL AFTER `holDateFm`";
	mysql_query($query);
	
    $query = "ALTER TABLE `xoops_pc_remarkevent` ADD `tb_ord` INT( 2 ) NOT NULL AFTER `event`";
	mysql_query($query);
	
    $query = "ALTER TABLE `xoops_pc_remarkrecord` ADD `remarkDateTil` DATE NOT NULL AFTER `remarkDate`";
	mysql_query($query);
	
    $query = "ALTER TABLE `xoops_pc_remarkrecord` CHANGE `notice` `notice` VARCHAR( 90 ) NOT NULL ";
	mysql_query($query);
	
    $query = "ALTER TABLE `xoops_pc_remarkrecord` ADD `status` INT( 1 ) NOT NULL AFTER `notice` ,ADD `apvby` VARCHAR( 15 ) NOT NULL AFTER `status` ,ADD `apvdate` DATE NOT NULL AFTER `apvby`";
	mysql_query($query);
	
    $query = "CREATE TABLE `xoops_pc_section` (`id` varchar(2) NOT NULL,`name` varchar(20) NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysql_query($query);

    $query = "INSERT INTO xoops_pc_section VALUES ('0', 'UNDEFINED'),('1', '8:30 ~ 17:00'),('2', '1:00 ~ 17:00'),('3', 'UNDEFINED'),('4', 'UNDEFINED'),('5', 'UNDEFINED'),('6', 'UNDEFINED'),('7', 'UNDEFINED'),('8', 'UNDEFINED'),('9', 'UNDEFINED')";
    mysql_query($query);
	
    $query = "CREATE TABLE `xoops_pc_setting` (`passverify` int(1) NOT NULL,`maxpunchtime` int(2) NOT NULL default '1') ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysql_query($query);
	
    $query = "ALTER TABLE `xoops_pc_timetable` ADD `secid` INT( 1 ) NOT NULL AFTER `id`";
	mysql_query($query);
	
	$query = "INSERT INTO xoops_pc_timetable VALUES (NULL, 1, '1', '08:30:00', '17:00:00'),(NULL, 1, '2', '08:30:00', '17:00:00'),(NULL, 1, '3', '08:30:00', '17:00:00'),(NULL, 1, '4', '08:30:00', '17:00:00'),(NULL, 1, '5', '08:30:00', '17:00:00'),(NULL, 1, '6', '08:30:00', '13:00:00')";
    mysql_query($query);
	
    $query = "CREATE TABLE `xoops_sps_system` (
  `id` int(5) NOT NULL default '0',
  `format` varchar(50) NOT NULL default '',
  `passmark` int(3) NOT NULL default '40',
  `ROformat` varchar(50) NOT NULL default '',
  `schName` varchar(50) NOT NULL default '',
  `schCName` varchar(50) NOT NULL default '',
  `schCode` varchar(10) NOT NULL default '',
  `pksrRatio` char(1) NOT NULL default '',
  `imgPath` varchar(100) default NULL,
  `prisub1` int(5) default NULL,
  `prisub2` int(5) default NULL,
  `thisYear` varchar(4) NOT NULL default '',
  `passVerify` int(1) NOT NULL default '0',
  `pksr1rate` int(3) NOT NULL default '0',
  `pksr2rate` int(3) NOT NULL default '0',
  `gender` int(1) NOT NULL default '0',
  `upsrranking` int(1) NOT NULL default '0',
  `upsrclsarr` int(1) NOT NULL default '0',
  `language` int(1) NOT NULL default '0',
  `reportnote` varchar(100) default NULL,
  `reporttitle` varchar(100) NOT NULL default '',
  `reporttype` int(1) NOT NULL default '0',
  `report4type` int(1) NOT NULL default '0',
  `morecol` int(1) NOT NULL default '0',
  `showpksr` int(1) NOT NULL default '0',
  `atttimes` int(1) NOT NULL default '2',
  `sysver` varchar(15) default NULL,
  `ranktimes` int(1) NOT NULL default '2',
  `pksrname1` varchar(20) default 'PKSR1',
  `pksrname2` varchar(20) default 'PKSR2',
  `pksrnamet` varchar(20) default '???',
  `diffail` int(1) NOT NULL default '0',
  `sem1` varchar(30) default NULL,
  `sem2` varchar(30) default NULL,
  `showSchlogo` varchar(1) NOT NULL default '1',
  `schlogoHeight` varchar(2) NOT NULL default '9',
  `showgbname` int(1) NOT NULL default '0',
  `gbname` varchar(30) NOT NULL default '',
  `showgender` int(1) NOT NULL default '0',
  `showkk` int(1) NOT NULL default '1',
  `shownilam` int(1) NOT NULL default '1',
  `showseatno` int(1) NOT NULL default '0',
  `showsociety` int(1) NOT NULL default '1',
  `showclub` int(1) NOT NULL default '1',
  `showsport` int(1) NOT NULL default '1',
  `showteeth` int(1) NOT NULL default '1',
  `showhonor` int(1) NOT NULL default '1',
  `shownclass` int(1) NOT NULL default '1',
  `showtotalj` int(1) NOT NULL default '1',
  `showthisj` int(1) NOT NULL default '1',
  `showrmb` int(1) NOT NULL default '1',
  `gurusign` varchar(50) default NULL,
  `gurubesarsign` varchar(50) default NULL,
  `ibubapasign` varchar(50) default NULL,
  `printstyle` int(1) NOT NULL default '0',
  `printnumstu` int(2) NOT NULL default '33',
  `rptpgbrk` int(1) NOT NULL default '0',
  `avggrade` int(1) NOT NULL default '0',
  `thranking` int(1) NOT NULL,
  `bonus1` varchar(1) NOT NULL,
  `bonustxt1` varchar(14) NOT NULL,
  `bonus2` varchar(1) NOT NULL,
  `bonustxt2` varchar(14) NOT NULL,
  `bonus3` varchar(1) NOT NULL,
  `bonustxt3` varchar(14) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
	mysql_query($query);
	
    $query = "INSERT INTO `xoops_sps_system` VALUES (0, 'A80-B60-C40-D20-E0', 40, 'A4-B3-C2-D1', 'SUPERSOFT PUNCH CARD SYSTEM', '', 'ABC2126', '1', 'comlogo.jpg', 0, 0, '2011', 0, 50, 50, 0, 0, 0, 0, '* matapelajaran yg akan dihitung dlm PKSR', '', 0, 0, 0, 0, 0, 'Ver. 2011', 0, 'PKSR1', 'PKSR2', '×ü???ù', 0, '', '', '1', '9', 0, '', 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 'Tandatangan<br> Guru Kelas', 'Tandatangan<br> Guru Besar', 'Tandatangan<br>Ibubapa/Penjaga', 0, 40, 0, 0, 0, '0', '', '0', '', '0', '')";
	mysql_query($query);

    $query = "UPDATE xoops_adm_teacher SET administrator='8' WHERE administrator='1'";
	mysql_query($query);
	
	$query = "UPDATE xoops_adm_teacher SET section='1'";
	mysql_query($query);

	header("Location: ../index.php");
  }else{//-- if dun nid update anymore
    header("Location: ../index.php");
  }
?>