Sei sulla pagina 1di 2

/**

* Created by gfiorini on 20/02/14.


*/
//create the controller and inject Angular's $scope
angular
.module('phoenixApp')
.controller(
'ricercaAppelliController',
[
'$rootScope',
'$scope',
'$location',
'ngProgress',
'TipoStudenteService',
'$log',
function($rootScope, $scope, $location, ngProgress,
TipoStudenteService, $log) {
ngProgress.complete();

$rootScope.isPrenotabile = function(esame) {

var d = new Date();


var now = moment(d.getDate() + "/"
+ (d.getMonth() + 1) + "/"
+ d.getFullYear(), "DD-MM-YYYY");

var inizioPrenotazione = moment(


esame.dataInizioPrenotazione,
"DD-MM-YYYY");
var finePrenotazione = moment(
esame.dataFinePrenotazione,
"DD-MM-YYYY");

if ((now.isSame(inizioPrenotazione) ||
now.isSame(finePrenotazione))
|| (inizioPrenotazione.isBefore(now) &&
(now
.isBefore(finePrenotazione)))
)
return true;
return false;

};

if ($rootScope.anagrafica.tipoStudente == -1) {
var tipoStudente = TipoStudenteService.get();

tipoStudente.$promise
.then(
function(result) {
if (result.livelloErrore == 0) {

$rootScope.anagrafica.tipoStudente = result.risultato;
// $log.info("update
// tipoStudente : " +
// result.risultato);

redirect();
}
},
function(error) {
$rootScope
.messageBox(
'Esami sostenibili',
"warn",
"Alcuni dati non sono
momentaneamente disponibili. Riprovare più tardi.");
$log.warn(error);
});
} else {
redirect();
}

function redirect() {

console.log('scope.anagrafica.tipoStudente '
+ $scope.anagrafica.tipoStudente);
$rootScope.showResearchBox = true;
switch ($scope.anagrafica.tipoStudente) {

case null:
// Carriera chiusa

$rootScope.showResearchBox = true;
//console.log('$rootScope.showResearchBox ' +
$rootScope.showResearchBox);
//$location.path('/corsiLaurea/ricerca509');
$scope.anagrafic.accessoPrenotazione=true;

$location.path('/corsiLaurea/ricercaAppelliSostenibili'); //270PF
break;
case 1:
// 509 Nuovi stati introdotti con Tep
// (09/11/2012) decodificati da
// AnagraficaServiceDAO.getTipoStudente
$location.path('/corsiLaurea/ricerca509');
break;
case 2:

$location.path('/corsiLaurea/ricercaAppelliSostenibili'); //270PF
break;
default:
$location.path('/corsiLaurea/ricerca509');
//270
break;
}
}

} ]);

Potrebbero piacerti anche