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

(-)a/admin/aqbudgetperiods.pl (-12 / +18 lines)
Lines 69-76 my $budget_period_id = $input->param('budget_period_id'); Link Here
69
my $op                   = $input->param('op')||"else";
69
my $op                   = $input->param('op')||"else";
70
70
71
my $budget_period_hashref= $input->Vars;
71
my $budget_period_hashref= $input->Vars;
72
#my $sort1_authcat = $input->param('sort1_authcat');
72
73
#my $sort2_authcat = $input->param('sort2_authcat');
73
my $sql_error;
74
74
75
my $pagesize    = 20;
75
my $pagesize    = 20;
76
$searchfield =~ s/\,//g;
76
$searchfield =~ s/\,//g;
Lines 140-154 if ( $op eq 'add_form' ) { Link Here
140
elsif ( $op eq 'add_validate' ) {
140
elsif ( $op eq 'add_validate' ) {
141
## add or modify a budget period (confirmation)
141
## add or modify a budget period (confirmation)
142
142
143
	## update budget period data
143
    ## update budget period data
144
	if ( $budget_period_id ne '' ) {
144
    my $r;
145
		$$budget_period_hashref{$_}||=0 for qw(budget_period_active budget_period_locked);
145
    if ( $budget_period_id ne '' ) {
146
		my $status=ModBudgetPeriod($budget_period_hashref);
146
        $$budget_period_hashref{$_}||=0 for qw(budget_period_active budget_period_locked);
147
	} 
147
        $r = ModBudgetPeriod($budget_period_hashref);
148
	else {    # ELSE ITS AN ADD
148
    } 
149
		my $budget_period_id=AddBudgetPeriod($budget_period_hashref);
149
    else {    # ELSE ITS AN ADD
150
	}
150
        $r = AddBudgetPeriod($budget_period_hashref);
151
	$op='else';
151
    }
152
153
    $sql_error = 1 unless $r;
154
    $op='else';
152
}
155
}
153
156
154
#--------------------------------------------------
157
#--------------------------------------------------
Lines 267-271 elsif ( $op eq 'duplicate_budget' ){ Link Here
267
		pagination_bar		  => pagination_bar("aqbudgetperiods.pl",getnbpages(scalar(@$results),$pagesize),$page),
270
		pagination_bar		  => pagination_bar("aqbudgetperiods.pl",getnbpages(scalar(@$results),$pagesize),$page),
268
    );
271
    );
