source: trunk/temp/product.php@ 452

Last change on this file since 452 was 452, checked in by chronos, 13 years ago
  • Opraveno: Zobrazování odkazů v aktualitách.
  • Upraveno: Tabulka Product rozdělena na Product a StockItem. Upravena struktura.
File size: 1.0 KB
Line 
1<?php
2include('../Common/Global.php');
3GlobalInit();
4
5/* @var $System System */
6$System->Database->query('TRUNCATE TABLE StockItem');
7$System->Database->query('TRUNCATE TABLE Product');
8
9$DbResult = $System->Database->select('ProductOld', '*');
10while($DbRow = $DbResult->fetch_assoc())
11{
12 echo($DbRow['Name'].', ');
13
14 $System->Database->insert('Product', array('Name' => $DbRow['Name'],
15 'SellPrice' => $DbRow['Price'], 'BuyPrice' => $DbRow['Price'],
16 'Consumption' => $DbRow['Consumption'], 'UnitOfMeasure' => 1, 'VAT' => 20));
17 $ProductId = $System->Database->insert_id;
18 if($DbRow['Used'] == 1) $Elimination = 'NULL';
19 else $Elimination = $DbRow['TimeElimination'];
20 $Database->insert('StockItem', array('Stock' => 1, 'Product' => $ProductId, 'Amount' => $DbRow['Count'],
21 'Segment' => $DbRow['Segment'], 'TimeEnlistment' => $DbRow['Date'], 'TimeElimination' => $Elimination,
22 'SerialNumber' => $DbRow['DeviceId'], 'BuyPrice' => $DbRow['Price'], 'SellPrice' => $DbRow['Price'],
23 'Location' => $DbRow['User'], 'Info' => $DbRow['Info']));
24}
25
26?>
Note: See TracBrowser for help on using the repository browser.