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

(-)a/C4/Acquisition.pm (-21 / +123 lines)
Lines 28-34 use MARC::Record; Link Here
28
use C4::Suggestions;
28
use C4::Suggestions;
29
use C4::Biblio;
29
use C4::Biblio;
30
use C4::Debug;
30
use C4::Debug;
31
use C4::SQLHelper qw(InsertInTable);
31
use C4::SQLHelper qw(InsertInTable UpdateInTable);
32
use C4::Bookseller qw(GetBookSellerFromId);
32
use C4::Bookseller qw(GetBookSellerFromId);
33
use C4::Templates qw(gettemplate);
33
use C4::Templates qw(gettemplate);
34
34
Lines 43-49 BEGIN { Link Here
43
    require Exporter;
43
    require Exporter;
44
    @ISA    = qw(Exporter);
44
    @ISA    = qw(Exporter);
45
    @EXPORT = qw(
45
    @EXPORT = qw(
46
        &GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket
46
        &GetBasket &NewBasket &CloseBasket &ReopenBasket &DelBasket &ModBasket
47
        &GetBasketAsCSV &GetBasketGroupAsCSV
47
        &GetBasketAsCSV &GetBasketGroupAsCSV
48
        &GetBasketsByBookseller &GetBasketsByBasketgroup
48
        &GetBasketsByBookseller &GetBasketsByBasketgroup
49
        &GetBasketsInfosByBookseller
49
        &GetBasketsInfosByBookseller
Lines 75-80 BEGIN { Link Here
75
        &GetItemnumbersFromOrder
75
        &GetItemnumbersFromOrder
76
76
77
        &AddClaim
77
        &AddClaim
78
        &GetBiblioCountByBasketno
78
    );
79
    );
79
}
80
}
80
81
Lines 214-220 sub NewBasket { Link Here
214
215
215
  &CloseBasket($basketno);
216
  &CloseBasket($basketno);
216
217
217
close a basket (becomes unmodifiable,except for recieves)
218
close a basket (becomes unmodifiable, except for receives)
218
219
219
=cut
220
=cut
220
221
Lines 228-233 sub CloseBasket { Link Here
228
    ";
229
    ";
229
    my $sth = $dbh->prepare($query);
230
    my $sth = $dbh->prepare($query);
230
    $sth->execute($basketno);
231
    $sth->execute($basketno);
232
233
    my @orders = GetOrders($basketno);
234
    foreach my $order (@orders) {
235
        $query = qq{
236
            UPDATE aqorders
237
            SET orderstatus = 1
238
            WHERE ordernumber = ?;
239
        };
240
        $sth = $dbh->prepare($query);
241
        $sth->execute($order->{'ordernumber'});
242
    }
243
}
244
245
=head3 ReopenBasket
246
247
  &ReopenBasket($basketno);
248
249
reopen a basket
250
251
=cut
252
253
sub ReopenBasket {
254
    my ($basketno) = @_;
255
    my $dbh        = C4::Context->dbh;
256
    my $query = "
257
        UPDATE aqbasket
258
        SET    closedate=NULL
259
        WHERE  basketno=?
260
    ";
261
    my $sth = $dbh->prepare($query);
262
    $sth->execute($basketno);
263
264
    my @orders = GetOrders($basketno);
265
    foreach my $order (@orders) {
266
        $query = qq{
267
            UPDATE aqorders
268
            SET orderstatus = 0
269
            WHERE ordernumber = ?;
270
        };
271
        $sth = $dbh->prepare($query);
272
        $sth->execute($order->{'ordernumber'});
273
    }
231
}
274
}
232
275
233
#------------------------------------------------------------#
276
#------------------------------------------------------------#
Lines 467-472 sub ModBasket { Link Here
467
    my $dbh = C4::Context->dbh;
510
    my $dbh = C4::Context->dbh;
468
    my $sth = $dbh->prepare($query);
511
    my $sth = $dbh->prepare($query);
469
    $sth->execute(@params);
512
    $sth->execute(@params);
513
470
    $sth->finish;
514
    $sth->finish;
471
}
515
}
472
516
Lines 1041-1047 The following keys are used: "biblionumber", "title", "basketno", "quantity", "n Link Here
1041
1085
1042
sub NewOrder {
1086
sub NewOrder {
1043
    my $orderinfo = shift;
1087
    my $orderinfo = shift;
1044
#### ------------------------------
1088
    my $parent_ordernumber = shift;
1089
1045
    my $dbh = C4::Context->dbh;
1090
    my $dbh = C4::Context->dbh;
1046
    my @params;
1091
    my @params;
1047
1092
Lines 1316-1321 sub ModReceiveOrder { Link Here
1316
        $sth=$dbh->prepare("
1361
        $sth=$dbh->prepare("
1317
            UPDATE aqorders
1362
            UPDATE aqorders
1318
            SET quantity = ?
1363
            SET quantity = ?
1364
                ordernumber = 2
1319
            WHERE ordernumber = ?
1365
            WHERE ordernumber = ?
1320
        ");
1366
        ");
1321
1367
Lines 1395-1401 sub ModReceiveOrder { Link Here
1395
    } else {
1441
    } else {
1396
        $sth=$dbh->prepare("update aqorders
1442
        $sth=$dbh->prepare("update aqorders
1397
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1443
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1398
                                unitprice=?,rrp=?,ecost=?
1444
                                unitprice=?,rrp=?,ecost=?,orderstatus=3
1399
                            where biblionumber=? and ordernumber=?");
1445
                            where biblionumber=? and ordernumber=?");
1400
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber);
1446
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber);
1401
        $sth->finish;
1447
        $sth->finish;
Lines 1615-1621 sub DelOrder { Link Here
1615
    my $dbh = C4::Context->dbh;
1661
    my $dbh = C4::Context->dbh;
1616
    my $query = "
1662
    my $query = "
1617
        UPDATE aqorders
1663
        UPDATE aqorders
1618
        SET    datecancellationprinted=now()
1664
        SET    datecancellationprinted=now(), orderstatus=4
1619
        WHERE  biblionumber=? AND ordernumber=?
1665
        WHERE  biblionumber=? AND ordernumber=?
1620
    ";
1666
    ";
1621
    my $sth = $dbh->prepare($query);
1667
    my $sth = $dbh->prepare($query);
Lines 1634-1641 sub DelOrder { Link Here
1634
1680
1635
=head3 DelMarcOrder
1681
=head3 DelMarcOrder
1636
1682
1637
=over 4
1638
1639
&DelMarcOrder($biblionumber, $ordernumber);
1683
&DelMarcOrder($biblionumber, $ordernumber);
1640
1684
1641
Delete the order field from the MARC record. aqorders.ordernumber needs
1685
Delete the order field from the MARC record. aqorders.ordernumber needs
Lines 2016-2021 sub GetHistory { Link Here
2016
    my $basket = $params{basket};
2060
    my $basket = $params{basket};
2017
    my $booksellerinvoicenumber = $params{booksellerinvoicenumber};
2061
    my $booksellerinvoicenumber = $params{booksellerinvoicenumber};
2018
    my $basketgroupname = $params{basketgroupname};
2062
    my $basketgroupname = $params{basketgroupname};
2063
    my $budget = $params{budget};
2064
    my $branchcode = $params{branchcode};
2065
    my $orderstatus = $params{orderstatus};
2066
2019
    my @order_loop;
2067
    my @order_loop;
2020
    my $total_qty         = 0;
2068
    my $total_qty         = 0;
2021
    my $total_qtyreceived = 0;
2069
    my $total_qtyreceived = 0;
Lines 2024-2033 sub GetHistory { Link Here
2024
    my $dbh   = C4::Context->dbh;
2072
    my $dbh   = C4::Context->dbh;
2025
    my $query ="
2073
    my $query ="
2026
        SELECT
2074
        SELECT
2027
            biblio.title,
2075
            COALESCE(biblio.title,     deletedbiblio.title)     AS title,
2028
            biblio.author,
2076
            COALESCE(biblio.author,    deletedbiblio.author)    AS author,
2029
            biblioitems.isbn,
2077
            COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn,
2030
        biblioitems.ean,
2078
            COALESCE(biblioitems.ean,  deletedbiblioitems.ean)  AS ean,
2031
            aqorders.basketno,
2079
            aqorders.basketno,
2032
            aqbasket.basketname,
2080
            aqbasket.basketname,
2033
            aqbasket.basketgroupid,
2081
            aqbasket.basketgroupid,
Lines 2041-2059 sub GetHistory { Link Here
2041
            aqorders.ordernumber,
2089
            aqorders.ordernumber,
2042
            aqinvoices.invoicenumber,
2090
            aqinvoices.invoicenumber,
2043
            aqbooksellers.id as id,
2091
            aqbooksellers.id as id,
2044
            aqorders.biblionumber
2092
            aqorders.biblionumber,
2093
            aqorders.orderstatus,
2094
            aqorders.branchcode,
2095
            aqorders.parent_ordernumber,
2096
            aqbudgets.budget_name,
2097
            branches.branchname
2098
            ";
2099
    $query .= ", aqbudgets.budget_id AS budget" if defined $budget;
2100
    $query .= "
2045
        FROM aqorders
2101
        FROM aqorders
2046
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
2102
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
2047
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
2103
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
2048
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
2104
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
2049
        LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
2105
        LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
2050
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
2106
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
2051
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2107
        LEFT JOIN branches ON branches.branchcode=aqorders.branchcode
2108
        LEFT JOIN aqbudgets ON aqorders.budget_id=aqbudgets.budget_id
2109
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
2110
        LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber
2111
        LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber
2112
        ";
2113
2114
    if ( C4::Context->preference("IndependantBranches") ) {
2115
        $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber";
2116
    }
2052
2117
2053
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2118
    $query .= " WHERE 1 ";
2054
    if ( C4::Context->preference("IndependantBranches") );
2055
2119
2056
    $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
2120
    $query .= " AND (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') " if $orderstatus ne '4';
2057
2121
2058
    my @query_params  = ();
2122
    my @query_params  = ();
2059
2123
Lines 2072-2078 sub GetHistory { Link Here
2072
        $query .= " AND biblioitems.isbn LIKE ? ";
2136
        $query .= " AND biblioitems.isbn LIKE ? ";
2073
        push @query_params, "%$isbn%";
2137
        push @query_params, "%$isbn%";
2074
    }
2138
    }
2075
    if ( defined $ean and $ean ) {
2139
    if ( $ean ) {
2076
        $query .= " AND biblioitems.ean = ? ";
2140
        $query .= " AND biblioitems.ean = ? ";
2077
        push @query_params, "$ean";
2141
        push @query_params, "$ean";
2078
    }
2142
    }
Lines 2081-2086 sub GetHistory { Link Here
2081
        push @query_params, "%$name%";
2145
        push @query_params, "%$name%";
2082
    }
2146
    }
2083
2147
2148
    if ( $budget ) {
2149
        $query .= " AND aqbudgets.budget_id = ? ";
2150
        push @query_params, "$budget";
2151
    }
2152
2084
    if ( $from_placed_on ) {
2153
    if ( $from_placed_on ) {
2085
        $query .= " AND creationdate >= ? ";
2154
        $query .= " AND creationdate >= ? ";
2086
        push @query_params, $from_placed_on;
2155
        push @query_params, $from_placed_on;
Lines 2091-2096 sub GetHistory { Link Here
2091
        push @query_params, $to_placed_on;
2160
        push @query_params, $to_placed_on;
2092
    }
2161
    }
2093
2162
2163
    if ( defined $orderstatus and $orderstatus ne '') {
2164
        $query .= " AND aqorders.orderstatus = ? ";
2165
        push @query_params, "$orderstatus";
2166
    }
2167
2094
    if ($basket) {
2168
    if ($basket) {
2095
        if ($basket =~ m/^\d+$/) {
2169
        if ($basket =~ m/^\d+$/) {
2096
            $query .= " AND aqorders.basketno = ? ";
2170
            $query .= " AND aqorders.basketno = ? ";
Lines 2117-2122 sub GetHistory { Link Here
2117
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2191
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2118
            push @query_params, $userenv->{branch};
2192
            push @query_params, $userenv->{branch};
2119
        }
2193
        }
2194
    } elsif ( defined $branchcode and $branchcode ) {
2195
        $query .= " AND aqorders.branchcode = ? ";
2196
        push @query_params, $branchcode;
2120
    }
2197
    }
2121
    $query .= " ORDER BY id";
2198
    $query .= " ORDER BY id";
2122
    my $sth = $dbh->prepare($query);
2199
    my $sth = $dbh->prepare($query);
Lines 2126-2134 sub GetHistory { Link Here
2126
        $line->{count} = $cnt++;
2203
        $line->{count} = $cnt++;
2127
        $line->{toggle} = 1 if $cnt % 2;
2204
        $line->{toggle} = 1 if $cnt % 2;
2128
        push @order_loop, $line;
2205
        push @order_loop, $line;
2129
        $total_qty         += $line->{'quantity'};
2206
        $total_qty         += ( $line->{quantity} ) ? $line->{quantity} : 0;
2130
        $total_qtyreceived += $line->{'quantityreceived'};
2207
        $total_qtyreceived += ( $line->{quantityreceived} ) ? $line->{quantityreceived} : 0;
2131
        $total_price       += $line->{'quantity'} * $line->{'ecost'};
2208
        $total_price       += ( $line->{quantity} and $line->{ecost} ) ? $line->{quantity} * $line->{ecost} : 0;
2132
    }
2209
    }
2133
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2210
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2134
}
2211
}
Lines 2592-2597 sub ReopenInvoice { Link Here
2592
    $sth->execute($invoiceid);
2669
    $sth->execute($invoiceid);
2593
}
2670
}
2594
2671
2672
=head3 GetBiblioCountByBasketno
2673
2674
$biblio_count = &GetBiblioCountByBasketno($basketno);
2675
2676
Looks up the biblio's count that has basketno value $basketno
2677
2678
Returns a quantity
2679
2680
=cut
2681
2682
sub GetBiblioCountByBasketno {
2683
    my ($basketno) = @_;
2684
    my $dbh          = C4::Context->dbh;
2685
    my $query        = "
2686
        SELECT COUNT( DISTINCT( biblionumber ) )
2687
        FROM   aqorders
2688
        WHERE  basketno = ?
2689
            AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')
2690
        ";
2691
2692
    my $sth = $dbh->prepare($query);
2693
    $sth->execute($basketno);
2694
    return $sth->fetchrow;
2695
}
2696
2595
1;
2697
1;
2596
__END__
2698
__END__
2597
2699
(-)a/acqui/basket.pl (-10 / +8 lines)
Lines 177-194 if ( $op eq 'delete_confirm' ) { Link Here
177
        }
177
        }
178
        exit;
178
        exit;
179
    } else {
179
    } else {
180
    $template->param(confirm_close => "1",
180
    $template->param(
181
            booksellerid    => $booksellerid,
181
        confirm_close   => "1",
182
            basketno        => $basket->{'basketno'},
182
        booksellerid    => $booksellerid,
183
                basketname      => $basket->{'basketname'},
183
        basketno        => $basket->{'basketno'},
184
            basketgroupname => $basket->{'basketname'});
184
        basketname      => $basket->{'basketname'},
185
        
185
        basketgroupname => $basket->{'basketname'},
186
    );
186
    }
187
    }
187
} elsif ($op eq 'reopen') {
188
} elsif ($op eq 'reopen') {
188
    my $basket;
189
    ReopenBasket($query->param('basketno'));
189
    $basket->{basketno} = $query->param('basketno');
190
    $basket->{closedate} = undef;
191
    ModBasket($basket);
192
    print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'})
190
    print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'})
193
} else {
191
} else {
194
    # get librarian branch...
192
    # get librarian branch...
(-)a/acqui/histsearch.pl (-2 / +39 lines)
Lines 57-62 use C4::Output; Link Here
57
use C4::Acquisition;
57
use C4::Acquisition;
58
use C4::Dates;
58
use C4::Dates;
59
use C4::Debug;
59
use C4::Debug;
60
use C4::Branch;
61
use C4::Koha;
60
62
61
my $input = new CGI;
63
my $input = new CGI;
62
my $title                   = $input->param( 'title');
64
my $title                   = $input->param( 'title');
Lines 70-75 my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' ); Link Here
70
my $do_search               = $input->param('do_search') || 0;
72
my $do_search               = $input->param('do_search') || 0;
71
my $from_placed_on          = C4::Dates->new($input->param('from'));
73
my $from_placed_on          = C4::Dates->new($input->param('from'));
72
my $to_placed_on            = C4::Dates->new($input->param('to'));
74
my $to_placed_on            = C4::Dates->new($input->param('to'));
75
my $budget                  = $input->param( 'budget' );
76
my $branchcode              = $input->param( 'branchcode' );
77
my $orderstatus             = $input->param( 'orderstatus' );
78
73
if ( not $input->param('from') ) {
79
if ( not $input->param('from') ) {
74
    # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ?
80
    # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ?
75
    # We would use a function like Add_Delta_YM(-1, 0, 0);
81
    # We would use a function like Add_Delta_YM(-1, 0, 0);
Lines 110-130 if ($do_search) { Link Here
110
        basket => $basket,
116
        basket => $basket,
111
        booksellerinvoicenumber => $booksellerinvoicenumber,
117
        booksellerinvoicenumber => $booksellerinvoicenumber,
112
        basketgroupname => $basketgroupname,
118
        basketgroupname => $basketgroupname,
119
        budget => $budget,
120
        branchcode => $branchcode,
121
        orderstatus => $orderstatus,
113
    );
122
    );
114
}
123
}
115
124
116
my $from_date = $from_placed_on ? $from_placed_on->output('syspref') : undef;
125
my $from_date = $from_placed_on ? $from_placed_on->output('syspref') : undef;
117
my $to_date = $to_placed_on ? $to_placed_on->output('syspref') : undef;
126
my $to_date = $to_placed_on ? $to_placed_on->output('syspref') : undef;
118
127
128
my $budgetperiods = C4::Budgets::GetBudgetPeriods;
129
my $bp_loop = $budgetperiods;
130
for my $bp ( @{$budgetperiods} ) {
131
    my $hierarchy = C4::Budgets::GetBudgetHierarchy( $$bp{budget_period_id} );
132
    for my $budget ( @{$hierarchy} ) {
133
        $$budget{budget_display_name} = sprintf("%s", ">" x $$budget{depth} . $$budget{budget_name});
134
    }
135
    $$bp{hierarchy} = $hierarchy;
136
}
137
138
if ( not C4::Context->preference("IndependantBranches") ){
139
    my $branches = GetBranches();
140
    my @branchloop;
141
    foreach my $thisbranch ( keys %$branches ) {
142
        my %row = (
143
            value      => $thisbranch,
144
            branchname => $branches->{$thisbranch}->{'branchname'},
145
        );
146
        push @branchloop, \%row;
147
    }
148
    $template->param(
149
        branchcode           => $branchcode,
150
        display_branchcode   => !C4::Context->preference("IndependantBranches"),
151
        branchloop          => \@branchloop
152
    );
153
}
154
119
$template->param(
155
$template->param(
120
    suggestions_loop        => $order_loop,
156
    order_loop              => $order_loop,
121
    total_qty               => $total_qty,
157
    total_qty               => $total_qty,
122
    total_qtyreceived       => $total_qtyreceived,
158
    total_qtyreceived       => $total_qtyreceived,
123
    total_price             => sprintf( "%.2f", $total_price ),
159
    total_price             => sprintf( "%.2f", $total_price ),
124
    numresults              => $order_loop ? scalar(@$order_loop) : undef,
160
    numresults              => $order_loop ? scalar(@$order_loop) : undef,
125
    title                   => $title,
161
    title                   => $title,
126
    author                  => $author,
162
    author                  => $author,
127
    isbn		    => $isbn,
163
    isbn                    => $isbn,
128
    ean                     => $ean,
164
    ean                     => $ean,
129
    name                    => $name,
165
    name                    => $name,
130
    basket                  => $basket,
166
    basket                  => $basket,
Lines 132-137 $template->param( Link Here
132
    basketgroupname         => $basketgroupname,
168
    basketgroupname         => $basketgroupname,
133
    from_placed_on          => $from_date,
169
    from_placed_on          => $from_date,
134
    to_placed_on            => $to_date,
170
    to_placed_on            => $to_date,
171
    bp_loop                 => $bp_loop,
135
    debug                   => $debug || $input->param('debug') || 0,
172
    debug                   => $debug || $input->param('debug') || 0,
136
    uc(C4::Context->preference("marcflavour")) => 1
173
    uc(C4::Context->preference("marcflavour")) => 1
137
);
174
);
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2806-2811 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2806
  `claimed_date` date default NULL, -- last date a claim was generated
2806
  `claimed_date` date default NULL, -- last date a claim was generated
2807
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
2807
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
2808
  `branchcode` varchar(10) default NULL,
2808
  `branchcode` varchar(10) default NULL,
2809
  `orderstatus` tinyint(2) default 0, -- the current status for this line item
2809
  PRIMARY KEY  (`ordernumber`),
2810
  PRIMARY KEY  (`ordernumber`),
2810
  KEY `basketno` (`basketno`),
2811
  KEY `basketno` (`basketno`),
2811
  KEY `biblionumber` (`biblionumber`),
2812
  KEY `biblionumber` (`biblionumber`),
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 6483-6488 if ( CheckVersion($DBversion) ) { Link Here
6483
}
6483
}
6484
6484
6485
6485
6486
6487
6488
6489
6490
$DBversion = "3.11.00.XXX";
6491
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6492
    my $return_count;
6493
    $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus tinyint(2) DEFAULT 0 AFTER branchcode");
6494
    $dbh->do("UPDATE aqorders SET orderstatus=1 WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)");
6495
    $dbh->do("UPDATE aqorders SET orderstatus=2 WHERE quantity > quantityreceived AND quantityreceived > 0");
6496
    $dbh->do("UPDATE aqorders SET orderstatus=3 WHERE quantity=quantityreceived");
6497
    $dbh->do("UPDATE aqorders SET orderstatus=4 WHERE datecancellationprinted IS NOT NULL");
6498
    print "Upgrade to $DBversion done (Add category ORDRSTATUS values in authorised_values table)\n";
6499
    SetVersion($DBversion);
6500
}
6501
6486
=head1 FUNCTIONS
6502
=head1 FUNCTIONS
6487
6503
6488
=head2 TableExists($table)
6504
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-27 / +88 lines)
Lines 1-6 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( suggestions_loop ) %]Orders search &rsaquo; Search results[% ELSE %]Order search[% END %]</title>
3
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( order_loop ) %]Orders search &rsaquo; Search results[% ELSE %]Order search[% END %]</title>
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'calendar.inc' %]
6
[% INCLUDE 'calendar.inc' %]
Lines 24-30 Link Here
24
[% INCLUDE 'header.inc' %]
24
[% INCLUDE 'header.inc' %]
25
[% INCLUDE 'acquisitions-search.inc' %]
25
[% INCLUDE 'acquisitions-search.inc' %]
26
26
27
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; [% IF ( suggestions_loop ) %]<a href="/cgi-bin/koha/acqui/histsearch.pl">Orders search</a> &rsaquo; Search results[% ELSE %]Order search[% END %]</div>
27
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; [% IF ( order_loop ) %]<a href="/cgi-bin/koha/acqui/histsearch.pl">Orders search</a> &rsaquo; Search results[% ELSE %]Order search[% END %]</div>
28
28
29
<div id="doc3" class="yui-t2">
29
<div id="doc3" class="yui-t2">
30
   
