Ignore:
Timestamp:
Jan 4, 2015, 11:30:15 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Old invoice items with validity period contained in Text was changed to move period to PeriodFrom and PeriodTo columns.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Setup/Updates.php

    r722 r725  
    11271127{
    11281128        $Manager->Execute('ALTER TABLE `Service` DROP `CustomerCount`;');
     1129}
     1130
     1131function UpdateTo725($Manager)
     1132{
     1133        // Text column of invoices is not used. Text from invoice items is taken instead.
     1134        $DbResult = $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `Text`;');
     1135       
     1136        $SearchText = 'Připojení k síti';
     1137        $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";');
     1138        while($DbRow = $DbResult->fetch_assoc())
     1139        {
     1140                $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1));
     1141                $Text = explode('-', $Text);           
     1142                $PeriodFrom = explode('.', trim($Text[0]));
     1143                $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0];
     1144                $PeriodTo = explode('.', trim($Text[1]));
     1145                $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0];
     1146                $Manager->Execute('UPDATE `FinanceInvoice` SET `PeriodFrom`="'.$PeriodFrom.'", `PeriodTo`="'.$PeriodTo.'" WHERE `Id`='.$DbRow['FinanceInvoice']);
     1147        }
     1148        $DbResult = $Manager->Execute('UPDATE `FinanceInvoiceItem` SET `Description` = "'.$SearchText.'" WHERE `Description` LIKE "'.$SearchText.' za období%";');
     1149       
     1150        $SearchText = 'Připojení k Internetu';
     1151        $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";');
     1152        while($DbRow = $DbResult->fetch_assoc())
     1153        {
     1154                $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1));
     1155                $Text = explode('-', $Text);           
     1156                $PeriodFrom = explode('.', trim($Text[0]));
     1157                $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0];
     1158                $Text[1] = trim($Text[1]);
     1159                if(strpos($Text[1], ' ') !== false) $Text[1] = substr($Text[1], 0, strpos($Text[1], ' '));
     1160                $PeriodTo = explode('.', trim($Text[1]));
     1161                $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0];
     1162                $Manager->Execute('UPDATE `FinanceInvoice` SET `PeriodFrom`="'.$PeriodFrom.'", `PeriodTo`="'.$PeriodTo.'" WHERE `Id`='.$DbRow['FinanceInvoice']);
     1163        }
     1164        $DbResult = $Manager->Execute('UPDATE `FinanceInvoiceItem` SET `Description` = "'.$SearchText.'" WHERE `Description` LIKE "'.$SearchText.' za období%";');
    11291165}
    11301166
     
    11881224        719 => array('Revision' => 720, 'Function' => 'UpdateTo720'),
    11891225        720 => array('Revision' => 722, 'Function' => 'UpdateTo722'),
     1226        722 => array('Revision' => 725, 'Function' => 'UpdateTo725'),
    11901227    ));
    11911228  }
Note: See TracChangeset for help on using the changeset viewer.