Changeset 792


Ignore:
Timestamp:
Feb 3, 2016, 12:25:27 AM (9 years ago)
Author:
chronos
Message:
  • Fixed: Also Contract table now use BillCode as reference to DocumentLineCode table.
  • Fixed: Previous SQL update was not used.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r787 r792  
    14841484  }
    14851485  $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `BillCodeText`;');
    1486 
    1487         //$Manager->Execute('RENAME TABLE `FinanceOperationGroup` TO `FinanceOperationTemplate`');
    1488         //$Manager->Execute('RENAME TABLE `FinanceInvoiceGroup` TO `FinanceInvoiceTemplate`');
    14891486}
    14901487
     
    18041801  $Manager->Execute('ALTER TABLE `Member` ADD `ChangeReplaceId` INT(11) NULL DEFAULT NULL;');
    18051802  $Manager->Execute('ALTER TABLE `Member` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `Member`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     1803}
     1804
     1805function UpdateTo792($Manager)
     1806{
     1807  // Transform contracts
     1808  $Manager->Execute('ALTER TABLE `Contract` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
     1809  $Manager->Execute('ALTER TABLE `Contract` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)');
     1810  $Manager->Execute('ALTER TABLE `Contract` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     1811  $DbResult = $Manager->Execute('SELECT `Contract`.`Id`, `Contract`.`BillCodeText`, `Contract`.`DocumentLine` '.
     1812    'FROM `Contract` '.
     1813    'WHERE `Contract`.`BillCodeText`!=""');
     1814  while($DbRow = $DbResult->fetch_assoc())
     1815  {
     1816    if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
     1817    $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
     1818      'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
     1819    $CodeId = $Manager->Database->insert_id;
     1820    $Manager->Execute('UPDATE `Contract` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']);
     1821  }
     1822  //$Manager->Execute('ALTER TABLE `Contract` DROP `BillCodeText`;');
    18061823}
    18071824
     
    18871904      768 => array('Revision' => 770, 'Function' => 'UpdateTo770'),
    18881905      770 => array('Revision' => 785, 'Function' => 'UpdateTo785'),
    1889       775 => array('Revision' => 786, 'Function' => 'UpdateTo786'),
     1906      785 => array('Revision' => 786, 'Function' => 'UpdateTo786'),
     1907      786 => array('Revision' => 792, 'Function' => 'UpdateTo792'),
    18901908    ));
    18911909  }
  • trunk/Application/Version.php

    r791 r792  
    11<?php
    22
    3 $Revision = 790; // Subversion revision
    4 $DatabaseRevision = 785; // SQL structure revision
    5 $ReleaseTime = strtotime('2016-01-22');
     3$Revision = 792; // Subversion revision
     4$DatabaseRevision = 792; // SQL structure revision
     5$ReleaseTime = strtotime('2016-02-02');
  • trunk/Modules/Finance/Finance.php

    r789 r792  
    534534      'Items' => array(
    535535        'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),
    536         'BillCode' => array('Type' => 'String', 'Caption' => 'Kód', 'Default' => ''),
     536        'BillCode' => array('Type' => 'TDocumentLineCode', 'Caption' => 'Kód', 'Default' => ''),
    537537        'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),
    538538        'ValidFrom' => array('Type' => 'Date', 'Caption' => 'Platnost od', 'Default' => ''),
Note: See TracChangeset for help on using the changeset viewer.