30
   
Lines 32-38 Link Here
32
	<div id="yui-main">
32
	<div id="yui-main">
33
	<div class="yui-b">
33
	<div class="yui-b">
34
	
34
	
35
		[% UNLESS ( suggestions_loop ) %]<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
35
[% UNLESS ( order_loop ) %]<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
36
<fieldset class="rows">
36
<fieldset class="rows">
37
	<legend>Search Orders</legend>
37
	<legend>Search Orders</legend>
38
		<ol>
38
		<ol>
Lines 49-54 Link Here
49
            <label for="basketgroupname">Basket group:</label>
49
            <label for="basketgroupname">Basket group:</label>
50
            <input type="text" name="basketgroupname" id="basketgroupname" value="[% basketgroupname %]" />
50
            <input type="text" name="basketgroupname" id="basketgroupname" value="[% basketgroupname %]" />
51
        </li>
51
        </li>
52
53
        <li>
54
            <label for="orderstatus">Order Status: </label>
55
            <select name="orderstatus" id="orderstatus">
56
                <option value=""></option>
57
                <option value="0">New</option>
58
                <option value="1">Ordered</option>
59
                <option value="2">Partial</option>
60
                <option value="3">Complete</option>
61
                <option value="4">Deleted</option>
62
            </select>
63
        </li>
