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

(-)a/C4/Budgets.pm (+13 lines)
Lines 41-46 BEGIN { Link Here
41
        &DelBudget
41
        &DelBudget
42
        &GetBudgetSpent
42
        &GetBudgetSpent
43
        &GetBudgetOrdered
43
        &GetBudgetOrdered
44
        &GetBudgetCredited
44
        &GetBudgetName
45
        &GetBudgetName
45
        &GetPeriodsCount
46
        &GetPeriodsCount
46
        &GetChildBudgetsSpent
47
        &GetChildBudgetsSpent
Lines 357-362 sub GetBudgetOrdered { Link Here
357
	return $sum;
358
	return $sum;
358
}
359
}
359
360
361
# -------------------------------------------------------------------
362
sub GetBudgetCredited {
363
	my ($budget_id) = @_;
364
	my $dbh = C4::Context->dbh;
365
	my $sth = $dbh->prepare(qq|
366
        SELECT SUM(amountcredit) AS sum FROM aqcreditnotes
367
            WHERE budget_id = ? 
368
    |);
369
	$sth->execute($budget_id);
370
	return $sth->fetchrow_array;
371
}
372
360
=head2 GetBudgetName
373
=head2 GetBudgetName
361
374
362
  my $budget_name = &GetBudgetName($budget_id);
375
  my $budget_name = &GetBudgetName($budget_id);
(-)a/C4/Creditnote.pm (+148 lines)
Line 0 Link Here
1
package C4::Creditnote;
2
3
# Copyright 2013 Amit Gupta (amitddng135@gmail.com)
4
#
5
# This file is part of Koha.
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
21
use strict;
22
use warnings;
23
use C4::Context;
24
25
use vars qw($VERSION @ISA @EXPORT);
26
27
BEGIN {
28
    # set the version for version checking
29
    $VERSION = 3.07.00.049;
30
    require Exporter;
31
    @ISA    = qw(Exporter);
32
    @EXPORT = qw(
33
        &AddCreditnote &ModCreditnote &Creditnote &ShowCreditnoteid
34
        &DelCreditnote
35
    
36
    );
37
}
38
39
40
=head3 AddCreditnote
41
   
42
Create a new creditnote and return its id.
43
44
=cut
45
46
sub AddCreditnote {
47
    my ($booksellerid, $invoiceid, $vendorrefid, $amountcredit, $creditdate, $notes, $budget_id)  = @_;
48
    my $dbh = C4::Context->dbh;
49
    my $query = qq|
50
            INSERT INTO aqcreditnotes
51
                (booksellerid, invoiceid, vendorrefid, amountcredit, creditdate, notes, budget_id)
52
            VALUES (?,?,?,?,?,?,?)    |;
53
54
    my $sth = $dbh->prepare($query);
55
    $sth->execute( $booksellerid,$invoiceid,$vendorrefid,$amountcredit,$creditdate,$notes,$budget_id);
56
}
57
58
=head3 ModCreditnote
59
60
Modify an creditnote, creditnote_id is mandatory.
61
62
Return undef if it fails.
63
64
=cut
65
66
sub ModCreditnote {
67
    my ($vendorrefid,$amountcredit,$creditdate,$notes,$budget_id,$creditnote_id) = @_;   
68
    my $dbh = C4::Context->dbh;
69
    my $query = qq|
70
        UPDATE aqcreditnotes
71
        SET    vendorrefid = ?, amountcredit = ?, creditdate = ?, notes = ?, budget_id = ?
72
        WHERE  creditnote_id=?
73
        |;
74
    my $sth = $dbh->prepare($query);
75
    $sth->execute($vendorrefid,$amountcredit,$creditdate,$notes,$budget_id,$creditnote_id);    
76
}
77
78
=head3 Creditnote
79
80
Show all results against booksellerid and invoiceid
81
82
=cut
83
84
sub Creditnote {
85
    my ($booksellerid, $invoiceid)  = @_;
86
    my $dbh = C4::Context->dbh;
87
    my $query = qq|
88
            SELECT * FROM aqcreditnotes 
89
            WHERE booksellerid = ? AND invoiceid = ?
90
                 |;
91
    my $sth = $dbh->prepare($query);
92
    my @results;
93
    $sth->execute($booksellerid, $invoiceid);  
94
    return $sth->fetchall_arrayref( {} );
95
}
96
97
=head3 ShowCreditnoteid
98
99
Show particular result against creditnote_id
100
101
=cut
102
103
sub ShowCreditnoteid {
104
    my ($creditnote_id)  = @_;    
105
    my $dbh        = C4::Context->dbh;
106
    my $query = "
107
        SELECT * FROM aqcreditnotes 
108
        WHERE creditnote_id = ?
109
    ";
110
    my $sth=$dbh->prepare($query);
111
    $sth->execute($creditnote_id);
112
    return $sth->fetchrow_hashref;    
113
}
114
115
=head3 DelCreditnote
116
117
  &DelCreditnote($creditnote_id,$booksellerid,$invoiceid);
