DROP DATABASE BLANKDB ;
CREATE DATABASE BLANKDB;
USE BLANKDB;

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES tis620 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

CREATE TABLE `adjcode` (
  `ADJCODE` char(2) NOT NULL default '',
  `ADJDESC` varchar(50) default NULL,
  `GLID` varchar(15) default NULL,
  PRIMARY KEY  (`ADJCODE`),
  KEY `GLID` (`GLID`)
) TYPE=MyISAM;

CREATE TABLE `adjhead` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `DPTID` varchar(10) default NULL,
  `SALEID` varchar(10) default NULL,
  `FLAG` varchar(20) default NULL,
  `JOBNO` varchar(25) default NULL,
  `XREMARK` varchar(100) default NULL,
  `REFNO` varchar(20) default NULL,
  `ADJCODE` char(2) default NULL,
  `LOCID` varchar(10) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `apcard` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `DUEDATE` datetime default NULL,
  `ACCID` varchar(15) default NULL,
  `TAXNO` varchar(30) default NULL,
  `TAXTYPE` varchar(20) default NULL,
  `DELITYPE` varchar(10) default NULL,
  `AREA` varchar(10) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VAT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `AMOUNT_B` decimal(13,3) default '0.000',
  `DISCD` varchar(10) default NULL,
  `DISCAMT` decimal(13,3) default '0.000',
  `AFTDISC` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `AMOUNT_D` decimal(13,3) default '0.000',
  `ADVAMT` decimal(13,3) default '0.000',
  `RECAMT` decimal(13,3) default '0.000',
  `LOCID` varchar(10) default NULL,
  `CUS_PO` varchar(15) default NULL,
  `SETBILL` char(1) default NULL,
  `VATTYPE` varchar(15) default NULL,
  `TERM` int(11) default NULL,
  `XNOTE` varchar(60) default NULL,
  `AFTADV` decimal(13,3) default '0.000',
  `VATADD` char(1) default NULL,
  `IVNO` varchar(20) default NULL,
  `SALEAMT` decimal(13,3) default '0.000',
  `GLID` varchar(15) default NULL,
  `NBAL` decimal(13,3) default '0.000',
  `BILLDOC` varchar(15) default 'X',
  `RECBEG` decimal(13,3) default '0.000',
  `VOID` int(11) default '0',
  `TRTYPE` char(3) default NULL,
  `REPBAL` decimal(13,3) default '0.000',
  `CASHPAY` decimal(13,3) default '0.000',
  `TAXPAID` decimal(13,3) default '0.000',
  `LINE` int(11) NOT NULL default '0',
  `DEBTAMT` decimal(13,3) default '0.000',
  `BALLINE` decimal(13,3) default '0.000',
  `OTHDESC` mediumtext,
  `VATPERIOD` varchar(7) default NULL,
  `CHKPAY` decimal(13,3) default '0.000',
  `AMTDESC` varchar(60) default NULL,
  `VATEXP` char(1) default NULL,
  `SALETYPE` varchar(15) default NULL,
  `REFNO` varchar(20) default NULL,
  `DATEINV` date default NULL,
  `DISCTYPE` varchar(30) default NULL,
  `INVREF` decimal(13,3) default '0.000',
  `VATEDIT` tinyint(3) unsigned default '0',
  `PAYNOW` decimal(13,3) default '0.000',
  `NEWFORMAT` int(11) default '0',
  `ORDPONO` varchar(15) default NULL,
  `XREMARK` text,
  `APCONTLINE` int(11) default '0',
  `COSTADJ` int(11) default '0',
  PRIMARY KEY  (`DOCNO`,`LINE`),
  KEY `DOCNO` (`DOCNO`),
  KEY `Index2` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `apcont` (
  `ACCID` varchar(15) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `CONTACT` varchar(50) default NULL,
  `ADD1` varchar(60) default NULL,
  `ADD2` varchar(60) default NULL,
  PRIMARY KEY  (`ACCID`,`LINE`),
  KEY `ACCID` (`ACCID`)
) TYPE=MyISAM ROW_FORMAT=DYNAMIC;

CREATE TABLE `apgroup` (
  `APGID` varchar(10) NOT NULL default '',
  `APGDESC` varchar(70) default NULL,
  PRIMARY KEY  (`APGID`)
) TYPE=MyISAM;

CREATE TABLE `apinvpr` (
  `accid` varchar(20) NOT NULL default '',
  `id` varchar(30) NOT NULL default '',
  `price` decimal(14,4) default '0.0000',
  `discl` varchar(10) default NULL,
  PRIMARY KEY  (`accid`,`id`)
) TYPE=MyISAM;