64
65
        [% IF ( display_branchcode ) %]
66
            <li>
67
                <label for="branchcode">Branch: </label>
68
                <select name="branchcode" id="branchcode">
69
                    <option value=""></option>
70
                    [% FOREACH branch IN branchloop %]
71
                        <option value="[% branch.value %]">
72
                            [% branch.value %] - [% branch.branchname %]
73
                        </option>
74
                    [% END %]
75
                </select>
76
            </li>
77
        [% END %]
78
79
        <li>
80
            <label for="budget">Budget: </label>
81
            <select name="budget" id="budget">
82
                <option value="">All budgets</option>
83
                [% FOREACH bp_loo IN bp_loop %]
84
                    <optgroup label="[% bp_loo.budget_period_description %]">
85
                    [% FOREACH h_loo IN bp_loo.hierarchy %]
86
                        <option type="text" name="budget" value="[% h_loo.budget_id %]" branchcode="[% h_loo.budget_branchcode %]">
87
                            [% h_loo.budget_display_name %]
88
                        </option>
89
                    [% END %]
90
                    </optgroup>
91
                [% END %]
92
            </select>
93
        </li>
94
52
		<li><label for="from">From: </label> 
95
		<li><label for="from">From: </label> 
53
        <input type="text" size="10" id="from" name="from" value="[% from_placed_on %]" class="datepickerfrom" />
