You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchController.js

122 lines
3.7 KiB

evoapp.controller('SearchController', function($rootScope, $scope, $timeout, $compile, $injector, $filter, globals)
{
$scope.globals = globals;
$scope.searching = {Name: ''};//new globals.dataService.record('Discipline');
//TODO: this one might have a different name!!!
$scope.storeResumoTrabalhador = new globals.dataService.store({
model: null,
actions: {
get: 'getResumoTrabalhador'
}
});
$scope.storeFichasTrabalhador = new globals.dataService.store({
model: null,
actions: {
}
});
$scope.dadosTrabalhador = null;
$scope.list = function(){
//$scope.storeFichasTrabalhador.items = [];
//$scope.storeFichasTrabalhador.loadData($scope.testArray);
//$scope.storeFichasTrabalhador.loadData([{data: '12-12-2012', responsavel: 'responsavel 1'}]);
};
$scope.edit = function(selected){
$scope.$parent.loadModule({Controller: 'Form1'}, function(className, scope, isNewModule){
scope.edit(selected);
});
};
$scope.add = function(selected){
$scope.$parent.loadModule({Controller: selected.Controller}, function(className, scope, isNewModule){
scope.descricao = selected.descricao;
//NOTICE: vais receber estrutura com array de fichas + ficha pré-preenchida...
var newRecord = {
ficha: $scope.dadosTrabalhador
};
newRecord.ficha.tipo_ficha_id = selected.id;
newRecord.ficha.data_conclusao = null;
scope.add(newRecord);
});
};
$scope.clear = function(){
$scope.dadosTrabalhador = null;
$scope.storeFichasTrabalhador.items = [];
$scope.comboEmpresas.setValue(null);
$scope.comboEstabelecimentos.clear();
$scope.comboTrabalhadores.clear();
};
$scope.onEmpresaChange = function(selectedValue, selectedRecord){
$scope.comboEstabelecimentos.clear();
$scope.comboTrabalhadores.clear();
$scope.comboEstabelecimentos.store.extraParams = {
empresaID: selectedRecord.id
};
$scope.comboEstabelecimentos.loadStore(function(response, status, headers, config, items){
});
};
$scope.onEstabelecimentoChange = function(selectedValue, selectedRecord){
$scope.comboTrabalhadores.setValue(null);
$scope.comboTrabalhadores.clear();
$scope.comboTrabalhadores.store.extraParams = {
estabelecimentoID: selectedRecord.id
};
$scope.comboTrabalhadores.loadStore(function(response, status, headers, config, items){
});
};
$scope.onTrabalhadorChange = function(selectedValue, selectedRecord){
$scope.storeResumoTrabalhador.extraParams = {
trabalhadorID: selectedRecord.id
};
$scope.storeResumoTrabalhador.get(function(response, status, headers, config, items){
if(response.data.dadosTrabalhador)
{
$scope.dadosTrabalhador = response.data.dadosTrabalhador;
}
var fichas = response.data.fichas;
$scope.storeFichasTrabalhador.items = [];
$scope.storeFichasTrabalhador.loadData(fichas);
});
};
$scope.$on('afterrender', function(event, args){
$scope.comboEmpresas.loadStore(function(response, status, headers, config, items){
});
});
});