CREATE TABLE `apmst` (
  `ACCID` varchar(15) NOT NULL default '',
  `GACCID` varchar(10) default NULL,
  `GLID` varchar(15) default NULL,
  `XCOMP` varchar(120) default NULL,
  `XNAME` varchar(50) default NULL,
  `ADD_1` varchar(70) default NULL,
  `ADD_2` varchar(70) default NULL,
  `TEL` varchar(30) default NULL,
  `FAX` varchar(20) default NULL,
  `SHIPTO_1` varchar(70) default NULL,
  `SHIPTO_2` varchar(70) default NULL,
  `SALEID` varchar(10) default NULL,
  `AREA` char(2) default NULL,
  `DELITYPE` char(2) default NULL,
  `TERM` int(11) default NULL,
  `GRADE` varchar(5) default NULL,
  `XLIMIT` decimal(13,2) default '0.00',
  `BILLCOND` varchar(50) default NULL,
  `CHKCOND` varchar(50) default NULL,
  `NBAL` decimal(13,2) default '0.00',
  `XREMARK` varchar(100) default NULL,
  `DISC` varchar(10) default NULL,
  `TAXNO` varchar(20) default NULL,
  `XEMAIL` varchar(50) default NULL,
  `APBANK` varchar(50) default NULL,
  `APBANKACC` varchar(20) default NULL,
  `XSTATUS` varchar(30) default 'Y - Active',
  `TAXSITETYPE` varchar(20) default '01',
  `TAXSITE` varchar(50) default 'สำนักงานใหญ่',
  PRIMARY KEY  (`ACCID`),
  KEY `APACC` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `apmst_copy` (
  `ACCID` varchar(15) NOT NULL default '',
  `GACCID` varchar(10) default NULL,
  `GLID` varchar(15) default NULL,
  `XCOMP` varchar(70) default NULL,
  `XNAME` varchar(50) default NULL,
  `ADD_1` varchar(70) default NULL,
  `ADD_2` varchar(70) default NULL,
  `TEL` varchar(30) default NULL,
  `FAX` varchar(20) default NULL,
  `SHIPTO_1` varchar(70) default NULL,
  `SHIPTO_2` varchar(70) default NULL,
  `SALEID` varchar(10) default NULL,
  `AREA` char(2) default NULL,
  `DELITYPE` char(2) default NULL,
  `TERM` int(11) default NULL,
  `GRADE` varchar(5) default NULL,
  `XLIMIT` decimal(13,2) default '0.00',
  `BILLCOND` varchar(50) default NULL,
  `CHKCOND` varchar(50) default NULL,
  `NBAL` decimal(13,2) default '0.00',
  `XREMARK` varchar(70) default NULL,
  `DISC` varchar(10) default NULL,
  `TAXNO` varchar(20) default NULL,
  `XEMAIL` varchar(50) default NULL,
  PRIMARY KEY  (`ACCID`),
  KEY `APACC` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `appayhd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ACCID` varchar(15) default NULL,
  `RECAMT` decimal(13,3) default '0.000',
  `CASHAMT` decimal(13,3) default '0.000',
  `CHKAMT` decimal(13,3) default '0.000',
  `TAXPAID` decimal(13,3) default '0.000',
  `DISC` decimal(13,3) default '0.000',
  `DISCDR` decimal(13,3) default '0.000',
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VATPERIOD` varchar(7) default NULL,
  `VATTYPE` char(2) default NULL,
  `VATAMT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `XNOTE` varchar(40) default NULL,
  `DEBTAMT` decimal(13,3) default '0.000',
  `TAXNO` varchar(15) default NULL,
  `AMTDESC` varchar(20) default NULL,
  `XREMARK` varchar(100) default NULL,
  `AMOUNT` decimal(13,2) default '0.00',
  `DISCD` decimal(13,3) default '0.000',
  `OTHERS` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  `BILLDETAIL` varchar(50) default NULL,
  `TRANAMT` decimal(13,3) default '0.000',
  `PAYTYPEDESC` varchar(50) default NULL,
  PRIMARY KEY  (`DOCNO`),
  KEY `DOCNO` (`DOCNO`,`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `aptrtail` (
  `docno` varchar(20) NOT NULL default '',
  `line` tinyint(3) unsigned NOT NULL default '0',
  `accid` varchar(15) default NULL,
  `glid` varchar(20) default NULL,
  `amount_l` decimal(13,2) default '0.00',
  `TAXTYPE` varchar(20) default NULL,
  `DATEINV` date default NULL,
  `VAT` decimal(13,2) default '0.00',
  `XREMARK` varchar(100) default NULL,
  `JOB` varchar(10) default NULL,
  `DPTID` varchar(10) default NULL,
  `TAXNO` varchar(20) default NULL,
  `AMOUNT_B` decimal(13,2) default '0.00',
  `VATAMT` decimal(13,2) default '0.00',
  `INVAMT` decimal(13,2) default '0.00',
  `VOID` tinyint(3) unsigned default '0',
  `NEWFORMAT` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`docno`,`line`)
) TYPE=MyISAM;

CREATE TABLE `arcard` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `DUEDATE` datetime default NULL,
  `ACCID` varchar(15) default NULL,
  `SALEID` varchar(10) default NULL,
  `TAXTYPE` varchar(20) default NULL,
  `DELITYPE` varchar(10) default NULL,
  `AREA` varchar(10) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VAT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `AMOUNT_B` decimal(13,3) default '0.000',
  `DISCD` varchar(10) default NULL,
  `DISCAMT` decimal(13,3) default '0.000',
  `AFTDISC` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `AMOUNT_D` decimal(13,3) default '0.000',
  `ADVAMT` decimal(13,3) default '0.000',
  `RECAMT` decimal(13,3) default '0.000',
  `LOCID` varchar(10) default NULL,
  `CUS_PO` varchar(50) default NULL,
  `SETBILL` char(1) default NULL,
  `VATTYPE` varchar(15) default NULL,
  `TERM` int(11) default NULL,
  `XNOTE` varchar(60) default NULL,
  `AFTADV` decimal(13,3) default '0.000',
  `VATADD` char(1) default NULL,
  `IVNO` varchar(20) default NULL,
  `SALEAMT` decimal(13,3) default '0.000',
  `GLID` varchar(15) default NULL,
  `NBAL` decimal(13,3) default '0.000',
  `BILLDOC` varchar(15) default 'X',
  `RECBEG` decimal(13,3) default '0.000',
  `VOID` int(11) default '0',
  `TRTYPE` char(3) default NULL,
  `REPBAL` decimal(13,3) default '0.000',
  `CASHPAY` decimal(13,3) default '0.000',
  `TAXPAID` decimal(13,3) default '0.000',
  `LINE` int(11) NOT NULL default '0',
  `DEBTAMT` decimal(13,3) default '0.000',
  `BALLINE` decimal(13,3) default '0.000',
  `OTHDESC` mediumtext,
  `VATPERIOD` varchar(7) default NULL,
  `CHKPAY` decimal(13,3) default '0.000',
  `AMTDESC` varchar(60) default NULL,
  `INVREF` decimal(13,2) default '0.00',
  `DISCTYPE` varchar(30) default NULL,
  `RECIMD` decimal(13,2) default '0.00',
  `SALETYPE` varchar(15) default NULL,
  `XREMARK` text,
  `REFNO` varchar(20) default NULL,
  `DATEINV` date default NULL,
  `XBUYER` varchar(20) default NULL,
  `DATEDELIVERY` date default NULL,
  `VATEDIT` tinyint(3) unsigned default '0',
  `PAYNOW` decimal(13,3) default '0.000',
  `ORDPONO` varchar(20) default NULL,
  `ARCONTLINE` int(11) default '0',
  `XCASHIN` decimal(13,3) default '0.000',
  `XCHANGE` decimal(13,3) default '0.000',
  `FROMPOS` int(11) default '0',
  `NOVATAMT` decimal(13,3) default '0.000',
  `PRNCOUNT` int(11) default '0',
  PRIMARY KEY  (`DOCNO`,`LINE`),
  KEY `ACCID` (`ACCID`),
  KEY `DOCNO` (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `arcont` (
  `ACCID` varchar(15) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `CONTACT` varchar(50) default NULL,
  `ADD1` varchar(60) default NULL,
  `ADD2` varchar(60) default NULL,
  PRIMARY KEY  (`ACCID`,`LINE`),
  KEY `ACCID` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `area` (
  `AID` varchar(10) NOT NULL default '',
  `ADESC` varchar(70) default NULL,
  PRIMARY KEY  (`AID`)
) TYPE=MyISAM;

CREATE TABLE `argroup` (
  `ARGID` varchar(10) NOT NULL default '',
  `ARGDESC` varchar(70) default NULL,
  PRIMARY KEY  (`ARGID`)
) TYPE=MyISAM;

CREATE TABLE `arinvpr` (
  `accid` varchar(20) NOT NULL default '',
  `id` varchar(30) NOT NULL default '',
  `price` decimal(14,4) default '0.0000',
  `discl` varchar(10) default NULL,
  PRIMARY KEY  (`accid`,`id`)
) TYPE=MyISAM;

CREATE TABLE `armappic` (
  `ID` varchar(30) NOT NULL default '',
  `LINE` int(11) NOT NULL default '1',
  `XPIC` longblob,
  PRIMARY KEY  (`ID`)
) TYPE=MyISAM;

CREATE TABLE `armst` (
  `ACCID` varchar(15) NOT NULL default '',
  `GACCID` varchar(10) default NULL,
  `GLID` varchar(15) default NULL,
  `XCOMP` varchar(120) default NULL,
  `XNAME` varchar(50) default NULL,
  `ADD_1` varchar(70) default NULL,
  `ADD_2` varchar(70) default NULL,
  `TEL` varchar(30) default NULL,
  `FAX` varchar(20) default NULL,
  `SHIPTO_1` varchar(70) default NULL,
  `SHIPTO_2` varchar(70) default NULL,
  `SALEID` varchar(10) default NULL,
  `AREA` varchar(10) default NULL,
  `DELITYPE` varchar(10) default NULL,
  `TERM` int(11) default NULL,
  `GRADE` varchar(5) default NULL,
  `XLIMIT` decimal(13,2) default '0.00',
  `BILLCOND` varchar(50) default NULL,
  `CHKCOND` varchar(50) default NULL,
  `NBAL` decimal(13,2) default '0.00',
  `XREMARK` varchar(100) default NULL,
  `DISC` varchar(10) default NULL,
  `ROUTE` varchar(10) default NULL,
  `ZIP` varchar(10) default NULL,
  `SEVEN` varchar(10) default NULL,
  `DATESEVEN` varchar(5) default NULL,
  `XEMAIL` varchar(50) default NULL,
  `XSTATUS` varchar(30) default 'Y - Active',
  `TAXNO` varchar(20) default NULL,
  `TAXSITETYPE` varchar(20) default '01',
  `TAXSITE` varchar(50) default 'สำนักงานใหญ่',
  PRIMARY KEY  (`ACCID`),
  KEY `ACCID` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `armst_copy` (
  `ACCID` varchar(15) NOT NULL default '',
  `GACCID` varchar(10) default NULL,
  `GLID` varchar(15) default NULL,
  `XCOMP` varchar(70) default NULL,
  `XNAME` varchar(50) default NULL,
  `ADD_1` varchar(70) default NULL,
  `ADD_2` varchar(70) default NULL,
  `TEL` varchar(30) default NULL,
  `FAX` varchar(20) default NULL,
  `SHIPTO_1` varchar(70) default NULL,
  `SHIPTO_2` varchar(70) default NULL,
  `SALEID` varchar(10) default NULL,
  `AREA` varchar(10) default NULL,
  `DELITYPE` varchar(10) default NULL,
  `TERM` int(11) default NULL,
  `GRADE` varchar(5) default NULL,
  `XLIMIT` decimal(13,2) default '0.00',
  `BILLCOND` varchar(50) default NULL,
  `CHKCOND` varchar(50) default NULL,
  `NBAL` decimal(13,2) default '0.00',
  `XREMARK` varchar(70) default NULL,
  `DISC` varchar(10) default NULL,
  `ROUTE` varchar(10) default NULL,
  `ZIP` varchar(10) default NULL,
  `SEVEN` varchar(10) default NULL,
  `DATESEVEN` varchar(5) default NULL,
  `XEMAIL` varchar(50) default NULL,
  PRIMARY KEY  (`ACCID`),
  KEY `ACCID` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `aroepic` (
  `ID` varchar(30) NOT NULL default '',
  `LINE` int(11) NOT NULL default '1',
  `XPIC` longblob,
  PRIMARY KEY  (`ID`)
) TYPE=MyISAM;

CREATE TABLE `arpayhd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ACCID` varchar(15) default NULL,
  `RECAMT` decimal(13,3) default '0.000',
  `CASHAMT` decimal(13,3) default '0.000',
  `CHKAMT` decimal(13,3) default '0.000',
  `TAXPAID` decimal(13,3) default '0.000',
  `DISC` decimal(13,3) default '0.000',
  `DISCDR` decimal(13,3) default '0.000',
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VATPERIOD` varchar(7) default NULL,
  `VATTYPE` char(2) default NULL,
  `VATAMT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `XNOTE` varchar(40) default NULL,
  `DEBTAMT` decimal(13,3) default '0.000',
  `AMTDESC` varchar(50) default NULL,
  `XREMARK` varchar(100) default NULL,
  `AMOUNT` decimal(13,2) default '0.00',
  `DISCD` decimal(13,3) default '0.000',
  `OTHERS` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  `XDATECHK` varchar(20) default NULL,
  `XCHKNO` varchar(20) default NULL,
  `YDATECHK` date default NULL,
  `BILLDETAIL` varchar(50) default NULL,
  `TRANAMT` decimal(13,2) default '0.00',
  `XCASHIN` decimal(13,3) default '0.000',
  `XCHANGE` decimal(13,3) default '0.000',
  `PAYTYPEDESC` varchar(50) default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `artrtail` (
  `docno` varchar(20) NOT NULL default '',
  `line` tinyint(3) unsigned NOT NULL default '0',
  `accid` varchar(15) default NULL,
  `glid` varchar(20) default NULL,
  `amount_l` decimal(13,2) default '0.00',
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`docno`,`line`)
) TYPE=MyISAM;

CREATE TABLE `bank` (
  `BANKID` varchar(5) NOT NULL default '',
  `BANKNAME` varchar(40) default NULL,
  `BRANCH` varchar(20) default NULL,
  `BANKACC` varchar(13) default NULL,
  `GLID` varchar(15) default NULL,
  `BEGAMT` decimal(13,3) default '0.000',
  PRIMARY KEY  (`BANKID`)
) TYPE=MyISAM;

CREATE TABLE `billaphd` (
  `BDOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` date default NULL,
  `ACCID` varchar(15) default NULL,
  `XREMARK` varchar(100) default NULL,
  `AMOUNT_D` decimal(15,2) default '0.00',
  `BAHTTEXT` varchar(60) default NULL,
  `BILLDATE` date default NULL,
  `DATEREC` varchar(10) default NULL,
  `DATECHECK` varchar(10) default NULL,
  `DATERECD` date default NULL,
  `BILLDATES` varchar(10) default '\\',
  PRIMARY KEY  (`BDOCNO`),
  KEY `BDOCNO` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `billaptr` (
  `BDOCNO` varchar(20) NOT NULL default '',
  `LINE` tinyint(3) unsigned NOT NULL default '0',
  `DOCNO` varchar(20) default NULL,
  `REFNO` varchar(20) default NULL,
  `DATEDOC` datetime default NULL,
  `DUEDATE` datetime default NULL,
  `AMOUNT_L` decimal(15,2) default '0.00',
  `ACCID` varchar(15) default NULL,
  PRIMARY KEY  (`BDOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `billhd` (
  `BDOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` date default NULL,
  `ACCID` varchar(15) default NULL,
  `XREMARK` varchar(100) default NULL,
  `AMOUNT_D` decimal(15,2) default '0.00',
  `BAHTTEXT` varchar(120) default NULL,
  `BILLDATE` date default NULL,
  `DATEREC` varchar(10) default '''''',
  `DATECHECK` varchar(10) default '''''',
  `DATERECD` date default NULL,
  `BILLDATES` varchar(10) default '''''',
  `JOBNO` varchar(10) default NULL,
  `XSTATUS` varchar(20) default NULL,
  `XPOSTPONE` int(11) default '0',
  `XPROBLEM` varchar(100) default NULL,
  `DELITYPE` varchar(10) default NULL,
  PRIMARY KEY  (`BDOCNO`)
) TYPE=MyISAM;

CREATE TABLE `billtr` (
  `BDOCNO` varchar(20) NOT NULL default '',
  `LINE` tinyint(3) unsigned NOT NULL default '0',
  `DOCNO` varchar(20) default NULL,
  `REFNO` varchar(20) default NULL,
  `DATEDOC` datetime default NULL,
  `DUEDATE` datetime default NULL,
  `AMOUNT_L` decimal(15,2) default '0.00',
  `ACCID` varchar(15) default NULL,
  PRIMARY KEY  (`BDOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `bkktran` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `BANKID` varchar(5) default NULL,
  `BANKID2` varchar(5) default NULL,
  `AMOUNT_D` decimal(13,3) default '0.000',
  `XREMARK` varchar(100) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `bktr` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ARACCID` varchar(15) default NULL,
  `APACCID` varchar(15) default NULL,
  `BANKID` varchar(5) default NULL,
  `BRANCH` varchar(20) default NULL,
  `CHKNO` varchar(17) default NULL,
  `DATECHK` datetime default NULL,
  `AMT_IN` decimal(13,3) default '0.000',
  `AMT_OUT` decimal(13,3) default '0.000',
  `DOCGL` varchar(15) default NULL,
  `XDESC` varchar(60) default NULL,
  `DATEPASS` datetime default NULL,
  `DATEPAYIN` datetime default NULL,
  `BKKCHG` decimal(13,3) default '0.000',
  `BANKID2` varchar(5) default NULL,
  `GLID` varchar(15) default NULL,
  `TRTYPE` char(2) default NULL,
  `CLRCHK` int(1) default '0',
  `CHKRETU` char(1) default NULL,
  `JOBNO` varchar(25) default NULL,
  `LINE` int(11) NOT NULL default '0',
  `PAYTYPE` varchar(30) default NULL,
  `REPBAL` decimal(13,2) default '0.00',
  `XREMARK` varchar(100) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  `SALEID` varchar(10) default NULL,
  `BCID` varchar(5) default NULL,
  `BRID` varchar(5) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`),
  KEY `ARACCID` (`ARACCID`),
  KEY `APACCID` (`APACCID`)
) TYPE=MyISAM;

CREATE TABLE `bookgl` (
  `LINE` tinyint(3) unsigned NOT NULL default '0',
  `XSCRDESC` varchar(50) default NULL,
  `XFORM` varchar(50) default NULL,
  `JN` varchar(10) default NULL,
  PRIMARY KEY  (`LINE`)
) TYPE=MyISAM;

CREATE TABLE `branchmst` (
  `BRID` varchar(5) NOT NULL default '',
  `BRANCH` varchar(100) default NULL,
  PRIMARY KEY  (`BRID`)
) TYPE=MyISAM;

CREATE TABLE `brand` (
  `BID` varchar(10) NOT NULL default '',
  `BDESC` varchar(70) default NULL,
  PRIMARY KEY  (`BID`)
) TYPE=MyISAM;

CREATE TABLE `cashpay` (
  `docno` varchar(20) NOT NULL default '',
  `datedoc` date default NULL,
  `dptid` varchar(10) default NULL,
  `jobno` varchar(25) default NULL,
  `vatperiod` varchar(10) default NULL,
  `xremark` varchar(100) default NULL,
  `amount_b` decimal(13,3) default '0.000',
  `invamt` decimal(13,3) default '0.000',
  `vatamt` decimal(13,3) default '0.000',
  `amount_d` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  `accid` varchar(15) default NULL,
  `VATADD` char(1) default 'N',
  `VATEXP` char(1) default 'N',
  `TRANAMT` decimal(13,3) default '0.000',
  PRIMARY KEY  (`docno`)
) TYPE=MyISAM;

CREATE TABLE `chkretu` (
  `chkno` varchar(20) NOT NULL default '',
  `datechk` date NOT NULL default '0000-00-00',
  `dateretu` date default NULL,
  `datein` date default NULL,
  `line` int(11) NOT NULL default '0',
  `xcase` varchar(70) default NULL,
  `araccid` varchar(15) default NULL,
  `apaccid` varchar(15) default NULL,
  PRIMARY KEY  (`chkno`,`line`)
) TYPE=MyISAM;

CREATE TABLE `config` (
  `XINDEX` varchar(5) NOT NULL default '',
  `XCOMP` varchar(70) default NULL,
  `COMTAXNO` varchar(15) default NULL,
  `COMVAT` decimal(10,0) default '0',
  `TAXTYPE` char(2) default NULL,
  `AREATYPE` char(2) default NULL,
  `ACCMTH` int(11) default NULL,
  `ACCYR` int(11) default NULL,
  `ASKUNRATIO` char(1) default NULL,
  `AROLDPRICE` char(1) default NULL,
  `APOLDPRICE` char(1) default NULL,
  `LOCID` varchar(10) default NULL,
  `CASH` char(2) default NULL,
  `VATTYPE` char(2) default NULL,
  `GLTYPE` char(2) default NULL,
  `COSTTYPE` char(2) default NULL,
  `INVZERO` char(1) default NULL,
  `AROVER` char(2) default NULL,
  `GLSHOW` char(1) default NULL,
  `COMADD1` varchar(70) default NULL,
  `COMADD2` varchar(70) default NULL,
  `SWARNBACK` int(11) default NULL,
  `DATETYPE` char(2) default NULL,
  `CASHAP` char(2) default NULL,
  `SPLACCU` varchar(15) default NULL,
  `SLASTBACK` datetime default NULL,
  `SKINPATH` varchar(50) default NULL,
  `DBVERSION` varchar(10) default NULL,
  `COSTLOCID` char(2) default NULL,
  `FIXDAYINYR` int(11) default NULL,
  `F3INV` char(1) default NULL,
  `SENG` char(1) default NULL,
  `SLOCK` char(1) default NULL,
  `SLOCKDATE1` datetime default NULL,
  `SLOCKDATE2` datetime default NULL,
  `SERIAL` char(1) default NULL,
  `SHOWPIC` char(1) default NULL,
  `MULTIORD` char(1) default NULL,
  `MULTIPO` char(1) default NULL,
  `SDATESTART` date default '0000-00-00',
  `EDITPRICE` char(1) default NULL,
  `COMTYPE` varchar(20) default NULL,
  `DOCRUNOLDPAT` char(1) default 'N',
  `FONTNAME` varchar(50) default 'X',
  `FONTSIZE` tinyint(3) unsigned default '8',
  `FONTSTYLE` varchar(5) default NULL,
  `OETYPE` char(1) default 'N',
  `POTYPE` char(1) default 'N',
  `CHKGLBAL` char(1) default 'N',
  `ASKCONT` char(1) default 'N',
  `REPENG` char(1) default 'N',
  `FORMZERO` char(1) default 'N',
  `SEEKSALE` char(1) default 'N',
  `ASKBILLAR` char(1) default 'Y',
  `ASKBILLAP` char(1) default 'Y',
  `XLIMIT` int(11) default '0',
  `JOBLINE` char(1) default 'N',
  `ASKCONT2` char(1) default 'N',
  `FORMDATETHAI` char(1) default 'Y',
  `DLOCID` char(1) default 'Y',
  `TAXSITETYPE` varchar(20) default '01',
  `TAXSITE` varchar(50) default 'สำนักงานใหญ่',
  `ASKWEIGHT` char(1) default 'N',
  `EDPOSEND` char(1) default 'N',
  `EDOESEND` char(1) default 'N',
  `MULTIQUO2OE` char(1) default 'Y',
  `CALCOSTRF` char(1) default 'N',
  `CHKTAXNO_SALE` char(1) default 'N',
  `IDFORREM` varchar(20) default NULL,
  `HAVELOG` char(1) default 'N',
  `BILL_FORM_ID` char(1) default 'N',
  `BR_FORM_ID` char(1) default 'N',
  `IVPRNCOUNT` char(1) default 'N',
  `OEMATCHIV` char(1) default 'N',
  PRIMARY KEY  (`XINDEX`)
) TYPE=MyISAM;

CREATE TABLE `costadjhd` (
  `docno` varchar(15) NOT NULL default '',
  `datedoc` date default NULL,
  `rcdocno` varchar(15) default NULL,
  `xremark` varchar(50) default NULL,
  `amount_d` decimal(13,3) default '0.000',
  `dptid` varchar(10) default NULL,
  `jobno` varchar(10) default NULL,
  PRIMARY KEY  (`docno`)
) TYPE=MyISAM;

CREATE TABLE `costadjtr` (
  `docno` varchar(15) NOT NULL default '',
  `datedoc` date default NULL,
  `apdocno` varchar(15) default NULL,
  `line` int(11) NOT NULL default '0',
  `amount_l` decimal(13,3) default '0.000',
  `dateap` date default NULL,
  `accid` varchar(10) default NULL,
  PRIMARY KEY  (`docno`,`line`)
) TYPE=MyISAM;

CREATE TABLE `cusbank` (
  `BCID` varchar(5) NOT NULL default '',
  `BCNAME` varchar(100) default NULL,
  PRIMARY KEY  (`BCID`)
) TYPE=MyISAM;

CREATE TABLE `datadict1` (
  `REPNAME` varchar(200) default NULL,
  `XTITLE` varchar(200) default NULL,
  `XTABLE` varchar(200) default NULL,
  `XFIELD` varchar(200) default NULL,
  `FIELDNAME` varchar(200) default NULL,
  `FULLNAME` varchar(200) default NULL,
  `NEWFIELDNAME` varchar(200) default NULL,
  `HEADER` varchar(50) default NULL,
  `FLDTYPE` char(1) default 'C',
  `FLDSIZE` int(11) default '0',
  `FLDSORT` int(11) default '0',
  `FLDCOND` int(11) default '0',
  `FLDRELA` varchar(200) default NULL,
  `F3SEEK` varchar(10) default NULL,
  `SQLTOPBOT` varchar(200) default NULL
) TYPE=MyISAM ROW_FORMAT=DYNAMIC;

CREATE TABLE `datadictall` (
  `XFullname` varchar(20) NOT NULL default '',
  `fieldname` varchar(20) default NULL,
  `tablename` varchar(20) default NULL,
  `fldtype` varchar(20) default NULL,
  `fldsize` int(11) default NULL,
  `header` varchar(50) default NULL,
  `fldsort` int(11) default '0',
  `fldcond` int(11) default '0',
  `FLDRELA` varchar(200) default '',
  `F3SEEK` varchar(10) default NULL,
  `SQLTOPBOT` varchar(200) default NULL,
  `Eheader` varchar(50) default NULL,
  PRIMARY KEY  (`XFullname`)
) TYPE=MyISAM;

CREATE TABLE `deli` (
  `DEID` varchar(10) NOT NULL default '',
  `DEDESC` varchar(70) default NULL,
  PRIMARY KEY  (`DEID`)
) TYPE=MyISAM;

CREATE TABLE `depart` (
  `DID` varchar(10) NOT NULL default '',
  `DDESC` varchar(70) default NULL,
  PRIMARY KEY  (`DID`)
) TYPE=MyISAM;

CREATE TABLE `downiv` (
  `docno` varchar(20) NOT NULL default '',
  `line` tinyint(3) unsigned NOT NULL default '0',
  `adocno` varchar(20) default NULL,
  `refamt` decimal(13,2) default '0.00',
  `clramt` decimal(13,2) default '0.00',
  PRIMARY KEY  (`docno`,`line`)
) TYPE=MyISAM;

CREATE TABLE `downpay` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ACCID` varchar(15) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `TAXTYPE` char(2) default NULL,
  `PERIOD` int(11) default NULL,
  `CPNO` varchar(15) default NULL,
  `VAT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `AMOUNT_D` decimal(13,3) default '0.000',
  `AMOUNT_B` decimal(13,3) default '0.000',
  `XDESC` varchar(70) default NULL,
  `INVAMT` decimal(13,3) default '0.000',
  `TAXPAID` decimal(13,3) default '0.000',
  `CLRAMT` decimal(13,3) default '0.000',
  `AMOUNTCUT` decimal(13,3) default '0.000',
  `CHKAMT` decimal(13,3) default '0.000',
  `CASHAMT` decimal(13,3) default '0.000',
  `NBAL` decimal(13,3) default '0.000',
  `INVNO` varchar(15) default NULL,
  `NOCLAIM` enum('True','False') default NULL,
  `NBAL_12` decimal(13,3) default '0.000',
  `CLRAMT_12` decimal(13,3) default '0.000',
  `RECBEG` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  `VATPERIOD` varchar(7) default NULL,
  `TAXDATE` date default NULL,
  `TAXNO` varchar(15) default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `downrc` (
  `docno` varchar(20) NOT NULL default '',
  `line` tinyint(3) unsigned NOT NULL default '0',
  `adocno` varchar(20) default NULL,
  `refamt` decimal(13,2) default '0.00',
  `clramt` decimal(13,2) default '0.00',
  PRIMARY KEY  (`docno`,`line`)
) TYPE=MyISAM;

CREATE TABLE `downrec` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ACCID` varchar(15) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `SALEID` varchar(10) default NULL,
  `TAXTYPE` char(2) default NULL,
  `PERIOD` int(11) default NULL,
  `CPNO` varchar(15) default NULL,
  `VAT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `AMOUNT_D` decimal(13,3) default '0.000',
  `AMOUNT_B` decimal(13,3) default '0.000',
  `XDESC` varchar(70) default NULL,
  `INVAMT` decimal(13,3) default '0.000',
  `TAXPAID` decimal(10,3) default '0.000',
  `CLRAMT` decimal(10,3) default '0.000',
  `AMOUNTCUT` decimal(10,3) default '0.000',
  `CHKAMT` decimal(10,3) default '0.000',
  `CASHAMT` decimal(13,3) default '0.000',
  `NBAL` decimal(13,3) default '0.000',
  `NBAL_12` decimal(13,3) default '0.000',
  `CLRAMT_12` decimal(13,3) default '0.000',
  `RECBEG` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  `VATPERIOD` varchar(7) default NULL,
  `TAXDATE` date default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `exptail` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `TAXNO` varchar(15) default NULL,
  `LINE` int(11) NOT NULL default '0',
  `GLID` varchar(15) default NULL,
  `JOBNO` varchar(25) default NULL,
  `DPTID` varchar(10) default NULL,
  `AMOUNT_L` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `AMOUNT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `VATDATE` datetime default NULL,
  `VATADD` char(1) default NULL,
  `NOCLAIM` char(1) default NULL,
  `XREMARK` varchar(100) default NULL,
  `VAT` decimal(13,2) default '0.00',
  `TAXTYPE` varchar(20) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  `VATPERIOD` varchar(7) default NULL,
  `XREMARK2` varchar(100) default NULL,
  `XTAXNO` varchar(20) default NULL,
  `TAXSITETYPE` varchar(20) default '01',
  `TAXSITE` varchar(50) default 'สำนักงานใหญ่',
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `fixgroup` (
  `FIXGROUP` varchar(10) NOT NULL default '',
  `FIXGROUPDESC` varchar(50) default NULL,
  PRIMARY KEY  (`FIXGROUP`)
) TYPE=MyISAM;

CREATE TABLE `fixmst` (
  `FIXID` varchar(10) NOT NULL default '',
  `FIXDESC` varchar(45) default NULL,
  `FIXGROUP` varchar(10) default NULL,
  `CALTYPE` varchar(10) default NULL,
  `DPTID` varchar(10) default NULL,
  `FIXGL` varchar(15) default NULL,
  `DEP_EX` varchar(15) default NULL,
  `DEP_ACC` varchar(15) default NULL,
  `METHOD` varchar(10) default NULL,
  `RATE` decimal(13,3) default '0.000',
  `AGE` int(11) default NULL,
  `DATESTART` datetime default NULL,
  `LASTDATE` datetime default NULL,
  `SALEDATE` datetime default NULL,
  `COST` decimal(13,3) default '0.000',
  `YEAR_COST` decimal(13,3) default '0.000',
  `LAST_COST` decimal(13,3) default '0.000',
  `BEG_COST` decimal(13,3) default '0.000',
  `JOBNO` varchar(25) default NULL,
  `ACCDOC` varchar(15) default NULL,
  `SUPPLIER` varchar(30) default NULL,
  `SERIAL` varchar(40) default NULL,
  `MODAL` varchar(15) default NULL,
  `BRAND` varchar(20) default NULL,
  `INSNO` varchar(40) default NULL,
  `INSAGE` int(11) default NULL,
  `INSDATE` datetime default NULL,
  `INSDATE2` datetime default NULL,
  `REMARK` varchar(30) default NULL,
  `SALE` char(1) default 'N',
  `DPTID2` varchar(10) default NULL,
  PRIMARY KEY  (`FIXID`)
) TYPE=MyISAM;

CREATE TABLE `fixpic` (
  `ID` varchar(20) NOT NULL default '',
  `LINE` int(11) NOT NULL default '1',
  `XPIC` longblob,
  PRIMARY KEY  (`ID`)
) TYPE=MyISAM;

CREATE TABLE `fixtr` (
  `FIXID` varchar(10) NOT NULL default '',
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `AMOUNT` decimal(14,4) default '0.0000',
  `LINE` int(11) NOT NULL default '0',
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `genfinhd` (
  `FINID` varchar(5) NOT NULL default '',
  `FINDESC` varchar(50) default NULL,
  `FINTITLE` varchar(70) default NULL,
  `SHOWHEAD` char(1) default NULL,
  `HXDESC` varchar(50) default NULL,
  `HCOLA` varchar(15) default NULL,
  `HCOLB` varchar(15) default NULL,
  `HCOLC` varchar(15) default NULL,
  `HCOLD` varchar(15) default NULL,
  PRIMARY KEY  (`FINID`)
) TYPE=MyISAM;

CREATE TABLE `genfintail` (
  `FINID` varchar(5) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `XLINE` varchar(10) default NULL,
  `XSHOW` char(1) default 'N',
  `XTYPE` varchar(25) default NULL,
  `XDESC` varchar(70) default NULL,
  `XCOLA` varchar(30) default NULL,
  `XCOLB` varchar(30) default NULL,
  `XCOLC` varchar(30) default NULL,
  `XCOLD` varchar(30) default NULL,
  `XFLAG1` varchar(30) default NULL,
  `XFLAG2` varchar(30) default NULL,
  `XCOLAVAR` decimal(15,2) default '0.00',
  `XCOLBVAR` decimal(15,2) default '0.00',
  `XCOLCVAR` decimal(15,2) default '0.00',
  `XCOLDVAR` decimal(15,2) default '0.00',
  `DATAA` varchar(30) default NULL,
  `DATAB` varchar(30) default NULL,
  `DATAC` varchar(30) default NULL,
  `DATAD` varchar(30) default NULL,
  PRIMARY KEY  (`FINID`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `glbudget` (
  `glid` varchar(15) NOT NULL default '',
  `xmonth` int(11) NOT NULL default '0',
  `xyear` int(11) NOT NULL default '0',
  `datestart` date default NULL,
  `dateend` date default NULL,
  `budget` decimal(13,2) default '0.00',
  `lastyear` decimal(13,2) default '0.00',
  PRIMARY KEY  (`glid`,`xmonth`,`xyear`)
) TYPE=MyISAM;

CREATE TABLE `glgroup` (
  `glgroup` char(3) NOT NULL default '',
  `glgroupdesc` varchar(50) default NULL,
  `glgroupe` varchar(50) default NULL,
  PRIMARY KEY  (`glgroup`)
) TYPE=MyISAM;

CREATE TABLE `gllink` (
  `XINDEX` varchar(10) default NULL,
  `GLCASHIN` varchar(15) default NULL,
  `GLCASHOUT` varchar(15) default NULL,
  `GLBANK` varchar(15) default NULL,
  `GLDOWNREC` varchar(15) default NULL,
  `GLAR` varchar(15) default NULL,
  `GLTAX` varchar(15) default NULL,
  `GLCHKIN` varchar(15) default NULL,
  `GLINV` varchar(15) default NULL,
  `GLVATSALE` varchar(15) default NULL,
  `GLNODUE` varchar(15) default NULL,
  `GLAP` varchar(15) default NULL,
  `GLDOWNPAY` varchar(15) default NULL,
  `GLCHKOUT` varchar(15) default NULL,
  `GLTAXOUT` varchar(15) default NULL,
  `GLVATPUR` varchar(15) default NULL,
  `GLVATADD` varchar(15) default NULL,
  `GLPLYEAR` varchar(15) default NULL,
  `GLPLBAL` varchar(15) default NULL,
  `GLREC` varchar(15) default NULL,
  `GLRI` varchar(15) default NULL,
  `GLDISC` varchar(15) default NULL,
  `GLCOST` varchar(15) default NULL,
  `GLPUR` varchar(15) default NULL,
  `GLRO` varchar(15) default NULL,
  `GLFIX` varchar(15) default NULL,
  `GLDISCOUT` varchar(15) default NULL,
  `GLPAYBANK` varchar(15) default NULL,
  `GLPAYVATPUR` varchar(15) default NULL,
  `GLCARDAR` varchar(15) default NULL,
  `GLCARDAP` varchar(15) default NULL,
  `GLBANKREV` varchar(15) default NULL
) TYPE=MyISAM;

CREATE TABLE `glmst` (
  `GLID` varchar(15) NOT NULL default '',
  `GLDESC` varchar(60) default NULL,
  `GLEDESC` varchar(60) default NULL,
  `GLGROUP` varchar(30) default NULL,
  `CASHSTAT` char(2) default NULL,
  `XFLAG` char(1) default NULL,
  `NATURE` char(1) default NULL,
  `GLTYPE` varchar(50) default NULL,
  `BAL` decimal(16,2) default '0.00',
  `GLCON` varchar(15) default NULL,
  PRIMARY KEY  (`GLID`)
) TYPE=MyISAM;

CREATE TABLE `glt1` (
  `GLTID` varchar(5) NOT NULL default '',
  `GLTDESC` varchar(50) default NULL,
  `DESC1` varchar(50) default NULL,
  `DESC2` varchar(50) default NULL,
  PRIMARY KEY  (`GLTID`)
) TYPE=MyISAM;

CREATE TABLE `glt2` (
  `GLTID` varchar(5) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `GLID` varchar(15) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(10) default NULL,
  `JN` varchar(10) default NULL,
  PRIMARY KEY  (`GLTID`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `gltemplate1` (
  `XSCR` varchar(5) NOT NULL default '',
  `XSCRDESC` varchar(50) default NULL,
  PRIMARY KEY  (`XSCR`)
) TYPE=MyISAM;

CREATE TABLE `gltr` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `GLID` varchar(15) default NULL,
  `DEBIT` decimal(18,4) default '0.0000',
  `CREDIT` decimal(18,4) default '0.0000',
  `XREMARK` varchar(100) default NULL,
  `JN` char(3) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `LINE` int(11) NOT NULL default '0',
  `DEBITBAL` decimal(18,4) default '0.0000',
  `CREDITBAL` decimal(18,4) default '0.0000',
  PRIMARY KEY  (`DOCNO`,`LINE`),
  KEY `GLID` (`GLID`)
) TYPE=MyISAM;

CREATE TABLE `gltrhd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `XREMARK` mediumtext,
  `XFLINE` varchar(60) default NULL,
  `XREF` varchar(15) default NULL,
  `XREMLINE` varchar(50) default NULL,
  `XREF2` varchar(15) default NULL,
  `JOBNO` varchar(25) default NULL,
  `DPTID` varchar(10) default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `glttemplate` (
  `LINE` tinyint(3) unsigned NOT NULL default '0',
  `XDESC` varchar(60) default NULL,
  `XSCR` varchar(5) NOT NULL default '',
  `GLID` varchar(20) default NULL,
  `GLLINK` varchar(20) default NULL,
  `XDB` varchar(20) default '0',
  `XCR` varchar(20) default '0',
  `BOOKNO` varchar(5) default NULL,
  PRIMARY KEY  (`XSCR`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `htax` (
  `DOCNO` varchar(20) NOT NULL default '',
  `XLine` int(11) NOT NULL default '0',
  `DATEDOC` datetime default NULL,
  `XTYPE` varchar(10) default NULL,
  `XDESC` varchar(40) default NULL,
  `TAXBASE` decimal(13,2) default '0.00',
  `TAX` decimal(13,2) default '0.00',
  `ACCID` varchar(15) default NULL,
  `TAXRATE` decimal(13,2) default '0.00',
  `TAXLINE` int(11) default NULL,
  `HDOCNO` varchar(50) default NULL,
  `PAYTYPELINE` tinyint(3) unsigned default '0',
  `TAXRUNNO` varchar(15) default '0',
  PRIMARY KEY  (`DOCNO`,`XLine`)
) TYPE=MyISAM;

CREATE TABLE `idtype` (
  `IDTID` varchar(10) NOT NULL default '',
  `IDTDESC` varchar(70) default NULL,
  PRIMARY KEY  (`IDTID`)
) TYPE=MyISAM;

CREATE TABLE `invapprice` (
  `ID` varchar(30) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `ACCID` varchar(15) default NULL,
  `COST` decimal(13,3) default '0.000',
  `DISCL` varchar(10) default '0.000',
  `XREMARK` varchar(100) default '0.000',
  PRIMARY KEY  (`ID`,`LINE`),
  KEY `ACCID` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `invcard` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ID` varchar(30) default NULL,
  `PRICE` decimal(14,4) default '0.0000',
  `XDESC` varchar(60) default NULL,
  `QUAN` decimal(14,4) default '0.0000',
  `UNIT` varchar(10) default NULL,
  `UNRATIO` decimal(13,4) default '0.0000',
  `DISCL` varchar(20) default NULL,
  `AMOUNT_L` decimal(13,3) default '0.000',
  `XREMARK` varchar(100) default NULL,
  `LINE` int(11) NOT NULL default '0',
  `INVAMT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `LOCID` varchar(10) default NULL,
  `TRTYPE` char(2) default NULL,
  `DISCLAMT` decimal(13,3) default '0.000',
  `DISCAMT` decimal(13,3) default '0.000',
  `COST` decimal(13,6) default '0.000000',
  `COSTAMT` decimal(13,4) default '0.0000',
  `MQUAN` decimal(14,4) default '0.0000',
  `COSTBAL` decimal(13,3) default '0.000',
  `SALEID` varchar(10) default NULL,
  `DPTID` varchar(10) default NULL,
  `ACCID` varchar(15) default NULL,
  `JOBNO` varchar(25) default NULL,
  `SALEPURAMT` decimal(13,3) default '0.000',
  `SALEPURQTY` decimal(14,4) default '0.0000',
  `SUBSET` char(1) default NULL,
  `HAVESET` char(1) default NULL,
  `OLDCOST` decimal(13,4) default '0.0000',
  `REPBAL` decimal(14,4) default '0.0000',
  `TRTYPE2` char(2) default NULL,
  `OTHDESC` mediumtext,
  `GLID` varchar(20) default NULL,
  `COSTREPBAL` decimal(13,4) default '0.0000',
  `ORDLINE` int(10) unsigned default '0',
  `ORDDOC` varchar(30) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  `SUBLINE` tinyint(3) unsigned NOT NULL default '0',
  `QTYCUT` decimal(14,4) default '0.0000',
  `CUSID` varchar(20) default NULL,
  `WEIGHT` decimal(13,4) default '0.0000',
  `VOLUME` decimal(13,4) default '0.0000',
  `LINEREMARK` int(11) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`,`SUBLINE`),
  KEY `ID` (`ID`),
  KEY `DOCNO` (`DOCNO`),
  KEY `ACCID` (`ACCID`)
) TYPE=MyISAM;

CREATE TABLE `invfor` (
  `id` varchar(30) NOT NULL default '',
  `line` int(11) NOT NULL default '0',
  `idraw` varchar(20) default NULL,
  `forqty` decimal(10,4) default '0.0000',
  `unit` varchar(10) default '0',
  `stdcost` decimal(14,4) default '0.0000',
  PRIMARY KEY  (`id`,`line`)
) TYPE=MyISAM;

CREATE TABLE `invmst` (
  `ID` varchar(30) NOT NULL default '',
  `XDESC` varchar(100) default NULL,
  `XGROUP` char(2) default NULL,
  `XSGROUP` varchar(10) default NULL,
  `XBRAND` varchar(10) default NULL,
  `XIDTYPE` varchar(10) default NULL,
  `OTHDESC` mediumtext,
  `INVGLID` varchar(15) default NULL,
  `SALEGLID` varchar(15) default NULL,
  `UNIT` varchar(10) default NULL,
  `UNITSAL` varchar(10) default NULL,
  `UNITPUR` varchar(10) default NULL,
  `MINPOINT` decimal(18,4) default '0.0000',
  `MAXPOINT` decimal(18,4) default '0.0000',
  `RORDER` decimal(18,4) default '0.0000',
  `NBAL` decimal(18,4) default '0.0000',
  `BACKORDER` decimal(18,4) default '0.0000',
  `ONORDER` decimal(18,4) default '0.0000',
  `COSTBAL` decimal(18,4) default '0.0000',
  `COSTGLID` varchar(15) default NULL,
  `WORKGLID` varchar(15) default NULL,
  `SEVEN` varchar(20) default NULL,
  `FROMPRN` char(2) default 'N',
  `HAVELOT` char(1) default 'N',
  `HAVESET` char(1) default 'N',
  `LDATESALE` date default '0000-00-00',
  `LDATEPUR` date default '0000-00-00',
  `OLDPRICE` decimal(18,4) default '0.0000',
  `OLDCOST` decimal(18,4) default '0.0000',
  `FORMPRN` char(1) default 'N',
  `FORMPRNSET` char(1) default 'N',
  `FORMPRNSER` char(1) default 'N',
  `LASTUPDATE` date default NULL,
  `XDESC2` varchar(60) default NULL,
  `LOCID` varchar(10) default '00',
  `LEADTIME` int(11) default '0',
  `PROCESSCOST` decimal(18,4) default '0.0000',
  `XDESCENG` varchar(70) default NULL,
  `HAVEVAT` char(1) default 'Y',
  PRIMARY KEY  (`ID`),
  KEY `ID` (`ID`)
) TYPE=MyISAM;

CREATE TABLE `invmst_copy` (
  `ID` varchar(30) NOT NULL default '',
  `XDESC` varchar(100) default NULL,
  `XGROUP` char(2) default NULL,
  `XSGROUP` char(2) default NULL,
  `XBRAND` char(2) default NULL,
  `XIDTYPE` char(2) default NULL,
  `OTHDESC` mediumtext,
  `INVGLID` varchar(15) default NULL,
  `SALEGLID` varchar(15) default NULL,
  `UNIT` varchar(10) default NULL,
  `UNITSAL` varchar(10) default NULL,
  `UNITPUR` varchar(10) default NULL,
  `MINPOINT` decimal(18,4) default '0.0000',
  `MAXPOINT` decimal(18,4) default '0.0000',
  `RORDER` decimal(18,4) default '0.0000',
  `NBAL` decimal(18,4) default '0.0000',
  `BACKORDER` decimal(18,4) default '0.0000',
  `ONORDER` decimal(18,4) default '0.0000',
  `COSTBAL` decimal(18,4) default '0.0000',
  `COSTGLID` varchar(15) default NULL,
  `WORKGLID` varchar(15) default NULL,
  `SEVEN` varchar(20) default NULL,
  `FROMPRN` char(2) default 'N',
  `HAVELOT` char(1) default 'N',
  `HAVESET` char(1) default 'N',
  `LDATESALE` date default '0000-00-00',
  `LDATEPUR` date default '0000-00-00',
  `OLDPRICE` decimal(18,4) default '0.0000',
  `OLDCOST` decimal(18,4) default '0.0000',
  `FORMPRN` char(1) default 'N',
  `FORMPRNSET` char(1) default 'N',
  `FORMPRNSER` char(1) default 'N',
  `LASTUPDATE` date default NULL,
  PRIMARY KEY  (`ID`),
  KEY `ID` (`ID`)
) TYPE=MyISAM;

CREATE TABLE `invpic` (
  `ID` varchar(30) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `XPIC` longblob,
  PRIMARY KEY  (`ID`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `invset` (
  `ID` varchar(30) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `IDSUBSET` varchar(20) default NULL,
  `QUAN` decimal(13,2) default '0.00',
  `UNIT` varchar(15) default NULL,
  `XDESC` varchar(20) default NULL,
  PRIMARY KEY  (`ID`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `invshelf` (
  `ID` varchar(30) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `LOCID` varchar(10) default NULL,
  `SHELF` varchar(10) default NULL,
  PRIMARY KEY  (`ID`,`LINE`),
  KEY `ID_LOCID` (`ID`,`LOCID`)
) TYPE=MyISAM;

CREATE TABLE `invstdcost` (
  `LINE` int(50) unsigned NOT NULL default '0',
  `ID` varchar(30) NOT NULL default '',
  `DATEFROM` datetime default NULL,
  `DATETO` datetime default NULL,
  `COST` decimal(13,2) default '0.00',
  PRIMARY KEY  (`ID`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `isshead` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `XREMARK` varchar(100) default NULL,
  `REFNO` varchar(20) default NULL,
  `LOCID` varchar(10) default NULL,
  `ORDDOCNO` varchar(20) default NULL,
  `FID` varchar(18) default NULL,
  `FQUAN` decimal(13,6) default '0.000000',
  `FUNIT` varchar(10) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `ivgroup` (
  `IVGID` varchar(10) NOT NULL default '',
  `IVGDESC` varchar(70) default NULL,
  PRIMARY KEY  (`IVGID`)
) TYPE=MyISAM;

CREATE TABLE `jn` (
  `JN` varchar(10) NOT NULL default '',
  `JNDESC` varchar(50) default NULL,
  PRIMARY KEY  (`JN`)
) TYPE=MyISAM;

CREATE TABLE `jobmst` (
  `JOBNO` varchar(25) NOT NULL default '',
  `JDESC` varchar(70) default NULL,
  PRIMARY KEY  (`JOBNO`)
) TYPE=MyISAM;

CREATE TABLE `jobtail` (
  `jobno` varchar(25) NOT NULL default '',
  `glid` varchar(15) default NULL,
  `line` int(11) NOT NULL default '0',
  `begdb` decimal(18,4) default '0.0000',
  `begcr` decimal(18,4) default '0.0000',
  `budget` decimal(18,4) default '0.0000',
  `lastyr` decimal(18,4) default '0.0000',
  `DPTID` varchar(15) default NULL,
  `MTH1` decimal(18,4) default '0.0000',
  `MTH2` decimal(18,4) default '0.0000',
  `MTH3` decimal(18,4) default '0.0000',
  `MTH4` decimal(18,4) default '0.0000',
  `MTH5` decimal(18,4) default '0.0000',
  `MTH6` decimal(18,4) default '0.0000',
  `MTH7` decimal(18,4) default '0.0000',
  `MTH8` decimal(18,4) default '0.0000',
  `MTH9` decimal(18,4) default '0.0000',
  `MTH10` decimal(18,4) default '0.0000',
  `MTH11` decimal(18,4) default '0.0000',
  `MTH12` decimal(18,4) default '0.0000',
  PRIMARY KEY  (`jobno`,`line`),
  KEY `glid` (`glid`)
) TYPE=MyISAM;

CREATE TABLE `lblx150521143128` (
  `ID` varchar(20) default NULL,
  `BARCODE` varchar(20) default NULL,
  `XDESC` varchar(100) default NULL,
  `XDESCB` varchar(100) default '',
  `UNIT` varchar(20) default NULL,
  `PRICE1` double default '0',
  `PRICE2` double default '0',
  `PRICE3` double default '0',
  `PRICE4` double default '0',
  KEY `ID` (`ID`)
) TYPE=MyISAM;

CREATE TABLE `loca` (
  `LOCID` varchar(10) NOT NULL default '',
  `LOCDESC` varchar(70) default NULL,
  PRIMARY KEY  (`LOCID`)
) TYPE=MyISAM;

CREATE TABLE `log` (
  `XUSER` varchar(20) default NULL,
  `XFORMNAME` varchar(20) default NULL,
  `XDOC` varchar(20) default NULL,
  `XMODE` char(1) default NULL,
  `XDATETIME` timestamp(14) NOT NULL,
  KEY `XDOC` (`XDOC`)
) TYPE=MyISAM;

CREATE TABLE `ordhead` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `TERM` int(11) default NULL,
  `ACCID` varchar(15) default NULL,
  `DELITYPE` varchar(10) default NULL,
  `SENDDATE` datetime default NULL,
  `PONO` varchar(15) default NULL,
  `SALEID` varchar(10) default NULL,
  `TAXTYPE` char(2) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VAT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `DISCD` varchar(10) default NULL,
  `AMOUNT_D` decimal(13,3) default '0.000',
  `AMOUNT_B` decimal(13,3) default '0.000',
  `QUOFLG` char(1) default NULL,
  `DISCAMT` decimal(13,3) default '0.000',
  `AREA` varchar(10) default NULL,
  `AFTDISC` decimal(13,3) default '0.000',
  `CLEAR` char(1) default 'N',
  `QDOCNO` varchar(20) default NULL,
  `INVAMT` decimal(13,3) default '0.000',
  `XREMARK` mediumtext,
  `AMTDESC` varchar(60) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  `ARCONTLINE` int(11) default '0',
  `LINEREMARK` int(11) default NULL,
  PRIMARY KEY  (`DOCNO`),
  KEY `ACCID` (`ACCID`),
  KEY `XDOCNO` (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `otherid` (
  `ID` varchar(30) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `GACCID` varchar(10) default NULL,
  `OTHID` varchar(15) default NULL,
  PRIMARY KEY  (`ID`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `passhead` (
  `MPASS` varchar(10) NOT NULL default '',
  `MUSER` varchar(20) default NULL,
  `FNAME` varchar(70) default NULL,
  `LNAME` varchar(140) default NULL,
  `SALEID` varchar(70) default NULL,
  `OE` varchar(50) default 'N',
  `QT` varchar(50) default 'N',
  `IV` varchar(50) default 'N',
  `LOCKSALETR` varchar(50) default 'N'
) TYPE=MyISAM;

CREATE TABLE `passtail` (
  `MPASS` varchar(10) NOT NULL default '',
  `MLINE` int(10) NOT NULL default '0',
  `MDESC` varchar(50) default NULL,
  `MFORM` varchar(50) default NULL,
  `MINX` char(1) default NULL,
  `MADD` char(1) default NULL,
  `MEDI` char(1) default NULL,
  `MDEL` char(1) default NULL,
  `MTYPE` char(1) default NULL,
  `MPFORM` char(1) default 'Y'
) TYPE=MyISAM;

CREATE TABLE `payin` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `LINE` int(11) NOT NULL default '0',
  `CHKNO` varchar(17) default NULL,
  `DATECHK` datetime default NULL,
  `BRANCH` varchar(20) default NULL,
  `AMOUNT_L` decimal(13,3) default '0.000',
  `BKKCHG` decimal(13,3) default '0.000',
  `XDATEPASS` datetime default NULL,
  `XDOCGL` varchar(15) default NULL,
  `BKKCHK` decimal(13,3) default '0.000',
  `XDATEPAYIN` datetime default NULL,
  `XBANKID` varchar(10) default NULL,
  `PAYDOCNO` varchar(20) default NULL,
  `PAYTYPE` varchar(30) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `payinhd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `AMOUNT_D` decimal(13,3) default '0.000',
  `BANKID` varchar(5) default NULL,
  `DATEPASS` datetime default NULL,
  `REFNO` varchar(20) default NULL,
  `BKKCHK` decimal(13,3) default '0.000',
  `XREMARK` varchar(100) default NULL,
  `AMOUNT_CRD` decimal(13,3) default '0.000',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `payout` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `LINE` smallint(6) NOT NULL default '0',
  `CHKNO` varchar(17) default NULL,
  `DATECHK` datetime default NULL,
  `BANKID` varchar(5) default NULL,
  `BRANCH` varchar(20) default NULL,
  `AMOUNT_L` decimal(10,2) default '0.00',
  `MARK` char(1) default NULL,
  `CHKTYPE` varchar(10) default NULL,
  `PAYDOCNO` varchar(20) default NULL,
  `PAYTYPE` varchar(30) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `payouthd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `AMOUNT_D` decimal(13,3) default '0.000',
  `REFNO` varchar(20) default NULL,
  `XREMARK` varchar(100) default NULL,
  `DATEPASS` date default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `po` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ID` varchar(30) default NULL,
  `XDESC` varchar(60) default NULL,
  `QUAN` decimal(13,3) default '0.000',
  `PRICE` decimal(14,4) default '0.0000',
  `REC` decimal(13,3) default '0.000',
  `UNIT_SAL` varchar(10) default NULL,
  `RATIO` decimal(13,4) default '0.0000',
  `DISCL` varchar(10) default NULL,
  `AMOUNT_L` decimal(13,3) default '0.000',
  `LINE` int(11) NOT NULL default '0',
  `DISCAMT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `OTHDESC` mediumtext,
  `AMOUNT_B` decimal(13,3) default '0.000',
  `DISCDAMT` decimal(13,3) default '0.000',
  `MQUAN` decimal(13,3) default '0.000',
  `MQUANREC` decimal(13,3) default '0.000',
  `NBAL` decimal(13,3) default '0.000',
  `NBAL_12` decimal(13,3) default '0.000',
  `REC_12` decimal(13,3) default '0.000',
  `RECBEG` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  `PRNO` varchar(20) default '',
  `PRLINE` varchar(5) default '0',
  `JOBNO` varchar(25) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `pohead` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `TERM` int(11) default NULL,
  `ACCID` varchar(15) default NULL,
  `DELITYPE` char(2) default NULL,
  `SENDDATE` datetime default NULL,
  `TAXTYPE` char(2) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VAT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `DISCD` varchar(10) default NULL,
  `AMOUNT_D` decimal(13,3) default '0.000',
  `AMOUNT_B` decimal(13,3) default '0.000',
  `QDOCNO` varchar(20) default NULL,
  `QUOFLG` char(1) default NULL,
  `DISCAMT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `AREA` char(2) default NULL,
  `AFTDISC` decimal(13,3) default '0.000',
  `CLEAR` char(1) default 'N',
  `XREMARK` mediumtext,
  `AMTDESC` varchar(60) default NULL,
  `PAYTYPE` varchar(30) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  `PRNO` varchar(15) default NULL,
  `XREFER` varchar(30) default NULL,
  `SENDDATE2` varchar(60) default NULL,
  `APCONTLINE` int(11) default '0',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `pr` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ID` varchar(30) default NULL,
  `XDESC` varchar(60) default NULL,
  `QUAN` decimal(13,3) default '0.000',
  `PRICE` decimal(14,4) default '0.0000',
  `REC` decimal(13,3) default '0.000',
  `UNIT_SAL` varchar(10) default NULL,
  `RATIO` decimal(13,3) default '0.000',
  `DISCL` varchar(10) default NULL,
  `AMOUNT_L` decimal(13,3) default '0.000',
  `LINE` int(11) NOT NULL default '0',
  `DISCAMT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `OTHDESC` mediumtext,
  `AMOUNT_B` decimal(13,3) default '0.000',
  `DISCDAMT` decimal(13,3) default '0.000',
  `MQUAN` decimal(13,3) default '0.000',
  `MQUANREC` decimal(13,3) default '0.000',
  `NBAL` decimal(13,3) default '0.000',
  `NBAL_12` decimal(13,3) default '0.000',
  `REC_12` decimal(13,3) default '0.000',
  `RECBEG` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  `ACCID` varchar(15) default '',
  `XSTATUS` varchar(20) default '',
  `XQ` decimal(13,3) default '0.000',
  `DATEAUTHORIZE` date default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM ROW_FORMAT=DYNAMIC;

CREATE TABLE `prhead` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `TERM` int(11) default NULL,
  `ACCID` varchar(15) default NULL,
  `DELITYPE` char(2) default NULL,
  `SENDDATE` datetime default NULL,
  `TAXTYPE` char(2) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VAT` decimal(13,3) default '0.000',
  `VATAMT` decimal(13,3) default '0.000',
  `DISCD` varchar(10) default NULL,
  `AMOUNT_D` decimal(13,3) default '0.000',
  `AMOUNT_B` decimal(13,3) default '0.000',
  `QDOCNO` varchar(20) default NULL,
  `QUOFLG` char(1) default NULL,
  `DISCAMT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `AREA` char(2) default NULL,
  `AFTDISC` decimal(13,3) default '0.000',
  `CLEAR` char(1) default 'N',
  `XREMARK` mediumtext,
  `AMTDESC` varchar(60) default NULL,
  `PAYTYPE` varchar(30) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  `PRNO` varchar(15) default NULL,
  `XREFER` varchar(30) default NULL,
  `SENDDATE2` varchar(60) default NULL,
  `REASONID` varchar(10) default NULL,
  `XUSER` varchar(30) default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM ROW_FORMAT=DYNAMIC;

CREATE TABLE `pricechg` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `DATEEND` datetime default NULL,
  `CUSGRP` varchar(4) default NULL,
  `DISC` varchar(10) default NULL,
  `ID` varchar(30) NOT NULL default '',
  `CUSGRP2` varchar(4) default NULL,
  `PRICE` float default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `profreehd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` date default NULL,
  `XREMARK` varchar(100) default NULL,
  `ID` varchar(20) default NULL,
  `UNIT` varchar(10) default NULL,
  `QTY` decimal(13,2) default '0.00',
  `STARTDATE` date default NULL,
  `STOPDATE` date default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `profreetail` (
  `DOCNO` varchar(20) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `IDFREE` varchar(20) default NULL,
  `UNIT` varchar(10) default NULL,
  `QTYFREE` decimal(13,2) default '0.00',
  `PRICE` decimal(13,2) default '0.00',
  `RATIO` decimal(13,3) default '0.000',
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `quo` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ID` varchar(30) default NULL,
  `XDESC` varchar(60) default NULL,
  `QTY` decimal(18,4) default '0.0000',
  `PRICE` decimal(18,4) default '0.0000',
  `UNIT_SAL` varchar(10) default NULL,
  `PER_SAL` decimal(18,4) default '0.0000',
  `DISCL` varchar(15) default NULL,
  `AMOUNT_L` decimal(13,2) default '0.00',
  `LINE` int(11) NOT NULL default '0',
  `DISAMT` decimal(13,2) default '0.00',
  `INVAMT` decimal(13,2) default '0.00',
  `OTHDESC` mediumtext,
  `AMOUNT_B` decimal(13,2) default '0.00',
  `DISCDAMT` decimal(13,2) default '0.00',
  `MQUAN` decimal(13,2) default '0.00',
  `JOBNO` varchar(25) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `quofollow` (
  `docno` varchar(15) NOT NULL default '',
  `line` int(11) NOT NULL default '0',
  `datetr` date default NULL,
  `remline` varchar(60) default NULL,
  `xremark` text,
  PRIMARY KEY  (`docno`,`line`)
) TYPE=MyISAM;

CREATE TABLE `quohead` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `TERM` int(11) default NULL,
  `ACCID` varchar(15) default NULL,
  `DELITYPE` char(2) default NULL,
  `DUEN` int(11) default NULL,
  `PAIDTYPE` varchar(20) default NULL,
  `SALEID` varchar(10) default NULL,
  `TAXTYPE` char(2) default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `VAT` decimal(13,2) default '0.00',
  `VATAMT` decimal(13,2) default '0.00',
  `AMOUNT_D` decimal(13,2) default '0.00',
  `AMOUNT_B` decimal(13,2) default '0.00',
  `STATUS` char(2) default NULL,
  `QUOFLAG` char(2) default NULL,
  `DISCAMT` decimal(13,2) default '0.00',
  `INVAMT` decimal(13,2) default '0.00',
  `AREA` char(2) default NULL,
  `AFTDISC` decimal(13,2) default '0.00',
  `REFNO` varchar(20) default NULL,
  `XREMARK` mediumtext,
  `DISCD` varchar(10) default NULL,
  `AMTDESC` varchar(60) default NULL,
  `ARCONTLINE` int(11) default '0',
  `LINEREMARK` int(11) default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `reason` (
  `REASONID` varchar(10) NOT NULL default '',
  `REASON` varchar(100) default NULL,
  PRIMARY KEY  (`REASONID`)
) TYPE=MyISAM ROW_FORMAT=DYNAMIC;

CREATE TABLE `recfinhd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `XREMARK` varchar(100) default NULL,
  `REFNO` varchar(20) default NULL,
  `LOCID` varchar(10) default NULL,
  `ORDDOCNO` varchar(20) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `repuser` (
  `REPID` varchar(15) NOT NULL default '',
  `REPGROUP` varchar(20) default NULL,
  `REPNAME` varchar(50) default NULL,
  `XCR` text,
  `FRF` mediumblob,
  `XPASS` varchar(20) default NULL,
  PRIMARY KEY  (`REPID`)
) TYPE=MyISAM;

CREATE TABLE `retisshd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `DPTID` varchar(10) default NULL,
  `JOBNO` varchar(25) default NULL,
  `XREMARK` varchar(100) default NULL,
  `REFNO` varchar(20) default NULL,
  `LOCID` varchar(10) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `route` (
  `ROUTE` varchar(4) NOT NULL default '',
  `AREA1` varchar(250) default NULL,
  PRIMARY KEY  (`ROUTE`)
) TYPE=MyISAM;

CREATE TABLE `runno` (
  `MPRE` char(2) default NULL,
  `MMTH` int(11) default NULL,
  `MYR` int(11) default NULL,
  `RUNNO` int(11) default NULL
) TYPE=MyISAM;

CREATE TABLE `runnohead` (
  `PREDOC` char(2) default NULL,
  `TEMPLATE` varchar(15) default NULL,
  `XKEY` char(2) default NULL,
  `LASTDOC` varchar(15) default NULL,
  `NO` int(11) NOT NULL auto_increment,
  `MTHRESET` tinyint(4) default NULL,
  `XSCREEN` varchar(30) default NULL,
  PRIMARY KEY  (`NO`),
  KEY `PREDOC` (`PREDOC`,`XKEY`)
) TYPE=MyISAM;

CREATE TABLE `runtail` (
  `TEMPLATE` varchar(15) default NULL,
  `XYEAR` int(4) default NULL,
  `XMONTH` int(2) default NULL,
  `LASTDOC` varchar(15) default NULL,
  KEY `RUNTAIL` (`TEMPLATE`,`XYEAR`,`XMONTH`)
) TYPE=MyISAM;

CREATE TABLE `salemst` (
  `SID` varchar(10) NOT NULL default '',
  `SNAME` varchar(70) default NULL,
  `SPASS` varchar(10) default NULL,
  PRIMARY KEY  (`SID`)
) TYPE=MyISAM;

CREATE TABLE `scrform` (
  `FFORMNAME` varchar(255) default NULL,
  `FILENAME` varchar(50) NOT NULL default '',
  `FRMCONTENT` mediumtext,
  `FRMSCREEN` varchar(250) default NULL,
  `FRMCOPY` int(10) default '1',
  `COPYSTRING` varchar(50) default '',
  PRIMARY KEY  (`FILENAME`)
) TYPE=MyISAM;

CREATE TABLE `scrformpic` (
  `FILENAME` varchar(50) NOT NULL default '',
  `LINE` int(11) NOT NULL default '0',
  `XPIC` longblob,
  PRIMARY KEY  (`FILENAME`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `seven` (
  `ID` varchar(50) default NULL,
  `SEVEN` varchar(50) default NULL
) TYPE=MyISAM;

CREATE TABLE `sin` (
  `DOCNO` varchar(20) NOT NULL default '',
  `LINE` int(255) NOT NULL default '0',
  `ID` varchar(30) default NULL,
  `LOCID` varchar(10) default NULL,
  `QUANIN` decimal(13,2) default '0.00',
  `QUANOUT` decimal(13,2) default '0.00',
  `REPBAL` decimal(13,2) default '0.00',
  `SERIAL` varchar(30) default NULL,
  `DATEDOC` datetime default NULL,
  `COSTREPBAL` decimal(13,2) default '0.00',
  `COST` decimal(13,3) default '0.000',
  `BEGFLAG` char(1) default NULL,
  `REFX` varchar(15) default NULL,
  `ARACCID` varchar(15) default NULL,
  `APACCID` varchar(15) default NULL,
  `TRLINE` tinyint(3) unsigned default '0',
  `TRTYPE` char(2) default '00',
  `LASTBAL` decimal(13,2) unsigned default '0.00',
  PRIMARY KEY  (`DOCNO`,`LINE`),
  KEY `ACCID` (`ARACCID`),
  KEY `APACCID` (`APACCID`),
  KEY `ID` (`ID`),
  KEY `LOCID` (`LOCID`)
) TYPE=MyISAM;

CREATE TABLE `skin` (
  `FormName` varchar(20) NOT NULL default '',
  `FFolder` varchar(50) default NULL,
  `JpgName` varchar(20) default NULL,
  PRIMARY KEY  (`FormName`)
) TYPE=MyISAM;

CREATE TABLE `status` (
  `STATUS` varchar(5) NOT NULL default '',
  `STATUSNAME` varchar(50) default NULL,
  `LINKOE` char(1) default 'Y',
  PRIMARY KEY  (`STATUS`)
) TYPE=MyISAM;

CREATE TABLE `tranhd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `LOCIDFRM` varchar(10) default NULL,
  `LOCIDTO` varchar(10) default NULL,
  `XREMARK` varchar(100) default NULL,
  `JOBNO` varchar(25) default NULL,
  `DPTID` varchar(10) default NULL,
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `trantail` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ID` varchar(30) default NULL,
  `XDESC` varchar(60) default NULL,
  `QUAN` decimal(13,3) default '0.000',
  `UNIT` varchar(10) default NULL,
  `UNRATIO` decimal(13,3) default '0.000',
  `LINE` int(11) NOT NULL default '0',
  `LOCIDFRM` varchar(10) default NULL,
  `LOCIDTO` varchar(10) default NULL,
  `MQUAN` decimal(13,3) default '0.000',
  `COST` decimal(13,3) default '0.000',
  `VOID` tinyint(3) unsigned default '0',
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `unpr` (
  `ID` varchar(30) NOT NULL default '',
  `UNIT` varchar(10) default NULL,
  `LINE` int(11) NOT NULL default '0',
  `RATIO` decimal(18,4) default '0.0000',
  `PRICE1` decimal(18,4) default '0.0000',
  `PRICE2` decimal(18,4) default '0.0000',
  `PRICE3` decimal(18,4) default '0.0000',
  `PRICE4` decimal(18,4) default '0.0000',
  `BARCODE` varchar(20) default NULL,
  `XDESCB` varchar(100) default NULL,
  PRIMARY KEY  (`ID`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `unprx` (
  `ID` varchar(30) NOT NULL default '',
  `UNIT` varchar(10) default NULL,
  `LINE` int(11) NOT NULL default '0',
  `RATIO` decimal(18,4) default '0.0000',
  `PRICE1` decimal(18,4) default '0.0000',
  `PRICE2` decimal(18,4) default '0.0000',
  `PRICE3` decimal(18,4) default '0.0000',
  `PRICE4` decimal(18,4) default '0.0000',
  `BARCODE` varchar(20) default NULL,
  `XDESCB` varchar(100) default NULL,
  PRIMARY KEY  (`ID`,`LINE`)
) TYPE=MyISAM ROW_FORMAT=DYNAMIC;

CREATE TABLE `upayin` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `LINE` smallint(6) NOT NULL default '0',
  `CHKNO` varchar(17) default NULL,
  `DATECHK` datetime default NULL,
  `BRANCH` varchar(20) default NULL,
  `AMOUNT_L` decimal(10,3) default '0.000',
  `BKKCHK` decimal(10,3) default '0.000',
  `MARK` char(1) default NULL,
  `CHKTYPE` varchar(10) default NULL,
  `PAYDOCNO` varchar(20) default NULL,
  `PAYTYPE` varchar(30) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `upayinhd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `AMOUNT_D` decimal(10,0) default '0',
  `REFNO` varchar(20) default NULL,
  `BKKCHK` decimal(10,0) default '0',
  `XREMARK` varchar(100) default NULL,
  `BANKID` varchar(10) default NULL,
  `AMOUNT_CRD` decimal(13,3) default '0.000',
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `upayout` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `LINE` smallint(6) NOT NULL default '0',
  `CHKNO` varchar(17) default NULL,
  `DATECHK` datetime default NULL,
  `BANKID` varchar(5) default NULL,
  `BRANCH` varchar(20) default NULL,
  `AMOUNT_L` decimal(10,3) default '0.000',
  `MARK` char(1) default NULL,
  `CHKTYPE` varchar(10) default NULL,
  `PAYDOCNO` varchar(20) default NULL,
  `PAYTYPE` varchar(30) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `upayouthd` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `AMOUNT_D` decimal(10,0) default '0',
  `REFNO` varchar(20) default NULL,
  `XREMARK` varchar(100) default NULL,
  PRIMARY KEY  (`DOCNO`)
) TYPE=MyISAM;

CREATE TABLE `vatapcard` (
  `DATEDOC` datetime default NULL,
  `DOCNO` varchar(20) NOT NULL default '',
  `VATAMT` double(15,3) default NULL,
  `INVAMT` double(15,3) default NULL,
  `XCOMP` varchar(70) default NULL,
  `xtaxno` varchar(20) default NULL,
  `taxsitetype` varchar(20) default '01',
  `taxsite` varchar(50) default 'สำนักงานใหญ่',
  `ACCID` varchar(15) default NULL,
  `TAXNO` varchar(30) default NULL,
  `REFNO` varchar(20) default NULL,
  `TRTYPE` char(2) default NULL,
  `vatexp` char(1) default NULL,
  `void` int(11) default '0',
  `XINVAMT1` double(15,3) default NULL,
  `XINVAMT2` double(15,3) default NULL,
  `xdesc` varchar(70) default NULL,
  `xsite1` varchar(20) NOT NULL default '',
  `xsite2` varchar(20) NOT NULL default ''
) TYPE=MyISAM;

CREATE TABLE `vatcard` (
  `DATEDOC` datetime default NULL,
  `DOCNO` varchar(20) NOT NULL default '',
  `vatamt` double(15,3) default NULL,
  `invamt` double(15,3) default NULL,
  `XCOMP` varchar(120) default NULL,
  `ACCID` varchar(15) default NULL,
  `trtype` char(3) default NULL,
  `void` int(11) default '0',
  `xtaxno` varchar(20) default NULL,
  `taxsitetype` varchar(20) default '01',
  `taxsite` varchar(50) default 'สำนักงานใหญ่',
  `xdesc` varchar(120) default NULL,
  `xinvamt1` double(15,3) default NULL,
  `xinvamt2` double(15,3) default NULL,
  `XSITE1` varchar(20) NOT NULL default '',
  `XSITE2` varchar(20) NOT NULL default ''
) TYPE=MyISAM;

CREATE TABLE `vatgl` (
  `docno` varchar(20) NOT NULL default '',
  `taxno` varchar(20) default NULL,
  `datedoc` date default NULL,
  `mcomp` varchar(70) default NULL,
  `vatperiod` varchar(10) default NULL,
  `vatamt` decimal(13,3) default '0.000',
  `invamt` decimal(13,3) default '0.000',
  `vatadd` char(1) default 'N',
  `dptid` varchar(10) default '',
  `jobno` varchar(25) default '',
  `taxtype` varchar(20) default '',
  `vatxtype` varchar(20) default '',
  `xtaxno` varchar(20) default NULL,
  `TAXSITETYPE` varchar(20) default '01',
  `TAXSITE` varchar(50) default 'สำนักงานใหญ่',
  PRIMARY KEY  (`docno`)
) TYPE=MyISAM;

CREATE TABLE `xorder` (
  `DOCNO` varchar(20) NOT NULL default '',
  `DATEDOC` datetime default NULL,
  `ID` varchar(30) default NULL,
  `XDESC` varchar(60) default NULL,
  `QUAN` decimal(18,4) default '0.0000',
  `PRICE` decimal(14,4) default '0.0000',
  `REC` decimal(18,4) default '0.0000',
  `UNIT_SAL` varchar(10) default NULL,
  `RATIO` decimal(13,4) default '0.0000',
  `DISCL` varchar(10) default NULL,
  `AMOUNT_L` decimal(13,3) default '0.000',
  `LINE` int(11) NOT NULL default '0',
  `DISCAMT` decimal(13,3) default '0.000',
  `INVAMT` decimal(13,3) default '0.000',
  `OTHDESC` mediumtext,
  `AMOUNT_B` decimal(13,3) default '0.000',
  `DISCDAMT` decimal(13,3) default '0.000',
  `MQUAN` decimal(18,4) default '0.0000',
  `MQUANREC` decimal(18,4) default '0.0000',
  `NBAL` decimal(18,4) default '0.0000',
  `NBAL_12` decimal(18,4) default '0.0000',
  `REC_12` decimal(18,4) default '0.0000',
  `RECBEG` decimal(18,4) default '0.0000',
  `VOID` tinyint(3) unsigned default '0',
  `JOBNO` varchar(25) default NULL,
  PRIMARY KEY  (`DOCNO`,`LINE`)
) TYPE=MyISAM;

CREATE TABLE `xrec` (
  `id` varchar(30) default NULL,
  `xdesc` varchar(60) default NULL,
  `xbeg` double(16,4) default NULL,
  `xin` double(16,4) default NULL,
  `xout` double(16,4) default NULL,
  `xbal` double(4,2) NOT NULL default '0.00'
) TYPE=MyISAM;


/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