118
119
Deletes the creditnote that has creditnote_id field $creditnote_id in the aqcreditnotes table.
120
121
=over
122
123
=item C<$creditnote_id> is the primary key of the creditnote in the aqcreditnotes table.
124
125
=back
126
127
=cut
128
129
sub DelCreditnote {
130
    my ($creditnote_id,$booksellerid,$invoiceid) = @_;
131
    my $dbh = C4::Context->dbh;    
132
    my $query = qq|
133
            DELETE FROM aqcreditnotes 
134
            WHERE creditnote_id = ? AND booksellerid = ? AND invoiceid = ?
135
                 |;
136
    my $sth = $dbh->prepare($query);
137
    $sth->execute($creditnote_id,$booksellerid,$invoiceid);
138
    $sth->finish; 
139
}
140
141
1;
142
__END__
143
144
=head1 AUTHOR
145
146
Amit Gupta <amitddng135 AT gmail.com>
147
148
=cut
(-)a/acqui/acqui-home.pl (-4 / +14 lines)
Lines 85-95 my $totspent = 0; Link Here
85
my $totordered = 0;
85
my $totordered = 0;
86
my $totcomtd   = 0;
86
my $totcomtd   = 0;
87
my $totavail   = 0;
87
my $totavail   = 0;
88
my $totcredit = 0;
88
89
89
my $total_active        = 0;
90
my $total_active        = 0;
90
my $totspent_active     = 0;
91
my $totspent_active     = 0;
91
my $totordered_active   = 0;
92
my $totordered_active   = 0;
92
my $totavail_active     = 0;
93
my $totavail_active     = 0;
94
my $totavail_credit     = 0;
93
95
94
my @budget_loop;
96
my @budget_loop;
95
foreach my $budget ( @{$budget_arr} ) {
97
foreach my $budget ( @{$budget_arr} ) {
Lines 112-140 foreach my $budget ( @{$budget_arr} ) { Link Here
112
    }
114
    }
113
115
114
    $budget->{'budget_ordered'} = GetBudgetOrdered( $budget->{'budget_id'} );
116
    $budget->{'budget_ordered'} = GetBudgetOrdered( $budget->{'budget_id'} );
115
    $budget->{'budget_spent'}   = GetBudgetSpent( $budget->{'budget_id'} );
117
    $budget->{'budget_spent'}   = GetBudgetSpent( $budget->{'budget_id'} );    
118
    $budget->{'budget_credit'}   = GetBudgetCredited( $budget->{'budget_id'} );
116
    if ( !defined $budget->{budget_spent} ) {
119
    if ( !defined $budget->{budget_spent} ) {
117
        $budget->{budget_spent} = 0;
120
        $budget->{budget_spent} = 0;
118
    }
121
    }
119
    if ( !defined $budget->{budget_ordered} ) {
122
    if ( !defined $budget->{budget_ordered} ) {
120
        $budget->{budget_ordered} = 0;
123
        $budget->{budget_ordered} = 0;
121
    }
124
    }
125
    if ( !defined $budget->{budget_credit} ) {
126
        $budget->{budget_credit} = 0;
127
    }
122
    $budget->{'budget_avail'} =
128
    $budget->{'budget_avail'} =
123
      $budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} );
129
      ($budget->{'budget_amount'} + $budget->{'budget_credit'})- ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} );
124
130
125
    $total      += $budget->{'budget_amount'};
131
    $total      += $budget->{'budget_amount'};
126
    $totspent   += $budget->{'budget_spent'};
132
    $totspent   += $budget->{'budget_spent'};
127
    $totordered += $budget->{'budget_ordered'};
133
    $totordered += $budget->{'budget_ordered'};
128
    $totavail   += $budget->{'budget_avail'};
134
    $totavail   += $budget->{'budget_avail'};
135
    $totcredit   += $budget->{'budget_credit'};
