6 function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route) {
8 $scope.$routeParams = $routeParams;
9 $scope.$location = $location;
11 $scope.update = function(registration) {
13 registration.$save( function(registration) {
14 $log.info("saved", registration);
15 $log.info('id =', registration.id);
16 if ( registration.id ) {
17 $location.path( '/registration-finished/' + registration.id );
19 $log.error("can't find id in ", registration);
24 $scope.reset = function() {
25 if ( $routeParams.registrationId ) {
26 $scope.registration = new Registration();
27 $scope.registration.$get({ registrationId: $routeParams.registrationId }, function(registration) {
28 $log.info("get Registration", registration);
29 $scope.user = registration.user;
30 $scope.work = registration.work;
33 $scope.registration = new Registration({ user: {} });
34 $log.info("new Registration", $scope.user);
35 $scope.user = $scope.registration.user;
36 $scope.work = $scope.registration.work;
39 $log.info( $routeParams.registrationId );
42 $scope.$watch('user.registration_type', function( oldValue, newValue ) {
43 $log.info("registration_type watch", oldValue, newValue );
46 $scope.user.registration_type == 'lecture' ||
47 $scope.user.registration_type == 'poster' ||
48 $scope.user.registration_type == 'symposium' ||
49 $scope.user.registration_type == 'round'
52 $scope.work.type = $scope.user.registration_type;
53 $log.info( $scope.user.registration_type, " type updated");
56 type: $scope.user.registration_type,
57 persons: [ $scope.user ],
59 $log.info( $scope.user.registration_type, " type created");
61 $scope.has_work = true;
63 $log.info( $scope.user.registration_type, "NO work" );
64 $scope.has_work = false;
68 $scope.change_student = function() {
69 if ( $scope.user.student ) {
70 $scope.user.hpd_member = false;
71 $scope.user.reception = false;
72 $scope.user.dinner = false;
76 $scope.addPerson = function() {
77 $scope.work.persons.push({ firstname: '' });
80 $scope.removePerson = function(person) {
81 var persons = $scope.work.persons;
82 for (var i = 0, ii = persons.length; i < ii; i++) {
83 if (person === persons[i]) {
91 //RegistrationCtrl.$inject = [ '$scope', '$log' ];