CREATE TABLE `audittrail` (
  `id` int(11) NOT NULL auto_increment,
  `datetime` datetime NOT NULL,
  `script` varchar(80) collate latin1_general_ci default NULL,
  `user` varchar(80) collate latin1_general_ci default NULL,
  `action` varchar(80) collate latin1_general_ci default NULL,
  `table` varchar(80) collate latin1_general_ci default NULL,
  `field` varchar(80) collate latin1_general_ci default NULL,
  `keyvalue` longtext collate latin1_general_ci,
  `oldvalue` longtext collate latin1_general_ci,
  `newvalue` longtext collate latin1_general_ci,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3061 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

ALTER TABLE `cias` ADD COLUMN `LABREFERENCIA` int(1);

ALTER TABLE `cias` ADD COLUMN `VENDEDOR` int(11);

ALTER TABLE `cias` DROP KEY `Nombre`;

CREATE TABLE `counters` (
  `id` int(11) NOT NULL auto_increment,
  `sociedad` varchar(50) collate latin1_general_ci default NULL,
  `cedula` varchar(20) collate latin1_general_ci default NULL,
  `direccion1` varchar(50) collate latin1_general_ci default NULL,
  `direccion2` varchar(50) collate latin1_general_ci default NULL,
  `telefonos` varchar(50) collate latin1_general_ci default NULL,
  `logofactura` varchar(50) collate latin1_general_ci default NULL,
  `logorecibo` varchar(50) collate latin1_general_ci default NULL,
  `logoreporte` varchar(50) collate latin1_general_ci default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

ALTER TABLE `datosexa` ADD COLUMN `SEMACIA` char(1);

ALTER TABLE `datosexa` ADD COLUMN `LABID` int(1);

ALTER TABLE `datosexa` ADD COLUMN `FACTURARAID` varchar(20);

ALTER TABLE `datosexa` ADD COLUMN `VALIDADA` int(1);

ALTER TABLE `datosexa` ADD COLUMN `VALIDADAUSER` char(12);

ALTER TABLE `datosexa` ADD COLUMN `FECHAVALIDADA` date;

ALTER TABLE `datosexa` ADD COLUMN `HORAVALIDADA` time;

ALTER TABLE `datosexa` ADD INDEX `Labid` (`LABID`);

ALTER TABLE `datosexa` DROP KEY `fechafinidx`;

CREATE TABLE `datosexa_totimpuesto` (
  `ID` int(11) NOT NULL auto_increment,
  `NUMEREX` int(9) default NULL,
  `IMPUESTOID` int(11) default NULL,
  `TOTALIMPUESTO` double(15,2) default NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

ALTER TABLE `direxame` MODIFY COLUMN `ordenimp` int(11) COMMENT 'Orden de impresion';

CREATE TABLE `direxame_impuesto` (
  `id` int(11) NOT NULL auto_increment,
  `codiex` char(4) collate latin1_general_ci default NULL,
  `impuestoid` int(11) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

ALTER TABLE `doctores` ADD COLUMN `VENDEDOR` int(11);

CREATE TABLE `examenes_impuestos` (
  `id` int(11) NOT NULL auto_increment,
  `examenid` int(9) default NULL,
  `codiex` char(4) collate latin1_general_ci default NULL,
  `impuestoid` int(11) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

CREATE TABLE `exportadores` (
  `id` int(11) NOT NULL auto_increment,
  `usuario` int(11) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

CREATE TABLE `factura_head` (
  `factura` int(11) NOT NULL auto_increment,
  `fecha` date default NULL,
  `tipo_factura` int(11) default NULL,
  `cliente` varchar(60) collate latin1_general_ci default NULL,
  `cedula_cliente` varchar(20) collate latin1_general_ci default NULL,
  `paciente` varchar(60) collate latin1_general_ci default NULL,
  `cedula_paciente` varchar(20) collate latin1_general_ci default NULL,
  `direccion` varchar(50) collate latin1_general_ci default NULL,
  `subtotal` double(15,2) default NULL,
  `descuento` double(15,2) default NULL,
  `cargo` double(15,2) default NULL,
  `total` double(15,2) default NULL,
  PRIMARY KEY  (`factura`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

CREATE TABLE `factura_line` (
  `id` int(11) NOT NULL auto_increment,
  `factura` int(11) default NULL,
  `codigo` varchar(4) collate latin1_general_ci default NULL,
  `prueba` varchar(30) collate latin1_general_ci default NULL,
  `orden` int(11) default NULL,
  `paciente` varchar(60) collate latin1_general_ci default NULL,
  `cedula` varchar(20) collate latin1_general_ci default NULL,
  `total` double(15,2) default NULL,
  `pagado` double(15,2) default NULL,
  `saldo` double(15,2) default NULL,
  `notas` varchar(255) collate latin1_general_ci default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

CREATE TABLE `factura_orden` (
  `id` int(11) NOT NULL auto_increment,
  `counterid` int(11) default NULL,
  `facturanum` int(11) default NULL,
  `numerex` int(11) default NULL,
  `fechafac` date default NULL,
  PRIMARY KEY  (`id`),
  KEY `numerex` (`numerex`),
  KEY `counterfac` (`counterid`,`facturanum`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

CREATE TABLE `impuestos` (
  `ID` int(11) NOT NULL auto_increment,
  `DESCRIPCION` varchar(30) collate latin1_general_ci default NULL,
  `FIJOPOR` char(1) collate latin1_general_ci default NULL,
  `AUTOINCLUIR` int(1) default NULL,
  `MONTO` double(15,2) default NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

ALTER TABLE `laboratorios` ADD COLUMN `conterid` int(11);

CREATE TABLE `laboratorios_ip` (
  `DIRIP` varchar(15) collate latin1_general_ci NOT NULL,
  `labid` int(11) NOT NULL,
  PRIMARY KEY  (`DIRIP`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

ALTER TABLE `metaexas` MODIFY COLUMN `PRECIO` double(15,2) DEFAULT '0.00';

CREATE TABLE `recibo_machote` (
  `id` int(11) NOT NULL default '0',
  `pagonum` int(9) default NULL,
  `usuarioid` int(9) default NULL,
  `fecha` date default NULL,
  `time` time default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

ALTER TABLE `usuarios` ADD COLUMN `PUEDEVALIDAR` int(1);

ALTER TABLE `usuarios` ADD COLUMN `PUEDEEXPORTAR` int(1);

CREATE TABLE `validadores` (
  `id` int(11) NOT NULL auto_increment,
  `usuario` int(9) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

