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

(-)a/C4/Acquisition.pm (-20 / +124 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 211-217 sub NewBasket { Link Here
211
212
212
  &CloseBasket($basketno);
213
  &CloseBasket($basketno);
213
214
214
close a basket (becomes unmodifiable,except for recieves)
215
close a basket (becomes unmodifiable, except for receives)
215
216
216
=cut
217
=cut
217
218
Lines 225-230 sub CloseBasket { Link Here
225
    ";
226
    ";
226
    my $sth = $dbh->prepare($query);
227
    my $sth = $dbh->prepare($query);
227
    $sth->execute($basketno);
228
    $sth->execute($basketno);
229
230
    my @orders = GetOrders($basketno);
231
    foreach my $order (@orders) {
232
        $query = qq{
233
            UPDATE aqorders
234
            SET orderstatus = 1
235
            WHERE ordernumber = ?;
236
        };
237
        $sth = $dbh->prepare($query);
238
        $sth->execute($order->{'ordernumber'});
239
    }
240
}
241
242
=head3 CloseBasket
243
244
  &ReopenBasket($basketno);
245
246
reopen a basket
247
248
=cut
249
250
sub ReopenBasket {
251
    my ($basketno) = @_;
252
    my $dbh        = C4::Context->dbh;
253
    my $query = "
254
        UPDATE aqbasket
255
        SET    closedate=NULL
256
        WHERE  basketno=?
257
    ";
258
    my $sth = $dbh->prepare($query);
259
    $sth->execute($basketno);
260
261
    my @orders = GetOrders($basketno);
262
    foreach my $order (@orders) {
263
        $query = qq{
264
            UPDATE aqorders
265
            SET orderstatus = 0
266
            WHERE ordernumber = ?;
267
        };
268
        $sth = $dbh->prepare($query);
269
        $sth->execute($order->{'ordernumber'});
270
    }
228
}
271
}
229
272
230
#------------------------------------------------------------#
273
#------------------------------------------------------------#
Lines 464-469 sub ModBasket { Link Here
464
    my $dbh = C4::Context->dbh;
507
    my $dbh = C4::Context->dbh;
465
    my $sth = $dbh->prepare($query);
508
    my $sth = $dbh->prepare($query);
466
    $sth->execute(@params);
509
    $sth->execute(@params);
510
467
    $sth->finish;
511
    $sth->finish;
468
}
512
}
469
513
Lines 1040-1046 The following keys are used: "biblionumber", "title", "basketno", "quantity", "n Link Here
1040
1084
1041
sub NewOrder {
1085
sub NewOrder {
1042
    my $orderinfo = shift;
1086
    my $orderinfo = shift;
1043
#### ------------------------------
1087
    my $parent_ordernumber = shift;
1088
1044
    my $dbh = C4::Context->dbh;
1089
    my $dbh = C4::Context->dbh;
1045
    my @params;
1090
    my @params;
1046
1091
Lines 1313-1318 sub ModReceiveOrder { Link Here
1313
        $sth=$dbh->prepare("
1358
        $sth=$dbh->prepare("
1314
            UPDATE aqorders
1359
            UPDATE aqorders
1315
            SET quantity = ?
1360
            SET quantity = ?
1361
                ordernumber = 2
1316
            WHERE ordernumber = ?
1362
            WHERE ordernumber = ?
1317
        ");
1363
        ");
1318
1364
Lines 1339-1345 sub ModReceiveOrder { Link Here
1339
    } else {
1385
    } else {
1340
        $sth=$dbh->prepare("update aqorders
1386
        $sth=$dbh->prepare("update aqorders
1341
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1387
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1342
                                unitprice=?,rrp=?,ecost=?
1388
                                unitprice=?,rrp=?,ecost=?,orderstatus=3
1343
                            where biblionumber=? and ordernumber=?");
1389
                            where biblionumber=? and ordernumber=?");
1344
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber);
1390
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber);
1345
        $sth->finish;
1391
        $sth->finish;
Lines 1556-1562 sub DelOrder { Link Here
1556
    my $dbh = C4::Context->dbh;
1602
    my $dbh = C4::Context->dbh;
1557
    my $query = "
1603
    my $query = "
1558
        UPDATE aqorders
1604
        UPDATE aqorders
1559
        SET    datecancellationprinted=now()
1605
        SET    datecancellationprinted=now(), orderstatus=4
1560
        WHERE  biblionumber=? AND ordernumber=?
1606
        WHERE  biblionumber=? AND ordernumber=?
1561
    ";
1607
    ";
1562
    my $sth = $dbh->prepare($query);
1608
    my $sth = $dbh->prepare($query);
Lines 1917-1922 sub GetHistory { Link Here
1917
    my $basket = $params{basket};
1963
    my $basket = $params{basket};
1918
    my $booksellerinvoicenumber = $params{booksellerinvoicenumber};
1964
    my $booksellerinvoicenumber = $params{booksellerinvoicenumber};
1919
    my $basketgroupname = $params{basketgroupname};
1965
    my $basketgroupname = $params{basketgroupname};
1966
    my $budget = $params{budget};
1967
    my $branchcode = $params{branchcode};
1968
    my $orderstatus = $params{orderstatus};
1969
1920
    my @order_loop;
1970
    my @order_loop;
1921
    my $total_qty         = 0;
1971
    my $total_qty         = 0;
1922
    my $total_qtyreceived = 0;
1972
    my $total_qtyreceived = 0;
Lines 1925-1934 sub GetHistory { Link Here
1925
    my $dbh   = C4::Context->dbh;
1975
    my $dbh   = C4::Context->dbh;
1926
    my $query ="
1976
    my $query ="
1927
        SELECT
1977
        SELECT
1928
            biblio.title,
1978
            COALESCE(biblio.title,     deletedbiblio.title)     AS title,
1929
            biblio.author,
1979
            COALESCE(biblio.author,    deletedbiblio.author)    AS author,
1930
	    biblioitems.isbn,
1980
            COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn,
1931
        biblioitems.ean,
1981
            COALESCE(biblioitems.ean,  deletedbiblioitems.ean)  AS ean,
1932
            aqorders.basketno,
1982
            aqorders.basketno,
1933
            aqbasket.basketname,
1983
            aqbasket.basketname,
1934
            aqbasket.basketgroupid,
1984
            aqbasket.basketgroupid,
Lines 1942-1960 sub GetHistory { Link Here
1942
            aqorders.ordernumber,
1992
            aqorders.ordernumber,
1943
            aqinvoices.invoicenumber,
1993
            aqinvoices.invoicenumber,
1944
            aqbooksellers.id as id,
1994
            aqbooksellers.id as id,
1945
            aqorders.biblionumber
1995
            aqorders.biblionumber,
1996
            aqorders.orderstatus,
1997
            aqorders.branchcode,
1998
            aqorders.parent_ordernumber,
1999
            aqbudgets.budget_name,
2000
            branches.branchname
2001
            ";
2002
    $query .= ", aqbudgets.budget_id AS budget" if defined $budget;
2003
    $query .= "
1946
        FROM aqorders
2004
        FROM aqorders
1947
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
2005
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
1948
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
2006
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1949
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
2007
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1950
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
2008
        LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1951
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
2009
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
1952
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2010
        LEFT JOIN branches ON branches.branchcode=aqorders.branchcode
2011
        LEFT JOIN aqbudgets ON aqorders.budget_id=aqbudgets.budget_id
2012
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
2013
        LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber
2014
        LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber
2015
        ";
2016
2017
    if ( C4::Context->preference("IndependantBranches") ) {
2018
        $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber";
2019
    }
1953
2020
1954
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2021
    $query .= " WHERE 1 ";
1955
    if ( C4::Context->preference("IndependantBranches") );
1956
2022
1957
    $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
2023
    $query .= " AND (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') " if $orderstatus ne '4';
1958
2024
1959
    my @query_params  = ();
2025
    my @query_params  = ();
1960
2026
Lines 1973-1979 sub GetHistory { Link Here
1973
        $query .= " AND biblioitems.isbn LIKE ? ";
2039
        $query .= " AND biblioitems.isbn LIKE ? ";
1974
        push @query_params, "%$isbn%";
2040
        push @query_params, "%$isbn%";
1975
    }
2041
    }
1976
    if ( defined $ean and $ean ) {
2042
    if ( $ean ) {
1977
        $query .= " AND biblioitems.ean = ? ";
2043
        $query .= " AND biblioitems.ean = ? ";
1978
        push @query_params, "$ean";
2044
        push @query_params, "$ean";
1979
    }
2045
    }
Lines 1982-1987 sub GetHistory { Link Here
1982
        push @query_params, "%$name%";
2048
        push @query_params, "%$name%";
1983
    }
2049
    }
1984
2050
2051
    if ( $budget ) {
2052
        $query .= " AND aqbudgets.budget_id = ? ";
2053
        push @query_params, "$budget";
2054
    }
2055
1985
    if ( $from_placed_on ) {
2056
    if ( $from_placed_on ) {
1986
        $query .= " AND creationdate >= ? ";
2057
        $query .= " AND creationdate >= ? ";
1987
        push @query_params, $from_placed_on;
2058
        push @query_params, $from_placed_on;
Lines 1992-1997 sub GetHistory { Link Here
1992
        push @query_params, $to_placed_on;
2063
        push @query_params, $to_placed_on;
1993
    }
2064
    }
1994
2065
2066
    if ( defined $orderstatus and $orderstatus ne '') {
2067
        $query .= " AND aqorders.orderstatus = ? ";
2068
        push @query_params, "$orderstatus";
2069
    }
2070
1995
    if ($basket) {
2071
    if ($basket) {
1996
        if ($basket =~ m/^\d+$/) {
2072
        if ($basket =~ m/^\d+$/) {
1997
            $query .= " AND aqorders.basketno = ? ";
2073
            $query .= " AND aqorders.basketno = ? ";
Lines 2018-2023 sub GetHistory { Link Here
2018
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2094
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2019
            push @query_params, $userenv->{branch};
2095
            push @query_params, $userenv->{branch};
2020
        }
2096
        }
2097
    } elsif ( defined $branchcode and $branchcode ) {
2098
        $query .= " AND aqorders.branchcode = ? ";
2099
        push @query_params, $branchcode;
2021
    }
2100
    }
2022
    $query .= " ORDER BY id";
2101
    $query .= " ORDER BY id";
2023
    my $sth = $dbh->prepare($query);
2102
    my $sth = $dbh->prepare($query);
Lines 2027-2035 sub GetHistory { Link Here
2027
        $line->{count} = $cnt++;
2106
        $line->{count} = $cnt++;
2028
        $line->{toggle} = 1 if $cnt % 2;
2107
        $line->{toggle} = 1 if $cnt % 2;
2029
        push @order_loop, $line;
2108
        push @order_loop, $line;
2030
        $total_qty         += $line->{'quantity'};
2109
        $total_qty         += ( $line->{quantity} ) ? $line->{quantity} : 0;
2031
        $total_qtyreceived += $line->{'quantityreceived'};
2110
        $total_qtyreceived += ( $line->{quantityreceived} ) ? $line->{quantityreceived} : 0;
2032
        $total_price       += $line->{'quantity'} * $line->{'ecost'};
2111
        $total_price       += ( $line->{quantity} and $line->{ecost} ) ? $line->{quantity} * $line->{ecost} : 0;
2033
    }
2112
    }
2034
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2113
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2035
}
2114
}
Lines 2491-2496 sub ReopenInvoice { Link Here
2491
    $sth->execute($invoiceid);
2570
    $sth->execute($invoiceid);
2492
}
2571
}
2493
2572
2573
=head3 GetBiblioCountByBasketno
2574
2575
$biblio_count = &GetBiblioCountByBasketno($basketno);
2576
2577
Looks up the biblio's count that has basketno value $basketno
2578
2579
Returns a quantity
2580
2581
=cut
2582
2583
sub GetBiblioCountByBasketno {
2584
    my ($basketno) = @_;
2585
    my $dbh          = C4::Context->dbh;
2586
    my $query        = "
2587
        SELECT COUNT( DISTINCT( biblionumber ) )
2588
        FROM   aqorders
2589
        WHERE  basketno = ?
2590
            AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')
2591
        ";
2592
2593
    my $sth = $dbh->prepare($query);
2594
    $sth->execute($basketno);
2595
    return $sth->fetchrow;
2596
}
2597
2494
1;
2598
1;
2495
__END__
2599
__END__
2496
2600
(-)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
    DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
172
    DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
136
    dateformat              => C4::Dates->new()->format(),
173
    dateformat              => C4::Dates->new()->format(),
137
    debug                   => $debug || $input->param('debug') || 0,
174
    debug                   => $debug || $input->param('debug') || 0,
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2805-2810 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2805
  `claims_count` int(11) default 0, -- count of claim letters generated
2805
  `claims_count` int(11) default 0, -- count of claim letters generated
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
  `orderstatus` tinyint(2) default 0, -- the current status for this line item
2808
  PRIMARY KEY  (`ordernumber`),
2809
  PRIMARY KEY  (`ordernumber`),
2809
  KEY `basketno` (`basketno`),
2810
  KEY `basketno` (`basketno`),
2810
  KEY `biblionumber` (`biblionumber`),
2811
  KEY `biblionumber` (`biblionumber`),
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 6299-6304 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6299
}
6299
}
6300
6300
6301
6301
6302
6303
6304
6305
6306
$DBversion = "3.11.00.XXX";
6307
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6308
    my $return_count;
6309
    $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus tinyint(2) DEFAULT 0 AFTER parent_ordernumber");
6310
    $dbh->do("UPDATE aqorders SET orderstatus=1 WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)");
6311
    $dbh->do("UPDATE aqorders SET orderstatus=2 WHERE quantity > quantityreceived AND quantityreceived > 0");
6312
    $dbh->do("UPDATE aqorders SET orderstatus=3 WHERE quantity=quantityreceived");
6313
    $dbh->do("UPDATE aqorders SET orderstatus=4 WHERE datecancellationprinted IS NOT NULL");
6314
    print "Upgrade to $DBversion done (Add category ORDRSTATUS values in authorised_values table)\n";
6315
    SetVersion($DBversion);
6316
}
6317
6302
=head1 FUNCTIONS
6318
=head1 FUNCTIONS
6303
6319
6304
=head2 TableExists($table)
6320
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-28 / +89 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 21-27 Link Here
21
[% INCLUDE 'header.inc' %]
21
[% INCLUDE 'header.inc' %]
22
[% INCLUDE 'acquisitions-search.inc' %]
22
[% INCLUDE 'acquisitions-search.inc' %]
23
23
24
<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>
24
<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>
25
25
26
<div id="doc3" class="yui-t2">
26
<div id="doc3" class="yui-t2">
27
   
27
   
Lines 29-35 Link Here
29
	<div id="yui-main">
29
	<div id="yui-main">
30
	<div class="yui-b">
30
	<div class="yui-b">
31
	
31
	
32
		[% UNLESS ( suggestions_loop ) %]<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
32
		[% UNLESS ( order_loop ) %]<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
33
<fieldset class="rows">
33
<fieldset class="rows">
34
	<legend>Search Orders</legend>
34
	<legend>Search Orders</legend>
35
		<ol>
35
		<ol>
Lines 46-51 Link Here
46
            <label for="basketgroupname">Basket group:</label>
46
            <label for="basketgroupname">Basket group:</label>
47
            <input type="text" name="basketgroupname" id="basketgroupname" value="[% basketgroupname %]" />
47
            <input type="text" name="basketgroupname" id="basketgroupname" value="[% basketgroupname %]" />
48
        </li>
48
        </li>
49
50
        <li>
51
            <label for="orderstatus">Order Status: </label>
52
            <select name="orderstatus" id="orderstatus">
53
                <option value=""></option>
54
                <option value="0">New</option>
55
                <option value="1">Ordered</option>
56
                <option value="2">Partial</option>
57
                <option value="3">Complete</option>
58
                <option value="4">Deleted</option>
59
            </select>
60
        </li>
61
62
        [% IF ( display_branchcode ) %]
63
            <li>
64
                <label for="branchcode">Branch: </label>
65
                <select name="branchcode" id="branchcode">
66
                    <option value=""></option>
67
                    [% FOREACH branch IN branchloop %]
68
                        <option value="[% branch.value %]">
69
                            [% branch.value %] - [% branch.branchname %]
70
                        </option>
71
                    [% END %]
72
                </select>
73
            </li>
74
        [% END %]
75
76
        <li>
77
            <label for="budget">Budget: </label>
78
            <select name="budget" id="budget">
79
                <option value="">All budgets</option>
80
                [% FOREACH bp_loo IN bp_loop %]
81
                    <optgroup label="[% bp_loo.budget_period_description %]">
82
                    [% FOREACH h_loo IN bp_loo.hierarchy %]
83
                        <option type="text" name="budget" value="[% h_loo.budget_id %]" branchcode="[% h_loo.budget_branchcode %]">
84
                            [% h_loo.budget_display_name %]
85
                        </option>
86
                    [% END %]
87
                    </optgroup>
88
                [% END %]
89
            </select>
90
        </li>
91
49
		<li><label for="from">From: </label> 
92
		<li><label for="from">From: </label> 
50
        <input type="text" size="10" id="from" name="from" value="[% from_placed_on %]" class="datepickerfrom" />
93
        <input type="text" size="10" id="from" name="from" value="[% from_placed_on %]" class="datepickerfrom" />
51
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
94
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
Lines 59-69 Link Here
59
    <input type="hidden" name="do_search" value="1" />
102
    <input type="hidden" name="do_search" value="1" />
60
	<fieldset class="action"><input type="submit" value="Search" /></fieldset>
103
	<fieldset class="action"><input type="submit" value="Search" /></fieldset>
61
	</form>[% END %]
104
	</form>[% END %]
62
    [% IF ( suggestions_loop ) %]<h1>Search results</h1>
105
    [% IF ( order_loop ) %]<h1>Search results</h1>
63
	<div id="acqui_histsearch">
106
	<div id="acqui_histsearch">
64
        <table id="histsearcht">
107
        <table id="histsearcht">
65
            <thead>
108
            <thead>
66
			<tr>
109
			<tr>
110
                <th>Order line</th>
67
				<th>Basket</th>
111
				<th>Basket</th>
68
				<th>Basket group</th>
112
				<th>Basket group</th>
69
                <th>Invoice number</th>
113
                <th>Invoice number</th>
Lines 72-112 Link Here
72
				<th>Vendor</th>
116
				<th>Vendor</th>
73
				<th>Placed on</th>
117
				<th>Placed on</th>
74
				<th>Received on</th>
118
				<th>Received on</th>
75
				<th>Quantity ordered</th>
119
                <th>Status</th>
120
				<th>Quantity received</th>
121
                <th>Pending order</th>
76
				<th>Unit cost</th>
122
				<th>Unit cost</th>
123
                <th>Budget</th>
124
                <th>Branch</th>
77
			</tr>
125
			</tr>
78
            </thead>
126
            </thead>
79
            <tbody>
127
            <tbody>
80
			[% FOREACH suggestions_loo IN suggestions_loop %]
128
            [% FOREACH order IN order_loop %]
81
				<tr>
129
                <tr>
82
                    <td>[% suggestions_loo.basketname %] (<a href="basket.pl?basketno=[% suggestions_loo.basketno %]">[% suggestions_loo.basketno %]</a>)</td>
130
                    <td>[% order.parent_ordernumber %]</td>
131
                    <td>[% order.basketname %] (<a href="basket.pl?basketno=[% order.basketno %]">[% order.basketno %]</a>)</td>
83
                    <td>
132
                    <td>
84
                        [% IF ( suggestions_loo.basketgroupid ) %]
133
                        [% IF ( order.basketgroupid ) %]
85
                            [% suggestions_loo.groupname %] (<a href="basketgroup.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.basketgroupid %]</a>)
134
                            [% order.groupname %] (<a href="basketgroup.pl?booksellerid=[% order.id %]">[% order.basketgroupid %]</a>)
86
                        [% ELSE %]
135
                        [% ELSE %]
87
                            &nbsp;
136
                            &nbsp;
88
                        [% END %]
137
                        [% END %]
89
                    </td>
138
                    </td>
90
					<td>[% IF ( suggestions_loo.invoicenumber ) %]
139
                    <td>[% IF ( order.invoicenumber ) %]
91
					        <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% suggestions_loo.invoicenumber %]&amp;booksellerid=[% suggestions_loo.id %]&amp;datereceived=[% suggestions_loo.datereceived %]">[% suggestions_loo.invoicenumber %]</a>
140
                            <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% order.invoicenumber %]&amp;booksellerid=[% order.id %]&amp;datereceived=[% order.datereceived %]">[% order.invoicenumber %]</a>
92
					    [% ELSE %]
141
                        [% ELSE %]
93
					        &nbsp;
142
                            &nbsp;
94
					    [% END %]
143
                        [% END %]
95
					</td>
144
                    </td>
96
                    <td>[% suggestions_loo.ordernumber %]</td>
145
                    <td>[% order.ordernumber %]</td>
97
					<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% suggestions_loo.biblionumber %]">[% suggestions_loo.title |html %]</a>
146
                    <td>
98
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
147
                        <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber %]">[% order.title |html %]</a>
