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

(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 3051-3056 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
3051
  KEY `basketno` (`basketno`),
3051
  KEY `basketno` (`basketno`),
3052
  KEY `biblionumber` (`biblionumber`),
3052
  KEY `biblionumber` (`biblionumber`),
3053
  KEY `budget_id` (`budget_id`),
3053
  KEY `budget_id` (`budget_id`),
3054
  CONSTRAINT `aqorders_budget_id_fk` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3054
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3055
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3055
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3056
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3056
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
3057
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
(-)a/installer/data/mysql/updatedatabase.pl (+42 lines)
Lines 8845-8850 if ( CheckVersion($DBversion) ) { Link Here
8845
   SetVersion ($DBversion);
8845
   SetVersion ($DBversion);
8846
}
8846
}
8847
8847
8848
8849
$DBversion = "3.17.00.XXX";
8850
if ( CheckVersion($DBversion) ) {
8851
    my $number_of_orders_not_linked = $dbh->selectcol_arrayref(q|
8852
        SELECT COUNT(*)
8853
        FROM aqorders o
8854
        WHERE NOT EXISTS (
8855
            SELECT NULL
8856
            FROM aqbudgets b
8857
            WHERE b.budget_id = o.budget_id
8858
        );
8859
    |);
8860
8861
    if ( $number_of_orders_not_linked->[0] > 0 ) {
8862
        $dbh->do(q|
8863
            INSERT INTO aqbudgetperiods(budget_period_startdate, budget_period_enddate, budget_period_active, budget_period_description, budget_period_total) VALUES ( CAST(NOW() AS date), CAST(NOW() AS date), 0, "WARNING: This budget has been automatically created by the updatedatabase script, please see bug 12601 for more information", 0)
8864
        |);
8865
        my $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef );
8866
        $dbh->do(qq|
8867
            INSERT INTO aqbudgets(budget_code, budget_name, budget_amount, budget_period_id) VALUES ( "BACKUP_TMP", "WARNING: fund created by the updatedatabase script, please see bug 12601", 0, $budget_period_id );
8868
        |);
8869
        my $budget_id = $dbh->last_insert_id( undef, undef, 'aqbudgets', undef );
8870
        $dbh->do(qq|
8871
            UPDATE aqorders o
8872
            SET budget_id = $budget_id
8873
            WHERE NOT EXISTS (
8874
                SELECT NULL
8875
                FROM aqbudgets b
8876
                WHERE b.budget_id = o.budget_id
8877
            )
8878
        |);
8879
    }
8880
8881
    $dbh->do(q|
8882
        ALTER TABLE aqorders
8883
        ADD CONSTRAINT aqorders_budget_id_fk FOREIGN KEY (budget_id) REFERENCES aqbudgets(budget_id) ON DELETE CASCADE ON UPDATE CASCADE
8884
    |);
8885
8886
    print "Upgrade to $DBversion done (Bug 12601 - Add new foreign key aqorders.budget_id" . ( ( $number_of_orders_not_linked->[0] > 0 )  ? ' WARNING: temporary budget and fund have been created (search for "BACKUP_TMP"). At least one of your order was not linked to a budget' : '' ) . ")\n";
8887
    SetVersion($DBversion);
8888
}
8889
8848
=head1 FUNCTIONS
8890
=head1 FUNCTIONS
8849
8891
8850
=head2 TableExists($table)
8892
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-1 / +1 lines)
Lines 593-598 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
593
593
594
[% IF op == 'delete_confirm' %]
594
[% IF op == 'delete_confirm' %]
595
<div class="dialog alert"> <h3>Delete fund [% budget_name %]?</h3>
595
<div class="dialog alert"> <h3>Delete fund [% budget_name %]?</h3>
596
If you delete this fund, all orders linked to this fund will be deleted!
596
<table>
597
<table>
597
    <tr>
598
    <tr>
598
    <th scope="row">Fund amount:</th>
599
    <th scope="row">Fund amount:</th>
599
- 

Return to bug 12601