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

(-)a/C4/Acquisition.pm (-1 / +1 lines)
Lines 1207-1213 sub ModOrder { Link Here
1207
        #See report 10110 and guided_reports.pl
1207
        #See report 10110 and guided_reports.pl
1208
    my $query = "UPDATE aqorders SET ";
1208
    my $query = "UPDATE aqorders SET ";
1209
1209
1210
    foreach my $orderinfokey (grep(!/ordernumber/, keys %$orderinfo)){
1210
    foreach my $orderinfokey (keys %$orderinfo){
1211
        # ... and skip hash entries that are not in the aqorders table
1211
        # ... and skip hash entries that are not in the aqorders table
1212
        # FIXME : probably not the best way to do it (would be better to have a correct hash)
1212
        # FIXME : probably not the best way to do it (would be better to have a correct hash)
1213
        next unless grep(/^$orderinfokey$/, @$colnames);
1213
        next unless grep(/^$orderinfokey$/, @$colnames);
(-)a/acqui/neworderempty.pl (+4 lines)
Lines 357-367 my @gst_values = map { Link Here
357
    option => $_
357
    option => $_
358
}, split( '\|', C4::Context->preference("gist") );
358
}, split( '\|', C4::Context->preference("gist") );
359
359
360
360
$template->param(
361
$template->param(
361
    existing         => $biblionumber,
362
    existing         => $biblionumber,
362
    ordernumber           => $ordernumber,
363
    ordernumber           => $ordernumber,
363
    # basket informations
364
    # basket informations
364
    basketno             => $basketno,
365
    basketno             => $basketno,
366
    purchaseordernumber => $data->{purchaseordernumber},
367
    prefix           => GetAuthorisedValues('PONUMPREFIX'),
368
    enableponumber => C4::Context->preference('EnablePONumber'),
365
    basketname           => $basket->{'basketname'},
369
    basketname           => $basket->{'basketname'},
366
    basketnote           => $basket->{'note'},
370
    basketnote           => $basket->{'note'},
367
    booksellerid         => $basket->{'booksellerid'},
371
    booksellerid         => $basket->{'booksellerid'},
(-)a/acqui/poseqnextvalue.pl (+45 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2013 Amit Gupta(amitddng135@gmail.com)
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
use CGI;
23
use C4::Auth;
24
use C4::Output;
25
use JSON;
26
27
my $input = new CGI;
28
29
my $generateno = sprintf( "%0*d", "7", getnext() );
30
31
print $input->header('application/json');
32
my $json = { generateno => $generateno, };
33
my $json_text = to_json( $json, { utf8 => 1 } );
34
print $json_text;
35
36
sub getnext {
37
    my $dbh = C4::Context->dbh;
38
    # next two lines should be wrapped in a transaction
39
    $dbh->do(
40
q{UPDATE po_sequence set seq_value = seq_value + 1 where seqid = 'POSEQ'}
41
    );
42
    my @row = $dbh->selectrow_array(
43
        q{SELECT seq_value from po_sequence where seqid = 'POSEQ'});
44
    return $row[0];
45
}
(-)a/installer/data/mysql/kohastructure.sql (+12 lines)
Lines 3214-3219 CREATE TABLE IF NOT EXISTS plugin_data ( Link Here
3214
  PRIMARY KEY (plugin_class,plugin_key)
3214
  PRIMARY KEY (plugin_class,plugin_key)
3215
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3215
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3216
3216
3217
3218
--
3219
-- Table structure for table 'po_sequence'
3220
--
3221
3222
CREATE TABLE IF NOT EXISTS po_sequence (
3223
  seqid varchar(10) PRIMARY KEY,
3224
  seq_value bigint(20) unsigned NOT NULL,
3225
  PRIMARY KEY (seqid)
3226
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3227
3228
3217
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3229
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3218
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3230
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3219
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3231
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 430-432 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V Link Here
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
433
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EnablePONumber',0,'Enable purchase order number',NULL,'YesNo');
434
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 7067-7072 if ( CheckVersion($DBversion) ) { Link Here
7067
    SetVersion($DBversion);
7067
    SetVersion($DBversion);
7068
}
7068
}
7069
7069
7070
$DBversion = "3.13.00.XXX";
7071
if ( CheckVersion($DBversion) ) {
7072
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('EnablePONumber',0,'Enable purchase order number',NULL,'YesNo')");
7073
    $dbh->do("CREATE TABLE IF NOT EXISTS po_sequence (seqid varchar(10) PRIMARY KEY, seq_value bigint(20) unsigned NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;")
7074
    $dbh->do(q|INSERT INTO po_sequence values( 'POSEQ', 1)|);
7075
    print "Upgrade to $DBversion done (Bug 4456 - Add systempreferences to enabling purchaseordernumber and create new table po_sequence)\n";
7076
    SetVersion ($DBversion);
7077
}
7078
7070
=head1 FUNCTIONS
7079
=head1 FUNCTIONS
7071
7080
7072
=head2 TableExists($table)
7081
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (+44 lines)
Lines 144-149 $(document).ready(function() Link Here
144
    });
144
    });
145
//]]>
145
//]]>
146
</script>
146
</script>
147
<script language="Javascript" type="text/javascript">
148
    $(document).ready(function(){
149
    $('#ponumber').change(function() {
150
    $.ajax({url:"/cgi-bin/koha/acqui/poseqnextvalue.pl",
151
        type: "get",
152
        async: false,
153
        dataType: 'json',
154
        success:function(generateno) {
155
            var len =  document.getElementsByName("purchaseordernumber").length - 1;
156
            var t1 = document.getElementById('ponumber').value;
157
            var t2 = generateno.generateno;
158
            if (t1.length > 0 && t2.length > 0) {
159
                document.getElementsByName("purchaseordernumber")[len].value = t1+t2;
160
            }
161
        }});
162
    });
163
});
164
</script>
147
</head>
165
</head>
148
<body id="acq_neworderempty" class="acq">
166
<body id="acq_neworderempty" class="acq">
149
167
Lines 538-543 $(document).ready(function() Link Here
538
                <label for="notes">Notes: </label>
556
                <label for="notes">Notes: </label>
539
                <textarea id="notes" cols="30" rows="3" name="notes" >[% IF ( notes ) %][% notes %][% END %]</textarea>
557
                <textarea id="notes" cols="30" rows="3" name="notes" >[% IF ( notes ) %][% notes %][% END %]</textarea>
540
            </li>
558
            </li>
559
            [% IF enableponumber %]
560
            [% IF ( ordernumber ) %]
561
            <li>
562
                <label for="purchaseordernumber">Purchase order: </label>
563
                <input type="text" id="purchaseordernumber" size="20" name="purchaseordernumber" value="[% purchaseordernumber %]"/>
564
            </li>
565
            [% ELSE %]
566
            <li><p>Select ordernumber prefix for auto-generated purchase order number.</p></li>
567
            <li>
568
                <label for="prefix">Prefix:</label>
569
                [% IF prefix %]
570
                    <select id="ponumber" onchange="Calculatepurorderno(this.value)">
571
                    <option value="">Select</option>
572
                    [% FOREACH d IN prefix %]
573
                        <option value="[% d.authorised_value %]">[% d.lib %]</option>
574
                    [% END %]
575
                    </select>
576
                    [% ELSE %]
577
                        <span id="pordernumber">No prefix authorized values found! Please create one or more authorized values with the category PONUMPREFIX.</span>
578
                [% END %]
579
            </li>
580
                <label for="purchaseordernumber">Purchase order: </label>
581
                <input type="text" id="purchaseordernumber" size="20" name="purchaseordernumber" value="[% purchaseordernumber %]"/>
582
            </li>
583
            [% END %]
584
            [% END %]
541
            <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
585
            <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
542
                <label for="sort1">Statistic 1: </label>
586
                <label for="sort1">Statistic 1: </label>
543
                <span id="sort1_zone">
587
                <span id="sort1_zone">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (-1 / +6 lines)
Lines 42-47 Acquisitions: Link Here
42
                  yes: Warn
42
                  yes: Warn
43
                  no: "Do not warn"
43
                  no: "Do not warn"
44
            - when the librarian tries to create an invoice with a duplicate number.
44
            - when the librarian tries to create an invoice with a duplicate number.
45
        -
46
            - pref: EnablePONumber
47
              choices:
48
                  yes: Enable
49
                  no: Disable
50
            - Enable purchase order number.
45
51
46
    Printing:
52
    Printing:
47
        -
53
        -
48
- 

Return to bug 4456