unit uPluginContactos;

interface

uses
  uModuleController, uInterfaces, uHostManager, Menus, Classes, ActnList,
  ImgList, Controls, PngImageList;

type
  IMCContactos = interface(IInterface)
    ['{6D35035D-BE4A-41F1-A599-CB4D5C359DF3}']

  end;
  
  TPluginContactos = class(TModuleController, IMCContactos)
    actPacientes: TAction;
    ExtraImages: TPngImageList;
    LargeImages: TPngImageList;
    MainMenu: TMainMenu;
    ModuleActionList: TActionList;
    SmallImages: TPngImageList;
    Ventas1: TMenuItem;
    Pacientes1: TMenuItem;
    procedure actPacientesExecute(Sender: TObject);
    procedure actPacientesUpdate(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

implementation

{$R *.dfm}

uses
  Forms, Dialogs, uGUIBase, uCustomEditor, SysUtils, uContactosController,
  uPacientesController,
  uContactosViewRegister, uBizContactos, uFactuGES_App;

function GetModule : TModuleController;
begin
  Result := TPluginContactos.Create(NIL);
end;

exports
  GetModule name GET_MODULE_FUNC;

{
******************************* TModuleContactos *******************************
}
procedure TPluginContactos.actPacientesExecute(Sender: TObject);
var
  APacientesController : IPacientesController;
  APacientes : IBizPaciente;
begin
  try
  APacientesController := TPacientesController.Create;
  APacientes := (APacientesController.BuscarTodos as IBizPaciente);
  APacientesController.VerTodos(APacientes);
  finally
    APacientes := Nil;
    APacientesController := Nil;
  end;
end;

procedure TPluginContactos.actPacientesUpdate(Sender: TObject);
begin
  (Sender as TAction).Enabled := Assigned(AppFactuGES.EmpresaActiva);
end;

constructor TPluginContactos.Create(AOwner: TComponent);
begin
  inherited;
  uContactosViewRegister.RegisterViews;
end;

destructor TPluginContactos.Destroy;
begin
  uContactosViewRegister.UnregisterViews;
  inherited;
end;

initialization
  uHostManager.RegisterModuleClass(TPluginContactos);

finalization
  uHostManager.UnRegisterModuleClass(TPluginContactos);

end.
