eaiovnaovbqoebvqoeavibavo obtener_conexion(); $sql="insert into notificacion(id_alumno, asunto, mensaje, created_at) values(3363, :asunto, :mensaje, now())"; $estado=$conexion->prepare($sql); $estado->bindParam(':asunto',$asunto); $estado->bindParam(':mensaje',$mensaje); if(!$estado){ return 'Error al guardar'; }else{ $estado->execute(); return $conexion->lastInsertId(); } } public function registrarAsistencia($carnet, $descripcion, $fecha){ $modelo= new Conexion(); $conexion=$modelo->obtener_conexion(); $sql="insert into asistencias(id_alumno, excusa, tipo, created_at, updated_at) values(:carnet, :descripcion, 'entrada', :fecha, now())"; $estado=$conexion->prepare($sql); $estado->bindParam(':carnet',$carnet); $estado->bindParam(':descripcion',$descripcion); $estado->bindParam(':fecha',$fecha); if(!$estado){ return 'Error al guardar'; }else{ $estado->execute(); return $conexion->lastInsertId(); } } function buscarTokens(){ $modelo= new Conexion(); $conexion=$modelo->obtener_conexion(); $sql="select token from token_notification"; $estado=$conexion->prepare($sql); $estado->execute(); while($result = $estado->fetch()){ $rows[]=$result; } if(!isset($rows)){ $rows=null; } return $rows; } function buscarAlumnos(){ $modelo= new Conexion(); $conexion=$modelo->obtener_conexion(); $sql="select carnet, apellidos, nombres from alumno"; $estado=$conexion->prepare($sql); $estado->execute(); while($result = $estado->fetch()){ $rows[]=$result; } if(!isset($rows)){ $rows=null; } return $rows; } function buscarJustificar(){ $modelo= new Conexion(); $conexion=$modelo->obtener_conexion(); $sql="select alumno.carnet,alumno.apellidos, alumno.nombres, justificar.id, justificar.descripcion, justificar.telefono, justificar.created_at from justificar INNER JOIN alumno ON alumno.carnet = justificar.id_alumno WHERE justificar.estado=1"; $estado=$conexion->prepare($sql); $estado->execute(); while($result = $estado->fetch()){ $rows[]=$result; } if(!isset($rows)){ $rows=null; } return $rows; } function buscarJustificacionesAprobadas(){ $modelo= new Conexion(); $conexion=$modelo->obtener_conexion(); $sql="select alumno.carnet,alumno.apellidos, alumno.nombres, justificar.id, justificar.descripcion, justificar.telefono, justificar.created_at from justificar INNER JOIN alumno ON alumno.carnet = justificar.id_alumno WHERE justificar.estado=2"; $estado=$conexion->prepare($sql); $estado->execute(); while($result = $estado->fetch()){ $rows[]=$result; } if(!isset($rows)){ $rows=null; } return $rows; } function aprobarJustificacion($id_justificacion){ $modelo= new Conexion(); $conexion=$modelo->obtener_conexion(); $sql="update justificar SET estado=2 where id=:id_justificacion"; $estado=$conexion->prepare($sql); $estado->bindParam(':id_justificacion',$id_justificacion); if(!$estado){ return 'Error al guardar'; }else{ $estado->execute(); return 'Datos guardados con exito'; } } function rechazarJustificacion($id_justificacion){ $modelo= new Conexion(); $conexion=$modelo->obtener_conexion(); $sql="update justificar SET estado=3 where id=:id_justificacion"; $estado=$conexion->prepare($sql); $estado->bindParam(':id_justificacion',$id_justificacion); if(!$estado){ return 'Error al guardar'; }else{ $estado->execute(); return 'Datos guardados con exito'; } } } ?>