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

(-)a/C4/Accounts.pm (-9 / +16 lines)
Lines 35-41 BEGIN { Link Here
35
	@ISA    = qw(Exporter);
35
	@ISA    = qw(Exporter);
36
	@EXPORT = qw(
36
	@EXPORT = qw(
37
		&recordpayment &makepayment &manualinvoice
37
		&recordpayment &makepayment &manualinvoice
38
		&getnextacctno &reconcileaccount &getcharges &getcredits
38
		&getnextacctno &reconcileaccount &getcharges &ModNote &getcredits
39
		&getrefunds &chargelostitem
39
		&getrefunds &chargelostitem
40
		&ReversePayment
40
		&ReversePayment
41
	); # removed &fixaccounts
41
	); # removed &fixaccounts
Lines 327-333 sub chargelostitem{ Link Here
327
=head2 manualinvoice
327
=head2 manualinvoice
328
328
329
  &manualinvoice($borrowernumber, $itemnumber, $description, $type,
329
  &manualinvoice($borrowernumber, $itemnumber, $description, $type,
330
                 $amount, $user);
330
                 $amount, $note);
331
331
332
C<$borrowernumber> is the patron's borrower number.
332
C<$borrowernumber> is the patron's borrower number.
333
C<$description> is a description of the transaction.
333
C<$description> is a description of the transaction.
Lines 351-357 should be the empty string. Link Here
351
#
351
#
352
352
353
sub manualinvoice {
353
sub manualinvoice {
354
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $user ) = @_;
354
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
355
    my $manager_id = C4::Context->userenv->{'number'};
355
    my $dbh      = C4::Context->dbh;
356
    my $dbh      = C4::Context->dbh;
356
    my $notifyid = 0;
357
    my $notifyid = 0;
357
    my $insert;
358
    my $insert;
Lines 403-418 sub manualinvoice { Link Here
403
        $desc .= " " . $itemnum;
404
        $desc .= " " . $itemnum;
404
        my $sth = $dbh->prepare(
405
        my $sth = $dbh->prepare(
405
            "INSERT INTO  accountlines
406
            "INSERT INTO  accountlines
406
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id)
407
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)
407
        VALUES (?, ?, now(), ?,?, ?,?,?,?)");
408
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)");
408
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid) || return $sth->errstr;
409
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;
409
  } else {
410
  } else {
410
    my $sth=$dbh->prepare("INSERT INTO  accountlines
411
    my $sth=$dbh->prepare("INSERT INTO  accountlines
411
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id)
412
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)
412
            VALUES (?, ?, now(), ?, ?, ?, ?,?)"
413
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"
413
        );
414
        );
414
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
415
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
415
            $amountleft, $notifyid );
416
            $amountleft, $notifyid, $note, $manager_id );
416
    }
417
    }
417
    return 0;
418
    return 0;
