Compare commits
No commits in common. "bb1b2f077bc9eb178cb280ebe251ffb2dacdf10a" and "650df9d0f68bbacfe38c3a17a599fd66c4c990a7" have entirely different histories.
bb1b2f077b
...
650df9d0f6
@ -1,4 +1,4 @@
|
||||
CREATE DATABASE IF NOT EXISTS practica CHARACTER SET utf8mb4;
|
||||
CREATE DATABASE IF NOT EXISTS practica CHARACTER SET utf8;
|
||||
|
||||
CREATE USER IF NOT EXISTS practica IDENTIFIED BY 'practica';
|
||||
|
||||
@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS usuario(
|
||||
especialidad VARCHAR(50),
|
||||
correo VARCHAR(100) NOT NULL,
|
||||
fecha_alta TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
fecha_baja DATE,
|
||||
fecha_baja TIMESTAMP,
|
||||
FOREIGN KEY (rol)
|
||||
REFERENCES rol(codigo)
|
||||
);
|
||||
@ -94,6 +94,3 @@ CREATE TABLE IF NOT EXISTS informe(
|
||||
FOREIGN KEY (paciente)
|
||||
REFERENCES paciente(documento_identificativo)
|
||||
);
|
||||
|
||||
INSERT INTO rol (codigo, nombre) VALUES (1, "administrativo");
|
||||
INSERT INTO rol (codigo, nombre) VALUES (2, "medico");
|
||||
|
@ -1,52 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>Gestión de usuarios</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||
<!-- Place favicon.ico in the root directory -->
|
||||
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browserupgrade">
|
||||
You are using an <strong>outdated</strong> browser. Please
|
||||
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||
your experience.
|
||||
</p>
|
||||
<![endif]-->
|
||||
<form method="post" action="../src/user_management.php">
|
||||
<div class="input-group">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="nombre" value="">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>usuario</label>
|
||||
<input type="text" name="usuario" value="">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>contraseña</label>
|
||||
<input type="password" name="contraseña" value="">
|
||||
</div>
|
||||
<div class="select-input">
|
||||
<label>rol</label>
|
||||
<select id="rol" name="rol">
|
||||
<option value="1">administrativo</option>
|
||||
<option value="2">médico</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>correo</label>
|
||||
<input type="text" name="correo" value="">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<button class="btn" type="submit" name="submit" >Guardar</button>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
function connectDatabase(string $user, string $pass, string $db) {
|
||||
function connectDatabase(str $user, str $pass, str $db) {
|
||||
$unix_socket = '.mysql/mysql.sock';
|
||||
$charset = 'utf8mb4';
|
||||
$dsn = "mysql:unix_socket=$unix_socket;dbname=$db;charset=$charset";
|
||||
@ -24,29 +24,25 @@ function listRows($pdo, $table) {
|
||||
displayResults($query);
|
||||
}
|
||||
|
||||
function findRows($pdo, string $table, string $attr, string $param) {
|
||||
function findRows($pdo, str $table, str $attr, str $param) {
|
||||
$query = "SELECT * FROM ? WHERE ? = ?";
|
||||
$result = $pdo->prepare($query)->execute([$table, $attr, $param]);
|
||||
displayResults($query);
|
||||
}
|
||||
|
||||
function createPatient($pdo, $data) {
|
||||
$query = "INSERT INTO paciente
|
||||
(nombre, apellido, fecha_de_nacimiento, documento_identificativo, tipo_documento, direccion, localidad, provincia, pais)
|
||||
VALUES (?,?,?,?,?,?,?,?,?)";
|
||||
$pdo->prepare($query)->execute([$data["nombre"], $data["apellido"], $data["fecha_de_nacimiento"],
|
||||
$data["documento_identificativo"], $data["tipo_documento"], $data["direccion"],
|
||||
$data["localidad"], $data["provincia"], $data["pais"]]);
|
||||
$query = "INSERT INTO paciente (nombre, apellido, fecha_de_nacimiento, documento_identificativo, tipo_documento, direccion, localidad, provincia, pais) VALUES (? ? ? ? ? ? ? ? ?)";
|
||||
$pdo->prepare($query)->execute([$data["nombre"], $data["apellido"], $data["fecha_de_nacimiento"], $data["documento_identificativo"], $data["tipo_documento"], $data["direccion"], $data["localidad"], $data["provincia"], $data["pais"]]);
|
||||
return "Paciente creado con éxito";
|
||||
}
|
||||
|
||||
function editPatient($pdo, string $attr, string $param, string $id) {
|
||||
function editPatient($pdo, str $attr, str $param, str $id) {
|
||||
$query = "UPDATE paciente SET ? = ? WHERE documento_identificativo = ?";
|
||||
$pdo->prepare($query)->execute([$attr, $param, $id]);
|
||||
return "Paciente modificado con éxito";
|
||||
}
|
||||
|
||||
function deletePatient($pdo, string $id) {
|
||||
function deletePatient($pdo, str $id) {
|
||||
$check = "SELECT * FROM informes where paciente = ?";
|
||||
$result = $pdo->prepare($check)->execute([$id]);
|
||||
if($result->columnCount() == 0){
|
||||
@ -58,7 +54,7 @@ function deletePatient($pdo, string $id) {
|
||||
}
|
||||
|
||||
function createHoliday($pdo, $data) {
|
||||
$query = "INSERT INTO festivo (fecha_festivo, tipo_festivo, medico) VALUES (?,?,?)";
|
||||
$query = "INSERT INTO festivo (fecha_festivo, tipo_festivo, medico) VALUES (? ? ?)";
|
||||
$pdo->prepare($query)->execute([$data["fecha_festivo"], $data["tipo_festivo"], $data["medico"]]);
|
||||
return "Festivo creado con éxito";
|
||||
}
|
||||
@ -76,7 +72,7 @@ function deleteHoliday($pdo, str $id) {
|
||||
}
|
||||
|
||||
function createUser($pdo, $data) {
|
||||
$query = "INSERT INTO usuario (nombre, usuario, contraseña, rol, correo) VALUES (?,?,?,?,?)";
|
||||
$query = "INSERT INTO usuario (nombre, usuario, contraseña, rol, correo) VALUES (? ? ? ? ?)";
|
||||
$pdo->prepare($query)->execute([$data["nombre"], $data["usuario"], $data["contraseña"], $data["rol"], $data["correo"]]);
|
||||
return "Usuario creado con éxito";
|
||||
}
|
||||
@ -87,12 +83,12 @@ function editUser($pdo, $attr, $param, $id) {
|
||||
return "Usuario modificado con éxito";
|
||||
}
|
||||
|
||||
function deactivateUser($pdo, string $id) {
|
||||
function deactivateUser($pdo, str $id) {
|
||||
editUser($pdo, "fecha_baja", "CURRENT_TIMESTAMP", $id);
|
||||
return "Usuario desactivado con éxito";
|
||||
}
|
||||
|
||||
function listAppointments($pdo, string $doctor) {
|
||||
function listAppointments($pdo, str $doctor) {
|
||||
findRows($pdo, "cita", "medico", $doctor);
|
||||
}
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
include'database.php';
|
||||
if (isset($_POST['submit'])) {
|
||||
$data = $_POST;
|
||||
$pdo = connectDatabase("practica", "practica", "practica");
|
||||
createUser($pdo, $data);
|
||||
closeDatabase($pdo);
|
||||
}
|
Loading…
Reference in New Issue
Block a user