129
136
130
    if ($budget->{budget_period_active}){
137
    if ($budget->{budget_period_active}){
131
	$total_active      += $budget->{'budget_amount'};
138
	$total_active      += $budget->{'budget_amount'};
132
	$totspent_active   += $budget->{'budget_spent'};
139
	$totspent_active   += $budget->{'budget_spent'};
133
	$totordered_active += $budget->{'budget_ordered'};
140
	$totordered_active += $budget->{'budget_ordered'};
134
	$totavail_active   += $budget->{'budget_avail'};    
141
	$totavail_active   += $budget->{'budget_avail'};    
142
	$totavail_credit   += $budget->{'budget_credit'};
135
    }
143
    }
136
144
137
    for my $field (qw( budget_amount budget_spent budget_ordered budget_avail ) ) {
145
    for my $field (qw( budget_amount budget_spent budget_ordered budget_avail budget_credit ) ) {
138
        $budget->{$field} = $num_formatter->format_price( $budget->{$field} );
146
        $budget->{$field} = $num_formatter->format_price( $budget->{$field} );
139
    }
147
    }
140
148
Lines 150-159 $template->param( Link Here
150
    totordered    => $num_formatter->format_price($totordered),
158
    totordered    => $num_formatter->format_price($totordered),
151
    totcomtd      => $num_formatter->format_price($totcomtd),
159
    totcomtd      => $num_formatter->format_price($totcomtd),
152
    totavail      => $num_formatter->format_price($totavail),
160
    totavail      => $num_formatter->format_price($totavail),
153
    total_active  => $num_formatter->format_price($total_active),
161
    totcredit   => $num_formatter->format_price($totcredit),
162
    total_active  => $num_formatter->format_price($total_active),    
154
    totspent_active     => $num_formatter->format_price($totspent_active),
163
    totspent_active     => $num_formatter->format_price($totspent_active),
155
    totordered_active   => $num_formatter->format_price($totordered_active),
164
    totordered_active   => $num_formatter->format_price($totordered_active),
156
    totavail_active     => $num_formatter->format_price($totavail_active),
165
    totavail_active     => $num_formatter->format_price($totavail_active),
166
    totavail_credit     => $num_formatter->format_price($totavail_credit),
157
    suggestions_count   => $suggestions_count,
167
    suggestions_count   => $suggestions_count,
158
);
168
);
159
169
(-)a/acqui/creditnote.pl (+120 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 Amit Gupta(amitddng135@gmail.com)
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
creditnote.pl
22
23
=head1 DESCRIPTION
24
25
creditnote details
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
use C4::Acquisition;
36
use C4::Bookseller qw/GetBookSellerFromId/;
37
use C4::Creditnote;
38
use C4::Budgets;
39
use C4::Dates qw/format_date format_date_in_iso/;
40
41
my $input = new CGI;
42
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
43
    {
44
        template_name   => 'acqui/creditnote.tmpl',
45
        query           => $input,
46
        type            => 'intranet',
47
        authnotrequired => 0,
48
        flagsrequired   => { 'acquisition' => '*' },
49
        debug           => 1,
50
    }
51
);
52
53
my $invoiceid = $input->param('invoiceid');
54
my $booksellerid = $input->param('booksellerid');
55
my $vendorrefid = $input->param('vendorrefid');
56
my $amountcredit = $input->param('amountcredit');
57
my $budget_id       = $input->param('budget_id') || 0;
58
my $creditdate = C4::Dates->new($input->param('creditdate'))->output('iso');
59
my $notes = $input->param('notes');
60
my $creditnote_id = $input->param('creditnote_id');
61
my $op        = $input->param('op');
62
63
my $details     = GetInvoiceDetails($invoiceid);
64
my $bookseller  = GetBookSellerFromId($booksellerid);
65
66
# build budget list
67
my $budget_loop = [];
68
my $budgets = GetBudgetHierarchy;
69
foreach my $r (@{$budgets}) {    
70
    push @{$budget_loop}, {
71
        b_id  => $r->{budget_id},
72
        b_txt => $r->{budget_name},
73
        b_active => $r->{budget_period_active},  
74
        b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
75
    };
76
}
77
78
@{$budget_loop} =
79
  sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop};
80
81
my $script_name = "/cgi-bin/koha/acqui/creditnote.pl?booksellerid=$booksellerid&invoiceid=$invoiceid";
82
83
my $results = Creditnote($booksellerid, $invoiceid);
84
my @creditloop = ();
85
foreach my $credit (@$results) {
86
    my $budget_name =  GetBudget($credit->{'budget_id'});
87
            push @creditloop, {
88
            creditnote_id => $credit->{'creditnote_id'},
89
            vendorrefid => $credit->{'vendorrefid'},
90
            amountcredit  => sprintf( "%.2f", $credit->{'amountcredit'}),
91
            creditdate    => format_date($credit->{'creditdate'}),
92
            notes    => $credit->{'notes'},            
93
            budget   => $budget_name->{'budget_name'},            
94
        };
95
 }
