Tareas #1334: Repaso de envio por email de presupuestos para que funcione como los demás

Tareas #1335: Incluir fecha de vigencia en el informe de presupuestos

git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@222 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
This commit is contained in:
roberto 2014-03-27 23:05:28 +00:00
parent f2559e7166
commit 8fb5ab2b09
3 changed files with 82 additions and 35 deletions

File diff suppressed because one or more lines are too long

View File

@ -76,6 +76,9 @@ type
end; end;
TPresupuestosClienteController = class(TControllerBase, IPresupuestosClienteController) TPresupuestosClienteController = class(TControllerBase, IPresupuestosClienteController)
private
procedure _AnadirMarcaEnvioCorreo(APresupuesto: IBizPresupuestoCliente);
protected protected
FDataModule : IDataModulePresupuestosCliente; FDataModule : IDataModulePresupuestosCliente;
FClienteController : IClientesController; FClienteController : IClientesController;
@ -162,7 +165,7 @@ type
implementation implementation
uses uses
Controls, cxControls, DB, uEditorRegistryUtils, uEditorPreview, DateUtils, Forms, Controls, cxControls, DB, uEditorRegistryUtils, uEditorPreview, DateUtils,
uIEditorPresupuestosCliente, uDataModulePresupuestosCliente, Variants, uIEditorPresupuestosCliente, uDataModulePresupuestosCliente, Variants,
uBizContactos, uDataTableUtils, uDataModuleUsuarios, uFactuGES_App, uBizContactos, uDataTableUtils, uDataModuleUsuarios, uFactuGES_App,
schPresupuestosClienteClient_Intf, uDAInterfaces, uDateUtils, uIEditorPresupuestoCliente, schPresupuestosClienteClient_Intf, uDAInterfaces, uDateUtils, uIEditorPresupuestoCliente,
@ -602,6 +605,39 @@ begin
end; end;
end; end;
procedure TPresupuestosClienteController._AnadirMarcaEnvioCorreo(
APresupuesto: IBizPresupuestoCliente);
var
ASoloLectura : Boolean;
begin
if not Assigned(APresupuesto) then
raise Exception.Create ('Presupuesto no asignado (_AnadirMarcaEnvioCorreo)');
if APresupuesto.DataTable.Active then
APresupuesto.DataTable.Active := True;
// if AnadirMarcaEnvioCorreo(nme_PresupuestosCliente, APresupuesto.ID) then
// begin
DesconectarTabla(APresupuesto.DataTable);
try
ASoloLectura := APresupuesto.DataTable.ReadOnly;
if ASoloLectura then
SetDataTableReadOnly(APresupuesto.DataTable, False);
try
APresupuesto.Edit;
// APresupuesto.NUM_CORREOS := APresupuesto.NUM_CORREOS + 1;
APresupuesto.Post;
finally
if ASoloLectura then
SetDataTableReadOnly(APresupuesto.DataTable, True);
end;
finally
ConectarTabla(APresupuesto.DataTable);
end;
// end;
end;
function TPresupuestosClienteController._Vacio: IBizPresupuestoCliente; function TPresupuestosClienteController._Vacio: IBizPresupuestoCliente;
begin begin
Result := Buscar(ID_NULO); Result := Buscar(ID_NULO);
@ -745,6 +781,7 @@ var
AReportController : IPresupuestosClienteReportController; AReportController : IPresupuestosClienteReportController;
AFicheroTMP : TFileName; AFicheroTMP : TFileName;
AEMail : String; AEMail : String;
AAsunto: String;
AListaEmail : TStringList; AListaEmail : TStringList;
begin begin
if not Assigned(APresupuesto) then if not Assigned(APresupuesto) then
@ -763,10 +800,8 @@ begin
else begin else begin
AListaEmail := TStringList.Create; AListaEmail := TStringList.Create;
try try
if not APresupuesto.Cliente.EMAIL_1IsNull then if not EsCadenaVacia(APresupuesto.Cliente.EMAIL_ADMINISTRACION) then
AListaEmail.Add(APresupuesto.Cliente.EMAIL_1) AListaEmail.Add(APresupuesto.Cliente.EMAIL_ADMINISTRACION);
else if not APresupuesto.Cliente.EMAIL_2IsNull then
AListaEmail.Add(APresupuesto.Cliente.EMAIL_2);
if not ElegirEMail(AListaEmail, AEMail) then if not ElegirEMail(AListaEmail, AEMail) then
Exit; Exit;
@ -775,15 +810,25 @@ begin
end; end;
end; end;
if not EsCadenaVacia(AAsuntoEMail) then
AAsunto := AAsuntoEMail
else
AAsunto := 'Pedido ' + APresupuesto.REFERENCIA;
ShowHourglassCursor; ShowHourglassCursor;
Application.ProcessMessages;
AReportController := TPresupuestosClienteReportController.Create; AReportController := TPresupuestosClienteReportController.Create;
try try
AReportController.ExportToPDF(APresupuesto.ID, AFicheroTMP); AReportController.ExportToPDF(APresupuesto.ID, AFicheroTMP);
Result := EnviarEMailMAPI('Presupuesto ' + APresupuesto.REFERENCIA, '', AFicheroTMP, '', '', APresupuesto.Cliente.NOMBRE, AEMail, AEnviarDirectamente); Result := EnviarEMailMAPI(AAsunto, ATextoEMail, AFicheroTMP, '', '', APresupuesto.Cliente.NOMBRE, AEMail, AEnviarDirectamente);
// if Result then
// _AnadirMarcaEnvioCorreo(APresupuesto);
finally finally
DeleteFile(AFicheroTMP); SysUtils.DeleteFile(AFicheroTMP);
AReportController := NIL; AReportController := NIL;
HideHourglassCursor; HideHourglassCursor;
Application.ProcessMessages;
end; end;
end; end;
@ -1186,7 +1231,7 @@ begin
ShowHourglassCursor; ShowHourglassCursor;
try try
RecuperarCliente(APresupuesto); RecuperarCliente(APresupuesto);
EnviarPresupuestoPorEMail(APresupuesto); EnviarPresupuestoPorEMail(APresupuesto, False, APresupuesto.Cliente.EMAIL_ADMINISTRACION);
finally finally
HideHourglassCursor; HideHourglassCursor;
end; end;

View File

@ -235,7 +235,7 @@ begin
inherited; inherited;
if ViewGrid.NumSeleccionados = 1 then if ViewGrid.NumSeleccionados = 1 then
FController.EnviarPresupuestoPorEMail(FPresupuestos) FController.GenerarEmailPresupuesto(FPresupuestos)
else begin else begin
// ShowHourglassCursor; // ShowHourglassCursor;
try try