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

(-)a/acqui/check_budget_total.pl (-16 / +5 lines)
Lines 19-29 Link Here
19
19
20
use strict;
20
use strict;
21
#use warnings; FIXME - Bug 2505
21
#use warnings; FIXME - Bug 2505
22
use CGI;
23
use C4::Context;
24
use C4::Output;
25
use C4::Auth;
26
use C4::Budgets;
22
use C4::Budgets;
23
use C4::Service;
27
24
28
=head1 DESCRIPTION
25
=head1 DESCRIPTION
29
26
Lines 31-50 fetches the budget amount fron the DB Link Here
31
28
32
=cut
29
=cut
33
30
34
my $input = new CGI;
31
my ($query, $response) = C4::Service->init();
35
my $budget_id = $input->param('budget_id');
32
my ($budget_id, $total) = C4::Service->require_params( 'budget_id', 'total' );
36
my $total   = $input->param('total');
37
38
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
39
    {   template_name   => "acqui/ajax.tmpl",
40
        query           => $input,
41
        type            => "intranet",
42
        authnotrequired => 0,
43
        debug => 1,    } );
44
33
45
my $budget = GetBudget($budget_id);
34
my $budget = GetBudget($budget_id);
46
35
47
$template->param( return => $budget->{'budget_amount'}  );
36
$response->param( actTotal => $budget->{'budget_amount'} );
48
37
49
output_html_with_http_headers $input, $cookie, $template->output;
38
C4::Service->return_success( $response );
50
1;
39
1;
(-)a/admin/check_budget_parent.pl (-19 / +6 lines)
Lines 19-29 Link Here
19
19
20
use strict;
20
use strict;
21
#use warnings; FIXME - Bug 2505
21
#use warnings; FIXME - Bug 2505
22
use CGI;
23
use C4::Context;
24
use C4::Output;
25
use C4::Auth;
26
use C4::Budgets;
22
use C4::Budgets;
23
use C4::Service;
27
24
28
=head1 DESCRIPTION
25
=head1 DESCRIPTION
29
26
Lines 32-55 called by aqbudgets.pl and neworderempty.pl Link Here
32
29
33
=cut
30
=cut
34
31
35
my $input = new CGI;
32
my ($query, $response) = C4::Service->init();
36
33
my ($budget_id, $new_parent_id) = C4::Service->require_params( 'budget_id', 'new_parent' );
37
my $budget_id     = $input->param('budget_id');
38
my $new_parent_id = $input->param('new_parent');
39
40
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41
    {   template_name   => "acqui/ajax.tmpl",
42
        query           => $input,
43
        type            => "intranet",
44
        authnotrequired => 0,
45
        debug           => 0,
46
    }
47
);
48
34
49
my $budget            = GetBudget($budget_id);
35
my $budget            = GetBudget($budget_id);
50
my $new_parent_budget = GetBudget($new_parent_id);
36
my $new_parent_budget = GetBudget($new_parent_id);
51
my $result            = CheckBudgetParent( $new_parent_budget, $budget );
37
my $result            = CheckBudgetParent( $new_parent_budget, $budget );
52
$template->param( return => $result );
53
38
54
output_html_with_http_headers $input, $cookie, $template->output;
39
$response->param( result => $result );
40
41
C4::Service->return_success( $response );
55
1;
42
1;
(-)a/admin/check_parent_total.pl (-17 / +7 lines)
Lines 19-29 Link Here
19
19
20
use strict;
20
use strict;
21
#use warnings; FIXME - Bug 2505
21
#use warnings; FIXME - Bug 2505
22
use CGI;
23
use C4::Context;
22
use C4::Context;
24
use C4::Output;
25
use C4::Auth;
26
use C4::Budgets;
23
use C4::Budgets;
24
use C4::Service;
27
25
28
=head1 DESCRIPTION
26
=head1 DESCRIPTION
29
27
Lines 35-56 to determine whether the new parent budget (or period) has enough unallocated fu Link Here
35
=cut
33
=cut
36
34
37
my $dbh = C4::Context->dbh;
35
my $dbh = C4::Context->dbh;
38
my $input = new CGI;
36
my ($query, $response) = C4::Service->init();
37
my ($total, $period_id) = C4::Service->require_params( 'total', 'period_id' );
38
my ($budget_id, $parent_id) = C4::Service->optional_params( 'budget_id', 'parent_id' );
39
39
40
my $total     = $input->param('total');
41
my $budget_id = $input->param('budget_id');
42
my $parent_id = $input->param('parent_id');
43
my $period_id = $input->param('period_id');
44
my $returncode;
40
my $returncode;
45
41
46
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47
    {   template_name   => "acqui/ajax.tmpl",
48
        query           => $input,
49
        type            => "intranet",
50
        authnotrequired => 0,
51
        debug           => 0,
52
    }