96
97
98
if ($op eq 'add'){    
99
    AddCreditnote($booksellerid, $invoiceid, $vendorrefid, $amountcredit, $creditdate, $notes, $budget_id);
100
    print $input->redirect($script_name);
101
    exit;    
102
}
103
104
if ($op eq 'delete'){        
105
    DelCreditnote($creditnote_id,$booksellerid,$invoiceid);    
106
    print $input->redirect($script_name);
107
    exit;    
108
}
109
110
$template->param(
111
    invoiceid        => $invoiceid,
112
    invoicenumber    => $details->{'invoicenumber'},
113
    suppliername     => $bookseller->{'name'},    
114
    booksellerid     => $booksellerid,
115
    creditloop       => \@creditloop,
116
    budget_loop      => $budget_loop,
117
);
118
119
120
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/editcreditnote.pl (+103 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 Amit Gupta(amitddng135@gmail.com)
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
creditnote.pl
22
23
=head1 DESCRIPTION
24
25
creditnote details
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
use C4::Acquisition;
36
use C4::Bookseller qw/GetBookSellerFromId/;
37
use C4::Creditnote;
38
use C4::Budgets;
39
use C4::Dates qw/format_date format_date_in_iso/;
40
41
my $input = new CGI;
42
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
43
    {
44
        template_name   => 'acqui/editcreditnote.tmpl',
45
        query           => $input,
46
        type            => 'intranet',
47
        authnotrequired => 0,
48
        flagsrequired   => { 'acquisition' => '*' },
49
        debug           => 1,
50
    }
51
);
52
53
my $invoiceid = $input->param('invoiceid');
54
my $booksellerid = $input->param('booksellerid');
55
my $creditnote_id = $input->param('creditnote_id');
56
my $vendorrefid = $input->param('vendorrefid');
57
my $amountcredit = $input->param('amountcredit');
58
my $budget_id    = $input->param('budget_id');
59
my $creditdate = C4::Dates->new($input->param('creditdate'))->output('iso');
60
my $notes = $input->param('notes');
61
62
my $op        = $input->param('op');
63
64
my $creditdetail = &ShowCreditnoteid($creditnote_id);        
65
my $details      = GetInvoiceDetails($invoiceid);
66
my $bookseller   = GetBookSellerFromId($booksellerid);
67
68
# build budget list
69
my $budget_loop = [];
70
my $budgets = GetBudgetHierarchy;
71
foreach my $r (@{$budgets}) {    
72
    push @{$budget_loop}, {
73
        b_id  => $r->{budget_id},
74
        b_txt => $r->{budget_name},
75
        b_active => $r->{budget_period_active},  
76
        b_sel => ( $r->{budget_id} == $creditdetail->{'budget_id'} ) ? 1 : 0,
77
    };
78
}
79
80
@{$budget_loop} =
81
  sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop};
82
83
if ($op eq 'edit'){                 
84
      ModCreditnote($vendorrefid, $amountcredit, $creditdate,$notes,$budget_id, $creditnote_id);
85
      print $input->redirect("/cgi-bin/koha/acqui/creditnote.pl?booksellerid=$booksellerid&invoiceid=$invoiceid");
86
      exit;   
87
    }
88
    
89
$template->param(    
90
    invoiceid        => $invoiceid,
91
    invoicenumber    => $details->{'invoicenumber'},
92
    suppliername     => $bookseller->{'name'},    
93
    booksellerid     => $booksellerid,
94
    creditnote_id    => $creditnote_id,
95
    amountcredit => sprintf("%.2f",$creditdetail->{'amountcredit'}),
96
    creditdate   => format_date($creditdetail->{'creditdate'}),
97
    vendorrefid => $creditdetail->{'vendorrefid'},
98
    notes => $creditdetail->{'notes'},
99
    budget_loop      => $budget_loop,
100
);
101
102
103
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/admin/aqbudgets.pl (-6 / +13 lines)
Lines 276-289 if ($op eq 'add_form') { Link Here
276
    my $toggle = 0;
276
    my $toggle = 0;
277
    my @loop;
277
    my @loop;
278
    my $period_total = 0;
278
    my $period_total = 0;
279
    my ( $period_alloc_total, $base_spent_total );
279
    my ( $period_alloc_total, $base_spent_total, $base_credit_total);
280
280
281
	#This Looks WEIRD to me : should budgets be filtered in such a way ppl who donot own it would not see the amount spent on the budget by others ?
281
	#This Looks WEIRD to me : should budgets be filtered in such a way ppl who donot own it would not see the amount spent on the budget by others ?
282
282
283
    foreach my $budget (@budgets) {
283
    foreach my $budget (@budgets) {
284
        #Level and sublevels total spent
284
        #Level and sublevels total spent
285
        $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});
285
        $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});        
