Skip to content

Commit

Permalink
asignacion paso1 asginar automáticamente alumnos según transporte en
Browse files Browse the repository at this point in the history
coche o público
  • Loading branch information
DaniS authored and DaniS committed Jun 22, 2020
1 parent 9d8d4e1 commit 2ce9dac
Show file tree
Hide file tree
Showing 7 changed files with 415 additions and 184 deletions.
26 changes: 10 additions & 16 deletions GestionFCT/application/controllers/Asignar.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,9 @@ public function cPost(){
$mode = $alumno->metodo_transporte;

$arrResultado = devolverSedeMasCercana($this,$origen,$mode);
//[idSede] => 3
//[distancia] => 6,7 km
//[duracion] => 10 min

$this->Asignar_model->crearPractica($alumno->id,$arrResultado['idSede'],$arrResultado['distancia'],$arrResultado['duracion'],$_SESSION['user']->id,$idGrupo);

// echo "<pre>";
// print_r($arrResultado);
// echo "</pre>";

}

} else {
Expand All @@ -47,20 +42,19 @@ public function cPost(){
}
}

public function cPostTest(){
$idGrupo = isset($_GET["idGrupo"])?$_GET["idGrupo"]:null;
$idsAlumno = isset($_GET["idsAlumnos"])?$_GET["idsAlumnos"]:[];

echo print_r($idsAlumno);
}

public function paso1(){
verificarRol();


$this->load->model('Anexo_model');
$data['scripts']=['Sortable.min','asignar'];
$data['anexos']=$this->Anexo_model->getAnexosCursoActual();
frame($this, "asignar/paso1",$data);
}

public function mockup(){
verificarRol();
$data['scripts']=['Sortable.min','asignar'];
frame($this, "asignar/mockup",$data);
}

}
?>
Expand Down
10 changes: 8 additions & 2 deletions GestionFCT/application/helpers/mihelper_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,21 @@ function devolverSedeMasCercana($controlador,$origen,$mode){
$clave=""; $distanceValue=0; $distancia="";$duracion="";

foreach ($resultado['rows'][0]['elements'] as $k=>$v){
$distanceValueSede = $v['distance']['value'];
/*
if($mode=="driving"){$distanceValueSede = $v['distance']['value'];}
else{$distanceValueSede = $v['duration']['value'];}
*/

if($distanceValue==0){
$clave=$k;
$distanceValue=$v['distance']['value'];
$distanceValue=$distanceValueSede;
$distancia=$v['distance']['text'];
$duracion = $v['duration']['text'];
} else {
if($v['distance']['value'] < $distanceValue){
$clave=$k;
$distanceValue=$v['distance']['value'];
$distanceValue=$distanceValueSede;
$distancia=$v['distance']['text'];
$duracion = $v['duration']['text'];
}
Expand Down
13 changes: 13 additions & 0 deletions GestionFCT/application/models/Anexo_model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class Anexo_model extends CI_Model
{
function getAnexos(){
return R::findAll('anexo');
}

function getAnexosCursoActual(){
return R::findAll('anexo','cursoacademico_id=?',[getCursoActual()->id]);
}
}
?>
6 changes: 5 additions & 1 deletion GestionFCT/application/models/Asignar_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function crearPractica($idAlumno,$idSede,$distancia,$duracion,$idUsuario,$idGrup
$grupo = R::load('grupo', $idGrupo);
$cursoAcademico = getCursoActual();
$idCursoAcademico=$cursoAcademico->id;
$anexo = R::find('anexo','cursoacademico_id=? AND sede_id=?',[$idCursoAcademico,$idSede]);
$anexo = R::findOne('anexo','cursoacademico_id=? AND sede_id=?',[$idCursoAcademico,$idSede]);

if($anexo==null){
$anexo = R::dispense('anexo');
Expand All @@ -36,6 +36,10 @@ function crearPractica($idAlumno,$idSede,$distancia,$duracion,$idUsuario,$idGrup
$practica->grupo = $grupo;
$practica->alumno = $alumno;
R::store($practica);

$previsionPuestos = R::findOne('previsionpuestos','cursoacademico_id=? AND sede_id=?',[$idCursoAcademico,$idSede]);
$previsionPuestos->numero = (int)$previsionPuestos->numero - 1;
R::store($previsionPuestos);
}
}
?>
2 changes: 1 addition & 1 deletion GestionFCT/application/views/asignar/c.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function cargarAlumnos(url,datos){
for(opcion in respuesta){
var idAlumno = respuesta[opcion].id;
var nombreGrupo = respuesta[opcion].nombre;
alumnosCk.innerHTML+='<div class="form-check form-check-inline"><input class="form-check-input idsAlumnos" type="checkbox" name="idsAlumnos[]" id="idAlumno'+idAlumno+'" value="'+idAlumno+'"><label class="form-check-label" for="idAlumno'+idAlumno+'">'+nombreGrupo+'</label></div>';
alumnosCk.innerHTML+='<div class="form-check form-check-inline"><input class="form-check-input idsAlumnos" type="checkbox" name="idsAlumnos[]" id="idAlumno'+idAlumno+'" value="'+idAlumno+'" checked><label class="form-check-label" for="idAlumno'+idAlumno+'">'+nombreGrupo+'</label></div>';
}

}
Expand Down
Loading

0 comments on commit 2ce9dac

Please sign in to comment.