96
        <input type="text" size="10" id="from" name="from" value="[% from_placed_on %]" class="datepickerfrom" />
54
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
97
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
Lines 62-72 Link Here
62
    <input type="hidden" name="do_search" value="1" />
105
    <input type="hidden" name="do_search" value="1" />
63
	<fieldset class="action"><input type="submit" value="Search" /></fieldset>
106
	<fieldset class="action"><input type="submit" value="Search" /></fieldset>
64
	</form>[% END %]
107
	</form>[% END %]
65
    [% IF ( suggestions_loop ) %]<h1>Search results</h1>
108
    [% IF ( order_loop ) %]<h1>Search results</h1>
66
	<div id="acqui_histsearch">
109
	<div id="acqui_histsearch">
67
        <table id="histsearcht">
110
        <table id="histsearcht">
68
            <thead>
111
            <thead>
69
			<tr>
112
			<tr>
113
                <th>Order line</th>
70
				<th>Basket</th>
114
				<th>Basket</th>
71
				<th>Basket group</th>
115
				<th>Basket group</th>
72
                <th>Invoice number</th>
116
                <th>Invoice number</th>
Lines 75-115 Link Here
75
				<th>Vendor</th>
119
				<th>Vendor</th>
76
				<th>Placed on</th>
120
				<th>Placed on</th>
