2007-10-26 18:19:55 +00:00
|
|
|
unit uPresupuestosClienteReportController;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModulePresupuestosClienteReport,
|
|
|
|
|
uClientesController, uPresupuestosClienteController, uDetallesPresupuestoClienteController,
|
2008-08-22 14:52:35 +00:00
|
|
|
uBizPresupuestosCliente, uIntegerListUtils;
|
2007-10-26 18:19:55 +00:00
|
|
|
|
|
|
|
|
type
|
2008-02-06 14:28:09 +00:00
|
|
|
IPresupuestosClienteReportController = interface(IControllerBase)
|
2008-08-06 18:18:27 +00:00
|
|
|
['{41AE4B36-6114-4DDE-8BCF-288AA0E12449}']
|
2014-02-18 22:41:52 +00:00
|
|
|
procedure Preview(const AListaID : TIntegerList; Const AVerSello: Integer);
|
|
|
|
|
procedure Print(const AListaID : TIntegerList; Const AVerSello: Integer);
|
|
|
|
|
function ExportToWord(const AID: Integer; const AFileName : String = ''; Const AVerSello: Integer=1): Boolean;
|
|
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''; Const AVerSello: Integer=1): Boolean;
|
2008-08-06 18:18:27 +00:00
|
|
|
function GenerarCertificados(const AID: Integer; const AFileName : String): Boolean;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
|
2008-02-06 14:28:09 +00:00
|
|
|
TPresupuestosClienteReportController = class(TControllerBase, IPresupuestosClienteReportController)
|
2007-10-26 18:19:55 +00:00
|
|
|
private
|
|
|
|
|
FDataModule : IDataModulePresupuestosClienteReport;
|
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
public
|
2008-05-20 18:50:02 +00:00
|
|
|
constructor Create; override;
|
2007-10-26 18:19:55 +00:00
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
2014-02-18 22:41:52 +00:00
|
|
|
procedure Preview(const AListaID : TIntegerList; Const AVerSello: Integer);
|
|
|
|
|
procedure Print(const AListaID : TIntegerList; Const AVerSello: Integer);
|
|
|
|
|
function ExportToWord(const AID: Integer; const AFileName : String = ''; Const AVerSello: Integer=1): Boolean;
|
|
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''; Const AVerSello: Integer=1): Boolean;
|
2008-08-06 18:18:27 +00:00
|
|
|
function GenerarCertificados(const AID: Integer; const AFileName : String): Boolean;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
uROTypes, uEditorRegistryUtils, uIEditorPresupuestosClientePreview,
|
2007-12-20 21:05:11 +00:00
|
|
|
uEditorPreview, uDataModulePresupuestosCliente, uEditorBase,
|
2008-02-06 14:28:09 +00:00
|
|
|
cxControls, uFactuGES_App, uStringsUtils, uSistemaFunc;
|
2007-10-26 18:19:55 +00:00
|
|
|
|
|
|
|
|
{ TPresupuestosClienteReportController }
|
|
|
|
|
|
|
|
|
|
constructor TPresupuestosClienteReportController.Create;
|
|
|
|
|
begin
|
2008-11-11 16:22:18 +00:00
|
|
|
inherited;
|
2007-10-26 18:19:55 +00:00
|
|
|
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;
|
|
|
|
|
|
2014-02-18 22:41:52 +00:00
|
|
|
function TPresupuestosClienteReportController.ExportToPDF(const AID: Integer; const AFileName: String; Const AVerSello: Integer): Boolean;
|
2008-08-21 17:01:02 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
if EsCadenaVacia(AFileName) then
|
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2014-02-18 22:41:52 +00:00
|
|
|
AStream := FDataModule.GetRptPDFPresupuesto(AID, AVerSello);
|
2008-08-21 17:01:02 +00:00
|
|
|
try
|
|
|
|
|
AStream.SaveToFile(AFileName);
|
|
|
|
|
Result := True;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2014-02-18 22:41:52 +00:00
|
|
|
function TPresupuestosClienteReportController.ExportToWord(const AID: Integer; const AFileName : String; Const AVerSello: Integer) : Boolean;
|
2008-02-06 14:28:09 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AFile : String;
|
|
|
|
|
begin
|
2008-05-20 18:50:02 +00:00
|
|
|
Result := False;
|
2008-02-06 14:28:09 +00:00
|
|
|
AFile := AFileName;
|
2008-08-20 14:23:47 +00:00
|
|
|
if EsCadenaVacia(AFile) and (not PreguntarFicheroWordExportar(AFile)) then
|
2008-02-06 14:28:09 +00:00
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2014-02-18 22:41:52 +00:00
|
|
|
AStream := FDataModule.GetRptWordPresupuesto(AID, AVerSello);
|
2008-02-06 14:28:09 +00:00
|
|
|
try
|
|
|
|
|
AStream.SaveToFile(AFile);
|
|
|
|
|
Result := True;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2008-08-06 18:18:27 +00:00
|
|
|
function TPresupuestosClienteReportController.GenerarCertificados(
|
|
|
|
|
const AID: Integer; const AFileName : String): Boolean;
|
|
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AFile : String;
|
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
AFile := AFileName;
|
2009-06-02 11:06:34 +00:00
|
|
|
|
2008-08-20 14:23:47 +00:00
|
|
|
if EsCadenaVacia(AFile) and (not PreguntarFicheroWordExportar(AFile)) then
|
2008-08-06 18:18:27 +00:00
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
AStream := FDataModule.GetRptWordCertificadoTrabajos(AID);
|
|
|
|
|
try
|
|
|
|
|
AStream.SaveToFile(AFile);
|
|
|
|
|
Result := True;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2014-02-18 22:41:52 +00:00
|
|
|
procedure TPresupuestosClienteReportController.Preview(const AListaID : TIntegerList; Const AVerSello: Integer);
|
2007-10-26 18:19:55 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
2008-11-11 16:22:18 +00:00
|
|
|
|
2009-06-02 11:06:34 +00:00
|
|
|
ShowHourglassCursor;
|
2007-10-26 18:19:55 +00:00
|
|
|
try
|
2014-02-18 22:41:52 +00:00
|
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID, AVerSello);
|
2009-06-02 11:06:34 +00:00
|
|
|
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;
|
2008-08-22 14:52:35 +00:00
|
|
|
end;
|
2009-06-02 11:06:34 +00:00
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
finally
|
2009-06-02 11:06:34 +00:00
|
|
|
HideHourglassCursor;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2014-02-18 22:41:52 +00:00
|
|
|
procedure TPresupuestosClienteReportController.Print(const AListaID : TIntegerList; Const AVerSello: Integer);
|
2007-10-26 18:19:55 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
2010-07-12 18:03:50 +00:00
|
|
|
|
2007-10-26 18:19:55 +00:00
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2014-02-18 22:41:52 +00:00
|
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID, AVerSello);
|
2007-10-26 18:19:55 +00:00
|
|
|
try
|
|
|
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, AEditor);
|
2007-11-13 19:36:56 +00:00
|
|
|
if Assigned(AEditor) then
|
2008-08-22 14:52:35 +00:00
|
|
|
begin
|
|
|
|
|
try
|
2008-08-21 17:01:02 +00:00
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
AEditor.ListaID := AListaID;
|
2008-08-22 14:52:35 +00:00
|
|
|
AEditor.Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
2008-08-21 17:01:02 +00:00
|
|
|
AEditor.LoadFromStream(AStream);
|
|
|
|
|
AEditor.Print;
|
2008-08-22 14:52:35 +00:00
|
|
|
finally
|
2008-08-21 17:01:02 +00:00
|
|
|
AEditor.Release;
|
|
|
|
|
end;
|
2008-08-22 14:52:35 +00:00
|
|
|
end;
|
2007-10-26 18:19:55 +00:00
|
|
|
finally
|
2007-11-13 19:36:56 +00:00
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|