From 1fafaafc9a165a662cc8c2431956c92ca3f7d13d Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Delaune?= Date: Wed, 6 Apr 2011 15:59:53 +0200 Subject: [PATCH] Bug 5728: adding note and manager_id fields to accountlines Biblibre bug #1874 Signed-off-by: fdurand Signed-off-by: Chris Cormack --- C4/Accounts.pm | 25 ++++++--- C4/Context.pm | 2 +- installer/data/mysql/kohastructure.sql | 2 + installer/data/mysql/updatedatabase.pl | 8 +++ .../prog/en/modules/members/boraccount.tmpl | 2 + .../prog/en/modules/members/mancredit.tmpl | 1 + .../prog/en/modules/members/maninvoice.tmpl | 1 + .../prog/en/modules/members/pay.tmpl | 12 +++- members/mancredit.pl | 19 ++++--- members/maninvoice.pl | 55 ++++++++++--------- members/pay.pl | 8 +++ 11 files changed, 89 insertions(+), 46 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index c54f7f949f..9540b44a63 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -35,7 +35,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw( &recordpayment &makepayment &manualinvoice - &getnextacctno &reconcileaccount &getcharges &getcredits + &getnextacctno &reconcileaccount &getcharges &ModNote &getcredits &getrefunds &chargelostitem &ReversePayment ); # removed &fixaccounts @@ -327,7 +327,7 @@ sub chargelostitem{ =head2 manualinvoice &manualinvoice($borrowernumber, $itemnumber, $description, $type, - $amount, $user); + $amount, $note); C<$borrowernumber> is the patron's borrower number. C<$description> is a description of the transaction. @@ -351,7 +351,8 @@ should be the empty string. # sub manualinvoice { - my ( $borrowernumber, $itemnum, $desc, $type, $amount, $user ) = @_; + my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; + my $manager_id = C4::Context->userenv->{'number'}; my $dbh = C4::Context->dbh; my $notifyid = 0; my $insert; @@ -403,16 +404,16 @@ sub manualinvoice { $desc .= " " . $itemnum; my $sth = $dbh->prepare( "INSERT INTO accountlines - (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id) - VALUES (?, ?, now(), ?,?, ?,?,?,?)"); - $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid) || return $sth->errstr; + (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id) + VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)"); + $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr; } else { my $sth=$dbh->prepare("INSERT INTO accountlines - (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id) - VALUES (?, ?, now(), ?, ?, ?, ?,?)" + (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id) + VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)" ); $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, - $amountleft, $notifyid ); + $amountleft, $notifyid, $note, $manager_id ); } return 0; } @@ -606,6 +607,12 @@ sub getcharges { return (@results); } +sub ModNote { + my ( $borrowernumber, $accountno, $note ) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?'); + $sth->execute( $note, $borrowernumber, $accountno ); +} sub getcredits { my ( $date, $date2 ) = @_; diff --git a/C4/Context.pm b/C4/Context.pm index 484d4e10a8..85d1c1870a 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -914,7 +914,7 @@ sub userenv { my $var = $context->{"activeuser"}; return $context->{"userenv"}->{$var} if (defined $var and defined $context->{"userenv"}->{$var}); # insecure=1 management - if ($context->{"dbh"} && $context->preference('insecure')) { + if ($context->{"dbh"} && $context->preference('insecure') eq 'yes') { my %insecure; $insecure{flags} = '16382'; $insecure{branchname} ='Insecure'; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 1122826519..e3c6f42a76 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2299,6 +2299,8 @@ CREATE TABLE `accountlines` ( `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `notify_id` int(11) NOT NULL default 0, `notify_level` int(2) NOT NULL default 0, + `note` text NULL default NULL, + `manager_id` int(11) NULL, KEY `acctsborridx` (`borrowernumber`), KEY `timeidx` (`timestamp`), KEY `itemnumber` (`itemnumber`), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 61bae05666..7729a7ec4d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4277,6 +4277,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = '3.03.00.049'; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL"); + $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL "); + print "Upgrade to $DBversion done (adding note and manager_id fields in accountlines table)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl index ef59ad2af9..4f66ec56d5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl @@ -30,6 +30,7 @@ Date Description of charges + Note Amount Outstanding @@ -44,6 +45,7 @@  &itemnumber=">View item  + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl index 16f7a7bbac..d23cf18366 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl @@ -43,6 +43,7 @@ $(document).ready(function(){
  • +
  • Example: 5.00
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl index a7c49e8482..0062bfe3a5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl @@ -67,6 +67,7 @@ type_fees[''] = "">Cancel diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl index 1177ba2c22..99fdc2abbb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl @@ -32,6 +32,7 @@ Fines & Charges Description + Note Account Type Notify id Level @@ -61,6 +62,13 @@ " value="" /> + + + " value=" + + + " /> + @@ -71,13 +79,13 @@ - Sub Total + Sub Total - Total Due + Total Due diff --git a/members/mancredit.pl b/members/mancredit.pl index 7db4bbdcea..7d57fa5a24 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -43,14 +43,17 @@ my $data=GetMember('borrowernumber' => $borrowernumber); my $add=$input->param('add'); if ($add){ - my $barcode=$input->param('barcode'); - my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode; - my $desc=$input->param('desc'); - my $amount=$input->param('amount') || 0; - $amount = -$amount; - my $type=$input->param('type'); - manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount); - print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); + if(checkauth($input)) { + my $barcode = $input->param('barcode'); + my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode; + my $desc = $input->param('desc'); + my $note = $input->param('note'); + my $amount = $input->param('amount') || 0; + $amount = -$amount; + my $type = $input->param('type'); + manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note ); + print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); + } } else { my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "members/mancredit.tmpl", diff --git a/members/maninvoice.pl b/members/maninvoice.pl index 521989bd6d..f804e52666 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -42,32 +42,35 @@ my $borrowernumber=$input->param('borrowernumber'); my $data=GetMember('borrowernumber'=>$borrowernumber); my $add=$input->param('add'); if ($add){ -# print $input->header; - my $barcode=$input->param('barcode'); - my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode; - my $desc=$input->param('desc'); - my $amount=$input->param('amount'); - my $type=$input->param('type'); - my $error=manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount); - if ($error){ - my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "members/maninvoice.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {borrowers => 1}, - debug => 1, - }); - if ($error =~ /FOREIGN KEY/ && $error =~ /itemnumber/){ - $template->param('ITEMNUMBER' => 1); - } - $template->param('ERROR' => $error); - output_html_with_http_headers $input, $cookie, $template->output; - } - else { - print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); - exit; - } + if(checkauth($input)) { + # print $input->header; + my $barcode=$input->param('barcode'); + my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode; + my $desc=$input->param('desc'); + my $amount=$input->param('amount'); + my $type=$input->param('type'); + my $note = $input->param('note'); + my $error = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note ); + if ($error) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "members/maninvoice.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1 }, + debug => 1, + } + ); + if ( $error =~ /FOREIGN KEY/ && $error =~ /itemnumber/ ) { + $template->param( 'ITEMNUMBER' => 1 ); + } + $template->param( 'ERROR' => $error ); + output_html_with_http_headers $input, $cookie, $template->output; + } else { + print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); + exit; + } + } } else { my ($template, $loggedinuser, $cookie) diff --git a/members/pay.pl b/members/pay.pl index 06e103d2c3..4ecdcc925d 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -84,7 +84,14 @@ for ( my $i = 0 ; $i < @names ; $i++ ) { makepayment( $borrowernumber, $accountno, $amount, $user, $branch ); $check = 2; } + if ( $temp eq 'no'||$temp eq 'yes'||$temp eq 'wo') { + my $borrowernumber = $input->param( $names[ $i + 5 ] ); + my $accountno = $input->param( $names[ $i + 6 ] ); + my $note = $input->param( $names[ $i + 10 ] ); + ModNote( $borrowernumber, $accountno, $note ); + } } + my $total = $input->param('total') || ''; if ( $check == 0 ) { if ( $total ne '' ) { @@ -115,6 +122,7 @@ if ( $check == 0 ) { $line{borrowernumber} = $borrowernumber; $line{accountno} = $accts->[$i]{'accountno'}; $line{description} = $accts->[$i]{'description'}; + $line{note} = $accts->[$i]{'note'}; $line{title} = $accts->[$i]{'title'}; $line{notify_id} = $accts->[$i]{'notify_id'}; $line{notify_level} = $accts->[$i]{'notify_level'}; -- 2.39.5