CREATE TABLE thym_branch (
  region tinyint(3) unsigned NOT NULL default '0',
  bname varchar(50) default NULL,
  bcode char(5) NOT NULL,
  PRIMARY KEY  (region,bcode)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO thym_branch (region, bname, bcode) VALUES (1,'ABU DHABI MALL\r','00203');
INSERT INTO thym_branch (region, bname, bcode) VALUES (1,'PHONOCARE ABU DHABI\r','00207');
INSERT INTO thym_branch (region, bname, bcode) VALUES (1,'MARINA MALL\r','00213');
INSERT INTO thym_branch (region, bname, bcode) VALUES (1,'AL WADHA\r','00230');
INSERT INTO thym_branch (region, bname, bcode) VALUES (1,'Al Raha Mall Abudhab\r','00232');
INSERT INTO thym_branch (region, bname, bcode) VALUES (1,'SPINNEYS KHALIDIYA','00300');

CREATE TABLE thym_data (
  country tinyint(3) unsigned default NULL,
  SDate char(50) NOT NULL default '',
  Serial char(50) NOT NULL default '',
  region int(2) default NULL,
  bcode char(5) default NULL,
  brand int(2) default NULL,
  SName text,
  visitno char(10) default NULL,
  app char(4) default NULL,
  exp char(4) default NULL,
  rec char(4) default NULL,
  add char(4) default NULL,
  clos char(4) default NULL,
  tot char(4) default NULL,
  mapp char(4) default NULL,
  mexp char(4) default NULL,
  mrec char(4) default NULL,
  madd char(4) default NULL,
  mclos char(4) default NULL,
  mtot char(4) default NULL,
  flname1 varchar(100) default NULL,
  mdate date default NULL,
  aapp char(4) default NULL,
  aexp char(4) default NULL,
  arec char(4) default NULL,
  aadd char(4) default NULL,
  aclos char(4) default NULL,
  atot char(4) default NULL,
  sentpdf tinyint(1) unsigned default '0',
  PRIMARY KEY  (SDate,Serial)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/13','00019',3,'00237',1,'454                 ',NULL,'010','005','035','040','010','100','007','005','035','000','005','052',NULL,'2008-10-13','070','100','100','000','050','052',0);
INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/13','00027',4,'00215',1,'205                 ',NULL,'010','005','035','040','010','100','010','005','035','025','010','085',NULL,'2008-10-13','100','100','100','062','100','085',0);
INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/13','00035',3,'01302',3,'1302                ',NULL,'010','005','035','040','010','100','007','005','015','025','005','057',NULL,'2008-10-13','070','100','042','062','050','057',0);
INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/14','03018',3,'00221',1,'185                 ',NULL,'010','005','035','040','010','100','010','005','035','005','005','060',NULL,'2008-10-14','100','100','100','012','050','060',0);
INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/14','03026',7,'00424',3,'26                  ',NULL,'010','005','035','040','010','100','010','005','015','025','005','060',NULL,'2008-10-14','100','100','042','062','050','060',0);
INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/14','03034',3,'00202',1,'185                 ',NULL,'010','005','035','040','010','100','010','005','035','005','005','060',NULL,'2008-10-14','100','100','100','012','050','060',0);
INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/14','03042',3,'00418',3,'26                  ',NULL,'010','005','035','040','010','100','007','005','035','025','005','077',NULL,'2008-10-14','070','100','100','062','050','077',0);
INSERT INTO thym_data (country, SDate, Serial, region, bcode, brand, SName, visitno, app, exp, rec, add, clos, tot, mapp, mexp, mrec, madd, mclos, mtot, flname1, mdate, aapp, aexp, arec, aadd, aclos, atot, sentpdf) VALUES (1,'2008/10/14','03050',2,'00214',1,'373                 ',NULL,'010','005','035','040','010','100','010','005','035','040','005','095',NULL,'2008-10-14','100','100','100','100','050','095',0);

CREATE TABLE thym_sel (
  flname varchar(100) NOT NULL default '',
  PRIMARY KEY  (flname)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
