/* Controllers */
-function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, Organizations, ValidStates) {
+function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, View, ValidStates) {
$scope.$routeParams = $routeParams;
$scope.$location = $location;
$scope.organizations = [];
- Organizations.getArrayPromise().then(function(data) {
+ View.getArrayPromise('organizations?group=true;format=key_array').then(function(data) {
$scope.organizations = data;
$log.info('organizations promise ', $scope.organizations);
});
$scope.update = function(registration, state, info_message) {
- registration.state = state;
+ if ( $scope.ValidStates.indexOf( state ) > $scope.ValidStates.indexOf( registration.state ) ) {
+ registration.state = state;
+ $log.info( 'registration.state updated to ',state);
+ } else {
+ $log.info('registration.state NOT changed');
+ }
if ( ! $scope.has_work && registration.work ) {
delete( registration.work );
registration.$save( function(registration) {
$log.info('id =', registration.id, 'state = ', registration.state);
if ( registration.id && registration.state ) {
- $log.error( $location.path(), registration.state, $routeParams );
+ $log.info( 'have id && state', $location.path(), registration.state, $routeParams );
if ( $location.path().split(/\//)[1] != registration.state ) {
$location.path( '/' + registration.state + '/' + registration.id );
} else {
$scope.user.registration_type == 'symposium' ||
$scope.user.registration_type == 'round'
) {
+ if ( angular.isUndefined( $scope.registration.work ) ) {
+ $log.info('create empty work');
+ $scope.registration.work = { persons: [ $scope.user ] };
+ if ( angular.isUndefined( $scope.work ) )
+ $scope.work = $scope.registration.work;
+ }
+
+
$scope.work.type = $scope.user.registration_type;
$scope.has_work = true;
$log.info( $scope.user.registration_type, " type updated");
$scope.show_submission_type = function() {
// FIXME check if all submission are allowed by date and allow them!
+ if ( angular.isUndefined( $scope.user ) || angular.isUndefined( $scope.registration ) ) return false;
return (
angular.isUndefined( $scope.user.registration_type ) // new registration
|| angular.isUndefined( $scope.registration.state ) // not saved yet
$scope.reset();
}
-RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'Organizations', 'ValidStates' ];
+RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'View', 'ValidStates' ];
function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidStates ) {
};
$scope.search = {};
$scope.ready = false;
- $scope.filters = [ 'student', 'hpd_member', 'reception', 'dinner' ];
+ $scope.filters = [
+ { select: 'user.student', label: 'student', name: 'filter_student' },
+ { select: 'user.hpd_member', label: 'HPD', name: 'filter_hpd' },
+ { select: 'user.reception', label: 'reception', name: 'filter_reception' },
+ { select: 'user.dinner', label: 'dinner', name: 'filter_dinner' },
+ { select: 'payment.received', label: 'payment', name: 'filter_payment' }
+ ];
$scope.show = {
registration_type: true,
filters: true,
var type = value.user.registration_type;
inc_count( type );
inc_count( '' ); // total
- angular.forEach( $scope.filters, function(subtype) {
- var v = value.user[subtype];
+ angular.forEach( $scope.filters, function(filter) {
+ var s = filter.select.split(/\./);
+ var v = value[s[0]];
+ if ( angular.isDefined( v ) ) {
+ v = v[s[1]];
+ }
if ( v === 'yes' || v === true ) {
- inc_count( subtype );
- inc_count( type + '+' + subtype );
- inc_count( '+' + subtype ); // total
+ inc_count( filter.name );
+ inc_count( type + '+' + filter.name );
+ inc_count( '+' + filter.name ); // total
+ value[filter.name] = true;
+ } else {
+ value[filter.name] = false;
}
});
// for filter
value.registration_type = type;
- angular.forEach( $scope.filters, function(f) {
- var v = value.user[f];
- value[f] = v == true || v == 'yes' ? true : false;
- });
// count registration state
inc_count( 'state+' + value.state );
-// $log.info( key, value, Counts[type] );
+// $log.info( key, value );
});
$log.info('Counts', Counts);
$scope.Counts = Counts;
$log.info('reset', $scope.search );
$scope.pager.page = 1;
}
+
+ $scope.print = {
+ layout: false,
+ center: '',
+ bold: '',
+ toggle: function(v) {
+ $log.info('print_hide', v);
+ $scope.print.layout = ! $scope.print.layout;
+ if ( v ) {
+ $scope.print.center = 'print-center';
+ $scope.print.bold = 'print-bold';
+ } else {
+ $scope.print.center = '';
+ $scope.print.bold = '';
+ }
+ }
+ }
}
ListCtrl.$inject = [ '$scope', '$log', 'Registration', 'RegistrationTypes', '$filter', 'ValidStates' ];