Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
2 |
|
3 |
#script to Payment Capture against vendor |
4 |
#written by amit.gupta@osslabs.biz 09/06/2012 |
5 |
|
6 |
# Copyright 2012 Nucsoft Osslabs |
7 |
# |
8 |
# This file is part of Koha. |
9 |
# |
10 |
# Koha is free software; you can redistribute it and/or modify it under the |
11 |
# terms of the GNU General Public License as published by the Free Software |
12 |
# Foundation; either version 2 of the License, or (at your option) any later |
13 |
# version. |
14 |
# |
15 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
16 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
17 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
18 |
# |
19 |
# You should have received a copy of the GNU General Public License along |
20 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
21 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
22 |
|
23 |
=head1 NAME |
24 |
|
25 |
payments.pl |
26 |
|
27 |
This script is used to capture payments against vendor. |
28 |
|
29 |
=cut |
30 |
|
31 |
use strict; |
32 |
use warnings; |
33 |
use C4::Auth; |
34 |
use C4::Acquisition; |
35 |
use C4::Bookseller qw/ GetBookSellerFromId /; |
36 |
use CGI; |
37 |
use C4::Output; |
38 |
use C4::Dates qw/format_date format_date_in_iso/; |
39 |
|
40 |
|
41 |
my $input=new CGI; |
42 |
my $booksellerid=$input->param('booksellerid'); |
43 |
my $bookseller=GetBookSellerFromId($booksellerid); |
44 |
my $chequeno=$input->param('chequeno') || ''; |
45 |
my $notes=$input->param('notes') || ''; |
46 |
my $op = $input->param('op'); |
47 |
|
48 |
my $datereceived = ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) : C4::Dates->new($input->param('datereceived'), 'iso') ; |
49 |
$datereceived = C4::Dates->new() unless $datereceived; |
50 |
|
51 |
my ($template, $loggedinuser, $cookie) |
52 |
= get_template_and_user({template_name => "acqui/payments.tmpl", |
53 |
query => $input, |
54 |
type => "intranet", |
55 |
authnotrequired => 0, |
56 |
flagsrequired => {acquisition => 'order_receive'}, |
57 |
debug => 1, |
58 |
}); |
59 |
|
60 |
my @parcelitems = GetPayments($booksellerid); |
61 |
my $countlines = scalar @parcelitems; |
62 |
my @loop_received = (); |
63 |
|
64 |
for (my $i = 0 ; $i < $countlines ; $i++) { |
65 |
my %line; |
66 |
%line = %{ $parcelitems[$i] }; |
67 |
$line{booksellerid} = $booksellerid; |
68 |
$line{chequedate} = format_date($line{chequedate}); |
69 |
push @loop_received, \%line; |
70 |
|
71 |
} |
72 |
|
73 |
my $pendingpayments = GetPendingpayments($booksellerid); |
74 |
my $countpendings = scalar @$pendingpayments; |
75 |
|
76 |
|
77 |
my @loop_orders = (); |
78 |
for (my $i = 0 ; $i < $countpendings ; $i++) { |
79 |
my %line; |
80 |
%line = %{$pendingpayments->[$i]}; |
81 |
$line{datereceived} = format_date($line{datereceived}); |
82 |
push @loop_orders, \%line; |
83 |
} |
84 |
|
85 |
|
86 |
if ($op eq "saveall"){ |
87 |
my @booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber'); |
88 |
my $chequedate = $input->param('date'); |
89 |
foreach my $invoiceno(@booksellerinvoicenumber){ |
90 |
next unless $invoiceno; |
91 |
AddPayments( $invoiceno, $chequeno,$chequedate,$notes); |
92 |
} |
93 |
my $date = format_date($chequedate); |
94 |
print $input->redirect("payments.pl?booksellerid=$booksellerid&op=new¬es=$notes&chequeno=$chequeno&datereceived=$date"); |
95 |
} |
96 |
|
97 |
|
98 |
$template->param( |
99 |
chequeno => $chequeno, |
100 |
notes => $notes, |
101 |
datereceived => $datereceived->output('iso'), |
102 |
formatteddatereceived => $datereceived->output(), |
103 |
booksellerid => $booksellerid, |
104 |
name => $bookseller->{'name'}, |
105 |
loop_received => \@loop_received, |
106 |
loop_orders => \@loop_orders, |
107 |
|
108 |
); |
109 |
output_html_with_http_headers $input, $cookie, $template->output; |
110 |
|