418
}
419
}
Lines 606-611 sub getcharges { Link Here
606
    return (@results);
607
    return (@results);
607
}
608
}
608
609
610
sub ModNote {
611
    my ( $borrowernumber, $accountno, $note ) = @_;
612
    my $dbh = C4::Context->dbh;
613
    my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?');
614
    $sth->execute( $note, $borrowernumber, $accountno );
615
}
609
616
610
sub getcredits {
617
sub getcredits {
611
	my ( $date, $date2 ) = @_;
618
	my ( $date, $date2 ) = @_;
(-)a/C4/Context.pm (-1 / +1 lines)
Lines 914-920 sub userenv { Link Here
914
    my $var = $context->{"activeuser"};
914
    my $var = $context->{"activeuser"};
915
    return $context->{"userenv"}->{$var} if (defined $var and defined $context->{"userenv"}->{$var});
915
    return $context->{"userenv"}->{$var} if (defined $var and defined $context->{"userenv"}->{$var});
916
    # insecure=1 management
916
    # insecure=1 management
917
    if ($context->{"dbh"} && $context->preference('insecure')) {
917
    if ($context->{"dbh"} && $context->preference('insecure') eq 'yes') {
918
        my %insecure;
918
        my %insecure;
919
        $insecure{flags} = '16382';
919
        $insecure{flags} = '16382';
920
        $insecure{branchname} ='Insecure';
920
        $insecure{branchname} ='Insecure';
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 2289-2294 CREATE TABLE `accountlines` ( Link Here
2289
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2289
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2290
  `notify_id` int(11) NOT NULL default 0,
2290
  `notify_id` int(11) NOT NULL default 0,
2291
  `notify_level` int(2) NOT NULL default 0,
2291
  `notify_level` int(2) NOT NULL default 0,
2292
  `note` text NULL default NULL,
2293
  `manager_id` int(11) NULL,
2292
  KEY `acctsborridx` (`borrowernumber`),
2294
  KEY `acctsborridx` (`borrowernumber`),
2293
  KEY `timeidx` (`timestamp`),
2295
  KEY `timeidx` (`timestamp`),
2294
  KEY `itemnumber` (`itemnumber`),
2296
  KEY `itemnumber` (`itemnumber`),
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 4090-4095 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4090
    SetVersion ($DBversion);
4090
    SetVersion ($DBversion);
4091
}
4091
}
4092
4092
4093
$DBversion = 'XXX';
4094
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4095
    $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
4096
    $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
4097
    print "Upgrade to $DBversion done (adding note and manager_id fields in accountlines table)\n";
4098
    SetVersion($DBversion);
4099
}
4100
4093
=head1 FUNCTIONS
4101
=head1 FUNCTIONS
4094
4102
4095
=head2 DropAllForeignKeys($table)
4103
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl (+2 lines)
Lines 30-35 Link Here
30
  <tr>
30
  <tr>
31
  	<th>Date</th>
31
  	<th>Date</th>
32
    <th>Description of charges</th>
32
    <th>Description of charges</th>
33
    <th>Note</th>
33
    <th>Amount</th>
34
    <th>Amount</th>
34
    <th>Outstanding</th>
35
    <th>Outstanding</th>
35
    <!-- TMPL_IF NAME="reverse_col" -->
36
    <!-- TMPL_IF NAME="reverse_col" -->
Lines 44-49 Link Here
44
   <!-- TMPL_IF NAME="__odd__" --><tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
45
   <!-- TMPL_IF NAME="__odd__" --><tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
45
      <td><!-- TMPL_VAR NAME="date" --></td>
46
      <td><!-- TMPL_VAR NAME="date" --></td>
46
      <td><!-- TMPL_VAR NAME="description" -->&nbsp;<!-- TMPL_IF NAME="itemnumber" --><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">View item</a>&nbsp;<!-- /TMPL_IF --><!-- TMPL_IF NAME="printtitle" --> <!-- TMPL_VAR NAME="title" escape="html" --><!-- /TMPL_IF --></td>
47
      <td><!-- TMPL_VAR NAME="description" -->&nbsp;<!-- TMPL_IF NAME="itemnumber" --><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">View item</a>&nbsp;<!-- /TMPL_IF --><!-- TMPL_IF NAME="printtitle" --> <!-- TMPL_VAR NAME="title" escape="html" --><!-- /TMPL_IF --></td>
48
      <td><!-- TMPL_VAR NAME="note" --></td>
47
      <!-- TMPL_IF NAME="amountcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amount" --></td>
49
      <!-- TMPL_IF NAME="amountcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amount" --></td>
48
      <!-- TMPL_IF NAME="amountoutstandingcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amountoutstanding" --></td>
50
      <!-- TMPL_IF NAME="amountoutstandingcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amountoutstanding" --></td>
49
    <!-- TMPL_IF NAME="reverse_col" -->
51
    <!-- TMPL_IF NAME="reverse_col" -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl (+1 lines)
Lines 43-48 $(document).ready(function(){ Link Here
43
</select></li>
43
</select></li>
44
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
44
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
45
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
45
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
46
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
46
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
47
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
47
</ol></fieldset>
48
</ol></fieldset>
48
49
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl (+1 lines)
Lines 67-72 type_fees['<!-- TMPL_VAR NAME="authorised_value" -->'] = "<!-- TMPL_VAR NAME="li Link Here
67
      </li>
67
      </li>
68
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
68
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
69
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
69
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
70
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
70
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
71
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
71
	</ol></fieldset>
72
	</ol></fieldset>
72
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
73
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl (-2 / +10 lines)
Lines 32-37 Link Here
32
<tr>
32
<tr>
33
	<th>Fines &amp; Charges</th>
33
	<th>Fines &amp; Charges</th>
34
	<th>Description</th>
34
	<th>Description</th>
35
    <th>Note</th>
35
	<th>Account Type</th>
36
	<th>Account Type</th>
36
	<th>Notify id</th>
37
	<th>Notify id</th>
37
	<th>Level</th>
38
	<th>Level</th>
Lines 61-66 Link Here
61
	<input type="hidden" name="totals<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="totals" -->" />
62
	<input type="hidden" name="totals<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="totals" -->" />
62
	</td>
63
	</td>
63
	<td><!-- TMPL_VAR name="description" --> <!-- TMPL_VAR name="title" escape="html" --></td>
64
	<td><!-- TMPL_VAR name="description" --> <!-- TMPL_VAR name="title" escape="html" --></td>
65
    <td>
66
        <!-- TMPL_IF NAME="net_balance" -->
67
        <input type="text" name="note<!-- TMPL_VAR name="i" -->" value="
68
        <!-- /TMPL_IF -->
69
        <!-- TMPL_VAR name="note" -->
70
        <!-- TMPL_IF NAME="net_balance" -->" /><!-- /TMPL_IF -->
71
    </td>
64
	<td><!-- TMPL_VAR name="accounttype" --></td>
72
	<td><!-- TMPL_VAR name="accounttype" --></td>
65
	<td><!-- TMPL_VAR name="notify_id" --></td>
73
	<td><!-- TMPL_VAR name="notify_id" --></td>
66
	<td><!-- TMPL_VAR name="notify_level" --></td>
74
	<td><!-- TMPL_VAR name="notify_level" --></td>
Lines 71-83 Link Here
71
<!-- TMPL_IF  NAME="total"-->
79
<!-- TMPL_IF  NAME="total"-->
72
<tr>
80
<tr>
73
81
74
	<td colspan="6">Sub Total</td>
82
	<td colspan="7">Sub Total</td>
75
	<td><!-- TMPL_VAR name="total" --></td>
83
	<td><!-- TMPL_VAR name="total" --></td>
76
</tr>
84
</tr>
77
<!--/TMPL_IF-->
85
<!--/TMPL_IF-->
78
<!-- /TMPL_LOOP  -->
86
<!-- /TMPL_LOOP  -->
79
<tr>
87
<tr>
80
	<td colspan="6">Total Due</td>
88
	<td colspan="7">Total Due</td>
81
	<td><!-- TMPL_VAR name="total" --></td>
89
	<td><!-- TMPL_VAR name="total" --></td>
82
</tr>
90
</tr>
83
</table>
91
</table>
(-)a/members/mancredit.pl (-8 / +11 lines)
Lines 43-56 my $data=GetMember('borrowernumber' => $borrowernumber); Link Here
43
my $add=$input->param('add');
43
my $add=$input->param('add');
44
44
45
if ($add){
45
if ($add){
46
    my $barcode=$input->param('barcode');
46
    if(checkauth($input)) {
47
    my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
47
        my $barcode = $input->param('barcode');
48
    my $desc=$input->param('desc');
48
        my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
49
    my $amount=$input->param('amount') || 0;
49
        my $desc    = $input->param('desc');
50
    $amount = -$amount;
50
        my $note    = $input->param('note');
51
    my $type=$input->param('type');
51
        my $amount  = $input->param('amount') || 0;
52
    manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
52
        $amount = -$amount;
53
    print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
53
        my $type = $input->param('type');
54
        manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
55
        print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
56
    }
54
} else {
57
} else {
55
	my ($template, $loggedinuser, $cookie)
58
	my ($template, $loggedinuser, $cookie)
56
	  = get_template_and_user({template_name => "members/mancredit.tmpl",
59
	  = get_template_and_user({template_name => "members/mancredit.tmpl",
(-)a/members/maninvoice.pl (-26 / +29 lines)
Lines 42-73 my $borrowernumber=$input->param('borrowernumber'); Link Here
42
my $data=GetMember('borrowernumber'=>$borrowernumber);
42
my $data=GetMember('borrowernumber'=>$borrowernumber);
43
my $add=$input->param('add');
43
my $add=$input->param('add');
44
if ($add){
44
if ($add){
45
#  print $input->header;
45
    if(checkauth($input)) {
46
    my $barcode=$input->param('barcode');
46
        #  print $input->header;
47
    my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
47
        my $barcode=$input->param('barcode');
48
    my $desc=$input->param('desc');
48
        my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
49
    my $amount=$input->param('amount');
49
        my $desc=$input->param('desc');
50
    my $type=$input->param('type');
50
        my $amount=$input->param('amount');
51
    my $error=manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
51
        my $type=$input->param('type');
52
	if ($error){
52
        my $note    = $input->param('note');
53
		my ($template, $loggedinuser, $cookie)
53
        my $error   = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
54
		  = get_template_and_user({template_name => "members/maninvoice.tmpl",
54
        if ($error) {
55
					query => $input,
55
            my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
56
					type => "intranet",
56
                {   template_name   => "members/maninvoice.tmpl",
57
					authnotrequired => 0,
57
                    query           => $input,
58
					flagsrequired => {borrowers => 1},
58
                    type            => "intranet",
59
					debug => 1,
59
                    authnotrequired => 0,
60
					});
60
                    flagsrequired   => { borrowers => 1 },
61
		if ($error =~ /FOREIGN KEY/ && $error =~ /itemnumber/){
61
                    debug           => 1,
62
			$template->param('ITEMNUMBER' => 1);
62
                }
63
		}
63
            );
64
		$template->param('ERROR' => $error);
64
            if ( $error =~ /FOREIGN KEY/ && $error =~ /itemnumber/ ) {
65
        output_html_with_http_headers $input, $cookie, $template->output;
65
                $template->param( 'ITEMNUMBER' => 1 );
66
	}
66
            }
67
	else {
67
            $template->param( 'ERROR' => $error );
68
		print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
68
            output_html_with_http_headers $input, $cookie, $template->output;
69
		exit;
69
        } else {
70
	}
70
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
71
            exit;
72
        }
73
    }
71
} else {
74
} else {
72
75
73
	my ($template, $loggedinuser, $cookie)
76
	my ($template, $loggedinuser, $cookie)
(-)a/members/pay.pl (-1 / +8 lines)
Lines 84-90 for ( my $i = 0 ; $i < @names ; $i++ ) { Link Here
84
        makepayment( $borrowernumber, $accountno, $amount, $user, $branch );
84
        makepayment( $borrowernumber, $accountno, $amount, $user, $branch );
85
        $check = 2;
85
        $check = 2;
86
    }
86
    }
87
    if ( $temp eq 'no'||$temp eq 'yes'||$temp eq 'wo') {
88
        my $borrowernumber = $input->param( $names[ $i + 5 ] );
89
        my $accountno      = $input->param( $names[ $i + 6 ] );
90
        my $note     = $input->param( $names[ $i + 10 ] );
91
        ModNote( $borrowernumber, $accountno, $note );
92
    }
87
}
93
}
94
88
my $total = $input->param('total') || '';
95
my $total = $input->param('total') || '';
89
if ( $check == 0 ) {
96
if ( $check == 0 ) {
90
    if ( $total ne '' ) {
97
    if ( $total ne '' ) {
Lines 115-120 if ( $check == 0 ) { Link Here
115
                $line{borrowernumber} = $borrowernumber;
122
                $line{borrowernumber} = $borrowernumber;
116
                $line{accountno}      = $accts->[$i]{'accountno'};
123
                $line{accountno}      = $accts->[$i]{'accountno'};
117
                $line{description}    = $accts->[$i]{'description'};
124
                $line{description}    = $accts->[$i]{'description'};
125
                $line{note}           = $accts->[$i]{'note'};
118
                $line{title}          = $accts->[$i]{'title'};
126
                $line{title}          = $accts->[$i]{'title'};
119
                $line{notify_id}      = $accts->[$i]{'notify_id'};
127
                $line{notify_id}      = $accts->[$i]{'notify_id'};
120
                $line{notify_level}   = $accts->[$i]{'notify_level'};
128
                $line{notify_level}   = $accts->[$i]{'notify_level'};
121
- 

Return to bug 5728