");
exit();
}
//conectar a la bbdd usando los datos introducidos por el usuario
$result=mysql_connect($host, $user, $pass);
if (!$result) {
echo ("
");
exit;
}
//Crear base de datos
mysql_query("CREATE DATABASE $bbdd");
mysql_select_db($bbdd);
//Crear las tablas si no existen
// Estructura de la tabla `empleados`
$empleados="
CREATE TABLE IF NOT EXISTS `empleados` (
`idemp` int(5) NOT NULL AUTO_INCREMENT,
`nombre` text NOT NULL,
`apellidouno` text NOT NULL,
`apellidodos` text NOT NULL,
`email` text NOT NULL,
`dni` text NOT NULL,
`estado` text NOT NULL,
`nuss` text NOT NULL,
`sexo` int(1) NOT NULL,
`observaciones` text NOT NULL,
`telfcont` int(15) NOT NULL,
`telfcont2` int(15) NOT NULL,
`calle` text NOT NULL,
`piso` varchar(5) NOT NULL,
`puerta` varchar(5) NOT NULL,
`cp` int(10) NOT NULL,
`localidad` text NOT NULL,
`provincia` text NOT NULL,
`fechaent` text NOT NULL,
`fechasal` text NOT NULL,
`hijos` int(3) NOT NULL,
`estadocivil` int(1) NOT NULL,
PRIMARY KEY (`idemp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=100 ;";
mysql_query($empleados);
// Estructura de la tabla `nominas`
$nominas="CREATE TABLE IF NOT EXISTS `nominas` (`idnomina` int(5) NOT NULL AUTO_INCREMENT, `idemp` int(5) NOT NULL,
`mes` text NOT NULL, `urtea` int(4) NOT NULL, `hcontrato` int(11) NOT NULL, `shora` float NOT NULL,
`hextra` int(11) NOT NULL, `sextra` float NOT NULL, `hdietas` int(11) NOT NULL, `sdietas` float NOT NULL,
`plustransp` float NOT NULL, `hfestivo` int(11) NOT NULL, `sfestivo` float NOT NULL, `hnorturna` int(11) NOT NULL,
`snocturna` float NOT NULL, `irpf` int(11) NOT NULL, `desempleo` int(11) NOT NULL, `total` float NOT NULL,
PRIMARY KEY (`idnomina`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1000 ;";
mysql_query($nominas);
//Estructura de la tabla solicitudes
$solicitudes="CREATE TABLE IF NOT EXISTS `solicitudes` (
`IdSolicitud` int(5) NOT NULL AUTO_INCREMENT, `IdEmp` int(5) NOT NULL, `Tipo` int(1) NOT NULL,
`FechaInicio` date NOT NULL, `FechaFin` date NOT NULL, `Motivo` text NOT NULL, `Aprobado` int(1) NOT NULL,
`FechaAprobado` date NOT NULL, `Anotaciones` text NOT NULL,
PRIMARY KEY (`IdSolicitud`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;" ;
mysql_query($solicitudes);
//Estuctura de la tabla miembros
$miembros="CREATE TABLE IF NOT EXISTS `miembros` ( `idusario` int(11) NOT NULL AUTO_INCREMENT,
`usuario` text NOT NULL, `userpass` text NOT NULL, `anotaciones` text NOT NULL,
`tab_bemp` int(11) NOT NULL, `tab_bnom` int(11) NOT NULL, `tab_lemp` int(11) NOT NULL,
`tab_lnom` int(11) NOT NULL, `tab_nemp` int(11) NOT NULL, `tab_nnom` int(11) NOT NULL,
`tab_stats` int(11) NOT NULL, `tab_usera` int(11) NOT NULL, `tab_insta` int(11) NOT NULL,
`tab_nsol` int(11) NOT NULL, PRIMARY KEY (`idusario`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; ";
mysql_query($miembros);
//insertar en la tabla miembros el usuario administrador
$usuarioadm=" INSERT INTO `miembros` (`idusario`, `usuario`, `userpass`, `anotaciones`, `tab_bemp`,
`tab_bnom`, `tab_lemp`, `tab_lnom`, `tab_nemp`, `tab_nnom`, `tab_stats`, `tab_usera`,
`tab_insta`, `tab_nsol`) VALUES (NULL, '$useradmin', '$passadmin', 'Usuario adminsitrativo con acceso total',
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1'); ";
mysql_query($usuarioadm);
//crear archivo de conexion a la bbdd si no existe
$url = 'conectarbbdd.php';
echo('