View | Details | Raw Unified | Return to bug 14057
Collapse All | Expand All

(-)a/C4/Items.pm (-8 / +32 lines)
Lines 1024-1030 sub GetLostItems { Link Here
1024
1024
1025
=head2 GetItemsForInventory
1025
=head2 GetItemsForInventory
1026
1026
1027
($itemlist, $iTotalRecords)  = GetItemsForInventory($minlocation, $maxlocation, $location, $itemtype, $ignoreissued, $datelastseen, $branchcode, $offset, $size, $statushash);
1027
($itemlist, $iTotalRecords) = GetItemsForInventory( {
1028
  minlocation  => $minlocation,
1029
  maxlocation  => $maxlocation,
1030
  location     => $location,
1031
  itemtype     => $itemtype,
1032
  ignoreissued => $ignoreissued,
1033
  datelastseen => $datelastseen,
1034
  branchcode   => $branchcode,
1035
  branch       => $branch,
1036
  offset       => $offset,
1037
  size         => $size,
1038
  stautshash   => $statushash
1039
  interface    => $interface,
1040
} );
1028
1041
1029
Retrieve a list of title/authors/barcode/callnumber, for biblio inventory.
1042
Retrieve a list of title/authors/barcode/callnumber, for biblio inventory.
1030
1043
Lines 1042-1048 $iTotalRecords is the number of rows that would have been returned without the $ Link Here
1042
=cut
1055
=cut
1043
1056
1044
sub GetItemsForInventory {
1057
sub GetItemsForInventory {
1045
    my ( $minlocation, $maxlocation,$location, $itemtype, $ignoreissued, $datelastseen, $branchcode, $branch, $offset, $size, $statushash ) = @_;
1058
    my ( $parameters ) = @_;
1059
    my $minlocation  = $parameters->{'minlocation'}  // '';
1060
    my $maxlocation  = $parameters->{'maxlocation'}  // '';
1061
    my $location     = $parameters->{'location'}     // '';
1062
    my $itemtype     = $parameters->{'itemtype'}     // '';
1063
    my $ignoreissued = $parameters->{'ignoreissued'} // '';
1064
    my $datelastseen = $parameters->{'datelastseen'} // '';
1065
    my $branchcode   = $parameters->{'branchcode'}   // '';
1066
    my $branch       = $parameters->{'branch'}       // '';
1067
    my $offset       = $parameters->{'offset'}       // '';
1068
    my $size         = $parameters->{'size'}         // '';
1069
    my $statushash   = $parameters->{'statushash'}   // '';
1070
1046
    my $dbh = C4::Context->dbh;
1071
    my $dbh = C4::Context->dbh;
1047
    my ( @bind_params, @where_strings );
1072
    my ( @bind_params, @where_strings );
1048
1073
Lines 1121-1136 sub GetItemsForInventory { Link Here
1121
    $sth->execute( @bind_params );
1146
    $sth->execute( @bind_params );
1122
    my ($iTotalRecords) = $sth->fetchrow_array();
1147
    my ($iTotalRecords) = $sth->fetchrow_array();
1123
1148
1149
    my $avmapping = C4::Koha::GetKohaAuthorisedValuesMapping( {
1150
                      interface => 'unknown'
1151
                    } );
1124
    foreach my $row (@$tmpresults) {
1152
    foreach my $row (@$tmpresults) {
1125
1153
1126
        # Auth values
1154
        # Auth values
1127
        foreach (keys %$row) {
1155
        foreach (keys %$row) {
1128
            # If the koha field is mapped to a marc field
1156
            if (defined($avmapping->{"items.$_,".$row->{'frameworkcode'}.",".$row->{$_}})) {
1129
            my ($f, $sf) = GetMarcFromKohaField("items.$_", $row->{'frameworkcode'});
1157
                $row->{$_} = $avmapping->{"items.$_,".$row->{'frameworkcode'}.",".$row->{$_}};
1130
            if ($f and $sf) {
1131
                # We replace the code with it's description
1132
                my $authvals = C4::Koha::GetKohaAuthorisedValuesFromField($f, $sf, $row->{'frameworkcode'});
1133
                $row->{$_} = $authvals->{$row->{$_}} if defined $authvals->{$row->{$_}};
1134
            }
1158
            }
1135
        }
1159
        }
1136
        push @results, $row;
1160
        push @results, $row;
(-)a/C4/Koha.pm (+44 lines)
Lines 1327-1332 sub GetKohaAuthorisedValuesFromField { Link Here
1327
  }
1327
  }
1328
}
1328
}
1329
1329
1330
=head2 GetKohaAuthorisedValuesMapping
1331
1332
Takes a hash as a parameter. The interface key indicates the
1333
description to use in the mapping.
1334
1335
Returns hashref of:
1336
 "{kohafield},{frameworkcode},{authorised_value}" => "{description}"
1337
for all the kohafields, frameworkcodes, and authorised values.
1338
1339
Returns undef if nothing is found.
1340
1341
=cut
1342
1343
sub GetKohaAuthorisedValuesMapping {
1344
    my ($parameter) = @_;
1345
    my $interface = $parameter->{'interface'} // '';
1346
1347
    my $query_mapping = q{
1348
SELECT TA.kohafield,TA.authorised_value AS category,
1349
       TA.frameworkcode,TB.authorised_value,
1350
       IF(TB.lib_opac>'',TB.lib_opac,TB.lib) AS OPAC,
1351
       TB.lib AS Intranet,TB.lib_opac
1352
FROM marc_subfield_structure AS TA JOIN
1353
     authorised_values as TB ON
1354
     TA.authorised_value=TB.category
1355
WHERE TA.kohafield>'' AND TA.authorised_value>'';
1356
    };
1357
    my $dbh = C4::Context->dbh;
1358
    my $sth = $dbh->prepare($query_mapping);
1359
    $sth->execute();
1360
    my $avmapping;
1361
    if ($interface eq 'opac') {
1362
        while (my $row = $sth->fetchrow_hashref) {
1363
            $avmapping->{$row->{kohafield}.",".$row->{frameworkcode}.",".$row->{authorised_value}} = $row->{OPAC};
1364
        }
1365
    }
1366
    else {
1367
        while (my $row = $sth->fetchrow_hashref) {
1368
            $avmapping->{$row->{kohafield}.",".$row->{frameworkcode}.",".$row->{authorised_value}} = $row->{Intranet};
1369
        }
1370
    }
1371
    return $avmapping;
1372
}
1373
1330
=head2 xml_escape
1374
=head2 xml_escape
1331
1375
1332
  my $escaped_string = C4::Koha::xml_escape($string);
1376
  my $escaped_string = C4::Koha::xml_escape($string);
(-)a/tools/inventory.pl (-3 / +28 lines)
Lines 234-243 if ( $markseen or $op ) { Link Here
234
234
235
    # We use datelastseen only when comparing the results to the barcode file.
235
    # We use datelastseen only when comparing the results to the barcode file.
236
    my $paramdatelastseen = ($compareinv2barcd) ? $datelastseen : '';
236
    my $paramdatelastseen = ($compareinv2barcd) ? $datelastseen : '';
237
    ($inventorylist, $totalrecords) = GetItemsForInventory($minlocation, $maxlocation, $location, $itemtype, $ignoreissued, $paramdatelastseen, $branchcode, $branch, 0, undef, $staton);
237
    ($inventorylist, $totalrecords) = GetItemsForInventory( {
238
      minlocation  => $minlocation,
239
      maxlocation  => $maxlocation,
240
      location     => $location,
241
      itemtype     => $itemtype,
242
      ignoreissued => $ignoreissued,
243
      datelastseen => $paramdatelastseen,
244
      branchcode   => $branchcode,
245
      branch       => $branch,
246
      offset       => 0,
247
      size         => undef,
248
      statushash   => $staton,
249
      interface    => 'staff',
250
    } );
238
251
239
    # For the items that may be marked as "wrong place", we only check the location (callnumbers, location and branch)
252
    # For the items that may be marked as "wrong place", we only check the location (callnumbers, location and branch)
240
    ($wrongplacelist, $totalrecords) = GetItemsForInventory($minlocation, $maxlocation, $location, undef, undef, undef, $branchcode, $branch, 0, undef, undef);
253
    ($wrongplacelist, $totalrecords) = GetItemsForInventory( {
254
      minlocation  => $minlocation,
255
      maxlocation  => $maxlocation,
256
      location     => $location,
257
      itemtype     => undef,
258
      ignoreissued => undef,
259
      datelastseen => undef,
260
      branchcode   => $branchcode,
261
      branch       => $branch,
262
      offset       => 0,
263
      size         => undef,
264
      statushash   => undef,
265
      interface    => 'staff',
266
    } );
241
267
242
}
268
}
243
269
244
- 

Return to bug 14057