286
286
        $budget->{'budget_credit'} = GetBudgetCredited($budget->{"budget_id"}); 
287
        # PERMISSIONS
287
        # PERMISSIONS
288
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
288
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
289
            $budget->{'budget_lock'} = 1;
289
            $budget->{'budget_lock'} = 1;
Lines 303-309 if ($op eq 'add_form') { Link Here
303
        # adds to total  - only if budget is a 'top-level' budget
303
        # adds to total  - only if budget is a 'top-level' budget
304
        $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
304
        $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
305
        $base_spent_total += $budget->{'budget_spent'};
305
        $base_spent_total += $budget->{'budget_spent'};
306
        $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'};
306
        $base_credit_total += $budget->{'budget_credit'};
307
        $budget->{'budget_remaining'} = ($budget->{'budget_amount'} + $budget->{'budget_credit'}) - $budget->{'total_levels_spent'};
307
308
308
# if amount == 0 dont display...
309
# if amount == 0 dont display...
309
        delete $budget->{'budget_unalloc_sublevel'}
310
        delete $budget->{'budget_unalloc_sublevel'}
Lines 312-324 if ($op eq 'add_form') { Link Here
312
313
313
        $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
314
        $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
314
        $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
315
        $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
315
		for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){
316
		for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc|budget_credit/} keys %$budget){
316
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
317
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
317
		}
318
		}
318
319
319
        # Value of budget_spent equals 0 instead of undefined value
320
        # Value of budget_spent equals 0 instead of undefined value
320
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
321
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
321
322
        $budget->{"budget_credit"} = $num->format_price(0) unless defined($budget->{"budget_credit"});
323
        
322
        my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
324
        my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
323
        $budget->{"budget_owner_name"}     = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
325
        $budget->{"budget_owner_name"}     = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
324
        $budget->{"budget_borrowernumber"} = $borrower->{'borrowernumber'};
326
        $budget->{"budget_borrowernumber"} = $borrower->{'borrowernumber'};
