|
Lines 30-38
use C4::Members;
Link Here
|
| 30 |
use List::MoreUtils qw/any uniq/; |
30 |
use List::MoreUtils qw/any uniq/; |
| 31 |
use Koha::DateUtils; |
31 |
use Koha::DateUtils; |
| 32 |
use C4::Members::Attributes qw(GetBorrowerAttributes); |
32 |
use C4::Members::Attributes qw(GetBorrowerAttributes); |
|
|
33 |
use JSON; |
| 34 |
use Data::Dumper; |
| 33 |
|
35 |
|
| 34 |
use Koha::Patrons; |
36 |
use Koha::Patrons; |
| 35 |
use Koha::Patron::Categories; |
37 |
use Koha::Patron::Categories; |
|
|
38 |
use Koha::Account::Lines; |
| 36 |
|
39 |
|
| 37 |
my $input = CGI->new; |
40 |
my $input = CGI->new; |
| 38 |
|
41 |
|
|
Lines 92-97
if ( $op eq 'export_barcodes' ) {
Link Here
|
| 92 |
} |
95 |
} |
| 93 |
} |
96 |
} |
| 94 |
|
97 |
|
|
|
98 |
if($op eq 'export_gdprdata') { |
| 99 |
my $exportedData = { |
| 100 |
'patron' => { |
| 101 |
'title' => $patron->title, |
| 102 |
'surname' => $patron->surname, |
| 103 |
'firstname' => $patron->firstname, |
| 104 |
'othernames' => $patron->othernames, |
| 105 |
'initials' => $patron->initials, |
| 106 |
'streetnumber' => $patron->streetnumber, |
| 107 |
'streettype' => $patron->streettype, |
| 108 |
'address' => $patron->address, |
| 109 |
'address2' => $patron->address2, |
| 110 |
'city' => $patron->city, |
| 111 |
'state' => $patron->state, |
| 112 |
'zipcode' => $patron->zipcode, |
| 113 |
'country' => $patron->country, |
| 114 |
'category_type' => $patron->category->category_type, |
| 115 |
'email' => $patron->email, |
| 116 |
'phone' => $patron->phone, |
| 117 |
'mobile' => $patron->mobile, |
| 118 |
'fax' => $patron->fax, |
| 119 |
'emailpro' => $patron->emailpro, |
| 120 |
'phonepro' => $patron->phonepro, |
| 121 |
'B_streetnumber' => $patron->B_streetnumber, |
| 122 |
'B_streettype' => $patron->B_streettype, |
| 123 |
'B_address' => $patron->B_address, |
| 124 |
'B_address2' => $patron->B_address2, |
| 125 |
'B_city' => $patron->B_city, |
| 126 |
'B_state' => $patron->B_state, |
| 127 |
'B_zipcode' => $patron->B_zipcode, |
| 128 |
'B_country' => $patron->B_country, |
| 129 |
'B_email' => $patron->B_email, |
| 130 |
'B_phone' => $patron->B_phone, |
| 131 |
'dateoffbirth' => $patron->dateofbirth, |
| 132 |
'categorycode' => $patron->categorycode, |
| 133 |
'dateenrolled' => $patron->dateenrolled, |
| 134 |
'dateexpiry' => $patron->dateexpiry, |
| 135 |
'date_renewed' => $patron->date_renewed, |
| 136 |
'gonenoaddress' => $patron->gonenoaddress, |
| 137 |
'lost' => $patron->lost, |
| 138 |
'debarred' => $patron->debarred, |
| 139 |
'debarredcomment' => $patron->debarredcomment, |
| 140 |
'contactname' => $patron->contactname, |
| 141 |
'contactfirstname' => $patron->contactfirstname, |
| 142 |
'contacttitle' => $patron->contacttitle, |
| 143 |
'borrowernotes' => $patron->borrowernotes, |
| 144 |
'sex' => $patron->sex, |
| 145 |
'userid' => $patron->userid, |
| 146 |
'opacnote' => $patron->opacnote, |
| 147 |
'contactnote' => $patron->contactnote, |
| 148 |
'altcontactfirstname' => $patron->altcontactfirstname, |
| 149 |
'altcontactsurname' => $patron->altcontactsurname, |
| 150 |
'altcontactaddress1' => $patron->altcontactaddress1, |
| 151 |
'altcontactaddress2' => $patron->altcontactaddress2, |
| 152 |
'altcontactaddress3' => $patron->altcontactaddress3, |
| 153 |
'altcontactstate' => $patron->altcontactstate, |
| 154 |
'altcontactzipcode' => $patron->altcontactzipcode, |
| 155 |
'altcontactcountry' => $patron->altcontactcountry, |
| 156 |
'altcontactphone' => $patron->altcontactphone, |
| 157 |
'smsalertnumber' => $patron->smsalertnumber, |
| 158 |
'updated_on' => $patron->updated_on, |
| 159 |
'lastseen' => $patron->lastseen, |
| 160 |
'lang' => $patron->lang, |
| 161 |
'login_attempts' => $patron->login_attempts, |
| 162 |
'account_locked' => $patron->account_locked, |
| 163 |
'age' => $patron->get_age, |
| 164 |
'has_overdues' => $patron->has_overdues, |
| 165 |
'borrowernumber' => $patron->borrowernumber, |
| 166 |
'cardnumber' => $patron->cardnumber, |
| 167 |
'branchcode' => $patron->branchcode, |
| 168 |
}, |
| 169 |
}; |
| 170 |
|
| 171 |
my $guarantor = $patron->guarantor(); |
| 172 |
if($guarantor) { |
| 173 |
$exportedData->{'patron'}->{'guarantor'} = |
| 174 |
$guarantor->{'borrowernumber'}; |
| 175 |
} |
| 176 |
my @guarantees = $patron->guarantees(); |
| 177 |
if(@guarantees) { |
| 178 |
foreach my $bod (@guarantees) { |
| 179 |
push @{$exportedData->{'patron'}->{'guarantees'}}, $bod->borrowernumber; |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
my $image = $patron->image; |
| 184 |
if($image) { |
| 185 |
$exportedData->{'image'} = { |
| 186 |
'mimetype' => $image->mimetype, |
| 187 |
'imagefile' => $image->imagefile, |
| 188 |
}; |
| 189 |
} |
| 190 |
|
| 191 |
my $holds = $patron->holds; |
| 192 |
if($holds) { |
| 193 |
while(my $hold = $holds->next()) { |
| 194 |
push @{$exportedData->{'holds'}}, { |
| 195 |
'reserve_id' => $hold->reserve_id, |
| 196 |
'reservedate' => $hold->reservedate, |
| 197 |
'biblionumber' => $hold->biblionumber, |
| 198 |
'branchcode' => $hold->branchcode, |
| 199 |
'nofificationdate' => $hold->notificationdate, |
| 200 |
'reminderdate' => $hold->reminderdate, |
| 201 |
'cancellationdate' => $hold->cancellationdate, |
| 202 |
'reservenotes' => $hold->reservenotes, |
| 203 |
'priority' => $hold->priority, |
| 204 |
'found' => $hold->found, |
| 205 |
'timestamp' => $hold->timestamp, |
| 206 |
'itemnumber' => $hold->itemnumber, |
| 207 |
'waitingdate' => $hold->waitingdate, |
| 208 |
'expirationdate' => $hold->expirationdate, |
| 209 |
'lowestPriority' => $hold->lowestPriority, |
| 210 |
'suspend' => $hold->suspend, |
| 211 |
'suspend_until' => $hold->suspend_until, |
| 212 |
'itemtype' => $hold->itemtype, |
| 213 |
} |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
my $oldHolds = $patron->old_holds; |
| 218 |
if($oldHolds) { |
| 219 |
while(my $hold = $oldHolds->next()) { |
| 220 |
push @{$exportedData->{'holds'}}, { |
| 221 |
'reserve_id' => $hold->reserve_id, |
| 222 |
'reservedate' => $hold->reservedate, |
| 223 |
'biblionumber' => $hold->biblionumber, |
| 224 |
'branchcode' => $hold->branchcode, |
| 225 |
'nofificationdate' => $hold->notificationdate, |
| 226 |
'reminderdate' => $hold->reminderdate, |
| 227 |
'cancellationdate' => $hold->cancellationdate, |
| 228 |
'reservenotes' => $hold->reservenotes, |
| 229 |
'priority' => $hold->priority, |
| 230 |
'found' => $hold->found, |
| 231 |
'timestamp' => $hold->timestamp, |
| 232 |
'itemnumber' => $hold->itemnumber, |
| 233 |
'waitingdate' => $hold->waitingdate, |
| 234 |
'expirationdate' => $hold->expirationdate, |
| 235 |
'lowestPriority' => $hold->lowestPriority, |
| 236 |
'suspend' => $hold->suspend, |
| 237 |
'suspend_until' => $hold->suspend_until, |
| 238 |
'itemtype' => $hold->itemtype, |
| 239 |
} |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
my $checkouts = $patron->checkouts; |
| 244 |
if($checkouts) { |
| 245 |
while(my $checkout = $checkouts->next()) { |
| 246 |
push @{$exportedData->{'checkouts'}}, { |
| 247 |
'issue_id' => $checkout->issue_id, |
| 248 |
'itemnumber' => $checkout->itemnumber, |
| 249 |
'date_due' => $checkout->date_due, |
| 250 |
'branchcode' => $checkout->branchcode, |
| 251 |
'returndate' => $checkout->returndate, |
| 252 |
'lastreneweddate' => $checkout->lastreneweddate, |
| 253 |
'renewals' =>$checkout->renewals, |
| 254 |
'auto_renew' => $checkout->auto_renew, |
| 255 |
'auto_renew_error' => $checkout->auto_renew_error, |
| 256 |
'timestamp' => $checkout->timestamp, |
| 257 |
'issuedate' => $checkout->issuedate, |
| 258 |
'onsite_checkout' => $checkout->onsite_checkout, |
| 259 |
'note' => $checkout->note, |
| 260 |
'notedate' => $checkout->notedate, |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
my $oldCheckouts = $patron->old_checkouts; |
| 266 |
if($oldCheckouts) { |
| 267 |
while(my $checkout = $oldCheckouts->next()) { |
| 268 |
push @{$exportedData->{'checkouts'}}, { |
| 269 |
'issue_id' => $checkout->issue_id, |
| 270 |
'itemnumber' => $checkout->itemnumber, |
| 271 |
'date_due' => $checkout->date_due, |
| 272 |
'branchcode' => $checkout->branchcode, |
| 273 |
'returndate' => $checkout->returndate, |
| 274 |
'lastreneweddate' => $checkout->lastreneweddate, |
| 275 |
'renewals' =>$checkout->renewals, |
| 276 |
'auto_renew' => $checkout->auto_renew, |
| 277 |
'auto_renew_error' => $checkout->auto_renew_error, |
| 278 |
'timestamp' => $checkout->timestamp, |
| 279 |
'issuedate' => $checkout->issuedate, |
| 280 |
'onsite_checkout' => $checkout->onsite_checkout, |
| 281 |
'note' => $checkout->note, |
| 282 |
'notedate' => $checkout->notedate, |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
my $clubs = $patron->get_club_enrollments; |
| 288 |
if($clubs) { |
| 289 |
while(my $club = $clubs->next()) { |
| 290 |
push @{$exportedData->{'clubs'}}, { |
| 291 |
id => $club->id, |
| 292 |
date_enrolled => $club->date_enrolled, |
| 293 |
date_canceled => $club->date_canceled, |
| 294 |
date_created => $club->date_created, |
| 295 |
date_updated => $club->date_updated, |
| 296 |
branchcode => $club->branchcode, |
| 297 |
} |
| 298 |
} |
| 299 |
} |
| 300 |
|
| 301 |
my $account = $patron->account; |
| 302 |
if($account) { |
| 303 |
$exportedData->{'account'} = { |
| 304 |
'balance' => $account->balance, |
| 305 |
'non_issues_charges' => $account->non_issues_charges, |
| 306 |
}; |
| 307 |
my $acclines = Koha::Account::Lines->search( |
| 308 |
{ |
| 309 |
borrowernumber => $patron->borrowernumber, |
| 310 |
}, |
| 311 |
{ |
| 312 |
order_by => 'accountno' |
| 313 |
} |
| 314 |
); |
| 315 |
while(my $thisLine = $acclines->next()) { |
| 316 |
push @{$exportedData->{'account'}->{'accountLines'}}, { |
| 317 |
'accountlines_id' => $thisLine->accountlines_id, |
| 318 |
'payment_type' => $thisLine->payment_type, |
| 319 |
'amountoutstanding' => $thisLine->amountoutstanding, |
| 320 |
'accounttype' => $thisLine->accounttype, |
| 321 |
'timestamp' => $thisLine->timestamp, |
| 322 |
'issue_id' => $thisLine->issue_id, |
| 323 |
'description' => $thisLine->description, |
| 324 |
'dispute' => $thisLine->dispute, |
| 325 |
'lastincrement' => $thisLine->lastincrement, |
| 326 |
'date' => $thisLine->date, |
| 327 |
'amount' => $thisLine->amount, |
| 328 |
'manager_id' => $thisLine->manager_id, |
| 329 |
'note' => $thisLine->note, |
| 330 |
} |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
# Generate the JSON file and spit it out |
| 335 |
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); |
| 336 |
my $borrowercardnumber = $patron->cardnumber; |
| 337 |
print $input->header( |
| 338 |
-type => 'application/json', |
| 339 |
-charset => 'utf-8', |
| 340 |
-attachment => "$today-$borrowercardnumber-GDPR-Export.json" |
| 341 |
); |
| 342 |
my $json = new JSON; |
| 343 |
print $json->pretty->encode($exportedData); |
| 344 |
exit; |
| 345 |
} |
| 346 |
|
| 95 |
if ( $patron->is_child ) { |
347 |
if ( $patron->is_child ) { |
| 96 |
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); |
348 |
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); |
| 97 |
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; |
349 |
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; |
| 98 |
- |
|
|