53
);
54
my ($period, $parent , $budget);
42
my ($period, $parent , $budget);
55
$period = GetBudgetPeriod($period_id) if $period_id;
43
$period = GetBudgetPeriod($period_id) if $period_id;
56
$parent = GetBudget($parent_id)       if defined $parent_id;
44
$parent = GetBudget($parent_id)       if defined $parent_id;
Lines 108-112 if ( $parent_id) { Link Here
108
}
96
}
109
97
110
98
111
output_html_with_http_headers $input, $cookie, $returncode;
99
$response->param( returncode => $returncode );
100
101
C4::Service->return_success( $response );
112
1;
102
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js (-8 / +3 lines)
Lines 728-734 for (i=1;i<=2;i++) { Link Here
728
        url: url,
728
        url: url,
729
        mimeType: 'text/xml',
729
        mimeType: 'text/xml',
730
        success: function (data, textStatus, xmlhttp) {
730
        success: function (data, textStatus, xmlhttp) {
731
            // rc =  eval ( xmlhttp.responseText );
732
            var retRootType = jQuery(xmlhttp.responseXML).children().first().get(0).nodeName.toLowerCase();
731
            var retRootType = jQuery(xmlhttp.responseXML).children().first().get(0).nodeName.toLowerCase();
733
            var hasInputs = $sort_zone.has('input').length > 0;
732
            var hasInputs = $sort_zone.has('input').length > 0;
734
            if (hasInputs && retRootType == 'input') {
733
            if (hasInputs && retRootType == 'input') {
Lines 754-763 function totalExceedsBudget(budgetId, total) { Link Here
754
    var ret = undefined;
753
    var ret = undefined;
755
    jQuery.ajax({
754
    jQuery.ajax({
756
        url: url,
755
        url: url,
757
        mimeType: 'text/xml',
758
        async: false, // non-async because we need to return a value based on the result
756
        async: false, // non-async because we need to return a value based on the result
759
        success: function(data, textStatus, xmlhttp) {
757
        success: function(data, textStatus, xmlhttp) {
760
            actTotal = eval ( xmlhttp.responseText );
758
            actTotal = data.actTotal;
761
759
762
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
760
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
763
            // if budget is to low :(
761
            // if budget is to low :(
Lines 785-794 if ( newBudgetParent ) { url += '&parent_id=' + newBudgetParent}; Link Here
785
    var ret = undefined;
783
    var ret = undefined;
786
    jQuery.ajax({
784
    jQuery.ajax({
787
        url: url,
785
        url: url,
788
        mimeType: 'text/xml',
789
        async: false, // non-async because we need to return a value based on the result
786
        async: false, // non-async because we need to return a value based on the result
790
        success: function(data, textStatus, xmlhttp) {
787
        success: function(data, textStatus, xmlhttp) {
791
            var result = eval ( xmlhttp.responseText );
788
            var result = data.returncode;
792
789
793
            if (result == '1') {
790
            if (result == '1') {
794
                    ret = _("- Budget total exceeds parent allocation\n");
791
                    ret = _("- Budget total exceeds parent allocation\n");
Lines 811-820 function checkBudgetParent(budgetId, newBudgetParent) { Link Here
811
    var ret = undefined;
808
    var ret = undefined;
812
    jQuery.ajax({
809
    jQuery.ajax({
813
        url: url,
810
        url: url,
814
        mimeType: 'text/xml',
815
        async: false, // non-async because we need to return a value based on the result
811
        async: false, // non-async because we need to return a value based on the result
816
        success: function(data, textStatus, xmlhttp) {
812
        success: function(data, textStatus, xmlhttp) {
817
            var result = eval ( xmlhttp.responseText );
813
            var result = data.result;
818
814
819
            if (result == '1') {
815
            if (result == '1') {
820
                    ret = _("- New budget-parent is beneath budget\n");
816
                    ret = _("- New budget-parent is beneath budget\n");
821
- 

Return to bug 9411