Initial state

This commit is contained in:
2023-05-16 10:16:21 -06:00
commit c3c0108143
167 changed files with 20135 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
<?php
$ruta = "../";
require_once "../include/bd_pdo.php";
$id = trim(filter_input(INPUT_POST, "id", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
if(isset($_POST["dlfacultad"]))
$facultad = trim(filter_input(INPUT_POST, "dlfacultad", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
else
$facultad = trim(filter_input(INPUT_POST, "mfacultad", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
$clave = trim(filter_input(INPUT_POST, "mclave", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
$grado = trim(filter_input(INPUT_POST, "grado", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
$nombre = trim(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
$grado = mb_strtoupper($grado);
if(!empty($grado)){
if(!ctype_space($grado)){
if($grado[strlen($grado)-1] != '.')
$grado.='.';
}
else{
$grado="";
}
}
$fs_profesores = query(//revisar si existe la clave del profesor
"SELECT * FROM fs_profesor WHERE clave = :clave",
array(":clave" => $_POST["mclave"]),
true
);
if(!$fs_profesores){//hay que crearlo desde 0 (profesor) y agregarlo a su facultad(facultad_profesor)
$profesor_id = query(
"SELECT public.fi_profesor(
:nombre,
:clave,
:facultad,
null,
:grado
)",
array(":nombre" => mb_strtoupper($nombre), ":clave" => $clave, ":facultad" => $facultad, ":grado" => $grado),
true
);
header("Location: ../profesores.php");
exit();
}
else{//el profesor ya existe
$profac = query(
"SELECT * FROM facultad_profesor WHERE facultad_id = :facultad AND profesor_id = :profesor",
array(":facultad" => $facultad, ":profesor" => $fs_profesores["id"]),
true
);
if(!$profac){//agregarlo a la facultad (facultad_profesor)
query(
"SELECT fi_facultad_profesor(
:facultad,
:profesor
)",
array(":facultad" => $facultad, ":profesor" => $fs_profesores["id"]),
true
);
header("Location: ../profesores.php");
exit();
}
else{//regresar error (ya existe este profesor en esta facultad)
//print_r($profac);
if(!$profac['fp_activo']){
query(
"SELECT fu_estado_facultad_profesor(:idprofesor, :idfacultad, :estado)",
array(":idprofesor" => $fs_profesores["id"], ":idfacultad" => $facultad, ":estado" => true),
true
);
header("Location: ../profesores.php");
exit();
}
header("Location: ../profesores.php?error=1");
#exit();
}
}
?>