2019-11-18 10:36:42 +00:00
|
|
|
unit uContratosClienteReportController;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleContratosClienteReport,
|
|
|
|
|
uClientesController, uContratosClienteController, uDetallesContratoClienteController,
|
|
|
|
|
uBizContratosCliente, uIntegerListUtils;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
IContratosClienteReportController = interface(IControllerBase)
|
|
|
|
|
['{FEF47B69-26A3-462A-AF6D-4B2073D4F9DC}']
|
2021-03-04 14:07:54 +00:00
|
|
|
procedure Preview(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
|
|
|
procedure Print(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
2019-11-18 10:36:42 +00:00
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TContratosClienteReportController = class(TControllerBase, IContratosClienteReportController)
|
|
|
|
|
private
|
|
|
|
|
FDataModule : IDataModuleContratosClienteReport;
|
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
public
|
|
|
|
|
constructor Create; override;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
2021-03-04 14:07:54 +00:00
|
|
|
procedure Preview(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
|
|
|
procedure Print(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
2019-11-18 10:36:42 +00:00
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
uROTypes, uEditorRegistryUtils, uIEditorContratosClientePreview,
|
|
|
|
|
uEditorPreview, uDataModuleContratosCliente, uEditorBase,
|
|
|
|
|
cxControls, uFactuGES_App, uStringsUtils, uSistemaFunc;
|
|
|
|
|
|
|
|
|
|
{ TContratosClienteReportController }
|
|
|
|
|
|
|
|
|
|
constructor TContratosClienteReportController.Create;
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
FDataModule := TDataModuleContratosCliente.Create(Nil);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TContratosClienteReportController.CreateEditor(const AName: String;
|
|
|
|
|
const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
begin
|
|
|
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
destructor TContratosClienteReportController.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FDataModule := NIL;
|
|
|
|
|
inherited;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TContratosClienteReportController.ExportToPDF(const AID: Integer;
|
|
|
|
|
const AFileName: String): Boolean;
|
|
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
if EsCadenaVacia(AFileName) then
|
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
AStream := FDataModule.GetRptPDFContrato(AID);
|
|
|
|
|
try
|
|
|
|
|
AStream.SaveToFile(AFileName);
|
|
|
|
|
Result := True;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2021-03-04 14:07:54 +00:00
|
|
|
procedure TContratosClienteReportController.Preview(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
2019-11-18 10:36:42 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorContratosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2021-03-04 14:07:54 +00:00
|
|
|
AStream := FDataModule.GetRptContratos(AListaID, AVerCondiciones);
|
2019-11-18 10:36:42 +00:00
|
|
|
try
|
|
|
|
|
CreateEditor('EditorContratosClientePreview', IEditorContratosClientePreview, AEditor);
|
|
|
|
|
if Assigned(AEditor) then
|
|
|
|
|
begin
|
|
|
|
|
try
|
|
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
AEditor.ListaID := AListaID;
|
2020-03-04 18:16:20 +00:00
|
|
|
AEditor.Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
2019-11-18 10:36:42 +00:00
|
|
|
AEditor.LoadFromStream(AStream);
|
|
|
|
|
AEditor.Preview;
|
|
|
|
|
finally
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2021-03-04 14:07:54 +00:00
|
|
|
procedure TContratosClienteReportController.Print(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
2020-03-04 18:16:20 +00:00
|
|
|
var
|
2019-11-18 10:36:42 +00:00
|
|
|
AStream: Binary;
|
2020-03-04 18:16:20 +00:00
|
|
|
AEditor : IEditorContratosClientePreview;
|
2019-11-18 10:36:42 +00:00
|
|
|
begin
|
2020-03-04 18:16:20 +00:00
|
|
|
AEditor := NIL;
|
2019-11-18 10:36:42 +00:00
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2021-03-04 14:07:54 +00:00
|
|
|
AStream := FDataModule.GetRptContratos(AListaID, AVerCondiciones);
|
2019-11-18 10:36:42 +00:00
|
|
|
try
|
|
|
|
|
CreateEditor('EditorContratosClientePreview', IEditorContratosClientePreview, AEditor);
|
|
|
|
|
if Assigned(AEditor) then
|
|
|
|
|
begin
|
|
|
|
|
try
|
|
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
AEditor.ListaID := AListaID;
|
|
|
|
|
AEditor.Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
|
|
|
AEditor.LoadFromStream(AStream);
|
|
|
|
|
AEditor.Print;
|
|
|
|
|
finally
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|