|
Lines 18-109
Link Here
|
| 18 |
# You should have received a copy of the GNU General Public License |
18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 20 |
|
20 |
|
| 21 |
package C4::Barcodes::ValueBuilder::incremental; |
21 |
{ |
|
|
22 |
package C4::Barcodes::ValueBuilder::incremental; |
| 22 |
|
23 |
|
| 23 |
use Modern::Perl; |
24 |
use Modern::Perl; |
| 24 |
use C4::Context; |
25 |
use C4::Context; |
| 25 |
my $DEBUG = 0; |
26 |
my $DEBUG = 0; |
| 26 |
|
27 |
|
| 27 |
sub get_barcode { |
28 |
sub get_barcode { |
| 28 |
my ($args) = @_; |
29 |
my ($args) = @_; |
| 29 |
my $nextnum; |
30 |
my $nextnum; |
| 30 |
# not the best, two catalogers could add the same barcode easily this way :/ |
31 |
# not the best, two catalogers could add the same barcode easily this way :/ |
| 31 |
my $query = "select max(abs(barcode)) from items"; |
32 |
my $query = "select max(abs(barcode)) from items"; |
| 32 |
my $sth = C4::Context->dbh->prepare($query); |
33 |
my $sth = C4::Context->dbh->prepare($query); |
| 33 |
$sth->execute(); |
34 |
$sth->execute(); |
| 34 |
while (my ($count)= $sth->fetchrow_array) { |
35 |
while (my ($count)= $sth->fetchrow_array) { |
| 35 |
$nextnum = $count; |
36 |
$nextnum = $count; |
|
|
37 |
} |
| 38 |
$nextnum++; |
| 39 |
return $nextnum; |
| 36 |
} |
40 |
} |
| 37 |
$nextnum++; |
|
|
| 38 |
return $nextnum; |
| 39 |
} |
41 |
} |
| 40 |
|
42 |
|
| 41 |
1; |
43 |
{ |
| 42 |
|
44 |
package C4::Barcodes::ValueBuilder::hbyymmincr; |
| 43 |
package C4::Barcodes::ValueBuilder::hbyymmincr; |
45 |
use C4::Context; |
| 44 |
use C4::Context; |
46 |
my $DEBUG = 0; |
| 45 |
my $DEBUG = 0; |
|
|
| 46 |
|
47 |
|
| 47 |
sub get_barcode { |
48 |
sub get_barcode { |
| 48 |
my ($args) = @_; |
49 |
my ($args) = @_; |
| 49 |
my $nextnum = 0; |
50 |
my $nextnum = 0; |
| 50 |
my $year = substr($args->{year}, -2); |
51 |
my $year = substr($args->{year}, -2); |
| 51 |
my $month = $args->{mon}; |
52 |
my $month = $args->{mon}; |
| 52 |
my $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?"; |
53 |
my $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?"; |
| 53 |
my $sth = C4::Context->dbh->prepare($query); |
54 |
my $sth = C4::Context->dbh->prepare($query); |
| 54 |
$sth->execute("^[-a-zA-Z]{1,}$year$month"); |
55 |
$sth->execute("^[-a-zA-Z]{1,}$year$month"); |
| 55 |
while (my ($count)= $sth->fetchrow_array) { |
56 |
while (my ($count)= $sth->fetchrow_array) { |
| 56 |
$nextnum = $count if $count; |
57 |
$nextnum = $count if $count; |
| 57 |
$nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 9999 items per month |
58 |
$nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 9999 items per month |
| 58 |
warn "Existing incremental number = $nextnum" if $DEBUG; |
59 |
warn "Existing incremental number = $nextnum" if $DEBUG; |
| 59 |
} |
|
|
| 60 |
$nextnum++; |
| 61 |
$nextnum = sprintf("%0*d", "4",$nextnum); |
| 62 |
$nextnum = $year . $month . $nextnum; |
| 63 |
warn "New hbyymmincr Barcode = $nextnum" if $DEBUG; |
| 64 |
my $scr = " |
| 65 |
var form = document.getElementById('f'); |
| 66 |
if ( !form ) { |
| 67 |
form = document.getElementById('serials_edit'); |
| 68 |
} |
| 69 |
if ( !form ) { |
| 70 |
form = document.getElementById('Aform'); |
| 71 |
} |
60 |
} |
| 72 |
for (i=0 ; i<form.field_value.length ; i++) { |
61 |
$nextnum++; |
| 73 |
if (form.tag[i].value == '$args->{loctag}' && form.subfield[i].value == '$args->{locsubfield}') { |
62 |
$nextnum = sprintf("%0*d", "4",$nextnum); |
| 74 |
fnum = i; |
63 |
$nextnum = $year . $month . $nextnum; |
|
|
64 |
warn "New hbyymmincr Barcode = $nextnum" if $DEBUG; |
| 65 |
my $scr = " |
| 66 |
var form = document.getElementById('f'); |
| 67 |
if ( !form ) { |
| 68 |
form = document.getElementById('serials_edit'); |
| 69 |
} |
| 70 |
if ( !form ) { |
| 71 |
form = document.getElementById('Aform'); |
| 75 |
} |
72 |
} |
|
|
73 |
for (i=0 ; i<form.field_value.length ; i++) { |
| 74 |
if (form.tag[i].value == '$args->{loctag}' && form.subfield[i].value == '$args->{locsubfield}') { |
| 75 |
fnum = i; |
| 76 |
} |
| 77 |
} |
| 78 |
if (\$('#' + id).val() == '') { |
| 79 |
\$('#' + id).val(form.field_value[fnum].value + '$nextnum'); |
| 76 |
} |
80 |
} |
| 77 |
if (\$('#' + id).val() == '') { |
81 |
"; |
| 78 |
\$('#' + id).val(form.field_value[fnum].value + '$nextnum'); |
82 |
return $nextnum, $scr; |
| 79 |
} |
83 |
} |
| 80 |
"; |
|
|
| 81 |
return $nextnum, $scr; |
| 82 |
} |
84 |
} |
| 83 |
|
85 |
|
|
|
86 |
{ |
| 87 |
package C4::Barcodes::ValueBuilder::annual; |
| 88 |
use C4::Context; |
| 89 |
my $DEBUG = 0; |
| 84 |
|
90 |
|
| 85 |
package C4::Barcodes::ValueBuilder::annual; |
91 |
sub get_barcode { |
| 86 |
use C4::Context; |
92 |
my ($args) = @_; |
| 87 |
my $DEBUG = 0; |
93 |
my $nextnum; |
| 88 |
|
94 |
my $query = "select max(cast( substring_index(barcode, '-',-1) as signed)) from items where barcode like ?"; |
| 89 |
sub get_barcode { |
95 |
my $sth=C4::Context->dbh->prepare($query); |
| 90 |
my ($args) = @_; |
96 |
$sth->execute($args->{year} . '-%'); |
| 91 |
my $nextnum; |
97 |
while (my ($count)= $sth->fetchrow_array) { |
| 92 |
my $query = "select max(cast( substring_index(barcode, '-',-1) as signed)) from items where barcode like ?"; |
98 |
warn "Examining Record: $count" if $DEBUG; |
| 93 |
my $sth=C4::Context->dbh->prepare($query); |
99 |
$nextnum = $count if $count; |
| 94 |
$sth->execute($args->{year} . '-%'); |
100 |
} |
| 95 |
while (my ($count)= $sth->fetchrow_array) { |
101 |
$nextnum++; |
| 96 |
warn "Examining Record: $count" if $DEBUG; |
102 |
$nextnum = sprintf("%0*d", "4",$nextnum); |
| 97 |
$nextnum = $count if $count; |
103 |
$nextnum = "$args->{year}-$nextnum"; |
|
|
104 |
return $nextnum; |
| 98 |
} |
105 |
} |
| 99 |
$nextnum++; |
|
|
| 100 |
$nextnum = sprintf("%0*d", "4",$nextnum); |
| 101 |
$nextnum = "$args->{year}-$nextnum"; |
| 102 |
return $nextnum; |
| 103 |
} |
106 |
} |
| 104 |
|
107 |
|
| 105 |
1; |
|
|
| 106 |
|
| 107 |
|
108 |
|
| 108 |
=head1 Barcodes::ValueBuilder |
109 |
=head1 Barcodes::ValueBuilder |
| 109 |
|
110 |
|
| 110 |
- |
|
|