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:
parent
f2559e7166
commit
8fb5ab2b09
File diff suppressed because one or more lines are too long
@ -76,6 +76,9 @@ type
|
||||
end;
|
||||
|
||||
TPresupuestosClienteController = class(TControllerBase, IPresupuestosClienteController)
|
||||
private
|
||||
procedure _AnadirMarcaEnvioCorreo(APresupuesto: IBizPresupuestoCliente);
|
||||
|
||||
protected
|
||||
FDataModule : IDataModulePresupuestosCliente;
|
||||
FClienteController : IClientesController;
|
||||
@ -162,7 +165,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
Controls, cxControls, DB, uEditorRegistryUtils, uEditorPreview, DateUtils,
|
||||
Forms, Controls, cxControls, DB, uEditorRegistryUtils, uEditorPreview, DateUtils,
|
||||
uIEditorPresupuestosCliente, uDataModulePresupuestosCliente, Variants,
|
||||
uBizContactos, uDataTableUtils, uDataModuleUsuarios, uFactuGES_App,
|
||||
schPresupuestosClienteClient_Intf, uDAInterfaces, uDateUtils, uIEditorPresupuestoCliente,
|
||||
@ -602,6 +605,39 @@ begin
|
||||
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;
|
||||
begin
|
||||
Result := Buscar(ID_NULO);
|
||||
@ -745,6 +781,7 @@ var
|
||||
AReportController : IPresupuestosClienteReportController;
|
||||
AFicheroTMP : TFileName;
|
||||
AEMail : String;
|
||||
AAsunto: String;
|
||||
AListaEmail : TStringList;
|
||||
begin
|
||||
if not Assigned(APresupuesto) then
|
||||
@ -763,10 +800,8 @@ begin
|
||||
else begin
|
||||
AListaEmail := TStringList.Create;
|
||||
try
|
||||
if not APresupuesto.Cliente.EMAIL_1IsNull then
|
||||
AListaEmail.Add(APresupuesto.Cliente.EMAIL_1)
|
||||
else if not APresupuesto.Cliente.EMAIL_2IsNull then
|
||||
AListaEmail.Add(APresupuesto.Cliente.EMAIL_2);
|
||||
if not EsCadenaVacia(APresupuesto.Cliente.EMAIL_ADMINISTRACION) then
|
||||
AListaEmail.Add(APresupuesto.Cliente.EMAIL_ADMINISTRACION);
|
||||
|
||||
if not ElegirEMail(AListaEmail, AEMail) then
|
||||
Exit;
|
||||
@ -775,15 +810,25 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
if not EsCadenaVacia(AAsuntoEMail) then
|
||||
AAsunto := AAsuntoEMail
|
||||
else
|
||||
AAsunto := 'Pedido ' + APresupuesto.REFERENCIA;
|
||||
|
||||
ShowHourglassCursor;
|
||||
Application.ProcessMessages;
|
||||
|
||||
AReportController := TPresupuestosClienteReportController.Create;
|
||||
try
|
||||
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
|
||||
DeleteFile(AFicheroTMP);
|
||||
SysUtils.DeleteFile(AFicheroTMP);
|
||||
AReportController := NIL;
|
||||
HideHourglassCursor;
|
||||
Application.ProcessMessages;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1186,7 +1231,7 @@ begin
|
||||
ShowHourglassCursor;
|
||||
try
|
||||
RecuperarCliente(APresupuesto);
|
||||
EnviarPresupuestoPorEMail(APresupuesto);
|
||||
EnviarPresupuestoPorEMail(APresupuesto, False, APresupuesto.Cliente.EMAIL_ADMINISTRACION);
|
||||
finally
|
||||
HideHourglassCursor;
|
||||
end;
|
||||
|
||||
@ -235,7 +235,7 @@ begin
|
||||
inherited;
|
||||
|
||||
if ViewGrid.NumSeleccionados = 1 then
|
||||
FController.EnviarPresupuestoPorEMail(FPresupuestos)
|
||||
FController.GenerarEmailPresupuesto(FPresupuestos)
|
||||
else begin
|
||||
// ShowHourglassCursor;
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user