77
				<th>Received on</th>
121
				<th>Received on</th>
78
				<th>Quantity ordered</th>
122
                <th>Status</th>
123
                <th>Quantity received</th>
124
                <th>Pending order</th>
79
				<th>Unit cost</th>
125
				<th>Unit cost</th>
126
                <th>Budget</th>
127
                <th>Branch</th>
80
			</tr>
128
			</tr>
81
            </thead>
129
            </thead>
82
            <tbody>
130
            <tbody>
83
			[% FOREACH suggestions_loo IN suggestions_loop %]
131
            [% FOREACH order IN order_loop %]
84
				<tr>
132
                <tr>
85
                    <td>[% suggestions_loo.basketname %] (<a href="basket.pl?basketno=[% suggestions_loo.basketno %]">[% suggestions_loo.basketno %]</a>)</td>
133
                    <td>[% order.parent_ordernumber %]</td>
134
                    <td>[% order.basketname %] (<a href="basket.pl?basketno=[% order.basketno %]">[% order.basketno %]</a>)</td>
86
                    <td>
135
                    <td>
87
                        [% IF ( suggestions_loo.basketgroupid ) %]
136
                        [% IF ( order.basketgroupid ) %]
88
                            [% suggestions_loo.groupname %] (<a href="basketgroup.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.basketgroupid %]</a>)
137
                            [% order.groupname %] (<a href="basketgroup.pl?booksellerid=[% order.id %]">[% order.basketgroupid %]</a>)
89
                        [% ELSE %]
138
                        [% ELSE %]
90
                            &nbsp;
139
                            &nbsp;
91
                        [% END %]
140
                        [% END %]
92
                    </td>
141
                    </td>
93
					<td>[% IF ( suggestions_loo.invoicenumber ) %]
142
                    <td>[% IF ( order.invoicenumber ) %]
94
                            <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% suggestions_loo.invoicenumber %]">[% suggestions_loo.invoicenumber %]</a>