Lines 355-360 if ($op eq 'add_form') { Link Here
355
    if ($base_spent_total) {
357
    if ($base_spent_total) {
356
        $base_spent_total = $num->format_price($base_spent_total);
358
        $base_spent_total = $num->format_price($base_spent_total);
357
    }
359
    }
360
    
361
    if ($base_credit_total) {
362
        $base_credit_total = $num->format_price($base_credit_total);
363
    }
358
364
359
    $template->param(
365
    $template->param(
360
        else                   => 1,
366
        else                   => 1,
Lines 362-367 if ($op eq 'add_form') { Link Here
362
        budget_period_total    => $budget_period_total,
368
        budget_period_total    => $budget_period_total,
363
        period_alloc_total     => $period_alloc_total,
369
        period_alloc_total     => $period_alloc_total,
364
        base_spent_total       => $base_spent_total,
370
        base_spent_total       => $base_spent_total,
371
        base_credit_total      => $base_credit_total,
365
        branchloop             => \@branchloop2,
372
        branchloop             => \@branchloop2,
366
    );
373
    );
367
374
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (+3 lines)
Lines 120-125 $(document).ready(function() { Link Here
120
            <th>Amount</th>
120
            <th>Amount</th>
121
            <th>Ordered</th>
121
            <th>Ordered</th>
122
            <th>Spent</th>
122
            <th>Spent</th>
123
            <th>Credited</th>
123
            <th>Avail</th>
124
            <th>Avail</th>
124
        </tr>
125
        </tr>
125
        </thead>
126
        </thead>
Lines 133-138 $(document).ready(function() { Link Here
133
            <th class="data"><span class="bu_active">[% total %]</span><span class="bu_inactive" >[% total_active %]</span></th>
134
            <th class="data"><span class="bu_active">[% total %]</span><span class="bu_inactive" >[% total_active %]</span></th>
134
            <th class="data"><span class="bu_active">[% totordered %]</span><span class="bu_inactive" >[% totordered_active %]</span></th>
135
            <th class="data"><span class="bu_active">[% totordered %]</span><span class="bu_inactive" >[% totordered_active %]</span></th>
135
            <th class="data"><span class="bu_active">[% totspent %]</span><span class="bu_inactive" >[% totspent_active %]</span></th>
136
            <th class="data"><span class="bu_active">[% totspent %]</span><span class="bu_inactive" >[% totspent_active %]</span></th>
137
            <th class="data"><span class="bu_active">[% totavail_credit %]</span><span class="bu_inactive" >[% totavail_credit %]</span></th>
136
            <th class="data"><span class="bu_active">[% totavail %]</span><span class="bu_inactive" >[% totavail_active %]</span></th>
138
            <th class="data"><span class="bu_active">[% totavail %]</span><span class="bu_inactive" >[% totavail_active %]</span></th>
137
        </tr>
139
        </tr>
138
        </tfoot>
140
        </tfoot>
Lines 159-164 $(document).ready(function() { Link Here
159
                <td class="data">[% loop_budge.budget_amount %]</td>
161
                <td class="data">[% loop_budge.budget_amount %]</td>
160
                <td class="data"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered %]</a></td>
162
                <td class="data"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered %]</a></td>
161
                <td class="data"><a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent %]</a></td>
163
                <td class="data"><a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent %]</a></td>
164
                <td class="data">[% loop_budge.budget_credit %]</td>
162
                <td class="data">[% loop_budge.budget_avail %]</td>
165
                <td class="data">[% loop_budge.budget_avail %]</td>
163
            </tr>
166
            </tr>
164
        [% ELSE %]
167
        [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/creditnote.tt (+132 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'calendar.inc' %]
7
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
9
[% INCLUDE 'datatables-strings.inc' %]
10
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
11
<script type="text/javascript">
12
//<![CDATA[
13
    function Check(f) {
14
        if ((f.amountcredit.value.length == 0) && (f.budget_id.value.length == 0)) {
15
            alert("Budget and amount is missing");
16
            return false;
17
        } else if (f.amountcredit.value.length == 0) {
18
            alert("Amount is missing");
19
            return false;
20
        } else if (f.budget_id.value.length == 0) {
21
            alert("Budget is missing");
22
            return false;
23
        } else{
24
            document.Aform.submit();
25
        }
26
    }
27
    $(document).ready(function() {
28
        $("#table_credit").dataTable($.extend(true, {}, dataTablesDefaults, {
29
            "aoColumnDefs": [
30
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
31
            ],
32
            "aaSorting": [[ 1, "asc" ]],
33
            "iDisplayLength": 10,
34
            "aLengthMenu": [[2, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
35
        }));
36
    });
37
//]]>
38
</script>
39
</head>
40
41
<body>
42
[% INCLUDE 'header.inc' %]
43
[% INCLUDE 'acquisitions-search.inc' %]
44
45
<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; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/creditnote.pl?booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Credit note</a></div>
46
47
48
<div id="doc3" class="yui-t2">
49
50
<div id="bd">
51
  <div id="yui-main">
52
    <div class="yui-b">
53
      [% IF ( modified ) %]
54
        <div class="dialog message">
55
          <p>Invoice has been modified</p>
56
        </div>
57
      [% END %]
58
      <h1>Invoice: [% invoicenumber %]</h1>
59
      <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% suppliername %]</a></p>
60
        <form action="/cgi-bin/koha/acqui/creditnote.pl" name="Aform" method="post">
61
        <input type="hidden" name="op" value="add" />
62
        <input type="hidden" id="booksellerid" name="booksellerid" value="[% booksellerid %]"/>            
63
        <input type="hidden" id="invoiceid" name="invoiceid" value="[% invoiceid %]"/>               
64
        <fieldset class="rows">
65
            <ol>
66
            <li><label for="invoicenumber">Invoicenumber:</label>[% invoicenumber %]</li>            
67
            <li><label for="suppliername">Vendorname:</label>[% suppliername %]</li>            
68
            <li><label for="vendorrefid">Vendor ref. id:</label>
69
            <input type="text" size="30" id="vendorrefid" name="vendorrefid" value="[% vendorrefid %]" /></li>
70
            <li><label class="required" for="budget_id">Fund: </label>
71
                <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
72
                        <option value="">Select a budget</option>
73
                [% FOREACH budget_loo IN budget_loop %]
74
                    [% IF ( budget_loo.b_sel ) %]
75
                        <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
76
                    [% ELSE %]
77
                        [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
78
                        [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive">[% budget_loo.b_txt %]</option>
79
                        [% END %]
80
                    [% END %]
81
                [% END %]
82
                </select>
83
            </li>    
84
            <li><label for="amountcredit">Amount credit:</label>
85
            <input type="text" size="10" id="amountcredit" name="amountcredit" value="[% amountcredit %]" /></li>
86
            <li><label for="creditdate">Date:</label>
87
                    <input type="text" size="10" id="creditdate" name="creditdate" value="[% creditdate | $KohaDates %]" readonly="readonly" class="datepicker" /></li>
88
            <li><label for="notes">Notes: </label><textarea id = "notes" name="notes" width="40" rows="8" >[% notes %]</textarea></li>
89
                      <input type="hidden" name="op" value="mod" />
90
          <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
91
        </fieldset>
92
        <fieldset class="action">
93
            <input type="submit" value="Save" onclick="Check(this.form); return false;"/>
94
        </fieldset>
95
      </form>
96
       <h2>Credit details</h2>
97
      [% IF creditloop.size %]
98
          <table id="table_credit">
99
            <thead>
100
              <tr>
101
                <th>Vendor reference id</th>
102
                <th>Amount credit</th>
103
                <th>Credit date</th>
104
                <th>Budget</th>
105
                <th>Notes</th>
106
                <th></th>
107
                <th></th>
108
              </tr>
109
            </thead>            
110
              [% FOREACH credit IN creditloop %]              
111
                <tr>
112
                  <td>[% credit.vendorrefid %]</td>
113
                  <td>[% credit.amountcredit %]</td>
114
                  <td>[% credit.creditdate %]</td>
115
                  <td>[% credit.budget %]</td>
116
                  <td>[% credit.notes %]</td>
117
                  <td><a href="/cgi-bin/koha/acqui/editcreditnote.pl?creditnote_id=[% credit.creditnote_id %]&amp;booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Edit</a></td>
118
                  <td><a href="/cgi-bin/koha/acqui/creditnote.pl?op=delete&amp;creditnote_id=[% credit.creditnote_id %]&amp;booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Delete</a></td>
119
                </tr>
120
               </thead>
121
              [% END %]                  
122
          </table>
123
        [% ELSE %]
124
            <div class="dialog message"><p>No credit details yet</p></div>
125
        [% END %]            
126
    </div>
127
  </div>
128
  <div class="yui-b">
129
    [% INCLUDE 'acquisitions-menu.inc' %]
130
  </div>
131
</div>
132
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/editcreditnote.tt (+63 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Acquisitions &rsaquo; Creditnote</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'calendar.inc' %]
6
</head>
7
8
<body>
9
[% INCLUDE 'header.inc' %]
10
[% INCLUDE 'acquisitions-search.inc' %]
11
12
<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; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/editcreditnote.pl?creditnote_id=[% creditnote_id %]&amp;booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Modify credit note</a></div>
13
14
<div id="doc3" class="yui-t2">
15
16
<div id="bd">
17
  <div id="yui-main">
18
    <div class="yui-b">
19
      <h1>Invoice: [% invoicenumber %]</h1>
20
      <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% suppliername %]</a></p>
21
        <form action="/cgi-bin/koha/acqui/editcreditnote.pl" name="Aform" method="post">
22
        <input type="hidden" name="op" value="edit" />
23
        <input type="hidden" id="booksellerid" name="booksellerid" value="[% booksellerid %]"/>            
24
        <input type="hidden" id="invoiceid" name="invoiceid" value="[% invoiceid %]"/>               
25
        <input type="hidden" id="creditnote_id" name="creditnote_id" value="[% creditnote_id %]"/>               
26
        <fieldset class="rows">
27
            <ol>
28
            <li><label for="invoicenumber">Invoicenumber:</label>[% invoicenumber %]</li>            
29
            <li><label for="suppliername">Vendorname:</label>[% suppliername %]</li>            
30
            <li><label for="vendorrefid">Vendor ref. id:</label>
31
            <input type="text" size="30" id="vendorrefid" name="vendorrefid" value="[% vendorrefid %]" /></li>
32
            <li><label class="required" for="budget_id">Fund: </label>
33
                <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
34
                        <option value="">Select a budget</option>
35
                [% FOREACH budget_loo IN budget_loop %]
36
                    [% IF ( budget_loo.b_sel ) %]
37
                        <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
38
                    [% ELSE %]
39
                        [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
40
                        [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive">[% budget_loo.b_txt %]</option>
41
                        [% END %]
42
                    [% END %]
43
                [% END %]
44
                </select>
45
            </li>    
46
            <li><label for="amountcredit">Amount credit:</label>
47
            <input type="text" size="10" id="amountcredit" name="amountcredit" value="[% amountcredit %]" /></li>
48
            <li><label for="creditdate">Date:</label>
49
                    <input type="text" size="10" id="creditdate" name="creditdate" value="[% creditdate | $KohaDates %]" readonly="readonly" class="datepicker" /></li>
50
            <li><label for="notes">Notes: </label><textarea id = "notes" name="notes" width="40" rows="8" >[% notes %]</textarea></li>
51
                     <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
52
        </fieldset>       
53
        <fieldset class="action">
54
            <input type="submit" value="Save"/>
55
        </fieldset>
56
      </form>       
57
    </div>
58
  </div>
59
  <div class="yui-b">
60
    [% INCLUDE 'acquisitions-menu.inc' %]
61
  </div>
62
</div>
63
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+2 lines)
Lines 50-55 $(document).ready(function() { Link Here
50
                <th>Billing date</th>
50
                <th>Billing date</th>
51
                <th>Received biblios</th>
51
                <th>Received biblios</th>
52
                <th>Received items</th>
52
                <th>Received items</th>
53
                <th>Creditnote</th>
53
                <th>Status</th>
54
                <th>Status</th>
54
                <th>&nbsp;</th>
55
                <th>&nbsp;</th>
55
              </tr>
56
              </tr>
Lines 66-71 $(document).ready(function() { Link Here
66
                  </td>
67
                  </td>
67
                  <td>[% invoice.receivedbiblios %]</td>
68
                  <td>[% invoice.receivedbiblios %]</td>
68
                  <td>[% invoice.receiveditems %]</td>
69
                  <td>[% invoice.receiveditems %]</td>
70
                  <td><a href="/cgi-bin/koha/acqui/creditnote.pl?booksellerid=[% invoice.booksellerid %]&amp;invoiceid=[% invoice.invoiceid %]">Credit note</td>
69
                  <td>
71
                  <td>
70
                    [% IF invoice.closedate %]
72
                    [% IF invoice.closedate %]
71
                      Closed on [% invoice.closedate | $KohaDates %]
73
                      Closed on [% invoice.closedate | $KohaDates %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-2 / +4 lines)
Lines 239-246 Link Here
239
            <th>Fund name</th>
239
            <th>Fund name</th>
240
            <th>Total<br />allocated</th>
240
            <th>Total<br />allocated</th>
241
            <th>Base-level<br />allocated</th>
241
            <th>Base-level<br />allocated</th>
242
            <th>Base-level<br />spent</th>
242
            <th>Base-level<br />spent</th>            
243
            <th>Total sublevels<br />spent</th>
243
            <th>Total sublevels<br />spent</th>
244
            <th>Base-level<br />credited</th>
244
            <th>Base-level<br />remaining</th>
245
            <th>Base-level<br />remaining</th>
245
            <th class="tooltipcontent">&nbsp;</th>
246
            <th class="tooltipcontent">&nbsp;</th>
246
            <th>Actions</th>
247
            <th>Actions</th>
Lines 253-258 Link Here
253
    <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
254
    <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
254
    <th class="data">[% base_spent_total %]</th>
255
    <th class="data">[% base_spent_total %]</th>
255
    <th class="data">[% base_spent_total %]</th>
256
    <th class="data">[% base_spent_total %]</th>
257
    <th class="data">[% base_credit_total %]</th>
256
    <th class="data">[% base_remaining_total %]</th>
258
    <th class="data">[% base_remaining_total %]</th>
257
    <th class="tooltipcontent"></th>
259
    <th class="tooltipcontent"></th>
258
    <th></th>
260
    <th></th>
Lines 272-277 Link Here
272
    <td class="data">[% budge.budget_amount %] </td>
274
    <td class="data">[% budge.budget_amount %] </td>
273
    <td class="data">[% budge.budget_spent %] </td>
275
    <td class="data">[% budge.budget_spent %] </td>
274
    <td class="data">[% budge.total_levels_spent %]</td>
276
    <td class="data">[% budge.total_levels_spent %]</td>
277
    <td class="data">[% budge.budget_credit %]</td>
275
    [% IF ( budge.remaining_pos ) %]
278
    [% IF ( budge.remaining_pos ) %]
276
        <td class="data" style="color: green;">
279
        <td class="data" style="color: green;">
277
    [% ELSIF ( budge.remaining_neg ) %] 
280
    [% ELSIF ( budge.remaining_neg ) %] 
278
- 

Return to bug 10412