<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );

//ส่วนการสร้างตารางระบบย่อย
$sql_create="CREATE TABLE `la_cancel` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `person_id` varchar(13) NOT NULL,
  `la_type` tinyint(4) NOT NULL,
  `write_at` varchar(100) DEFAULT NULL,
  `permission_start` date NOT NULL,
  `permission_finish` date NOT NULL,
  `permission_total` float NOT NULL,
  `because` varchar(200) NOT NULL,
  `cancel_la_start` date NOT NULL,
  `cancel_la_finish` date NOT NULL,
  `cancel_la_total` float NOT NULL,
  `no_comment` int(11) NOT NULL DEFAULT '0',
  `grant_p_selected` varchar(13) DEFAULT NULL,
  `rec_date` datetime NOT NULL,
  `officer_comment` varchar(200) DEFAULT NULL,
  `officer_sign` varchar(13) DEFAULT NULL,
  `officer_date` datetime DEFAULT NULL,
  `group_comment` varchar(100) DEFAULT NULL,
  `group_sign` varchar(13) DEFAULT NULL,
  `group_date` datetime DEFAULT NULL,
  `comment_date` datetime DEFAULT NULL,
  `commander_grant` tinyint(4) DEFAULT NULL,
  `commander_comment` varchar(100) DEFAULT NULL,
  `commander_sign` varchar(13) DEFAULT NULL,
  `grant_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
$query = mysqli_query($connect,$sql_create);

$sql_create="CREATE TABLE `la_main` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `person_id` varchar(13) NOT NULL,
  `la_type` tinyint(4) NOT NULL,
  `write_at` varchar(100) DEFAULT NULL,
  `because` varchar(250) DEFAULT NULL,
  `la_start` date NOT NULL,
  `la_finish` date NOT NULL,
  `la_total` float NOT NULL,
  `last_la_start` date DEFAULT NULL,
  `last_la_finish` date DEFAULT NULL,
  `last_la_total` float DEFAULT NULL,
  `contact` varchar(150) DEFAULT NULL,
  `contact_tel` varchar(20) DEFAULT NULL,
  `document` varchar(100) DEFAULT NULL,
  `no_comment` tinyint(4) NOT NULL DEFAULT '0',
  `grant_p_selected` varchar(13) DEFAULT NULL,
  `sick_ago` float DEFAULT NULL,
  `sick_this` float DEFAULT NULL,
  `sick_total` float DEFAULT NULL,
  `privacy_ago` float DEFAULT NULL,
  `privacy_this` float DEFAULT NULL,
  `privacy_total` float DEFAULT NULL,
  `birth_ago` float DEFAULT NULL,
  `birth_this` float DEFAULT NULL,
  `birth_total` float DEFAULT NULL,
  `relax_ago` float DEFAULT NULL,
  `relax_this` float DEFAULT NULL,
  `relax_total` float DEFAULT NULL,
  `relax_collect` float DEFAULT NULL,
  `relax_this_year` float DEFAULT NULL,
  `job_person` varchar(13) DEFAULT NULL,
  `job_person_sign` tinyint(4) NOT NULL DEFAULT '0',
  `rec_date` datetime NOT NULL,
  `officer_comment` varchar(200) DEFAULT NULL,
  `officer_sign` varchar(13) DEFAULT NULL,
  `officer_date` datetime DEFAULT NULL,
  `group_comment` varchar(100) DEFAULT NULL,
  `group_sign` varchar(13) DEFAULT NULL,
  `group_date` datetime DEFAULT NULL,
  `comment_date` datetime DEFAULT NULL,
  `commander_grant` tinyint(4) DEFAULT NULL,
  `commander_comment` varchar(100) DEFAULT NULL,
  `commander_sign` varchar(13) DEFAULT NULL,
  `grant_date` datetime DEFAULT NULL,
  `school_code` varchar(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ;
$query = mysqli_query($connect,$sql_create);

$sql_create="CREATE TABLE `la_permission` (
  `id` int(11) NOT NULL auto_increment,
  `person_id` varchar(13) NOT NULL,
  `p1` tinyint(4) NOT NULL,
  `officer` varchar(13) NOT NULL,
  `rec_date` date NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ;
$query = mysqli_query($connect,$sql_create);

$sql_create="CREATE TABLE `la_person_set` (
  `id` int(11) NOT NULL auto_increment,
  `person_id` varchar(13) NOT NULL,
  `comment_person` varchar(13) default NULL,
  `grant_person` varchar(13) default NULL,
  `officer` varchar(13) default NULL,
  `rec_date` date default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `person_id` (`person_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ;
$query = mysqli_query($connect,$sql_create);

$sql_create="CREATE TABLE `la_year` (
  `id` int(11) NOT NULL auto_increment,
  `budget_year` int(11) NOT NULL,
  `year_active` tinyint(1) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `budget_year` (`budget_year`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ;
$query = mysqli_query($connect,$sql_create);

$sql_create="CREATE TABLE `la_collect` (
  `id` int(11) NOT NULL auto_increment,
  `year` int(11) NOT NULL,
  `person_id` varchar(13) NOT NULL,
  `collect_day` tinyint(4) NOT NULL default '0',
  `this_year_day` tinyint(4) NOT NULL default '0',
  `officer` varchar(13) default NULL,
  `rec_date` date default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ;
$query = mysqli_query($connect,$sql_create);

?>