unit uBootStrap;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uSplash, uFactuGES_App, StdCtrls;

procedure Initialize;
procedure Run;
procedure Terminate;

implementation

uses
  uDMBase, uDataModuleConexion, uDataModuleConfiguracion, uPlugins_Intf,
  uMainMenuController, uNavPaneController, uPantallaPrincipal;

procedure DoAppLoadModules;
begin
  with AppFactuGES.ModuleManager do
  begin
    LoadModule('Referencias_plugin.bpl');  
    LoadModule('FormasPago_plugin.bpl');
    LoadModule('TiposIVA_plugin.bpl');
    LoadModule('Familias_plugin.bpl');
    LoadModule('Fabricantes_plugin.bpl');    
    LoadModule('UnidadesMedida_plugin.bpl');

    LoadModule('Contactos_plugin.bpl');

    LoadModule('Almacenes_plugin.bpl');
    LoadModule('Obras_plugin.bpl');    
    LoadModule('Articulos_plugin.bpl');

    LoadModule(MODULENAME_PRESUPUESTOS_CLIENTE);
    LoadModule(MODULENAME_ALBARANES_CLIENTE);

    LoadModule('RecibosCliente_plugin.bpl');
    LoadModule(MODULENAME_FACTURAS_CLIENTE);

    LoadModule(MODULENAME_PEDIDOS_PROVEEDOR);
    LoadModule(MODULENAME_ALBARANES_PROVEEDOR);

    LoadModule(MODULENAME_RECIBOS_PROVEEDOR);
    LoadModule(MODULENAME_FACTURAS_PROVEEDOR);

    LoadModule('RemesasCliente_plugin.bpl');
    LoadModule('RemesasProveedor_plugin.bpl');

    LoadModule('Inventario_plugin.bpl');
    LoadModule('HistoricoMovimientos_plugin.bpl');

    LoadModule('GestorInformes_plugin.bpl');    
  end;
end;

procedure DoAppMainForm;
begin
  Application.CreateForm(TfPantallaPrincipal, fPantallaPrincipal);
end;

procedure Initialize;
begin

  dmConexion := TdmConexion.Create(NIL);
  dmConfiguracion := TdmConfiguracion.Create(NIL);
  dmBase := TdmBase.Create(NIL);

  AppFactuGES := TAppFactuGES.Create;
  with AppFactuGES do
  begin
    AppSplashForm := TAppSplashForm.Create;
    DoMainFormEvent := DoAppMainForm;
    DoLoadModulesEvent := DoAppLoadModules;
  end;

  NavPaneController := TNavPaneController.Create;
  MainMenuController := TMainMenuController.Create;
end;

procedure Run;
begin
  AppFactuGES.Run;
end;

procedure Terminate;
begin
  FreeANDNIL(MainMenuController);
  FreeANDNIL(NavPaneController);

  AppFactuGES := NIL;

  FreeANDNIL(dmBase);
  FreeANDNIL(dmConfiguracion);
  FreeAndNil(dmConexion);

  Application.ProcessMessages
end;

end.
