- Timestamp:
- 12/18/15 18:35:43 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Users.pm
r1500 r1507 101 101 /^employment$/ and do { 102 102 $arg ||= $c->stash->{user}->get_attributes('currentEmployment'); 103 104 $c->stash->{employment} = $base->get_object('employment', $arg); 105 $c->stash->{forme} = $c->model('AttrForms', 'employment', 106 $c->stash->{employment} ? $c->stash->{employment} : 'employment', $base); 107 $c->stash->{forme}->set_attrs if($c->stash->{employment}); 108 $c->stash->{template} = 'users/employment.tt'; 103 109 if ($arg) { 104 110 if ($arg =~ m/^\@/) { 105 111 $c->stash->{newemployment} = 1; 106 $c->stash->{forme} = $c->model('AttrForms', 'employment', 'employment', $base);107 112 if ($arg =~ m/\@duplicate/i) { 108 113 my $oldempl = $c->model('Accounts')->db->get_object('employment', … … 122 127 } elsif ($arg =~ m/\@create/i) { 123 128 124 my $time = str2time($c->req->param('firstday')); 125 my $lastd = DateTime->from_epoch( epoch => $time ) 126 ->set_time_zone( DateTime::TimeZone->new( name => 'local' ) ); 127 128 my ($empl) = $c->stash->{user}->listEmployment; 129 if ($empl) { 130 my $obj = $c->model('Accounts')->db->get_object('employment', $empl); 131 if (!$obj->get_attributes('lastday')) { 132 $obj->set_c_fields(lastday => $lastd->subtract(days => 1)->ymd('-')); 133 } 129 for (1) { 130 my $time = str2time($c->req->param('firstday')) or last; 131 my $lastd = DateTime->from_epoch( epoch => $time ) 132 ->set_time_zone( DateTime::TimeZone->new( name => 'local' ) ); 133 134 my ($empl) = $c->stash->{user}->listEmployment; 135 if ($empl) { 136 my $obj = $c->model('Accounts')->db->get_object('employment', $empl); 137 if (!$obj->get_attributes('lastday')) { 138 $obj->set_c_fields(lastday => $lastd->subtract(days => 1)->ymd('-')); 139 } 140 } 141 142 my $id = $username . '-' . $lastd->ymd('-'); 143 $c->req->params->{user} = $username; 144 if ($id = $c->stash->{forme}->set_attrs([ 'user', 145 map { $_->name } $c->stash->{forme}->write_attributes], $id)) { 146 $c->res->redirect($c->uri_for('/users', $username, 'employment', $id)); 147 return 1; 148 } 134 149 } 135 136 my $id = $username . '-' . $lastd->ymd('-'); 137 $c->req->params->{user} = $username; 138 if ($id = $c->stash->{forme}->set_attrs([ 'user', 139 map { $_->name } $c->stash->{forme}->write_attributes], $id)) { 140 $c->res->redirect($c->uri_for('/users', $username, 'employment', $id)); 141 return 1; 142 } 143 } 144 } else { 145 $c->stash->{employment} = $base->get_object('employment', $arg); 146 $c->stash->{forme} = $c->model('AttrForms', 'employment', $c->stash->{employment}); 147 $c->stash->{forme}->set_attrs; 150 } 148 151 } 149 152 } … … 153 156 } 154 157 155 $c->stash->{template} = 'users/employment.tt';156 158 }; 157 159 /^passwd$/ and do {
Note: See TracChangeset
for help on using the changeset viewer.