https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15239
--- Comment #9 from Ruben Norori <[email protected]> --- I have the definitive solution: First we must add two new procedures, functions, methods, which consult in the database the registry homebranch. #Original function sub get_item_from_barcode { my ($barcode)=@_; my $dbh=C4::Context->dbh; my $result; my $rq=$dbh->prepare("SELECT itemnumber from items where items.barcode=?"); $rq->execute($barcode); ($result)=$rq->fetchrow; return($result); } #New function sub get_home_from_barcode { my ($barcode)=@_; my $dbh=C4::Context->dbh; my $result; my $rq=$dbh->prepare("SELECT homebranch from items where items.barcode=?"); $rq->execute($barcode); ($result)=$rq->fetchrow; return($result); } #New function sub get_home_from_item { my ($barcode)=@_; my $dbh=C4::Context->dbh; my $result; my $rq=$dbh->prepare("SELECT homebranch from items where items.itemnumber=?"); $rq->execute($barcode); ($result)=$rq->fetchrow; return($result); } Then call the functions and save the result in a variable that we concate at the final result, also add an "if" to use one function in the first iteration and the other function executes it in the "else". for (my $i = 0; $i < $number_of_copies;) { # If there is a barcode if ($barcodevalue) { # Getting a new barcode (if it is not the first iteration or the barcode we tried already exists) # For execute only in the first iteration if($i<1){ # Call new function my $newv = get_home_from_item($exist_itemnumber); $barcodevalue = $newv.$barcodeobj->next_value($oldbarcode) if ($i > 0 || $exist_itemnumber); }else{ # Call new function my $exin = get_home_from_barcode($barcodevalue); $barcodevalue = $exin.$barcodeobj->next_value($oldbarcode) if ($i > 0 || $exist_itemnumber); } # Putting it into the record if ($barcodevalue) { $record->field($tagfield)->update($tagsubfield => $barcodevalue); } -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
