<?php
include_once ("lib/fpdf/funci.php");
date_default_timezone_set('America/La_Paz');
$conex = conectar();
/*
//Maestro de Almacenes
$incal = "create table if not exists incal
         (incalcalm  int(6)        not null,
          incalnalm  char(30)      not null,
          incalfech  date          not null,
          incalusua  char(15)      not null,
          incalstat  smallint(1)   not null,
          unique index1 (incalcalm))";
          mysql_query($incal);

//Maestro de Materiales X Almacen - Lote y Fecha de Vencimiento
$inalm = "create table if not exists inalm
         (inalmcorr  int           auto_increment,
          inalmcalm  int(6)        not null,
          inalmcart  char(15)      not null,
          inalmcant  decimal(12,2) not null,
          inalmlote  char(12)              ,
          inalmfven  date                  ,
          inalmfech  date          not null,
          inalmusua  char(15)      not null,
          inalmstat  smallint(1)   not null,
          primary key (inalmcorr)          ,
          unique index inalm1 (inalmcalm,inalmcart,inalmlote,inalmfven),
          foreign key inalm2 (inalmcalm)
          references incal(incalcalm)
          on delete no action
          on update no action)";
          mysql_query($inalm);

//Cabecera Inventario
$incab = "create table if not exists incab
         (incabntra  int           auto_increment,
          incabrtra  int           not null,
          incabcalm  int(6)        not null,
          incabfech  date          not null,
          incabtmov  smallint(1)   not null,
          incabcmov  smallint(1)   not null,
          incabdesc  char(30)      not null,
          incabgest  int(4)        not null,
          incabusua  char(15)      not null,
          incabstat  smallint(1)   not null,
          primary key (incabntra)          ,
          index incab1 (incabgest,incabntra))";
          mysql_query($incab);

//Detalle Inventario Materiales
$indet = "create table if not exists indet
         (indetcorr  int           auto_increment,
          indetntra  int           not null,
          indetcalm  int(6)        not null,
          indetcart  char(15)      not null,
          indetcant  decimal(12,2) not null,
          primary key (indetcorr)          ,
          index indet1 (indetntra),
          index indet2 (indetcalm),
          index indet3 (indetcart))";
          mysql_query($indet);

//Usuarios x Almacen
$adalm = "create table if not exists adalm
         (adalmcorr  int           auto_increment,
          adalmusua  char(15)      not null,
          adalmcalm  int(6)        not null,
          adalmingr  smallint(1)   not null,
          adalmegre  smallint(1)   not null,
          adalmstat  smallint(1)   not null,
          primary key (adalmcorr)          ,
          unique index adalm1 (adalmusua,adalmcalm))";
          mysql_query($adalm);

//Tipo de Clientes/Proveedores (Cliente/Proveedor/Clie-Prov)
$adtip = "create table if not exists adtip
         (adtiptipo  smallint(1)   not null,
          adtipdesc  char(12)      not null,
          adtipstat  smallint(1)   not null,
          unique index adtip1 (adtiptipo))";
          mysql_query($adtip);

//Clase de Clientes/Proveedores (Natural/Juridico)
$adcla = "create table if not exists adcla
         (adclatipo  smallint(1)   not null,
          adcladesc  char(12)      not null,
          adclastat  smallint(1)   not null,
          unique index adcla1 (adclatipo))";
          mysql_query($adcla);

//Maestro de clientes y Proveedores
$adage = "create table if not exists adage
         (adagendoc  char(12)      not null,
          adagenomb  char(40)      not null,
          adagefech  date          not null,
          adagetelf  char(15)              ,
          adagedire  char(35)      not null,
          adagemail  char(20)              ,
          adagetipo  smallint(1)   not null,
          adageclas  smallint(1)   not null,
          adagedfac  char(12)              ,
          adagenfac  char(35)              ,
          adageusua  char(15)      not null,
          adagestat  smallint(1)   not null,
          unique index adage1 (adagendoc),
          foreign key adage2 (adagetipo)
          references adtip(adtiptipo)
          on delete no action
          on update no action,
          foreign key adage3 (adageclas)
          references adcla(adclatipo)
          on delete no action
          on update no action)";
          mysql_query($adage);

//Cabecera de Ventas
$vecab = "create table if not exists vecab
         (vecabntra  int           auto_increment,
          vecabcalm  int(6)        not null,
          vecabfech  date          not null,
          vecabnfac  char(10)      not null,
          vecabccli  char(12)      not null,
          vecabncli  char(40)      not null,
          vecabtven  decimal(12,2) not null,
          vecabgest  int(4)        not null,
          vecabcctl  char(15)      not null,
          vecabusua  char(15)      not null,
          vecabstat  smallint(1)   not null,
          primary key (vecabntra)  ,
          index vecab1 (vecabgest,vecabntra))";
          mysql_query($vecab);

//Detalle de Ventas
$vedet = "create table if not exists vedet
         (vedetcorr  int           auto_increment,
          vedetntra  int           not null,
          vedetcart  char(15)      not null,
          vedetcant  decimal(12,2) not null,
          vedetpven  decimal(12,5) not null,
          vedettven  decimal(12,2) not null,
          primary key (vedetcorr)          ,
          index vedet1 (vedetntra),
          index vedet2 (vedetcart))";
          mysql_query($vedet);

//Tipo Movimiento de Inventario
$intmv = "create table if not exists intmv
         (intmvtipo  smallint(1)   not null,
          intmvdesc  char(15)      not null,
          intmvstat  smallint(1)   not null,
          unique index intmv1 (intmvtipo))";
          mysql_query($intmv);

//Clase Movimiento de Inventario
$incmv = "create table if not exists incmv
         (incmvtipo  smallint(1)   not null,
          incmvclas  smallint(1)   not null,
          incmvdesc  char(15)      not null,
          incmvstat  smallint(1)   not null,
          unique index incmv1 (incmvtipo,incmvclas))";
          mysql_query($incmv);
*/
//Datos de Facturacion
$vedfa = "create table if not exists vedfa
         (vedfacorr  int           auto_increment,
          vedfanfac  decimal(12,0) not null,
          vedfanini  decimal(12,0) not null,
          vedfanfin  decimal(12,0) not null,
          vedfanaut  decimal(12,0) not null,
          vedfallav  char(35)      not null,
          vedfafech  date          not null,
          vedfastat  smallint(1)   not null,
          primary key (vedfacorr))";
          mysql_query($vedfa);
