Changeset 236
- Timestamp:
- 06/06/09 20:46:24 (15 years ago)
- Location:
- LATMOS-Accounts-Web
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/MassEdit.pm
r235 r236 26 26 27 27 my $base = $c->stash->{db} = $c->model('Accounts')->db; 28 28 29 if ($c->req->param('otype') && $c->req->param('otype') ne $c->session->{filter}{otype}) { 29 30 $c->session->{filter} = undef; … … 37 38 $c->req->params->{attrcol} = $c->session->{massedit}{attrcol}; 38 39 } 40 } 41 42 if (($c->req->param('_change') || '') eq 'all') { 43 my %change; 44 foreach ($c->req->param('attrcol')) { 45 $change{$_} = $c->req->param($_) || undef; 46 delete($c->req->params->{$_}); 47 } 48 foreach my $id ($c->req->param('objid')) { 49 my $obj = $base->get_object($c->req->param('otype'), $id) or next; 50 $obj->set_c_fields(%change); 51 } 52 $base->commit; 53 } elsif (($c->req->param('_change') || '') eq 'perobj') { 54 foreach my $id ($c->req->param('objid')) { 55 my $obj = $base->get_object($c->req->param('otype'), $id) or next; 56 my %change; 57 foreach ($c->req->param('attrcol')) { 58 $change{$_} = $c->req->param($id . '_' . $_) || undef; 59 delete($c->req->params->{$id . '_' . $_}); 60 } 61 $obj->set_c_fields(%change); 62 } 63 $base->commit; 39 64 } 40 65 $c->forward('filter'); -
LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm
r215 r236 19 19 uidNumber => [ 'UID', 'text:6' ], 20 20 gidNumber => [ 'GID', 'select:group:gidNumber' ], 21 manager => [ 'Responsable', 'select-N:user :uid' ],22 managedBy => [ 'Responsable', 'select-N:user :uid' ],21 manager => [ 'Responsable', 'select-N:user' ], 22 managedBy => [ 'Responsable', 'select-N:user' ], 23 23 sn => [ 'Nom' ], 24 24 givenName => [ 'Prénom' ], … … 37 37 expire => [ 'Expire le', 'date' ], 38 38 st => [ 'Ãtat (US)' ], 39 sutype => [ 'Structure admin.', 'select-N:sutype :name' ],39 sutype => [ 'Structure admin.', 'select-N:sutype' ], 40 40 exported => [ 'Exporté', 'checkbox' ], 41 41 locked => [ 'Vérouillé', 'checkbox' ], … … 176 176 $type ||= 'text'; 177 177 $type = 'text:6' if (($self->{form} || '') =~ /^group/ && $attr eq 'gidNumber'); 178 my $htmlname = ($self->{object} ? $self->{object}->id . '_' : '') . $attr; 178 179 for ($type) { 179 180 /^textarea$/ and return sprintf( 180 181 '<textarea name="%s" cols="40">%s</textarea>', 181 $self->escape($ attr),182 $self->escape($htmlname), 182 183 $self->escape($self->attr_raw_value($attr)), 183 184 ); … … 195 196 $html .= sprintf( 196 197 '<input type="text" name="%s" value="%s" size="12">', 197 $ attr,198 $htmlname, 198 199 $self->escape($date) 199 200 ); … … 201 202 $html .= qq{ 202 203 <A HREF="#" 203 onClick="cal13.select(document.forms[0].$ attr,'anchor13','dd/MM/yyyy');return false;"204 TITLE="cal13.select(document.forms[0].$ attr,'anchor13','dd/MM/yyyy'); return false;"204 onClick="cal13.select(document.forms[0].$htmlname,'anchor13','dd/MM/yyyy');return false;" 205 TITLE="cal13.select(document.forms[0].$htmlname,'anchor13','dd/MM/yyyy'); return false;" 205 206 NAME="anchor13" ID="anchor13"> 206 207 <img src="} . $self->{c}->uri_for(qw(/static icons view-calendar-day.png)) … … 210 211 /^checkbox$/ and do { 211 212 return sprintf('<input type="checkbox" name="%s"%s>', 212 $ attr,213 $self->escape($htmlname), 213 214 $self->attr_raw_value($attr) ? ' checked="yes"' : '' 214 215 ); … … 219 220 my $keyfield = $3; 220 221 my $select = sprintf('<select name="%s">', 221 $self->escape($ attr)) . "\n";222 $self->escape($htmlname)) . "\n"; 222 223 $select .= '<option value="">--</option>' . "\n" if ($options =~ /N/); 223 224 my $value = $self->attr_raw_value($attr) || ''; … … 239 240 return sprintf( 240 241 '<input type="text" name="%s" value="%s" size="%d">', 241 $ attr,242 $self->escape($htmlname), 242 243 $self->escape($self->attr_raw_value($attr)), 243 244 $1 || 30, … … 258 259 my ($self) = @_; 259 260 $self->{c}->req->param($self->label) or return; 261 my $prefix = $self->{object}->id . '_'; 260 262 $self->{object}->set_c_fields( 261 263 map { 262 264 $_ => 263 265 ($attrs->{$_}[1] || '') eq 'checkbox' 264 ? ($self->{c}->req->param( $_) ? 1 : 0)265 : $self->{c}->req->param($_)266 ? ($self->{c}->req->param("$prefix$_") ? 1 : 0) 267 : ($self->{c}->req->param("$prefix$_") || undef) 266 268 } $self->attributes 267 269 ) or return; -
LATMOS-Accounts-Web/root/html/massedit/index.tt
r234 r236 47 47 <form action="[% c.uri_for() %]" method="POST"> 48 48 <input type="hidden" name="otype" value="[% c.req.param('otype') %]"> 49 <input type="hidden" name="_change" value="all"> 50 [% FOREACH obj = objectslist %] 51 <input type="hidden" name="objid" value="[% obj.id | html %]"> 52 [% END %] 49 53 [% FOREACH atcol = c.req.param('attrcol') %] 50 54 [% NEXT IF NOT atcol %] 51 <input type="hidden" name="attrcol" value="[% atcol %]">52 55 [% END %] 53 56 <tr> … … 66 69 <form action="[% c.uri_for() %]" method="POST"> 67 70 <input type="hidden" name="otype" value="[% c.req.param('otype') %]"> 71 <input type="hidden" name="_change" value="perobj"> 68 72 [% FOREACH atcol = c.req.param('attrcol') %] 69 73 [% NEXT IF NOT atcol %] 70 <input type="hidden" name="attrcol" value="[% atcol %]">71 74 [% END %] 72 75 [% FOREACH obj = objectslist %] 73 76 [% attrform = c.model('AttrForms', c.req.param('otype'), obj) %] 74 77 <tr> 75 <th>[% obj.id | html %]</th> 78 <th>[% obj.id | html %] 79 <input type="hidden" name="objid" value="[% obj.id | html %]"> 80 </th> 76 81 [% FOREACH atcol = c.req.param('attrcol') %] 77 82 [% NEXT IF NOT atcol %]
Note: See TracChangeset
for help on using the changeset viewer.