143
                            <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% suggestions_loo.invoicenumber %]">[% suggestions_loo.invoicenumber %]</a>
95
					    [% ELSE %]
144
                        [% ELSE %]
96
					        &nbsp;
145
                            &nbsp;
97
					    [% END %]
146
                        [% END %]
98
					</td>
147
                    </td>
99
                    <td>[% suggestions_loo.ordernumber %]</td>
148
                    <td>[% order.ordernumber %]</td>
100
					<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% suggestions_loo.biblionumber %]">[% suggestions_loo.title |html %]</a>
149
                    <td>
101
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
150
                        <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber %]">[% order.title |html %]</a>
102
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
151
                        <br />[% order.author %] <br /> [% IF ( order.internalnotes ) %][% order.internalnotes %]<br />[% END %][% order.isbn %]</td>
103
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
152
                    <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.id %]">[% order.name %]</a></td>
153
                    <td>[% order.creationdate | $KohaDates %]</td>
154
                    <td>
155
                        [% IF order.datereceived %]
156
                            [% order.datereceived | $KohaDates %]
157
                        [% END %]
158
                    </td>
104
                    <td>
159
                    <td>
105
                        [% IF suggestions_loo.datereceived %]
160
                        [% SWITCH order.orderstatus %]
106
                            [% suggestions_loo.datereceived | $KohaDates %]
161
                            [% CASE '0' %]New
162
                            [% CASE '1' %]Ordered
163
                            [% CASE '2' %]Partial
164
                            [% CASE '3' %]Complete
165
                            [% CASE '4' %]Deleted
107
                        [% END %]
166
                        [% END %]
108
                    </td>
167
                    </td>
109
					<td>[% suggestions_loo.quantity %]</td>
168
                    <td>[% order.quantityreceived %]</td>
110
					<td>[% suggestions_loo.ecost %]</td>
169
                    <td>[% order.quantity %]</td>
111
				</tr>
170
                    <td>[% order.ecost %]</td>
112
			[% END %]
171
                    <td>[% order.budget_name %]</td>
172
                    <td>[% order.branchname %]</td>
173
                </tr>
174
            [% END %]
113
            </tbody>
175
            </tbody>
114
		</table>
176
		</table>
115
	</div>[% ELSE %][% END %]
177
	</div>[% ELSE %][% END %]
116
- 

Return to bug 5336