/*
//Cabecera de Compras
$cocab = "create table if not exists cocab
         (cocabntra  int           auto_increment,
          cocabcalm  int(6)        not null,
          cocabfech  date          not null,
          cocabcprv  char(12)      not null,
          cocabtcom  decimal(12,2) not null,
          cocabgest  int(4)        not null,
          cocabusua  char(15)      not null,
          cocabstat  smallint(1)   not null,
          primary key (cocabntra)          ,
          index cocab1 (cocabgest,cocabntra))";
          mysql_query($cocab);

//Detalle de Compras
$codet = "create table if not exists codet
         (codetcorr  int           auto_increment,
          codetntra  int           not null,
          codetcart  char(15)      not null,
          codetcant  decimal(12,2) not null,
          codetpcom  decimal(12,5) not null,
          codettcom  decimal(12,2) not null,
          primary key (codetcorr)          ,
          index codet1 (codetntra),
          index codet2 (codetcart))";
          mysql_query($codet);

//Unidad de Medida
$inumd = "create table if not exists inumd
         (inumdcorr  int           auto_increment,
          inumddesc  char(15)      not null,
          inumdumed  char(3)       not null,
          primary key (inumdcorr))";
          mysql_query($inumd);

//Maestro de Ubicaciones
$inubi = "create table if not exists inubi
         (inubicorr  int     auto_increment,
          inubidesc  char(35)      not null,
          inubiubic  char(15)      not null,
          primary key (inubicorr))";
          mysql_query($inubi);
*/
//Forma de Pago
$vefpg = "create table if not exists vefpg
         (vefpgcorr  smallint(1)   auto_increment,
          vefpgdesc  char(12)      not null,
          primary key (vefpgcorr))";
          mysql_query($vefpg);
/*
//Grupo
$ingrp = "create table if not exists ingrp
         (ingrpgrup  smallint(3)   not null,
          ingrpdesc  char(25)      not null,
          unique index ingrp1 (ingrpgrup))";
          mysql_query($ingrp);

//Sub Grupo
$insgp = "create table if not exists insgp
         (insgpgrup  smallint(3)   not null,
          insgpsubg  smallint(3)   not null,
          insgpdesc  char(25)      not null,
          unique index insgp1 (insgpgrup,insgpsubg))";
          mysql_query($insgp);

//Maestro de Materiales
$inart = "create table if not exists inart
         (inartcart  char(15)      not null,
          inartnart  char(25)      not null,
          inartdesc  char(40)      not null,
          inartimag  char(35)      not null,
          inartumed  char(3)       not null,
          inartubic  char(15)      not null,
          inartgrup  smallint(3)   not null,
          inartsubg  smallint(3)   not null,
          inartcant  decimal(12,2) not null,
          inartpcom  decimal(12,5) not null,
          inartpven  decimal(12,5) not null,
          inartsmax  decimal(10,2) not null,
          inartsmin  decimal(10,2) not null,
          inartlofe  smallint(1)   not null,
          inartfech  date          not null,
          inartusua  char(15)      not null,
          inartstat  smallint(1)   not null,
          unique index inart1 (inartcart))";
          mysql_query($inart);

//Lote y Fecha de Vencimiento
$inlfv = "create table if not exists inlfv
         (inlfvcorr  int     auto_increment,
          inlfvdesc  char(2)       not null,
          primary key (inlfvcorr))";
          mysql_query($inlfv);

//Maestro de Usuarios
$adusr = "create table if not exists adusr
         (adusrusua  char(15)      not null,
          adusrnomb  char(40)      not null,
          adusrmail  char(40)      not null,
          adusracom  int(6)                ,
          adusraven  int(6)                ,
          adusrpawd  int(12)       not null,
          adusrauto  smallint(1)   not null,
          adusrstat  smallint(1)   not null,
          adusrfech  date          not null,
          adusruser  char(15)      not null,
          unique index adusr1 (adusrusua))";
          mysql_query($adusr);

$fecha = date("Y-m-d");
$xuser = "insert into adusr values 
         ('admin','Administrador del Sistema','admin@outlook.com',568812,4,0,'$fecha','admin')";
mysql_query($xuser);
*/
?>