269
272
270
$template->param($op=>1);
273
$template->param(
274
    $op => 1,
275
    sql_error => $sql_error,
276
);
271
output_html_with_http_headers $input, $cookie, $template->output;
277
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/admin/aqbudgets.pl (-2 / +6 lines)
Lines 40-45 use C4::Debug; Link Here
40
40
41
my $input = new CGI;
41
my $input = new CGI;
42
my $dbh     = C4::Context->dbh;
42
my $dbh     = C4::Context->dbh;
43
my $sql_error;
43
44
44
my ($template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user(
45
my ($template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user(
45
    {   template_name   => "admin/aqbudgets.tmpl",
46
    {   template_name   => "admin/aqbudgets.tmpl",
Lines 248-267 if ($op eq 'add_form') { Link Here
248
            @budgetusersid = split(':', $budget_hash->{'budget_users_ids'});
249
            @budgetusersid = split(':', $budget_hash->{'budget_users_ids'});
249
        }
250
        }
250
251
252
        my $r;
251
        if ( defined $$budget_hash{budget_id} ) {
253
        if ( defined $$budget_hash{budget_id} ) {
252
            if (CanUserModifyBudget($borrowernumber, $budget_hash->{budget_id},
254
            if (CanUserModifyBudget($borrowernumber, $budget_hash->{budget_id},
253
                $staffflags)
255
                $staffflags)
254
            ) {
256
            ) {
255
                ModBudget( $budget_hash );
257
                $r = ModBudget( $budget_hash );
256
                ModBudgetUsers($budget_hash->{budget_id}, @budgetusersid);
258
                ModBudgetUsers($budget_hash->{budget_id}, @budgetusersid);
257
            }
259
            }
258
            else {
260
            else {
259
                $template->param(error_not_authorised_to_modify => 1);
261
                $template->param(error_not_authorised_to_modify => 1);
260
            }
262
            }
261
        } else {
263
        } else {
262
            AddBudget( $budget_hash );
264
            $r = AddBudget( $budget_hash );
263
            ModBudgetUsers($budget_hash->{budget_id}, @budgetusersid);
265
            ModBudgetUsers($budget_hash->{budget_id}, @budgetusersid);
264
        }
266
        }
267
        $sql_error = 1 unless $r;
265
    }
268
    }
266
    my $branches = GetBranches();
269
    my $branches = GetBranches();
267
    $template->param(
270
    $template->param(
Lines 364-369 if ($op eq 'add_form') { Link Here
364
        period_alloc_total     => $period_alloc_total,
367
        period_alloc_total     => $period_alloc_total,
365
        base_spent_total       => $base_spent_total,
368
        base_spent_total       => $base_spent_total,
366
        branchloop             => \@branchloop2,
369
        branchloop             => \@branchloop2,
370
        sql_error              => $sql_error,
367
    );
371
    );
368
372
369
} #---- END $OP eq DEFAULT
373
} #---- END $OP eq DEFAULT
(-)a/installer/data/mysql/kohastructure.sql (-2 / +5 lines)
Lines 2644-2650 CREATE TABLE `aqbudgets` ( -- information related to Funds Link Here
2644
  `sort2_authcat` varchar(80) default NULL, -- second statistical category for this fund
2644
  `sort2_authcat` varchar(80) default NULL, -- second statistical category for this fund
2645
  `budget_owner_id` int(11) default NULL, -- borrowernumber of the person who owns this fund (borrowers.borrowernumber)
2645
  `budget_owner_id` int(11) default NULL, -- borrowernumber of the person who owns this fund (borrowers.borrowernumber)
2646
  `budget_permission` int(1) default '0', -- level of permission for this fund (used only by the owner, only by the library, or anyone)
2646
  `budget_permission` int(1) default '0', -- level of permission for this fund (used only by the owner, only by the library, or anyone)
2647
  PRIMARY KEY  (`budget_id`)
2647
  PRIMARY KEY  (`budget_id`),
2648
  UNIQUE KEY `uniq_budget_name_aqbudgets` (`budget_name`),
2649
  UNIQUE KEY `uniq_budget_code_aqbudgets` (`budget_code`
2648
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2650
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2649
2651
2650
--
2652
--
Lines 2680-2686 CREATE TABLE `aqbudgetperiods` ( -- information related to Budgets Link Here
2680
  `budget_period_locked` tinyint(1) default NULL, -- whether this budget is locked or not (1 for yes, 0 for no)
2682
  `budget_period_locked` tinyint(1) default NULL, -- whether this budget is locked or not (1 for yes, 0 for no)
2681
  `sort1_authcat` varchar(10) default NULL, -- statistical category for this budget
2683
  `sort1_authcat` varchar(10) default NULL, -- statistical category for this budget
2682
  `sort2_authcat` varchar(10) default NULL, -- second statistical category for this budget
2684
  `sort2_authcat` varchar(10) default NULL, -- second statistical category for this budget
2683
  PRIMARY KEY  (`budget_period_id`)
2685
  PRIMARY KEY  (`budget_period_id`),
2686
  UNIQUE KEY `uniq_aqbudgetperiods` (`budget_period_description`)
2684
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2687
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2685
2688
2686
--
2689
--
(-)a/installer/data/mysql/updatedatabase.pl (+25 lines)
Lines 5635-5640 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5635
    SetVersion($DBversion);
5635
    SetVersion($DBversion);
5636
}
5636
}
5637
5637
5638
$DBversion = "3.07.00.XXX";
5639
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5640
    $dbh->do(q{
5641
        ALTER TABLE `aqbudgetperiods` MODIFY COLUMN `budget_period_description` VARCHAR(255)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
5642
    });
5643
    $dbh->do(q{
5644
        ALTER TABLE `aqbudgetperiods` ADD UNIQUE ( budget_period_description);
5645
    });
5646
    $dbh->do(q{
5647
        ALTER TABLE `aqbudgets` MODIFY COLUMN `budget_name` VARCHAR(80)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
5648
    });
5649
    $dbh->do(q{
5650
        ALTER TABLE `aqbudgets` MODIFY COLUMN `budget_code` VARCHAR(30)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
5651
    });
5652
    $dbh->do(q{
5653
        ALTER TABLE `aqbudgets` ADD UNIQUE ( budget_name );
5654
    });
5655
    $dbh->do(q{
5656
        ALTER TABLE `aqbudgets` ADD UNIQUE ( budget_code );
5657
    });
5658
5659
    print "Upgrade to $DBversion done (aqbudgets and aqbudgetperiods. Unique constraint on field.)\n";
5660
    SetVersion ($DBversion);
5661
}
5662
5638
=head1 FUNCTIONS
5663
=head1 FUNCTIONS
5639
5664
5640
=head2 TableExists($table)
5665
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt (+6 lines)
Lines 151-156 Link Here
151
<div id="yui-main">
151
<div id="yui-main">
152
<div class="yui-b">
152
<div class="yui-b">
153
153
154
[% IF ( sql_error ) %]
155
    <div class="error">
156
        This budget name already exists
157
    </div>
158
[% END %]
159
154
[% INCLUDE 'budgets-admin-toolbar.inc' %]
160
[% INCLUDE 'budgets-admin-toolbar.inc' %]
155
161
156
[% IF ( duplicate_form ) %]
162
[% IF ( duplicate_form ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-1 / +5 lines)
Lines 206-211 Link Here
206
<div id="yui-main">
206
<div id="yui-main">
207
<div class="yui-b" id="content">
207
<div class="yui-b" id="content">
208
208
209
[% IF ( sql_error ) %]
210
    <div class="error">
211
        This fund name (or code) already exists
212
    </div>
213
[% END %]
209
214
210
[% UNLESS ( delete_confirm ) %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
215
[% UNLESS ( delete_confirm ) %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
211
216
212
- 

Return to bug 7303