diff --git a/Build/Build.fbl6 b/Build/Build.fbl6
index 578da83..c30df1b 100644
Binary files a/Build/Build.fbl6 and b/Build/Build.fbl6 differ
diff --git a/Database/scripts/factuges.sql b/Database/scripts/factuges.sql
index e3f6773..82656fe 100644
--- a/Database/scripts/factuges.sql
+++ b/Database/scripts/factuges.sql
@@ -1592,7 +1592,7 @@ SELECT
FROM
ALBARANES_PROVEEDOR
INNER JOIN CONTACTOS PROVEEDORES ON (PROVEEDORES.ID = ALBARANES_PROVEEDOR.ID_PROVEEDOR)
- INNER JOIN CONTACTOS CLIENTES ON (CLIENTES.ID = ALBARANES_PROVEEDOR.ID_CLIENTE_FINAL)
+ LEFT JOIN CONTACTOS CLIENTES ON (CLIENTES.ID = ALBARANES_PROVEEDOR.ID_CLIENTE_FINAL)
LEFT OUTER JOIN ALBARANES_PROVEEDOR ALB_DEV ON (ALB_DEV.ID = ALBARANES_PROVEEDOR.ID_ALBARAN_DEV)
LEFT OUTER JOIN FACTURAS_PROVEEDOR FAC_PROV_ALB_DEV ON (FAC_PROV_ALB_DEV.ID = ALB_DEV.ID_FACTURA)
LEFT OUTER JOIN FACTURAS_PROVEEDOR ON (FACTURAS_PROVEEDOR.ID = ALBARANES_PROVEEDOR.ID_FACTURA)
diff --git a/Source/Base/Base.dproj b/Source/Base/Base.dproj
index bbd92a3..553497e 100644
--- a/Source/Base/Base.dproj
+++ b/Source/Base/Base.dproj
@@ -63,58 +63,58 @@
TDataModule
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
TForm
diff --git a/Source/Cliente/FactuGES.dproj b/Source/Cliente/FactuGES.dproj
index a12fba3..5473f53 100644
--- a/Source/Cliente/FactuGES.dproj
+++ b/Source/Cliente/FactuGES.dproj
@@ -53,7 +53,7 @@
Delphi.Personality
VCLApplication
-FalseTrueFalseC:\Archivos de programa\Borland\Delphi7\Bin\TrueFalse4190FalseFalseFalseFalseFalse30821252Rodax Software S.L.4.1.9.0FactuGESFactuGES4.1.9.0FactuGES.dprFalse
+FalseTrueFalseC:\Archivos de programa\Borland\Delphi7\Bin\TrueFalse4200FalseFalseFalseFalseFalse30821252Rodax Software S.L.4.2.0.0FactuGESFactuGES4.2.0.0FactuGES.dprFalse
diff --git a/Source/Informes/1/InformeObjetivosAgentesAlbaranes.fr3 b/Source/Informes/1/InformeObjetivosAgentesAlbaranes.fr3
new file mode 100644
index 0000000..cdfc371
--- /dev/null
+++ b/Source/Informes/1/InformeObjetivosAgentesAlbaranes.fr3
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.dfm b/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.dfm
index 94ff3d1..ffb463d 100644
--- a/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.dfm
+++ b/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.dfm
@@ -484,6 +484,276 @@ object RptAlbaranesCliente: TRptAlbaranesCliente
DataType = datCurrency
end>
end
+ item
+ Params = <>
+ Statements = <
+ item
+ ConnectionType = 'Interbase'
+ Default = True
+ Name = 'IBX'
+ SQL =
+ 'select A.ID_EMPRESA, A.ID_AGENTE,'#10' A.ANO,'#10' A.MES,'#10' AO.C' +
+ 'ANTIDAD_OBJETIVO,'#10' AO.IMPORTE_OBJETIVO,'#10' A.CANTIDAD_CONSEG' +
+ 'UIDA,'#10' A.CANTIDAD_DEVUELTA,'#10' A.IMPORTE_CONSEGUIDO,'#10' A.I' +
+ 'MPORTE_DEVUELTO,'#10' (A.CANTIDAD_CONSEGUIDA - AO.CANTIDAD_OBJETI' +
+ 'VO) as CANTIDAD_RESULTADO,'#10' (A.IMPORTE_CONSEGUIDO - AO.IMPORT' +
+ 'E_OBJETIVO) as IMPORTE_RESULTADO'#10#10#10'from v_inf_objetivos_albarane' +
+ 's A'#10'left join V_INF_OBJETIVOS_ALB_AGENTES AO on ((AO.id_agente =' +
+ ' A.id_agente) and (AO.ano = A.ANO) and (AO.mes = A.MES))'#10#10#10
+ StatementType = stSQL
+ ColumnMappings = <
+ item
+ DatasetField = 'ID_EMPRESA'
+ TableField = 'ID_EMPRESA'
+ end
+ item
+ DatasetField = 'ID_AGENTE'
+ TableField = 'ID_AGENTE'
+ end
+ item
+ DatasetField = 'ANO'
+ TableField = 'ANO'
+ end
+ item
+ DatasetField = 'MES'
+ TableField = 'MES'
+ end
+ item
+ DatasetField = 'CANTIDAD_OBJETIVO'
+ TableField = 'CANTIDAD_OBJETIVO'
+ end
+ item
+ DatasetField = 'IMPORTE_OBJETIVO'
+ TableField = 'IMPORTE_OBJETIVO'
+ end
+ item
+ DatasetField = 'CANTIDAD_CONSEGUIDA'
+ TableField = 'CANTIDAD_CONSEGUIDA'
+ end
+ item
+ DatasetField = 'CANTIDAD_DEVUELTA'
+ TableField = 'CANTIDAD_DEVUELTA'
+ end
+ item
+ DatasetField = 'IMPORTE_CONSEGUIDO'
+ TableField = 'IMPORTE_CONSEGUIDO'
+ end
+ item
+ DatasetField = 'IMPORTE_DEVUELTO'
+ TableField = 'IMPORTE_DEVUELTO'
+ end
+ item
+ DatasetField = 'CANTIDAD_RESULTADO'
+ TableField = 'CANTIDAD_RESULTADO'
+ end
+ item
+ DatasetField = 'IMPORTE_RESULTADO'
+ TableField = 'IMPORTE_RESULTADO'
+ end>
+ end>
+ Name = 'Informe_Objetivos_Albaranes'
+ Fields = <
+ item
+ Name = 'ID_EMPRESA'
+ DataType = datInteger
+ end
+ item
+ Name = 'ID_AGENTE'
+ DataType = datInteger
+ end
+ item
+ Name = 'ANO'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'MES'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'CANTIDAD_OBJETIVO'
+ DataType = datInteger
+ end
+ item
+ Name = 'IMPORTE_OBJETIVO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_CONSEGUIDA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_DEVUELTA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_CONSEGUIDO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_DEVUELTO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_RESULTADO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_RESULTADO'
+ DataType = datCurrency
+ end>
+ end
+ item
+ Params = <
+ item
+ Name = 'ANO1'
+ Value = ''
+ end
+ item
+ Name = 'ID_EMPRESA'
+ Value = ''
+ end>
+ Statements = <
+ item
+ Connection = 'IBX'
+ ConnectionType = 'Interbase'
+ Default = True
+ Name = 'IBX'
+ SQL =
+ 'select OBJETIVOS.ID_AGENTE, OBJETIVOS.AGENTE, OBJETIVOS.ANO,'#10' ' +
+ ' OBJETIVOS.MES,'#10' OBJETIVOS.descripcion,'#10' OBJETIVOS.CANTIDA' +
+ 'D_OBJETIVO,'#10' OBJETIVOS.IMPORTE_OBJETIVO,'#10' ALCANZADO.CANTID' +
+ 'AD_CONSEGUIDA,'#10' ALCANZADO.CANTIDAD_DEVUELTA,'#10' ALCANZADO.IM' +
+ 'PORTE_CONSEGUIDO,'#10' ALCANZADO.IMPORTE_DEVUELTO,'#10' (ALCANZADO' +
+ '.CANTIDAD_CONSEGUIDA - OBJETIVOS.CANTIDAD_OBJETIVO) as CANTIDAD_' +
+ 'RESULTADO,'#10' (ALCANZADO.IMPORTE_CONSEGUIDO - OBJETIVOS.IMPORTE' +
+ '_OBJETIVO) as IMPORTE_RESULTADO'#10'from'#10#10'(select AO.ID_AGENTE, C.NO' +
+ 'MBRE as AGENTE, AO.ANO,'#10' AO.MES,'#10' P.descripcion,'#10' sum(A' +
+ 'O.CANTIDAD_OBJETIVO) as CANTIDAD_OBJETIVO,'#10' sum(AO.IMPORTE_OB' +
+ 'JETIVO) as IMPORTE_OBJETIVO'#10'from V_INF_OBJETIVOS_ALB_AGENTES AO'#10 +
+ 'left join periodos_aux P on ((P.periodo = '#39'MENSUAL'#39') and (P.valo' +
+ 'r = AO.MES))'#10'left join contactos C on (C.ID = AO.ID_AGENTE)'#10'wher' +
+ 'e (AO.ANO = :ANO1)'#10'group by 1,2,3,4,5'#10'order by 1,2,3,4,5) OBJETI' +
+ 'VOS'#10#10#10'left join'#10'(select ID_AGENTE, AGENTE, ANO, MES, sum(CANTIDA' +
+ 'D_CONSEGUIDA) as CANTIDAD_CONSEGUIDA,'#10' sum(CANTIDAD_DEVUELTA) as' +
+ ' CANTIDAD_DEVUELTA, sum(IMPORTE_CONSEGUIDO) as IMPORTE_CONSEGUID' +
+ 'O,'#10' sum(IMPORTE_DEVUELTO) as IMPORTE_DEVUELTO'#10' from v_inf_objeti' +
+ 'vos_albaranes'#10' where ((v_inf_objetivos_albaranes.id_empresa = :I' +
+ 'D_EMPRESA) and (v_inf_objetivos_albaranes.ANO = :ANO1))'#10' group b' +
+ 'y 1,2,3,4'#10' order by 1,2,3,4) ALCANZADO on ((OBJETIVOS.id_agente ' +
+ '= ALCANZADO.id_agente) and (OBJETIVOS.ano = ALCANZADO.ANO) and (' +
+ 'OBJETIVOS.mes = ALCANZADO.MES))'#10#10'where {where}'#10
+ StatementType = stSQL
+ ColumnMappings = <
+ item
+ DatasetField = 'AGENTE'
+ TableField = 'AGENTE'
+ end
+ item
+ DatasetField = 'ANO'
+ TableField = 'ANO'
+ end
+ item
+ DatasetField = 'MES'
+ TableField = 'MES'
+ end
+ item
+ DatasetField = 'DESCRIPCION'
+ TableField = 'DESCRIPCION'
+ end
+ item
+ DatasetField = 'CANTIDAD_OBJETIVO'
+ TableField = 'CANTIDAD_OBJETIVO'
+ end
+ item
+ DatasetField = 'IMPORTE_OBJETIVO'
+ TableField = 'IMPORTE_OBJETIVO'
+ end
+ item
+ DatasetField = 'CANTIDAD_CONSEGUIDA'
+ TableField = 'CANTIDAD_CONSEGUIDA'
+ end
+ item
+ DatasetField = 'CANTIDAD_DEVUELTA'
+ TableField = 'CANTIDAD_DEVUELTA'
+ end
+ item
+ DatasetField = 'IMPORTE_CONSEGUIDO'
+ TableField = 'IMPORTE_CONSEGUIDO'
+ end
+ item
+ DatasetField = 'IMPORTE_DEVUELTO'
+ TableField = 'IMPORTE_DEVUELTO'
+ end
+ item
+ DatasetField = 'CANTIDAD_RESULTADO'
+ TableField = 'CANTIDAD_RESULTADO'
+ end
+ item
+ DatasetField = 'IMPORTE_RESULTADO'
+ TableField = 'IMPORTE_RESULTADO'
+ end
+ item
+ DatasetField = 'ID_AGENTE'
+ TableField = 'ID_AGENTE'
+ end>
+ end>
+ Name = 'InformeListadoObjetivosMensual'
+ Fields = <
+ item
+ Name = 'ID_AGENTE'
+ DataType = datInteger
+ end
+ item
+ Name = 'AGENTE'
+ DataType = datString
+ Size = 255
+ end
+ item
+ Name = 'ANO'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'MES'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'DESCRIPCION'
+ DataType = datString
+ Size = 20
+ end
+ item
+ Name = 'CANTIDAD_OBJETIVO'
+ DataType = datLargeInt
+ end
+ item
+ Name = 'IMPORTE_OBJETIVO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_CONSEGUIDA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_DEVUELTA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_CONSEGUIDO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_DEVUELTO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_RESULTADO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_RESULTADO'
+ DataType = datCurrency
+ end>
+ end
item
Params = <
item
@@ -1796,6 +2066,310 @@ object RptAlbaranesCliente: TRptAlbaranesCliente
Name = 'PORCENTAJE'
DataType = datFloat
end>
+ end
+ item
+ Params = <
+ item
+ Name = 'ANO1'
+ Value = ''
+ end
+ item
+ Name = 'ID_EMPRESA'
+ Value = ''
+ end>
+ Statements = <
+ item
+ Connection = 'IBX'
+ ConnectionType = 'Interbase'
+ Default = True
+ SQL =
+ 'select OBJETIVOS.ID_AGENTE, OBJETIVOS.AGENTE, OBJETIVOS.ANO,'#10' ' +
+ ' OBJETIVOS.TRIMESTRE,'#10' OBJETIVOS.descripcion,'#10' OBJETIVOS.C' +
+ 'ANTIDAD_OBJETIVO,'#10' OBJETIVOS.IMPORTE_OBJETIVO,'#10' ALCANZADO.' +
+ 'CANTIDAD_CONSEGUIDA,'#10' ALCANZADO.CANTIDAD_DEVUELTA,'#10' ALCANZ' +
+ 'ADO.IMPORTE_CONSEGUIDO,'#10' ALCANZADO.IMPORTE_DEVUELTO,'#10' (ALC' +
+ 'ANZADO.CANTIDAD_CONSEGUIDA - OBJETIVOS.CANTIDAD_OBJETIVO) as CAN' +
+ 'TIDAD_RESULTADO,'#10' (ALCANZADO.IMPORTE_CONSEGUIDO - OBJETIVOS.I' +
+ 'MPORTE_OBJETIVO) as IMPORTE_RESULTADO'#10'from'#10#10'(select AO.ID_AGENTE' +
+ ', C.NOMBRE AS AGENTE, AO.ANO,'#10' AO.TRIMESTRE,'#10' P.descripcio' +
+ 'n,'#10' sum(AO.CANTIDAD_OBJETIVO) as CANTIDAD_OBJETIVO,'#10' sum(A' +
+ 'O.IMPORTE_OBJETIVO) as IMPORTE_OBJETIVO'#10'from V_INF_OBJETIVOS_ALB' +
+ '_AGENTES AO'#10'left join periodos_aux P on ((P.periodo = '#39'TRIMESTRA' +
+ 'L'#39') and (P.valor = AO.TRIMESTRE))'#10'left join contactos C on (C.ID' +
+ ' = AO.ID_AGENTE)'#10'where (AO.ANO = :ANO1)'#10'group by 1,2,3,4,5'#10'order' +
+ ' by 1,2,3,4,5) OBJETIVOS'#10#10#10'left join'#10'(select ID_AGENTE, AGENTE, ' +
+ 'ANO, TRIMESTRE, sum(CANTIDAD_CONSEGUIDA) as CANTIDAD_CONSEGUIDA,' +
+ #10' sum(CANTIDAD_DEVUELTA) as CANTIDAD_DEVUELTA, sum(IMPORTE_CONSE' +
+ 'GUIDO) as IMPORTE_CONSEGUIDO,'#10' sum(IMPORTE_DEVUELTO) as IMPORTE_' +
+ 'DEVUELTO'#10' from v_inf_objetivos_albaranes'#10' where ((v_inf_objetivo' +
+ 's_albaranes.id_empresa = :ID_EMPRESA) and (v_inf_objetivos_albar' +
+ 'anes.ANO = :ANO1))'#10' group by 1,2,3,4'#10' order by 1,2,3,4) ALCANZAD' +
+ 'O on ((OBJETIVOS.id_agente = ALCANZADO.id_agente) and (OBJETIVOS' +
+ '.ano = ALCANZADO.ANO) and (OBJETIVOS.TRIMESTRE = ALCANZADO.TRIME' +
+ 'STRE))'#10#10' where {where}'#10#10#10
+ StatementType = stSQL
+ ColumnMappings = <
+ item
+ DatasetField = 'ANO'
+ TableField = 'ANO'
+ end
+ item
+ DatasetField = 'CANTIDAD_OBJETIVO'
+ TableField = 'CANTIDAD_OBJETIVO'
+ end
+ item
+ DatasetField = 'IMPORTE_OBJETIVO'
+ TableField = 'IMPORTE_OBJETIVO'
+ end
+ item
+ DatasetField = 'CANTIDAD_CONSEGUIDA'
+ TableField = 'CANTIDAD_CONSEGUIDA'
+ end
+ item
+ DatasetField = 'CANTIDAD_DEVUELTA'
+ TableField = 'CANTIDAD_DEVUELTA'
+ end
+ item
+ DatasetField = 'IMPORTE_CONSEGUIDO'
+ TableField = 'IMPORTE_CONSEGUIDO'
+ end
+ item
+ DatasetField = 'IMPORTE_DEVUELTO'
+ TableField = 'IMPORTE_DEVUELTO'
+ end
+ item
+ DatasetField = 'CANTIDAD_RESULTADO'
+ TableField = 'CANTIDAD_RESULTADO'
+ end
+ item
+ DatasetField = 'IMPORTE_RESULTADO'
+ TableField = 'IMPORTE_RESULTADO'
+ end
+ item
+ DatasetField = 'DESCRIPCION'
+ TableField = 'DESCRIPCION'
+ end
+ item
+ DatasetField = 'TRIMESTRE'
+ TableField = 'TRIMESTRE'
+ end
+ item
+ DatasetField = 'AGENTE'
+ TableField = 'AGENTE'
+ end
+ item
+ DatasetField = 'ID_AGENTE'
+ TableField = 'ID_AGENTE'
+ end>
+ end>
+ Name = 'InformeListadoObjetivosTrimestral'
+ Fields = <
+ item
+ Name = 'ID_AGENTE'
+ DataType = datInteger
+ end
+ item
+ Name = 'AGENTE'
+ DataType = datString
+ Size = 255
+ end
+ item
+ Name = 'ANO'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'TRIMESTRE'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'DESCRIPCION'
+ DataType = datString
+ Size = 20
+ end
+ item
+ Name = 'CANTIDAD_OBJETIVO'
+ DataType = datLargeInt
+ end
+ item
+ Name = 'IMPORTE_OBJETIVO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_CONSEGUIDA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_DEVUELTA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_CONSEGUIDO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_DEVUELTO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_RESULTADO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_RESULTADO'
+ DataType = datCurrency
+ end>
+ end
+ item
+ Params = <
+ item
+ Name = 'ANO1'
+ Value = ''
+ end
+ item
+ Name = 'ID_EMPRESA'
+ Value = ''
+ end>
+ Statements = <
+ item
+ Connection = 'IBX'
+ ConnectionType = 'Interbase'
+ Default = True
+ SQL =
+ 'select OBJETIVOS.ID_AGENTE, OBJETIVOS.AGENTE, OBJETIVOS.ANO,'#10' ' +
+ ' OBJETIVOS.SEMESTRE,'#10' OBJETIVOS.descripcion,'#10' OBJETIVOS.CA' +
+ 'NTIDAD_OBJETIVO,'#10' OBJETIVOS.IMPORTE_OBJETIVO,'#10' ALCANZADO.C' +
+ 'ANTIDAD_CONSEGUIDA,'#10' ALCANZADO.CANTIDAD_DEVUELTA,'#10' ALCANZA' +
+ 'DO.IMPORTE_CONSEGUIDO,'#10' ALCANZADO.IMPORTE_DEVUELTO,'#10' (ALCA' +
+ 'NZADO.CANTIDAD_CONSEGUIDA - OBJETIVOS.CANTIDAD_OBJETIVO) as CANT' +
+ 'IDAD_RESULTADO,'#10' (ALCANZADO.IMPORTE_CONSEGUIDO - OBJETIVOS.IM' +
+ 'PORTE_OBJETIVO) as IMPORTE_RESULTADO'#10'from'#10#10'(select AO.ID_AGENTE,' +
+ ' C.NOMBRE as AGENTE, AO.ANO,'#10' AO.SEMESTRE,'#10' P.descripcion,' +
+ #10' sum(AO.CANTIDAD_OBJETIVO) as CANTIDAD_OBJETIVO,'#10' sum(AO.' +
+ 'IMPORTE_OBJETIVO) as IMPORTE_OBJETIVO'#10'from V_INF_OBJETIVOS_ALB_A' +
+ 'GENTES AO'#10'left join periodos_aux P on ((P.periodo = '#39'SEMESTRAL'#39')' +
+ ' and (P.valor = AO.SEMESTRE))'#10'left join contactos C on (C.ID = A' +
+ 'O.ID_AGENTE)'#10'where (AO.ANO = :ANO1)'#10'group by 1,2,3,4,5'#10'order by ' +
+ '1,2,3,4,5) OBJETIVOS'#10#10#10'left join'#10'(select ID_AGENTE, AGENTE, ANO,' +
+ ' SEMESTRE, sum(CANTIDAD_CONSEGUIDA) as CANTIDAD_CONSEGUIDA,'#10' sum' +
+ '(CANTIDAD_DEVUELTA) as CANTIDAD_DEVUELTA, sum(IMPORTE_CONSEGUIDO' +
+ ') as IMPORTE_CONSEGUIDO,'#10' sum(IMPORTE_DEVUELTO) as IMPORTE_DEVUE' +
+ 'LTO'#10' from v_inf_objetivos_albaranes'#10' where ((v_inf_objetivos_alb' +
+ 'aranes.id_empresa = :ID_EMPRESA) and (v_inf_objetivos_albaranes.' +
+ 'ANO = :ANO1))'#10' group by 1,2,3,4'#10' order by 1,2,3,4) ALCANZADO on ' +
+ '((OBJETIVOS.id_agente = ALCANZADO.id_agente) and (OBJETIVOS.ano ' +
+ '= ALCANZADO.ANO) and (OBJETIVOS.SEMESTRE = ALCANZADO.SEMESTRE))'#10 +
+ #10'where {where}'#10
+ StatementType = stSQL
+ ColumnMappings = <
+ item
+ DatasetField = 'ANO'
+ TableField = 'ANO'
+ end
+ item
+ DatasetField = 'CANTIDAD_OBJETIVO'
+ TableField = 'CANTIDAD_OBJETIVO'
+ end
+ item
+ DatasetField = 'IMPORTE_OBJETIVO'
+ TableField = 'IMPORTE_OBJETIVO'
+ end
+ item
+ DatasetField = 'CANTIDAD_CONSEGUIDA'
+ TableField = 'CANTIDAD_CONSEGUIDA'
+ end
+ item
+ DatasetField = 'CANTIDAD_DEVUELTA'
+ TableField = 'CANTIDAD_DEVUELTA'
+ end
+ item
+ DatasetField = 'IMPORTE_CONSEGUIDO'
+ TableField = 'IMPORTE_CONSEGUIDO'
+ end
+ item
+ DatasetField = 'IMPORTE_DEVUELTO'
+ TableField = 'IMPORTE_DEVUELTO'
+ end
+ item
+ DatasetField = 'CANTIDAD_RESULTADO'
+ TableField = 'CANTIDAD_RESULTADO'
+ end
+ item
+ DatasetField = 'IMPORTE_RESULTADO'
+ TableField = 'IMPORTE_RESULTADO'
+ end
+ item
+ DatasetField = 'DESCRIPCION'
+ TableField = 'DESCRIPCION'
+ end
+ item
+ DatasetField = 'SEMESTRE'
+ TableField = 'SEMESTRE'
+ end
+ item
+ DatasetField = 'AGENTE'
+ TableField = 'AGENTE'
+ end
+ item
+ DatasetField = 'ID_AGENTE'
+ TableField = 'ID_AGENTE'
+ end>
+ end>
+ Name = 'InformeListadoObjetivosSemestral'
+ Fields = <
+ item
+ Name = 'ID_AGENTE'
+ DataType = datInteger
+ end
+ item
+ Name = 'AGENTE'
+ DataType = datString
+ Size = 255
+ end
+ item
+ Name = 'ANO'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'SEMESTRE'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'DESCRIPCION'
+ DataType = datString
+ Size = 20
+ end
+ item
+ Name = 'CANTIDAD_OBJETIVO'
+ DataType = datLargeInt
+ end
+ item
+ Name = 'IMPORTE_OBJETIVO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_CONSEGUIDA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_DEVUELTA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_CONSEGUIDO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_DEVUELTO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_RESULTADO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_RESULTADO'
+ DataType = datCurrency
+ end>
end>
JoinDataTables = <>
UnionDataTables = <>
@@ -1815,178 +2389,23 @@ object RptAlbaranesCliente: TRptAlbaranesCliente
PreviewOptions.Zoom = 1.000000000000000000
PrintOptions.Printer = 'Por defecto'
PrintOptions.PrintOnSheet = 0
- ReportOptions.CreateDate = 39065.872423495400000000
- ReportOptions.LastChange = 40842.791316122700000000
+ ReportOptions.CreateDate = 37800.807714351900000000
+ ReportOptions.LastChange = 40935.658182025470000000
ScriptLanguage = 'PascalScript'
ScriptText.Strings = (
- 'var'
- ' Pagina: Variant;'
- ''
- ''
- 'procedure DatosEmpresaOnBeforePrint(Sender: TfrxComponent);'
- 'var'
- ' Cadena: String;'
+ 'procedure mContinuaOnBeforePrint(Sender: TfrxComponent);'
'begin'
- ' DatosEmpresa.Lines.Clear;'
- ' if ( <> '#39#39') then'
- ' Cadena := '#39'TLF: '#39' + ;'
- ' if ( <> '#39#39') then'
-
- ' Cadena := Cadena + '#39' FAX: '#39' + ;'
- ' DatosEmpresa.Lines.Add(Cadena);'
- 'end;'
- ''
- 'procedure NombreEmpresaOnBeforePrint(Sender: TfrxComponent);'
- 'begin'
- ' NombreEmpresa.Lines.Clear;'
- ' NombreEmpresa.Lines.Add();'
- 'end;'
- ''
- 'procedure DireccionEnvioOnBeforePrint(Sender: TfrxComponent);'
- 'var'
- ' ACadena : String;'
- 'begin'
- ' ACadena := '#39#39';'
- ' DireccionEnvio.Lines.Clear;'
- ''
- ' ACadena := '#39#39';'
- ''
- ' DireccionEnvio.Lines.Add();'
- ' if ( <> '#39#39') then'
- ' ACadena := + '#39' '#39';'
- ' if ( <> '#39#39') then'
- ' ACadena := ACadena + ;'
- ''
- ' if (ACadena <> '#39#39') then'
- ' DireccionEnvio.Lines.Add(ACadena);'
- ''
- ' if ( <> '#39#39') then'
- ' DireccionEnvio.Lines.Add();'
- 'end;'
- ''
- 'procedure Memo2OnBeforePrint(Sender: TfrxComponent);'
- 'begin'
- ' Memo2.Lines.Clear;'
- ' if (StrToFloat() < 0) then'
- ' Memo2.Lines.Add('#39'ORDEN DE DEVOLUCI'#211'N'#39')'
- ' else'
- ' Memo2.Lines.Add('#39'ALBAR'#193'N DE CLIENTE'#39')'
- 'end;'
- ''
- 'procedure Memo5OnBeforePrint(Sender: TfrxComponent);'
- 'begin'
- ' if (StrToFloat() < 0) then'
+ ' if Engine.FinalPass then'
' begin'
- ' Memo5.Lines.Clear;'
- ' Memo5.Lines.Add('#39'N'#186' orden:'#39');'
- ' end;'
- 'end;'
- ''
- 'procedure Memo9OnBeforePrint(Sender: TfrxComponent);'
- 'begin'
- ' if (StrToFloat() < 0) then'
- ' begin'
- ' Memo9.Lines.Clear;'
- ' Memo9.Lines.Add('#39'Fecha orden:'#39');'
- ' end;'
- 'end;'
- ''
- 'procedure PageHeader1OnBeforePrint(Sender: TfrxComponent);'
- 'begin'
- ' if not Engine.FinalPass then'
- ' Set('#39'TotalPaginas'#39', ( + 1));'
- ''
- ' if Engine.FinalPass then'
- ' Set('#39'Pagina'#39', ( + 1));'
- 'end;'
- ''
- 'procedure frxReportOnStartReport(Sender: TfrxComponent);'
- 'begin'
- ' Set('#39'Pagina'#39', 0);'
- ' Set('#39'TotalPaginas'#39', 0);'
- 'end;'
- ''
- 'procedure Picture1OnBeforePrint(Sender: TfrxComponent);'
- 'begin'
- ' if then'
- ' begin '
- ' Picture1.Visible := True; '
- ' Picture2.Visible := True; '
- ' Picture3.Visible := True; '
- ' Picture4.Visible := True; '
- ' Picture5.Visible := True; '
- ' Picture6.Visible := True; '
- ' Memo25.Visible := True;'
- ' NombreEmpresa.Visible := False;'
-
- ' DatosEmpresa.Visible := False; ' +
- ' '
- ' end'
- ' else'
- ' begin '
- ' Picture1.Visible := False;'
- ' Picture2.Visible := False;'
- ' Picture3.Visible := False;'
- ' Picture4.Visible := False;'
- ' Picture5.Visible := False;'
- ' Picture6.Visible := False;'
- ' Memo25.Visible := False;'
- ' NombreEmpresa.Visible := True;'
- ' DatosEmpresa.Visible := True; '
- ' end'
- 'end;'
- ''
- 'procedure Memo26OnBeforePrint(Sender: TfrxComponent);'
- 'begin'
-
- ' if and ( <> ' +
- #39#39') then'
-
- ' Memo26.Visible := True ' +
- ' '
- ' else'
- ' Memo26.Visible := False '
- 'end;'
- ''
- 'procedure Memo27OnBeforePrint(Sender: TfrxComponent);'
- 'begin'
-
- ' if and ( <> '#39#39') ' +
- 'then'
-
- ' Memo27.Visible := True ' +
- ' '
- ' else'
- ' Memo27.Visible := False '
- 'end;'
- ''
- 'procedure eImporteUnidadOnBeforePrint(Sender: TfrxComponent);'
- 'begin'
- ' if then'
- ' begin '
- ' eImporteUnidad.Visible := True; '
- ' lImporteUnidad.Visible := True; '
- ' eImporteTotal.Visible := True; '
- ' lImporteTotal.Visible := True; '
- ' ImporteUnidad.Visible := True; '
- ' ImporteTotal.Visible := True; '
- ' end'
- ' else'
- ' begin '
- ' eImporteUnidad.Visible := False; '
- ' lImporteUnidad.Visible := False; '
- ' eImporteTotal.Visible := False; '
- ' lImporteTotal.Visible := False; '
- ' ImporteUnidad.Visible := False; '
- ' ImporteTotal.Visible := False;'
-
- ' eConcepto.Width := eConcepto.Width + ImporteTotal.Width + I' +
- 'mporteUnidad.Width + 10;'
-
- ' Concepto.Width := Concepto.Width + ImporteTotal.Width + Imp' +
- 'orteUnidad.Width; '
- ' end '
+ ' if ( = ) then'
+ ' begin '
+ ' mContinua.Visible := False;'
+ ' end '
+ ' else'
+ ' begin '
+ ' mContinua.Visible := True;'
+ ' end '
+ ' end; '
'end;'
''
'begin'
@@ -3169,4 +3588,246 @@ object RptAlbaranesCliente: TRptAlbaranesCliente
Left = 776
Top = 512
end
+ object frxDBInformeObjetivos: TfrxDBDataset
+ UserName = 'frxDBInformeObjetivos'
+ CloseDataSource = False
+ DataSource = DADSInformeObjetivos
+ BCDToCurrency = False
+ Left = 160
+ Top = 88
+ end
+ object DADSInformeObjetivos: TDADataSource
+ DataSet = tbl_InformeObjetivosMensual.Dataset
+ DataTable = tbl_InformeObjetivosMensual
+ Left = 160
+ Top = 144
+ end
+ object tbl_InformeObjetivosMensual: TDAMemDataTable
+ RemoteUpdatesOptions = []
+ Fields = <
+ item
+ Name = 'ID_AGENTE'
+ DataType = datInteger
+ end
+ item
+ Name = 'AGENTE'
+ DataType = datString
+ Size = 255
+ end
+ item
+ Name = 'ANO'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'MES'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'DESCRIPCION'
+ DataType = datString
+ Size = 20
+ end
+ item
+ Name = 'CANTIDAD_OBJETIVO'
+ DataType = datLargeInt
+ end
+ item
+ Name = 'IMPORTE_OBJETIVO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_CONSEGUIDA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_DEVUELTA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_CONSEGUIDO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_DEVUELTO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_RESULTADO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_RESULTADO'
+ DataType = datCurrency
+ end>
+ Params = <
+ item
+ Name = 'ANO1'
+ Value = ''
+ end
+ item
+ Name = 'ID_EMPRESA'
+ Value = ''
+ end>
+ LogChanges = False
+ StreamingOptions = [soDisableEventsWhileStreaming]
+ RemoteFetchEnabled = False
+ LocalSchema = schReport
+ LocalDataStreamer = DABin2DataStreamer1
+ LogicalName = 'InformeListadoObjetivosMensual'
+ IndexDefs = <>
+ Left = 40
+ Top = 200
+ end
+ object tbl_InformeObjetivosTrimestral: TDAMemDataTable
+ RemoteUpdatesOptions = []
+ Fields = <
+ item
+ Name = 'ID_AGENTE'
+ DataType = datInteger
+ end
+ item
+ Name = 'AGENTE'
+ DataType = datString
+ Size = 255
+ end
+ item
+ Name = 'ANO'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'TRIMESTRE'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'DESCRIPCION'
+ DataType = datString
+ Size = 20
+ end
+ item
+ Name = 'CANTIDAD_OBJETIVO'
+ DataType = datLargeInt
+ end
+ item
+ Name = 'IMPORTE_OBJETIVO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_CONSEGUIDA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_DEVUELTA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_CONSEGUIDO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_DEVUELTO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_RESULTADO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_RESULTADO'
+ DataType = datCurrency
+ end>
+ Params = <
+ item
+ Name = 'ANO1'
+ Value = ''
+ end
+ item
+ Name = 'ID_EMPRESA'
+ Value = ''
+ end>
+ LogChanges = False
+ StreamingOptions = [soDisableEventsWhileStreaming]
+ RemoteFetchEnabled = False
+ LocalSchema = schReport
+ LocalDataStreamer = DABin2DataStreamer1
+ LogicalName = 'InformeListadoObjetivosTrimestral'
+ IndexDefs = <>
+ Left = 168
+ Top = 200
+ end
+ object tbl_InformeObjetivosSemestral: TDAMemDataTable
+ RemoteUpdatesOptions = []
+ Fields = <
+ item
+ Name = 'ID_AGENTE'
+ DataType = datInteger
+ end
+ item
+ Name = 'AGENTE'
+ DataType = datString
+ Size = 255
+ end
+ item
+ Name = 'ANO'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'SEMESTRE'
+ DataType = datSmallInt
+ end
+ item
+ Name = 'DESCRIPCION'
+ DataType = datString
+ Size = 20
+ end
+ item
+ Name = 'CANTIDAD_OBJETIVO'
+ DataType = datLargeInt
+ end
+ item
+ Name = 'IMPORTE_OBJETIVO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_CONSEGUIDA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_DEVUELTA'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_CONSEGUIDO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_DEVUELTO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'CANTIDAD_RESULTADO'
+ DataType = datCurrency
+ end
+ item
+ Name = 'IMPORTE_RESULTADO'
+ DataType = datCurrency
+ end>
+ Params = <
+ item
+ Name = 'ANO1'
+ Value = ''
+ end
+ item
+ Name = 'ID_EMPRESA'
+ Value = ''
+ end>
+ LogChanges = False
+ StreamingOptions = [soDisableEventsWhileStreaming]
+ RemoteFetchEnabled = False
+ LocalSchema = schReport
+ LocalDataStreamer = DABin2DataStreamer1
+ LogicalName = 'InformeListadoObjetivosSemestral'
+ IndexDefs = <>
+ Left = 288
+ Top = 200
+ end
end
diff --git a/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.pas b/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.pas
index ae0b2ca..82f0f6f 100644
--- a/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.pas
+++ b/Source/Modulos/Albaranes de cliente/Reports/uRptAlbaranesCliente_Server.pas
@@ -74,6 +74,11 @@ type
frxDBInformeListadoClientesMayorOrdenesDevResumen: TfrxDBDataset;
DADSInformeListadoClientesMayorOrdenesDevResumen: TDADataSource;
tbl_InformeListadoClientesMayorOrdenesDevResumen: TDAMemDataTable;
+ frxDBInformeObjetivos: TfrxDBDataset;
+ DADSInformeObjetivos: TDADataSource;
+ tbl_InformeObjetivosMensual: TDAMemDataTable;
+ tbl_InformeObjetivosTrimestral: TDAMemDataTable;
+ tbl_InformeObjetivosSemestral: TDAMemDataTable;
schReport: TDASchema;
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
@@ -91,6 +96,8 @@ type
FAno2: Variant;
FIntervalo: Variant;
FListaIDClientes: TIntegerArray;
+ FListaIDAgentes: TIntegerArray;
+ FListaNombresAgentes : TStringList;
FTopN: Integer;
//Genera cada uno de los albaranes a imprimir
@@ -98,6 +105,9 @@ type
procedure PrepararTablaInformeGrafComp(ATabla: TDAMemDataTable);
procedure PrepararTablaResumenInformeGrafComp(ATabla: IDADataset);
+ procedure PrepararTablaInformeObjetivos(ATabla: TDAMemDataTable);
+ procedure IniciarParametrosInforme;
+ procedure RecuperarNombresAgentes;
public
function GenerarEtiquetas(const AID : Integer; withRefCliente: Boolean): Binary;
@@ -107,6 +117,10 @@ type
const VerIncidencias: Boolean): Binary;
function GenerarInformeAlbaranesGrafComp(const IdEmpresa: Integer; const Intervalo: Variant; const Ano1: Variant; const Ano2: Variant; const ListaIDClientes: TIntegerArray; const TopN: Integer; const Serie: Variant): Binary;
+
+ function GenerarInformeObjetivosAgentesAlbaranes(const IdEmpresa: Integer; const Intervalo: Variant; const Ano1: Variant; const Ano2: Variant; const ListaIDAgentes: TIntegerArray; const TopN: Integer): Binary;
+
+
end;
implementation
@@ -114,12 +128,14 @@ implementation
{$R *.dfm}
uses
- uSistemaFunc, uDataModuleServer, schAlbaranesClienteClient_Intf, srvGestorInformes_Impl;
+ uSistemaFunc, uDataModuleServer, schAlbaranesClienteClient_Intf, srvGestorInformes_Impl,
+ DataAbstract4_Intf, uROServer;
const
rptInforme = 'InfAlbaranCliente.fr3';
rptInfEtiquetas = 'InfEtiquetasAlbaranCliente.fr3';
rptInformeListadoAlbaranesClienteGrafComp = 'InformeListadoAlbaranesClienteGrafComp.fr3';
+ rptInformeObjetivosAgentesAlbaranes = 'InformeObjetivosAgentesAlbaranes.fr3';
{ Dataset names for schReport }
ds_InformeCabecera = 'Informe_Cabecera';
@@ -140,12 +156,16 @@ begin
frxDBDetalles.DataSource := DADSDetalles;
frxDBDetalles.CloseDataSource := False;
+
+ FListaNombresAgentes := TStringList.Create;
end;
procedure TRptAlbaranesCliente.DataModuleDestroy(Sender: TObject);
begin
tbl_Cabecera.Active := False;
tbl_Detalles.Active := False;
+
+ FreeANDNIL(FListaNombresAgentes);
end;
procedure TRptAlbaranesCliente.frxReportGetValue(const VarName: string;
@@ -326,6 +346,90 @@ begin
end;
end;
+function TRptAlbaranesCliente.GenerarInformeObjetivosAgentesAlbaranes(
+ const IdEmpresa: Integer; const Intervalo, Ano1, Ano2: Variant;
+ const ListaIDAgentes: TIntegerArray; const TopN: Integer): Binary;
+var
+ AStream: TMemoryStream;
+ AInforme: Variant;
+
+begin
+ FConnection.BeginTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
+
+ AStream := TMemoryStream.Create;
+ try
+ //Inicializamos parametros
+ FIdEmpresa := IdEmpresa;
+ FAno1 := Ano1;
+ FIntervalo := Intervalo;
+
+ if Assigned(FListaIDAgentes) then
+ FListaIDClientes.Free;
+ FListaIDAgentes := ListaIDAgentes;
+
+ //Preparamos la tabla correspondiente y la abrimos para el informe
+ if (FIntervalo = CTE_MENSUAL) then
+ PrepararTablaInformeObjetivos(tbl_InformeObjetivosMensual)
+ else if (FIntervalo = CTE_TRIMESTRAL) then
+ PrepararTablaInformeObjetivos(tbl_InformeObjetivosTrimestral)
+ else
+ PrepararTablaInformeObjetivos(tbl_InformeObjetivosSemestral);
+
+ //Se preparan las tablas del listado resumen del informe
+// PrepararTablaResumenInformeGrafComp(tbl_InformeListadoClientesMayorAlbaranadoResumen);
+// PrepararTablaResumenInformeGrafComp(tbl_InformeListadoClientesMayorIncidenciasResumen);
+// PrepararTablaResumenInformeGrafComp(tbl_InformeListadoClientesMayorOrdenesDevResumen);
+
+ Result := Binary.Create;
+
+ AInforme := DarRutaFichero(DarRutaInformes, rptInformeObjetivosAgentesAlbaranes, IntTostr(FIdEmpresa));
+ if VarIsNull(AInforme) then
+ raise Exception.Create (('Error Servidor: GenerarInformeObjetivosAgentesAlbaranes, no encuentra informe ' + rptInformeObjetivosAgentesAlbaranes));
+
+ frxReport.LoadFromFile(AInforme, True);
+ IniciarParametrosInforme;
+
+ frxReport.PrepareReport(False);
+ frxReport.PreviewPages.SaveToStream(Result);
+
+ finally
+ AStream.Free;
+ FConnection.RollbackTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
+ end;
+end;
+
+procedure TRptAlbaranesCliente.IniciarParametrosInforme;
+var
+ ATextos : TStringList;
+ ACadena : String;
+begin
+ ATextos := TStringList.Create;
+
+ try
+ ACadena := 'Año: ' + FAno1;
+ ATextos.Add(ACadena);
+
+ ACadena := 'Agente: ';
+ if Assigned(FListaIDAgentes) and (FListaIDAgentes.Count > 0) then
+ begin
+ RecuperarNombresAgentes;
+ ACadena := ACadena + FListaNombresAgentes.Text;
+ end
+ else begin
+ ACadena := 'Todos los agentes';
+// if FDesglosado then
+ ACadena := ACadena + ' (desglosados)'
+ end;
+
+ ATextos.Add(ACadena);
+ ACadena := '';
+
+ frxReport.Variables.Variables['TextoParametros'] := ATextos.Text;
+ finally
+ FreeAndNil(ATextos);
+ end;
+end;
+
procedure TRptAlbaranesCliente.PrepararTablaInformeGrafComp(
ATabla: TDAMemDataTable);
begin
@@ -340,6 +444,40 @@ begin
ATabla.Active := True;
end;
+procedure TRptAlbaranesCliente.PrepararTablaInformeObjetivos(ATabla: TDAMemDataTable);
+var
+ Condicion: TDAWhereExpression;
+ i: Integer;
+
+begin
+ if ATabla.Active then
+ ATabla.Active := False;
+
+ // Filtrar el informe por agente
+ if Assigned(FListaIDAgentes) then
+ begin
+ with ATabla.DynamicWhere do
+ begin
+ for i := 0 to FListaIDAgentes.Count - 1 do
+ begin
+
+ // (ID_AGENTE = ID)
+ Condicion := NewBinaryExpression(NewField('OBJETIVOS', 'ID_AGENTE'), NewConstant(FListaIDAgentes.Items[i], datInteger), dboEqual);
+ if IsEmpty then
+ Expression := Condicion
+ else
+ Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
+ end;
+ end;
+ end;
+
+
+ DADSInformeObjetivos.DataTable := ATabla;
+ ATabla.ParamByName('ID_EMPRESA').AsInteger := FIdEmpresa;
+ ATabla.ParamByName('ANO1').AsVariant := FAno1;
+ ATabla.Active := True;
+end;
+
procedure TRptAlbaranesCliente.PrepararTablaResumenInformeGrafComp(ATabla: IDADataset);
begin
if ATabla.Active then
@@ -351,4 +489,94 @@ begin
ATabla.Active := True;
end;
+procedure TRptAlbaranesCliente.RecuperarNombresAgentes;
+var
+ AContactosService : IsrvContactos;
+ Intf : IInterface;
+ AClientID : TGUID;
+
+ ATableNameArray: StringArray;
+ ATableRequestInfoArray: TableRequestInfoArray;
+ ATableRequestInfo: TableRequestInfoV5;
+ AStream: TMemoryStream;
+ ADataTable: TDAMemDataTable;
+ i: Integer;
+ AWhereBuilder : TDAWhereBuilder;
+ ACondicion : TDAWhereExpression;
+begin
+ CreateGUID(AClientID);
+
+ GetClassFactory('srvContactos').CreateInstance(AClientID, Intf);
+
+ if Assigned(Intf) then
+ begin
+ AContactosService := Intf as IsrvContactos;
+
+ ATableNameArray := StringArray.Create;
+ ATableRequestInfoArray := TableRequestInfoArray.Create;
+ AWhereBuilder := TDAWhereBuilder.Create;
+ try
+ ATableNameArray.Add('Agentes');
+ ATableRequestInfo := TableRequestInfoV5.Create;
+
+ with ATableRequestInfo do
+ begin
+ IncludeSchema := True;
+ MaxRecords := -1;
+ UserFilter := '';
+
+ AWhereBuilder.Clear;
+ with AWhereBuilder do
+ for i := 0 to FListaIDAgentes.Count - 1 do
+ begin
+ ACondicion := NewBinaryExpression(
+ NewBinaryExpression(NewField('', 'ID'), NewConstant(FListaIDAgentes[i], datInteger), dboEqual),
+ NewBinaryExpression(NewField('', 'ID_EMPRESA'), NewConstant(FIdEmpresa, datInteger), dboEqual),
+ dboAnd);
+
+ if not AWhereBuilder.IsEmpty then
+ Expression := NewBinaryExpression(Expression, ACondicion, dboOr)
+ else
+ Expression := ACondicion;
+ end;
+
+ WhereClause := AWhereBuilder.ExpressionToXmlNode(AWhereBuilder.Expression);
+ end;
+
+ try
+ ATableRequestInfoArray.Add(ATableRequestInfo);
+ AStream := AContactosService.GetData(ATableNameArray, ATableRequestInfoArray);
+ if Assigned(AStream) then
+ begin
+ ADataTable := TDAMemDataTable.Create(nil);
+ try
+ ADataTable.Name := 'Agentes';
+ ADataTable.LocalDataStreamer := DABin2DataStreamer1;
+ ADataTable.RemoteFetchEnabled := False;
+ DABin2DataStreamer1.ReadDataset(AStream, ADataTable, True);
+
+ ADataTable.Open;
+ FListaNombresAgentes.Clear;
+ for i := 0 to ADataTable.RecordCount - 1 do
+ begin
+ FListaNombresAgentes.Add(ADataTable.FieldByName('NOMBRE').AsString);
+ ADataTable.Next;
+ end;
+
+ finally
+ FreeANDNil(ADataTable);
+ end;
+ end;
+ except
+ on e: Exception do
+ dmServer.EscribirLog(e.Message);
+ end;
+ finally
+ FreeANDNIL(ATableRequestInfoArray);
+ FreeANDNIL(ATableNameArray);
+ FreeANDNIL(AWhereBuilder);
+ end;
+ end;
+end;
+
end.
diff --git a/Source/Modulos/Contactos/Controller/Contactos_controller.dpk b/Source/Modulos/Contactos/Controller/Contactos_controller.dpk
index a2ad358..da7dc11 100644
--- a/Source/Modulos/Contactos/Controller/Contactos_controller.dpk
+++ b/Source/Modulos/Contactos/Controller/Contactos_controller.dpk
@@ -86,6 +86,7 @@ contains
uIEditorElegirPersonaContacto in 'View\uIEditorElegirPersonaContacto.pas',
uAgentesController in 'uAgentesController.pas',
uIEditorAgente in 'View\uIEditorAgente.pas',
- uIEditorAgentes in 'View\uIEditorAgentes.pas';
+ uIEditorAgentes in 'View\uIEditorAgentes.pas',
+ uIEditorElegirAgentes in 'View\uIEditorElegirAgentes.pas';
end.
diff --git a/Source/Modulos/Contactos/Controller/Contactos_controller.dproj b/Source/Modulos/Contactos/Controller/Contactos_controller.dproj
index bad7d4a..00806ec 100644
--- a/Source/Modulos/Contactos/Controller/Contactos_controller.dproj
+++ b/Source/Modulos/Contactos/Controller/Contactos_controller.dproj
@@ -43,12 +43,6 @@
Package
FalseTrueFalseFalseFalseFalseTrueFalse1000FalseFalseFalseFalseFalse308212521.0.0.01.0.0.0
-
-
-
-
-
-
JCL Debug IDE extension
JCL Project Analyzer
JCL Open and Save IDE dialogs with favorite folders
@@ -59,25 +53,6 @@
MainSource
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -91,10 +66,25 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -103,6 +93,7 @@
+
@@ -118,7 +109,11 @@
-
+
+
+
+
+