--
-- Host: localhost    Database: pcscale
-- ------------------------------------------------------


--
-- Table structure for table `advertising`
--

CREATE TABLE `advertising` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Scope` smallint(6) DEFAULT '0',
  `Number` int(11) DEFAULT '0',
  `Timeout` int(11) DEFAULT '0',
  `ShowTime` int(11) DEFAULT '10',
  `FadeTime` int(11) DEFAULT '0',
  `FadeType` int(11) DEFAULT '0',
  `ZeroOnly` tinyint(1) DEFAULT '1',
  `ForcedImage` tinyint(1) DEFAULT '0',
  `Publi0` smallint(6) DEFAULT '0',
  `Publi1` smallint(6) DEFAULT '0',
  `PlayList0` varchar(32) NOT NULL DEFAULT '',
  `PlayList1` varchar(32) NOT NULL DEFAULT '',
  `FullScreen0` tinyint(1) DEFAULT '0',
  `FullScreen1` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Scope` (`Scope`,`Number`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

--
-- Table structure for table `allergenicons`
--

CREATE TABLE `allergenicons` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Allergen` varchar(16) NOT NULL,
  `Description` varchar(127) NOT NULL DEFAULT '',
  `Icon` varchar(127) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Allergen` (`Allergen`)
) ENGINE=InnoDB AUTO_INCREMENT=127 DEFAULT CHARSET=utf8;

--
-- Table structure for table `barcodeean13`
--

CREATE TABLE `barcodeean13` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `NumberType` char(1) DEFAULT NULL,
  `Number` smallint(6) DEFAULT '0',
  `NetworkSales` char(12) NOT NULL,
  `NetworkParked` char(12) NOT NULL DEFAULT '',
  `NetworkLineSLB` char(12) NOT NULL,
  `NetworkTotalSLB` char(12) NOT NULL,
  `NetworkSS` char(12) NOT NULL,
  `NetworkPacket1` char(12) NOT NULL,
  `NetworkPacket2` char(12) NOT NULL,
  `LocalSales` char(12) NOT NULL,
  `LocalLineSLB` char(12) NOT NULL,
  `LocalTotalSLB` char(12) NOT NULL,
  `LocalSS` char(12) NOT NULL,
  `LocalPacket1` char(12) NOT NULL,
  `LocalPacket2` char(12) NOT NULL,
  `LocalTotal` char(12) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `NumberType` (`NumberType`,`Number`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Table structure for table `bovine`
--

CREATE TABLE `bovine` (
  `NumCard` smallint(3) NOT NULL,
  `EarTag` varchar(30) NOT NULL,
  `Weight` decimal(6,3) NOT NULL DEFAULT '0.000',
  `BirthLand` smallint(6) DEFAULT NULL,
  `BirthDate` date DEFAULT NULL,
  `BreedingLand` smallint(6) DEFAULT NULL,
  `SlaughterLand` smallint(6) DEFAULT NULL,
  `SlaughterReg` varchar(30) DEFAULT NULL,
  `SlaughterDate` date DEFAULT NULL,
  `ButcherLand` smallint(6) DEFAULT NULL,
  `ButcherReg` varchar(30) DEFAULT NULL,
  `Lot` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`NumCard`),
  KEY `EarTag` (`EarTag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `card`
--

CREATE TABLE `card` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(32) NOT NULL DEFAULT '',
  `Enabled` tinyint(1) NOT NULL DEFAULT '0',
  `URL` varchar(128) NOT NULL DEFAULT '',
  `User` varchar(32) NOT NULL DEFAULT '',
  `Password` varchar(128) NOT NULL DEFAULT '',
  `WaitPaid` char(1) NOT NULL DEFAULT '0',
  `Status` char(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `cardreports`
--

CREATE TABLE `cardreports` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `UUID` varchar(48) NOT NULL,
  `DatTim` datetime NOT NULL,
  `Terminal` varchar(32) NOT NULL DEFAULT '',
  `Type` char(1) NOT NULL DEFAULT '-',
  `TextReport` text NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `UUID` (`UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `cash`
--

CREATE TABLE `cash` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Scope` smallint(6) DEFAULT '0',
  `Number` int(11) DEFAULT '0',
  `Name` varchar(32) NOT NULL DEFAULT '',
  `IP` int(10) unsigned NOT NULL DEFAULT '0',
  `User` varchar(32) NOT NULL DEFAULT '',
  `Password` varchar(32) NOT NULL DEFAULT '',
  `WaitPaid` char(1) NOT NULL DEFAULT '0',
  `Status` char(1) NOT NULL DEFAULT '0',
  `Oper` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IP` (`IP`),
  UNIQUE KEY `Scope` (`Scope`,`Number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `cashdrawer`
--

CREATE TABLE `cashdrawer` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Scale` int(11) NOT NULL DEFAULT '0',
  `Vendor` int(11) NOT NULL DEFAULT '0',
  `DatTim` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `CashIn` decimal(10,2) NOT NULL DEFAULT '0.00',
  `CashOut` decimal(10,2) NOT NULL DEFAULT '0.00',
  `CashIP` int(10) unsigned NOT NULL DEFAULT '0',
  `Text` varchar(64) NOT NULL DEFAULT '',
  `CashStatus` char(1) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '-',
  `CashOperId` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `cfgparams`
--

CREATE TABLE `cfgparams` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `ParamKey` varchar(128) NOT NULL DEFAULT '',
  `ParamValue` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `ParamKey` (`ParamKey`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;

--
-- Table structure for table `cfgsystem`
--

CREATE TABLE `cfgsystem` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `ParamKey` varchar(128) NOT NULL DEFAULT '',
  `ParamValue` varchar(128) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `ParamKey` (`ParamKey`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

--
-- Table structure for table `clientconfiguration`
--

CREATE TABLE `clientconfiguration` (
  `TypeNumber` int(11) NOT NULL,
  `Name` varchar(20) NOT NULL DEFAULT '',
  `Icon` varchar(16) NOT NULL DEFAULT 'face',
  `InUse` tinyint(1) DEFAULT '0',
  `IPv4` int(10) unsigned NOT NULL DEFAULT '0',
  `Port` smallint(5) unsigned NOT NULL DEFAULT '1900',
  `ConnectTimeout` tinyint(3) unsigned NOT NULL DEFAULT '2',
  `TckSend` tinyint(1) DEFAULT '1',
  `TckWaitShort` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `TckWaitLong` tinyint(3) unsigned NOT NULL DEFAULT '5',
  `TckTimeout` tinyint(3) unsigned NOT NULL DEFAULT '2',
  `CmdRequest` tinyint(1) DEFAULT '1',
  `CmdWaitShort` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `CmdWaitLong` tinyint(3) unsigned NOT NULL DEFAULT '60',
  `CmdTimeout` tinyint(3) unsigned NOT NULL DEFAULT '2',
  `DateRequest` tinyint(1) DEFAULT '1',
  `DateTimeRequest` int(10) unsigned NOT NULL DEFAULT '3600',
  `UseQMatic` tinyint(1) DEFAULT '0',
  `URL` varchar(255) NOT NULL DEFAULT 'http://demo.q-matic.es:9094',
  `UseRemote` tinyint(1) DEFAULT '0',
  `URLRemote` varchar(255) DEFAULT '',
  `Company` int(11) DEFAULT '0',
  `Shop` int(11) DEFAULT '0',
  PRIMARY KEY (`TypeNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `code128`
--

CREATE TABLE `code128` (
  `Counter` int(11) NOT NULL DEFAULT '0',
  `Code1` varchar(32) DEFAULT '',
  `Code2` varchar(32) DEFAULT '',
  `Code3` varchar(32) DEFAULT '',
  `Code4` varchar(32) DEFAULT '',
  `Code5` varchar(32) DEFAULT '',
  `Code6` varchar(32) DEFAULT '',
  `Code7` varchar(32) DEFAULT '',
  `Code8` varchar(32) DEFAULT '',
  `Code9` varchar(32) DEFAULT '',
  `Code10` varchar(32) DEFAULT '',
  PRIMARY KEY (`Counter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `counterfamilies`
--

CREATE TABLE `counterfamilies` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `CounterCode` int(11) NOT NULL,
  `FamilyIndex` int(11) NOT NULL DEFAULT '1',
  `FamilyCode` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `idcofam` (`CounterCode`,`FamilyIndex`),
  CONSTRAINT `fkcofam` FOREIGN KEY (`CounterCode`) REFERENCES `counters` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

--
-- Table structure for table `countergoals`
--

CREATE TABLE `countergoals` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `OnDate` date NOT NULL,
  `Counter` int(11) DEFAULT '0',
  `Amount` decimal(10,2) DEFAULT '0.00',
  `AMCustomers` int(11) DEFAULT '0',
  `PMCustomers` int(11) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `idx` (`OnDate`,`Counter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `counters`
--

CREATE TABLE `counters` (
  `Code` int(11) NOT NULL,
  `Name` varchar(64) DEFAULT '',
  `Icon` varchar(127) DEFAULT NULL,
  `MyGroup` int(11) NOT NULL DEFAULT '0',
  `TurnProfile` varchar(3) DEFAULT '',
  `TurnProfileGroup` varchar(3) DEFAULT '',
  `TurnIdentifier` char(1) DEFAULT '',
  `Turn` int(10) unsigned DEFAULT '1',
  `TurnsPending` int(10) unsigned NOT NULL DEFAULT '0',
  `TurnDatTim` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TurnLast` int(10) unsigned NOT NULL DEFAULT '0',
  `TurnLastTime` time NOT NULL DEFAULT '00:00:00',
  `TurnDelay` int(11) NOT NULL DEFAULT '0',
  `TurnOnTime` tinyint(1) NOT NULL DEFAULT '0',
  `TurnMonitor` tinyint(1) DEFAULT '1',
  `MarkCaptured` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When close ticket, mark as captured',
  `Description` varchar(127) DEFAULT '',
  `Text1` varchar(255) DEFAULT '',
  `Text2` varchar(255) DEFAULT '',
  `Text3` varchar(255) DEFAULT '',
  `Text4` varchar(255) DEFAULT '',
  `Text5` varchar(255) DEFAULT '',
  `Text6` varchar(255) DEFAULT '',
  `Text7` varchar(255) DEFAULT '',
  `Text8` varchar(255) DEFAULT '',
  `Text9` varchar(255) DEFAULT '',
  `Text10` varchar(255) DEFAULT '',
  PRIMARY KEY (`Code`),
  UNIQUE KEY `Code` (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `countries`
--

CREATE TABLE `countries` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Locale` char(2) NOT NULL DEFAULT '',
  `Code` int(11) NOT NULL DEFAULT '0',
  `Alpha2` char(2) NOT NULL DEFAULT '',
  `Name` varchar(127) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Locale` (`Locale`,`Code`),
  KEY `Name` (`Name`(19))
) ENGINE=InnoDB AUTO_INCREMENT=997 DEFAULT CHARSET=utf8;

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TIN` varchar(16) NOT NULL DEFAULT '',
  `Name` varchar(255) NOT NULL DEFAULT '',
  `Type` char(1) NOT NULL DEFAULT 'C',
  `Address` varchar(255) DEFAULT '',
  `City` varchar(255) DEFAULT '',
  `Postalcode` varchar(80) DEFAULT '',
  `CountryCode` smallint(6) NOT NULL DEFAULT '0',
  `Country` varchar(80) DEFAULT '',
  `WEB` varchar(255) DEFAULT '',
  `Phone` varchar(80) DEFAULT '',
  `Fax` varchar(80) DEFAULT '',
  `MobilePhone` varchar(80) DEFAULT '',
  `eMail` varchar(80) DEFAULT '',
  `SendMail` char(1) NOT NULL DEFAULT 'N',
  `Text` varchar(255) DEFAULT '',
  `Discount` decimal(4,2) DEFAULT '0.00',
  `SimplifiedInvoice` tinyint(1) DEFAULT '0',
  `TicketOrder` tinyint(1) DEFAULT '0',
  `Points` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `TIN` (`TIN`),
  KEY `Name` (`Name`(19))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `datalogger`
--

CREATE TABLE `datalogger` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` int(11) NOT NULL DEFAULT '0',
  `Scale` int(11) NOT NULL DEFAULT '0',
  `DatTim` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `Message` text NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;

--
-- Table structure for table `ean128`
--

CREATE TABLE `ean128` (
  `Counter` int(11) NOT NULL DEFAULT '0',
  `Code1` varchar(32) DEFAULT '',
  `Code2` varchar(32) DEFAULT '',
  `Code3` varchar(32) DEFAULT '',
  `Code4` varchar(32) DEFAULT '',
  `Code5` varchar(32) DEFAULT '',
  `Code6` varchar(32) DEFAULT '',
  `Code7` varchar(32) DEFAULT '',
  `Code8` varchar(32) DEFAULT '',
  `Code9` varchar(32) DEFAULT '',
  `Code10` varchar(32) DEFAULT '',
  PRIMARY KEY (`Counter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `erasetickets`
--

CREATE TABLE `erasetickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` char(1) DEFAULT 'T',
  `DatTim` datetime DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Type` (`Type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `families`
--

CREATE TABLE `families` (
  `Code` int(11) NOT NULL,
  `Name` varchar(54) NOT NULL DEFAULT '',
  `Icon` varchar(127) DEFAULT '',
  `DefaultIcon` varchar(127) DEFAULT '',
  `IsBovine` tinyint(1) DEFAULT '0',
  `Label` varchar(64) NOT NULL,
  PRIMARY KEY (`Code`),
  KEY `Name` (`Name`(19))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `fiscal`
--

CREATE TABLE `fiscal` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(32) NOT NULL DEFAULT '',
  `Enabled` tinyint(1) NOT NULL DEFAULT '0',
  `URL` varchar(128) NOT NULL DEFAULT '',
  `User` varchar(32) NOT NULL DEFAULT '',
  `Password` varchar(128) NOT NULL DEFAULT '',
  `WaitPaid` char(1) NOT NULL DEFAULT '0',
  `Status` char(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `fiscalrec`
--

CREATE TABLE `fiscalrec` (
  `IdHTicket` int(11) NOT NULL,
  `Status` char(1) DEFAULT '-',
  `TID` int(11) DEFAULT '0',
  `StartD` datetime DEFAULT NULL,
  `FinishD` datetime DEFAULT NULL,
  `QRCode` varchar(2048) DEFAULT '',
  `TicketLines` varchar(2048) DEFAULT '',
  `SentStatus` smallint(6) NOT NULL DEFAULT '0',
  `SentCode` smallint(6) NOT NULL DEFAULT '0',
  `SentDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SentID` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`IdHTicket`),
  CONSTRAINT `fiscalrec_ibfk_1` FOREIGN KEY (`IdHTicket`) REFERENCES `htickets` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `globalvendorlogged`
--

CREATE TABLE `globalvendorlogged` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IPServer` varchar(80) NOT NULL DEFAULT '',
  `DatTim` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `Counter` int(11) NOT NULL DEFAULT '0',
  `ActiveKeys` int(11) NOT NULL DEFAULT '1',
  `Vendor` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IPServer` (`IPServer`,`Counter`,`Vendor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `hangedmarks`
--

CREATE TABLE `hangedmarks` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Identifier` char(1) NOT NULL DEFAULT '0',
  `Description` varchar(127) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Identifier` (`Identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `hcustomerorders`
--

CREATE TABLE `hcustomerorders` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdHTicket` int(11) DEFAULT NULL,
  `Number` varchar(16) NOT NULL,
  `Section` decimal(3,0) DEFAULT '0',
  `UseSection` tinyint(1) DEFAULT '0',
  `OrderDate` date NOT NULL DEFAULT '0000-00-00',
  `TIN` varchar(16) NOT NULL DEFAULT '',
  `Customer` varchar(127) NOT NULL DEFAULT '',
  `Phone` varchar(20) NOT NULL DEFAULT '',
  `DeliveryDate` date NOT NULL DEFAULT '0000-00-00',
  `DeliveryHour` time NOT NULL DEFAULT '00:00:00',
  `PreparationDateLimit` date NOT NULL DEFAULT '0000-00-00',
  `PreparationHourLimit` time NOT NULL DEFAULT '00:00:00',
  `Observations` varchar(255) NOT NULL DEFAULT '',
  `Origin` varchar(32) NOT NULL DEFAULT '',
  `StartDateTime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `ReopenDateTime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `NumberHTicket` int(11) NOT NULL DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Vendor` int(11) NOT NULL DEFAULT '0',
  `AddedLines` int(11) DEFAULT '0',
  `NetAmount` decimal(10,2) DEFAULT '0.00',
  `TotalWeight` decimal(12,3) DEFAULT '0.000',
  `TotalUnits` int(11) DEFAULT '0',
  `Packages` int(11) NOT NULL DEFAULT '1',
  `DatTim` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Status` char(1) NOT NULL DEFAULT '0',
  `Captured` char(1) NOT NULL DEFAULT '0',
  `RemoteInstance` varchar(255) DEFAULT '',
  `RemoteCounterChallenge` varchar(255) DEFAULT '',
  `RemoteOrderText` text,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `hctor_idx` (`Number`,`Section`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `htickets`
--

CREATE TABLE `htickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdNetHticket` int(11) DEFAULT '0',
  `NetStat` char(1) DEFAULT '',
  `Captured` char(1) DEFAULT '',
  `CapturedDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `tckType` char(1) DEFAULT NULL,
  `Status` char(1) DEFAULT NULL,
  `Number` int(11) DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Vendor` int(11) DEFAULT NULL,
  `TurnPrefix` char(1) DEFAULT '0',
  `Turn` int(10) unsigned DEFAULT '0',
  `TurnId` decimal(20,0) DEFAULT '0',
  `TurnDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TurnOnTime` tinyint(1) NOT NULL DEFAULT '0',
  `SectionItem` int(11) DEFAULT '0',
  `UseSectionItem` tinyint(1) DEFAULT '0',
  `HVATCode` decimal(1,0) unsigned NOT NULL DEFAULT '0',
  `NumLines` int(11) DEFAULT '0',
  `AddedLines` int(11) DEFAULT '0',
  `GrossAmount` decimal(10,2) DEFAULT '0.00',
  `NetAmount` decimal(10,2) DEFAULT '0.00',
  `TotalWeight` decimal(12,3) DEFAULT '0.000',
  `TotalUnits` int(11) DEFAULT '0',
  `NegativeLines` int(11) DEFAULT '0',
  `NegativeAmount` decimal(10,2) DEFAULT '0.00',
  `CanceledLines` int(11) DEFAULT '0',
  `CanceledAmount` decimal(10,2) DEFAULT '0.00',
  `Packages` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `EAN13` char(13) NOT NULL DEFAULT '',
  `Code128` varchar(32) NOT NULL DEFAULT '',
  `StartDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimesPrinted` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `DatTim` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReloadFrom` int(11) DEFAULT '0',
  `ReloadScale` int(11) NOT NULL DEFAULT '0',
  `ReloadDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReloadTicketNumber` int(11) NOT NULL DEFAULT '0',
  `ReloadtckType` char(1) DEFAULT '',
  `ReloadTo` int(11) DEFAULT '0',
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `CustomerName` varchar(255) NOT NULL DEFAULT '',
  `CustomerAddress` varchar(255) NOT NULL DEFAULT '',
  `CustomerCity` varchar(255) NOT NULL DEFAULT '',
  `CustomerPostalCode` varchar(80) NOT NULL DEFAULT '',
  `CustomerCountryCode` smallint(6) NOT NULL DEFAULT '0',
  `Points` int(11) NOT NULL DEFAULT '0',
  `PointsExtra` int(11) NOT NULL DEFAULT '0',
  `PointsDiscount` int(11) NOT NULL DEFAULT '0',
  `PointsAmount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `PointsChanged` int(11) NOT NULL DEFAULT '0',
  `OrderNumber` varchar(16) DEFAULT '',
  `SimplifiedInvoice` tinyint(1) DEFAULT '0',
  `Invoice` varchar(20) NOT NULL DEFAULT '',
  `InvoiceDate` date DEFAULT '0000-00-00',
  `tckDiscount` decimal(4,2) DEFAULT '0.00',
  `ParkedNumber` int(11) DEFAULT '0',
  `NeedCopy` tinyint(1) DEFAULT '0',
  `CashStatus` char(1) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '-',
  `CashOperId` int(11) DEFAULT '0',
  `CashAmount` decimal(10,2) DEFAULT '0.00',
  `CashIP` int(10) unsigned NOT NULL DEFAULT '0',
  `CardStatus` char(1) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '-',
  `CardOperId` varchar(64) NOT NULL DEFAULT '',
  `CardAmount` decimal(10,2) DEFAULT '0.00',
  `CardId` varchar(32) NOT NULL DEFAULT '',
  `TIN` varchar(80) NOT NULL DEFAULT '',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  KEY `Vendor` (`Vendor`),
  KEY `Invoice` (`Invoice`),
  KEY `datim_idx` (`DatTim`),
  KEY `OrderNumber` (`OrderNumber`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `inventory`
--

CREATE TABLE `inventory` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` int(11) DEFAULT '0',
  `PrintDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Code` int(11) DEFAULT NULL,
  `SectionItem` int(11) DEFAULT '0',
  `Name` varchar(127) NOT NULL,
  `DateTime` datetime DEFAULT NULL,
  `Weight` decimal(5,3) DEFAULT NULL,
  `Units` int(11) DEFAULT NULL,
  `Status` smallint(6) DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `invoicedetails`
--

CREATE TABLE `invoicedetails` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdInvoice` int(11) DEFAULT NULL,
  `IdHTicket` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IdInvoice` (`IdInvoice`,`IdHTicket`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `invoices`
--

CREATE TABLE `invoices` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` varchar(20) NOT NULL DEFAULT '',
  `OriginalNumber` varchar(20) NOT NULL DEFAULT '',
  `Date` date DEFAULT '0000-00-00',
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `Type` char(1) NOT NULL DEFAULT '0',
  `Reason` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  KEY `Number` (`Number`),
  KEY `OriginalNumber` (`OriginalNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemgroupkeys`
--

CREATE TABLE `itemgroupkeys` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `NumKey` decimal(2,0) NOT NULL,
  `AboveSection` decimal(2,0) DEFAULT '0',
  `Section` decimal(2,0) DEFAULT '0',
  `SubSection` decimal(2,0) DEFAULT '0',
  `Family` decimal(2,0) DEFAULT '0',
  `SubFamily` decimal(2,0) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `idx_` (`NumKey`,`AboveSection`,`Section`,`SubSection`,`Family`,`SubFamily`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemgroupkeystext`
--

CREATE TABLE `itemgroupkeystext` (
  `NumKey` decimal(2,0) NOT NULL,
  `Text` varchar(64) DEFAULT '',
  `Icon` varchar(127) DEFAULT '',
  PRIMARY KEY (`NumKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemhabitual`
--

CREATE TABLE `itemhabitual` (
  `Position` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `Code` int(11) NOT NULL,
  PRIMARY KEY (`Position`),
  KEY `fk_1` (`Code`),
  CONSTRAINT `itemhabitual_ibfk_1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemlinkcommon`
--

CREATE TABLE `itemlinkcommon` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `NumCard` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `commonlink_idx` (`Code`,`NumCard`),
  CONSTRAINT `ilc_ibfk1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemmiddleweights`
--

CREATE TABLE `itemmiddleweights` (
  `Code` int(11) NOT NULL,
  `MiddleWeight` decimal(7,3) DEFAULT '0.000',
  `Units` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`Code`),
  CONSTRAINT `imwitem` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `itemofferdates`
--

CREATE TABLE `itemofferdates` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `StartDate` date NOT NULL,
  `EndDate` date DEFAULT NULL,
  `PriceSet` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`),
  CONSTRAINT `iod_items` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemofferpricerates`
--

CREATE TABLE `itemofferpricerates` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `Rate` decimal(1,0) NOT NULL DEFAULT '0',
  `Price` decimal(8,2) NOT NULL DEFAULT '0.00',
  `Step` decimal(7,3) NOT NULL DEFAULT '0.000',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `idx_rate` (`Code`,`Rate`,`Step`),
  KEY `iop_rates` (`Rate`),
  CONSTRAINT `iop_dates` FOREIGN KEY (`Code`) REFERENCES `itemofferdates` (`Code`) ON DELETE CASCADE,
  CONSTRAINT `iop_rates` FOREIGN KEY (`Rate`) REFERENCES `pricerates` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itempricerates`
--

CREATE TABLE `itempricerates` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `Rate` decimal(1,0) NOT NULL DEFAULT '1',
  `Price` decimal(8,2) NOT NULL DEFAULT '0.00',
  `Step` decimal(7,3) NOT NULL DEFAULT '0.000',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `idx_rate` (`Code`,`Rate`,`Step`),
  KEY `Rate` (`Rate`),
  CONSTRAINT `itempricerates_ibfk_1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE,
  CONSTRAINT `itempricerates_ibfk_2` FOREIGN KEY (`Rate`) REFERENCES `pricerates` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `items`
--

CREATE TABLE `items` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `Inactive` tinyint(1) DEFAULT '0',
  `Name` varchar(127) NOT NULL DEFAULT '',
  `ShortName` varchar(64) DEFAULT '',
  `Text` text,
  `Text1` text,
  `Text2` text,
  `Text3` text,
  `Text4` text,
  `Text5` text,
  `Family` int(11) DEFAULT '0',
  `SubFamily` decimal(2,0) DEFAULT '0',
  `FamilyOrder` int(11) DEFAULT '0',
  `OnKey` tinyint(1) DEFAULT '1',
  `AboveSection` decimal(2,0) DEFAULT '0',
  `Section` decimal(3,0) DEFAULT '0',
  `SubSection` decimal(2,0) DEFAULT '0',
  `WorkingMode` varchar(20) DEFAULT '',
  `Price` decimal(8,2) DEFAULT '0.00',
  `Offer` tinyint(1) DEFAULT '0',
  `Discount` decimal(4,2) DEFAULT '0.00',
  `SaleForm` smallint(6) DEFAULT '1',
  `PLU` int(11) DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `VAT` decimal(1,0) unsigned DEFAULT '0',
  `VATExemption` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `EAN13` varchar(13) DEFAULT '',
  `Expiring` smallint(6) DEFAULT '0',
  `BestBefore` smallint(6) DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT '0.000',
  `Label` varchar(64) DEFAULT '',
  `Label2` varchar(64) DEFAULT '-',
  `Nutrition` int(11) DEFAULT '0',
  `EAN13Print` varchar(12) DEFAULT '',
  `AI01Prefix` varchar(1) NOT NULL DEFAULT '',
  `AI240` varchar(30) NOT NULL DEFAULT '',
  `PacketExt` char(1) NOT NULL DEFAULT '-',
  `IsFrozen` tinyint(1) DEFAULT '0',
  `Icon` varchar(127) DEFAULT '',
  `Icon2` varchar(127) DEFAULT '',
  `QLevel` varchar(16) DEFAULT '',
  `Mixed` smallint(6) DEFAULT '0',
  `MixedWeight` decimal(7,3) DEFAULT '0.000',
  `CommonCard` int(11) DEFAULT '0',
  `PatternNumberPieces` int(11) NOT NULL DEFAULT '0',
  `PatternWeightPieces` decimal(9,5) NOT NULL DEFAULT '0.00000',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`),
  KEY `Name` (`Name`(19)),
  KEY `ide_fmor` (`Family`,`FamilyOrder`)
) ENGINE=InnoDB AUTO_INCREMENT=671 DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemsallergenicons`
--

CREATE TABLE `itemsallergenicons` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `Allergen` varchar(16) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `iai_codal` (`Code`,`Allergen`),
  KEY `iai_allergen` (`Allergen`),
  CONSTRAINT `iai_allergen` FOREIGN KEY (`Allergen`) REFERENCES `allergenicons` (`Allergen`) ON DELETE CASCADE,
  CONSTRAINT `iai_codes` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemschangepoints`
--

CREATE TABLE `itemschangepoints` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `Points` int(11) NOT NULL DEFAULT '0',
  `Quantity` decimal(5,3) NOT NULL DEFAULT '1.000',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`),
  CONSTRAINT `icpitem` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemsean128`
--

CREATE TABLE `itemsean128` (
  `Code` int(11) NOT NULL,
  `AI91` varchar(128) NOT NULL DEFAULT '',
  `AI92` varchar(128) NOT NULL DEFAULT '',
  `AI93` varchar(128) NOT NULL DEFAULT '',
  `AI94` varchar(128) NOT NULL DEFAULT '',
  `AI95` varchar(128) NOT NULL DEFAULT '',
  `AI96` varchar(128) NOT NULL DEFAULT '',
  `AI97` varchar(128) NOT NULL DEFAULT '',
  `AI98` varchar(128) NOT NULL DEFAULT '',
  `AI99` varchar(128) NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`),
  CONSTRAINT `i128item` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemsean13`
--

CREATE TABLE `itemsean13` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `EAN13` decimal(13,0) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `EAN13` (`EAN13`),
  KEY `iean13_item` (`Code`),
  CONSTRAINT `iean13_item` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemsextrapoints`
--

CREATE TABLE `itemsextrapoints` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `Points` int(11) NOT NULL DEFAULT '0',
  `Quantity` decimal(5,3) NOT NULL DEFAULT '1.000',
  `FromQuantity` decimal(5,3) NOT NULL DEFAULT '0.000',
  `Proportional` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`),
  CONSTRAINT `iepitem` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemsformats`
--

CREATE TABLE `itemsformats` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `Format` varchar(32) COLLATE utf8_bin NOT NULL,
  `Price` decimal(8,2) DEFAULT '0.00',
  `Expiring` smallint(6) DEFAULT '0',
  `BestBefore` smallint(6) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`,`Format`),
  CONSTRAINT `ifitem` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `itemtextbonus`
--

CREATE TABLE `itemtextbonus` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) NOT NULL,
  `NumLine` smallint(6) DEFAULT '1',
  `Text` varchar(40) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `itemtext_idx` (`Code`,`NumLine`),
  CONSTRAINT `itemtextbonus_ibfk_1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `itemtextcommon`
--

CREATE TABLE `itemtextcommon` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `NumCard` int(11) NOT NULL,
  `NumLine` smallint(6) DEFAULT '1',
  `Text` varchar(100) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `commontext_idx` (`NumCard`,`NumLine`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lcustomerorders`
--

CREATE TABLE `lcustomerorders` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `OrderNumber` varchar(16) NOT NULL,
  `Item` int(11) NOT NULL DEFAULT '0',
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `Name` varchar(127) NOT NULL DEFAULT '',
  `Section` decimal(3,0) DEFAULT '0',
  `Quantity` decimal(8,3) DEFAULT '0.000',
  `Format` varchar(10) NOT NULL DEFAULT '',
  `Price` decimal(8,2) NOT NULL DEFAULT '0.00',
  `Remark` varchar(255) NOT NULL DEFAULT '',
  `Weight` decimal(7,3) DEFAULT '0.000',
  `Units` int(11) DEFAULT '0',
  `Amount` decimal(10,2) DEFAULT '0.00',
  `Status` char(1) NOT NULL DEFAULT '0',
  `DatTim` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `ReplacedBy` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `lctor_idx` (`OrderNumber`,`Item`,`ItemFormat`),
  KEY `lhkey` (`OrderNumber`,`Section`),
  CONSTRAINT `lhkey` FOREIGN KEY (`OrderNumber`, `Section`) REFERENCES `hcustomerorders` (`Number`, `Section`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localcfgforms`
--

CREATE TABLE `localcfgforms` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Form` varchar(20) NOT NULL,
  `Widget` varchar(32) NOT NULL,
  `Value` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Form` (`Form`,`Widget`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localcfgkeyboard`
--

CREATE TABLE `localcfgkeyboard` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `ParamKey` varchar(128) NOT NULL DEFAULT '',
  `ParamValue` varchar(128) NOT NULL DEFAULT 'none',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `ParamKey` (`ParamKey`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localcfgparams`
--

CREATE TABLE `localcfgparams` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `ParamKey` varchar(128) NOT NULL DEFAULT '',
  `ParamValue` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `ParamKey` (`ParamKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localcfgscale`
--

CREATE TABLE `localcfgscale` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `ParamKey` varchar(128) NOT NULL DEFAULT '',
  `ParamValue` varchar(128) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `ParamKey` (`ParamKey`)
) ENGINE=InnoDB AUTO_INCREMENT=323 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localcomm`
--

CREATE TABLE `localcomm` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `dev` varchar(16) NOT NULL DEFAULT '',
  `rxprefix` int(11) DEFAULT '2',
  `rxsufix` int(11) DEFAULT '13',
  `txprefix` int(11) DEFAULT '2',
  `txsufix` int(11) DEFAULT '3',
  `txhandshake` int(11) DEFAULT '1',
  `rxhandshake` int(11) DEFAULT '1',
  `baudrate` int(11) DEFAULT '9600',
  `parity` char(1) DEFAULT 'N',
  `stopbits` tinyint(4) DEFAULT '1',
  `bytesize` tinyint(4) DEFAULT '8',
  `port` int(11) DEFAULT '0',
  `remoteip` varchar(15) DEFAULT '000.000.000.000',
  `remoteport` int(11) DEFAULT '0',
  `protocol` varchar(32) DEFAULT 'src_eachconversion',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `dev` (`dev`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localcountries`
--

CREATE TABLE `localcountries` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` int(11) DEFAULT NULL,
  `Alpha2` char(2) NOT NULL,
  `Name` varchar(127) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Alpha2` (`Alpha2`),
  UNIQUE KEY `Code` (`Code`),
  KEY `Name` (`Name`(19))
) ENGINE=InnoDB AUTO_INCREMENT=249 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localdatalogger`
--

CREATE TABLE `localdatalogger` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` int(11) DEFAULT NULL,
  `DatTim` datetime DEFAULT NULL,
  `Message` varchar(255) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localerasetickets`
--

CREATE TABLE `localerasetickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` char(1) DEFAULT 'T',
  `DatTim` datetime DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Type` (`Type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localfiscalrec`
--

CREATE TABLE `localfiscalrec` (
  `IdHTicket` int(11) NOT NULL,
  `Status` char(1) DEFAULT '-',
  `TID` int(11) DEFAULT '0',
  `StartD` datetime DEFAULT NULL,
  `FinishD` datetime DEFAULT NULL,
  `QRCode` varchar(2048) DEFAULT '',
  `TicketLines` varchar(2048) DEFAULT '',
  `SentStatus` smallint(6) NOT NULL DEFAULT '0',
  `SentCode` smallint(6) NOT NULL DEFAULT '0',
  `SentDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SentID` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`IdHTicket`),
  CONSTRAINT `localfiscalrec_ibfk_1` FOREIGN KEY (`IdHTicket`) REFERENCES `localhtickets` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localhtickets`
--

CREATE TABLE `localhtickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdNetHticket` int(11) DEFAULT '0',
  `NetStat` char(1) DEFAULT '',
  `Captured` char(1) DEFAULT '',
  `CapturedDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `tckType` char(1) DEFAULT NULL,
  `Status` char(1) DEFAULT NULL,
  `Number` int(11) DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Vendor` int(11) DEFAULT NULL,
  `TurnPrefix` char(1) DEFAULT '0',
  `Turn` int(10) unsigned DEFAULT '0',
  `TurnId` decimal(20,0) DEFAULT '0',
  `TurnDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TurnOnTime` tinyint(1) NOT NULL DEFAULT '0',
  `SectionItem` int(11) DEFAULT '0',
  `UseSectionItem` tinyint(1) DEFAULT '0',
  `HVATCode` decimal(1,0) unsigned NOT NULL DEFAULT '0',
  `NumLines` int(11) DEFAULT '0',
  `AddedLines` int(11) DEFAULT '0',
  `GrossAmount` decimal(10,2) DEFAULT '0.00',
  `NetAmount` decimal(10,2) DEFAULT '0.00',
  `TotalWeight` decimal(12,3) DEFAULT '0.000',
  `TotalUnits` int(11) DEFAULT '0',
  `NegativeLines` int(11) DEFAULT '0',
  `NegativeAmount` decimal(10,2) DEFAULT '0.00',
  `CanceledLines` int(11) DEFAULT '0',
  `CanceledAmount` decimal(10,2) DEFAULT '0.00',
  `Packages` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `EAN13` char(13) NOT NULL DEFAULT '',
  `Code128` varchar(32) NOT NULL DEFAULT '',
  `StartDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimesPrinted` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `DatTim` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReloadFrom` int(11) DEFAULT '0',
  `ReloadScale` int(11) NOT NULL DEFAULT '0',
  `ReloadDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReloadTicketNumber` int(11) NOT NULL DEFAULT '0',
  `ReloadtckType` char(1) DEFAULT '',
  `ReloadTo` int(11) DEFAULT '0',
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `CustomerName` varchar(255) NOT NULL DEFAULT '',
  `CustomerAddress` varchar(255) NOT NULL DEFAULT '',
  `CustomerCity` varchar(255) NOT NULL DEFAULT '',
  `CustomerPostalCode` varchar(80) NOT NULL DEFAULT '',
  `CustomerCountryCode` smallint(6) NOT NULL DEFAULT '0',
  `Points` int(11) NOT NULL DEFAULT '0',
  `PointsExtra` int(11) NOT NULL DEFAULT '0',
  `PointsDiscount` int(11) NOT NULL DEFAULT '0',
  `PointsAmount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `PointsChanged` int(11) NOT NULL DEFAULT '0',
  `OrderNumber` varchar(16) DEFAULT '',
  `SimplifiedInvoice` tinyint(1) DEFAULT '0',
  `Invoice` varchar(20) NOT NULL DEFAULT '',
  `InvoiceDate` date DEFAULT '0000-00-00',
  `tckDiscount` decimal(4,2) DEFAULT '0.00',
  `ParkedNumber` int(11) DEFAULT '0',
  `NeedCopy` tinyint(1) DEFAULT '0',
  `CashStatus` char(1) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '-',
  `CashOperId` int(11) DEFAULT '0',
  `CashAmount` decimal(10,2) DEFAULT '0.00',
  `CashIP` int(10) unsigned NOT NULL DEFAULT '0',
  `CardStatus` char(1) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '-',
  `CardOperId` varchar(64) NOT NULL DEFAULT '',
  `CardAmount` decimal(10,2) DEFAULT '0.00',
  `CardId` varchar(32) NOT NULL DEFAULT '',
  `TIN` varchar(80) NOT NULL DEFAULT '',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  KEY `Vendor` (`Vendor`),
  KEY `Invoice` (`Invoice`),
  KEY `IdNetHticket` (`IdNetHticket`),
  KEY `datim_idx` (`DatTim`),
  KEY `OrderNumber` (`OrderNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localints`
--

CREATE TABLE `localints` (
  `i` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`i`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localitemgroupkeyschanges`
--

CREATE TABLE `localitemgroupkeyschanges` (
  `NumKey` decimal(2,0) NOT NULL,
  PRIMARY KEY (`NumKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `locallicenses`
--

CREATE TABLE `locallicenses` (
  `IdProduct` varchar(16) NOT NULL,
  `Scope` char(1) NOT NULL DEFAULT 'S',
  `ProductName` varchar(255) NOT NULL DEFAULT '',
  `Holder` varchar(255) NOT NULL DEFAULT '',
  `License` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`IdProduct`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localltickets`
--

CREATE TABLE `localltickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdHTicket` int(11) DEFAULT NULL,
  `NetStat` char(1) DEFAULT 'L',
  `lineType` smallint(6) DEFAULT NULL,
  `SaleForm` smallint(6) DEFAULT NULL,
  `SaleFormEx` char(1) DEFAULT '-',
  `Item` int(11) DEFAULT NULL,
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `Name` varchar(127) NOT NULL DEFAULT '',
  `Section` decimal(3,0) NOT NULL DEFAULT '0',
  `Family` int(11) DEFAULT '0',
  `ItemAccess` int(11) DEFAULT '0',
  `LineScale` int(11) NOT NULL DEFAULT '0',
  `LineVendor` int(11) NOT NULL DEFAULT '0',
  `LineDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SourceKey` char(1) NOT NULL DEFAULT '0',
  `PriceChanged` tinyint(1) NOT NULL DEFAULT '0',
  `VATCode` decimal(1,0) unsigned NOT NULL DEFAULT '0',
  `VATPercent` decimal(4,2) unsigned NOT NULL DEFAULT '0.00',
  `VATExemption` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `Weight` decimal(7,3) DEFAULT NULL,
  `NumberPieces` int(11) NOT NULL DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT '0.000',
  `TTare` char(1) DEFAULT '',
  `lineDiscount` decimal(4,2) DEFAULT NULL,
  `Price` decimal(8,2) DEFAULT NULL,
  `Amount` decimal(10,2) DEFAULT NULL,
  `BaseAmount` decimal(13,5) DEFAULT '0.00000',
  `Points` int(11) NOT NULL DEFAULT '0',
  `BovineCard` smallint(3) DEFAULT NULL,
  `EarTag` varchar(30) DEFAULT NULL,
  `BovineLot` varchar(20) DEFAULT NULL,
  `FreezingDate` date DEFAULT NULL,
  `TicketDiscount` decimal(4,2) DEFAULT '0.00',
  `PrintScale` int(11) NOT NULL DEFAULT '0',
  `PrintDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `PrintTicketNumber` int(11) NOT NULL DEFAULT '0',
  `PrinttckType` char(1) DEFAULT '',
  `ReloadScale` int(11) NOT NULL DEFAULT '0',
  `ReloadDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReloadTicketNumber` int(11) NOT NULL DEFAULT '0',
  `ReloadtckType` char(1) DEFAULT '',
  `ReloadTo` int(11) DEFAULT '0',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  KEY `IdHTicket` (`IdHTicket`),
  CONSTRAINT `localltickets_ibfk_1` FOREIGN KEY (`IdHTicket`) REFERENCES `localhtickets` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localnumtickets`
--

CREATE TABLE `localnumtickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` binary(1) DEFAULT 'T',
  `Identifier` varchar(16) NOT NULL DEFAULT '',
  `Number` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Identifier` (`Identifier`,`Type`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localpacketlabels`
--

CREATE TABLE `localpacketlabels` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Captured` char(1) DEFAULT '',
  `CapturedDateTime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `Number` int(11) DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Vendor` int(11) DEFAULT NULL,
  `lineType` smallint(6) DEFAULT NULL,
  `Item` int(11) DEFAULT NULL,
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `SaleForm` smallint(6) DEFAULT NULL,
  `SaleFormEx` char(1) DEFAULT '-',
  `Weight` decimal(7,3) DEFAULT NULL,
  `NumberPieces` int(10) unsigned NOT NULL DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT '0.000',
  `TTare` char(1) DEFAULT '',
  `Price` decimal(8,2) DEFAULT NULL,
  `lineDiscount` decimal(4,2) DEFAULT NULL,
  `Amount` decimal(10,2) DEFAULT NULL,
  `PacketExt` char(1) NOT NULL DEFAULT '-',
  `BovineCard` int(11) DEFAULT NULL,
  `EarTag` varchar(30) DEFAULT NULL,
  `BovineLot` varchar(20) DEFAULT NULL,
  `FreezingDate` date DEFAULT NULL,
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `DatTim` datetime DEFAULT NULL,
  `EAN13` varchar(13) NOT NULL DEFAULT '',
  `Code128` varchar(32) NOT NULL DEFAULT '',
  `Lot` varchar(20) NOT NULL DEFAULT '',
  `Ordinal` int(10) unsigned DEFAULT NULL,
  `OrderNumber` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localpacketpresets`
--

CREATE TABLE `localpacketpresets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Vendor` int(11) DEFAULT NULL,
  `Level` smallint(6) DEFAULT NULL,
  `Type` smallint(6) DEFAULT NULL,
  `Value` decimal(6,3) DEFAULT NULL,
  `Number` int(11) DEFAULT '1',
  `ItemTotal` int(11) DEFAULT '0',
  `LowerLabels` int(10) unsigned NOT NULL DEFAULT '0',
  `TotalUnits` int(10) unsigned NOT NULL DEFAULT '0',
  `TotalWeight` decimal(12,3) unsigned NOT NULL DEFAULT '0.000',
  `TotalNumberPieces` int(10) unsigned NOT NULL DEFAULT '0',
  `TotalAmount` decimal(12,2) unsigned NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Vendor` (`Vendor`,`Level`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localpaytickets`
--

CREATE TABLE `localpaytickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdHTicket` int(11) DEFAULT NULL,
  `PayMethod` int(11) DEFAULT NULL,
  `Delivered` decimal(10,2) DEFAULT '0.00',
  PRIMARY KEY (`Id`),
  KEY `IdHTicket` (`IdHTicket`),
  CONSTRAINT `localpaytickets_ibfk_1` FOREIGN KEY (`IdHTicket`) REFERENCES `localhtickets` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localplukeyschanges`
--

CREATE TABLE `localplukeyschanges` (
  `Section` int(11) NOT NULL,
  `Board` int(11) NOT NULL,
  `PLUKey` int(11) NOT NULL,
  `Code` int(11) NOT NULL,
  PRIMARY KEY (`Section`,`Board`,`PLUKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localsservicelabels`
--

CREATE TABLE `localsservicelabels` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Captured` char(1) DEFAULT '',
  `CapturedDateTime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `Number` int(11) DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Vendor` int(11) DEFAULT NULL,
  `lineType` smallint(6) DEFAULT NULL,
  `Item` int(11) DEFAULT NULL,
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `SaleForm` smallint(6) DEFAULT NULL,
  `SaleFormEx` char(1) DEFAULT '-',
  `Weight` decimal(7,3) DEFAULT NULL,
  `NumberPieces` int(10) unsigned NOT NULL DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT '0.000',
  `TTare` char(1) DEFAULT '',
  `Price` decimal(8,2) DEFAULT NULL,
  `lineDiscount` decimal(4,2) DEFAULT NULL,
  `Amount` decimal(10,2) DEFAULT NULL,
  `PacketExt` char(1) NOT NULL DEFAULT '-',
  `BovineCard` int(11) DEFAULT NULL,
  `EarTag` varchar(30) DEFAULT NULL,
  `BovineLot` varchar(20) DEFAULT NULL,
  `FreezingDate` date DEFAULT NULL,
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `DatTim` datetime DEFAULT NULL,
  `EAN13` varchar(13) NOT NULL DEFAULT '',
  `Code128` varchar(32) NOT NULL DEFAULT '',
  `Lot` varchar(20) NOT NULL DEFAULT '',
  `Ordinal` int(10) unsigned DEFAULT NULL,
  `OrderNumber` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localstatus`
--

CREATE TABLE `localstatus` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Version` smallint(6) DEFAULT '23',
  `AppVersion` varchar(16) DEFAULT '',
  `Language` varchar(31) NOT NULL DEFAULT '',
  `EraseTickets` tinyint(1) DEFAULT '0',
  `RemoveScale` tinyint(1) DEFAULT '0',
  `CheckCounters` tinyint(1) DEFAULT '0',
  `CheckCountersKeys` tinyint(1) DEFAULT '0',
  `CheckSections` tinyint(1) DEFAULT '0',
  `CheckFamilies` tinyint(1) DEFAULT '0',
  `CheckCounterFamilies` tinyint(1) DEFAULT '0',
  `CheckItemGroupKeysText` tinyint(1) DEFAULT '0',
  `RefreshTouchsel` tinyint(1) DEFAULT '0',
  `ResizeTouch` tinyint(1) DEFAULT '0',
  `CheckTareCodes` tinyint(1) DEFAULT '0',
  `CheckScripts` tinyint(1) DEFAULT '0',
  `CheckQuickKeys` tinyint(1) DEFAULT '0',
  `LocalTickets` tinyint(1) DEFAULT '0',
  `AdvertisingChanged` tinyint(1) DEFAULT '0',
  `CheckCustomerOrders` tinyint(1) DEFAULT '0',
  `CheckCash` tinyint(1) DEFAULT '0',
  `CheckTurn` tinyint(1) DEFAULT '0',
  `CheckCard` tinyint(1) DEFAULT '0',
  `CheckTotalDaily` tinyint(1) DEFAULT '1',
  `CheckTotalScaleFamilies` tinyint(1) DEFAULT '1',
  `CheckShortcuts` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Table structure for table `localtreeboard`
--

CREATE TABLE `localtreeboard` (
  `Board` int(11) NOT NULL COMMENT 'Numeric table on keyboard. Without gaps',
  `Source1` int(11) NOT NULL DEFAULT '0' COMMENT 'Real value. May be gaps',
  `Source2` int(11) NOT NULL DEFAULT '0',
  `Source3` int(11) NOT NULL DEFAULT '0',
  `Source4` int(11) NOT NULL DEFAULT '0',
  `Source5` int(11) NOT NULL DEFAULT '0',
  `Level1` int(11) NOT NULL DEFAULT '0' COMMENT 'Position value. Without gaps',
  `Level2` int(11) NOT NULL DEFAULT '0',
  `Level3` int(11) NOT NULL DEFAULT '0',
  `Level4` int(11) NOT NULL DEFAULT '0',
  `Level5` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Board`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localvendorchanges`
--

CREATE TABLE `localvendorchanges` (
  `Id` int(11) NOT NULL,
  `Vendor` int(11) DEFAULT NULL,
  `tck` char(1) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localvendorkeys`
--

CREATE TABLE `localvendorkeys` (
  `Counter` int(11) DEFAULT NULL,
  `VendorKey` int(11) DEFAULT NULL,
  `Vendor` int(11) NOT NULL,
  PRIMARY KEY (`Vendor`),
  UNIQUE KEY `Counter` (`Counter`,`VendorKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localvendorkeyschanges`
--

CREATE TABLE `localvendorkeyschanges` (
  `VendorKey` int(11) NOT NULL,
  `Vendor` int(11) DEFAULT '0',
  `VendorRelease` int(11) DEFAULT '0',
  `Name` varchar(64) DEFAULT NULL,
  `Icon` varchar(127) NOT NULL DEFAULT '',
  PRIMARY KEY (`VendorKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localvendorpacket`
--

CREATE TABLE `localvendorpacket` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Vendor` int(11) DEFAULT NULL,
  `Auto` tinyint(1) DEFAULT NULL,
  `ClearStart` tinyint(1) DEFAULT NULL,
  `Repetitions` smallint(6) DEFAULT '0',
  `Copies` smallint(6) DEFAULT '0',
  `EAN13` char(1) DEFAULT '1',
  `PacketExt` char(1) NOT NULL DEFAULT '-',
  `BovineCard` int(11) DEFAULT NULL,
  `EarTag` varchar(30) DEFAULT NULL,
  `BovineLot` varchar(20) DEFAULT NULL,
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `PresetON` tinyint(1) DEFAULT '0',
  `Item` int(11) DEFAULT '0',
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `SaleForm` smallint(6) DEFAULT NULL,
  `MixedMode` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `ManualWeight` decimal(7,3) DEFAULT NULL,
  `Price` decimal(8,2) DEFAULT NULL,
  `Units` int(10) unsigned NOT NULL DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT NULL,
  `Discount` decimal(4,2) DEFAULT NULL,
  `Lot` varchar(20) NOT NULL DEFAULT '',
  `Ordinal` int(10) unsigned DEFAULT NULL,
  `OrderNumber` varchar(30) NOT NULL DEFAULT '',
  `ExpiringDate` date NOT NULL DEFAULT '0000-00-00',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Vendor` (`Vendor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localvendorregister`
--

CREATE TABLE `localvendorregister` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Vendor` int(11) DEFAULT NULL,
  `RegisterDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `RegisterSend` smallint(6) DEFAULT '0',
  `ReleaseDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReleaseSend` smallint(6) DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `localworkingmodes`
--

CREATE TABLE `localworkingmodes` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `WorkingMode` varchar(20) NOT NULL DEFAULT '',
  `ParamName` varchar(32) NOT NULL,
  `ParamValue` varchar(200) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `WorkingMode` (`WorkingMode`,`ParamName`)
) ENGINE=InnoDB AUTO_INCREMENT=574 DEFAULT CHARSET=utf8;

--
-- Table structure for table `ltickets`
--

CREATE TABLE `ltickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdHTicket` int(11) DEFAULT NULL,
  `NetStat` char(1) DEFAULT 'N',
  `lineType` smallint(6) DEFAULT NULL,
  `SaleForm` smallint(6) DEFAULT NULL,
  `SaleFormEx` char(1) DEFAULT '-',
  `Item` int(11) DEFAULT NULL,
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `Name` varchar(127) NOT NULL DEFAULT '',
  `Section` decimal(3,0) NOT NULL DEFAULT '0',
  `Family` int(11) DEFAULT '0',
  `ItemAccess` int(11) DEFAULT '0',
  `LineScale` int(11) NOT NULL DEFAULT '0',
  `LineVendor` int(11) NOT NULL DEFAULT '0',
  `LineDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SourceKey` char(1) NOT NULL DEFAULT '0',
  `PriceChanged` tinyint(1) NOT NULL DEFAULT '0',
  `VATCode` decimal(1,0) unsigned NOT NULL DEFAULT '0',
  `VATPercent` decimal(4,2) unsigned NOT NULL DEFAULT '0.00',
  `VATExemption` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `Weight` decimal(7,3) DEFAULT NULL,
  `NumberPieces` int(11) NOT NULL DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT '0.000',
  `TTare` char(1) DEFAULT '',
  `lineDiscount` decimal(4,2) DEFAULT NULL,
  `Price` decimal(8,2) DEFAULT NULL,
  `Amount` decimal(10,2) DEFAULT NULL,
  `BaseAmount` decimal(13,5) DEFAULT '0.00000' COMMENT 'Amount with discounts without tax',
  `Points` int(11) NOT NULL DEFAULT '0',
  `BovineCard` smallint(3) DEFAULT NULL,
  `EarTag` varchar(30) DEFAULT NULL,
  `BovineLot` varchar(20) DEFAULT NULL,
  `FreezingDate` date DEFAULT NULL,
  `TicketDiscount` decimal(4,2) DEFAULT '0.00',
  `PrintScale` int(11) NOT NULL DEFAULT '0',
  `PrintDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `PrintTicketNumber` int(11) NOT NULL DEFAULT '0',
  `PrinttckType` char(1) DEFAULT '',
  `ReloadScale` int(11) NOT NULL DEFAULT '0',
  `ReloadDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReloadTicketNumber` int(11) NOT NULL DEFAULT '0',
  `ReloadtckType` char(1) DEFAULT '',
  `ReloadTo` int(11) DEFAULT '0',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  KEY `IdHTicket` (`IdHTicket`),
  CONSTRAINT `ltickets_ibfk_1` FOREIGN KEY (`IdHTicket`) REFERENCES `htickets` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

--
-- Table structure for table `netstatus`
--

CREATE TABLE `netstatus` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `NetworkName` varchar(50) NOT NULL DEFAULT '',
  `NetworkPrivateName` varchar(80) NOT NULL DEFAULT '',
  `MCast_port` decimal(4,0) NOT NULL DEFAULT '2335',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `numberingtickets`
--

CREATE TABLE `numberingtickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` binary(1) DEFAULT 'T',
  `Serial` varchar(14) NOT NULL DEFAULT '',
  `Fiscal` varchar(14) NOT NULL DEFAULT '',
  `Numbering` smallint(6) DEFAULT '0',
  `NumberingLocal` tinyint(1) DEFAULT '0',
  `StartNumber` int(10) unsigned DEFAULT '1',
  `MaximumNumber` int(10) unsigned DEFAULT '9999',
  `MaximumInvoice` int(10) unsigned DEFAULT '9999',
  `ResetNumber` tinyint(1) DEFAULT '0',
  `SaveMode` char(1) DEFAULT '',
  `ClearStart` tinyint(1) DEFAULT '0',
  `ClearStartDays` smallint(6) DEFAULT '0',
  `ClearStartResetNumber` tinyint(1) DEFAULT '0',
  `ClearStartDaily` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Type` (`Type`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `numinvoices`
--

CREATE TABLE `numinvoices` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `MaxNumber` int(11) DEFAULT NULL,
  `Number` int(11) DEFAULT NULL,
  `Serial` varchar(16) NOT NULL DEFAULT '',
  `RecNumber` int(11) DEFAULT NULL,
  `RecSerial` varchar(16) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `numtickets`
--

CREATE TABLE `numtickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` binary(1) DEFAULT 'T',
  `Identifier` varchar(16) NOT NULL DEFAULT '',
  `Number` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Identifier` (`Identifier`,`Type`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Table structure for table `nutrition`
--

CREATE TABLE `nutrition` (
  `card` int(11) NOT NULL,
  `portion_weight` float DEFAULT '0',
  `energy_kj_100` float DEFAULT '0',
  `energy_kj_portion` float DEFAULT '0',
  `energy_kcal_100` float DEFAULT '0',
  `energy_kcal_portion` float DEFAULT '0',
  `fat_100` float DEFAULT '0',
  `fat_portion` float DEFAULT '0',
  `saturates_100` float DEFAULT '0',
  `saturates_portion` float DEFAULT '0',
  `mono_unsaturates_100` float DEFAULT '0',
  `mono_unsaturates_portion` float DEFAULT '0',
  `polyunsaturates_100` float DEFAULT '0',
  `polyunsaturates_portion` float DEFAULT '0',
  `carbohydrate_100` float DEFAULT '0',
  `carbohydrate_portion` float DEFAULT '0',
  `sugars_100` float DEFAULT '0',
  `sugars_portion` float DEFAULT '0',
  `polyols_100` float DEFAULT '0',
  `polyols_portion` float DEFAULT '0',
  `starch_100` float DEFAULT '0',
  `starch_portion` float DEFAULT '0',
  `fibre_100` float DEFAULT '0',
  `fibre_portion` float DEFAULT '0',
  `protein_100` float DEFAULT '0',
  `protein_portion` float DEFAULT '0',
  `salt_100` float DEFAULT '0',
  `salt_portion` float DEFAULT '0',
  PRIMARY KEY (`card`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `overunderlevels`
--

CREATE TABLE `overunderlevels` (
  `Code` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(16) NOT NULL,
  `LowWeight` decimal(7,3) NOT NULL DEFAULT '0.000',
  `HighWeight` decimal(7,3) NOT NULL DEFAULT '0.000',
  PRIMARY KEY (`Code`),
  UNIQUE KEY `Name` (`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `packetlabels`
--

CREATE TABLE `packetlabels` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Captured` char(1) DEFAULT '',
  `CapturedDateTime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `Number` int(11) DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Vendor` int(11) DEFAULT NULL,
  `lineType` smallint(6) DEFAULT NULL,
  `Item` int(11) DEFAULT NULL,
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `SaleForm` smallint(6) DEFAULT NULL,
  `SaleFormEx` char(1) DEFAULT '-',
  `Weight` decimal(7,3) DEFAULT NULL,
  `NumberPieces` int(10) unsigned NOT NULL DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT '0.000',
  `TTare` char(1) DEFAULT '',
  `Price` decimal(8,2) DEFAULT NULL,
  `lineDiscount` decimal(4,2) DEFAULT NULL,
  `Amount` decimal(10,2) DEFAULT NULL,
  `PacketExt` char(1) NOT NULL DEFAULT '-',
  `BovineCard` int(11) DEFAULT NULL,
  `EarTag` varchar(30) DEFAULT NULL,
  `BovineLot` varchar(20) DEFAULT NULL,
  `FreezingDate` date DEFAULT NULL,
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `DatTim` datetime DEFAULT NULL,
  `EAN13` varchar(13) NOT NULL DEFAULT '',
  `Code128` varchar(32) NOT NULL DEFAULT '',
  `Lot` varchar(20) NOT NULL DEFAULT '',
  `Ordinal` int(10) unsigned DEFAULT NULL,
  `OrderNumber` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `paymethods`
--

CREATE TABLE `paymethods` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Identifier` tinyint(3) unsigned NOT NULL,
  `Name` varchar(64) NOT NULL,
  `InUse` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Identifier` (`Identifier`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Table structure for table `paytickets`
--

CREATE TABLE `paytickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IdHTicket` int(11) DEFAULT NULL,
  `PayMethod` int(11) DEFAULT NULL,
  `Delivered` decimal(10,2) DEFAULT '0.00',
  PRIMARY KEY (`Id`),
  KEY `IdHTicket` (`IdHTicket`),
  CONSTRAINT `paytickets_ibfk_1` FOREIGN KEY (`IdHTicket`) REFERENCES `htickets` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Table structure for table `pktfishery`
--

CREATE TABLE `pktfishery` (
  `Code` int(11) NOT NULL,
  `CommercialDesignation` varchar(127) NOT NULL DEFAULT '',
  `SCName` varchar(127) NOT NULL,
  `FAO3Alfa` varchar(3) NOT NULL DEFAULT '',
  `Lot` varchar(20) NOT NULL,
  `Date` date DEFAULT NULL,
  `Production` varchar(127) NOT NULL,
  `VesselName` varchar(127) NOT NULL DEFAULT '',
  `VesselID` varchar(127) NOT NULL DEFAULT '',
  `Catched` varchar(127) NOT NULL,
  `FAOArea` varchar(10) NOT NULL DEFAULT '',
  `CatchDate` date NOT NULL DEFAULT '0000-00-00',
  `LandingDate` date NOT NULL DEFAULT '0000-00-00',
  `FishingGear` varchar(127) NOT NULL DEFAULT '',
  `FishingISSCFG` varchar(10) NOT NULL DEFAULT '',
  `Presentation` varchar(127) NOT NULL,
  `Defrosted` tinyint(1) DEFAULT '0',
  `Size` decimal(1,0) DEFAULT NULL,
  `Freshness` varchar(10) NOT NULL,
  `Issuer` varchar(255) NOT NULL,
  `IssuerTIN` varchar(16) NOT NULL DEFAULT '',
  `IssuerAddress` varchar(255) NOT NULL DEFAULT '',
  `Descriptive` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`Code`),
  CONSTRAINT `pktfishery_ibfk_1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `pktgeneric`
--

CREATE TABLE `pktgeneric` (
  `NumCard` smallint(3) NOT NULL,
  `Lot` varchar(20) NOT NULL,
  `OriginLand` smallint(6) DEFAULT NULL,
  `Region` varchar(255) NOT NULL,
  `SanitaryReg1` varchar(30) DEFAULT NULL,
  `Date1` date DEFAULT NULL,
  `SanitaryReg2` varchar(30) DEFAULT NULL,
  `Date2` date DEFAULT NULL,
  `Descriptive` varchar(255) DEFAULT NULL,
  `Text1` varchar(255) DEFAULT NULL,
  `Text2` varchar(255) DEFAULT NULL,
  `Text3` varchar(255) DEFAULT NULL,
  `Text4` varchar(255) DEFAULT NULL,
  `Text5` varchar(255) DEFAULT NULL,
  `Text6` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`NumCard`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `pktvegetables`
--

CREATE TABLE `pktvegetables` (
  `Code` int(11) NOT NULL,
  `Variety` varchar(127) NOT NULL,
  `Lot` varchar(20) NOT NULL,
  `OriginLand` smallint(6) DEFAULT NULL,
  `Region` varchar(255) NOT NULL,
  `Quality` varchar(127) NOT NULL,
  `Size` decimal(2,0) DEFAULT NULL,
  `Issuer` varchar(255) NOT NULL,
  `Descriptive` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`Code`),
  CONSTRAINT `pktvegetables_ibfk_1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `playlists`
--

CREATE TABLE `playlists` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(31) DEFAULT NULL,
  `Type` smallint(6) DEFAULT '0',
  `PlayIndex` int(11) DEFAULT NULL,
  `FileName` varchar(127) NOT NULL,
  `ExposureTime` smallint(6) DEFAULT '0',
  `TransitionTime` smallint(6) DEFAULT '0',
  `TransitionType` smallint(6) DEFAULT '0',
  `StartDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `EndDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Status` char(1) DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Name` (`Name`,`PlayIndex`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `plugins`
--

CREATE TABLE `plugins` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(16) NOT NULL,
  `Enabled` tinyint(1) DEFAULT '0',
  `Attr` text NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Name` (`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `plukeys`
--

CREATE TABLE `plukeys` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Section` int(11) DEFAULT NULL,
  `Board` int(11) DEFAULT NULL,
  `PLUKey` int(11) DEFAULT NULL,
  `Code` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Section` (`Section`,`Board`,`PLUKey`),
  KEY `Code` (`Code`)
) ENGINE=InnoDB AUTO_INCREMENT=107 DEFAULT CHARSET=utf8;

--
-- Table structure for table `plukeysfile`
--

CREATE TABLE `plukeysfile` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Source1` int(11) NOT NULL DEFAULT '0',
  `Source2` int(11) NOT NULL DEFAULT '0',
  `Source3` int(11) NOT NULL DEFAULT '0',
  `Source4` int(11) NOT NULL DEFAULT '0',
  `Source5` int(11) NOT NULL DEFAULT '0',
  `PLU` int(11) NOT NULL DEFAULT '0',
  `Name` varchar(64) NOT NULL DEFAULT '',
  `Icon` varchar(96) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `idx_keys` (`Source1`,`Source2`,`Source3`,`Source4`,`Source5`,`PLU`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `pricerates`
--

CREATE TABLE `pricerates` (
  `Code` decimal(1,0) NOT NULL,
  `Name` varchar(64) NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `providers`
--

CREATE TABLE `providers` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TIN` varchar(16) NOT NULL DEFAULT '',
  `Name` varchar(255) NOT NULL DEFAULT '',
  `Address` varchar(255) DEFAULT '',
  `City` varchar(255) DEFAULT '',
  `Postalcode` varchar(80) DEFAULT '',
  `CountryCode` smallint(6) NOT NULL DEFAULT '0',
  `Country` varchar(80) DEFAULT '',
  `WEB` varchar(255) DEFAULT '',
  `Phone` varchar(80) DEFAULT '',
  `Fax` varchar(80) DEFAULT '',
  `MobilePhone` varchar(80) DEFAULT '',
  `eMail` varchar(80) DEFAULT '',
  `Text` varchar(255) DEFAULT '',
  `Discount` decimal(4,2) DEFAULT '0.00',
  `SimplifiedInvoice` tinyint(1) DEFAULT '0',
  `TicketOrder` tinyint(1) DEFAULT '0',
  `Points` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `TIN` (`TIN`),
  KEY `Name` (`Name`(19))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `qlevels`
--

CREATE TABLE `qlevels` (
  `Code` varchar(16) NOT NULL,
  `Icon` varchar(64) NOT NULL,
  `Description` varchar(127) NOT NULL,
  PRIMARY KEY (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `qrfields`
--

CREATE TABLE `qrfields` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `SourceTable` char(1) NOT NULL DEFAULT 'H',
  `Name` varchar(127) NOT NULL DEFAULT '',
  `FieldIndex` decimal(2,0) NOT NULL DEFAULT '1',
  `FieldType` char(1) NOT NULL DEFAULT 'F',
  `Size` decimal(2,0) NOT NULL DEFAULT '1',
  `Format` varchar(127) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `qrf_idx` (`SourceTable`,`FieldIndex`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

--
-- Table structure for table `quickkeys`
--

CREATE TABLE `quickkeys` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` smallint(6) DEFAULT '1',
  `Name` varchar(32) NOT NULL DEFAULT '',
  `Label` varchar(64) DEFAULT '',
  `Vendor` int(11) DEFAULT '0',
  `EAN13` char(13) NOT NULL DEFAULT '',
  `Code128` decimal(2,0) DEFAULT '0',
  `UserText` varchar(32) NOT NULL DEFAULT '',
  `UseForm` int(11) DEFAULT '0',
  `Transaction` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `scales`
--

CREATE TABLE `scales` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `MAC` varchar(17) NOT NULL,
  `IP` varchar(16) NOT NULL,
  `Number` int(11) NOT NULL DEFAULT '0',
  `Counter` int(11) NOT NULL DEFAULT '0',
  `Name` varchar(64) NOT NULL DEFAULT '',
  `Type` char(1) DEFAULT NULL,
  `AppVersion` varchar(16) DEFAULT '',
  `ScaleVersion` varchar(32) NOT NULL DEFAULT '',
  `SerialNumber` varchar(10) DEFAULT '',
  `System` varchar(32) DEFAULT '',
  `Keyboard` varchar(128) NOT NULL DEFAULT '',
  `WorkingMode` varchar(128) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `MAC` (`MAC`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;

--
-- Table structure for table `scheduler`
--

CREATE TABLE `scheduler` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL DEFAULT '',
  `ScaleType` int(11) DEFAULT '0',
  `ScaleNumber` int(11) DEFAULT '0',
  `Task` smallint(6) DEFAULT '0',
  `Type` smallint(6) DEFAULT '0',
  `DatTim` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `LastExec` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `TaskParam` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `scripts`
--

CREATE TABLE `scripts` (
  `Code` int(11) NOT NULL,
  `Description` varchar(127) DEFAULT '',
  `Script` text,
  PRIMARY KEY (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `sections`
--

CREATE TABLE `sections` (
  `Code` decimal(3,0) NOT NULL,
  `Name` varchar(20) NOT NULL DEFAULT '',
  `Icon` varchar(127) DEFAULT NULL,
  `IsFrozen` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Code`),
  KEY `Name` (`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `selfctl`
--

CREATE TABLE `selfctl` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` int(11) DEFAULT '0',
  `PrintDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Relation` int(11) DEFAULT NULL,
  `Code` int(11) DEFAULT NULL,
  `SectionItem` int(11) DEFAULT '0',
  `Name` varchar(127) NOT NULL,
  `DateTime` datetime DEFAULT NULL,
  `Weight` decimal(5,3) DEFAULT NULL,
  `Units` int(11) DEFAULT NULL,
  `Status` smallint(6) DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `Relation` (`Relation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `selfctloper`
--

CREATE TABLE `selfctloper` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `OpType` char(1) DEFAULT '0',
  `Code` smallint(6) DEFAULT '0',
  `Name` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `OpType` (`OpType`,`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `selfctlrelations`
--

CREATE TABLE `selfctlrelations` (
  `IdRel` int(11) NOT NULL,
  `Source` smallint(6) DEFAULT '0',
  `Type` smallint(6) DEFAULT '0',
  `Corrective` smallint(6) DEFAULT '0',
  `Name` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`IdRel`),
  UNIQUE KEY `Source` (`Source`,`Type`,`Corrective`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `shoporder`
--

CREATE TABLE `shoporder` (
  `Code` int(11) NOT NULL,
  `Name` varchar(127) NOT NULL,
  `SaleForm` smallint(6) DEFAULT '1',
  `Weight` decimal(12,3) DEFAULT '0.000',
  `Units` int(11) DEFAULT '0',
  `Observations` varchar(127) DEFAULT NULL,
  `DatTim` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`Code`),
  CONSTRAINT `shoporder_ibfk_1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `shortcuts`
--

CREATE TABLE `shortcuts` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` decimal(2,0) NOT NULL,
  `Based` varchar(16) NOT NULL DEFAULT 'sales',
  `LKFunction` varchar(24) NOT NULL DEFAULT '',
  `Param` varchar(54) NOT NULL DEFAULT '',
  `Icon` varchar(127) NOT NULL DEFAULT '',
  `UseDual` tinyint(1) DEFAULT '1',
  `DualField` varchar(54) NOT NULL DEFAULT '',
  `KeyField1` varchar(24) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `sc_codbas` (`Code`,`Based`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `sservicelabels`
--

CREATE TABLE `sservicelabels` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Captured` char(1) DEFAULT '',
  `CapturedDateTime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `Number` int(11) DEFAULT '0',
  `Counter` int(11) DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Vendor` int(11) DEFAULT NULL,
  `lineType` smallint(6) DEFAULT NULL,
  `Item` int(11) DEFAULT NULL,
  `ItemFormat` varchar(32) NOT NULL DEFAULT '',
  `SaleForm` smallint(6) DEFAULT NULL,
  `SaleFormEx` char(1) DEFAULT '-',
  `Weight` decimal(7,3) DEFAULT NULL,
  `NumberPieces` int(10) unsigned NOT NULL DEFAULT '0',
  `Tare` decimal(7,3) DEFAULT '0.000',
  `TTare` char(1) DEFAULT '',
  `Price` decimal(8,2) DEFAULT NULL,
  `lineDiscount` decimal(4,2) DEFAULT NULL,
  `Amount` decimal(10,2) DEFAULT NULL,
  `PacketExt` char(1) NOT NULL DEFAULT '-',
  `BovineCard` int(11) DEFAULT NULL,
  `EarTag` varchar(30) DEFAULT NULL,
  `BovineLot` varchar(20) DEFAULT NULL,
  `FreezingDate` date DEFAULT NULL,
  `Customer` varchar(16) NOT NULL DEFAULT '',
  `DatTim` datetime DEFAULT NULL,
  `EAN13` varchar(13) NOT NULL DEFAULT '',
  `Code128` varchar(32) NOT NULL DEFAULT '',
  `Lot` varchar(20) NOT NULL DEFAULT '',
  `Ordinal` int(10) unsigned DEFAULT NULL,
  `OrderNumber` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `status`
--

CREATE TABLE `status` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Version` smallint(6) DEFAULT '23',
  `AppVersion` varchar(16) DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Table structure for table `stock`
--

CREATE TABLE `stock` (
  `Code` int(11) NOT NULL,
  `Name` varchar(127) NOT NULL,
  `SaleForm` smallint(6) DEFAULT '1',
  `Weight` decimal(12,3) DEFAULT '0.000',
  `Units` int(11) DEFAULT '0',
  `Inventory_Weight` decimal(12,3) DEFAULT '0.000',
  `Inventory_Units` int(11) DEFAULT '0',
  `Shrink_Weight` decimal(12,3) DEFAULT '0.000',
  `Shrink_Units` int(11) DEFAULT '0',
  `Return_Weight` decimal(12,3) DEFAULT '0.000',
  `Return_Units` int(11) DEFAULT '0',
  PRIMARY KEY (`Code`),
  CONSTRAINT `stock_ibfk_1` FOREIGN KEY (`Code`) REFERENCES `items` (`Code`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `tarecodes`
--

CREATE TABLE `tarecodes` (
  `Code` decimal(2,0) NOT NULL,
  `Tare` decimal(7,3) DEFAULT '0.000',
  `Name` varchar(20) NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `totaldaily`
--

CREATE TABLE `totaldaily` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` char(1) DEFAULT '',
  `NetStat` char(1) DEFAULT '',
  `Date` date NOT NULL,
  `Number` int(10) unsigned DEFAULT '0',
  `PrintChgCounter` int(10) unsigned DEFAULT '1',
  `Printing` tinyint(3) unsigned DEFAULT '0',
  `Printed` tinyint(3) unsigned DEFAULT '0',
  `Tickets` int(11) DEFAULT '1',
  `TotalLines` int(11) DEFAULT '0',
  `TotalAmount` decimal(12,2) DEFAULT '0.00',
  `TotalDiscount` decimal(12,2) DEFAULT '0.00',
  `TotalWeight` decimal(12,3) DEFAULT '0.000',
  `TotalUnits` int(11) DEFAULT '0',
  `NegativeLines` int(11) DEFAULT '0',
  `NegativeAmount` decimal(12,2) DEFAULT '0.00',
  `CanceledLines` int(11) DEFAULT '0',
  `CanceledAmount` decimal(12,2) DEFAULT '0.00',
  `ReloadedTickets` int(11) NOT NULL DEFAULT '0',
  `TotalReloadedAmount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `Invoices` int(11) DEFAULT '0',
  `InvoiceAmount` decimal(12,2) DEFAULT '0.00',
  `InvoicesRefund` int(11) NOT NULL DEFAULT '0',
  `InvoiceAmountRefund` decimal(12,2) NOT NULL DEFAULT '0.00',
  `AccumulatedAmount` decimal(12,2) DEFAULT '0.00',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `dailycnt_idx` (`Date`,`Type`,`NetStat`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `totalpaytickets`
--

CREATE TABLE `totalpaytickets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` char(1) DEFAULT 'T',
  `NetStat` char(1) DEFAULT '',
  `Date` date NOT NULL,
  `PayMethod` int(11) DEFAULT NULL,
  `Delivered` decimal(12,2) DEFAULT '0.00',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `paytck_idx` (`Date`,`Type`,`NetStat`,`PayMethod`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `totalperpetual`
--

CREATE TABLE `totalperpetual` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` char(1) DEFAULT '',
  `NetStat` char(1) DEFAULT '',
  `Date` date NOT NULL,
  `Tickets` int(11) DEFAULT '1',
  `TotalLines` int(11) DEFAULT '0',
  `TotalAmount` decimal(12,2) DEFAULT '0.00',
  `TotalDiscount` decimal(12,2) DEFAULT '0.00',
  `TotalWeight` decimal(12,3) DEFAULT '0.000',
  `TotalUnits` int(11) DEFAULT '0',
  `NegativeLines` int(11) DEFAULT '0',
  `NegativeAmount` decimal(12,2) DEFAULT '0.00',
  `CanceledLines` int(11) DEFAULT '0',
  `CanceledAmount` decimal(12,2) DEFAULT '0.00',
  `ReloadedTickets` int(11) NOT NULL DEFAULT '0',
  `TotalReloadedAmount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `Invoices` int(11) DEFAULT '0',
  `InvoiceAmount` decimal(12,2) DEFAULT '0.00',
  `InvoicesRefund` int(11) NOT NULL DEFAULT '0',
  `InvoiceAmountRefund` decimal(12,2) NOT NULL DEFAULT '0.00',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `perpetual_idx` (`Type`,`NetStat`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

--
-- Table structure for table `totalscalefamilies`
--

CREATE TABLE `totalscalefamilies` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Date` date NOT NULL,
  `Number` int(10) unsigned DEFAULT '0',
  `Scale` int(11) DEFAULT '0',
  `Family` int(11) DEFAULT '0',
  `PrintChgCounter` int(10) unsigned DEFAULT '1',
  `Printing` tinyint(3) unsigned DEFAULT '0',
  `Printed` tinyint(3) unsigned DEFAULT '0',
  `TotalWeight` decimal(12,3) DEFAULT '0.000',
  `TotalUnits` int(11) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `total_idx` (`Date`,`Scale`,`Family`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Table structure for table `totalvat`
--

CREATE TABLE `totalvat` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` char(1) DEFAULT 'T',
  `NetStat` char(1) DEFAULT '',
  `Date` date NOT NULL,
  `Code` decimal(1,0) unsigned NOT NULL,
  `Percentage` decimal(4,2) DEFAULT NULL,
  `Amount` decimal(12,2) DEFAULT '0.00',
  `Base` decimal(12,2) DEFAULT '0.00',
  `Tax` decimal(12,2) DEFAULT '0.00',
  `Checksum` varchar(1024) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `totalvat_idx` (`Date`,`Type`,`NetStat`,`Code`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `trademark`
--

CREATE TABLE `trademark` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `CO_Name` varchar(255) DEFAULT '',
  `Description` varchar(255) DEFAULT '',
  `Business` varchar(255) DEFAULT '',
  `Slogan` varchar(255) DEFAULT '',
  `Headquarter` varchar(255) DEFAULT '',
  `CO_WEB` varchar(255) DEFAULT '',
  `Shop_Name` varchar(255) DEFAULT '',
  `Address` varchar(255) DEFAULT '',
  `City` varchar(255) DEFAULT '',
  `Postalcode` varchar(80) DEFAULT '',
  `CountryCode` smallint(6) NOT NULL DEFAULT '0',
  `Country` varchar(80) DEFAULT '',
  `Phone` varchar(80) DEFAULT '',
  `Fax` varchar(80) DEFAULT '',
  `MobilePhone` varchar(80) DEFAULT '',
  `eMail` varchar(80) DEFAULT '',
  `TIN` varchar(80) DEFAULT '',
  `Shop_WEB` varchar(255) DEFAULT '',
  `Text1` varchar(255) DEFAULT '',
  `Text2` varchar(255) DEFAULT '',
  `Text3` varchar(255) DEFAULT '',
  `Text4` varchar(255) DEFAULT '',
  `Text5` varchar(255) DEFAULT '',
  `Text6` varchar(255) DEFAULT '',
  `Text7` varchar(255) DEFAULT '',
  `Text8` varchar(255) DEFAULT '',
  `Text9` varchar(255) DEFAULT '',
  `Text10` varchar(255) DEFAULT '',
  `Icon` varchar(127) DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Table structure for table `turn`
--

CREATE TABLE `turn` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(32) NOT NULL DEFAULT '',
  `IP` int(10) unsigned NOT NULL DEFAULT '0',
  `URL` varchar(255) NOT NULL DEFAULT '',
  `Login` varchar(255) NOT NULL DEFAULT '',
  `Enabled` tinyint(1) DEFAULT '0',
  `User` varchar(32) NOT NULL DEFAULT '',
  `Password` varchar(32) NOT NULL DEFAULT '',
  `Status` char(1) NOT NULL DEFAULT '0',
  `MaxNumberRange` int(11) NOT NULL DEFAULT '99',
  `ResetNumberType` smallint(6) NOT NULL DEFAULT '0',
  `LastResetDate` datetime DEFAULT NULL,
  `DisplayType` smallint(6) NOT NULL DEFAULT '0',
  `TicketType` smallint(6) NOT NULL DEFAULT '0',
  `PrintLogo` tinyint(1) NOT NULL DEFAULT '0',
  `ShopId` smallint(6) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `turns`
--

CREATE TABLE `turns` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Counter` int(11) NOT NULL,
  `Number` int(11) NOT NULL DEFAULT '0',
  `Status` smallint(6) NOT NULL DEFAULT '0',
  `ServeDatetime` datetime DEFAULT NULL,
  `OpenDateTime` datetime DEFAULT NULL,
  `CloseDateTime` datetime DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `turnswaiting`
--

CREATE TABLE `turnswaiting` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Counter` decimal(3,0) DEFAULT '0',
  `DayWeek` decimal(1,0) DEFAULT '0',
  `TimeLimit` int(11) NOT NULL DEFAULT '0',
  `TurnsLimit` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `idx_twt` (`Counter`,`DayWeek`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `User` varchar(16) NOT NULL DEFAULT '',
  `Password` varchar(31) NOT NULL,
  `Name` varchar(127) NOT NULL,
  `LevelLab` tinyint(1) DEFAULT '0',
  `LevelAdmin` tinyint(1) DEFAULT '0',
  `LevelConfig` tinyint(1) DEFAULT '0',
  `LevelProg` tinyint(1) DEFAULT '0',
  `LevelVendor` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `User` (`User`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Table structure for table `vatexemptions`
--

CREATE TABLE `vatexemptions` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` tinyint(3) unsigned NOT NULL,
  `Description` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `vats`
--

CREATE TABLE `vats` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Code` decimal(1,0) unsigned NOT NULL,
  `Name` varchar(16) NOT NULL,
  `Percent` decimal(4,2) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8;

--
-- Table structure for table `vendorkeys`
--

CREATE TABLE `vendorkeys` (
  `Counter` int(11) DEFAULT NULL,
  `VendorKey` int(11) DEFAULT NULL,
  `Vendor` int(11) NOT NULL,
  PRIMARY KEY (`Vendor`),
  UNIQUE KEY `Counter` (`Counter`,`VendorKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `vendorregister`
--

CREATE TABLE `vendorregister` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Vendor` int(11) DEFAULT NULL,
  `RegisterDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `RegisterSend` smallint(6) DEFAULT '0',
  `ReleaseDateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ReleaseSend` smallint(6) DEFAULT '0',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `vendors`
--

CREATE TABLE `vendors` (
  `Code` int(11) NOT NULL,
  `Name` varchar(64) NOT NULL,
  `Password` varchar(31) NOT NULL DEFAULT '',
  `Icon` varchar(127) NOT NULL DEFAULT '',
  `TurnId` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `vitaminnames`
--

CREATE TABLE `vitaminnames` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `locale` char(2) NOT NULL DEFAULT '',
  `type` char(1) DEFAULT NULL,
  `shortname` char(3) NOT NULL DEFAULT '',
  `name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `locale` (`locale`,`type`,`shortname`)
) ENGINE=InnoDB AUTO_INCREMENT=109 DEFAULT CHARSET=utf8;

--
-- Table structure for table `vitamins`
--

CREATE TABLE `vitamins` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `card` int(11) NOT NULL,
  `identifier` int(11) NOT NULL,
  `type` char(1) DEFAULT NULL,
  `shortname` char(3) NOT NULL DEFAULT '',
  `name` varchar(50) DEFAULT NULL,
  `units` varchar(2) DEFAULT NULL,
  `daily_ref` float DEFAULT NULL,
  `per100` float DEFAULT '0',
  `perportion` float DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `vtm` (`card`,`identifier`),
  CONSTRAINT `vitamins_ibfk_1` FOREIGN KEY (`card`) REFERENCES `nutrition` (`card`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `xmltexts`
--

CREATE TABLE `xmltexts` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `XmlType` char(1) DEFAULT NULL,
  `GroupName` varchar(32) NOT NULL DEFAULT '',
  `Name` varchar(32) NOT NULL DEFAULT '',
  `XmlText` text NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `XmlType` (`XmlType`,`GroupName`,`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping routines for database 'pcscale'
--
/*!50003 DROP FUNCTION IF EXISTS `gs1_checkdigit` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `gs1_checkdigit`(base VARCHAR(17)) RETURNS char(1) CHARSET utf8
    DETERMINISTIC
BEGIN
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    DECLARE odds INTEGER DEFAULT 0;     
    DECLARE evens INTEGER DEFAULT 0;    
    DECLARE total INTEGER DEFAULT 0;    
    DECLARE len INTEGER;                
    DECLARE pos INTEGER DEFAULT 0;      
    DECLARE digit INTEGER;              
    DECLARE cd INTEGER;                 
    
    
    SET len = LENGTH(base);
    mainloop: LOOP
        
        
        SET digit = CAST(SUBSTRING(base, len-pos, 1) AS SIGNED INTEGER);
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        IF (pos % 2 = 0)
        THEN
            SET evens = evens + digit;
        ELSE
            SET odds = odds + digit;
        END IF;
        
        
        SET pos = pos + 1;
        IF (pos < LEN)
        THEN
            ITERATE mainloop;
        END IF;
        LEAVE mainloop;
    END LOOP mainloop;
    
    
    SET total = odds + (3 * evens);
    SET cd = total % 10;
    IF (cd <> 0)
    THEN
        SET cd = 10 - cd;
    END IF;
    
    RETURN (CAST(cd AS CHAR));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `pcs_net` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `pcs_net`(gross DECIMAL(10,2), discount DECIMAL(4,2), points DECIMAL(10,2)) RETURNS decimal(10,2)
    DETERMINISTIC
BEGIN
  DECLARE net DECIMAL(10,2);

  SET @amount_round := IFNULL(GLOBAL_GET("amount_round"), 0);
  SET @frac_digits := IFNULL(GLOBAL_GET("frac_digits"), 2);
  SET net=gross - ROUND((gross*discount)/100, @frac_digits) - points;
  IF(@amount_round=5) THEN
    SET net=(ROUND(net/5, @frac_digits) * 5);
  END IF;

  RETURN net;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `pcs_total_to_pay` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `pcs_total_to_pay`(id_ticket INTEGER, src_db TINYTEXT) RETURNS decimal(10,2)
    DETERMINISTIC
BEGIN
  DECLARE total DECIMAL(10,2);
  DECLARE without_taxes BOOLEAN DEFAULT FALSE;	
  SET without_taxes = (SELECT (IFNULL((SELECT `ParamValue` FROM `CfgSystem` WHERE `ParamKey`='prices-without-taxes'), 0)=1));
  IF(without_taxes=0) THEN
    IF(src_db='HTickets') THEN
      SET total = (SELECT `NetAmount` FROM `HTickets` WHERE `Id`=id_ticket);
    ELSE  
      SET total = (SELECT `NetAmount` FROM `LocalHTickets` WHERE `Id`=id_ticket);
    END IF;

  ELSE
    IF(src_db='HTickets') THEN
      SET total = (SELECT SUM(V_VAT.Amount) + SUM(CAST(((V_VAT.Amount*Percentage)/100) AS DECIMAL(10,2))) FROM
        (SELECT lt.`VATPercent`+'0' AS Percentage, CAST((SUM(lt.`Amount`)*(ht.`NetAmount`/ht.`GrossAmount`)) AS DECIMAL(10,2)) AS Amount
         FROM `HTickets` AS ht
         LEFT JOIN `LTickets` AS lt ON ht.`Id`=lt.`IdHTicket`
         WHERE ht.`Id`=id_ticket AND `lineType`=1 GROUP BY lt.`VATCode`) AS V_VAT);
    ELSE  
      SET total = (SELECT SUM(V_VAT.Amount) + SUM(CAST(((V_VAT.Amount*Percentage)/100) AS DECIMAL(10,2))) FROM
        (SELECT lt.`VATPercent`+'0' AS Percentage, CAST((SUM(lt.`Amount`)*(ht.`NetAmount`/ht.`GrossAmount`)) AS DECIMAL(10,2)) AS Amount
         FROM `LocalHTickets` AS ht
         LEFT JOIN `LocalLTickets` AS lt ON ht.`Id`=lt.`IdHTicket`
         WHERE ht.`Id`=id_ticket AND `lineType`=1 GROUP BY lt.`VATCode`) AS V_VAT);
    END IF;
  END IF;

  RETURN total;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DataloggerFiscalChange` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `DataloggerFiscalChange`(OldName VARCHAR(32), NewName VARCHAR(32), OldEnabled BOOLEAN, NewEnabled BOOLEAN )
BEGIN
  DECLARE msg VARCHAR(255) DEFAULT '';
  IF ((NewName!=OldName) OR (NewEnabled!=OldEnabled)) THEN
    SELECT (SELECT COUNT(*) FROM information_schema.global_status WHERE variable_name='SLAVE_RUNNING' AND VARIABLE_VALUE='ON'), (SELECT COUNT(*) FROM information_schema.processlist WHERE INFO='SELECT trx_get()') INTO @_slave_,@_app_running_;
    IF (@_slave_ = 0) THEN
      IF (NewName = OldName) THEN
        SET msg := CONCAT('Fiscal module ', NewName, IF(NewEnabled, ' enabled', ' disabled'));
      ELSEIF (NewName = '') THEN
        SET msg := CONCAT('Fiscal module ', OldName, ' dropped.');
      ELSEIF (OldName = '') THEN
        SET msg := CONCAT('Fiscal module ', NewName, ' raised. ',IF(NewEnabled, 'Enabled', 'Disabled'));
      ELSE
        SET msg := CONCAT('Fiscal module ', OldName, ' changed to ', NewName, IF(NewEnabled, '. Enabled', '. Disabled'));
      END IF;
    END IF;
    IF (@_app_running_ = 0) THEN
      INSERT INTO `LocalDataLogger` SET Type=134, DatTim=NOW(), Message=msg;
    ELSE
      SET @trx := (SELECT trx_new("FISCAL_RELOAD", "NETWORK"));
      SET @ret := (SELECT trx_set_param(@trx, "LOG", msg));
      SET @ret := (SELECT trx_send(@trx));
    END IF;
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `dbTrigger` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `dbTrigger`(IN `tbname` VARCHAR (40), `function` VARCHAR (10), `masterkey` VARCHAR (40))
BEGIN
    SET @trx := (SELECT trx_new("DBTRIGGER", "CORE"));
    SET @ret := (SELECT trx_set_param(@trx, "TABLE", `tbname`));
    SET @ret := (SELECT trx_set_param(@trx, "FUNCTION", `function`));
    SET @ret := (SELECT trx_set_param(@trx, "KEY", `masterkey`));
    SET @ret := (SELECT trx_send(@trx));
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `LocalTreeBoardFromPLUKeysFile` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `LocalTreeBoardFromPLUKeysFile`()
BEGIN


  DELETE FROM `LocalTreeBoard`;
  SET @rownumber:=100000;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`,`Source3`,`Source4`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2`, puk.`Source3`, puk.`Source4` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`!=0 AND puk.`Source5`!=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`,`Source3`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2`, puk.`Source3` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`!=0 AND puk.`Source5`=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2` AS kl FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`=0 AND puk.`Source5`=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`=0  AND puk.`Source4`=0 AND puk.`Source5`=0) AS VT;

  SET @rownumber:=0;
  UPDATE `LocalTreeBoard` SET Board=(@rownumber:=@rownumber+1) ORDER BY `Source1`,`Source2`,`Source3`,`Source4`,`Source5`;

 UPDATE `LocalTreeBoard` AS T1 LEFT JOIN
 (SELECT `Board`,
    IF(@src1!=`Source1`, @lv1:=@lv1+1, @lv1) AS lv1,
    IF(@src1!=`Source1`, IF(`Source2`!=0, @lv2:=1, @lv2:=0), IF(@src2!=`Source2`, @lv2:=@lv2+1, @lv2)) AS lv2,
    IF(@src1!=`Source1` OR @src2!=`Source2`, IF(`Source3`!=0, @lv3:=1, @lv3:=0), IF(@src3!=`Source3`, @lv3:=@lv3+1, @lv3)) AS lv3,
    IF(@src1!=`Source1` OR @src2!=`Source2` OR @src3!=`Source3`, IF(`Source4`!=0, @lv4:=1, @lv4:=0), IF(@src4!=`Source4`, @lv4:=@lv4+1, @lv4)) AS lv4,
    IF(@src1!=`Source1` OR @src2!=`Source2` OR @src3!=`Source3` OR @src4!=`Source4`, IF(`Source5`!=0, @lv5:=1, @lv5:=0), IF(@src5!=`Source5`, @lv5:=@lv5+1, @lv5)) AS lv5,
    @src1:=`Source1`, @src2:=`Source2`, @src3:=`Source3`, @src4:=`Source4`, @src5:=`Source5`
	FROM `LocalTreeBoard`, (SELECT @src1:=0, @lv1:=0, @src2:=0, @lv2:=0, @src3:=0, @lv3:=0, @src4:=0, @lv4:=0, @src5:=0, @lv5:=0) AS TT
    ORDER BY `Board`) AS T2 ON T1.`Board`=T2.`Board`
 SET T1.`Level1`=T2.lv1, T1.`Level2`=T2.lv2, T1.`Level3`=T2.lv3, T1.`Level4`=T2.lv4, T1.`Level5`=T2.lv5;
END ;;
DELIMITER ;


--
-- Host: localhost    Database: pcscale
-- ------------------------------------------------------


--
-- Dumping data for table `advertising`
--

INSERT INTO `advertising` VALUES (1,0,0,2,5,0,0,1,0,1,1,'','',1,1);

--
-- Dumping data for table `allergenicons`
--

INSERT INTO `allergenicons` VALUES (1,'gluten','Cereals containing gluten','gluten.png'),(2,'crustaceans','Crustaceans','crustacean.png'),(3,'eggs','Eggs','egg.png'),(4,'fish','Poisson','fish.png'),(5,'peanuts','Peanuts','peanut.png'),(6,'soybeans','Soybeans','soya.png'),(7,'milk','Milk','milk.png'),(8,'nuts','Nuts','treenut.png'),(9,'celery','Celery','celery.png'),(10,'mustard','Mustard','mustard.png'),(11,'sesame','Sesame seeds','sesame.png'),(12,'sulphurdioxide','Sulphur dioxide','sulphurdioxide.png'),(13,'lupin','Lupin','lupin.png'),(14,'molluscs','Molluscs','molluscs.png');

--
-- Dumping data for table `barcodeean13`
--

INSERT INTO `barcodeean13` VALUES (1,'G',0,'2YTTTTTIIIII','','20VVViiiiiii','10VVVIIIIIII','2YTTTTTiiiii','2CCCCCCiiiii','2CCCCCCiiiii','2YTTTTTIIIII','20VVViiiiiii','10VVVIIIIIII','2YTTTTTiiiii','2CCCCCCiiiii','2CCCCCCiiiii','2CCCCCCIIIII');

--
-- Dumping data for table `bovine`
--


--
-- Dumping data for table `card`
--


--
-- Dumping data for table `cash`
--


--
-- Dumping data for table `cfgparams`
--

INSERT INTO `cfgparams` VALUES (1,'AI91',''),(2,'AI92',''),(3,'AI93',''),(4,'AI94',''),(5,'AI95',''),(6,'AI96',''),(7,'AI97',''),(8,'AI98',''),(9,'AI99',''),(10,'SENDMAIL_URL','smtp://smtp.gmail.com:587'),(11,'SENDMAIL_USERNAME',''),(12,'SENDMAIL_PASSWORD',''),(13,'SENDMAIL_FROM',''),(14,'SENDMAIL_BODY','No reply'),(15,'SENDMAIL_TIMEOUT','10');

--
-- Dumping data for table `cfgsystem`
--

INSERT INTO `cfgsystem` VALUES (1,'simplified-invoice-serial','1400101'),(2,'forms-embedded-dp','1'),(3,'prices-without-taxes','0');

--
-- Dumping data for table `clientconfiguration`
--

INSERT INTO `clientconfiguration` VALUES (1,'ECI','face',0,0,1900,2,1,1,5,2,1,1,60,2,1,3600,0,'http://demo.q-matic.es:9094',0,'',0,0);

--
-- Dumping data for table `code128`
--


--
-- Dumping data for table `counterfamilies`
--

INSERT INTO `counterfamilies` VALUES (1,1,1,1),(2,1,2,2),(3,1,3,3),(4,1,4,4),(5,1,5,5),(6,1,6,6),(7,1,7,7),(8,1,8,8),(9,1,9,9),(10,1,10,10),(11,1,11,11),(12,1,12,12),(13,1,13,13),(14,1,14,14);

--
-- Dumping data for table `counters`
--

INSERT INTO `counters` VALUES (1,'RAYON','',0,'','','',1,0,'0000-00-00 00:00:00',0,'00:00:00',0,0,1,0,'','','','','','','','','','','');

--
-- Dumping data for table `customers`
--


--
-- Dumping data for table `ean128`
--


--
-- Dumping data for table `families`
--

INSERT INTO `families` VALUES (1,'MER','Saumon.png','',0,''),(2,'DECOUPE','dos_de_cabillaud.png','',0,''),(3,'ENTIER','bar.png','',0,''),(4,'CALAMARS','calamar.png','',0,''),(5,'CREVETTES','crevettes.png','',0,''),(6,'LANGOUSTINES','langoustine.png','',0,''),(7,'CRUSTACES','homard.png','',0,''),(8,'COQUILLAGES','bulots.png','',0,''),(9,'MOULES','moules.png','',0,''),(10,'TRAITEUR CHAUD','beignet_calamar.png','',0,''),(11,'TRAITEUR SALADE','salade_mer.png','',0,''),(12,'ORIENTAL','sushi.png','',0,''),(13,'VINS','vins-rouge-blanc-rose.png','',0,''),(14,'EPICERIE','sel_parfum.png','',0,'');

--
-- Dumping data for table `fiscal`
--


--
-- Dumping data for table `hangedmarks`
--


--
-- Dumping data for table `itemgroupkeys`
--


--
-- Dumping data for table `itemgroupkeystext`
--


--
-- Dumping data for table `itemhabitual`
--


--
-- Dumping data for table `itemlinkcommon`
--


--
-- Dumping data for table `itemmiddleweights`
--


--
-- Dumping data for table `itemofferdates`
--


--
-- Dumping data for table `itemofferpricerates`
--


--
-- Dumping data for table `itempricerates`
--


--
-- Dumping data for table `items`
--

INSERT INTO `items` VALUES (1,0,0,'','','','','','','','',0,0,999,0,0,0,0,'',0.00,0,0.00,1,0,0,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'','','',0,0.000,0,0,0.00000),(3,1,0,'CABILLAUD 6/8','CABILLAUD 6/8','','','','','','',1,0,1,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'cabillaud.png','','',0,0.000,0,0,0.00000),(4,2,0,'ESPADON','ESPADON','','','','','','',1,0,2,1,0,0,0,'',20.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'espadon.png','','',0,0.000,0,0,0.00000),(5,3,0,'LIEU JAUNE','LIEU JAUNE','','','','','','',1,0,3,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'lieu-jaune.png','','',0,0.000,0,0,0.00000),(6,4,0,'LONGE DE THON','LONGE DE THON','','','','','','',1,0,4,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'thon.png','','',0,0.000,0,0,0.00000),(7,5,0,'LONGE ESPADON','LONGE ESPADON','','','','','','',1,0,5,1,0,0,0,'',50.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'espadon.png','','',0,0.000,0,0,0.00000),(8,6,0,'MAIGRE','MAIGRE','','','','','','',1,0,6,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'maigre.png','','',0,0.000,0,0,0.00000),(9,7,0,'MERLU3/4','MERLU3/4','','','','','','',1,0,7,1,0,0,0,'',30.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'merlu.png','','',0,0.000,0,0,0.00000),(10,8,0,'MERLU4/5','MERLU4/5','','','','','','',1,0,8,1,0,0,0,'',30.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'merlu.png','','',0,0.000,0,0,0.00000),(11,9,0,'REQUIN TAUPE','REQUIN TAUPE','','','','','','',1,0,9,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'requin.png','','',0,0.000,0,0,0.00000),(12,10,0,'SAUMON BIO','SAUMON BIO','','','','','','',1,0,10,1,0,0,0,'',20.40,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Saumon.png','','',0,0.000,0,0,0.00000),(13,11,0,'SAUMON BIO ECOSSE','SAUMON BIO ECOSSE','','','','','','',1,0,11,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(14,12,0,'SAUMON LABEL','SAUMON LABEL','','','','','','',1,0,12,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Saumon.png','','',0,0.000,0,0,0.00000),(15,13,0,'SAUMON SAUVAGE','SAUMON SAUVAGE','','','','','','',1,0,13,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Saumon.png','','',0,0.000,0,0,0.00000),(16,14,0,'SAUMON SUP 5/6','SAUMON SUP 5/6','','','','','','',1,0,14,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Saumon.png','','',0,0.000,0,0,0.00000),(17,15,0,'THON BLANC','THON BLANC','','','','','','',1,0,15,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'thon.png','','',0,0.000,0,0,0.00000),(18,16,0,'THON ROUGE','THON ROUGE','','','','','','',1,0,16,1,0,0,0,'',30.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'thon.png','','',0,0.000,0,0,0.00000),(19,17,0,'DOS DE CABILLAUD GROS','DOS DE CABILLAUD GROS','','','','','','',2,0,1,1,0,0,0,'',20.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'cabillaud.png','','',0,0.000,0,0,0.00000),(20,18,0,'DOS DE CABILLAUD PETIT','DOS DE CABILLAUD PETIT','','','','','','',2,0,2,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'cabillaud.png','','',0,0.000,0,0,0.00000),(21,19,0,'DOS DE LIEU NOIR','DOS DE LIEU NOIR','','','','','','',2,0,3,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'lieu-noir-filet.png','','',0,0.000,0,0,0.00000),(22,20,0,'DOS DE LOUP','DOS DE LOUP','','','','','','',2,0,4,1,0,0,0,'',30.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'loup.png','','',0,0.000,0,0,0.00000),(23,21,0,'DOS DE PERCHE','DOS DE PERCHE','','','','','','',2,0,5,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'perche.png','','',0,0.000,0,0,0.00000),(24,22,0,'DOS DE SAUMON','DOS DE SAUMON','','','','','','',2,0,6,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Saumon.png','','',0,0.000,0,0,0.00000),(25,23,0,'DOS EGLEFIN','DOS EGLEFIN','','','','','','',2,0,7,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Eglefin.png','','',0,0.000,0,0,0.00000),(26,24,0,'FILET 150 ET +','FILET 150 ET +','','','','','','',2,0,8,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'cabillaud.png','','',0,0.000,0,0,0.00000),(27,25,0,'FILET DE BAR','FILET DE BAR','','','','','','',2,0,9,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'bar.png','','',0,0.000,0,0,0.00000),(28,26,0,'FILET DE CABILLAUD 100/20','FILET DE CABILLAUD 100/20','','','','','','',2,0,10,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'cabillaud.png','','',0,0.000,0,0,0.00000),(29,27,0,'FILET DE CABILLAUD 200/40','FILET DE CABILLAUD 200/40','','','','','','',2,0,11,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'cabillaud.png','','',0,0.000,0,0,0.00000),(30,28,0,'FILET DE MERLAN','FILET DE MERLAN','','','','','','',2,0,12,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Merlan.png','','',0,0.000,0,0,0.00000),(31,29,0,'FILET DE FLETAN','FILET DE FLETAN','','','','','','',2,0,13,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Fletan.png','','',0,0.000,0,0,0.00000),(32,30,0,'FILET DE GRENADIER','FILET DE GRENADIER','','','','','','',2,0,14,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Grenadier.png','','',0,0.000,0,0,0.00000),(33,31,0,'FILET DE GRONDIN','FILET DE GRONDIN','','','','','','',2,0,15,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Grondin.png','','',0,0.000,0,0,0.00000),(34,32,0,'FILET DE JULIENNE','FILET DE JULIENNE','','','','','','',2,0,16,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Julienne.png','','',0,0.000,0,0,0.00000),(35,33,0,'FILET DE LIEU JAUNE','FILET DE LIEU JAUNE','','','','','','',2,0,17,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'lieu-jaune.png','','',0,0.000,0,0,0.00000),(36,34,0,'FILET DE LIEU NOIR','FILET DE LIEU NOIR','','','','','','',2,0,18,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'lieu-noir-filet.png','','',0,0.000,0,0,0.00000),(37,35,0,'FILET DE LOTTE','FILET DE LOTTE','','','','','','',2,0,19,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Lotte.png','','',0,0.000,0,0,0.00000),(38,36,0,'FILET DE LOUP','FILET DE LOUP','','','','','','',2,0,20,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'loup.png','','',0,0.000,0,0,0.00000),(39,37,0,'FILET DE MAQUEREAUX','FILET DE MAQUEREAUX','','','','','','',2,0,21,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Maquereau.png','','',0,0.000,0,0,0.00000),(40,39,0,'FILET DE MERLU','FILET DE MERLU','','','','','','',2,0,22,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'merlu.png','','',0,0.000,0,0,0.00000),(41,40,0,'FILET DE MEROU','FILET DE MEROU','','','','','','',2,0,23,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Merou.png','','',0,0.000,0,0,0.00000),(42,41,0,'FILET DE MOSTELLE','FILET DE MOSTELLE','','','','','','',2,0,24,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'Eglefin.png','','',0,0.000,0,0,0.00000),(43,42,0,'FILET DE PANGA','FILET DE PANGA','','','','','','',2,0,25,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'filet-de-panga.png','','',0,0.000,0,0,0.00000),(44,43,0,'FILET DE PERCHE','FILET DE PERCHE','','','','','','',2,0,26,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'perche.png','','',0,0.000,0,0,0.00000),(45,44,0,'FILET DE PLIE CYNOGLOSSE','FILET DE PLIE CYNOGLOSSE','','','','','','',2,0,27,1,0,0,0,'',6.54,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Plie_cyn.png','','',0,0.000,0,0,0.00000),(46,45,0,'FILET DE ROUGET','FILET DE ROUGET','','','','','','',2,0,28,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Rouget.png','','',0,0.000,0,0,0.00000),(47,46,0,'FILET DE SABRE','FILET DE SABRE','','','','','','',2,0,29,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Sabres.png','','',0,0.000,0,0,0.00000),(48,47,0,'FILET DE SARDINES','FILET DE SARDINES','','','','','','',2,0,30,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sardines.png','','',0,0.000,0,0,0.00000),(49,48,0,'FILET DE SAUMON','FILET DE SAUMON','','','','','','',2,0,31,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(50,49,0,'FILET DE SOLE','FILET DE SOLE','','','','','','',2,0,32,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sole.png','','',0,0.000,0,0,0.00000),(51,50,0,'FILET DE TACAUD','FILET DE TACAUD','','','','','','',2,0,33,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Tacaud.png','','',0,0.000,0,0,0.00000),(52,51,0,'FILET DE TRUITE','FILET DE TRUITE','','','','','','',2,0,34,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'truite.png','','',0,0.000,0,0,0.00000),(53,52,0,'FILET DE TURBOT','FILET DE TURBOT','','','','','','',2,0,35,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'turbot.png','','',0,0.000,0,0,0.00000),(54,53,0,'FILET DE VIVE','FILET DE VIVE','','','','','','',2,0,36,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vive.png','','',0,0.000,0,0,0.00000),(55,54,0,'FILET EGLEFIN','FILET EGLEFIN','','','','','','',2,0,37,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Eglefin.png','','',0,0.000,0,0,0.00000),(56,55,0,'FILET ELINGUE','FILET ELINGUE','','','','','','',2,0,38,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Elingue.png','','',0,0.000,0,0,0.00000),(57,56,0,'FILET EMPEREUR','FILET EMPEREUR','','','','','','',2,0,39,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Empereur.png','','',0,0.000,0,0,0.00000),(58,57,0,'FILETS NET PAVES','FILETS NET PAVES','','','','','','',2,0,40,1,0,0,0,'',12.36,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(59,58,0,'JOUE DE LOTTE','JOUE DE LOTTE','','','','','','',2,0,41,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'joue_lotte.png','','',0,0.000,0,0,0.00000),(60,59,0,'JOUE DE LOUP','JOUE DE LOUP','','','','','','',2,0,42,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'joue_loup.png','','',0,0.000,0,0,0.00000),(61,60,0,'LIMANDE PRETE A CUIRE','LIMANDE PRETE A CUIRE','','','','','','',2,0,43,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'limande.png','','',0,0.000,0,0,0.00000),(62,61,0,'PAVE DE SAUMON BIO','PAVE DE SAUMON BIO','','','','','','',2,0,44,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(63,62,0,'PAVE DE SAUMON DE France','PAVE DE SAUMON DE France','','','','','','',2,0,45,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(64,63,0,'PAVE DE SAUMON LABEL ROUG','PAVE DE SAUMON LABEL ROUG','','','','','','',2,0,46,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(65,64,0,'PAVE DE SAUMON SAUVAGE','PAVE DE SAUMON SAUVAGE','','','','','','',2,0,47,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(66,65,0,'PAVE DE SAUMON SUPERIEUR','PAVE DE SAUMON SUPERIEUR','','','','','','',2,0,48,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Saumon.png','','',0,0.000,0,0,0.00000),(67,66,0,'AILE DE RAIE GROSSE','AILE DE RAIE GROSSE','','','','','','',3,0,1,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'aile_raie.png','','',0,0.000,0,0,0.00000),(68,67,0,'AILE DE RAIE PELEE PETITE','AILE DE RAIE PELEE PETITE','','','','','','',3,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'aile_raie.png','','',0,0.000,0,0,0.00000),(69,68,0,'BAR DE LIGNE GROS','BAR DE LIGNE GROS','','','','','','',3,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bar.png','','',0,0.000,0,0,0.00000),(70,69,0,'BAR DE LIGNE PETIT','BAR DE LIGNE PETIT','','','','','','',3,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bar.png','','',0,0.000,0,0,0.00000),(71,70,0,'BAR ELEVAGE GROS','BAR ELEVAGE GROS','','','','','','',3,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bar.png','','',0,0.000,0,0,0.00000),(72,71,0,'BAR ELEVAGE PETIT','BAR ELEVAGE PETIT','','','','','','',3,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bar.png','','',0,0.000,0,0,0.00000),(73,72,0,'BAR ELEVAGE ST MANDRIER 4','BAR ELEVAGE ST MANDRIER 4','','','','','','',3,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bar.png','','',0,0.000,0,0,0.00000),(74,73,0,'BAR ELEVAGE ST MANDRIER 6','BAR ELEVAGE ST MANDRIER 6','','','','','','',3,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bar.png','','',0,0.000,0,0,0.00000),(75,74,0,'BARBUE GROSSE','BARBUE GROSSE','','','','','','',3,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'barbue.png','','',0,0.000,0,0,0.00000),(76,75,0,'BARBUE PETITE','BARBUE PETITE','','','','','','',3,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'barbue.png','','',0,0.000,0,0,0.00000),(77,76,0,'CAPITAINE','CAPITAINE','','','','','','',3,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'capitaine.png','','',0,0.000,0,0,0.00000),(78,77,0,'CETEAUX','CETEAUX','','','','','','',3,0,12,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'ceteau.png','','',0,0.000,0,0,0.00000),(79,78,0,'CHINCHARD','CHINCHARD','','','','','','',3,0,13,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'chinchard.png','','',0,0.000,0,0,0.00000),(80,79,0,'DARNE DE DAURADE ROYALE','DARNE DE DAURADE ROYALE','','','','','','',3,0,14,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'darne-de-daurade.png','','',0,0.000,0,0,0.00000),(81,80,0,'DARNE DE LOTTE','DARNE DE LOTTE','','','','','','',3,0,15,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'darne_lotte.png','','',0,0.000,0,0,0.00000),(82,81,0,'DAURADE ROYALE ELEVAGE GR','DAURADE ROYALE ELEVAGE GR','','','','','','',3,0,16,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'daurade.png','','',0,0.000,0,0,0.00000),(83,82,0,'DAURADE ROYALE ELEVAGE PE','DAURADE ROYALE ELEVAGE PE','','','','','','',3,0,17,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'daurade.png','','',0,0.000,0,0,0.00000),(84,83,0,'DAURADE ROYALE FRITURE','DAURADE ROYALE FRITURE','','','','','','',3,0,18,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'daurade.png','','',0,0.000,0,0,0.00000),(85,84,0,'DAURADE ROYALE GROSSE','DAURADE ROYALE GROSSE','','','','','','',3,0,19,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'daurade.png','','',0,0.000,0,0,0.00000),(86,85,0,'DAURADE ROYALE PETITE','DAURADE ROYALE PETITE','','','','','','',3,0,20,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'daurade.png','','',0,0.000,0,0,0.00000),(87,86,0,'DORADE GRISE','DORADE GRISE','','','','','','',3,0,21,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'dorade-grise.png','','',0,0.000,0,0,0.00000),(88,87,0,'DORADE PAGRE','DORADE PAGRE','','','','','','',3,0,22,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'dorade_pagre.png','','',0,0.000,0,0,0.00000),(89,88,0,'DORADE ROSE','DORADE ROSE','','','','','','',3,0,23,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'dorade-rose.png','','',0,0.000,0,0,0.00000),(90,89,0,'HARENG','HARENG','','','','','','',3,0,24,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'hareng.png','','',0,0.000,0,0,0.00000),(91,90,0,'LANCON','LANCON','','','','','','',3,0,25,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'hareng.png','','',0,0.000,0,0,0.00000),(92,91,0,'LIMANDE','LIMANDE','','','','','','',3,0,26,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'limande.png','','',0,0.000,0,0,0.00000),(93,92,0,'LIMANDE SOLE','LIMANDE SOLE','','','','','','',3,0,27,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sole.png','','',0,0.000,0,0,0.00000),(94,93,0,'LOTTE GROSSE','LOTTE GROSSE','','','','','','',3,0,28,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Lotte.png','','',0,0.000,0,0,0.00000),(95,94,0,'LOTTE PETITE','LOTTE PETITE','','','','','','',3,0,29,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Lotte.png','','',0,0.000,0,0,0.00000),(96,95,0,'MAIGRE ELEVAGE','MAIGRE ELEVAGE','','','','','','',3,0,30,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'maigre.png','','',0,0.000,0,0,0.00000),(97,96,0,'MAIGRE GROS','MAIGRE GROS','','','','','','',3,0,31,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'maigre.png','','',0,0.000,0,0,0.00000),(98,97,0,'MAIGRE PETIT','MAIGRE PETIT','','','','','','',3,0,32,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'maigre.png','','',0,0.000,0,0,0.00000),(99,98,0,'MAQUEREAUX GROS','MAQUEREAUX GROS','','','','','','',3,0,33,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Maquereau.png','','',0,0.000,0,0,0.00000),(100,99,0,'MAQUEREAUX PETIT','MAQUEREAUX PETIT','','','','','','',3,0,34,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Maquereau.png','','',0,0.000,0,0,0.00000),(101,100,0,'MERLAN DE LIGNE','MERLAN DE LIGNE','','','','','','',3,0,35,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Merlan.png','','',0,0.000,0,0,0.00000),(102,101,0,'MERLU 1/2','MERLU 1/2','','','','','','',3,0,36,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'merlu.png','','',0,0.000,0,0,0.00000),(103,102,0,'MERLU 2/300','MERLU 2/300','','','','','','',3,0,37,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'merlu.png','','',0,0.000,0,0,0.00000),(104,103,0,'MERLU 4/600','MERLU 4/600','','','','','','',3,0,38,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'merlu.png','','',0,0.000,0,0,0.00000),(105,104,0,'MERLU 6/800','MERLU 6/800','','','','','','',3,0,39,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'merlu.png','','',0,0.000,0,0,0.00000),(106,105,0,'MULET','MULET','','','','','','',3,0,40,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'mulet.png','','',0,0.000,0,0,0.00000),(107,106,0,'OEUF DE MERLU','OEUF DE MERLU','','','','','','',3,0,41,1,0,0,0,'',5.70,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'oeufs-de-poissons.png','','',0,0.000,0,0,0.00000),(108,107,0,'ORPHIE','ORPHIE','','','','','','',3,0,42,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'orphie.png','','',0,0.000,0,0,0.00000),(109,108,0,'RASCASSE','RASCASSE','','','','','','',3,0,43,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'rascasse.png','','',0,0.000,0,0,0.00000),(110,109,0,'RASCASSE CHAPON','RASCASSE CHAPON','','','','','','',3,0,44,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'rascasse.png','','',0,0.000,0,0,0.00000),(111,110,0,'ROUGET A FILET','ROUGET A FILET','','','','','','',3,0,45,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Rouget.png','','',0,0.000,0,0,0.00000),(112,111,0,'ROUGET FRITURE','ROUGET FRITURE','','','','','','',3,0,46,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Rouget.png','','',0,0.000,0,0,0.00000),(113,112,0,'ROUGET GRONDIN','ROUGET GRONDIN','','','','','','',3,0,47,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Rouget.png','','',0,0.000,0,0,0.00000),(114,113,0,'ROUGET PORTION','ROUGET PORTION','','','','','','',3,0,48,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Rouget.png','','',0,0.000,0,0,0.00000),(115,114,0,'ROUSSETTE','ROUSSETTE','','','','','','',3,0,49,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'roussette.png','','',0,0.000,0,0,0.00000),(116,115,0,'SAINT PIERRE GROS','SAINT PIERRE GROS','','','','','','',3,0,50,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'st_pierre.png','','',0,0.000,0,0,0.00000),(117,116,0,'SAINT PIERRE PETIT','SAINT PIERRE PETIT','','','','','','',3,0,51,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'st_pierre.png','','',0,0.000,0,0,0.00000),(118,117,0,'SANDRE','SANDRE','','','','','','',3,0,52,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sandre.png','','',0,0.000,0,0,0.00000),(119,118,0,'SAR','SAR','','','','','','',3,0,53,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sardines.png','','',0,0.000,0,0,0.00000),(120,119,0,'SAUMONETTE','SAUMONETTE','','','','','','',3,0,54,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'saumonette.png','','',0,0.000,0,0,0.00000),(121,120,0,'SOLE A FILET','SOLE A FILET','','','','','','',3,0,55,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sole.png','','',0,0.000,0,0,0.00000),(122,121,0,'SOLE BLONDE','SOLE BLONDE','','','','','','',3,0,56,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sole.png','','',0,0.000,0,0,0.00000),(123,122,0,'SOLE GROSSE','SOLE GROSSE','','','','','','',3,0,57,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sole.png','','',0,0.000,0,0,0.00000),(124,123,0,'SOLE MOYENNE','SOLE MOYENNE','','','','','','',3,0,58,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sole.png','','',0,0.000,0,0,0.00000),(125,124,0,'SOLE PETITE','SOLE PETITE','','','','','','',3,0,59,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sole.png','','',0,0.000,0,0,0.00000),(126,125,0,'TRUITE BIO','TRUITE BIO','','','','','','',3,0,60,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'truite.png','','',0,0.000,0,0,0.00000),(127,126,0,'TRUITE GROSSE','TRUITE GROSSE','','','','','','',3,0,61,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'truite.png','','',0,0.000,0,0,0.00000),(128,127,0,'TRUITE PORTION BLANCHE','TRUITE PORTION BLANCHE','','','','','','',3,0,62,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'truite.png','','',0,0.000,0,0,0.00000),(129,128,0,'TRUITE PORTION ROSE','TRUITE PORTION ROSE','','','','','','',3,0,63,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'truite.png','','',0,0.000,0,0,0.00000),(130,129,0,'TURBOT GROS','TURBOT GROS','','','','','','',3,0,64,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'turbot.png','','',0,0.000,0,0,0.00000),(131,130,0,'TURBOT MOYEN','TURBOT MOYEN','','','','','','',3,0,65,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'turbot.png','','',0,0.000,0,0,0.00000),(132,131,0,'TURBOT PETIT','TURBOT PETIT','','','','','','',3,0,66,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'turbot.png','','',0,0.000,0,0,0.00000),(133,132,0,'TURBOTIN','TURBOTIN','','','','','','',3,0,67,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'turbot.png','','',0,0.000,0,0,0.00000),(134,133,0,'VIEILLE','VIEILLE','','','','','','',3,0,68,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vieille.png','','',0,0.000,0,0,0.00000),(135,134,0,'VIVANEAU','VIVANEAU','','','','','','',3,0,69,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vivaneau.png','','',0,0.000,0,0,0.00000),(136,135,0,'VIVE','VIVE','','','','','','',3,0,70,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vive.png','','',0,0.000,0,0,0.00000),(137,136,0,'ANNEAUX DE CALAMARS','ANNEAUX DE CALAMARS','','','','','','',4,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'anneaux-de-calamars.png','','',0,0.000,0,0,0.00000),(138,137,0,'BLANC DE SEICHE','BLANC DE SEICHE','','','','','','',4,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'blanc_seiche.png','','',0,0.000,0,0,0.00000),(139,138,0,'CASSERONS','CASSERONS','','','','','','',4,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'casseron.png','','',0,0.000,0,0,0.00000),(140,139,0,'CHIPIRON PATAGONICA','CHIPIRON PATAGONICA','','','','','','',4,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'chipirons.png','','',0,0.000,0,0,0.00000),(141,140,0,'CHIPIRONS','CHIPIRONS','','','','','','',4,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'chipirons.png','','',0,0.000,0,0,0.00000),(142,141,0,'ENCORNET 100/200','ENCORNET 100/200','','','','','','',4,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'encornet.png','','',0,0.000,0,0,0.00000),(143,142,0,'ENCORNET 200/300','ENCORNET 200/300','','','','','','',4,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'encornet.png','','',0,0.000,0,0,0.00000),(144,143,0,'LAMELLE DE CALAMARS','LAMELLE DE CALAMARS','','','','','','',4,0,1,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'calamar.png','','',0,0.000,0,0,0.00000),(145,144,0,'SEICHES','SEICHES','','','','','','',4,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'seiche.png','','',0,0.000,0,0,0.00000),(146,145,0,'SUPIONS','SUPIONS','','','','','','',4,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'supions.png','','',0,0.000,0,0,0.00000),(147,146,0,'TENTACULE DE CALAMAR','TENTACULE DE CALAMAR','','','','','','',4,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'tentacule.png','','',0,0.000,0,0,0.00000),(148,147,0,'CREVETTE BLANCHE','CREVETTE BLANCHE','','','','','','',5,0,2,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'crevettes_grises.png','','',0,0.000,0,0,0.00000),(149,148,0,'CREVETTE CRUES','CREVETTE CRUES','','','','','','',5,0,3,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'crevettes.png','','',0,0.000,0,0,0.00000),(150,149,0,'CREVETTES BIO','CREVETTES BIO','','','','','','',5,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes.png','','',0,0.000,0,0,0.00000),(151,150,0,'CREVETTES BOUQUET','CREVETTES BOUQUET','','','','','','',5,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes_pel.png','','',0,0.000,0,0,0.00000),(152,151,0,'CREVETTES GRISES HOLLANDE','CREVETTES GRISES HOLLANDE','','','','','','',5,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes_grises.png','','',0,0.000,0,0,0.00000),(153,152,0,'CREVETTES GRISES NORMANDI','CREVETTES GRISES NORMANDI','','','','','','',5,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes_grises.png','','',0,0.000,0,0,0.00000),(154,153,0,'CREVETTES ROSES 30/50','CREVETTES ROSES 30/50','','','','','','',5,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes.png','','',0,0.000,0,0,0.00000),(155,154,0,'CREVETTES ROSES 80/100','CREVETTES ROSES 80/100','','','','','','',5,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes.png','','',0,0.000,0,0,0.00000),(156,155,0,'CREVETTES ROSES MADAGASCA','CREVETTES ROSES MADAGASCA','','','','','','',5,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes.png','','',0,0.000,0,0,0.00000),(157,156,0,'CREVETTES ROSES MADAGASCA','CREVETTES ROSES MADAGASCA','','','','','','',5,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes.png','','',0,0.000,0,0,0.00000),(158,157,0,'CREVETTES ROSES MADAGASCA','CREVETTES ROSES MADAGASCA','','','','','','',5,0,12,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes.png','','',0,0.000,0,0,0.00000),(159,158,0,'CREVETTES ROYALES CUITES','CREVETTES ROYALES CUITES','','','','','','',5,0,13,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'gambas.png','','',0,0.000,0,0,0.00000),(160,159,0,'CREVETTES VIVANTES','CREVETTES VIVANTES','','','','','','',5,0,14,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes_grises.png','','',0,0.000,0,0,0.00000),(161,160,0,'GAMBAS BIO 20/30','GAMBAS BIO 20/30','','','','','','',5,0,15,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'gambas.png','','',0,0.000,0,0,0.00000),(162,161,0,'GAMBAS BIO 40/60','GAMBAS BIO 40/60','','','','','','',5,0,16,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'gambas.png','','',0,0.000,0,0,0.00000),(163,162,0,'GAMBAS CRUE','GAMBAS CRUE','','','','','','',5,0,17,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'gambas.png','','',0,0.000,0,0,0.00000),(164,163,0,'GAMBAS CUITE','GAMBAS CUITE','','','','','','',5,0,18,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes.png','','',0,0.000,0,0,0.00000),(165,164,0,'GAMBAS IMPERIALE CRUE','GAMBAS IMPERIALE CRUE','','','','','','',5,0,19,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'gambas.png','','',0,0.000,0,0,0.00000),(166,165,0,'GAMBAS ROYALE CRUE','GAMBAS ROYALE CRUE','','','','','','',5,0,20,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'gambas.png','','',0,0.000,0,0,0.00000),(167,166,0,'QUEUE DE CREVETTE','QUEUE DE CREVETTE','','','','','','',5,0,1,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'crevettes_pel.png','','',0,0.000,0,0,0.00000),(168,167,0,'QUEUES DE CREVETTE DECORT','QUEUES DE CREVETTE DECORT','','','','','','',5,0,21,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevettes_pel.png','','',0,0.000,0,0,0.00000),(169,170,0,'LANGOUSTINE GROSSE CRUE','LANGOUSTINE GROSSE CRUE','','','','','','',6,0,1,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(170,171,0,'LANGOUSTINE GROSSE CUITE','LANGOUSTINE GROSSE CUITE','','','','','','',6,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(171,172,0,'LANGOUSTINE IMPERIALE CRU','LANGOUSTINE IMPERIALE CRU','','','','','','',6,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(172,173,0,'LANGOUSTINE IMPERIALE CUI','LANGOUSTINE IMPERIALE CUI','','','','','','',6,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(173,174,0,'LANGOUSTINE MOYENNE CRUE','LANGOUSTINE MOYENNE CRUE','','','','','','',6,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(174,175,0,'LANGOUSTINE PETITE CRU','LANGOUSTINE PETITE CRU','','','','','','',6,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(175,176,0,'LANGOUSTINE PETITE CUITE','LANGOUSTINE PETITE CUITE','','','','','','',6,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(176,177,0,'LANGOUSTINE ROYALE CUITE','LANGOUSTINE ROYALE CUITE','','','','','','',6,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(177,178,0,'LANGOUSTINE ROYALES CRUE','LANGOUSTINE ROYALES CRUE','','','','','','',6,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(178,179,0,'LANGOUSTINE VIVANTE GROSS','LANGOUSTINE VIVANTE GROSS','','','','','','',6,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(179,180,0,'LANGOUSTINE VIVANTE MOYEN','LANGOUSTINE VIVANTE MOYEN','','','','','','',6,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langoustine.png','','',0,0.000,0,0,0.00000),(180,181,0,'ARAIGNEE CUITE','ARAIGNEE CUITE','','','','','','',7,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'araignee.png','','',0,0.000,0,0,0.00000),(181,182,0,'ARAIGNEE VIVANTE','ARAIGNEE VIVANTE','','','','','','',7,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'araignee.png','','',0,0.000,0,0,0.00000),(182,183,0,'HOMARD BRETON GROS CUIT','HOMARD BRETON GROS CUIT','','','','','','',7,0,1,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'homard.png','','',0,0.000,0,0,0.00000),(183,184,0,'HOMARD BRETON GROS VIVANT','HOMARD BRETON GROS VIVANT','','','','','','',7,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'homard.png','','',0,0.000,0,0,0.00000),(184,185,0,'HOMARD BRETON PETIT CUIT','HOMARD BRETON PETIT CUIT','','','','','','',7,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'homard.png','','',0,0.000,0,0,0.00000),(185,186,0,'HOMARD BRETON PETIT VIVAN','HOMARD BRETON PETIT VIVAN','','','','','','',7,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'homard.png','','',0,0.000,0,0,0.00000),(186,187,0,'HOMARD CANADIEN CUIT','HOMARD CANADIEN CUIT','','','','','','',7,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'homard.png','','',0,0.000,0,0,0.00000),(187,188,0,'HOMARD CANADIEN VIVANT','HOMARD CANADIEN VIVANT','','','','','','',7,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'homard.png','','',0,0.000,0,0,0.00000),(188,189,0,'LANGOUSTE CUITE','LANGOUSTE CUITE','','','','','','',7,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langouste.png','','',0,0.000,0,0,0.00000),(189,190,0,'LANGOUSTE VIVANTE','LANGOUSTE VIVANTE','','','','','','',7,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'langouste.png','','',0,0.000,0,0,0.00000),(190,191,0,'PETIT CRABE VERT','PETIT CRABE VERT','','','','','','',7,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crabe_vert.png','','',0,0.000,0,0,0.00000),(191,192,0,'PINCES DE TOURTEAUX','PINCES DE TOURTEAUX','','','','','','',7,0,12,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'pince-de-crabe.png','','',0,0.000,0,0,0.00000),(192,193,0,'PINCES DE TOURTEAUX ROYAL','PINCES DE TOURTEAUX ROYAL','','','','','','',7,0,13,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'pince-de-crabe.png','','',0,0.000,0,0,0.00000),(193,194,0,'TOURTEAU CUIT','TOURTEAU CUIT','','','','','','',7,0,14,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'tourteaux.png','','',0,0.000,0,0,0.00000),(194,195,0,'TOURTEAU VIVANT','TOURTEAU VIVANT','','','','','','',7,0,15,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'tourteaux.png','','',0,0.000,0,0,0.00000),(195,196,0,'AMANDES','AMANDES','','','','','','',8,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'amandes.png','','',0,0.000,0,0,0.00000),(196,197,0,'BIGORNEAUX CRUS','BIGORNEAUX CRUS','','','','','','',8,0,3,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'bigorneaux.png','','',0,0.000,0,0,0.00000),(197,198,0,'BIGORNEAUX CUITS MAISON','BIGORNEAUX CUITS MAISON','','','','','','',8,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bigorneaux.png','','',0,0.000,0,0,0.00000),(198,199,0,'BULOTS CRUS','BULOTS CRUS','','','','','','',8,0,2,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'bulots.png','','',0,0.000,0,0,0.00000),(199,200,0,'BULOTS CUITS MAISON','BULOTS CUITS MAISON','','','','','','',8,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bulots.png','','',0,0.000,0,0,0.00000),(200,201,0,'CLAMS','CLAMS','','','','','','',8,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'clams.png','','',0,0.000,0,0,0.00000),(201,202,0,'COQUES','COQUES','','','','','','',8,0,1,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'coques.png','','',0,0.000,0,0,0.00000),(202,203,0,'COQUES GROSSES','COQUES GROSSES','','','','','','',8,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'coques.png','','',0,0.000,0,0,0.00000),(203,204,0,'COUTEAU','COUTEAU','','','','','','',8,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'coques.png','','',0,0.000,0,0,0.00000),(204,205,0,'CYPRINES','CYPRINES','','','','','','',8,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'cyprines.png','','',0,0.000,0,0,0.00000),(205,206,0,'LAVAGNON','LAVAGNON','','','','','','',8,0,12,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'palourdes.png','','',0,0.000,0,0,0.00000),(206,207,0,'MURENE','MURENE','','','','','','',8,0,13,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Murene.png','','',0,0.000,0,0,0.00000),(207,208,0,'MURENE CUITS MAISON','MURENE CUITS MAISON','','','','','','',8,0,14,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Murene_cuite.png','','',0,0.000,0,0,0.00000),(208,209,0,'OURSINS','OURSINS','','','','','','',8,0,15,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'oursins.png','','',0,0.000,0,0,0.00000),(209,210,0,'PALOURDES','PALOURDES','','','','','','',8,0,4,1,0,0,0,'',10.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',NULL,'palourdes.png','','',0,0.000,0,0,0.00000),(210,211,0,'PALOURDES ROYALES','PALOURDES ROYALES','','','','','','',8,0,16,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'palourdes.png','','',0,0.000,0,0,0.00000),(211,212,0,'PRAIRES','PRAIRES','','','','','','',8,0,17,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'praire.png','','',0,0.000,0,0,0.00000),(212,213,0,'TELLINE','TELLINE','','','','','','',8,0,18,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'tellines.png','','',0,0.000,0,0,0.00000),(213,214,0,'VENUS','VENUS','','','','','','',8,0,19,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'venus.png','','',0,0.000,0,0,0.00000),(214,215,0,'VERNIS','VERNIS','','','','','','',8,0,20,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vernis.png','','',0,0.000,0,0,0.00000),(215,216,0,'VIOLET','VIOLET','','','','','','',8,0,21,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'violet.png','','',0,0.000,0,0,0.00000),(216,217,0,'MOULE BOUCHOT DE PENESTIN','MOULE BOUCHOT DE PENESTIN','','','','','','',9,0,1,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules.png','','',0,0.000,0,0,0.00000),(217,218,0,'MOULE DE BOUCHOT PRETE A','MOULE DE BOUCHOT PRETE A','','','','','','',9,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules.png','','',0,0.000,0,0,0.00000),(218,219,0,'MOULE D\'Irlande','MOULE D\'Irlande','','','','','','',9,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules.png','','',0,0.000,0,0,0.00000),(219,220,0,'MOULE Espagne','MOULE Espagne','','','','','','',9,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules.png','','',0,0.000,0,0,0.00000),(220,221,0,'MOULE GRANDE BRETAGNE','MOULE GRANDE BRETAGNE','','','','','','',9,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules.png','','',0,0.000,0,0,0.00000),(221,222,0,'BRANDADE DE MORUE','BRANDADE DE MORUE','','','','','','',10,0,1,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'brandade.png','','',0,0.000,0,0,0.00000),(222,223,0,'CALAMARS GRILLES A L\'ESPA','CALAMARS GRILLES A L\'ESPA','','','','','','',10,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'calamar_grill.png','','',0,0.000,0,0,0.00000),(223,224,0,'ENCORNET FARCI','ENCORNET FARCI','','','','','','',10,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'encornets-farcis.png','','',0,0.000,0,0,0.00000),(224,225,0,'GRATIN DE SAINT JACQUES E','GRATIN DE SAINT JACQUES E','','','','','','',10,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'gratin-de-saint-jacques.png','','',0,0.000,0,0,0.00000),(225,226,0,'MOULES A LA LUZIENNE','MOULES A LA LUZIENNE','','','','','','',10,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules_cuites.png','','',0,0.000,0,0,0.00000),(226,227,0,'MOULES A L\'ESPAGNOLE','MOULES A L\'ESPAGNOLE','','','','','','',10,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules.png','','',0,0.000,0,0,0.00000),(227,228,0,'MOULES FARCIES','MOULES FARCIES','','','','','','',10,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules_cuites.png','','',0,0.000,0,0,0.00000),(228,229,0,'MOULES MARINIERES','MOULES MARINIERES','','','','','','',10,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules_cuites.png','','',0,0.000,0,0,0.00000),(229,230,0,'MOULES VINCENT','MOULES VINCENT','','','','','','',10,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'moules_cuites.png','','',0,0.000,0,0,0.00000),(230,231,0,'PAELLA','PAELLA','','','','','','',10,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'paella.png','','',0,0.000,0,0,0.00000),(231,232,0,'SOUPE DE POISSON','SOUPE DE POISSON','','','','','','',10,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'soupe_poisson.png','','',0,0.000,0,0,0.00000),(232,233,0,'ZARZUELA','ZARZUELA','','','','','','',10,0,12,1,0,0,0,'',6.90,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'zarzuela.png','','',0,0.000,0,0,0.00000),(233,234,0,'ANCHOIS A LA CATALANE','ANCHOIS A LA CATALANE','','','','','','',11,0,1,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'anchois_huile.png','','',0,0.000,0,0,0.00000),(234,235,0,'ANCHOIS A L\'AIL','ANCHOIS A L\'AIL','','','','','','',11,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'anchois_huile.png','','',0,0.000,0,0,0.00000),(235,236,0,'ANCHOIS A L\'HUILE','ANCHOIS A L\'HUILE','','','','','','',11,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'anchois_huile.png','','',0,0.000,0,0,0.00000),(236,237,0,'ANCHOIS A L\'ORIENTALE','ANCHOIS A L\'ORIENTALE','','','','','','',11,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'anchois_huile.png','','',0,0.000,0,0,0.00000),(237,238,0,'BROCHETTES QUEUES DE CREV','BROCHETTES QUEUES DE CREV','','','','','','',11,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'brochette_crevettes.png','','',0,0.000,0,0,0.00000),(238,239,0,'BROCHETTES QUEUES DE CREV','BROCHETTES QUEUES DE CREV','','','','','','',11,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'brochette_crevettes.png','','',0,0.000,0,0,0.00000),(239,240,0,'CREVETTES AU CHUTNEY','CREVETTES AU CHUTNEY','','','','','','',11,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crevette_chutney.png','','',0,0.000,0,0,0.00000),(240,242,0,'FILETS DE MERLAN PANES','FILETS DE MERLAN PANES','','','','','','',11,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'merlan-pane.png','','',0,0.000,0,0,0.00000),(241,243,0,'MACEDOINE DE CRABE','MACEDOINE DE CRABE','','','','','','',11,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'macedoine_crabe.png','','',0,0.000,0,0,0.00000),(242,248,0,'MARINADE DE FRUITS DE MER','MARINADE DE FRUITS DE MER','','','','','','',11,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'marinade_fruit_mer.png','','',0,0.000,0,0,0.00000),(243,249,0,'MARINADE DE POULPE','MARINADE DE POULPE','','','','','','',11,0,11,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'marinade_poulpe.png','','',0,0.000,0,0,0.00000),(244,250,0,'PIEMONTAISE AUX DEUX SAUM','PIEMONTAISE AUX DEUX SAUM','','','','','','',11,0,12,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'piemontaise_saumon.png','','',0,0.000,0,0,0.00000),(245,251,0,'SALADE DE CALAMARS','SALADE DE CALAMARS','','','','','','',11,0,13,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(246,252,0,'SALADE DE CRUSTACES','SALADE DE CRUSTACES','','','','','','',11,0,14,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(247,253,0,'SALADE DE MORUE','SALADE DE MORUE','','','','','','',11,0,15,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(248,254,0,'SALADE DE THON TOSCANE','SALADE DE THON TOSCANE','','','','','','',11,0,16,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(249,255,0,'SALADE DU PECHEUR','SALADE DU PECHEUR','','','','','','',11,0,17,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(250,256,0,'SALADE FANTAISIE ECREVISS','SALADE FANTAISIE ECREVISS','','','','','','',11,0,18,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(251,257,0,'SALADE FRUITS DE MER','SALADE FRUITS DE MER','','','','','','',11,0,19,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(252,258,0,'SALADE GAMBAS MANDARINE','SALADE GAMBAS MANDARINE','','','','','','',11,0,20,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(253,259,0,'SALADE NEPTUNE','SALADE NEPTUNE','','','','','','',11,0,21,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(254,260,0,'SALADE PERLE OCEANE AU SA','SALADE PERLE OCEANE AU SA','','','','','','',11,0,22,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(255,261,0,'SALADE RIZ A LA NICOISE','SALADE RIZ A LA NICOISE','','','','','','',11,0,23,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(256,262,0,'SALADE TAGLIATELLE SURIMI','SALADE TAGLIATELLE SURIMI','','','','','','',11,0,24,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(257,263,0,'SALADE VINCENT','SALADE VINCENT','','','','','','',11,0,25,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'salade_mer.png','','',0,0.000,0,0,0.00000),(258,264,0,'TABOULE AU FRUITS DE MER','TABOULE AU FRUITS DE MER','','','','','','',11,0,26,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'taboulet_f_mer.png','','',0,0.000,0,0,0.00000),(259,265,0,'TIELLES SETOISES','TIELLES SETOISES','','','','','','',11,0,27,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'tielle.png','','',0,0.000,0,0,0.00000),(260,266,0,'BEIGNET CALAMARS','BEIGNET CALAMARS','','','','','','',12,0,1,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'beignet_calamar.png','','',0,0.000,0,0,0.00000),(261,267,0,'RABAS','RABAS','','','','','','',12,0,2,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'rabas.png','','',0,0.000,0,0,0.00000),(262,268,0,'ACCRA DE MORUE','ACCRA DE MORUE','','','','','','',12,0,3,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'accras-de-morue.png','','',0,0.000,0,0,0.00000),(263,269,0,'BEIGNETS DE CREVETTES MED','BEIGNETS DE CREVETTES MED','','','','','','',12,0,4,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'beignet-crevette.png','','',0,0.000,0,0,0.00000),(264,270,0,'BEIGNET PARMENTIER DE MOR','BEIGNET PARMENTIER DE MOR','','','','','','',12,0,5,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'beignets-parm_morue.png','','',0,0.000,0,0,0.00000),(265,271,0,'CROUSTILLANT DE CREVETTE','CROUSTILLANT DE CREVETTE','','','','','','',12,0,6,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'croustillant_crevettes.png','','',0,0.000,0,0,0.00000),(266,272,0,'NEMS AU CRABE','NEMS AU CRABE','','','','','','',12,0,7,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'nems.png','','',0,0.000,0,0,0.00000),(267,273,0,'NEMS CREVETTES','NEMS CREVETTES','','','','','','',12,0,8,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'nems.png','','',0,0.000,0,0,0.00000),(268,274,0,'ACCRA DE GAMBAS','ACCRA DE GAMBAS','','','','','','',12,0,9,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'accras-de-morue.png','','',0,0.000,0,0,0.00000),(269,275,0,'CRABES FARCIS','CRABES FARCIS','','','','','','',12,0,10,1,0,0,0,'',0.00,0,0.00,1,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'crabe_farci.png','','',0,0.000,0,0,0.00000),(270,276,0,'SUSHIS 6 PIECES','SUSHIS 6 PIECES','','','','','','',12,0,11,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sushi.png','','',0,0.000,0,0,0.00000),(271,277,0,'SUSHIS 11 PIECES','SUSHIS 11 PIECES','','','','','','',12,0,12,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sushi.png','','',0,0.000,0,0,0.00000),(272,300,0,'CHARDONNAY FRUITE PELLEHA','CHARDONNAY FRUITE PELLEHA','','','','','','',13,0,1,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vins-rouge-blanc-rose.png','','',0,0.000,0,0,0.00000),(273,301,0,'HARMONIE BLANC PELLEHAUT','HARMONIE BLANC PELLEHAUT','','','','','','',13,0,2,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vins-rouge-blanc-rose.png','','',0,0.000,0,0,0.00000),(274,302,0,'HARMONIE ROSE PELLEHAUT','HARMONIE ROSE PELLEHAUT','','','','','','',13,0,3,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vins-rouge-blanc-rose.png','','',0,0.000,0,0,0.00000),(275,303,0,'LYS BLANC BUZET','LYS BLANC BUZET','','','','','','',13,0,4,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vins-rouge-blanc-rose.png','','',0,0.000,0,0,0.00000),(276,304,0,'LYS ROSE BUZET','LYS ROSE BUZET','','','','','','',13,0,5,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vins-rouge-blanc-rose.png','','',0,0.000,0,0,0.00000),(277,305,0,'TURSAN BLANC','TURSAN BLANC','','','','','','',13,0,6,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'vins-rouge-blanc-rose.png','','',0,0.000,0,0,0.00000),(278,400,0,'4 SACHETS SEL','4 SACHETS SEL','','','','','','',14,0,1,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(279,401,0,'AROMATES POISSON','AROMATES POISSON','','','','','','',14,0,2,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'aromates.png','','',0,0.000,0,0,0.00000),(280,402,0,'BAQUET N°1','BAQUET N°1','','','','','','',14,0,3,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'baquet.png','','',0,0.000,0,0,0.00000),(281,403,0,'BARNDADE DE MORUE PETITE','BARNDADE DE MORUE PETITE','','','','','','',14,0,4,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'brandade.png','','',0,0.000,0,0,0.00000),(282,404,0,'BISQUE DE HOMARD','BISQUE DE HOMARD','','','','','','',14,0,5,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'bisque_homard.png','','',0,0.000,0,0,0.00000),(283,405,0,'BRANDADE DE MORUE GRANDE','BRANDADE DE MORUE GRANDE','','','','','','',14,0,6,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'brandade.png','','',0,0.000,0,0,0.00000),(284,406,0,'COURT BOUILLON','COURT BOUILLON','','','','','','',14,0,7,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'court-bouillon.png','','',0,0.000,0,0,0.00000),(285,407,0,'CROUTONS','CROUTONS','','','','','','',14,0,8,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'panure.png','','',0,0.000,0,0,0.00000),(286,408,0,'CURCUMA','CURCUMA','','','','','','',14,0,9,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'curcuma.png','','',0,0.000,0,0,0.00000),(287,409,0,'CURRY SELECTION','CURRY SELECTION','','','','','','',14,0,10,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'curry.png','','',0,0.000,0,0,0.00000),(288,410,0,'ENSOLEILLADE','ENSOLEILLADE','','','','','','',14,0,11,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'Ensoleillade.png','','',0,0.000,0,0,0.00000),(289,411,0,'EPICES BARBECUE','EPICES BARBECUE','','','','','','',14,0,12,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'epices-pour-barbecue.png','','',0,0.000,0,0,0.00000),(290,412,0,'FLEUR DE SEL 170 GRS','FLEUR DE SEL 170 GRS','','','','','','',14,0,13,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'fleur-de-sel.png','','',0,0.000,0,0,0.00000),(291,413,0,'FLEUR DE SEL AU PIMENT ES','FLEUR DE SEL AU PIMENT ES','','','','','','',14,0,14,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'fleur-de-sel.png','','',0,0.000,0,0,0.00000),(292,414,0,'HERBES DE PROVENCE','HERBES DE PROVENCE','','','','','','',14,0,15,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'herbes-de-provence.png','','',0,0.000,0,0,0.00000),(293,415,0,'HUILE AVOCAT','HUILE AVOCAT','','','','','','',14,0,16,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'huiles.png','','',0,0.000,0,0,0.00000),(294,416,0,'HUILE NOISETTE','HUILE NOISETTE','','','','','','',14,0,17,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'huiles.png','','',0,0.000,0,0,0.00000),(295,417,0,'HUILE PISTACHE','HUILE PISTACHE','','','','','','',14,0,18,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'huiles.png','','',0,0.000,0,0,0.00000),(296,418,0,'HUILE SESAME','HUILE SESAME','','','','','','',14,0,19,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'huiles.png','','',0,0.000,0,0,0.00000),(297,419,0,'HUILE WOK THAI','HUILE WOK THAI','','','','','','',14,0,20,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'huiles.png','','',0,0.000,0,0,0.00000),(298,420,0,'LA TARTINE ESPRIT DE SEL','LA TARTINE ESPRIT DE SEL','','','','','','',14,0,21,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(299,421,0,'LAURIER','LAURIER','','','','','','',14,0,22,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'laurier.png','','',0,0.000,0,0,0.00000),(300,422,0,'MOULIN SEL MARIN FOU','MOULIN SEL MARIN FOU','','','','','','',14,0,23,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(301,423,0,'MOULIN SEL MARIN GRILLADE','MOULIN SEL MARIN GRILLADE','','','','','','',14,0,24,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(302,424,0,'MOULIN SEL MARIN POISSON','MOULIN SEL MARIN POISSON','','','','','','',14,0,25,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(303,425,0,'MOUTARDE A LA SALICORNE','MOUTARDE A LA SALICORNE','','','','','','',14,0,26,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'rouille-pot.png','','',0,0.000,0,0,0.00000),(304,426,0,'MOUTARDE A L\'ANCIENNE A L','MOUTARDE A L\'ANCIENNE A L','','','','','','',14,0,27,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'rouille-pot.png','','',0,0.000,0,0,0.00000),(305,427,0,'PANURE POUR POISSON','PANURE POUR POISSON','','','','','','',14,0,28,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'panure.png','','',0,0.000,0,0,0.00000),(306,428,0,'PIMENT ESPELETTE','PIMENT ESPELETTE','','','','','','',14,0,29,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'piment.png','','',0,0.000,0,0,0.00000),(307,429,0,'PIMENT FORT','PIMENT FORT','','','','','','',14,0,30,1,0,0,0,'',18.60,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'piment.png','','',0,0.000,0,0,0.00000),(308,430,0,'POT FLEUR DE SEL 200GRS','POT FLEUR DE SEL 200GRS','','','','','','',14,0,31,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'fleur-de-sel.png','','',0,0.000,0,0,0.00000),(309,431,0,'ROUILLE','ROUILLE','','','','','','',14,0,32,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'rouille-pot.png','','',0,0.000,0,0,0.00000),(310,432,0,'SACHET SEL MARIN FOU 70 G','SACHET SEL MARIN FOU 70 G','','','','','','',14,0,33,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(311,433,0,'SALIERE  FLEUR DE SEL 70G','SALIERE  FLEUR DE SEL 70G','','','','','','',14,0,34,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(312,434,0,'SARDINES HUILE OLIVE','SARDINES HUILE OLIVE','','','','','','',14,0,35,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sardines-huile.png','','',0,0.000,0,0,0.00000),(313,435,0,'SARDINES HUILE OLIVE ET C','SARDINES HUILE OLIVE ET C','','','','','','',14,0,36,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sardines-huile.png','','',0,0.000,0,0,0.00000),(314,436,0,'SARDINES PIMENT AROMATES','SARDINES PIMENT AROMATES','','','','','','',14,0,37,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sardines-huile.png','','',0,0.000,0,0,0.00000),(315,437,0,'SAUCE AMERICAINE','SAUCE AMERICAINE','','','','','','',14,0,38,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sauces.png','','',0,0.000,0,0,0.00000),(316,438,0,'SAUCE BEURRE BLANC','SAUCE BEURRE BLANC','','','','','','',14,0,39,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sauces.png','','',0,0.000,0,0,0.00000),(317,439,0,'SAUCE CITRON','SAUCE CITRON','','','','','','',14,0,40,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sauces.png','','',0,0.000,0,0,0.00000),(318,440,0,'SAUCE HOLLANDAISE','SAUCE HOLLANDAISE','','','','','','',14,0,41,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sauces.png','','',0,0.000,0,0,0.00000),(319,441,0,'SAUCE OSEILLE','SAUCE OSEILLE','','','','','','',14,0,42,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sauces.png','','',0,0.000,0,0,0.00000),(320,442,0,'SEL MARIN CHIFFONADE','SEL MARIN CHIFFONADE','','','','','','',14,0,43,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(321,443,0,'SEL MARIN GRILLADES','SEL MARIN GRILLADES','','','','','','',14,0,44,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(322,444,0,'SEL MARIN PECHE MIGNON','SEL MARIN PECHE MIGNON','','','','','','',14,0,45,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(323,445,0,'SEL MARIN POISSON 160 GRS','SEL MARIN POISSON 160 GRS','','','','','','',14,0,46,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sel_parfum.png','','',0,0.000,0,0,0.00000),(324,446,0,'SOUPE DE POISSON 750','SOUPE DE POISSON 750','','','','','','',14,0,47,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'soupe_poisson.png','','',0,0.000,0,0,0.00000),(325,447,0,'SOUPE DE POISSON LITRE','SOUPE DE POISSON LITRE','','','','','','',14,0,48,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'soupe_poisson.png','','',0,0.000,0,0,0.00000),(326,448,0,'SPIGOL','SPIGOL','','','','','','',14,0,49,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'spigol.png','','',0,0.000,0,0,0.00000),(327,449,0,'THON BLANC HUILE D\'OLIVE','THON BLANC HUILE D\'OLIVE','','','','','','',14,0,50,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'thon.png','','',0,0.000,0,0,0.00000),(328,450,0,'TUBE 3 MINI POTS','TUBE 3 MINI POTS','','','','','','',14,0,51,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'sauces.png','','',0,0.000,0,0,0.00000),(329,451,0,'ZARZUELA GRANDE','ZARZUELA GRANDE','','','','','','',14,0,52,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'zarzuela.png','','',0,0.000,0,0,0.00000),(330,452,0,'ZARZUELLA PETITE','ZARZUELLA PETITE','','','','','','',14,0,53,1,0,0,0,'',0.00,0,0.00,0,0,1,0,0,'',0,0,0.000,'','-',0,'','','','-',0,'zarzuela.png','','',0,0.000,0,0,0.00000);

--
-- Dumping data for table `itemsallergenicons`
--


--
-- Dumping data for table `itemschangepoints`
--


--
-- Dumping data for table `itemsean128`
--


--
-- Dumping data for table `itemsean13`
--


--
-- Dumping data for table `itemsextrapoints`
--


--
-- Dumping data for table `itemsformats`
--


--
-- Dumping data for table `itemtextbonus`
--


--
-- Dumping data for table `itemtextcommon`
--


--
-- Dumping data for table `localcfgforms`
--

INSERT INTO `localcfgforms` VALUES (1,'reports','DAILY_DATE_ALL','0'),(2,'reports','DAILY_DATE_TODAY','0'),(3,'reports','DAILY_DATE_SELECT','1'),(4,'reports','DAILY_DAILYPRINT','1'),(5,'reports','DAILY_VATPRINT','1'),(6,'reports','DAILY_PAYMENTPRINT','1'),(7,'reports','DAILY-DETAIL','1'),(8,'reports','DAILY_ORDER','1'),(9,'reports','DAILY_TRAINING','1'),(10,'reports','TICKET-GROUP','0'),(11,'reports','TICKET-DETAIL','3'),(12,'reports','TOTAL-GROUP','1'),(13,'reports','TOTAL-BROKEN','0'),(14,'reports','CASHDRAWER-GROUP','0'),(15,'reports','CASHDRAWER-BROKEN','0'),(16,'reports','EMAIL-TO','');

--
-- Dumping data for table `localcfgkeyboard`
--

INSERT INTO `localcfgkeyboard` VALUES (1,'back_screen','1024x768'),(2,'menu','bionic'),(3,'turn','none');

--
-- Dumping data for table `localcfgparams`
--


--
-- Dumping data for table `localcfgscale`
--

INSERT INTO `localcfgscale` VALUES (7,'TOUCH/scale-icon','scale'),(8,'TOUCH/loader','1'),(10,'TOUCH/slave-icon','slave'),(12,'TOUCH/items-dnd','1'),(13,'TOUCH/vendor-icon','vnd3'),(24,'RESOURCES/user-icons-path','../share/pcscale/resources/icons/item'),(28,'NETWORK/scale-number','1'),(29,'CORE/mup-group','1'),(30,'CORE/plu-board-group','1'),(31,'NETWORK/scale-counter','1'),(40,'TOUCH/name','Classic'),(41,'sw-full-version','2.18 - Methone. Build id: 20171030 - 2691'),(42,'serial-number','888036'),(43,'PRINTER/lbl-format','J45X57'),(44,'PRINTER/prn-format','estandar+logo_LL'),(46,'TOUCH/language','fr_FR'),(71,'TOUCH/background','Generic'),(119,'backup-path','/home/pcscale/scale/backup'),(191,'sw-version-weight','MBPT-SPEN000100-0.58'),(296,'SCALE/prices-without-taxes','0'),(316,'TOUCH/GROUPS/menu/default','menu01'),(317,'TOUCH/GROUPS/VendorsGroup/default','Vnd-board-Classic1'),(318,'TOUCH/GROUPS/scroll-sales/default','kbd-PLUBoard-Classic1');

--
-- Dumping data for table `localcomm`
--


--
-- Dumping data for table `localints`
--

INSERT INTO `localints` VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

--
-- Dumping data for table `locallicenses`
--


--
-- Dumping data for table `localstatus`
--

INSERT INTO `localstatus` VALUES (1,156,'2.24.4216','fr_FR',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0);

--
-- Dumping data for table `localtreeboard`
--


--
-- Dumping data for table `localvendorkeys`
--

INSERT INTO `localvendorkeys` VALUES (1,1,101),(1,2,102),(1,3,103),(1,4,104);

--
-- Dumping data for table `localvendorregister`
--


--
-- Dumping data for table `localworkingmodes`
--

INSERT INTO `localworkingmodes` VALUES (3,'00 sales','based','sales'),(8,'01 packet','based','packet'),(9,'01 packet','description','Packet'),(10,'01 packet','keyboard','packet'),(11,'01 packet','user','admin'),(12,'01 packet','keyboard-loop','packet-loop'),(13,'01 packet','in-use','1'),(14,'02 selfservice','based','selfservice'),(20,'03 pos','based','sales'),(21,'03 pos','description','TPV'),(22,'03 pos','keyboard','POS'),(23,'03 pos','user','admin'),(24,'03 pos','in-use','1'),(93,'01 packet','user-check-mode-form','OFF'),(94,'01 packet','user-check-mode','OFF'),(95,'01 packet','user-prog-prices','ON'),(96,'01 packet','sections',''),(97,'01 packet','packet-customer','ON'),(98,'01 packet','show-print-packet','ON'),(99,'01 packet','allow-mult-key','ON'),(100,'01 packet','packet-vendor','0'),(101,'01 packet','show-form-packet','0'),(102,'01 packet','packet-after-item','OFF'),(103,'01 packet','autocode','ON'),(104,'01 packet','pluprc-key','ON'),(105,'01 packet','constant-key','ON'),(106,'01 packet','change-price','ON'),(107,'01 packet','amount-zero','ON'),(108,'01 packet','negative-amount','ON'),(109,'01 packet','code-digits','6'),(110,'01 packet','item-access','0'),(111,'01 packet','mixed-allowed','ON'),(112,'01 packet','weightlow-tsec','0'),(113,'01 packet','weightlow-beep','ON'),(114,'01 packet','weightlow-zero','OFF'),(115,'00 sales','user-check-mode-form','OFF'),(116,'00 sales','user-check-mode','OFF'),(117,'00 sales','user-prog-prices','ON'),(118,'00 sales','sections',''),(119,'00 sales','print-ticket','ON'),(120,'00 sales','print-label-total','OFF'),(121,'00 sales','print-label-line','OFF'),(122,'00 sales','close-with-line','OFF'),(123,'00 sales','total-discount','ON'),(124,'00 sales','sales-customer','ON'),(125,'00 sales','allow-orders','ON'),(126,'00 sales','payment','2'),(127,'00 sales','startlocal','0'),(128,'00 sales','allow-cancel','ON'),(129,'00 sales','allow-reload','ON'),(130,'00 sales','allow-amount0','ON'),(131,'00 sales','auto-fix','OFF'),(132,'00 sales','times-print','250'),(134,'00 sales','autocode','ON'),(135,'00 sales','pluprc-key','ON'),(136,'00 sales','constant-key','ON'),(137,'00 sales','change-price','ON'),(138,'00 sales','return-weight','OFF'),(139,'00 sales','amount-zero','ON'),(140,'00 sales','negative-amount','ON'),(141,'00 sales','code-digits','6'),(142,'00 sales','item-access','0'),(143,'00 sales','pos-method','OFF'),(144,'00 sales','clear-tare','ON'),(145,'00 sales','weightlow-tsec','0'),(146,'00 sales','weightlow-beep','ON'),(147,'00 sales','weightlow-zero','OFF'),(148,'03 pos','user-check-mode-form','OFF'),(149,'03 pos','user-check-mode','OFF'),(150,'03 pos','user-prog-prices','ON'),(151,'03 pos','sections',''),(152,'03 pos','print-ticket','ON'),(153,'03 pos','print-label-total','OFF'),(154,'03 pos','print-label-line','OFF'),(155,'03 pos','close-with-line','OFF'),(156,'03 pos','total-discount','ON'),(157,'03 pos','sales-customer','ON'),(158,'03 pos','allow-orders','ON'),(159,'03 pos','payment','0'),(160,'03 pos','startlocal','0'),(161,'03 pos','allow-cancel','ON'),(162,'03 pos','allow-reload','ON'),(163,'03 pos','allow-amount0','ON'),(164,'03 pos','auto-fix','ON'),(165,'03 pos','times-print','250'),(167,'03 pos','autocode','OFF'),(168,'03 pos','pluprc-key','ON'),(169,'03 pos','constant-key','ON'),(170,'03 pos','change-price','ON'),(171,'03 pos','return-weight','ON'),(172,'03 pos','amount-zero','ON'),(173,'03 pos','negative-amount','ON'),(174,'03 pos','code-digits','6'),(175,'03 pos','item-access','0'),(176,'03 pos','pos-method','ON'),(177,'03 pos','clear-tare','OFF'),(178,'03 pos','weightlow-tsec','0'),(179,'03 pos','weightlow-beep','ON'),(180,'03 pos','weightlow-zero','OFF'),(191,'02 selfservice','description','Autoservicio'),(192,'02 selfservice','keyboard','selfservice'),(193,'02 selfservice','user','admin'),(194,'02 selfservice','keyboard-loop',''),(195,'02 selfservice','keyboard-vendors',''),(196,'02 selfservice','in-use','0'),(203,'00 sales','description','Balance'),(204,'00 sales','keyboard','salesFamilies'),(205,'00 sales','user','admin'),(206,'00 sales','keyboard-loop',''),(207,'00 sales','keyboard-vendors',''),(208,'00 sales','in-use','1'),(219,'','working-mode','00 sales'),(220,'00 sales','print-ticket-suborder','ON'),(221,'03 pos','print-ticket-suborder','ON'),(223,'00 sales','print-label-total-suborder','OFF'),(224,'03 pos','print-label-total-suborder','OFF'),(226,'00 sales','print-ticket-order','ON'),(227,'03 pos','print-ticket-order','ON'),(229,'00 sales','print-label-order','OFF'),(230,'03 pos','print-label-order','OFF'),(235,'00 sales','key-fnc-on-pressed','0'),(238,'00 sales','keyboard-orders',''),(239,'00 sales','PLUload-func','2'),(240,'00 sales','PLUload-mode','1'),(241,'00 sales','current-data-mode','0'),(242,'00 sales','reprint-ticket','ON'),(243,'00 sales','reprint-label-total','OFF'),(244,'03 pos','reprint-ticket','ON'),(245,'03 pos','reprint-label-total','OFF'),(249,'00 sales','auto-vendor','ON'),(250,'00 sales','vendor-hide-code','OFF'),(251,'00 sales','vendor-summary','OFF'),(252,'00 sales','customer-care','OFF'),(253,'00 sales','park-ticket','ON'),(254,'00 sales','single-section','OFF'),(255,'00 sales','ean13-section-item','OFF'),(256,'00 sales','ticket-format',''),(257,'00 sales','label-format',''),(258,'00 sales','parking-format','parked'),(259,'00 sales','reload-type','1'),(260,'00 sales','reprint-type','1'),(261,'00 sales','ticket-days','1'),(262,'00 sales','allow-training','OFF'),(263,'00 sales','simplified-invoice','OFF'),(264,'00 sales','cancel-hanged','0'),(265,'00 sales','cancel-hanged-time','10'),(266,'00 sales','group-order-tickets','ON'),(267,'00 sales','group-order-as-invoice','OFF'),(268,'00 sales','hold-plu-to-set','Full'),(269,'00 sales','plukey-dnd','Full'),(270,'00 sales','user-pricerates','ON'),(271,'00 sales','save-code128','0'),(272,'00 sales','allow-customer-order','ON'),(297,'00 sales','change-price0','ON'),(298,'00 sales','weight-min','0,000'),(299,'00 sales','amount-min','0,00'),(300,'00 sales','pricerate','0'),(325,'00 sales','group-parked-tickets','OFF'),(326,'00 sales','group-parked-as-invoice','OFF'),(327,'00 sales','drawer-with-password','OFF'),(328,'00 sales','drawer-key-on-vendor-menu','OFF'),(329,'00 sales','allow-ticket-check','ON'),(330,'00 sales','max-lines-99','OFF'),(380,'00 sales','change-saleform','ON'),(399,'00 sales','drawer-direct','OFF'),(400,'00 sales','drawer-open-print','ON'),(475,'00 sales','number-of-packages','OFF'),(476,'00 sales','print-refund','OFF'),(477,'00 sales','print-label-package','OFF'),(478,'00 sales','reprint-label-package','OFF'),(479,'00 sales','park-reprint','OFF'),(480,'00 sales','line-discount','ON'),(481,'00 sales','slice-ticket-lines',''),(482,'00 sales','slice-ticket-header',''),(483,'00 sales','item-formats','0'),(484,'00 sales','manual-weight','OFF'),(485,'00 sales','allow-bovine','ON'),(486,'00 sales','edit-bovine-card','OFF'),(487,'00 sales','parking-order-format',''),(488,'00 sales','order-as-ticket','ON'),(489,'00 sales','order-allow-bovine','ON'),(490,'00 sales','order-edit-bovine-card','OFF'),(491,'00 sales','ask-replace','OFF'),(492,'00 sales','button-remark','OFF'),(493,'00 sales','piece-counting','OFF'),(494,'00 sales','over-under','OFF'),(573,'','user-check-menu-form','OFF');

--
-- Dumping data for table `numberingtickets`
--

INSERT INTO `numberingtickets` VALUES (1,'T','','',0,0,1,9999,9999,0,'D',0,0,0,0),(2,'D','','',1,0,1,9999,9999,0,'D',0,0,0,0),(3,'I','1400101','',1,0,1,9999,9999,0,'D',0,0,0,0);

--
-- Dumping data for table `nutrition`
--


--
-- Dumping data for table `overunderlevels`
--


--
-- Dumping data for table `paymethods`
--

INSERT INTO `paymethods` VALUES (1,0,'ESPECES',1),(2,1,'CB',1),(3,2,'CHEQUE',1),(4,3,'PAYMETHOD3',0),(5,4,'PAYMETHOD4',0),(6,5,'PAYMETHOD5',0),(7,6,'PAYMETHOD6',0);

--
-- Dumping data for table `pktfishery`
--


--
-- Dumping data for table `pktgeneric`
--


--
-- Dumping data for table `pktvegetables`
--


--
-- Dumping data for table `playlists`
--


--
-- Dumping data for table `plugins`
--


--
-- Dumping data for table `plukeys`
--

INSERT INTO `plukeys` VALUES (1,11,0,1,1),(2,11,0,2,2),(4,11,0,4,4),(5,11,0,5,5),(6,11,0,6,6),(7,11,0,7,7),(8,11,0,8,8),(9,11,0,9,9),(10,11,0,10,10),(11,11,0,11,11),(12,11,0,12,12),(13,11,0,13,13),(14,11,0,14,14),(15,11,0,15,15),(16,11,0,16,16),(17,11,0,17,17),(18,11,0,18,18),(19,11,0,19,19),(20,11,0,20,20),(21,11,0,21,21),(22,11,0,22,22),(23,11,0,23,23),(24,11,0,24,24),(25,11,0,25,25),(26,11,0,26,26),(27,11,0,27,27),(28,11,0,28,28),(29,11,0,29,29),(30,11,0,30,30),(31,11,0,31,31),(32,11,0,32,32),(33,11,0,33,33),(34,11,0,34,34),(35,11,0,35,35),(36,11,0,36,36),(37,11,0,37,37),(38,11,0,39,40),(39,11,0,38,39),(40,11,0,40,41),(41,11,1,1,143),(42,11,1,2,147),(43,11,1,3,148),(44,11,1,4,166),(45,11,1,5,170),(46,11,1,6,183),(47,11,1,7,197),(48,11,1,8,199),(49,11,1,9,202),(50,11,1,10,210),(51,1,0,1,1),(52,1,0,2,2),(53,1,0,3,3),(54,1,0,4,4),(55,1,0,5,5),(56,1,0,6,6),(57,1,0,7,7),(58,1,0,8,8),(59,1,0,9,9),(60,1,0,10,10),(61,1,0,11,11),(62,1,0,12,12),(63,1,0,13,13),(64,1,0,14,14),(65,1,0,15,15),(66,1,0,16,16),(67,1,0,17,17),(68,1,0,18,18),(69,1,0,19,19),(70,1,0,20,20),(71,1,0,21,21),(72,1,0,22,22),(73,1,0,23,23),(74,1,0,24,24),(75,1,0,25,25),(76,1,0,26,26),(77,1,0,27,27),(78,1,0,28,28),(79,1,0,29,29),(80,1,0,30,30),(81,1,0,31,31),(82,1,0,32,32),(83,1,0,33,33),(84,1,0,34,34),(85,1,0,35,35),(86,1,0,36,36),(87,1,0,37,37),(88,1,0,38,39),(89,1,0,39,40),(90,1,0,40,41),(91,1,1,1,143),(92,1,1,2,147),(93,1,1,3,148),(94,1,1,4,166),(95,1,1,5,170),(96,1,1,6,183),(97,1,1,7,197),(98,1,1,8,199),(99,1,1,9,202),(100,1,1,10,210),(101,0,1,1,1),(102,0,1,2,32),(103,0,1,3,11),(104,0,1,4,183),(105,0,1,5,202),(106,0,1,6,412);

--
-- Dumping data for table `plukeysfile`
--


--
-- Dumping data for table `pricerates`
--

INSERT INTO `pricerates` VALUES (0,'');

--
-- Dumping data for table `qrfields`
--

INSERT INTO `qrfields` VALUES (1,'H','[]',1,'F',0,'123'),(2,'H','Number',2,'N',6,'0FILLED'),(3,'H','DatTim',3,'D',0,'%y%m%d%H%i%s'),(4,'H','AddedLines',4,'N',2,'0FILLED'),(5,'H','NetAmount',5,'M',6,'0FILLED DPNONE'),(6,'L','[]',1,'F',0,'1'),(7,'L','Item',2,'N',5,'0FILLED'),(8,'L','Weight',3,'Q',5,'0FILLED DPNONE'),(9,'L','Price',4,'M',5,'0FILLED DPNONE'),(10,'L','Amount',5,'M',5,'0FILLED DPNONE'),(11,'','[]',1,'',0,'check128');

--
-- Dumping data for table `quickkeys`
--


--
-- Dumping data for table `scheduler`
--


--
-- Dumping data for table `scripts`
--

INSERT INTO `scripts` VALUES (1,'Export','#!/bin/bash\n##\n# Scrip que exporta la tabla de aticulos de pcscale a un dispositivo USB\n# Monta una memoria formateada con FAT32. En otros casos consulta el manual de mount\n\n#Exportación de archivo\nexport_file()\n{\ncd /var/lib/mysql/\nmysql -pepelsa -upcscale pcscale -e\"SELECT Items.code,Items.name,Items.SaleForm,Items.price,Items.family,families.name,Items.vat,Vats.name,Vats.percent FROM Items LEFT JOIN vats ON Items.vat=vats.Code LEFT JOIN families ON families.code=items.family ORDER BY items.code INTO OUTFILE \'/var/lib/mysql/progArticles.csv\' FIELDS TERMINATED BY \';\' ENCLOSED BY \'\\\"\' \nLINES TERMINATED BY \'\\n\'\"\nif [ ! -d \"/home/pcscale/Escritorio/xls\" ] ; then \n	mkdir \"/home/pcscale/Escritorio/xls\" ; \nfi\nsudo pcs-exec mv  /var/lib/mysql/progArticles.csv /home/pcscale/Escritorio/xls/.\nsudo pcs-exec chmod -R 777 /home/pcscale/Escritorio/xls/\n}\n\n# Detección dispositivo\ndetect_usb()\n{\nusb=\"sdb\"\ngrep -q \"/dev/sdb1\"  /proc/mounts\nif [ $? -eq 0 ]; then\n	usb=\"sdb1\"\nelse\n	grep -q \"/dev/sdb\"  /proc/mounts\n	if [ $? -eq 0 ]; then\n		usb=\"sdb\"\n	else\n		grep -q \"/dev/sdc1\"  /proc/mounts\n		if [ $? -eq 0 ]; then\n			usb=\"sdc1\"\n		else\n			grep -q \"/dev/sdc\"  /proc/mounts\n			if [ $? -eq 0 ]; then\n				usb=\"sdc\"\n			else\n				echo \"no se ha encontrado dispositivo usb\"\n				exit 0\n			fi\n		fi\n	fi\nfi\necho El dispositivo se ha creado sobre $usb\n}\n\n#Monta dispositivo sobre  \"/media/xls\"\nmount_device()\n{\n# Cambia el directorio por el que mas te interese\nif [ ! -d \"/media/xls\" ] ; then \n	sudo pcs-exec mkdir \"/media/xls\" ;\nfi\nsudo pcs-exec /bin/mount -t vfat -o shortname=mixed,iocharset=utf8 /dev/$usb \"/media/xls\"\n}\n\n\n# Sincroniza el contenido de \"/home/pcscale/Escritorio/xls/\" con \"/media/xls/\"\nsync_file()\n{	\n# De esta manera sincroniza desde el dispositivo USB a nuestro equipo, pero sin borrar el contenido de nuestro equipo, y copiando solo aquellos archivos que no existen.\nsudo pcs-exec rsync -rtv --modify-window=2 \"/home/pcscale/Escritorio/xls/\" \"/media/xls/\"\n# Fuerza la sincronización antes de desmontar\nsudo pcs-exec sync\n}\n\n# Desmontamos y Borramos el directorio\n\numount_device()\n{\nsudo pcs-exec umount \"/media/xls\"\nsudo pcs-exec rm -R \"/media/xls\"\n}\n\nexport_file\ndetect_usb\nmount_device\nsync_file\numount_device\nzenity --info --title=\"EXPORT ARTICLES\" --text \"Export effectué\"\nexit 0\n\n\n');

--
-- Dumping data for table `sections`
--


--
-- Dumping data for table `shortcuts`
--


--
-- Dumping data for table `status`
--

INSERT INTO `status` VALUES (1,156,'2.24.4216');

--
-- Dumping data for table `tarecodes`
--


--
-- Dumping data for table `trademark`
--

INSERT INTO `trademark` VALUES (1,'POISSONS','','','','','','','','','',0,'','','','','','123456','','BONNE JOURNEE !','','','','','','','','','','');

--
-- Dumping data for table `turn`
--


--
-- Dumping data for table `turnswaiting`
--


--
-- Dumping data for table `users`
--

INSERT INTO `users` VALUES (1,'admin','YWRtaW4=','Administrator',0,1,0,0,0),(2,'sales','c2FsZXM=','Sales user',0,0,0,0,1),(3,'packet','cGFja2V0','Packet user',0,0,0,0,1),(4,'sservice','c3NlcnZpY2U=','Self-Service user',0,0,0,0,0);

--
-- Dumping data for table `vatexemptions`
--


--
-- Dumping data for table `vats`
--

INSERT INTO `vats` VALUES (5,0,'Sans TVA',0.00),(10,1,'Réduit',5.50),(11,2,'Intermédiaire',10.00),(12,3,'Normal',20.00);

--
-- Dumping data for table `vendorkeys`
--

INSERT INTO `vendorkeys` VALUES (1,1,101),(1,2,102),(1,3,103),(1,4,104);

--
-- Dumping data for table `vendorregister`
--


--
-- Dumping data for table `vendors`
--

INSERT INTO `vendors` VALUES (101,'Ryan','','ryan-gosling.jpg','0'),(102,'Charlize','','charlize_theron.jpeg','0'),(103,'Scarlet','','Scarlett-Johansson.jpg','0'),(104,'Phil','','phil_mickelson.jpg','0');

--
-- Dumping data for table `vitamins`
--


--
-- Dumping routines for database 'pcscale'
--
/*!50003 DROP FUNCTION IF EXISTS `gs1_checkdigit` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `gs1_checkdigit`(base VARCHAR(17)) RETURNS char(1) CHARSET utf8
    DETERMINISTIC
BEGIN
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    DECLARE odds INTEGER DEFAULT 0;     
    DECLARE evens INTEGER DEFAULT 0;    
    DECLARE total INTEGER DEFAULT 0;    
    DECLARE len INTEGER;                
    DECLARE pos INTEGER DEFAULT 0;      
    DECLARE digit INTEGER;              
    DECLARE cd INTEGER;                 
    
    
    SET len = LENGTH(base);
    mainloop: LOOP
        
        
        SET digit = CAST(SUBSTRING(base, len-pos, 1) AS SIGNED INTEGER);
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        IF (pos % 2 = 0)
        THEN
            SET evens = evens + digit;
        ELSE
            SET odds = odds + digit;
        END IF;
        
        
        SET pos = pos + 1;
        IF (pos < LEN)
        THEN
            ITERATE mainloop;
        END IF;
        LEAVE mainloop;
    END LOOP mainloop;
    
    
    SET total = odds + (3 * evens);
    SET cd = total % 10;
    IF (cd <> 0)
    THEN
        SET cd = 10 - cd;
    END IF;
    
    RETURN (CAST(cd AS CHAR));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `pcs_net` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `pcs_net`(gross DECIMAL(10,2), discount DECIMAL(4,2), points DECIMAL(10,2)) RETURNS decimal(10,2)
    DETERMINISTIC
BEGIN
  DECLARE net DECIMAL(10,2);

  SET @amount_round := IFNULL(GLOBAL_GET("amount_round"), 0);
  SET @frac_digits := IFNULL(GLOBAL_GET("frac_digits"), 2);
  SET net=gross - ROUND((gross*discount)/100, @frac_digits) - points;
  IF(@amount_round=5) THEN
    SET net=(ROUND(net/5, @frac_digits) * 5);
  END IF;

  RETURN net;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `pcs_total_to_pay` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `pcs_total_to_pay`(id_ticket INTEGER, src_db TINYTEXT) RETURNS decimal(10,2)
    DETERMINISTIC
BEGIN
  DECLARE total DECIMAL(10,2);
  DECLARE without_taxes BOOLEAN DEFAULT FALSE;	
  SET without_taxes = (SELECT (IFNULL((SELECT `ParamValue` FROM `CfgSystem` WHERE `ParamKey`='prices-without-taxes'), 0)=1));
  IF(without_taxes=0) THEN
    IF(src_db='HTickets') THEN
      SET total = (SELECT `NetAmount` FROM `HTickets` WHERE `Id`=id_ticket);
    ELSE  
      SET total = (SELECT `NetAmount` FROM `LocalHTickets` WHERE `Id`=id_ticket);
    END IF;

  ELSE
    IF(src_db='HTickets') THEN
      SET total = (SELECT SUM(V_VAT.Amount) + SUM(CAST(((V_VAT.Amount*Percentage)/100) AS DECIMAL(10,2))) FROM
        (SELECT lt.`VATPercent`+'0' AS Percentage, CAST((SUM(lt.`Amount`)*(ht.`NetAmount`/ht.`GrossAmount`)) AS DECIMAL(10,2)) AS Amount
         FROM `HTickets` AS ht
         LEFT JOIN `LTickets` AS lt ON ht.`Id`=lt.`IdHTicket`
         WHERE ht.`Id`=id_ticket AND `lineType`=1 GROUP BY lt.`VATCode`) AS V_VAT);
    ELSE  
      SET total = (SELECT SUM(V_VAT.Amount) + SUM(CAST(((V_VAT.Amount*Percentage)/100) AS DECIMAL(10,2))) FROM
        (SELECT lt.`VATPercent`+'0' AS Percentage, CAST((SUM(lt.`Amount`)*(ht.`NetAmount`/ht.`GrossAmount`)) AS DECIMAL(10,2)) AS Amount
         FROM `LocalHTickets` AS ht
         LEFT JOIN `LocalLTickets` AS lt ON ht.`Id`=lt.`IdHTicket`
         WHERE ht.`Id`=id_ticket AND `lineType`=1 GROUP BY lt.`VATCode`) AS V_VAT);
    END IF;
  END IF;

  RETURN total;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DataloggerFiscalChange` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `DataloggerFiscalChange`(OldName VARCHAR(32), NewName VARCHAR(32), OldEnabled BOOLEAN, NewEnabled BOOLEAN )
BEGIN
  DECLARE msg VARCHAR(255) DEFAULT '';
  IF ((NewName!=OldName) OR (NewEnabled!=OldEnabled)) THEN
    SELECT (SELECT COUNT(*) FROM information_schema.global_status WHERE variable_name='SLAVE_RUNNING' AND VARIABLE_VALUE='ON'), (SELECT COUNT(*) FROM information_schema.processlist WHERE INFO='SELECT trx_get()') INTO @_slave_,@_app_running_;
    IF (@_slave_ = 0) THEN
      IF (NewName = OldName) THEN
        SET msg := CONCAT('Fiscal module ', NewName, IF(NewEnabled, ' enabled', ' disabled'));
      ELSEIF (NewName = '') THEN
        SET msg := CONCAT('Fiscal module ', OldName, ' dropped.');
      ELSEIF (OldName = '') THEN
        SET msg := CONCAT('Fiscal module ', NewName, ' raised. ',IF(NewEnabled, 'Enabled', 'Disabled'));
      ELSE
        SET msg := CONCAT('Fiscal module ', OldName, ' changed to ', NewName, IF(NewEnabled, '. Enabled', '. Disabled'));
      END IF;
    END IF;
    IF (@_app_running_ = 0) THEN
      INSERT INTO `LocalDataLogger` SET Type=134, DatTim=NOW(), Message=msg;
    ELSE
      SET @trx := (SELECT trx_new("FISCAL_RELOAD", "NETWORK"));
      SET @ret := (SELECT trx_set_param(@trx, "LOG", msg));
      SET @ret := (SELECT trx_send(@trx));
    END IF;
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `dbTrigger` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `dbTrigger`(IN `tbname` VARCHAR (40), `function` VARCHAR (10), `masterkey` VARCHAR (40))
BEGIN
    SET @trx := (SELECT trx_new("DBTRIGGER", "CORE"));
    SET @ret := (SELECT trx_set_param(@trx, "TABLE", `tbname`));
    SET @ret := (SELECT trx_set_param(@trx, "FUNCTION", `function`));
    SET @ret := (SELECT trx_set_param(@trx, "KEY", `masterkey`));
    SET @ret := (SELECT trx_send(@trx));
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `LocalTreeBoardFromPLUKeysFile` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `LocalTreeBoardFromPLUKeysFile`()
BEGIN


  DELETE FROM `LocalTreeBoard`;
  SET @rownumber:=100000;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`,`Source3`,`Source4`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2`, puk.`Source3`, puk.`Source4` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`!=0 AND puk.`Source5`!=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`,`Source3`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2`, puk.`Source3` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`!=0 AND puk.`Source5`=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2` AS kl FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`=0 AND puk.`Source5`=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`=0  AND puk.`Source4`=0 AND puk.`Source5`=0) AS VT;

  SET @rownumber:=0;
  UPDATE `LocalTreeBoard` SET Board=(@rownumber:=@rownumber+1) ORDER BY `Source1`,`Source2`,`Source3`,`Source4`,`Source5`;

 UPDATE `LocalTreeBoard` AS T1 LEFT JOIN
 (SELECT `Board`,
    IF(@src1!=`Source1`, @lv1:=@lv1+1, @lv1) AS lv1,
    IF(@src1!=`Source1`, IF(`Source2`!=0, @lv2:=1, @lv2:=0), IF(@src2!=`Source2`, @lv2:=@lv2+1, @lv2)) AS lv2,
    IF(@src1!=`Source1` OR @src2!=`Source2`, IF(`Source3`!=0, @lv3:=1, @lv3:=0), IF(@src3!=`Source3`, @lv3:=@lv3+1, @lv3)) AS lv3,
    IF(@src1!=`Source1` OR @src2!=`Source2` OR @src3!=`Source3`, IF(`Source4`!=0, @lv4:=1, @lv4:=0), IF(@src4!=`Source4`, @lv4:=@lv4+1, @lv4)) AS lv4,
    IF(@src1!=`Source1` OR @src2!=`Source2` OR @src3!=`Source3` OR @src4!=`Source4`, IF(`Source5`!=0, @lv5:=1, @lv5:=0), IF(@src5!=`Source5`, @lv5:=@lv5+1, @lv5)) AS lv5,
    @src1:=`Source1`, @src2:=`Source2`, @src3:=`Source3`, @src4:=`Source4`, @src5:=`Source5`
	FROM `LocalTreeBoard`, (SELECT @src1:=0, @lv1:=0, @src2:=0, @lv2:=0, @src3:=0, @lv3:=0, @src4:=0, @lv4:=0, @src5:=0, @lv5:=0) AS TT
    ORDER BY `Board`) AS T2 ON T1.`Board`=T2.`Board`
 SET T1.`Level1`=T2.lv1, T1.`Level2`=T2.lv2, T1.`Level3`=T2.lv3, T1.`Level4`=T2.lv4, T1.`Level5`=T2.lv5;
END ;;
DELIMITER ;


--
-- Host: localhost    Database: pcscale
-- ------------------------------------------------------

DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `AdvertisingInserted` AFTER INSERT ON `Advertising`
FOR EACH ROW BEGIN
  IF ((NEW.`Scope`=2) AND (NEW.`Number`=GLOBAL_GET("current_scale"))) OR
     ((NEW.`Scope`=1) AND (NEW.`Number`=GLOBAL_GET("current_counter"))) OR
     ((NEW.`Scope`=0) AND (NEW.`Number`=0)) THEN
    UPDATE `LocalStatus` SET `AdvertisingChanged` = TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `AdvertisingUpdated` AFTER UPDATE ON `Advertising`
FOR EACH ROW BEGIN
  IF ((NEW.`Scope`=2) AND (NEW.`Number`=GLOBAL_GET("current_scale"))) OR
     ((NEW.`Scope`=1) AND (NEW.`Number`=GLOBAL_GET("current_counter"))) OR
     ((NEW.`Scope`=0) AND (NEW.`Number`=0)) THEN
    UPDATE `LocalStatus` SET `AdvertisingChanged` = TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `AdvertisingDeleted` AFTER DELETE ON `Advertising`
FOR EACH ROW BEGIN
  IF ((OLD.`Scope`=2) AND (OLD.`Number`=GLOBAL_GET("current_scale"))) OR
     ((OLD.`Scope`=1) AND (OLD.`Number`=GLOBAL_GET("current_counter"))) THEN
    UPDATE `LocalStatus` SET `AdvertisingChanged` = TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CardInserted` AFTER INSERT ON `Card`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckCard` = TRUE;
  SET @trx := (SELECT trx_new("CARD_RELOAD", "NETWORK"));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CardUpdated` AFTER UPDATE ON `Card`
FOR EACH ROW BEGIN
  IF ((NEW.`Enabled`!=OLD.`Enabled`) OR (NEW.`Status`!=OLD.`Status`)) THEN
    UPDATE `LocalStatus` SET `CheckCard` = TRUE;
  END IF;
  IF ((NEW.`Enabled`!=OLD.`Enabled`) OR (NEW.`URL`!=OLD.`URL`) OR (NEW.`Name`!=OLD.`Name`)) THEN
    SET @trx := (SELECT trx_new("CARD_RELOAD", "NETWORK"));
    SET @ret := (SELECT trx_send(@trx));
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CardDeleted` AFTER DELETE ON `Card`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckCard` = TRUE;
  SET @trx := (SELECT trx_new("CARD_RELOAD", "NETWORK"));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CashInserted` AFTER INSERT ON `Cash`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckCash` = TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CashUpdated` AFTER UPDATE ON `Cash`
FOR EACH ROW BEGIN
  IF ((NEW.`Scope`!=OLD.`Scope`) OR (NEW.`Number`!=OLD.`Number`) OR (NEW.`Status`!=OLD.`Status`)) THEN
    UPDATE `LocalStatus` SET `CheckCash` = TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CashDeleted` AFTER DELETE ON `Cash`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckCash` = TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CashDrawerUpdated` AFTER UPDATE ON `CashDrawer`
FOR EACH ROW BEGIN
  INSERT INTO `TotalPayTickets` (`Date`, `Type`, `NetStat`, `PayMethod`, `Delivered`)
    VALUES (DATE(NEW.`DatTim`), 'T', 'N', 99, (NEW.`CashIn`-NEW.`CashOut`))
    ON DUPLICATE KEY UPDATE `TotalPayTickets`.`Delivered`=`TotalPayTickets`.`Delivered`+VALUES(`Delivered`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CfgInserted` AFTER INSERT ON `CfgSystem`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("BUTTON_UPDATE", "GUI"));
  SET @ret := (SELECT trx_set_param(@trx, "KEYNAME", CONCAT("CFGSYSTEM_", NEW.`ParamKey`)));
  SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", NEW.`ParamValue`));
  SET @ret := (SELECT trx_send(@trx));
  IF(NEW.`ParamKey`="allow-customer-order") THEN
    UPDATE `LocalStatus` SET `CheckCustomerOrders` = TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CfgUpdated` AFTER UPDATE ON `CfgSystem`
FOR EACH ROW BEGIN
  IF(OLD.`ParamValue`!=NEW.`ParamValue`) THEN
    SET @trx := (SELECT trx_new("BUTTON_UPDATE", "GUI"));
    SET @ret := (SELECT trx_set_param(@trx, "KEYNAME", CONCAT("CFGSYSTEM_", NEW.`ParamKey`)));
    SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", NEW.`ParamValue`));
    SET @ret := (SELECT trx_send(@trx));
    IF((OLD.`ParamKey`="allow-customer-order") OR (NEW.`ParamKey`="allow-customer-order")) THEN
      UPDATE `LocalStatus` SET `CheckCustomerOrders` = TRUE;
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `CfgDeleted` AFTER DELETE ON `CfgSystem`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("BUTTON_UPDATE", "GUI"));
  SET @ret := (SELECT trx_set_param(@trx, "KEYNAME", CONCAT("CFGSYSTEM_", OLD.`ParamKey`)));
  SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", ""));
  SET @ret := (SELECT trx_send(@trx));
  IF(OLD.`ParamKey`="allow-customer-order") THEN
    UPDATE `LocalStatus` SET `CheckCustomerOrders` = TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertCounterFamilies` AFTER INSERT ON `CounterFamilies`
FOR EACH ROW BEGIN
  IF (NEW.`CounterCode`= GLOBAL_GET("current_counter")) THEN
    UPDATE `LocalStatus` SET `CheckCounterFamilies`=TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateCounterFamilies` AFTER UPDATE ON `CounterFamilies`
FOR EACH ROW BEGIN
  IF (OLD.`CounterCode`= GLOBAL_GET("current_counter")) THEN
    UPDATE `LocalStatus` SET `CheckCounterFamilies`=TRUE;
  END IF;
  IF (NEW.`CounterCode`= GLOBAL_GET("current_counter")) THEN
    UPDATE `LocalStatus` SET `CheckCounterFamilies`=TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteCounterFamilies` AFTER DELETE ON `CounterFamilies`
FOR EACH ROW BEGIN
  IF (OLD.`CounterCode`= GLOBAL_GET("current_counter")) THEN
    UPDATE `LocalStatus` SET `CheckCounterFamilies`=TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertCounter` AFTER INSERT ON `Counters`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `CheckCounters`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateCounter` AFTER UPDATE ON `Counters`
FOR EACH ROW BEGIN
  IF(NEW.`Code`!=OLD.`Code`) THEN
    UPDATE `LocalStatus` SET `CheckCounters`=TRUE;
  ELSE
    UPDATE `LocalStatus` SET `CheckCountersKeys`=TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteCounter` AFTER DELETE ON `Counters`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `CheckCounters`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertEraseTickets` AFTER INSERT ON `EraseTickets`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `EraseTickets`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TicketsErased` AFTER UPDATE ON `EraseTickets`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `EraseTickets`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertFamily` AFTER INSERT ON `Families`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckFamilies`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateFamily` AFTER UPDATE ON `Families`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckFamilies`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteFamily` AFTER DELETE ON `Families`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckFamilies`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `FiscalInserted` AFTER INSERT ON `Fiscal`
FOR EACH ROW BEGIN
  CALL DataloggerFiscalChange('', NEW.`Name`, 0, NEW.`Enabled`);
  INSERT INTO `LocalCfgScale` (`ParamKey`,`ParamValue`) VALUES ('CheckFiscal', '1') ON DUPLICATE KEY UPDATE `ParamValue`='1';
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `FiscalUpdated` AFTER UPDATE ON `Fiscal`
FOR EACH ROW BEGIN
  CALL DataloggerFiscalChange(OLD.`Name`, NEW.`Name`, OLD.`Enabled`, NEW.`Enabled`);
  IF ((NEW.`Enabled`!=OLD.`Enabled`) OR (NEW.`Status`!=OLD.`Status`)) THEN
    INSERT INTO `LocalCfgScale` (`ParamKey`,`ParamValue`) VALUES ('CheckFiscal', '1') ON DUPLICATE KEY UPDATE `ParamValue`='1';
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `FiscalDeleted` AFTER DELETE ON `Fiscal`
FOR EACH ROW BEGIN
  CALL DataloggerFiscalChange(OLD.`Name`, '', OLD.`Enabled`, 0);
  INSERT INTO `LocalCfgScale` (`ParamKey`,`ParamValue`) VALUES ('CheckFiscal', '1') ON DUPLICATE KEY UPDATE `ParamValue`='1';
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `HCtordInserted` AFTER INSERT ON `HCustomerOrders`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckCustomerOrders` = TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `HCtordUpdated` AFTER UPDATE ON `HCustomerOrders`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckCustomerOrders` = TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `HCtordDeleted` AFTER DELETE ON `HCustomerOrders`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckCustomerOrders` = TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `HTicketsInsert` AFTER INSERT ON `HTickets`
FOR EACH ROW BEGIN
  IF (NEW.`NetStat`='N') THEN
    IF (NEW.`Counter`= GLOBAL_GET("current_counter")) THEN
      REPLACE INTO `LocalVendorChanges` VALUES ((NEW.`Vendor`*10)+1, NEW.`Vendor`,'1');
    END IF;
    IF (NEW.`OrderNumber`!='') THEN
      UPDATE `HCustomerOrders` SET `HCustomerOrders`.`IdHTicket`=NEW.`Id`, `HCustomerOrders`.`Vendor`=NEW.`Vendor`, `HCustomerOrders`.`Scale`=NEW.`Scale`, `HCustomerOrders`.`Counter`=NEW.`Counter`,
        `HCustomerOrders`.`ReopenDateTime`=NOW(), `HCustomerOrders`.`StartDateTime`=IF(`HCustomerOrders`.`Status`=1, NOW(), `HCustomerOrders`.`StartDateTime`),
        `HCustomerOrders`.`DatTim`=IF(`HCustomerOrders`.`Status`=1, NOW(), `HCustomerOrders`.`DatTim`), `HCustomerOrders`.`Status`=IF(`HCustomerOrders`.`Status`=1, 2, `HCustomerOrders`.`Status`)
      WHERE (`HCustomerOrders`.`Number`=New.`OrderNumber`) AND (`HCustomerOrders`.`Section`=New.`SectionItem`) AND ((`HCustomerOrders`.`Status`>0) AND (`HCustomerOrders`.`Status`!=3));
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `HTicketsUpdateB` BEFORE UPDATE ON `HTickets`
FOR EACH ROW BEGIN
  IF(NEW.`NetStat`='N') THEN
    SET @frac_digits := IFNULL(GLOBAL_GET("frac_digits"), 2);

    IF(OLD.`PointsDiscount`!=NEW.`PointsDiscount`) THEN
      SET @lypoints = (SELECT IFNULL(`ParamValue`,0) FROM `CfgSystem` WHERE `ParamKey`='loyalty-points-discount-currency');
      SET NEW.`PointsAmount`= IF(@lypoints,ROUND(NEW.`PointsDiscount`/@lypoints, @frac_digits),0);
      SET NEW.`NetAmount`=`pcs_net`(NEW.`GrossAmount`, NEW.`tckDiscount`, NEW.`PointsAmount`);
    END IF;
    IF((OLD.`GrossAmount`!=NEW.`GrossAmount`) OR (OLD.`tckDiscount`!=NEW.`tckDiscount`) OR (OLD.`Customer`!=NEW.`Customer`)) THEN
      SET NEW.`PointsDiscount`=0;
      SET NEW.`PointsAmount`= 0;
      SET NEW.`NetAmount`=`pcs_net`(NEW.`GrossAmount`, NEW.`tckDiscount`, NEW.`PointsAmount`);
    END IF;
    IF(OLD.`NetAmount`!=NEW.`NetAmount`) THEN
      SET @points = (SELECT IFNULL(`ParamValue`,0) FROM `CfgSystem` WHERE `ParamKey`='loyalty-currency-give-point');
      SET NEW.`Points`=IF(@points,FLOOR(NEW.`NetAmount`/@points),0);
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `HTicketsUpdate` AFTER UPDATE ON `HTickets`
FOR EACH ROW BEGIN

  IF(NEW.`ReloadTo`!=0) AND (OLD.`Status`!= NEW.`Status`) THEN
    UPDATE `LTickets` SET `LTickets`.`ReloadTo`=NEW.`ReloadTo` WHERE `LTickets`.`IdHTicket`=OLD.`Id`;
  END IF;

  IF((NEW.`NetStat`='N') AND (NEW.`Counter`= GLOBAL_GET("current_counter"))) THEN
    REPLACE INTO `LocalVendorChanges` VALUES ((NEW.`Vendor`*10)+1, NEW.`Vendor`,'1');

    UPDATE `LocalHTickets` SET `Status`=NEW.`Status`, `TimesPrinted`=NEW.`TimesPrinted`,
      `Captured`=IF(NEW.`Captured`!='',NEW.`Captured`,`Captured`), `CapturedDateTime`=IF(NEW.`Captured`!='',NEW.`CapturedDateTime`,`CapturedDateTime`)
      WHERE `IdNetHticket`=NEW.`Id`;
  END IF;

  IF(OLD.`Number`!= NEW.`Number`) THEN
    IF((SELECT IFNULL(`ParamValue`, 0) FROM `CfgSystem` WHERE `ParamKey`='prices-without-taxes')=1) THEN
      UPDATE `LTickets` AS `lt` SET `lt`.`PrintScale`=NEW.`Scale`, `lt`.`PrintDateTime`=NEW.`DatTim`, `lt`.`PrintTicketNumber`=NEW.`Number`,
        `lt`.`PrinttckType`=NEW.`tckType`, `lt`.`TicketDiscount`=NEW.`tckDiscount`, `lt`.`BaseAmount`=`lt`.`Amount`
        WHERE `lt`.`IdHTicket`=NEW.`Id`;
    ELSE
      UPDATE `LTickets` AS `lt` SET `lt`.`PrintScale`=NEW.`Scale`, `lt`.`PrintDateTime`=NEW.`DatTim`, `lt`.`PrintTicketNumber`=NEW.`Number`,
        `lt`.`PrinttckType`=NEW.`tckType`, `lt`.`TicketDiscount`=NEW.`tckDiscount`, `lt`.`BaseAmount`=(`lt`.`Amount`*(100-NEW.`tckDiscount`))/(100+`lt`.`VATPercent`)
        WHERE `lt`.`IdHTicket`=NEW.`Id`;
    END IF;
  END IF;


  IF(BINARY OLD.`Status`!= NEW.`Status`) THEN

   IF(BINARY NEW.`Status` IN ('C','V')) THEN

      INSERT INTO `TotalDaily` (`Date`, `Type`, `NetStat`, `Tickets`, `TotalLines`, `TotalAmount`, `TotalDiscount`, `TotalWeight`, `TotalUnits`,
        `NegativeLines`, `NegativeAmount`, `CanceledLines`, `CanceledAmount`, `ReloadedTickets`, `TotalReloadedAmount`,
        `Invoices`, `InvoiceAmount`, `InvoicesRefund`, `InvoiceAmountRefund`, `AccumulatedAmount`)
        VALUES (DATE(NEW.`DatTim`), NEW.`tckType`, NEW.`NetStat`, 1, NEW.`NumLines`, NEW.`NetAmount`, (NEW.`GrossAmount`-NEW.`NetAmount`), NEW.`TotalWeight`, NEW.`TotalUnits`,
        NEW.`NegativeLines`, NEW.`NegativeAmount`, NEW.`CanceledLines`, NEW.`CanceledAmount`, 0, 0,
        IF(NEW.`Invoice`!='',1,0), IF(NEW.`Invoice`!='',NEW.`NetAmount`,0), IF(BINARY NEW.`Status`='V',1,0), IF(BINARY NEW.`Status`='V',-NEW.`NetAmount`,0),
        NEW.`NetAmount`+IFNULL((SELECT `TotalAmount` FROM `TotalPerpetual` WHERE `TotalPerpetual`.`Type`=NEW.`tckType` AND `TotalPerpetual`.`NetStat`=NEW.`NetStat`),0) )
        ON DUPLICATE KEY UPDATE
          `TotalDaily`.`PrintChgCounter`=`TotalDaily`.`PrintChgCounter`+`TotalDaily`.`Printed`, `TotalDaily`.`Printed`=0,
          `TotalDaily`.`Tickets`=`TotalDaily`.`Tickets`+VALUES(`Tickets`),`TotalDaily`.`TotalLines`=`TotalDaily`.`TotalLines`+VALUES(`TotalLines`),`TotalAmount`=`TotalAmount`+VALUES(`TotalAmount`),
          `TotalDiscount`=`TotalDiscount`+VALUES(`TotalDiscount`), `TotalWeight`=`TotalWeight`+VALUES(`TotalWeight`), `TotalUnits`=`TotalUnits`+VALUES(`TotalUnits`),
          `NegativeLines`=`NegativeLines`+VALUES(`NegativeLines`), `NegativeAmount`=`NegativeAmount`+VALUES(`NegativeAmount`),
          `CanceledLines`=`CanceledLines`+VALUES(`CanceledLines`), `CanceledAmount`=`CanceledAmount`+VALUES(`CanceledAmount`),
          `ReloadedTickets`=`ReloadedTickets`+VALUES(`ReloadedTickets`), `TotalReloadedAmount`=`TotalReloadedAmount`+VALUES(`TotalReloadedAmount`),
          `Invoices`=`Invoices`+VALUES(`Invoices`), `InvoiceAmount`=`InvoiceAmount`+VALUES(`InvoiceAmount`),
          `InvoicesRefund`=`InvoicesRefund`+VALUES(`InvoicesRefund`), `InvoiceAmountRefund`=`InvoiceAmountRefund`+VALUES(`InvoiceAmountRefund`),
          `AccumulatedAmount`=VALUES(`AccumulatedAmount`);

      INSERT INTO `TotalPerpetual` (`Date`, `Type`, `NetStat`, `Tickets`, `TotalLines`, `TotalAmount`, `TotalDiscount`, `TotalWeight`, `TotalUnits`,
        `NegativeLines`, `NegativeAmount`, `CanceledLines`, `CanceledAmount`, `ReloadedTickets`, `TotalReloadedAmount`,
        `Invoices`, `InvoiceAmount`, `InvoicesRefund`, `InvoiceAmountRefund`)
        VALUES (DATE(NEW.`DatTim`), NEW.`tckType`, NEW.`NetStat`, 1, NEW.`NumLines`, NEW.`NetAmount`, (NEW.`GrossAmount`-NEW.`NetAmount`), NEW.`TotalWeight`, NEW.`TotalUnits`,
        NEW.`NegativeLines`, NEW.`NegativeAmount`, NEW.`CanceledLines`, NEW.`CanceledAmount`, 0, 0,
        IF(NEW.`Invoice`!='',1,0), IF(NEW.`Invoice`!='',NEW.`NetAmount`,0), IF(BINARY NEW.`Status`='V',1,0), IF(BINARY NEW.`Status`='V',-NEW.`NetAmount`,0)  )
        ON DUPLICATE KEY UPDATE
          `TotalPerpetual`.`Tickets`=`TotalPerpetual`.`Tickets`+VALUES(`Tickets`),`TotalPerpetual`.`TotalLines`=`TotalPerpetual`.`TotalLines`+VALUES(`TotalLines`),
          `TotalAmount`=`TotalAmount`+VALUES(`TotalAmount`),
          `TotalDiscount`=`TotalDiscount`+VALUES(`TotalDiscount`), `TotalWeight`=`TotalWeight`+VALUES(`TotalWeight`), `TotalUnits`=`TotalUnits`+VALUES(`TotalUnits`),
          `NegativeLines`=`NegativeLines`+VALUES(`NegativeLines`), `NegativeAmount`=`NegativeAmount`+VALUES(`NegativeAmount`),
          `CanceledLines`=`CanceledLines`+VALUES(`CanceledLines`), `CanceledAmount`=`CanceledAmount`+VALUES(`CanceledAmount`),
          `ReloadedTickets`=`ReloadedTickets`+VALUES(`ReloadedTickets`), `TotalReloadedAmount`=`TotalReloadedAmount`+VALUES(`TotalReloadedAmount`),
          `Invoices`=`Invoices`+VALUES(`Invoices`), `InvoiceAmount`=`InvoiceAmount`+VALUES(`InvoiceAmount`),
          `InvoicesRefund`=`InvoicesRefund`+VALUES(`InvoicesRefund`), `InvoiceAmountRefund`=`InvoiceAmountRefund`+VALUES(`InvoiceAmountRefund`);

      IF(NEW.`GrossAmount`!=0) THEN
        IF((SELECT IFNULL(`ParamValue`, 0) FROM `CfgSystem` WHERE `ParamKey`='prices-without-taxes')=1) THEN
          INSERT INTO `TotalVAT` (`Date`, `Type`, `NetStat`, `Code`, `Percentage`, `Amount`, `Base`, `Tax`)
            SELECT DATE(NEW.`DatTim`), NEW.`tckType`, NEW.`NetStat`, `V_VAT`.`VATCode`, `V_VAT`.`VATPercent`, `V_VAT`.`Base` + CAST(((`V_VAT`.`Base`*`VATPercent`)/100) AS DECIMAL(10,2)) AS `Amount`,
            `V_VAT`.`Base` AS `Base`, CAST(((`V_VAT`.`Base`*`VATPercent`)/100) AS DECIMAL(10,2)) AS Tax
            FROM (SELECT `VATCode`, `VATPercent`, CAST(SUM(`LTickets`.`Amount`)*(NEW.`NetAmount`/NEW.`GrossAmount`) AS DECIMAL(10,2)) AS `Base`
              FROM `LTickets` WHERE `LTickets`.`IdHTicket`=OLD.`Id` AND `LTickets`.`lineType`=1 GROUP BY `LTickets`.`VATCode`) AS `V_VAT`
              ON DUPLICATE KEY UPDATE
                `TotalVAT`.`Amount`=`TotalVAT`.`Amount`+VALUES(`Amount`), `TotalVAT`.`Base`=`TotalVAT`.`Base`+VALUES(`Base`),`TotalVAT`.`Tax`=`TotalVAT`.`Tax`+VALUES(`Tax`);
        ELSE
          INSERT INTO `TotalVAT` (`Date`, `Type`, `NetStat`, `Code`, `Percentage`, `Amount`, `Base`, `Tax`)
            SELECT DATE(NEW.`DatTim`), NEW.`tckType`, NEW.`NetStat`, `V_VAT`.`VATCode`, `V_VAT`.`VATPercent`, `V_VAT`.`Amount`,
            CAST((`V_VAT`.`Amount`*100)/(100+`VATPercent`) AS DECIMAL(10,2)) AS `Base`, `V_VAT`.`Amount` - CAST((`V_VAT`.`Amount`*100)/(100+`VATPercent`) AS DECIMAL(10,2)) AS Tax
            FROM (SELECT `VATCode`, `VATPercent`, CAST(SUM(`LTickets`.`Amount`)*(NEW.`NetAmount`/NEW.`GrossAmount`) AS DECIMAL(10,2)) AS `Amount`
              FROM `LTickets` WHERE `LTickets`.`IdHTicket`=OLD.`Id` AND `LTickets`.`lineType`=1 GROUP BY `LTickets`.`VATCode`) AS `V_VAT`
              ON DUPLICATE KEY UPDATE
                `TotalVAT`.`Amount`=`TotalVAT`.`Amount`+VALUES(`Amount`), `TotalVAT`.`Base`=`TotalVAT`.`Base`+VALUES(`Base`),`TotalVAT`.`Tax`=`TotalVAT`.`Tax`+VALUES(`Tax`);
        END IF;
      END IF;

      INSERT INTO `TotalPayTickets` (`Date`, `Type`, `NetStat`, `PayMethod`, `Delivered`)
        (SELECT DATE(NEW.`DatTim`), NEW.`tckType`, NEW.`NetStat`,`PayMethod`, `Delivered` FROM `PayTickets` WHERE `PayTickets`.`IdHTicket`=OLD.`Id`)
        ON DUPLICATE KEY UPDATE
         `TotalPayTickets`.`Delivered`=`TotalPayTickets`.`Delivered`+VALUES(`Delivered`);

      UPDATE `Customers` SET `Customers`.`Points`=GREATEST(`Customers`.`Points`+(NEW.`Points`+NEW.`PointsExtra`)-(NEW.`PointsDiscount`+NEW.`PointsChanged`),0) WHERE `Customers`.`TIN`=NEW.`Customer`;

      IF(NEW.`tckType`!='U') THEN


        IF(OLD.`Invoice`!='') THEN
          INSERT INTO `Invoices` (`Number`, `Date`, `Customer`, `Type`) VALUES (OLD.`Invoice`, OLD.`InvoiceDate`, OLD.`Customer`, IF(OLD.`SimplifiedInvoice`=1,'0','1'));
          INSERT INTO `InvoiceDetails` (`IdInvoice`, `IdHTicket`) VALUES (LAST_INSERT_ID(), OLD.`Id`);
        END IF;

        INSERT INTO `TotalScaleFamilies` (`Date`, `Scale`, `Family`, `TotalWeight`, `TotalUnits`)
          SELECT CONCAT(YEAR(NEW.`DatTim`),'-',MONTH(NEW.`DatTim`), '-01'), NEW.`Scale`, `Family`, SUM(IF(`Saleform`=1,`Weight`,0)), SUM(IF(`Saleform`=0,`Weight`,0))
          FROM `LTickets` WHERE (`IdHTicket`=OLD.`Id` AND `LTickets`.`lineType`=1) GROUP BY `Family`
          ON DUPLICATE KEY UPDATE
            `TotalScaleFamilies`.`PrintChgCounter`=`TotalScaleFamilies`.`PrintChgCounter`+`TotalScaleFamilies`.`Printed`, `TotalScaleFamilies`.`Printed`=0,
            `TotalWeight`=`TotalWeight`+ VALUES(`TotalWeight`), `TotalUnits`=`TotalUnits`+ VALUES(`TotalUnits`);

      END IF;

    END IF;

    IF((OLD.`Status`='C') AND (NEW.`Status`='R')) THEN


      INSERT INTO `TotalDaily` (`Date`, `Type`, `NetStat`, `Tickets`, `TotalLines`, `TotalAmount`, `TotalDiscount`, `TotalWeight`, `TotalUnits`,
        `NegativeLines`, `NegativeAmount`, `CanceledLines`, `CanceledAmount`, `ReloadedTickets`, `TotalReloadedAmount`,
        `Invoices`, `InvoiceAmount`, `InvoicesRefund`, `InvoiceAmountRefund`, `AccumulatedAmount`)
        VALUES (CURDATE(), OLD.`tckType`, OLD.`NetStat`, 1, -OLD.`NumLines`, -OLD.`NetAmount`, -(OLD.`GrossAmount`-OLD.`NetAmount`), -OLD.`TotalWeight`, -OLD.`TotalUnits`,
        -OLD.`NegativeLines`, -OLD.`NegativeAmount`, -OLD.`CanceledLines`, -OLD.`CanceledAmount`, 1, OLD.`NetAmount`,
        -IF(OLD.`Invoice`!='',1,0), -IF(OLD.`Invoice`!='',OLD.`NetAmount`,0), 0, 0,
        -OLD.`NetAmount`+IFNULL((SELECT `TotalAmount` FROM `TotalPerpetual` WHERE `TotalPerpetual`.`Type`=OLD.`tckType` AND `TotalPerpetual`.`NetStat`=OLD.`NetStat`),0) )
        ON DUPLICATE KEY UPDATE
          `TotalDaily`.`PrintChgCounter`=`TotalDaily`.`PrintChgCounter`+`TotalDaily`.`Printed`, `TotalDaily`.`Printed`=0,
          `TotalDaily`.`Tickets`=`TotalDaily`.`Tickets`+VALUES(`Tickets`),`TotalDaily`.`TotalLines`=`TotalDaily`.`TotalLines`+VALUES(`TotalLines`),`TotalAmount`=`TotalAmount`+VALUES(`TotalAmount`),
          `TotalDiscount`=`TotalDiscount`+VALUES(`TotalDiscount`), `TotalWeight`=`TotalWeight`+VALUES(`TotalWeight`), `TotalUnits`=`TotalUnits`+VALUES(`TotalUnits`),
          `NegativeLines`=`NegativeLines`+VALUES(`NegativeLines`), `NegativeAmount`=`NegativeAmount`+VALUES(`NegativeAmount`),
          `CanceledLines`=`CanceledLines`+VALUES(`CanceledLines`), `CanceledAmount`=`CanceledAmount`+VALUES(`CanceledAmount`),
          `ReloadedTickets`=`ReloadedTickets`+VALUES(`ReloadedTickets`), `TotalReloadedAmount`=`TotalReloadedAmount`+VALUES(`TotalReloadedAmount`),
          `Invoices`=`Invoices`+VALUES(`Invoices`), `InvoiceAmount`=`InvoiceAmount`+VALUES(`InvoiceAmount`),
          `InvoicesRefund`=`InvoicesRefund`+VALUES(`InvoicesRefund`), `InvoiceAmountRefund`=`InvoiceAmountRefund`+VALUES(`InvoiceAmountRefund`),
          `AccumulatedAmount`=VALUES(`AccumulatedAmount`);

      INSERT INTO `TotalPerpetual` (`Date`, `Type`, `NetStat`, `Tickets`, `TotalLines`, `TotalAmount`, `TotalDiscount`, `TotalWeight`, `TotalUnits`,
        `NegativeLines`, `NegativeAmount`, `CanceledLines`, `CanceledAmount`, `ReloadedTickets`, `TotalReloadedAmount`,
        `Invoices`, `InvoiceAmount`, `InvoicesRefund`, `InvoiceAmountRefund`)
        VALUES (CURDATE(), OLD.`tckType`, OLD.`NetStat`, 1, -OLD.`NumLines`, -OLD.`NetAmount`, -(OLD.`GrossAmount`-OLD.`NetAmount`), -OLD.`TotalWeight`, -OLD.`TotalUnits`,
        -OLD.`NegativeLines`, -OLD.`NegativeAmount`, -OLD.`CanceledLines`, -OLD.`CanceledAmount`, 1, OLD.`NetAmount`, -IF(OLD.`Invoice`!='',1,0), -IF(OLD.`Invoice`!='',OLD.`NetAmount`,0), 0, 0 )
        ON DUPLICATE KEY UPDATE
          `TotalPerpetual`.`Tickets`=`TotalPerpetual`.`Tickets`+VALUES(`Tickets`),`TotalPerpetual`.`TotalLines`=`TotalPerpetual`.`TotalLines`+VALUES(`TotalLines`),
          `TotalAmount`=`TotalAmount`+VALUES(`TotalAmount`),
          `TotalDiscount`=`TotalDiscount`+VALUES(`TotalDiscount`), `TotalWeight`=`TotalWeight`+VALUES(`TotalWeight`), `TotalUnits`=`TotalUnits`+VALUES(`TotalUnits`),
          `NegativeLines`=`NegativeLines`+VALUES(`NegativeLines`), `NegativeAmount`=`NegativeAmount`+VALUES(`NegativeAmount`),
          `CanceledLines`=`CanceledLines`+VALUES(`CanceledLines`), `CanceledAmount`=`CanceledAmount`+VALUES(`CanceledAmount`),
          `ReloadedTickets`=`ReloadedTickets`+VALUES(`ReloadedTickets`), `TotalReloadedAmount`=`TotalReloadedAmount`+VALUES(`TotalReloadedAmount`),
          `Invoices`=`Invoices`+VALUES(`Invoices`), `InvoiceAmount`=`InvoiceAmount`+VALUES(`InvoiceAmount`),
          `InvoicesRefund`=`InvoicesRefund`+VALUES(`InvoicesRefund`), `InvoiceAmountRefund`=`InvoiceAmountRefund`+VALUES(`InvoiceAmountRefund`);

      IF(OLD.`GrossAmount`!=0) THEN
        IF((SELECT IFNULL(`ParamValue`, 0) FROM `CfgSystem` WHERE `ParamKey`='prices-without-taxes')=1) THEN
          INSERT INTO `TotalVAT` (`Date`, `Type`, `NetStat`, `Code`, `Percentage`, `Amount`, `Base`, `Tax`)
            SELECT DATE(NEW.`DatTim`), NEW.`tckType`, NEW.`NetStat`, `V_VAT`.`VATCode`, `V_VAT`.`VATPercent`, -(`V_VAT`.`Base` + CAST(((`V_VAT`.`Base`*`VATPercent`)/100) AS DECIMAL(10,2))) AS `Amount`,
            -`V_VAT`.`Base` AS `Base`, -CAST(((`V_VAT`.`Base`*`VATPercent`)/100) AS DECIMAL(10,2)) AS Tax
            FROM (SELECT `VATCode`, `VATPercent`, CAST(SUM(`LTickets`.`Amount`)*(NEW.`NetAmount`/NEW.`GrossAmount`) AS DECIMAL(10,2)) AS `Base`
              FROM `LTickets` WHERE `LTickets`.`IdHTicket`=OLD.`Id` AND `LTickets`.`lineType`=1 GROUP BY `LTickets`.`VATCode`) AS `V_VAT`
              ON DUPLICATE KEY UPDATE
                `TotalVAT`.`Amount`=`TotalVAT`.`Amount`+VALUES(`Amount`), `TotalVAT`.`Base`=`TotalVAT`.`Base`+VALUES(`Base`),`TotalVAT`.`Tax`=`TotalVAT`.`Tax`+VALUES(`Tax`);
        ELSE
          INSERT INTO `TotalVAT` (`Date`, `Type`, `NetStat`, `Code`, `Percentage`, `Amount`, `Base`, `Tax`)
            SELECT CURDATE(), OLD.`tckType`, OLD.`NetStat`, `V_VAT`.`VATCode`, `V_VAT`.`VATPercent`, -`V_VAT`.`Amount`,
            -CAST((`V_VAT`.`Amount`*100)/(100+`VATPercent`) AS DECIMAL(10,2)) AS `Base`, -(`V_VAT`.`Amount` - CAST((`V_VAT`.`Amount`*100)/(100+`VATPercent`) AS DECIMAL(10,2))) AS Tax
             FROM (SELECT `VATCode`, `VATPercent`, CAST(SUM(`LTickets`.`Amount`)*(OLD.`NetAmount`/OLD.`GrossAmount`) AS DECIMAL(10,2)) AS `Amount`
              FROM `LTickets` WHERE `LTickets`.`IdHTicket`=OLD.`Id` AND `LTickets`.`lineType`=1 GROUP BY `LTickets`.`VATCode`) AS `V_VAT`
              ON DUPLICATE KEY UPDATE
                `TotalVAT`.`Amount`=`TotalVAT`.`Amount`+VALUES(`Amount`), `TotalVAT`.`Base`=`TotalVAT`.`Base`+VALUES(`Base`),`TotalVAT`.`Tax`=`TotalVAT`.`Tax`+VALUES(`Tax`);
        END IF;
      END IF;

      INSERT INTO `TotalPayTickets` (`Date`, `Type`, `NetStat`, `PayMethod`, `Delivered`)
        (SELECT CURDATE(), OLD.`tckType`, OLD.`NetStat`,`PayMethod`, -`Delivered` FROM `PayTickets` WHERE `PayTickets`.`IdHTicket`=OLD.`Id`)
        ON DUPLICATE KEY UPDATE
          `TotalPayTickets`.`Delivered`=`TotalPayTickets`.`Delivered`+VALUES(`Delivered`);

      UPDATE `Customers` SET `Customers`.`Points`=GREATEST(`Customers`.`Points`-(OLD.`Points`+OLD.`PointsExtra`)+(OLD.`PointsDiscount`+OLD.`PointsChanged`),0) WHERE `Customers`.`TIN`=NEW.`Customer`;

      IF(OLD.`tckType`!='U') THEN


        UPDATE `TotalScaleFamilies`,
          (SELECT CONCAT(YEAR(NEW.`DatTim`),'-',MONTH(NEW.`DatTim`), '-01') AS `fdt`,
          `Family`, SUM(IF(`Saleform`=1,`Weight`,0)) AS `fwght`, SUM(IF(`Saleform`=0,`Weight`,0)) AS `funits` FROM `LTickets` WHERE (`IdHTicket`=OLD.`Id` AND `LTickets`.`lineType`=1) GROUP BY `Family`) AS `VT_F`
          SET `TotalWeight`=`TotalWeight`-`VT_F`.`fwght` , `TotalUnits`=`TotalUnits`+ `VT_F`.`funits` WHERE (`Date`=`VT_F`.`fdt` AND `Scale`=NEW.`Scale` AND `TotalScaleFamilies`.`Family`=`VT_F`.`Family`);

        IF(OLD.`OrderNumber`!='') THEN
          UPDATE `HCustomerOrders` SET `HCustomerOrders`.`AddedLines`=`HCustomerOrders`.`AddedLines`-OLD.`AddedLines`, `HCustomerOrders`.`NetAmount`=`HCustomerOrders`.`NetAmount`-OLD.`NetAmount`,
            `HCustomerOrders`.`TotalWeight`=`HCustomerOrders`.`TotalWeight`-OLD.`TotalWeight`, `HCustomerOrders`.`TotalUnits`=`HCustomerOrders`.`TotalUnits`-OLD.`TotalUnits`, `HCustomerOrders`.`ReopenDateTime`=NOW()
            WHERE `HCustomerOrders`.`IdHTicket`=OLD.`Id` AND `HCustomerOrders`.`Status`=2;
        END IF;

      END IF;


    END IF;


    IF(OLD.`OrderNumber`!='') THEN
      IF(NEW.`Status`='C') THEN

        UPDATE `HCustomerOrders` SET `HCustomerOrders`.`NumberHTicket`=NEW.`Number`,`HCustomerOrders`.`Status`=3 WHERE `HCustomerOrders`.`IdHTicket`=OLD.`Id` AND `HCustomerOrders`.`Status`=2;
      ELSEIF(OLD.`Status`='O' AND NEW.`Status`='z') THEN

        UPDATE `HCustomerOrders` SET `HCustomerOrders`.`Vendor`=0,
          `HCustomerOrders`.`DatTim`=ADDDATE(`HCustomerOrders`.`DatTim`, INTERVAL TIME_TO_SEC(TIMEDIFF(NOW(),`HCustomerOrders`.`ReopenDateTime`)) SECOND)
          WHERE `HCustomerOrders`.`Number`=OLD.`OrderNumber` AND `HCustomerOrders`.`IdHTicket`=OLD.`Id` AND `HCustomerOrders`.`Status`=2;
      ELSEIF(OLD.`Status`='z' AND NEW.`Status`='O') THEN

        UPDATE `HCustomerOrders` SET `HCustomerOrders`.`Vendor`=NEW.`Vendor`, `HCustomerOrders`.`Scale`=NEW.`Scale`,`HCustomerOrders`.`Counter`=NEW.`Counter`,`HCustomerOrders`.`ReopenDateTime`=NOW()
          WHERE `HCustomerOrders`.`Number`=OLD.`OrderNumber` AND `HCustomerOrders`.`IdHTicket`=OLD.`Id` AND (`HCustomerOrders`.`Status`=2 OR `HCustomerOrders`.`Status`=4 OR `HCustomerOrders`.`Status`=5);
     END IF;
    END IF;


    IF(NEW.`Status` IN ('X','R')) THEN
      UPDATE `Stock`,
        (SELECT `Item`, SUM(IF(`Saleform`=1,IF(`Price`<0,-`Weight`,`Weight`),0)) AS `lwght`, SUM(IF(`Saleform`=0,IF(`Price`<0,-`Weight`,`Weight`),0)) AS `lunits` FROM `LTickets` WHERE (`IdHTicket`=OLD.`Id` AND ((`LTickets`.`lineType`&1)=1)) GROUP BY `Item`) AS `VT_L`
        SET `Stock`.`Weight`=(`Stock`.`Weight`+`VT_L`.`lwght`), `Stock`.`Units`=(`Stock`.`Units`+`VT_L`.`lunits`) WHERE `Stock`.`Code` = `VT_L`.`Item`;
    END IF;


  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `HTicketsDelete` AFTER DELETE ON `HTickets`
FOR EACH ROW BEGIN
  IF (OLD.`Counter`= GLOBAL_GET("current_counter")) THEN
    REPLACE INTO `LocalVendorChanges` VALUES ((OLD.`Vendor`*10)+1, OLD.`Vendor`,'1');
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `RemoveInvoice` AFTER DELETE ON `Invoices`
FOR EACH ROW BEGIN
  IF (@delete_tickets_from_invoices=1) THEN
    DELETE `InvoiceDetails`, `HTickets` FROM `InvoiceDetails` INNER JOIN `HTickets` WHERE IdHTicket=HTickets.Id AND IdInvoice=OLD.`Id`;
  ELSE
    UPDATE `HTickets` LEFT JOIN `InvoiceDetails` ON HTickets.Id=InvoiceDetails.IdHTicket SET HTickets.Invoice=DEFAULT(HTickets.Invoice), HTickets.InvoiceDate=DEFAULT(HTickets.InvoiceDate) WHERE IdInvoice=OLD.`Id`;
    DELETE FROM `InvoiceDetails` WHERE IdInvoice=OLD.`Id`;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertItemGroupKeys` AFTER INSERT ON `ItemGroupKeys`
FOR EACH ROW BEGIN
  INSERT INTO `LocalItemGroupKeysChanges` (`NumKey`) VALUES (NEW.`NumKey`) ON DUPLICATE KEY UPDATE `NumKey`=VALUES(`NumKey`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateItemGroupKeys` AFTER UPDATE ON `ItemGroupKeys`
FOR EACH ROW BEGIN
  INSERT INTO `LocalItemGroupKeysChanges` (`NumKey`) VALUES (OLD.`NumKey`) ON DUPLICATE KEY UPDATE `NumKey`=VALUES(`NumKey`);
  INSERT INTO `LocalItemGroupKeysChanges` (`NumKey`) VALUES (NEW.`NumKey`) ON DUPLICATE KEY UPDATE `NumKey`=VALUES(`NumKey`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteItemGroupKeys` AFTER DELETE ON `ItemGroupKeys`
FOR EACH ROW BEGIN
  INSERT INTO `LocalItemGroupKeysChanges` (`NumKey`) VALUES (OLD.`NumKey`) ON DUPLICATE KEY UPDATE `NumKey`=VALUES(`NumKey`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertItemGroupKeysText` AFTER INSERT ON `ItemGroupKeysText`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckItemGroupKeysText`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateItemGroupKeysText` AFTER UPDATE ON `ItemGroupKeysText`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckItemGroupKeysText`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteItemGroupKeysText` AFTER DELETE ON `ItemGroupKeysText`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckItemGroupKeysText`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemHabitualInserted` AFTER INSERT ON `ItemHabitual`
FOR EACH ROW BEGIN
  SET @toffer := IFNULL (GLOBAL_GET("table-offer"),0);
  SET @thabitual := IFNULL (GLOBAL_GET("table-habitual"),0);
  IF (@thabitual!=0) THEN
    IF ((SELECT IF(`Items`.`PLU`!=0 AND (`Items`.`Offer`=0 OR @toffer=0) ,0,1) FROM `Items` WHERE `Items`.`Code`=NEW.`Code`)=0) THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@thabitual,NEW.`Position`,NEW.`Code`)
        ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemHabitualUpdated` AFTER UPDATE ON `ItemHabitual`
FOR EACH ROW BEGIN
  SET @toffer := IFNULL (GLOBAL_GET("table-offer"),0);
  SET @thabitual := IFNULL (GLOBAL_GET("table-habitual"),0);
  IF (@thabitual!=0) THEN
    INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@thabitual,OLD.`Position`,0)
      ON DUPLICATE KEY UPDATE `Code`=0;
    IF ((SELECT IF(`Items`.`PLU`!=0 AND (`Items`.`Offer`=0 OR @toffer=0) ,0,1) FROM `Items` WHERE `Items`.`Code`=NEW.`Code`)=0) THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@thabitual,NEW.`Position`,NEW.`Code`)
        ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemHabitualDeleted` AFTER DELETE ON `ItemHabitual`
FOR EACH ROW BEGIN
  SET @thabitual := IFNULL (GLOBAL_GET("table-habitual"),0);
  IF (@thabitual!=0) THEN
    INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@thabitual,OLD.`Position`,0)
    ON DUPLICATE KEY UPDATE `Code`=0;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertMiddleWeight` AFTER INSERT ON `ItemMiddleWeights`
FOR EACH ROW BEGIN
  INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,`Code` FROM `PLUKeys`
    WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=GLOBAL_GET("current_group") OR (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard")) )
    ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateMiddleWeight` AFTER UPDATE ON `ItemMiddleWeights`
FOR EACH ROW BEGIN
  INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,`Code` FROM `PLUKeys`
    WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=GLOBAL_GET("current_group") OR (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard")) )
    ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteMiddleWeight` AFTER DELETE ON `ItemMiddleWeights`
FOR EACH ROW BEGIN
  INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,`Code` FROM `PLUKeys`
    WHERE `Code`=OLD.`Code` AND (`PLUKeys`.`Section`=GLOBAL_GET("current_group") OR (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard")) )
    ON DUPLICATE KEY UPDATE `Code`=OLD.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertItemOfferDates` AFTER INSERT ON `ItemOfferDates`
FOR EACH ROW BEGIN
  IF(NEW.StartDate<=CURDATE() AND NEW.EndDate>=CURDATE()) THEN
    UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE `Items`.`Code`=NEW.`Code`;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateItemOfferDates` AFTER UPDATE ON `ItemOfferDates`
FOR EACH ROW BEGIN
  IF((NEW.StartDate<=CURDATE() AND NEW.EndDate>=CURDATE()) OR (OLD.StartDate<=CURDATE() AND OLD.EndDate>=CURDATE())) THEN
    UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE (`Items`.`Code`=NEW.`Code`) OR (`Items`.`Code`=OLD.`Code`);
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteItemOfferDates` AFTER DELETE ON `ItemOfferDates`
FOR EACH ROW BEGIN
    UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE `Items`.`Code`=OLD.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertItemOfferPricerates` AFTER INSERT ON `ItemOfferPricerates`
FOR EACH ROW BEGIN
  IF(NEW.Rate=0 AND NEW.Step=0) THEN
    UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE (`Items`.`Code`=NEW.`Code`);
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateItemOfferPricerates` AFTER UPDATE ON `ItemOfferPricerates`
FOR EACH ROW BEGIN
  IF((NEW.Rate=0 AND NEW.Step=0) OR (OLD.Rate=0 AND OLD.Step=0)) THEN
    UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE (`Items`.`Code`=NEW.`Code`) OR (`Items`.`Code`=OLD.`Code`);
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteItemOfferPricerates` AFTER DELETE ON `ItemOfferPricerates`
FOR EACH ROW BEGIN
  IF(OLD.Rate=0 AND OLD.Step=0) THEN
    UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE (`Items`.`Code`=OLD.`Code`);
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemsInsertedB` BEFORE INSERT ON `Items`
FOR EACH ROW BEGIN
  IF(NEW.`FamilyOrder`=0) THEN
    SET NEW.`FamilyOrder`=IFNULL(
      (SELECT t1.`FamilyOrder`+1 as _id FROM (SELECT `FamilyOrder` FROM `Items` WHERE `Family`=NEW.`Family`) AS t1 
      LEFT JOIN (SELECT `FamilyOrder` FROM `Items` WHERE `Family`=NEW.`Family`) AS t2 ON t2.`FamilyOrder`=t1.`FamilyOrder`+1 
      WHERE t2.`FamilyOrder` IS NULL LIMIT 1), 1);
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemsInserted` AFTER INSERT ON `Items`
FOR EACH ROW BEGIN
  IF(NEW.`EAN13`!='') THEN
    INSERT INTO ItemsEAN13 (`Code`, `EAN13`) VALUES (NEW.`Code`, NEW.`EAN13`) ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
  END IF;
  SET @loadfunc := IFNULL (GLOBAL_GET("PLUload-func"),99);
  CASE @loadfunc

    WHEN 0 THEN
      IF (NEW.`Inactive`=FALSE) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,`Code` FROM `PLUKeys`
          WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=GLOBAL_GET("current_group") OR (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard")) )
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
     END IF;

    WHEN 1 THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,`Code` FROM `PLUKeys`
        WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard"))
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,NEW.`Family`,`PLUKey`,`Code` FROM `PLUKeys`
        WHERE `Code`=NEW.`Code` AND `PLUKeys`.`Section`=GLOBAL_GET("current_group")
        ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);

    WHEN 2 THEN
      SET @famor := (SELECT `FamilyIndex` FROM `CounterFamilies` WHERE `CounterCode`=GLOBAL_GET("current_counter") AND `FamilyCode`=NEW.`Family`);
      IF ((NEW.`OnKey`=TRUE) AND (NEW.`Inactive`=FALSE)) THEN
        IF (@famor IS NOT NULL) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES(GLOBAL_GET("current_group"),@famor,NEW.`FamilyOrder`,NEW.`Code`)
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
        END IF;
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,`Code` FROM `PLUKeys`
          WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard"))
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

    WHEN 3 THEN
      IF (NEW.`Counter`!=0) AND (NEW.`PLU`!=0) AND (NEW.`Counter`=GLOBAL_GET("current_counter")) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (NEW.`Counter`,0,NEW.`PLU`, NEW.`Code`)
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

    WHEN 100 THEN
      IF (NEW.`Counter`!=0) AND (NEW.`PLU`!=0) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,NEW.`PLU`, NEW.`Code`
        FROM (SELECT IF(Code=GLOBAL_GET("current_counter"),1,@a:=@a+1) AS board_idx, Code FROM (SELECT @a:=1) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

    WHEN 101 THEN
      IF (NEW.`Counter`!=0) AND (NEW.`PLU`!=0) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,NEW.`PLU`, NEW.`Code`
        FROM (SELECT @a:=@a+1 AS board_idx, Code FROM (SELECT @a:=0) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

    WHEN 4 THEN
      IF ((NEW.`PLU`!=0) AND (NEW.`Code`!=0)) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),`ItemGroupKeys`.`NumKey`,NEW.`PLU`,NEW.`Code` FROM `ItemGroupKeys`
          WHERE ((`ItemGroupKeys`.`Abovesection`!=0 AND `ItemGroupKeys`.`Abovesection`=NEW.`Abovesection`) OR (`ItemGroupKeys`.`Abovesection`=0))
          AND ((`ItemGroupKeys`.`Section`!=0 AND `ItemGroupKeys`.`Section`=NEW.`Section`) OR (`ItemGroupKeys`.`Section`=0))
          AND ((`ItemGroupKeys`.`SubSection`!=0 AND `ItemGroupKeys`.`SubSection`=NEW.`SubSection`) OR (`ItemGroupKeys`.`SubSection`=0))
          AND ((`ItemGroupKeys`.`Family`!=0 AND `ItemGroupKeys`.`Family`=NEW.`Family`) OR (`ItemGroupKeys`.`Family`=0))
          AND ((`ItemGroupKeys`.`SubFamily`!=0 AND `ItemGroupKeys`.`SubFamily`=NEW.`SubFamily`) OR (`ItemGroupKeys`.`SubFamily`=0))
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

    WHEN 5 THEN

      IF (SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name LIKE 'CFKeys') IS NOT NULL THEN
        IF ((NEW.`Code`!=0) AND (NEW.`OnKey`=TRUE)) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
            SELECT GLOBAL_GET("current_group"),`LocalTreeBoard`.`Board`, (`CFKeys`.`KeyCode`*10000)+(IF(`CFKeys`.`Level3`=0, `CFKeys`.`Level2`, `CFKeys`.`Level3`)), `CFKeys`.`Item` FROM `CFKeys`
            LEFT JOIN `LocalTreeBoard` ON `LocalTreeBoard`.`Level1`=`CFKeys`.`Level1` AND `LocalTreeBoard`.`Level2`=IF(`CFKeys`.`Level3`=0,0,`CFKeys`.`Level2`)
            WHERE `CFKeys`.`Item`=NEW.`Code` AND `CFKeys`.`Keyboard`=GLOBAL_GET("PLUload-kbd_db") AND (`CFKeys`.`EAN`!='00000000000000' AND `CFKeys`.`Item`!=0) AND Board IS NOT NULL
            ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
        END IF;

      ELSE


        IF (NEW.`PLU`!=0) THEN
          SET @src1 := NULL;
          SET @src2 := NULL;
          SET @src3 := NULL;
          SET @src4 := NULL;
          SET @src5 := NULL;
          SET @board := (SELECT `Board` FROM
            (SELECT @src1:=`Source1` AS `Source1`,@src2:=`Source2` AS `Source2`,@src3:=`Source3` AS `Source3`,@src4:=`Source4` AS `Source4`,@src5:=`Source5` AS `Source5` FROM `PLUKeysFile`
              WHERE `PLUKeysFile`.`PLU`=NEW.`PLU` AND NEW.`OnKey`=TRUE) AS puk
            LEFT JOIN `LocalTreeBoard` AS ltb ON
              ((puk.`Source5`!=0) AND (puk.`Source4`=ltb.`Source4` AND puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`!=0) AND (puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`!=0) AND (puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`=0 AND puk.`Source2`!=0) AND (puk.`Source1`=ltb.`Source1`)));
          IF(@src1 IS NOT NULL) THEN

            IF (@board IS NULL) THEN
              UPDATE `LocalStatus` SET `ResizeTouch`=TRUE;
            ELSE
              INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
                VALUES(GLOBAL_GET("current_group"),@board, 100000*(IF(@src5!=0, @src5, IF(@src4!=0, @src4, IF(@src3!=0, @src3, IF(@src2!=0, @src2, @src1)))))+NEW.`PLU`, NEW.`Code`)
                ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
            END IF;
          END IF;
        END IF;
      END IF;




    ELSE BEGIN END;
  END CASE;

  SET @toffer := IFNULL (GLOBAL_GET("table-offer"),0);
  SET @thabitual := IFNULL (GLOBAL_GET("table-habitual"),0);
  IF ((NEW.`Code`!=0) AND (NEW.`PLU`!=0)) THEN
    IF ((NEW.`Offer`=1) AND (@toffer!=0)) THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@toffer,NEW.`PLU`,NEW.`Code`)
        ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
    ELSE
      IF (@thabitual!=0) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),@thabitual,`ItemHabitual`.`Position`,NEW.`Code` FROM `ItemHabitual`
          WHERE `ItemHabitual`.`Code`=NEW.`Code`
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemsUpdated` AFTER UPDATE ON `Items`
FOR EACH ROW BEGIN
  IF(NEW.`EAN13`!=OLD.`EAN13`) THEN
    IF(NEW.`EAN13`!='') THEN
      INSERT INTO ItemsEAN13 (`Code`, `EAN13`) VALUES (NEW.`Code`, NEW.`EAN13`) ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
    END IF;
    IF(OLD.`EAN13`!='') THEN
      DELETE FROM ItemsEAN13 WHERE `Code`=OLD.`Code` AND `EAN13`=OLD.`EAN13`;
    END IF;
  END IF;
  SET @loadfunc := IFNULL (GLOBAL_GET("PLUload-func"),99);
  CASE @loadfunc

    WHEN 0 THEN
      IF (OLD.`Code`!=NEW.`Code`) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT `Section`,`Board`,`PLUKey`,0 FROM `PLUKeys`
            WHERE `Code`=OLD.`Code` AND (`PLUKeys`.`Section`=GLOBAL_GET("current_group") OR (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard")) )
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
        SELECT `Section`,`Board`,`PLUKey`,IF(NEW.`Inactive`=FALSE, NEW.`Code`, 0) FROM `PLUKeys`
          WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=GLOBAL_GET("current_group") OR (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard")) )
        ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);

    WHEN 1 THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,`Code` FROM `PLUKeys`
        WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard"))
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;
      IF(NEW.`Family`!=OLD.`Family`) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,OLD.`Family`,`PLUKey`,0 FROM `PLUKeys`
          WHERE `Code`=NEW.`Code` AND `PLUKeys`.`Section`=GLOBAL_GET("current_group")
          ON DUPLICATE KEY UPDATE `Code`=0;
      END IF;

      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,NEW.`Family`,`PLUKey`,`Code` FROM `PLUKeys`
        WHERE `Code`=NEW.`Code` AND `PLUKeys`.`Section`=GLOBAL_GET("current_group")
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;

    WHEN 2 THEN
      IF(OLD.`Family`!=NEW.`Family`) THEN
        SET @famor := (SELECT `FamilyIndex` FROM `CounterFamilies` WHERE `CounterCode`=GLOBAL_GET("current_counter") AND `FamilyCode`=OLD.`Family`);
        IF(@famor IS NOT NULL) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES(GLOBAL_GET("current_group"),@famor,OLD.`FamilyOrder`,0)
          ON DUPLICATE KEY UPDATE `Code`=0;
        END IF;
      END IF;
      SET @famor := (SELECT `FamilyIndex` FROM `CounterFamilies` WHERE `CounterCode`=GLOBAL_GET("current_counter") AND `FamilyCode`=NEW.`Family`);
      IF (@famor IS NOT NULL) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES(GLOBAL_GET("current_group"),@famor,NEW.`FamilyOrder`,
         IF(((NEW.`OnKey`=TRUE) AND (NEW.`Inactive`=FALSE)), NEW.`Code`, 0))
        ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,IF(((NEW.`OnKey`=TRUE) AND (NEW.`Inactive`=FALSE)), `Code`, 0) FROM `PLUKeys`
        WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard"))
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;

    WHEN 3 THEN
      IF (OLD.`Counter`!=NEW.`Counter`) AND (OLD.`Counter`=GLOBAL_GET("current_counter")) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (OLD.`Counter`,0,OLD.`PLU`, 0)
        ON DUPLICATE KEY UPDATE `Code`=0;
      END IF;
      IF (NEW.`Counter`!=0) AND (NEW.`PLU`!=0) AND (NEW.`Counter`=GLOBAL_GET("current_counter")) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (NEW.`Counter`,0,NEW.`PLU`, NEW.`Code`)
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

    WHEN 100 THEN
       IF (OLD.`Counter`!=NEW.`Counter`) THEN
        IF (OLD.`Counter`!=0) AND (OLD.`PLU`!=0) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT OLD.`Counter`,board_idx,OLD.`PLU`, 0
          FROM (SELECT IF(Code=GLOBAL_GET("current_counter"),1,@a:=@a+1) AS board_idx, Code FROM (SELECT @a:=1) AS ct, Counters) AS tt100 WHERE OLD.`Counter`=tt100.Code
         ON DUPLICATE KEY UPDATE `Code`=0;
        END IF;
        IF (NEW.`Counter`!=0) AND (NEW.`PLU`!=0) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,NEW.`PLU`, NEW.`Code`
             FROM (SELECT IF(Code=GLOBAL_GET("current_counter"),1,@a:=@a+1) AS board_idx, Code FROM (SELECT @a:=1) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
        END IF;
      ELSE
        IF (NEW.`Counter`!=0) THEN
          IF (OLD.`PLU`!=0) THEN
            INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,OLD.`PLU`, 0
              FROM (SELECT IF(Code=GLOBAL_GET("current_counter"),1,@a:=@a+1) AS board_idx, Code FROM (SELECT @a:=1) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
            ON DUPLICATE KEY UPDATE `Code`=`LocalPLUKeysChanges`.`Code`;
          END IF;
          IF (NEW.`PLU`!=0) THEN
            INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,NEW.`PLU`, NEW.`Code`
              FROM (SELECT IF(Code=GLOBAL_GET("current_counter"),1,@a:=@a+1) AS board_idx, Code FROM (SELECT @a:=1) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
            ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
          END IF;
        END IF;
      END IF;

    WHEN 101 THEN
      IF (OLD.`Counter`!=NEW.`Counter`) THEN
        IF (OLD.`Counter`!=0) AND (OLD.`PLU`!=0) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT OLD.`Counter`,board_idx,OLD.`PLU`, 0
            FROM (SELECT @a:=@a+1 AS board_idx, Code FROM (SELECT @a:=0) AS ct, Counters) AS tt100 WHERE OLD.`Counter`=tt100.Code
         ON DUPLICATE KEY UPDATE `Code`=0;
        END IF;
        IF (NEW.`Counter`!=0) AND (NEW.`PLU`!=0) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,NEW.`PLU`, NEW.`Code`
             FROM (SELECT @a:=@a+1 AS board_idx, Code FROM (SELECT @a:=0) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
        END IF;
      ELSE
        IF (NEW.`Counter`!=0) THEN
           IF (OLD.`PLU`!=0) THEN
            INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,OLD.`PLU`, 0
              FROM (SELECT @a:=@a+1 AS board_idx, Code FROM (SELECT @a:=0) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
            ON DUPLICATE KEY UPDATE `Code`=`LocalPLUKeysChanges`.`Code`;
          END IF;
          IF (NEW.`PLU`!=0) THEN
            INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Counter`,board_idx,NEW.`PLU`, NEW.`Code`
              FROM (SELECT @a:=@a+1 AS board_idx, Code FROM (SELECT @a:=0) AS ct, Counters) AS tt100 WHERE NEW.`Counter`=tt100.Code
            ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
          END IF;
        END IF;
      END IF;

      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,IF(NEW.`OnKey`=TRUE, `Code`, 0) FROM `PLUKeys`
        WHERE `Code`=NEW.`Code` AND (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard"))
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;

    WHEN 4 THEN
      IF ((OLD.`PLU`!=0) AND (OLD.`Code`!=0)) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),`ItemGroupKeys`.`NumKey`,OLD.`PLU`,0 FROM `ItemGroupKeys`
          WHERE ((`ItemGroupKeys`.`Abovesection`!=0 AND `ItemGroupKeys`.`Abovesection`=OLD.`Abovesection`) OR (`ItemGroupKeys`.`Abovesection`=0))
          AND ((`ItemGroupKeys`.`Section`!=0 AND `ItemGroupKeys`.`Section`=OLD.`Section`) OR (`ItemGroupKeys`.`Section`=0))
          AND ((`ItemGroupKeys`.`SubSection`!=0 AND `ItemGroupKeys`.`SubSection`=OLD.`SubSection`) OR (`ItemGroupKeys`.`SubSection`=0))
          AND ((`ItemGroupKeys`.`Family`!=0 AND `ItemGroupKeys`.`Family`=OLD.`Family`) OR (`ItemGroupKeys`.`Family`=0))
          AND ((`ItemGroupKeys`.`SubFamily`!=0 AND `ItemGroupKeys`.`SubFamily`=OLD.`SubFamily`) OR (`ItemGroupKeys`.`SubFamily`=0))
          ON DUPLICATE KEY UPDATE `Code`=0;
      END IF;
      IF ((NEW.`PLU`!=0) AND (NEW.`Code`!=0)) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),`ItemGroupKeys`.`NumKey`,NEW.`PLU`,NEW.`Code` FROM `ItemGroupKeys`
          WHERE ((`ItemGroupKeys`.`Abovesection`!=0 AND `ItemGroupKeys`.`Abovesection`=NEW.`Abovesection`) OR (`ItemGroupKeys`.`Abovesection`=0))
          AND ((`ItemGroupKeys`.`Section`!=0 AND `ItemGroupKeys`.`Section`=NEW.`Section`) OR (`ItemGroupKeys`.`Section`=0))
          AND ((`ItemGroupKeys`.`SubSection`!=0 AND `ItemGroupKeys`.`SubSection`=NEW.`SubSection`) OR (`ItemGroupKeys`.`SubSection`=0))
          AND ((`ItemGroupKeys`.`Family`!=0 AND `ItemGroupKeys`.`Family`=NEW.`Family`) OR (`ItemGroupKeys`.`Family`=0))
          AND ((`ItemGroupKeys`.`SubFamily`!=0 AND `ItemGroupKeys`.`SubFamily`=NEW.`SubFamily`) OR (`ItemGroupKeys`.`SubFamily`=0))
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

    WHEN 5 THEN

      IF (SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name LIKE 'CFKeys') IS NOT NULL THEN
        IF ((OLD.`Code`!=NEW.`Code`)  AND (OLD.`OnKey`=TRUE)) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
            SELECT GLOBAL_GET("current_group"),`LocalTreeBoard`.`Board`, (`CFKeys`.`KeyCode`*10000)+(IF(`CFKeys`.`Level3`=0, `CFKeys`.`Level2`, `CFKeys`.`Level3`)), 0 FROM `CFKeys`
            LEFT JOIN `LocalTreeBoard` ON `LocalTreeBoard`.`Level1`=`CFKeys`.`Level1` AND `LocalTreeBoard`.`Level2`=IF(`CFKeys`.`Level3`=0,0,`CFKeys`.`Level2`)
            WHERE `CFKeys`.`Item`=OLD.`Code` AND `CFKeys`.`Keyboard`=GLOBAL_GET("PLUload-kbd_db") AND (`CFKeys`.`EAN`!='00000000000000' AND `CFKeys`.`Item`!=0) AND Board IS NOT NULL
            ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
        END IF;
        IF (NEW.`Code`!=0) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
            SELECT GLOBAL_GET("current_group"),`LocalTreeBoard`.`Board`, (`CFKeys`.`KeyCode`*10000)+(IF(`CFKeys`.`Level3`=0, `CFKeys`.`Level2`, `CFKeys`.`Level3`)), IF(NEW.`OnKey`=TRUE, NEW.`Code`, 0) FROM `CFKeys`
            LEFT JOIN `LocalTreeBoard` ON `LocalTreeBoard`.`Level1`=`CFKeys`.`Level1` AND `LocalTreeBoard`.`Level2`=IF(`CFKeys`.`Level3`=0,0,`CFKeys`.`Level2`)
            WHERE `CFKeys`.`Item`=NEW.`Code` AND `CFKeys`.`Keyboard`=GLOBAL_GET("PLUload-kbd_db") AND (`CFKeys`.`EAN`!='00000000000000' AND `CFKeys`.`Item`!=0) AND Board IS NOT NULL
            ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
        END IF;

      ELSE


        IF ((OLD.`PLU`!=0) AND ((OLD.`PLU`!=NEW.`PLU`) OR (OLD.`Code`!=NEW.`Code`))) THEN
          SET @src1 := NULL;
          SET @src2 := NULL;
          SET @src3 := NULL;
          SET @src4 := NULL;
          SET @src5 := NULL;
          SET @board := (SELECT `Board` FROM
            (SELECT @src1:=`Source1` AS `Source1`,@src2:=`Source2` AS `Source2`,@src3:=`Source3` AS `Source3`,@src4:=`Source4` AS `Source4`,@src5:=`Source5` AS `Source5` FROM `PLUKeysFile`
              WHERE `PLUKeysFile`.`PLU`=OLD.`PLU` AND OLD.`OnKey`=TRUE) AS puk
            LEFT JOIN `LocalTreeBoard` AS ltb ON
              ((puk.`Source5`!=0) AND (puk.`Source4`=ltb.`Source4` AND puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`!=0) AND (puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`!=0) AND (puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`=0 AND puk.`Source2`!=0) AND (puk.`Source1`=ltb.`Source1`)));

          IF((@src1 IS NOT NULL) AND (@board IS NOT NULL)) THEN
              INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
                VALUES(GLOBAL_GET("current_group"),@board, 100000*(IF(@src5!=0, @src5, IF(@src4!=0, @src4, IF(@src3!=0, @src3, IF(@src2!=0, @src2, @src1)))))+OLD.`PLU`, 0)
                ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
          END IF;
        END IF;
        IF (NEW.`PLU`!=0) THEN
          SET @src1 := NULL;
          SET @src2 := NULL;
          SET @src3 := NULL;
          SET @src4 := NULL;
          SET @src5 := NULL;
          SET @board := (SELECT `Board` FROM
            (SELECT @src1:=`Source1` AS `Source1`,@src2:=`Source2` AS `Source2`,@src3:=`Source3` AS `Source3`,@src4:=`Source4` AS `Source4`,@src5:=`Source5` AS `Source5` FROM `PLUKeysFile`
              WHERE `PLUKeysFile`.`PLU`=NEW.`PLU` AND NEW.`OnKey`=TRUE) AS puk
            LEFT JOIN `LocalTreeBoard` AS ltb ON
              ((puk.`Source5`!=0) AND (puk.`Source4`=ltb.`Source4` AND puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`!=0) AND (puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`!=0) AND (puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`=0 AND puk.`Source2`!=0) AND (puk.`Source1`=ltb.`Source1`)));
          IF(@src1 IS NOT NULL) THEN

            IF (@board IS NULL) THEN
              UPDATE `LocalStatus` SET `ResizeTouch`=TRUE;
            ELSE
              INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
                VALUES(GLOBAL_GET("current_group"),@board, 100000*(IF(@src5!=0, @src5, IF(@src4!=0, @src4, IF(@src3!=0, @src3, IF(@src2!=0, @src2, @src1)))))+NEW.`PLU`, NEW.`Code`)
                ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
            END IF;
          END IF;
        END IF;
      END IF;




    ELSE BEGIN END;
  END CASE;


  SET @toffer := IFNULL (GLOBAL_GET("table-offer"),0);
  SET @thabitual := IFNULL (GLOBAL_GET("table-habitual"),0);
  IF ((OLD.`Code`!=0) AND (OLD.`PLU`!=0)) THEN
    IF ((OLD.`Offer`=1) AND (@toffer!=0)) THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@toffer,OLD.`PLU`,0)
        ON DUPLICATE KEY UPDATE `Code`=0;
    ELSE
      IF (@thabitual!=0) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),@thabitual,`ItemHabitual`.`Position`,0 FROM `ItemHabitual`
          WHERE `ItemHabitual`.`Code`=OLD.`Code`
          ON DUPLICATE KEY UPDATE `Code`=0;
      END IF;
    END IF;
  END IF;
  IF ((NEW.`Code`!=0) AND (NEW.`PLU`!=0)) THEN
    IF ((NEW.`Offer`=1) AND (@toffer!=0)) THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@toffer,NEW.`PLU`,NEW.`Code`)
        ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
    ELSE
      IF (@thabitual!=0) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),@thabitual,`ItemHabitual`.`Position`,NEW.`Code` FROM `ItemHabitual`
            WHERE `ItemHabitual`.`Code`=NEW.`Code`
            ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemsDeleted` BEFORE DELETE ON `Items`
FOR EACH ROW BEGIN
  SET @loadfunc := IFNULL (GLOBAL_GET("PLUload-func"),99);
  CASE @loadfunc

    WHEN 0 THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,0 FROM `PLUKeys`
        WHERE `Code`=OLD.`Code` AND (`PLUKeys`.`Section`=GLOBAL_GET("current_group") OR (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard")) )
        ON DUPLICATE KEY UPDATE `Code`=0;

    WHEN 1 THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,0 FROM `PLUKeys`
        WHERE `Code`=OLD.`Code` AND (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard"))
        ON DUPLICATE KEY UPDATE `Code`=0;
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,OLD.`Family`,`PLUKey`,0 FROM `PLUKeys`
        WHERE `Code`=OLD.`Code` AND `PLUKeys`.`Section`=GLOBAL_GET("current_group")
        ON DUPLICATE KEY UPDATE `Code`=0;

    WHEN 2 THEN
      SET @famor := (SELECT `FamilyIndex` FROM `CounterFamilies` WHERE `CounterCode`=GLOBAL_GET("current_counter") AND `FamilyCode`=OLD.`Family`);
      IF (@famor IS NOT NULL) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES(GLOBAL_GET("current_group"),@famor,OLD.`FamilyOrder`,0)
        ON DUPLICATE KEY UPDATE `Code`=0;
      END IF;
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT `Section`,`Board`,`PLUKey`,0 FROM `PLUKeys`
        WHERE `Code`=OLD.`Code` AND (`PLUKeys`.`Section`=0 AND `PLUKeys`.`Board`=GLOBAL_GET("current_mupboard"))
        ON DUPLICATE KEY UPDATE `Code`=0;

     WHEN 3 THEN
      IF (OLD.`Counter`!=0) AND (OLD.`PLU`!=0) AND (OLD.`Counter`=GLOBAL_GET("current_counter")) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (OLD.`Counter`,0,OLD.`PLU`, 0)
          ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
      END IF;

      WHEN 100 THEN
        IF (OLD.`Counter`!=0) AND (OLD.`PLU`!=0) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT OLD.`Counter`,board_idx,OLD.`PLU`, 0
            FROM (SELECT IF(Code=GLOBAL_GET("current_counter"),1,@a:=@a+1) AS board_idx, Code FROM (SELECT @a:=1) AS ct, Counters) AS tt100 WHERE OLD.`Counter`=tt100.Code
          ON DUPLICATE KEY UPDATE `Code`=0;
        END IF;

    WHEN 101 THEN
        IF (OLD.`Counter`!=0) AND (OLD.`PLU`!=0) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT OLD.`Counter`,board_idx,OLD.`PLU`, 0
            FROM (SELECT @a:=@a+1 AS board_idx, Code FROM (SELECT @a:=0) AS ct, Counters) AS tt100 WHERE OLD.`Counter`=tt100.Code
          ON DUPLICATE KEY UPDATE `Code`=0;
        END IF;

    WHEN 4 THEN
      IF ((OLD.`PLU`!=0) AND (OLD.`Code`!=0)) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),`ItemGroupKeys`.`NumKey`,OLD.`PLU`,0 FROM `ItemGroupKeys`
          WHERE ((`ItemGroupKeys`.`Abovesection`!=0 AND `ItemGroupKeys`.`Abovesection`=OLD.`Abovesection`) OR (`ItemGroupKeys`.`Abovesection`=0))
          AND ((`ItemGroupKeys`.`Section`!=0 AND `ItemGroupKeys`.`Section`=OLD.`Section`) OR (`ItemGroupKeys`.`Section`=0))
          AND ((`ItemGroupKeys`.`SubSection`!=0 AND `ItemGroupKeys`.`SubSection`=OLD.`SubSection`) OR (`ItemGroupKeys`.`SubSection`=0))
          AND ((`ItemGroupKeys`.`Family`!=0 AND `ItemGroupKeys`.`Family`=OLD.`Family`) OR (`ItemGroupKeys`.`Family`=0))
          AND ((`ItemGroupKeys`.`SubFamily`!=0 AND `ItemGroupKeys`.`SubFamily`=OLD.`SubFamily`) OR (`ItemGroupKeys`.`SubFamily`=0))
          ON DUPLICATE KEY UPDATE `Code`=0;
      END IF;

    WHEN 5 THEN

      IF (SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name LIKE 'CFKeys') IS NOT NULL THEN
        IF ((OLD.`Code`!=0) AND (OLD.`OnKey`=TRUE)) THEN
          INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
            SELECT GLOBAL_GET("current_group"),`LocalTreeBoard`.`Board`, (`CFKeys`.`KeyCode`*10000)+(IF(`CFKeys`.`Level3`=0, `CFKeys`.`Level2`, `CFKeys`.`Level3`)), 0 FROM `CFKeys`
            LEFT JOIN `LocalTreeBoard` ON `LocalTreeBoard`.`Level1`=`CFKeys`.`Level1` AND `LocalTreeBoard`.`Level2`=IF(`CFKeys`.`Level3`=0,0,`CFKeys`.`Level2`)
            WHERE `CFKeys`.`Item`=OLD.`Code` AND `CFKeys`.`Keyboard`=GLOBAL_GET("PLUload-kbd_db") AND (`CFKeys`.`EAN`!='00000000000000' AND `CFKeys`.`Item`!=0) AND Board IS NOT NULL
            ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
        END IF;

      ELSE


        IF (OLD.`PLU`!=0) THEN
          SET @src1 := NULL;
          SET @src2 := NULL;
          SET @src3 := NULL;
          SET @src4 := NULL;
          SET @src5 := NULL;
          SET @board := (SELECT `Board` FROM
            (SELECT @src1:=`Source1` AS `Source1`,@src2:=`Source2` AS `Source2`,@src3:=`Source3` AS `Source3`,@src4:=`Source4` AS `Source4`,@src5:=`Source5` AS `Source5` FROM `PLUKeysFile`
              WHERE `PLUKeysFile`.`PLU`=OLD.`PLU` AND OLD.`OnKey`=TRUE) AS puk
            LEFT JOIN `LocalTreeBoard` AS ltb ON
              ((puk.`Source5`!=0) AND (puk.`Source4`=ltb.`Source4` AND puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`!=0) AND (puk.`Source3`=ltb.`Source3` AND puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`!=0) AND (puk.`Source2`=ltb.`Source2` AND puk.`Source1`=ltb.`Source1`)) OR
              ((puk.`Source5`=0 AND puk.`Source4`=0 AND puk.`Source3`=0 AND puk.`Source2`!=0) AND (puk.`Source1`=ltb.`Source1`)));

          IF((@src1 IS NOT NULL) AND (@board IS NOT NULL)) THEN
              INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
                VALUES(GLOBAL_GET("current_group"),@board, 100000*(IF(@src5!=0, @src5, IF(@src4!=0, @src4, IF(@src3!=0, @src3, IF(@src2!=0, @src2, @src1)))))+OLD.`PLU`, 0)
                ON DUPLICATE KEY UPDATE `Code`=VALUES(`Code`);
          END IF;
        END IF;
      END IF;




    ELSE BEGIN END;
  END CASE;

  SET @toffer := IFNULL (GLOBAL_GET("table-offer"),0);
  SET @thabitual := IFNULL (GLOBAL_GET("table-habitual"),0);
  IF ((OLD.`Code`!=0) AND (OLD.`PLU`!=0)) THEN
    IF ((OLD.`Offer`=1) AND (@toffer!=0)) THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (GLOBAL_GET("current_group"),@toffer,OLD.`PLU`,0)
        ON DUPLICATE KEY UPDATE `Code`=0;
    ELSE
      IF (@thabitual!=0) THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`)
          SELECT GLOBAL_GET("current_group"),@thabitual,`ItemHabitual`.`Position`,0 FROM `ItemHabitual` WHERE `ItemHabitual`.`Code`=OLD.`Code`
          ON DUPLICATE KEY UPDATE `Code`=0;
      END IF;
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemsExtraPointsInserted` AFTER INSERT ON `ItemsExtraPoints`
FOR EACH ROW BEGIN
  UPDATE `Items` SET `Items`.`Code`=`Items`.`Code` WHERE `Items`.`Code`=NEW.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemsExtraPointsUpdated` AFTER UPDATE ON `ItemsExtraPoints`
FOR EACH ROW BEGIN
  IF(OLD.`Code`!=NEW.`Code`) THEN
    UPDATE `Items` SET `Items`.`Code`=`Items`.`Code` WHERE `Items`.`Code`=OLD.`Code`;
  END IF;
  UPDATE `Items` SET `Items`.`Code`=`Items`.`Code` WHERE `Items`.`Code`=NEW.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ItemsExtraPointsDeleted` AFTER DELETE ON `ItemsExtraPoints`
FOR EACH ROW BEGIN
  UPDATE `Items` SET `Items`.`Code`=`Items`.`Code` WHERE `Items`.`Code`=OLD.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LCorderInserted` AFTER INSERT ON `LCustomerOrders`
FOR EACH ROW BEGIN

  UPDATE `HCustomerOrders` SET `HCustomerOrders`.`DatTim`=NOW(),
    `HCustomerOrders`.`AddedLines`=`HCustomerOrders`.`AddedLines`+IF(NEW.`Status`!=7,1,0),
    `HCustomerOrders`.`NetAmount`=`HCustomerOrders`.`NetAmount`+NEW.`Amount`,
    `HCustomerOrders`.`TotalWeight`=`HCustomerOrders`.`TotalWeight`+NEW.`Weight`, `HCustomerOrders`.`TotalUnits`=`HCustomerOrders`.`TotalUnits`+NEW.`Units`
    WHERE (`HCustomerOrders`.`Number`=NEW.`OrderNumber` AND `HCustomerOrders`.`Section`=NEW.`Section`) AND ((`HCustomerOrders`.`Status`>1) AND (`HCustomerOrders`.`Status`!=3));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LCorderUpdated` AFTER UPDATE ON `LCustomerOrders`
FOR EACH ROW BEGIN
  UPDATE `HCustomerOrders` SET `HCustomerOrders`.`DatTim`=NOW(),
    `HCustomerOrders`.`AddedLines`=`HCustomerOrders`.`AddedLines`+
      IF(((NEW.`Status`=5 AND OLD.`Status`=0) OR (NEW.`Status`=0 AND OLD.`Status`=5) OR (NEW.`Status`=7 AND OLD.`Status`=2) OR (NEW.`Status`=2 AND OLD.`Status`=7)), 0,
      IF((OLD.`Weight`=0 AND OLD.`Units`=0), 1, IF(NEW.`Weight`=0 AND NEW.`Units`=0, -1, 0))),
    `HCustomerOrders`.`NetAmount`=`HCustomerOrders`.`NetAmount`-OLD.`Amount`+NEW.`Amount`,
    `HCustomerOrders`.`TotalWeight`=`HCustomerOrders`.`TotalWeight`-OLD.`Weight`+NEW.`Weight`, `HCustomerOrders`.`TotalUnits`=`HCustomerOrders`.`TotalUnits`-OLD.`Units`+NEW.`Units`
    WHERE (`HCustomerOrders`.`Number`=OLD.`OrderNumber` AND `HCustomerOrders`.`Section`=OLD.`Section`) AND ((`HCustomerOrders`.`Status`>1) AND (`HCustomerOrders`.`Status`!=3));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalCfgInserted` AFTER INSERT ON `LocalCfgScale`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("BUTTON_UPDATE", "GUI"));
  SET @ret := (SELECT trx_set_param(@trx, "KEYNAME", CONCAT("LOCALCFGSCALE_", NEW.`ParamKey`)));
  SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", NEW.`ParamValue`));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalCfgUpdated` AFTER UPDATE ON `LocalCfgScale`
FOR EACH ROW BEGIN
  IF(OLD.`ParamValue`!=NEW.`ParamValue`) THEN
    SET @trx := (SELECT trx_new("BUTTON_UPDATE", "GUI"));
    SET @ret := (SELECT trx_set_param(@trx, "KEYNAME", CONCAT("LOCALCFGSCALE_", NEW.`ParamKey`)));
    SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", NEW.`ParamValue`));
    SET @ret := (SELECT trx_send(@trx));
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalCfgDeleted` AFTER DELETE ON `LocalCfgScale`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("BUTTON_UPDATE", "GUI"));
  SET @ret := (SELECT trx_set_param(@trx, "KEYNAME", CONCAT("LOCALCFGSCALE_", OLD.`ParamKey`)));
  SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", ""));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalCommInserted` AFTER INSERT ON `LocalComm`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("RELOAD", "COMM"));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalCommUpdated` AFTER UPDATE ON `LocalComm`
FOR EACH ROW BEGIN
    SET @trx := (SELECT trx_new("RELOAD", "COMM"));
    SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalCommDeleted` AFTER DELETE ON `LocalComm`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("RELOAD", "COMM"));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalVendorTicketNew` AFTER INSERT ON `LocalHTickets`
FOR EACH ROW BEGIN
	REPLACE INTO `LocalVendorChanges` VALUES (NEW.`Vendor`*10, NEW.`Vendor`,'0');
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalHTicketsUpdateB` BEFORE UPDATE ON `LocalHTickets`
FOR EACH ROW BEGIN
  IF(NEW.`NetStat`='L') THEN
    SET @frac_digits := IFNULL(GLOBAL_GET("frac_digits"), 2);

    IF(OLD.`PointsDiscount`!=NEW.`PointsDiscount`) THEN
      SET @lypoints = (SELECT IFNULL(`ParamValue`,0) FROM `CfgSystem` WHERE `ParamKey`='loyalty-points-discount-currency');
      SET NEW.`PointsAmount`= IF(@lypoints,ROUND(NEW.`PointsDiscount`/@lypoints, @frac_digits),0);
      SET NEW.`NetAmount`=`pcs_net`(NEW.`GrossAmount`, NEW.`tckDiscount`, NEW.`PointsAmount`);
    END IF;
    IF((OLD.`GrossAmount`!=NEW.`GrossAmount`) OR (OLD.`tckDiscount`!=NEW.`tckDiscount`) OR (OLD.`Customer`!=NEW.`Customer`)) THEN
      SET NEW.`PointsDiscount`=0;
      SET NEW.`PointsAmount`= 0;
      SET NEW.`NetAmount`=`pcs_net`(NEW.`GrossAmount`, NEW.`tckDiscount`, NEW.`PointsAmount`);
    END IF;
    IF(OLD.`NetAmount`!=NEW.`NetAmount`) THEN
      SET @points = (SELECT IFNULL(`ParamValue`,0) FROM `CfgSystem` WHERE `ParamKey`='loyalty-currency-give-point');
      SET NEW.`Points`=IF(@points,FLOOR(NEW.`NetAmount`/@points),0);
    END IF;
    IF(OLD.`Status`!=NEW.`Status`) AND ((NEW.`Status`='C') OR (NEW.`Status`='X') OR (NEW.`Status`='D') OR (NEW.`Status`='R')) THEN
      SET NEW.`NeedCopy`=TRUE;
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalHTicketsUpdate` AFTER UPDATE ON `LocalHTickets`
FOR EACH ROW BEGIN

  IF(NEW.`ReloadTo`!=0) AND (OLD.`Status`!= NEW.`Status`) THEN
    UPDATE `LTickets` SET `LTickets`.`ReloadTo`=NEW.`ReloadTo` WHERE `LTickets`.`IdHTicket`=NEW.`Id`;
  END IF;
  REPLACE INTO `LocalVendorChanges` VALUES (NEW.`Vendor`*10, NEW.`Vendor`,'0');
  IF(OLD.`Number`!= NEW.`Number`) THEN
    IF((SELECT IFNULL(`ParamValue`, 0) FROM `CfgSystem` WHERE `ParamKey`='prices-without-taxes')=1) THEN
      UPDATE `LocalLTickets` AS `lt` SET `lt`.`PrintScale`=NEW.`Scale`, `lt`.`PrintDateTime`=NEW.`DatTim`, `lt`.`PrintTicketNumber`=NEW.`Number`,
        `lt`.`PrinttckType`=NEW.`tckType`, `lt`.`TicketDiscount`=NEW.`tckDiscount`, `lt`.`BaseAmount`=`lt`.`Amount`
        WHERE `lt`.`IdHTicket`=NEW.`Id`;
    ELSE
      UPDATE `LocalLTickets` AS `lt` SET `lt`.`PrintScale`=NEW.`Scale`, `lt`.`PrintDateTime`=NEW.`DatTim`, `lt`.`PrintTicketNumber`=NEW.`Number`,
        `lt`.`PrinttckType`=NEW.`tckType`, `lt`.`TicketDiscount`=NEW.`tckDiscount`, `lt`.`BaseAmount`=(`lt`.`Amount`*(100-NEW.`tckDiscount`))/(100+`lt`.`VATPercent`)
        WHERE `lt`.`IdHTicket`=NEW.`Id`;
    END IF;
  END IF;
  IF(NEW.`NetStat`='L') THEN
    UPDATE `LocalStatus` SET `LocalTickets` = TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalLTicketsInsertB` BEFORE INSERT ON `LocalLTickets`
FOR EACH ROW BEGIN
  SET @HTStatus:=(SELECT Status FROM `LocalHTickets` WHERE `LocalHTickets`.`Id`=NEW.`IdHTicket`);

  IF (@HTStatus!='?') THEN

    IF ((NEW.`NetStat`='L') AND  (NEW.`lineType`=1)) THEN
      IF (@HTStatus='O') THEN
        SET NEW.`LineDateTime`=NOW();
        IF ((SELECT IFNULL(`ParamValue`,0) FROM `CfgSystem` WHERE `ParamKey`='loyalty-items-extra-points')!=0) THEN
          SET NEW.`Points`=IFNULL((SELECT
            IF(`ItemsExtraPoints`.`FromQuantity`,

              IF(`ItemsExtraPoints`.`Quantity`,

                IF(`ItemsExtraPoints`.`Proportional`,

                  IF(NEW.`Weight`>=`ItemsExtraPoints`.`FromQuantity`,(((NEW.`Weight`-`ItemsExtraPoints`.`FromQuantity`)/`ItemsExtraPoints`.`Quantity`) +1)*`ItemsExtraPoints`.`Points`, 0),

                    IF(NEW.`Weight`>=`ItemsExtraPoints`.`FromQuantity`,(((NEW.`Weight`-`ItemsExtraPoints`.`FromQuantity`)/`ItemsExtraPoints`.`Quantity`) DIV 1 +1)*`ItemsExtraPoints`.`Points`, 0)),

                IF(NEW.`Weight`>=`ItemsExtraPoints`.`FromQuantity`,`ItemsExtraPoints`.`Points`,0)),

              IF(`ItemsExtraPoints`.`Quantity`,

                IF(`ItemsExtraPoints`.`Proportional`,

                  (NEW.`Weight`/`ItemsExtraPoints`.`Quantity`)*`ItemsExtraPoints`.`Points`,

                    IF(NEW.`Weight`>=`ItemsExtraPoints`.`Quantity`,(((NEW.`Weight`-`ItemsExtraPoints`.`Quantity`)/`ItemsExtraPoints`.`Quantity`) DIV 1 +1)*`ItemsExtraPoints`.`Points`, 0)),

                `ItemsExtraPoints`.`Points`))
          FROM `ItemsExtraPoints` WHERE `ItemsExtraPoints`.`Code`=NEW.`Item`), 0);
        END IF;

      ELSE
        UPDATE `PCScaleErrorTag` SET x=1;
      END IF;
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalLTicketsInserted` AFTER INSERT ON `LocalLTickets`
FOR EACH ROW BEGIN

  IF(NEW.`NetStat`='L') THEN
    SET @wgt = IF(NEW.`SaleForm`=1,NEW.`Weight`,0);
    SET @units = IF(NEW.`SaleForm`=0,NEW.`Weight`,0);
    CASE(NEW.`lineType`)

      WHEN 0 THEN
        UPDATE `LocalHTickets` SET `NumLines`=`NumLines`+1, `CanceledLines`=`CanceledLines`+1, `CanceledAmount`=`CanceledAmount`+NEW.`Amount`,
          `DatTim`=NOW(), `SectionItem`=NEW.`Section` WHERE `LocalHTickets`.`Id`=NEW.`IdHTicket` AND `LocalHTickets`.`Status`='O';

      WHEN 1 THEN
        UPDATE `LocalHTickets` SET `NumLines`=`NumLines`+1, `AddedLines`=`AddedLines`+1, `GrossAmount`=`GrossAmount`+NEW.`Amount`,
               `NegativeLines`=`NegativeLines`+IF(NEW.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`+IF(NEW.`Price`<0,-NEW.`Amount`,0),
               `TotalWeight`=`TotalWeight`+IF(NEW.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`+IF(NEW.`Price`<0,0,@units),
               `LocalHTickets`.`PointsExtra`=`LocalHTickets`.`PointsExtra`+IF(NEW.`Price`>0,NEW.`Points`,0),
               `DatTim`=NOW(), `SectionItem`=NEW.`Section` WHERE `LocalHTickets`.`Id`=NEW.`IdHTicket` AND `LocalHTickets`.`Status`='O' AND `LocalHTickets`.`NetStat`='L';

      WHEN 3 THEN
        IF(NEW.`SaleForm`=0) THEN
          UPDATE `LocalHTickets` SET `TotalWeight`=`TotalWeight`+@wgt, `TotalUnits`=`TotalUnits`+@units, `PointsChanged`=`PointsChanged`+NEW.`Price`, `DatTim`=NOW()
            WHERE `LocalHTickets`.`Id`=NEW.`IdHTicket` AND `LocalHTickets`.`Status`='O' ;
        END IF;

      ELSE BEGIN END;
    END CASE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalLTicketsUpdated` AFTER UPDATE ON `LocalLTickets`
FOR EACH ROW BEGIN
  IF((NEW.`Amount`!=OLD.`Amount`) OR (NEW.`VATCode`!=OLD.`VATCode`) OR (NEW.`VATPercent`!=OLD.`VATPercent`)
    OR (NEW.`SaleForm`!=OLD.`SaleForm`) OR (NEW.`Weight`!=OLD.`Weight`) OR (NEW.`Price`!=OLD.`Price`) OR (NEW.`lineDiscount`!=OLD.`lineDiscount`)
    OR ((NEW.`lineType`!=OLD.`lineType`) AND (NEW.`IdHTicket`!=OLD.`IdHTicket`))) THEN
    CALL `manipulate_protected_field`;
  END IF;

  IF((NEW.`lineType`!=OLD.`lineType`) AND (NEW.`IdHTicket`=OLD.`IdHTicket`)) THEN
    SET @wgt = IF(OLD.`SaleForm`=1,OLD.`Weight`,0);
    SET @units = IF(NEW.`SaleForm`=0,NEW.`Weight`,0);
    CASE(NEW.`lineType`)

      WHEN 0 THEN
        IF(OLD.`lineType`=1) THEN
          UPDATE `LocalHTickets` AS ht SET `AddedLines`=`AddedLines`-1, `GrossAmount`=`GrossAmount`-OLD.`Amount`,
            `NegativeLines`=`NegativeLines`-IF(OLD.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`-IF(OLD.`Price`<0,-OLD.`Amount`,0),
            `CanceledLines`=`CanceledLines`+1, `CanceledAmount` = `CanceledAmount`+OLD.`Amount`,
            `TotalWeight`=`TotalWeight`-IF(OLD.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`-IF(NEW.`Price`<0,0,@units),
            ht.`PointsExtra`=ht.`PointsExtra`-IF(OLD.`Price`>0,OLD.`Points`,0), `DatTim`=NOW()
          WHERE ht.`Id`=OLD.`IdHTicket`;
        END IF;

      WHEN 1 THEN
        IF(OLD.`lineType`=0) THEN
          UPDATE `LocalHTickets` AS ht SET `AddedLines`=`AddedLines`+1, `GrossAmount`=`GrossAmount`+OLD.`Amount`,
            `NegativeLines`=`NegativeLines`+IF(OLD.`Price`<0,1,0), `NegativeAmount`=`NegativeAmount`+IF(OLD.`Price`<0,-OLD.`Amount`,0),
            `CanceledLines`=`CanceledLines`-1, `CanceledAmount`=`CanceledAmount`-OLD.`Amount`,
            `TotalWeight`=`TotalWeight`+IF(OLD.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`+IF(NEW.`Price`<0,0,@units),
            ht.`PointsExtra`=ht.`PointsExtra`+IF(OLD.`Price`>0,OLD.`Points`,0), `DatTim`=NOW()
          WHERE ht.`Id`=OLD.`IdHTicket`;
        END IF;

      WHEN 2 THEN
        IF((NEW.`SaleForm`=0) AND (OLD.`lineType`=3)) THEN
          UPDATE `LocalHTickets` AS ht SET `TotalWeight`=`TotalWeight`-@wgt, `TotalUnits`=`TotalUnits`-@units, `PointsChanged`=`PointsChanged`-OLD.`Price`, `DatTim`=NOW() WHERE ht.`Id`=OLD.`IdHTicket`;
        END IF;

      WHEN 3 THEN
        IF((NEW.`SaleForm`=0) AND (OLD.`lineType`=2)) THEN
          UPDATE `LocalHTickets` AS ht SET `TotalWeight`=`TotalWeight`+@wgt, `TotalUnits`=`TotalUnits`+@units, `PointsChanged`=`PointsChanged`+OLD.`Price`, `DatTim`=NOW() WHERE ht.`Id`=OLD.`IdHTicket`;
        END IF;

      ELSE BEGIN END;
    END CASE;


  ELSEIF((NEW.`lineType`=OLD.`lineType`) AND (NEW.`IdHTicket`!=OLD.`IdHTicket`)) THEN
    SET @wgt = IF(NEW.`SaleForm`=1,NEW.`Weight`,0);
    SET @units = IF(NEW.`SaleForm`=0,NEW.`Weight`,0);
    SET @src_stck = ' ';
    SET @src_norder = 0;
    SET @dst_stck = ' ';
    SET @dst_norder = 0;
    SELECT `Status`, `OrderNumber`INTO @src_stck,@src_norder FROM `LocalHTickets` AS ht WHERE ht.`Id`=OLD.`IdHTicket`;
    SELECT `Status`, `OrderNumber`INTO @dst_stck,@dst_norder FROM `LocalHTickets` AS ht WHERE ht.`Id`=NEW.`IdHTicket`;
    IF ((@src_stck='O' OR @src_stck='P') AND (@dst_stck='O') AND (@src_norder='') AND (@dst_norder='')) THEN
      CASE(NEW.`lineType`)

        WHEN 0 THEN
          UPDATE `LocalHTickets` AS ht SET `NumLines`=`NumLines`+1, `CanceledLines`=`CanceledLines`+1, `CanceledAmount`=`CanceledAmount`+NEW.`Amount` WHERE ht.`Id`=NEW.`IdHTicket`;
          UPDATE `LocalHTickets` AS ht SET `NumLines`=`NumLines`-1, `CanceledLines`=`CanceledLines`-1, `CanceledAmount`=`CanceledAmount`-NEW.`Amount` WHERE ht.`Id`=OLD.`IdHTicket`;

        WHEN 1 THEN
          UPDATE `LocalHTickets` AS ht SET `NumLines`=`NumLines`+1, `AddedLines`=`AddedLines`+1, `GrossAmount`=`GrossAmount`+NEW.`Amount`,
            `NegativeLines`=`NegativeLines`+IF(NEW.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`+IF(NEW.`Price`<0,-NEW.`Amount`,0),
            `TotalWeight`=`TotalWeight`+IF(NEW.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`+IF(NEW.`Price`<0,0,@units)
             WHERE ht.`Id`=NEW.`IdHTicket`;
          UPDATE `LocalHTickets` AS ht SET `NumLines`=`NumLines`-1, `AddedLines`=`AddedLines`-1, `GrossAmount`=`GrossAmount`-NEW.`Amount`,
            `NegativeLines`=`NegativeLines`-IF(NEW.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`-IF(NEW.`Price`<0,-NEW.`Amount`,0),
            `TotalWeight`=`TotalWeight`-IF(NEW.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`-IF(NEW.`Price`<0,0,@units)
             WHERE ht.`Id`=OLD.`IdHTicket`;

        WHEN 3 THEN
          IF(NEW.`SaleForm`=0) THEN
            UPDATE `LocalHTickets` AS ht SET `TotalWeight`=`TotalWeight`+@wgt, `TotalUnits`=`TotalUnits`+@units WHERE ht.`Id`=NEW.`IdHTicket`;
            UPDATE `LocalHTickets` AS ht SET `TotalWeight`=`TotalWeight`-@wgt, `TotalUnits`=`TotalUnits`-@units WHERE ht.`Id`=OLD.`IdHTicket`;
          END IF;

        ELSE BEGIN END;
      END CASE;
    ELSE
      CALL `manipulate_protected_field1`;
    END IF;

  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertLocalVendorKey` AFTER INSERT ON `LocalVendorKeys`
FOR EACH ROW BEGIN
  IF (NEW.`Counter`= GLOBAL_GET("current_counter")) THEN
    REPLACE INTO `LocalVendorKeysChanges` (`VendorKey`, `Vendor`, `VendorRelease`,`Name`, `Icon`) 
     SELECT NEW.`VendorKey`, NEW.`Vendor`, 8880, `Vendors`.`Name`, `Vendors`.`Icon` 
     FROM `Vendors` WHERE `Vendors`.`Code`=NEW.`Vendor`;
    IF @disable_localregister IS NULL THEN
      INSERT INTO `LocalVendorRegister` (`Vendor`,`RegisterDateTime`) VALUES (NEW.`Vendor`,NOW());
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateLocalVendorKey` AFTER UPDATE ON `LocalVendorKeys`
FOR EACH ROW BEGIN
  SET @counter := GLOBAL_GET("current_counter");
  IF (OLD.`Counter`= @counter) THEN
    INSERT INTO `LocalVendorKeysChanges` (`VendorKey`, `VendorRelease`) VALUE (OLD.`VendorKey`, OLD.`Vendor` )
    ON DUPLICATE KEY UPDATE `LocalVendorKeysChanges`.`VendorRelease`=OLD.`Vendor`;
  END IF;
  IF (NEW.`Counter`= @counter) THEN
    INSERT INTO `LocalVendorKeysChanges` (`VendorKey`, `Vendor`, `VendorRelease`, `Name`, `Icon`) 
      SELECT NEW.`VendorKey`, NEW.`Vendor`, OLD.`Vendor`, `Vendors`.`Name`, `Vendors`.`Icon` FROM `Vendors` WHERE `Vendors`.`Code`=NEW.`Vendor` 
    ON DUPLICATE KEY UPDATE `LocalVendorKeysChanges`.`Vendor`=NEW.`Vendor`, `LocalVendorKeysChanges`.`Name`=VALUES(`Name`), `LocalVendorKeysChanges`.`Icon`=VALUES(`Icon`);
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteLocalVendorKey` AFTER DELETE ON `LocalVendorKeys`
FOR EACH ROW BEGIN
  IF (OLD.`Counter`= GLOBAL_GET("current_counter")) THEN
    REPLACE INTO `LocalVendorKeysChanges` (`VendorKey`, `Vendor`, `VendorRelease`) VALUE (OLD.`VendorKey`, 0, OLD.`Vendor` );
    IF @disable_localregister IS NULL THEN
      UPDATE `LocalVendorRegister` SET `ReleaseDateTime`=NOW() WHERE `Vendor`=OLD.`Vendor` AND `ReleaseDateTime`<='1970-01-01 00:00:00';
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalWMInserted` AFTER INSERT ON `LocalWorkingModes`
FOR EACH ROW BEGIN
  IF(NEW.`WorkingMode`=(SELECT `ParamValue` FROM `LocalWorkingModes` WHERE `ParamName`="working-mode" AND `WorkingMode`="")) THEN
    SET @trx := (SELECT trx_new("BUTTON_UPDATE", "CORE"));
    SET @ret := (SELECT trx_set_param(@trx, "WORKINGMODE", NEW.`WorkingMode`));
    SET @ret := (SELECT trx_set_param(@trx, "PARAMNAME", CONCAT("WORKINGMODES_", NEW.`ParamName`)));
    SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", NEW.`ParamValue`));
    SET @ret := (SELECT trx_send(@trx));
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalWMUpdated` AFTER UPDATE ON `LocalWorkingModes`
FOR EACH ROW BEGIN
  IF(NEW.`WorkingMode`=(SELECT `ParamValue` FROM `LocalWorkingModes` WHERE `ParamName`="working-mode" AND `WorkingMode`="")) THEN
    IF(OLD.`ParamValue`!=NEW.`ParamValue`) THEN
      SET @trx := (SELECT trx_new("BUTTON_UPDATE", "CORE"));
      SET @ret := (SELECT trx_set_param(@trx, "WORKINGMODE", NEW.`WorkingMode`));
      SET @ret := (SELECT trx_set_param(@trx, "PARAMNAME", CONCAT("WORKINGMODES_", NEW.`ParamName`)));
      SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", NEW.`ParamValue`));
      SET @ret := (SELECT trx_send(@trx));
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LocalWMDeleted` AFTER DELETE ON `LocalWorkingModes`
FOR EACH ROW BEGIN
  IF(OLD.`WorkingMode`=(SELECT `ParamValue` FROM `LocalWorkingModes` WHERE `ParamName`="working-mode" AND `WorkingMode`="")) THEN
    SET @trx := (SELECT trx_new("BUTTON_UPDATE", "CORE"));
    SET @ret := (SELECT trx_set_param(@trx, "WORKINGMODE", OLD.`WorkingMode`));
    SET @ret := (SELECT trx_set_param(@trx, "PARAMNAME", CONCAT("WORKINGMODES_", OLD.`ParamName`)));
    SET @ret := (SELECT trx_set_param(@trx, "PARAMVALUE", ""));
    SET @ret := (SELECT trx_send(@trx));
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LTicketsInsertB` BEFORE INSERT ON `LTickets`
FOR EACH ROW BEGIN

  SET @HTStatus:=(SELECT Status FROM `HTickets` WHERE `HTickets`.`Id`=NEW.`IdHTicket`);

  IF(NEW.`NetStat`='N') THEN

    IF(@HTStatus='v') THEN
      SET NEW.`Weight`=-NEW.`Weight`;
      SET NEW.`Amount`=-NEW.`Amount`;
    END IF;

    IF(@HTStatus IN ('O','v')) THEN
     IF(NEW.`lineType`=1) THEN
        SET NEW.`LineDateTime`=NOW();
        IF ((SELECT IFNULL(`ParamValue`,0) FROM `CfgSystem` WHERE `ParamKey`='loyalty-items-extra-points')!=0) THEN
          SET NEW.`Points`=IFNULL((SELECT
            IF(`ItemsExtraPoints`.`FromQuantity`,

              IF(`ItemsExtraPoints`.`Quantity`,

                IF(`ItemsExtraPoints`.`Proportional`,

                  IF(NEW.`Weight`>=`ItemsExtraPoints`.`FromQuantity`,(((NEW.`Weight`-`ItemsExtraPoints`.`FromQuantity`)/`ItemsExtraPoints`.`Quantity`) +1)*`ItemsExtraPoints`.`Points`, 0),

                    IF(NEW.`Weight`>=`ItemsExtraPoints`.`FromQuantity`,(((NEW.`Weight`-`ItemsExtraPoints`.`FromQuantity`)/`ItemsExtraPoints`.`Quantity`) DIV 1 +1)*`ItemsExtraPoints`.`Points`, 0)),

                IF(NEW.`Weight`>=`ItemsExtraPoints`.`FromQuantity`,`ItemsExtraPoints`.`Points`,0)),

              IF(`ItemsExtraPoints`.`Quantity`,

                IF(`ItemsExtraPoints`.`Proportional`,

                  (NEW.`Weight`/`ItemsExtraPoints`.`Quantity`)*`ItemsExtraPoints`.`Points`,

                    IF(NEW.`Weight`>=`ItemsExtraPoints`.`Quantity`,(((NEW.`Weight`-`ItemsExtraPoints`.`Quantity`)/`ItemsExtraPoints`.`Quantity`) DIV 1 +1)*`ItemsExtraPoints`.`Points`, 0)),

                `ItemsExtraPoints`.`Points`))
          FROM `ItemsExtraPoints` WHERE `ItemsExtraPoints`.`Code`=NEW.`Item`), 0);
        END IF;
      END IF;

    ELSE
      UPDATE `PCScaleErrorTag` SET x=1;
    END IF;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LTicketsInserted` AFTER INSERT ON `LTickets`
FOR EACH ROW BEGIN

  IF(NEW.`NetStat`='N') THEN


    IF(@HTStatus IN ('O','v')) THEN
      SET @wgt = IF(NEW.`SaleForm`=1,NEW.`Weight`,0);
      SET @units = IF(NEW.`SaleForm`=0,NEW.`Weight`,0);
      CASE(NEW.`lineType`)

        WHEN 0 THEN
          UPDATE `HTickets` SET `NumLines`=`NumLines`+1, `CanceledLines`=`CanceledLines`+1, `CanceledAmount`=`CanceledAmount`+NEW.`Amount`,
            `DatTim`=NOW(), `SectionItem`=NEW.`Section` WHERE `HTickets`.`Id`=NEW.`IdHTicket`;

        WHEN 1 THEN
          UPDATE `HTickets` SET `NumLines`=`NumLines`+1, `AddedLines`=`AddedLines`+1, `GrossAmount`=`GrossAmount`+NEW.`Amount`,
            `NegativeLines`=`NegativeLines`+IF(NEW.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`+IF(NEW.`Price`<0,-NEW.`Amount`,0),
            `TotalWeight`=`TotalWeight`+IF(NEW.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`+IF(NEW.`Price`<0,0,@units),
            `HTickets`.`PointsExtra`=`HTickets`.`PointsExtra`+IF(NEW.`Price`>0,NEW.`Points`,0),
            `DatTim`=NOW(), `SectionItem`=NEW.`Section` WHERE `HTickets`.`Id`=NEW.`IdHTicket`;
          SET @norder = '';
          SELECT `HCustomerOrders`.`Number`,`HCustomerOrders`.`Section` INTO @norder, @secorder FROM `HCustomerOrders`
            WHERE `HCustomerOrders`.`IdHTicket`=NEW.`IdHTicket` AND ((`HCustomerOrders`.`Status`>1) AND (`HCustomerOrders`.`Status`!=3));
          IF(@norder!='') THEN
            INSERT INTO `LCustomerOrders` (`OrderNumber`, `Section`, `Item`, `ItemFormat`, `Price`,`Status`,`Weight`,`Units`,`Amount`,`DatTim`)
              VALUES (@norder, @secorder, NEW.`Item`, NEW.`ItemFormat`, NEW.`Price`, 3, @wgt, @units, NEW.`Amount`,NOW())
              ON DUPLICATE KEY UPDATE `LCustomerOrders`.`Weight`=`LCustomerOrders`.`Weight`+@wgt, `LCustomerOrders`.`Units`=`LCustomerOrders`.`Units`+@units,
              `LCustomerOrders`.`Amount`=`LCustomerOrders`.`Amount`+VALUES(`Amount`),`LCustomerOrders`.`DatTim`=NOW(),
              `LCustomerOrders`.`ReplacedBy`=IF(@wgt=0 AND @units=0, 0, `LCustomerOrders`.`ReplacedBy`),
              `LCustomerOrders`.`Status`=IF((@wgt=0 AND @units=0 AND `LCustomerOrders`.`Status`=0), 5, ((CAST(Status AS UNSIGNED) & CAST(b'00000010' AS UNSIGNED)) | CAST(b'00000001' AS UNSIGNED)));
          END IF;

        WHEN 3 THEN
          IF(NEW.`SaleForm`=0) THEN
            UPDATE `HTickets` SET `TotalWeight`=`TotalWeight`+@wgt, `TotalUnits`=`TotalUnits`+@units, `PointsChanged`=`PointsChanged`+NEW.`Price`, `DatTim`=NOW()
              WHERE `HTickets`.`Id`=NEW.`IdHTicket`;
          END IF;

        ELSE BEGIN END;
      END CASE;
    END IF;
  END IF;

  CASE(NEW.`lineType`)
    WHEN 1 THEN

      UPDATE `Stock` SET
        `Stock`.`Weight`=(`Stock`.`Weight`-(IF(NEW.`Saleform`=1,IF(NEW.`Price`<0,-NEW.`Weight`,NEW.`Weight`),0))),
        `Stock`.`Units`=(`Stock`.`Units`-(IF(NEW.`Saleform`=0,IF(NEW.`Price`<0,-NEW.`Weight`,NEW.`Weight`),0)))
      WHERE `Stock`.`Code` = NEW.`Item`;
    WHEN 3 THEN

      IF(NEW.`SaleForm`=0) THEN
        UPDATE `Stock` SET `Stock`.`Units`=(`Stock`.`Units`-NEW.`Weight`) WHERE `Stock`.`Code` = NEW.`Item`;
      END IF;

    ELSE BEGIN END;
  END CASE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `LTicketsUpdated` AFTER UPDATE ON `LTickets`
FOR EACH ROW BEGIN
  IF((NEW.`Amount`!=OLD.`Amount`) OR (NEW.`VATCode`!=OLD.`VATCode`) OR (NEW.`VATPercent`!=OLD.`VATPercent`)
    OR (NEW.`SaleForm`!=OLD.`SaleForm`) OR (NEW.`Weight`!=OLD.`Weight`) OR (NEW.`Price`!=OLD.`Price`) OR (NEW.`lineDiscount`!=OLD.`lineDiscount`)
    OR ((NEW.`lineType`!=OLD.`lineType`) AND (NEW.`IdHTicket`!=OLD.`IdHTicket`))) THEN
    CALL `manipulate_protected_field`;
  END IF;

  IF((NEW.`lineType`!=OLD.`lineType`) AND (NEW.`IdHTicket`=OLD.`IdHTicket`)) THEN
    SET @wgt = IF(OLD.`SaleForm`=1,OLD.`Weight`,0);
    SET @units = IF(OLD.`SaleForm`=0,OLD.`Weight`,0);
    SET @stck = ' ';
    SET @norder = 0;
    SELECT `Status`, `OrderNumber`INTO @stck,@norder FROM `HTickets` AS ht WHERE ht.`Id`=OLD.`IdHTicket`;
    IF(@stck='O') THEN
      CASE(NEW.`lineType`)

        WHEN 0 THEN
          IF(OLD.`lineType`=1) THEN
            UPDATE `HTickets` AS ht SET `AddedLines`=`AddedLines`-1, `GrossAmount`=`GrossAmount`-OLD.`Amount`,
              `NegativeLines`=`NegativeLines`-IF(OLD.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`-IF(OLD.`Price`<0,-OLD.`Amount`,0),
              `CanceledLines`=`CanceledLines`+1, `CanceledAmount` = `CanceledAmount`+OLD.`Amount`,
              `TotalWeight`=`TotalWeight`-IF(OLD.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`-IF(NEW.`Price`<0,0,@units),
              ht.`PointsExtra`=ht.`PointsExtra`-IF(OLD.`Price`>0,OLD.`Points`,0), `DatTim`=NOW()
            WHERE ht.`Id`=OLD.`IdHTicket`;
            IF(@norder!=0) THEN 
              UPDATE `LCustomerOrders` SET `LCustomerOrders`.`Weight`=`LCustomerOrders`.`Weight`-@wgt, `LCustomerOrders`.`Units`=`LCustomerOrders`.`Units`-@units,
                `LCustomerOrders`.`Amount`=`LCustomerOrders`.`Amount`-OLD.`Amount`,`LCustomerOrders`.`DatTim`=NOW(),
                `LCustomerOrders`.`ReplacedBy`=IF(`LCustomerOrders`.`Weight`!=0 OR `LCustomerOrders`.`Units`!=0, 0, `LCustomerOrders`.`ReplacedBy`),
                `LCustomerOrders`.`Status`=IF((`LCustomerOrders`.`Weight`=0 AND `LCustomerOrders`.`Units`=0), CASE `LCustomerOrders`.`Status` WHEN 1 THEN 0 WHEN 3 THEN 2 ELSE `LCustomerOrders`.`Status` END, `LCustomerOrders`.`Status`)
              WHERE `LCustomerOrders`.`OrderNumber`=@norder AND `LCustomerOrders`.`Item`=OLD.`Item` AND `LCustomerOrders`.`ItemFormat`=OLD.`ItemFormat`;
           END IF;

            UPDATE `Stock` SET
              `Stock`.`Weight`=(`Stock`.`Weight`-(IF(NEW.`Saleform`=1,IF(NEW.`Price`<0,NEW.`Weight`,-NEW.`Weight`),0))),
              `Stock`.`Units`=(`Stock`.`Units`-(IF(NEW.`Saleform`=0,IF(NEW.`Price`<0,NEW.`Weight`,-NEW.`Weight`),0)))
            WHERE `Stock`.`Code` = NEW.`Item`;
          END IF;

        WHEN 1 THEN
          IF(OLD.`lineType`=0) THEN
            UPDATE `HTickets` AS ht SET `AddedLines`=`AddedLines`+1, `GrossAmount`=`GrossAmount`+OLD.`Amount`,
              `NegativeLines`=`NegativeLines`+IF(OLD.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`+IF(OLD.`Price`<0,-OLD.`Amount`,0),
              `CanceledLines`=`CanceledLines`-1, `CanceledAmount` = `CanceledAmount`-OLD.`Amount`,
              `TotalWeight`=`TotalWeight`+IF(OLD.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`+IF(NEW.`Price`<0,0,@units),
              ht.`PointsExtra`=ht.`PointsExtra`+IF(OLD.`Price`>0,OLD.`Points`,0), `DatTim`=NOW()
            WHERE ht.`Id`=OLD.`IdHTicket`;
            IF(@norder!=0) THEN 
              UPDATE `LCustomerOrders` SET `LCustomerOrders`.`Weight`=`LCustomerOrders`.`Weight`+@wgt, `LCustomerOrders`.`Units`=`LCustomerOrders`.`Units`+@units,
               `LCustomerOrders`.`Amount`=`LCustomerOrders`.`Amount`+OLD.`Amount`,`LCustomerOrders`.`DatTim`=NOW(),
                `LCustomerOrders`.`Status`=IF(`LCustomerOrders`.`Status`=0, 1, `LCustomerOrders`.`Status`)
              WHERE `LCustomerOrders`.`OrderNumber`=@norder AND `LCustomerOrders`.`Item`=OLD.`Item` AND `LCustomerOrders`.`ItemFormat`=OLD.`ItemFormat`;
            END IF;

            UPDATE `Stock` SET
              `Stock`.`Weight`=(`Stock`.`Weight`-(IF(NEW.`Saleform`=1,IF(NEW.`Price`<0,-NEW.`Weight`,NEW.`Weight`),0))),
              `Stock`.`Units`=(`Stock`.`Units`-(IF(NEW.`Saleform`=0,IF(NEW.`Price`<0,-NEW.`Weight`,NEW.`Weight`),0)))
            WHERE `Stock`.`Code` = NEW.`Item`;
          END IF;

        WHEN 2 THEN
          IF((NEW.`SaleForm`=0) AND (OLD.`lineType`=3)) THEN
            UPDATE `HTickets` AS ht SET `TotalWeight`=`TotalWeight`-@wgt, `TotalUnits`=`TotalUnits`-@units, `PointsChanged`=`PointsChanged`-OLD.`Price`, `DatTim`=NOW() WHERE ht.`Id`=OLD.`IdHTicket`;

            UPDATE `Stock` SET `Stock`.`Units`=(`Stock`.`Units`+NEW.`Weight`) WHERE `Stock`.`Code` = NEW.`Item`;
          END IF;

        WHEN 3 THEN
          IF((NEW.`SaleForm`=0) AND (OLD.`lineType`=2)) THEN
            UPDATE `HTickets` AS ht SET `TotalWeight`=`TotalWeight`+@wgt, `TotalUnits`=`TotalUnits`+@units, `PointsChanged`=`PointsChanged`+OLD.`Price`, `DatTim`=NOW() WHERE ht.`Id`=OLD.`IdHTicket`;

            UPDATE `Stock` SET `Stock`.`Units`=(`Stock`.`Units`-NEW.`Weight`) WHERE `Stock`.`Code` = NEW.`Item`;
          END IF;

        ELSE BEGIN END;
      END CASE;
    END IF; 


  ELSEIF((NEW.`lineType`=OLD.`lineType`) AND (NEW.`IdHTicket`!=OLD.`IdHTicket`)) THEN
    SET @wgt = IF(NEW.`SaleForm`=1,NEW.`Weight`,0);
    SET @units = IF(NEW.`SaleForm`=0,NEW.`Weight`,0);
    SET @src_stck = ' ';
    SET @src_norder = 0;
    SET @dst_stck = ' ';
    SET @dst_norder = 0;
    SELECT `Status`, `OrderNumber`INTO @src_stck,@src_norder FROM `HTickets` AS ht WHERE ht.`Id`=OLD.`IdHTicket`;
    SELECT `Status`, `OrderNumber`INTO @dst_stck,@dst_norder FROM `HTickets` AS ht WHERE ht.`Id`=NEW.`IdHTicket`;

    IF ((@src_stck='O' OR @src_stck='P') AND (@dst_stck='O')) THEN
      CASE(NEW.`lineType`)

        WHEN 0 THEN
          UPDATE `HTickets` AS ht SET `NumLines`=`NumLines`+1, `CanceledLines`=`CanceledLines`+1, `CanceledAmount`=`CanceledAmount`+NEW.`Amount` WHERE ht.`Id`=NEW.`IdHTicket`;
          UPDATE `HTickets` AS ht SET `NumLines`=`NumLines`-1, `CanceledLines`=`CanceledLines`-1, `CanceledAmount`=`CanceledAmount`-NEW.`Amount` WHERE ht.`Id`=OLD.`IdHTicket`;

        WHEN 1 THEN
          UPDATE `HTickets` AS ht SET `NumLines`=`NumLines`+1, `AddedLines`=`AddedLines`+1, `GrossAmount`=`GrossAmount`+NEW.`Amount`,
            `NegativeLines`=`NegativeLines`+IF(NEW.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`+IF(NEW.`Price`<0,-NEW.`Amount`,0),
            `TotalWeight`=`TotalWeight`+IF(NEW.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`+IF(NEW.`Price`<0,0,@units)
             WHERE ht.`Id`=NEW.`IdHTicket`;
          UPDATE `HTickets` AS ht SET `NumLines`=`NumLines`-1, `AddedLines`=`AddedLines`-1, `GrossAmount`=`GrossAmount`-NEW.`Amount`,
            `NegativeLines`=`NegativeLines`-IF(NEW.`Price`<0,1,0), `NegativeAmount` = `NegativeAmount`-IF(NEW.`Price`<0,-NEW.`Amount`,0),
            `TotalWeight`=`TotalWeight`-IF(NEW.`Price`<0,0,@wgt), `TotalUnits`=`TotalUnits`-IF(NEW.`Price`<0,0,@units)
             WHERE ht.`Id`=OLD.`IdHTicket`;

        WHEN 3 THEN
          IF(NEW.`SaleForm`=0) THEN
            UPDATE `HTickets` AS ht SET `TotalWeight`=`TotalWeight`+@wgt, `TotalUnits`=`TotalUnits`+@units WHERE ht.`Id`=NEW.`IdHTicket`;
            UPDATE `HTickets` AS ht SET `TotalWeight`=`TotalWeight`-@wgt, `TotalUnits`=`TotalUnits`-@units WHERE ht.`Id`=OLD.`IdHTicket`;
          END IF;

        ELSE BEGIN END;
      END CASE;
    ELSE
      CALL `manipulate_protected_field1`;
    END IF;

  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `PLUKeysInserted` AFTER INSERT ON `PLUKeys`
FOR EACH ROW BEGIN
  IF (NEW.`Section`=0 AND NEW.`Board`=GLOBAL_GET("current_mupboard")) THEN
    INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (0, NEW.`Board`, NEW.`PLUKey`, NEW.`Code`)
      ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;
  ELSEIF (NEW.`Section`=GLOBAL_GET("current_group")) THEN
    CASE GLOBAL_GET("PLUload-func")

      WHEN 0 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (NEW.`Section`, NEW.`Board`, NEW.`PLUKey`, NEW.`Code`)
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;

      WHEN 1 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Section`, `Family`, NEW.`PLUKey`, NEW.`Code` FROM `Items` WHERE `Items`.`Code`=NEW.`Code`
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;

      WHEN 2 THEN BEGIN END;




      ELSE BEGIN END;
    END CASE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `PLUKeysUpdated` AFTER UPDATE ON `PLUKeys`
FOR EACH ROW BEGIN
  SET @mygroup := GLOBAL_GET("current_group");
  SET @mupboard := GLOBAL_GET("current_mupboard");
  IF (OLD.`Section`=0 AND OLD.`Board`=@mupboard) THEN
      INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (0, @mupboard, OLD.`PLUKey`, 0)
      ON DUPLICATE KEY UPDATE `Code`=0;
  ELSEIF (OLD.`Section`=@mygroup) THEN
    CASE GLOBAL_GET("PLUload-func")

      WHEN 0 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (OLD.`Section`, OLD.`Board`, OLD.`PLUKey`, 0)
        ON DUPLICATE KEY UPDATE `Code`=0;

      WHEN 1 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT OLD.`Section`, `Family`, OLD.`PLUKey`, 0 FROM `Items` WHERE `Items`.`Code`=OLD.`Code`
        ON DUPLICATE KEY UPDATE `Code`=0;

      WHEN 2 THEN BEGIN END;




      ELSE BEGIN END;
   END CASE;
  END IF;
  IF (NEW.`Section`=0 AND NEW.`Board`=@mupboard) THEN
    INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (0, @mupboard, NEW.`PLUKey`, NEW.`Code`)
          ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;
  ELSEIF (NEW.`Section`=@mygroup) THEN
    CASE GLOBAL_GET("PLUload-func")

      WHEN 0 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (NEW.`Section`, NEW.`Board`, NEW.`PLUKey`, NEW.`Code`)
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;

      WHEN 1 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT NEW.`Section`, `Family`, NEW.`PLUKey`, NEW.`Code` FROM `Items` WHERE `Items`.`Code`=NEW.`Code`
        ON DUPLICATE KEY UPDATE `Code`=NEW.`Code`;

      WHEN 2 THEN BEGIN END;




      ELSE BEGIN END;
    END CASE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `PLUKeysDeleted` AFTER DELETE ON `PLUKeys`
FOR EACH ROW BEGIN
  IF (OLD.`Section`=0 AND OLD.`Board`=GLOBAL_GET("current_mupboard")) THEN
    INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (0, OLD.`Board`, OLD.`PLUKey`, 0)
    ON DUPLICATE KEY UPDATE `Code`=0;
  ELSEIF (OLD.`Section`=GLOBAL_GET("current_group")) THEN
    CASE GLOBAL_GET("PLUload-func")

      WHEN 0 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) VALUES (OLD.`Section`, OLD.`Board`, OLD.`PLUKey`, 0)
        ON DUPLICATE KEY UPDATE `Code`=0;

      WHEN 1 THEN
        INSERT INTO `LocalPLUKeysChanges` (`Section`,`Board`,`PLUKey`,`Code`) SELECT OLD.`Section`, `Family`, OLD.`PLUKey`, 0 FROM `Items` WHERE `Items`.`Code`=OLD.`Code`
        ON DUPLICATE KEY UPDATE `Code`=0;

      WHEN 2 THEN BEGIN END;




      ELSE BEGIN END;
    END CASE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `PLUKeysFileInserted` AFTER INSERT ON `PLUKeysFile`
FOR EACH ROW BEGIN
  SET @loadfunc := IFNULL (GLOBAL_GET("PLUload-func"),99);
  IF (@loadfunc=5) THEN

    UPDATE `LocalStatus` SET `ResizeTouch`=TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `PLUKeysFilesUpdated` AFTER UPDATE ON `PLUKeysFile`
FOR EACH ROW BEGIN
  SET @loadfunc := IFNULL (GLOBAL_GET("PLUload-func"),99);
  IF (@loadfunc=5) THEN

    UPDATE `LocalStatus` SET `ResizeTouch`=TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `PLUKeysFileDeleted` BEFORE DELETE ON `PLUKeysFile`
FOR EACH ROW BEGIN
  SET @loadfunc := IFNULL (GLOBAL_GET("PLUload-func"),99);
  IF (@loadfunc=5) THEN

    UPDATE `LocalStatus` SET `ResizeTouch`=TRUE;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertQuickKeys` AFTER INSERT ON `QuickKeys`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckQuickKeys`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateQuickKeys` AFTER UPDATE ON `QuickKeys`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckQuickKeys`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteQuickKeys` AFTER DELETE ON `QuickKeys`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckQuickKeys`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `JoinScale` AFTER INSERT ON `Scales`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `RemoveScale`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `ChangeScale` AFTER UPDATE ON `Scales`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `RemoveScale`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `RemoveScale` AFTER DELETE ON `Scales`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `RemoveScale`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertScripts` AFTER INSERT ON `Scripts`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckScripts`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateScripts` AFTER UPDATE ON `Scripts`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckScripts`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteScripts` AFTER DELETE ON `Scripts`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckScripts`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertSection` AFTER INSERT ON `Sections`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `CheckSections`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateSection` AFTER UPDATE ON `Sections`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `CheckSections`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteSection` AFTER DELETE ON `Sections`
FOR EACH ROW BEGIN
	UPDATE `LocalStatus` SET `CheckSections`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertShortcuts` AFTER INSERT ON `Shortcuts`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckShortcuts`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateShortcuts` AFTER UPDATE ON `Shortcuts`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckShortcuts`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteShortcuts` AFTER DELETE ON `Shortcuts`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckShortcuts`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertStock` AFTER INSERT ON `Stock`
FOR EACH ROW BEGIN
  UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE `Items`.`Code`=NEW.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateStock` AFTER UPDATE ON `Stock`
FOR EACH ROW BEGIN
  UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE (`Items`.`Code`=NEW.`Code`) OR (`Items`.`Code`=OLD.`Code`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteStock` AFTER DELETE ON `Stock`
FOR EACH ROW BEGIN
  UPDATE `Items` SET `Items`.`Price`=`Items`.`Price` WHERE `Items`.`Code`=OLD.`Code`;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertCounterTareCodes` AFTER INSERT ON `TareCodes`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckTareCodes`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateCounterTareCodes` AFTER UPDATE ON `TareCodes`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckTareCodes`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteCounterTareCodes` AFTER DELETE ON `TareCodes`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckTareCodes`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertTotalDaily` AFTER INSERT ON `TotalDaily`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckTotalDaily`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateBTotalDaily` BEFORE UPDATE ON `TotalDaily`
FOR EACH ROW BEGIN
  IF((@DailyUnlock IS NULL) OR (@DailyUnlock!='451')) THEN 
    CALL `manipulate_protected_field`;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateBTotalPayTickets` BEFORE UPDATE ON `TotalPayTickets`
FOR EACH ROW BEGIN
  IF((@DailyUnlock IS NULL) OR (@DailyUnlock!='451')) THEN 
    CALL `manipulate_protected_field`;  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertTotalScaleFamilies` AFTER INSERT ON `TotalScaleFamilies`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckTotalScaleFamilies`=TRUE;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateBTotalVAT` BEFORE UPDATE ON `TotalVAT`
FOR EACH ROW BEGIN
  IF((@DailyUnlock IS NULL) OR (@DailyUnlock!='451')) THEN 
    CALL `manipulate_protected_field`;
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TrademarkInsertedB` BEFORE INSERT ON `Trademark`
FOR EACH ROW BEGIN
  SET NEW.`Id`=1;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TrademarkInserted` AFTER INSERT ON `Trademark`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("TIN_UPDATE", "CORE-DATA"));
  SET @ret := (SELECT trx_set_param(@trx, "TIN", NEW.`TIN`));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TrademarkUpdated` AFTER UPDATE ON `Trademark`
FOR EACH ROW BEGIN
  IF(OLD.`TIN`!=NEW.`TIN`) THEN
    SET @trx := (SELECT trx_new("TIN_UPDATE", "CORE-DATA"));
    SET @ret := (SELECT trx_set_param(@trx, "TIN", NEW.`TIN`));
    SET @ret := (SELECT trx_send(@trx));
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TrademarkDeleted` AFTER DELETE ON `Trademark`
FOR EACH ROW BEGIN
  SET @trx := (SELECT trx_new("TIN_UPDATE", "CORE-DATA"));
  SET @ret := (SELECT trx_set_param(@trx, "TIN", ""));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `bTurnInsert` BEFORE INSERT ON `Turn`
FOR EACH ROW BEGIN
  SET NEW.`LastResetDate`=NOW();
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TurnInserted` AFTER INSERT ON `Turn`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckTurn` = TRUE;
  SET @trx := (SELECT trx_new("TURN_RELOAD", "NETWORK"));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TurnUpdated` AFTER UPDATE ON `Turn`
FOR EACH ROW BEGIN
  IF ((NEW.`Enabled`!=OLD.`Enabled`) OR (NEW.`Status`!=OLD.`Status`)) THEN
    UPDATE `LocalStatus` SET `CheckTurn` = TRUE;
  END IF;
  IF ((NEW.`Enabled`!=OLD.`Enabled`) OR (NEW.`IP`!=OLD.`IP`) OR (NEW.`URL`!=OLD.`URL`) OR (NEW.`User`!=OLD.`User`) OR (NEW.`Password`!=OLD.`Password`) OR (NEW.`Name`!=OLD.`Name`) OR (NEW.`ShopId`!=OLD.`ShopId`)) THEN
    SET @trx := (SELECT trx_new("TURN_RELOAD", "NETWORK"));
    SET @ret := (SELECT trx_send(@trx));
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TurnDeleted` AFTER DELETE ON `Turn`
FOR EACH ROW BEGIN
  UPDATE `LocalStatus` SET `CheckTurn` = TRUE;
  SET @trx := (SELECT trx_new("TURN_RELOAD", "NETWORK"));
  SET @ret := (SELECT trx_send(@trx));
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `bTurnsInsert` BEFORE INSERT ON `Turns`
FOR EACH ROW BEGIN
  SET NEW.`ServeDatetime`=NOW();
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TurnsInsert` AFTER INSERT ON `Turns`
FOR EACH ROW BEGIN
  UPDATE `Counters` SET `TurnsPending`=(SELECT COUNT(`Turns`.`Id`) FROM `Turns` WHERE (`Turns`.`Counter`=NEW.`Counter`) AND DATE(`Turns`.`ServeDatetime`)=CURDATE() AND (`Turns`.`Status`=0))
    WHERE (`Counters`.`Code`=NEW.`Counter`) OR (`Counters`.`MyGroup`=NEW.`Counter`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TurnsUpdate` AFTER UPDATE ON `Turns`
FOR EACH ROW BEGIN
  UPDATE `Counters` SET `TurnsPending`=(SELECT COUNT(`Turns`.`Id`) FROM `Turns` WHERE (`Turns`.`Counter`=NEW.`Counter`) AND DATE(`Turns`.`ServeDatetime`)=CURDATE() AND (`Turns`.`Status`=0))
    WHERE (`Counters`.`Code`=NEW.`Counter`) OR (`Counters`.`MyGroup`=NEW.`Counter`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `TurnsDelete` AFTER DELETE ON `Turns`
FOR EACH ROW BEGIN
  UPDATE `Counters` SET `TurnsPending`=0 WHERE (`Code`=OLD.`Counter`) OR (`Counters`.`MyGroup`=OLD.`Counter`);
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertVendorKey` AFTER INSERT ON `VendorKeys`
FOR EACH ROW BEGIN
  SET @disable_localregister = 1;
  REPLACE INTO `LocalVendorKeys` (`Counter`, `VendorKey`, `Vendor`) VALUES( NEW.`Counter`, NEW.`VendorKey`, NEW.`Vendor`);
  IF @disable_netregister IS NULL THEN
    INSERT INTO `VendorRegister` (`Vendor`,`RegisterDateTime`) VALUES (NEW.`Vendor`,NOW());
  END IF;
  SET @disable_localregister = NULL;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteVendorKey` AFTER DELETE ON `VendorKeys`
FOR EACH ROW BEGIN
  DELETE FROM `LocalVendorKeys` WHERE `Vendor`=OLD.`Vendor`;
  UPDATE `VendorRegister` SET `ReleaseDateTime`=NOW() WHERE `Vendor`=OLD.`Vendor` AND `ReleaseDateTime`<='1970-01-01 00:00:00';
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `InsertVendor` AFTER INSERT ON `Vendors`
FOR EACH ROW BEGIN
  IF (SELECT `Counter` FROM `VendorKeys` WHERE `VendorKeys`.`Vendor`=NEW.`Code`AND `VendorKeys`.`Counter`=GLOBAL_GET("current_counter")) IS NOT NULL THEN
	REPLACE INTO `LocalVendorChanges` VALUES (NEW.`Code`*10, NEW.`Code`,'0');
  END IF;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `UpdateVendor` AFTER UPDATE ON `Vendors`
FOR EACH ROW BEGIN
  IF (OLD.`Code`!=NEW.`Code`) THEN
      REPLACE INTO `LocalVendorChanges` VALUES ((OLD.`Code`*10)+1, OLD.`Code`,'1');
  END IF;
  REPLACE INTO `LocalVendorChanges` VALUES (NEW.`Code`*10, NEW.`Code`,'0');
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`pcscale`@`%`*/ /*!50003 TRIGGER `DeleteVendor` AFTER DELETE ON `Vendors`
FOR EACH ROW BEGIN
  IF (SELECT `Counter` FROM `VendorKeys` WHERE `VendorKeys`.`Vendor`=OLD.`Code`AND `VendorKeys`.`Counter`=GLOBAL_GET("current_counter")) IS NOT NULL THEN
    REPLACE INTO `LocalVendorChanges` VALUES ((OLD.`Code`*10)+1, OLD.`Code`,'1');
  END IF;
END */;;
DELIMITER ;

--
-- Dumping routines for database 'pcscale'
--
/*!50003 DROP FUNCTION IF EXISTS `gs1_checkdigit` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `gs1_checkdigit`(base VARCHAR(17)) RETURNS char(1) CHARSET utf8
    DETERMINISTIC
BEGIN
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    DECLARE odds INTEGER DEFAULT 0;     
    DECLARE evens INTEGER DEFAULT 0;    
    DECLARE total INTEGER DEFAULT 0;    
    DECLARE len INTEGER;                
    DECLARE pos INTEGER DEFAULT 0;      
    DECLARE digit INTEGER;              
    DECLARE cd INTEGER;                 
    
    
    SET len = LENGTH(base);
    mainloop: LOOP
        
        
        SET digit = CAST(SUBSTRING(base, len-pos, 1) AS SIGNED INTEGER);
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        IF (pos % 2 = 0)
        THEN
            SET evens = evens + digit;
        ELSE
            SET odds = odds + digit;
        END IF;
        
        
        SET pos = pos + 1;
        IF (pos < LEN)
        THEN
            ITERATE mainloop;
        END IF;
        LEAVE mainloop;
    END LOOP mainloop;
    
    
    SET total = odds + (3 * evens);
    SET cd = total % 10;
    IF (cd <> 0)
    THEN
        SET cd = 10 - cd;
    END IF;
    
    RETURN (CAST(cd AS CHAR));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `pcs_net` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `pcs_net`(gross DECIMAL(10,2), discount DECIMAL(4,2), points DECIMAL(10,2)) RETURNS decimal(10,2)
    DETERMINISTIC
BEGIN
  DECLARE net DECIMAL(10,2);

  SET @amount_round := IFNULL(GLOBAL_GET("amount_round"), 0);
  SET @frac_digits := IFNULL(GLOBAL_GET("frac_digits"), 2);
  SET net=gross - ROUND((gross*discount)/100, @frac_digits) - points;
  IF(@amount_round=5) THEN
    SET net=(ROUND(net/5, @frac_digits) * 5);
  END IF;

  RETURN net;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `pcs_total_to_pay` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` FUNCTION `pcs_total_to_pay`(id_ticket INTEGER, src_db TINYTEXT) RETURNS decimal(10,2)
    DETERMINISTIC
BEGIN
  DECLARE total DECIMAL(10,2);
  DECLARE without_taxes BOOLEAN DEFAULT FALSE;	
  SET without_taxes = (SELECT (IFNULL((SELECT `ParamValue` FROM `CfgSystem` WHERE `ParamKey`='prices-without-taxes'), 0)=1));
  IF(without_taxes=0) THEN
    IF(src_db='HTickets') THEN
      SET total = (SELECT `NetAmount` FROM `HTickets` WHERE `Id`=id_ticket);
    ELSE  
      SET total = (SELECT `NetAmount` FROM `LocalHTickets` WHERE `Id`=id_ticket);
    END IF;

  ELSE
    IF(src_db='HTickets') THEN
      SET total = (SELECT SUM(V_VAT.Amount) + SUM(CAST(((V_VAT.Amount*Percentage)/100) AS DECIMAL(10,2))) FROM
        (SELECT lt.`VATPercent`+'0' AS Percentage, CAST((SUM(lt.`Amount`)*(ht.`NetAmount`/ht.`GrossAmount`)) AS DECIMAL(10,2)) AS Amount
         FROM `HTickets` AS ht
         LEFT JOIN `LTickets` AS lt ON ht.`Id`=lt.`IdHTicket`
         WHERE ht.`Id`=id_ticket AND `lineType`=1 GROUP BY lt.`VATCode`) AS V_VAT);
    ELSE  
      SET total = (SELECT SUM(V_VAT.Amount) + SUM(CAST(((V_VAT.Amount*Percentage)/100) AS DECIMAL(10,2))) FROM
        (SELECT lt.`VATPercent`+'0' AS Percentage, CAST((SUM(lt.`Amount`)*(ht.`NetAmount`/ht.`GrossAmount`)) AS DECIMAL(10,2)) AS Amount
         FROM `LocalHTickets` AS ht
         LEFT JOIN `LocalLTickets` AS lt ON ht.`Id`=lt.`IdHTicket`
         WHERE ht.`Id`=id_ticket AND `lineType`=1 GROUP BY lt.`VATCode`) AS V_VAT);
    END IF;
  END IF;

  RETURN total;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DataloggerFiscalChange` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `DataloggerFiscalChange`(OldName VARCHAR(32), NewName VARCHAR(32), OldEnabled BOOLEAN, NewEnabled BOOLEAN )
BEGIN
  DECLARE msg VARCHAR(255) DEFAULT '';
  IF ((NewName!=OldName) OR (NewEnabled!=OldEnabled)) THEN
    SELECT (SELECT COUNT(*) FROM information_schema.global_status WHERE variable_name='SLAVE_RUNNING' AND VARIABLE_VALUE='ON'), (SELECT COUNT(*) FROM information_schema.processlist WHERE INFO='SELECT trx_get()') INTO @_slave_,@_app_running_;
    IF (@_slave_ = 0) THEN
      IF (NewName = OldName) THEN
        SET msg := CONCAT('Fiscal module ', NewName, IF(NewEnabled, ' enabled', ' disabled'));
      ELSEIF (NewName = '') THEN
        SET msg := CONCAT('Fiscal module ', OldName, ' dropped.');
      ELSEIF (OldName = '') THEN
        SET msg := CONCAT('Fiscal module ', NewName, ' raised. ',IF(NewEnabled, 'Enabled', 'Disabled'));
      ELSE
        SET msg := CONCAT('Fiscal module ', OldName, ' changed to ', NewName, IF(NewEnabled, '. Enabled', '. Disabled'));
      END IF;
    END IF;
    IF (@_app_running_ = 0) THEN
      INSERT INTO `LocalDataLogger` SET Type=134, DatTim=NOW(), Message=msg;
    ELSE
      SET @trx := (SELECT trx_new("FISCAL_RELOAD", "NETWORK"));
      SET @ret := (SELECT trx_set_param(@trx, "LOG", msg));
      SET @ret := (SELECT trx_send(@trx));
    END IF;
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `dbTrigger` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `dbTrigger`(IN `tbname` VARCHAR (40), `function` VARCHAR (10), `masterkey` VARCHAR (40))
BEGIN
    SET @trx := (SELECT trx_new("DBTRIGGER", "CORE"));
    SET @ret := (SELECT trx_set_param(@trx, "TABLE", `tbname`));
    SET @ret := (SELECT trx_set_param(@trx, "FUNCTION", `function`));
    SET @ret := (SELECT trx_set_param(@trx, "KEY", `masterkey`));
    SET @ret := (SELECT trx_send(@trx));
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `LocalTreeBoardFromPLUKeysFile` */;
DELIMITER ;;
CREATE DEFINER=`pcscale`@`%` PROCEDURE `LocalTreeBoardFromPLUKeysFile`()
BEGIN


  DELETE FROM `LocalTreeBoard`;
  SET @rownumber:=100000;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`,`Source3`,`Source4`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2`, puk.`Source3`, puk.`Source4` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`!=0 AND puk.`Source5`!=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`,`Source3`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2`, puk.`Source3` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`!=0 AND puk.`Source5`=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`,`Source2`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1`, puk.`Source2` AS kl FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`!=0  AND puk.`Source4`=0 AND puk.`Source5`=0) AS VT;

  INSERT INTO `LocalTreeBoard` (`Board`,`Source1`)
	SELECT @rownumber:=(@rownumber+1), VT.* FROM
    (SELECT DISTINCT puk.`Source1` FROM `PLUKeysFile` AS puk
    LEFT JOIN `Items` USING (`PLU`)
    WHERE (`Items`.`Code` IS NOT NULL AND `Items`.`OnKey`=TRUE) AND puk.`PLU`!=0 AND puk.`Source2`!=0 AND puk.`Source3`=0  AND puk.`Source4`=0 AND puk.`Source5`=0) AS VT;

  SET @rownumber:=0;
  UPDATE `LocalTreeBoard` SET Board=(@rownumber:=@rownumber+1) ORDER BY `Source1`,`Source2`,`Source3`,`Source4`,`Source5`;

 UPDATE `LocalTreeBoard` AS T1 LEFT JOIN
 (SELECT `Board`,
    IF(@src1!=`Source1`, @lv1:=@lv1+1, @lv1) AS lv1,
    IF(@src1!=`Source1`, IF(`Source2`!=0, @lv2:=1, @lv2:=0), IF(@src2!=`Source2`, @lv2:=@lv2+1, @lv2)) AS lv2,
    IF(@src1!=`Source1` OR @src2!=`Source2`, IF(`Source3`!=0, @lv3:=1, @lv3:=0), IF(@src3!=`Source3`, @lv3:=@lv3+1, @lv3)) AS lv3,
    IF(@src1!=`Source1` OR @src2!=`Source2` OR @src3!=`Source3`, IF(`Source4`!=0, @lv4:=1, @lv4:=0), IF(@src4!=`Source4`, @lv4:=@lv4+1, @lv4)) AS lv4,
    IF(@src1!=`Source1` OR @src2!=`Source2` OR @src3!=`Source3` OR @src4!=`Source4`, IF(`Source5`!=0, @lv5:=1, @lv5:=0), IF(@src5!=`Source5`, @lv5:=@lv5+1, @lv5)) AS lv5,
    @src1:=`Source1`, @src2:=`Source2`, @src3:=`Source3`, @src4:=`Source4`, @src5:=`Source5`
	FROM `LocalTreeBoard`, (SELECT @src1:=0, @lv1:=0, @src2:=0, @lv2:=0, @src3:=0, @lv3:=0, @src4:=0, @lv4:=0, @src5:=0, @lv5:=0) AS TT
    ORDER BY `Board`) AS T2 ON T1.`Board`=T2.`Board`
 SET T1.`Level1`=T2.lv1, T1.`Level2`=T2.lv2, T1.`Level3`=T2.lv3, T1.`Level4`=T2.lv4, T1.`Level5`=T2.lv5;
END ;;
DELIMITER ;