99
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
148
                        <br />[% order.author %] <br /> [% IF ( order.internalnotes ) %][% order.internalnotes %]<br />[% END %][% order.isbn %]</td>
100
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
149
                    <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.id %]">[% order.name %]</a></td>
150
                    <td>[% order.creationdate | $KohaDates %]</td>
151
                    <td>
152
                        [% IF order.datereceived %]
153
                            [% order.datereceived | $KohaDates %]
154
                        [% END %]
155
                    </td>
101
                    <td>
156
                    <td>
102
                        [% IF suggestions_loo.datereceived %]
157
                        [% SWITCH order.orderstatus %]
103
                            [% suggestions_loo.datereceived | $KohaDates %]
158
                            [% CASE '0' %]New
159
                            [% CASE '1' %]Ordered
160
                            [% CASE '2' %]Partial
161
                            [% CASE '3' %]Complete
162
                            [% CASE '4' %]Deleted
104
                        [% END %]
163
                        [% END %]
105
                    </td>
164
                    </td>
106
					<td>[% suggestions_loo.quantity %]</td>
165
                    <td>[% order.quantityreceived %]</td>
107
					<td>[% suggestions_loo.ecost %]</td>
166
                    <td>[% order.quantity %]</td>
108
				</tr>
167
                    <td>[% order.ecost %]</td>
109
			[% END %]
168
                    <td>[% order.budget_name %]</td>
169
                    <td>[% order.branchname %]</td>
170
                </tr>
171
            [% END %]
110
            </tbody>
172
            </tbody>
111
		</table>
173
		</table>
112
	</div>[% ELSE %][% END %]
174
	</div>[% ELSE %][% END %]
113
- 

Return to bug 5336