git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@72 93f398dd-4eb6-7a46-baf6-13f46f578da2
161 lines
5.7 KiB
ObjectPascal
161 lines
5.7 KiB
ObjectPascal
unit uPresupuestosClienteReportController;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModulePresupuestosClienteReport,
|
|
uClientesController, uPresupuestosClienteController, uDetallesPresupuestoClienteController,
|
|
uBizPresupuestosCliente, uIntegerListUtils;
|
|
|
|
type
|
|
IPresupuestosClienteReportController = interface(IControllerBase)
|
|
['{41AE4B36-6114-4DDE-8BCF-288AA0E12449}']
|
|
procedure Preview(const AListaID : TIntegerList; const VerLogotipo: Boolean;
|
|
const VerImprimirPrecios: Boolean = False; const VerImprimirTotales: Boolean = False; const VerImprimirRefProveedor: Boolean = False;
|
|
const VerImprimirObservaciones: Boolean = False; const VerImprimirIncidencias: Boolean = False);
|
|
procedure Print(const AListaID : TIntegerList; const VerLogotipo: Boolean;
|
|
const VerImprimirPrecios: Boolean = False; const VerImprimirTotales: Boolean = False; const VerImprimirRefProveedor: Boolean = False;
|
|
const VerImprimirObservaciones: Boolean = False; const VerImprimirIncidencias: Boolean = False);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
end;
|
|
|
|
TPresupuestosClienteReportController = class(TControllerBase, IPresupuestosClienteReportController)
|
|
private
|
|
FDataModule : IDataModulePresupuestosClienteReport;
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
public
|
|
constructor Create; override;
|
|
destructor Destroy; override;
|
|
|
|
procedure Preview(const AListaID : TIntegerList; const VerLogotipo: Boolean;
|
|
const VerImprimirPrecios: Boolean = False; const VerImprimirTotales: Boolean = False; const VerImprimirRefProveedor: Boolean = False;
|
|
const VerImprimirObservaciones: Boolean = False; const VerImprimirIncidencias: Boolean = False);
|
|
procedure Print(const AListaID : TIntegerList; const VerLogotipo: Boolean;
|
|
const VerImprimirPrecios: Boolean = False; const VerImprimirTotales: Boolean = False; const VerImprimirRefProveedor: Boolean = False;
|
|
const VerImprimirObservaciones: Boolean = False; const VerImprimirIncidencias: Boolean = False);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
uROTypes, uEditorRegistryUtils, uIEditorPresupuestosClientePreview,
|
|
uEditorPreview, uDataModulePresupuestosCliente, uEditorBase,
|
|
cxControls, uFactuGES_App, uStringsUtils, uSistemaFunc;
|
|
|
|
{ TPresupuestosClienteReportController }
|
|
|
|
constructor TPresupuestosClienteReportController.Create;
|
|
begin
|
|
inherited;
|
|
FDataModule := TDataModulePresupuestosCliente.Create(Nil);
|
|
end;
|
|
|
|
function TPresupuestosClienteReportController.CreateEditor(const AName: String;
|
|
const IID: TGUID; out Intf): Boolean;
|
|
begin
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|
end;
|
|
|
|
|
|
destructor TPresupuestosClienteReportController.Destroy;
|
|
begin
|
|
FDataModule := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
function TPresupuestosClienteReportController.ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
var
|
|
AStream: Binary;
|
|
begin
|
|
Result := False;
|
|
if EsCadenaVacia(AFileName) then
|
|
Exit;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPDFPresupuesto(AID, True);
|
|
try
|
|
AStream.SaveToFile(AFileName);
|
|
Result := True;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TPresupuestosClienteReportController.Preview(const AListaID : TIntegerList; const VerLogotipo: Boolean;
|
|
const VerImprimirPrecios: Boolean = False; const VerImprimirTotales: Boolean = False; const VerImprimirRefProveedor: Boolean = False;
|
|
const VerImprimirObservaciones: Boolean = False; const VerImprimirIncidencias: Boolean = False);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID, VerLogotipo, VerImprimirPrecios, VerImprimirTotales);
|
|
try
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, AEditor);
|
|
if Assigned(AEditor) then
|
|
begin
|
|
try
|
|
AEditor.Controller := Self;
|
|
AEditor.ListaID := AListaID;
|
|
AEditor.Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
AEditor.LoadFromStream(AStream);
|
|
AEditor.Preview;
|
|
finally
|
|
AEditor.Release;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
AEditor := Nil;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TPresupuestosClienteReportController.Print(const AListaID : TIntegerList; const VerLogotipo: Boolean;
|
|
const VerImprimirPrecios: Boolean = False; const VerImprimirTotales: Boolean = False; const VerImprimirRefProveedor: Boolean = False;
|
|
const VerImprimirObservaciones: Boolean = False; const VerImprimirIncidencias: Boolean = False);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID, VerLogotipo, VerImprimirPrecios, VerImprimirTotales);
|
|
try
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, 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.
|