Lines 92-103
sub add {
Link Here
|
92 |
|
92 |
|
93 |
my $body = $c->req->json; |
93 |
my $body = $c->req->json; |
94 |
|
94 |
|
95 |
my $periods = delete $body->{periods} // []; |
95 |
my $periods = delete $body->{periods} // []; |
96 |
my $user_roles = delete $body->{user_roles} // []; |
96 |
my $user_roles = delete $body->{user_roles} // []; |
97 |
my $agreement_licenses = delete $body->{agreement_licenses} // []; |
97 |
my $agreement_licenses = delete $body->{agreement_licenses} // []; |
98 |
my $agreement_relationships = delete $body->{agreement_relationships} // []; |
98 |
my $agreement_relationships = delete $body->{agreement_relationships} // []; |
99 |
my $documents = delete $body->{documents} // []; |
99 |
my $documents = delete $body->{documents} // []; |
100 |
my $extended_attributes = delete $body->{extended_attributes} // []; |
100 |
my $extended_attributes = delete $body->{extended_attributes} // []; |
101 |
|
101 |
|
102 |
my $agreement = Koha::ERM::Agreement->new_from_api($body)->store; |
102 |
my $agreement = Koha::ERM::Agreement->new_from_api($body)->store; |
103 |
$agreement->periods($periods); |
103 |
$agreement->periods($periods); |
Lines 106-112
sub add {
Link Here
|
106 |
$agreement->agreement_relationships($agreement_relationships); |
106 |
$agreement->agreement_relationships($agreement_relationships); |
107 |
$agreement->documents($documents); |
107 |
$agreement->documents($documents); |
108 |
|
108 |
|
109 |
my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; |
109 |
my @extended_attributes = |
|
|
110 |
map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes}; |
110 |
$agreement->extended_attributes( \@extended_attributes ); |
111 |
$agreement->extended_attributes( \@extended_attributes ); |
111 |
|
112 |
|
112 |
$c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); |
113 |
$c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); |
Lines 180-191
sub update {
Link Here
|
180 |
|
181 |
|
181 |
my $body = $c->req->json; |
182 |
my $body = $c->req->json; |
182 |
|
183 |
|
183 |
my $periods = delete $body->{periods} // []; |
184 |
my $periods = delete $body->{periods} // []; |
184 |
my $user_roles = delete $body->{user_roles} // []; |
185 |
my $user_roles = delete $body->{user_roles} // []; |
185 |
my $agreement_licenses = delete $body->{agreement_licenses} // []; |
186 |
my $agreement_licenses = delete $body->{agreement_licenses} // []; |
186 |
my $agreement_relationships = delete $body->{agreement_relationships} // []; |
187 |
my $agreement_relationships = delete $body->{agreement_relationships} // []; |
187 |
my $documents = delete $body->{documents} // []; |
188 |
my $documents = delete $body->{documents} // []; |
188 |
my $extended_attributes = delete $body->{extended_attributes} // []; |
189 |
my $extended_attributes = delete $body->{extended_attributes} // []; |
189 |
|
190 |
|
190 |
$agreement->set_from_api($body)->store; |
191 |
$agreement->set_from_api($body)->store; |
191 |
$agreement->periods($periods); |
192 |
$agreement->periods($periods); |
Lines 194-200
sub update {
Link Here
|
194 |
$agreement->agreement_relationships($agreement_relationships); |
195 |
$agreement->agreement_relationships($agreement_relationships); |
195 |
$agreement->documents($documents); |
196 |
$agreement->documents($documents); |
196 |
|
197 |
|
197 |
my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; |
198 |
my @extended_attributes = |
|
|
199 |
map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes}; |
198 |
$agreement->extended_attributes( \@extended_attributes ); |
200 |
$agreement->extended_attributes( \@extended_attributes ); |
199 |
|
201 |
|
200 |
$c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); |
202 |
$c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); |