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

(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 3054-3059 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
3054
  KEY `basketno` (`basketno`),
3054
  KEY `basketno` (`basketno`),
3055
  KEY `biblionumber` (`biblionumber`),
3055
  KEY `biblionumber` (`biblionumber`),
3056
  KEY `budget_id` (`budget_id`),
3056
  KEY `budget_id` (`budget_id`),
3057
  CONSTRAINT `aqorders_budget_id_fk` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3057
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3058
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3058
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3059
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3059
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
3060
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
(-)a/installer/data/mysql/updatedatabase.pl (+41 lines)
Lines 8949-8954 if ( CheckVersion($DBversion) ) { Link Here
8949
        ADD COLUMN cancellationreason TEXT DEFAULT NULL AFTER datecancellationprinted
8949
        ADD COLUMN cancellationreason TEXT DEFAULT NULL AFTER datecancellationprinted
8950
    ");
8950
    ");
8951
    print "Upgrade to $DBversion done (Bug 7162: Add aqorders.cancellationreason)\n";
8951
    print "Upgrade to $DBversion done (Bug 7162: Add aqorders.cancellationreason)\n";
8952
    SetVersion ($DBversion);
8953
}
8954
8955
$DBversion = "3.17.00.XXX";
8956
if ( CheckVersion($DBversion) ) {
8957
    my $number_of_orders_not_linked = $dbh->selectcol_arrayref(q|
8958
        SELECT COUNT(*)
8959
        FROM aqorders o
8960
        WHERE NOT EXISTS (
8961
            SELECT NULL
8962
            FROM aqbudgets b
8963
            WHERE b.budget_id = o.budget_id
8964
        );
8965
    |);
8966
8967
    if ( $number_of_orders_not_linked->[0] > 0 ) {
8968
        $dbh->do(q|
8969
            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)
8970
        |);
8971
        my $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef );
8972
        $dbh->do(qq|
8973
            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 );
8974
        |);
8975
        my $budget_id = $dbh->last_insert_id( undef, undef, 'aqbudgets', undef );
8976
        $dbh->do(qq|
8977
            UPDATE aqorders o
8978
            SET budget_id = $budget_id
8979
            WHERE NOT EXISTS (
8980
                SELECT NULL
8981
                FROM aqbudgets b
8982
                WHERE b.budget_id = o.budget_id
8983
            )
8984
        |);
8985
    }
8986
8987
    $dbh->do(q|
8988
        ALTER TABLE aqorders
8989
        ADD CONSTRAINT aqorders_budget_id_fk FOREIGN KEY (budget_id) REFERENCES aqbudgets(budget_id) ON DELETE CASCADE ON UPDATE CASCADE
8990
    |);
8991
8992
    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";
8952
    SetVersion($DBversion);
8993
    SetVersion($DBversion);
8953
}
8994
}
8954
8995
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-1 / +1 lines)
Lines 594-599 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
594
594
595
[% IF op == 'delete_confirm' %]
595
[% IF op == 'delete_confirm' %]
596
<div class="dialog alert"> <h3>Delete fund [% budget_name %]?</h3>
596
<div class="dialog alert"> <h3>Delete fund [% budget_name %]?</h3>
597
If you delete this fund, all orders linked to this fund will be deleted!
597
<table>
598
<table>
598
    <tr>
599
    <tr>
599
    <th scope="row">Fund amount:</th>
600
    <th scope="row">Fund amount:</th>
600
- 

Return to bug 12601