Changeset 802
- Timestamp:
- Feb 23, 2016, 4:44:03 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/UpdateTrace.php
r801 r802 1826 1826 { 1827 1827 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockItemHistory` ( 1828 `Id` int(11) NOT NULL ,1828 `Id` int(11) NOT NULL AUTO_INCREMENT, 1829 1829 `StockSerialNumber` int(11) NOT NULL, 1830 1830 `Time` datetime NOT NULL, … … 1838 1838 '"" AS `Time`, `Info` AS `Text` FROM `StockSerialNumber` WHERE `Info` != "")'); 1839 1839 $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP `Info`;'); 1840 } 1841 1842 function UpdateTo802($Manager) 1843 { 1844 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveGroup` ( 1845 `Id` int(11) NOT NULL AUTO_INCREMENT, 1846 `Name` varchar(255) NOT NULL, 1847 `DocumentLine` int(11) NOT NULL, 1848 `ValueSign` int(11) NOT NULL, 1849 `Direction` int(11) NOT NULL, 1850 PRIMARY KEY (`Id`), 1851 KEY `DocumentLine` (`DocumentLine`) 1852 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); 1853 $Manager->Execute('ALTER TABLE `StockMoveGroup` ADD FOREIGN KEY (`DocumentLine`) '. 1854 'REFERENCES `DocumentLine`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1855 $Manager->Execute('INSERT INTO `StockMoveGroup` (`Id`, `Name`, `DocumentLine`, '. 1856 '`ValueSign`, `Direction`) VALUES (NULL, "Příjem", 8, 1, 0), (NULL, "Výdej", 7, -1, 1);'); 1857 1858 $Manager->Execute('ALTER TABLE `StockMove` ADD `Group` INT NOT NULL AFTER `File`, ADD INDEX (`Group`);'); 1859 $Manager->Execute('ALTER TABLE `StockMove` ADD `Stock` INT NOT NULL AFTER `Time`, ADD INDEX (`Stock`);'); 1860 $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`Group`) REFERENCES `StockMoveGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1861 $Manager->Execute('UPDATE `StockMove` SET `Group`=(SELECT `Id` FROM `StockMoveGroup` WHERE `StockMoveGroup`.`DocumentLine` = `StockMove`.`DocumentLine`)'); 1862 $Manager->Execute('UPDATE `StockMove` SET `Stock`= `StockFrom` WHERE `DocumentLine` = 7'); 1863 $Manager->Execute('UPDATE `StockMove` SET `Stock`= `StockTo` WHERE `DocumentLine` = 8'); 1864 $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_2;'); 1865 $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_1;'); 1866 $Manager->Execute('ALTER TABLE `StockMove` DROP FOREIGN KEY StockMove_ibfk_3;'); 1867 $Manager->Execute('ALTER TABLE `StockMove` DROP `StockFrom`, DROP `StockTo`, DROP `DocumentLine`;'); 1868 $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`Stock`) REFERENCES `Stock`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1869 1870 // Make BillCode as reference to DocumentLineCode table 1871 $Manager->Execute('ALTER TABLE `StockMove` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL'); 1872 $Manager->Execute('ALTER TABLE `StockMove` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)'); 1873 $Manager->Execute('ALTER TABLE `StockMove` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1874 1875 $DbResult = $Manager->Execute('SELECT `StockMove`.`Id`, `StockMove`.`BillCodeText`, `StockMoveGroup`.`DocumentLine` '. 1876 'FROM `StockMove` '. 1877 'LEFT JOIN `StockMoveGroup` ON `StockMoveGroup`.`Id` = `StockMove`.`Group` '. 1878 'WHERE `StockMove`.`BillCodeText`!=""'); 1879 while($DbRow = $DbResult->fetch_assoc()) 1880 { 1881 if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; 1882 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 1883 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); 1884 $CodeId = $Manager->Database->insert_id; 1885 $Manager->Execute('UPDATE `StockMove` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']); 1886 } 1887 $Manager->Execute('ALTER TABLE `StockMove` DROP `BillCodeText`;'); 1888 $Manager->Execute('ALTER TABLE `StockMoveItem` DROP `Text`;'); 1840 1889 } 1841 1890 … … 1924 1973 786 => array('Revision' => 792, 'Function' => 'UpdateTo792'), 1925 1974 792 => array('Revision' => 800, 'Function' => 'UpdateTo800'), 1975 800 => array('Revision' => 802, 'Function' => 'UpdateTo802'), 1926 1976 )); 1927 1977 } -
trunk/Application/Version.php
r801 r802 1 1 <?php 2 2 3 $Revision = 80 1; // Subversion revision4 $DatabaseRevision = 80 0; // SQL structure revision5 $ReleaseTime = strtotime('2016-02-2 2');3 $Revision = 802; // Subversion revision 4 $DatabaseRevision = 802; // SQL structure revision 5 $ReleaseTime = strtotime('2016-02-23'); -
trunk/Modules/Finance/Finance.php
r793 r802 621 621 function BeforeInsertFinanceInvoice($Form) 622 622 { 623 // Get new DocumentLineCode by selected invoice Group 623 624 if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 624 625 else $Year = date("Y", $Form->Values['ValidFrom']); 625 $ FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');626 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($ FinanceGroup['DocumentLine'], $Year);626 $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 627 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 627 628 return($Form->Values); 628 629 } -
trunk/Modules/Stock/Stock.php
r800 r802 16 16 function DoStart() 17 17 { 18 global $Config; 19 18 20 $this->System->FormManager->RegisterClass('Product', array( 19 21 'Title' => 'Produkty', … … 21 23 'DefaultSortColumn' => 'Name', 22 24 'Items' => array( 25 'Manufacturer' => array('Type' => 'TSubject', 'Caption' => 'Výrobce', 'Default' => '', 'Null' => true), 26 'Code' => array('Type' => 'String', 'Caption' => 'Kód', 'Default' => ''), 23 27 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 24 28 'SellPrice' => array('Type' => 'Integer', 'Caption' => 'Prodejní cena', 'Default' => '0', 'Suffix' => 'Kč'), … … 27 31 'Consumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba', 'Default' => '', 'Suffix' => 'Watt'), 28 32 'Supplier' => array('Type' => 'TSubject', 'Caption' => 'Dodavatel', 'Default' => '', 'Null' => true), 29 'Manufacturer' => array('Type' => 'TSubject', 'Caption' => 'Výrobce', 'Default' => '', 'Null' => true),30 'Code' => array('Type' => 'String', 'Caption' => 'Kód', 'Default' => ''),31 33 'UnitOfMeasure' => array('Type' => 'TUnitOfMeasure', 'Caption' => 'Měrná jednotka', 'Default' => '', 'Null' => true), 32 34 'StockSerialNumbers' => array('Type' => 'TStockSerialNumberListProduct', 'Caption' => 'Položky na skladě', 'Default' => '', 'Suffix' => 'ks'), … … 79 81 'DefaultSortColumn' => 'Time', 80 82 'Items' => array( 81 ' DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),82 'BillCode' => array('Type' => ' String', 'Caption' => 'Označení', 'Default' => ''),83 'Group' => array('Type' => 'TStockMoveGroup', 'Caption' => 'Skupina', 'Default' => ''), 84 'BillCode' => array('Type' => 'TDocumentLineCode', 'Caption' => 'Označení', 'Default' => '', 'ReadOnly' => true), 83 85 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 84 'StockFrom' => array('Type' => 'TStock', 'Caption' => 'Zdrojový sklad', 'Default' => '', 'Null' => true), 85 'StockTo' => array('Type' => 'TStock', 'Caption' => 'Cílový sklad', 'Default' => '', 'Null' => true), 86 'Stock' => array('Type' => 'TStock', 'Caption' => 'Sklad', 'Default' => '', 'Null' => true), 86 87 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), 87 88 'Price' => array('Type' => 'Float', 'Caption' => 'Cena', 'Default' => '', … … 91 92 ), 92 93 'BeforeInsert' => array($this, 'BeforeInsertStockMove'), 93 )); 94 $this->System->FormManager->RegisterClass('StockMoveUnion', array( 95 'Title' => 'Skladový pohyb', 96 'BaseTable' => 'StockMove', 97 'DefaultSortColumn' => 'Time', 98 'SQL' => '(SELECT *, -1 AS `Direction`, `StockFrom` AS `Stock`, `StockTo` AS `StockOther` FROM `StockMove`) '. 99 'UNION (SELECT *, 1 AS `Direction`, `StockTo` AS `Stock`, `StockFrom` AS `StockOther` FROM `StockMove`)', 100 'Items' => array( 101 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 102 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 103 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 104 'Stock' => array('Type' => 'TStock', 'Caption' => 'První sklad', 'Default' => '', 'Null' => true), 105 'StockOther' => array('Type' => 'TStock', 'Caption' => 'Druhý sklad', 'Default' => '', 'Null' => true), 106 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), 107 'Price' => array('Type' => 'Float', 'Caption' => 'Cena', 'Default' => '', 108 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT `TX`.`Direction` * SUM(`StockMoveItem`.`UnitPrice` * `StockMoveItem`.`Amount`) FROM `StockMoveItem` '. 109 'WHERE `StockMoveItem`.`StockMove`=#Id)'), 110 'Items' => array('Type' => 'TStockMoveItemListStockMove', 'Caption' => 'Položky', 'Default' => ''), 111 ), 112 'BeforeInsert' => array($this, 'BeforeInsertStockMove'), 94 //'AfterInsert' => array($this, 'AfterInsertStockMove'), 95 //'BeforeModify' => array($this, 'BeforeModifyStockMove'), 113 96 )); 114 97 $this->System->FormManager->RegisterClass('StockMoveItem', array( 115 98 'Title' => 'Položka skladového pohybu', 116 99 'Table' => 'StockMoveItem', 117 'DefaultSortColumn' => ' Text',100 'DefaultSortColumn' => 'Product', 118 101 'Items' => array( 119 102 'StockMove' => array('Type' => 'TStockMove', 'Caption' => 'Skladový pohyb', 'Default' => ''), 120 103 'Product' => array('Type' => 'TProduct', 'Caption' => 'Produkt', 'Default' => ''), 104 'UnitPrice' => array('Type' => 'Integer', 'Caption' => 'Jednotková cena', 'Default' => '0', 'Suffix' => 'Kč'), 121 105 'Amount' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'), 122 'Text' => array('Type' => 'String', 'Caption' => 'Text', 'Default' => ''), 123 'UnitPrice' => array('Type' => 'Integer', 'Caption' => 'Jednotková cena', 'Default' => '0', 'Suffix' => 'Kč'), 106 'Total' => array('Type' => 'Integer', 'Caption' => 'Celkem', 'Default' => '', 'Suffix' => 'Kč', 107 'ReadOnly' => true, 'SQL' => 'ROUND(`UnitPrice` * `Amount`, '.$Config['Finance']['Rounding'].')'), 108 ), 109 )); 110 $this->System->FormManager->RegisterClass('StockMoveGroup', array( 111 'Title' => 'Skupina skladových pohybů', 112 'Table' => 'StockMoveGroup', 113 'Items' => array( 114 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'), 115 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'), 116 'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'), 117 'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'), 118 'Items' => array('Type' => 'TStockMoveListGroup', 'Caption' => 'Operace', 'Default' => ''), 124 119 ), 125 120 )); … … 148 143 'Filter' => '1', 149 144 )); 145 $this->System->FormManager->RegisterFormType('TStockMoveListGroup', array( 146 'Type' => 'ManyToOne', 147 'Table' => 'StockMove', 148 'Id' => 'Id', 149 'Ref' => 'Group', 150 'Filter' => '1', 151 )); 150 152 $this->System->FormManager->RegisterFormType('TStockMoveStock', array( 151 153 'Type' => 'ManyToOne', 152 'Table' => 'StockMove Union',154 'Table' => 'StockMove', 153 155 'Id' => 'Id', 154 156 'Ref' => 'Stock', … … 159 161 'Table' => 'StockMove', 160 162 'Id' => 'Id', 161 'Name' => ' BillCode',163 'Name' => '(SELECT `DocumentLineCode`.`Name` FROM `DocumentLineCode` WHERE `Id`=`StockMove`.`BillCode`)', 162 164 'Filter' => '1', 163 165 )); … … 172 174 'Type' => 'Reference', 173 175 'Table' => 'Stock', 176 'Id' => 'Id', 177 'Name' => 'Name', 178 'Filter' => '1', 179 )); 180 $this->System->FormManager->RegisterFormType('TStockMoveGroup', array( 181 'Type' => 'Reference', 182 'Table' => 'StockMoveGroup', 174 183 'Id' => 'Id', 175 184 'Name' => 'Name', … … 196 205 if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 197 206 else $Year = date("Y", $Form->Values['ValidFrom']); 198 $ DocumentLine = $Form->Values['DocumentLine'];199 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber ($DocumentLine, $Year);207 $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup'); 208 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 200 209 return($Form->Values); 201 210 }
Note:
See TracChangeset
for help on using the changeset viewer.