git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@690 f4e31baf-9722-1c47-927c-6f952f962d4b
405 lines
14 KiB
ObjectPascal
405 lines
14 KiB
ObjectPascal
unit uViewPresupuestosCliente;
|
||
|
||
interface
|
||
|
||
uses
|
||
uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
||
cxData, cxDataStorage, cxEdit, DB, cxDBData, dxPSGlbl, dxPSUtl, dxPSEngn,
|
||
dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
|
||
dxPSEdgePatterns, cxImageComboBox, ImgList, Controls, PngImageList,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, dxPSCore, dxPScxCommon, dxPScxGrid6Lnk,
|
||
uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView, Classes,
|
||
cxGrid, uBizPresupuestosCliente, cxCurrencyEdit, Forms, uViewFiltroBase, ActnList, TB2Item,
|
||
TBX, TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, uDAInterfaces, Windows,
|
||
uCustomView, uViewBase, cxTextEdit, cxCalendar;
|
||
|
||
type
|
||
IViewPresupuestosCliente = interface(IViewGrid)
|
||
['{96821714-55CF-4BC1-A0C1-16E027B2EF16}']
|
||
function GetPresupuestos: IBizPresupuestoCliente;
|
||
procedure SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
property Presupuestos: IBizPresupuestoCliente read GetPresupuestos write SetPresupuestos;
|
||
end;
|
||
|
||
TfrViewPresupuestosCliente = class(TfrViewGrid, IViewPresupuestosCliente)
|
||
cxGridViewREFERENCIA: TcxGridDBColumn;
|
||
cxGridViewINCIDENCIASACTIVAS: TcxGridDBColumn;
|
||
cxGridViewNOMBRE: TcxGridDBColumn;
|
||
cxGridViewSITUACION: TcxGridDBColumn;
|
||
cxGridViewFECHA_PRESUPUESTO: TcxGridDBColumn;
|
||
cxGridViewCONTRATO: TcxGridDBColumn;
|
||
cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
|
||
cxGridLevelPendientes: TcxGridLevel;
|
||
cxGridLevelEnProceso: TcxGridLevel;
|
||
cxGridLevelServidor: TcxGridLevel;
|
||
cxStylePENDIENTES: TcxStyle;
|
||
cxStyleACEPTADO: TcxStyle;
|
||
actCliente: TAction;
|
||
actProvincia: TAction;
|
||
TBXItem2: TTBXItem;
|
||
TBXSeparatorItem1: TTBXSeparatorItem;
|
||
TBXSeparatorItem2: TTBXSeparatorItem;
|
||
TBXItem3: TTBXItem;
|
||
cxGridViewFECHA_DECISION: TcxGridDBColumn;
|
||
cxGridViewNIF_CIF: TcxGridDBColumn;
|
||
cxGridViewINCIDENCIAS: TcxGridDBColumn;
|
||
cxStyleRECHAZADO: TcxStyle;
|
||
cxGridViewTIPO: TcxGridDBColumn;
|
||
cxGridViewColumn1: TcxGridDBColumn;
|
||
cxGridViewLISTA_NOMBRES: TcxGridDBColumn;
|
||
cxGridViewVENDEDOR: TcxGridDBColumn;
|
||
cxGridViewBASE_IMPONIBLE: TcxGridDBColumn;
|
||
cxGridViewIMPORTE_IVA: TcxGridDBColumn;
|
||
cxGridViewTIENDA: TcxGridDBColumn;
|
||
actTienda: TAction;
|
||
TBXItem4: TTBXItem;
|
||
TBXSeparatorItem3: TTBXSeparatorItem;
|
||
cxGridViewFECHA_ULT_PRESENTACION_CLIENTE: TcxGridDBColumn;
|
||
cxGridPlantillas: TcxGridLevel;
|
||
cxStylePLANTILLA: TcxStyle;
|
||
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel:
|
||
TcxGridLevel);
|
||
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
|
||
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out
|
||
AStyle: TcxStyle);
|
||
procedure actClienteExecute(Sender: TObject);
|
||
procedure actClienteUpdate(Sender: TObject);
|
||
procedure actProvinciaExecute(Sender: TObject);
|
||
procedure actProvinciaUpdate(Sender: TObject);
|
||
procedure cxGridViewICONOCustomDrawCell(Sender: TcxCustomGridTableView;
|
||
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
|
||
var ADone: Boolean);
|
||
procedure cxGridViewINCIDENCIASACTIVASGetCellHint(
|
||
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; const AMousePos: TPoint;
|
||
var AHintText: TCaption; var AIsHintMultiLine: Boolean;
|
||
var AHintTextRect: TRect);
|
||
procedure cxGridViewDataControllerCompare(
|
||
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
|
||
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
|
||
procedure OnFiltroListaPropertiesChange(Sender: TObject);
|
||
procedure OnFiltroListaPropertiesInitPopup(Sender: TObject);
|
||
procedure CustomViewDestroy(Sender: TObject);
|
||
procedure CustomViewShow(Sender: TObject);
|
||
procedure actTiendaExecute(Sender: TObject);
|
||
procedure actTiendaUpdate(Sender: TObject);
|
||
|
||
private
|
||
//Filtros relativos a la vista
|
||
procedure AnadirFiltroSituaciones;
|
||
procedure AnadirFiltroFechas;
|
||
// procedure AnadirFiltroFacturado;
|
||
|
||
protected
|
||
FPresupuestos: IBizPresupuestoCliente;
|
||
function GetPresupuestos: IBizPresupuestoCliente;
|
||
procedure SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
public
|
||
procedure AnadirOtrosFiltros; override;
|
||
procedure ConfigView; override;
|
||
property Presupuestos: IBizPresupuestoCliente read GetPresupuestos write SetPresupuestos;
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
SysUtils, variants, uDataModulePresupuestosCliente, schPresupuestosClienteClient_Intf,
|
||
uViewGridBase, uFactuGES_App,
|
||
//uReferenciasUtils,
|
||
cxVariants;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrViewPresupuestosCliente.actClienteExecute(Sender: TObject);
|
||
begin
|
||
if (cxGridViewNOMBRE.GroupIndex < 0) then
|
||
begin
|
||
cxGridViewNOMBRE.GroupIndex := cxGridView.GroupedColumnCount;
|
||
cxGridViewNOMBRE.Visible := False;
|
||
end
|
||
else
|
||
begin
|
||
cxGridViewNOMBRE.GroupIndex := -1;
|
||
cxGridViewNOMBRE.Visible := True;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actClienteUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Checked := not (cxGridViewNOMBRE.GroupIndex < 0);
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actProvinciaExecute(Sender: TObject);
|
||
begin
|
||
{
|
||
if (cxGridViewPROVINCIA.GroupIndex < 0) then
|
||
begin
|
||
cxGridViewPROVINCIA.GroupIndex := cxGridView.GroupedColumnCount;
|
||
cxGridViewPROVINCIA.Visible := False;
|
||
end
|
||
else
|
||
begin
|
||
cxGridViewPROVINCIA.GroupIndex := -1;
|
||
cxGridViewPROVINCIA.Visible := True;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actProvinciaUpdate(Sender: TObject);
|
||
begin
|
||
{
|
||
inherited;
|
||
(Sender as TAction).Checked := not (cxGridViewPROVINCIA.GroupIndex < 0);
|
||
}
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actTiendaExecute(Sender: TObject);
|
||
begin
|
||
if (cxGridViewTIENDA.GroupIndex < 0) then
|
||
begin
|
||
cxGridViewTIENDA.GroupIndex := cxGridView.GroupedColumnCount;
|
||
cxGridViewTIENDA.Visible := False;
|
||
end
|
||
else
|
||
begin
|
||
cxGridViewTIENDA.GroupIndex := -1;
|
||
cxGridViewTIENDA.Visible := True;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actTiendaUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Checked := not (cxGridViewTIENDA.GroupIndex < 0);
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.AnadirFiltroFechas;
|
||
var
|
||
Columna: TcxGridDBColumn;
|
||
Fecha1, Fecha2: Variant;
|
||
FFiltro : TcxFilterCriteriaItemList;
|
||
begin
|
||
Fecha1 := frViewFiltroBase1.edtFechaIniFiltro.EditValue;
|
||
Fecha2 := frViewFiltroBase1.edtFechaFinFiltro.EditValue;
|
||
|
||
if not VarIsNull(Fecha1)
|
||
and not VarIsNull(Fecha2) then
|
||
begin
|
||
cxGridView.DataController.Filter.Options := [fcoCaseInsensitive, fcoSoftCompare];
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
|
||
Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHA_Presupuesto');
|
||
FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
||
end;
|
||
end;
|
||
|
||
{procedure TfrViewPresupuestosCliente.AnadirFiltroFacturado;
|
||
var
|
||
FFiltro : TcxFilterCriteriaItemList;
|
||
begin
|
||
//Solo se aplica este filtro en el caso de tener activo el panel de detalle de filtro
|
||
//y sobre la lista de articulos detallada por proveedor
|
||
if frViewFiltroBase1.Visible then
|
||
begin
|
||
case frViewFiltroBase1.eLista.ItemIndex of
|
||
//Sin facturar
|
||
1 : begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
FFiltro.AddItem(cxGridViewFACTURA, foEqual, NULL, 'NoFacturado');
|
||
end;
|
||
|
||
//Facturados
|
||
2: begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
FFiltro.AddItem(cxGridViewFACTURA, foNotEqual, NULL, 'Facturado');
|
||
end;
|
||
end;
|
||
end;
|
||
end;}
|
||
|
||
procedure TfrViewPresupuestosCliente.AnadirFiltroSituaciones;
|
||
var
|
||
FFiltro : TcxFilterCriteriaItemList;
|
||
begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
|
||
case cxGrid.ActiveLevel.Index of
|
||
0 : FFiltro.AddItem(cxGridViewSITUACION, foNotEqual, SITUACION_PRESUPUESTO_PLANTILLA, SITUACION_PRESUPUESTO_PLANTILLA);
|
||
1 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PRESUPUESTO_PENDIENTE, SITUACION_PRESUPUESTO_PENDIENTE);
|
||
2 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PRESUPUESTO_ACEPTADO, SITUACION_PRESUPUESTO_ACEPTADO);
|
||
3 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PRESUPUESTO_ANULADO, SITUACION_PRESUPUESTO_ANULADO);
|
||
4 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PRESUPUESTO_PLANTILLA, SITUACION_PRESUPUESTO_PLANTILLA);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.AnadirOtrosFiltros;
|
||
begin
|
||
inherited;
|
||
|
||
AnadirFiltroSituaciones;
|
||
AnadirFiltroFechas;
|
||
// AnadirFiltroFacturado;
|
||
|
||
//Finalmente activamos el filtro si tenemos algo
|
||
if cxGridView.DataController.Filter.IsEmpty then
|
||
cxGridView.DataController.Filter.Active := False
|
||
else
|
||
cxGridView.DataController.Filter.Active := True;
|
||
cxGrid.ActiveLevel.GridView := cxGridView;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.ConfigView;
|
||
begin
|
||
inherited;
|
||
//Para que nos filtre la pesta<74>a todas y quite las facturas proforma
|
||
AnadirOtrosFiltros;
|
||
|
||
//FILTRO DE EMPRESAS
|
||
if (AppFactuGES.EmpresaActiva.ID = CTE_EMPRESA_ALISO) then
|
||
begin
|
||
cxGridViewTIENDA.Visible := True;
|
||
cxGridViewTIENDA.VisibleForCustomization := True;
|
||
|
||
actTienda.Visible := True;
|
||
end
|
||
else
|
||
begin
|
||
cxGridViewTIENDA.Visible := False;
|
||
cxGridViewTIENDA.VisibleForCustomization := False;
|
||
|
||
actTienda.Visible := False;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.CustomViewDestroy(Sender: TObject);
|
||
begin
|
||
// frViewFiltroBase1.eLista.Properties.OnChange := Nil;
|
||
// frViewFiltroBase1.eLista.Properties.OnInitPopup := Nil;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.CustomViewShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
// frViewFiltroBase1.eLista.Properties.OnChange := OnFiltroListaPropertiesChange;
|
||
// frViewFiltroBase1.eLista.Properties.OnInitPopup := OnFiltroListaPropertiesInitPopup;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
||
begin
|
||
inherited;
|
||
RefrescarFiltro;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridViewDataControllerCompare(
|
||
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
|
||
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
|
||
begin
|
||
inherited;
|
||
{
|
||
if (AItemIndex = cxGridViewREFERENCIA.Index) and
|
||
(VarType(V1) = VarType(V2)) and (VarType(V1) = varString) then
|
||
Compare := CompararReferencias(V1, V2)
|
||
else
|
||
Compare := VarCompare(V1, V2);
|
||
}
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridViewICONOCustomDrawCell(
|
||
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
||
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
{var
|
||
R : TRect;}
|
||
begin
|
||
inherited;
|
||
{ R := AViewInfo.ContentBounds;
|
||
ACanvas.FillRect(R);
|
||
|
||
if (cxGridView.DataController.DisplayTexts[AViewInfo.GridRecord.RecordIndex,
|
||
cxGridViewINCIDENCIASACTIVAS.Index] = 'Sin incidencias') then
|
||
ACanvas.DrawImage(GridPNGImageList, R.Left + 2, R.Top + 2, 1)
|
||
else
|
||
ACanvas.DrawImage(GridPNGImageList, R.Left + 2, R.Top + 2, 2);
|
||
ADone := True;}
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridViewINCIDENCIASACTIVASGetCellHint(
|
||
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; const AMousePos: TPoint;
|
||
var AHintText: TCaption; var AIsHintMultiLine: Boolean;
|
||
var AHintTextRect: TRect);
|
||
begin
|
||
inherited;
|
||
if (ARecord.DisplayTexts[Sender.Index] <> 'Sin incidencias') then
|
||
begin
|
||
AIsHintMultiLine := True;
|
||
if not VarIsNull(ARecord.Values[cxGridViewINCIDENCIAS.Index]) then
|
||
AHintText := ARecord.Values[cxGridViewINCIDENCIAS.Index];
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridViewStylesGetContentStyle(Sender:
|
||
TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem:
|
||
TcxCustomGridTableItem; out AStyle: TcxStyle);
|
||
var
|
||
IndiceCol: Integer;
|
||
ASituacion: string;
|
||
begin
|
||
inherited;
|
||
if Assigned(ARecord) then
|
||
begin
|
||
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_PresupuestosClienteSITUACION).Index;
|
||
ASituacion := VarToStr(ARecord.DisplayTexts[IndiceCol]);
|
||
if ASituacion = SITUACION_PRESUPUESTO_PENDIENTE then
|
||
AStyle.TextColor := cxStylePENDIENTES.TextColor
|
||
else if ASituacion = SITUACION_PRESUPUESTO_ACEPTADO then
|
||
AStyle.TextColor := cxStyleACEPTADO.TextColor
|
||
else if ASituacion = SITUACION_PRESUPUESTO_ANULADO then
|
||
AStyle.TextColor := cxStyleRECHAZADO.TextColor
|
||
else if ASituacion = SITUACION_PRESUPUESTO_PLANTILLA then
|
||
AStyle.TextColor := cxStylePLANTILLA.TextColor
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.OnFiltroListaPropertiesChange(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
RefrescarFiltro;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.OnFiltroListaPropertiesInitPopup(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
{
|
||
with frViewFiltroBase1.eLista.Properties.Items do
|
||
begin
|
||
BeginUpdate;
|
||
try
|
||
Clear;
|
||
Add('Todos'); //Case 0
|
||
Add('Sin facturar'); //Case 1
|
||
Add('Facturados'); //Case 2
|
||
frViewFiltroBase1.eLista.ItemIndex := 0;
|
||
finally
|
||
EndUpdate;
|
||
end;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
function TfrViewPresupuestosCliente.GetPresupuestos: IBizPresupuestoCliente;
|
||
begin
|
||
Result := FPresupuestos;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
begin
|
||
FPresupuestos := Value;
|
||
if Assigned(FPresupuestos) then
|
||
dsDataSource.DataTable := FPresupuestos.DataTable;
|
||
end;
|
||
|
||
end.
|