unit uViewCalendarioConFiltro;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewCalendarioBase, Menus, cxStyles, cxGraphics, cxEdit,
  cxScheduler, cxSchedulerStorage, cxSchedulerCustomControls,
  cxSchedulerCustomResourceView, cxSchedulerDayView,
  cxSchedulerDateNavigator, cxSchedulerTimeGridView, cxSchedulerUtils,
  cxSchedulerWeekView, cxSchedulerYearView, dxPrnDev, dxPSGlbl, dxPSUtl,
  dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPSCompsProvider, dxPSFillPatterns,
  dxPSEdgePatterns, cxContainer, cxCheckListBox, ExtCtrls,
  dxPSCore, dxPScxCommon, dxPScxScheduler2Lnk, dxPrnDlg,
  cxSchedulerDBStorage, ActnList, cxControls, JvAppStorage,
  JvAppRegistryStorage, JvComponentBase, JvFormPlacement, TB2Item, TBX,
  TB2Dock, TB2Toolbar, DB, uDADataTable, ImgList;

type
  IViewCalendarioConFiltro = interface(IViewCalendarioBase)
  ['{636C30A6-74A9-4B6D-A68A-2B26DE208A7F}']
    function getResources: TcxCheckListBox;
    property Resources: TcxCheckListBox read getResources;
  end;

  TfrViewCalendarioConFiltro = class(TfrViewCalendarioBase, IViewCalendarioConFiltro)
    pnlVendedores: TPanel;
    cxResources: TcxCheckListBox;
    Panel2: TPanel;
    tbxMain: TTBXToolbar;
    TBXItem5: TTBXItem;
    ImageList1: TImageList;
    procedure cxResourcesEditValueChanged(Sender: TObject);
    procedure cxSchedulerInitEventImages(Sender: TcxCustomScheduler;
      AEvent: TcxSchedulerControlEvent; AImages: TcxSchedulerEventImages);
  protected
    function getResources: TcxCheckListBox;
  public
    property Resources: TcxCheckListBox read getResources;

  public
    constructor Create(AOwner : TComponent); override;
  end;

var
  frViewCalendarioConFiltro: TfrViewCalendarioConFiltro;

implementation

{$R *.dfm}

procedure TfrViewCalendarioConFiltro.cxResourcesEditValueChanged(Sender: TObject);
var
  AIndex: Integer;
begin
  AIndex := cxResources.ItemIndex;

  if AIndex < 0 then
    Exit;
  with cxResources.Items[AIndex] do
       TcxSchedulerStorageResourceItem(ItemObject).Visible := Checked;

  if cxScheduler.Storage.Resources.ResourceItems.VisibleResourceCount = 0 then
  begin
    cxResources.Items[AIndex].Checked := True;
    Exit;
  end;
end;

procedure TfrViewCalendarioConFiltro.cxSchedulerInitEventImages(
  Sender: TcxCustomScheduler; AEvent: TcxSchedulerControlEvent;
  AImages: TcxSchedulerEventImages);
begin
  inherited;
  if not cxScheduler.ViewWeeks.Active then
    if AEvent.LabelColor = EventLabelColors[6] then
       AImages.Add(0);
end;

constructor TfrViewCalendarioConFiltro.Create(AOwner: TComponent);
begin
  inherited;
  {
  dsCitas.DataSet := TablaCitas;
  dsVendedores.DataSet := TablaVendedores;

  with TablaCitas do
  begin
    Database := dmBaseDatos.BD;
    Transaction := dmBaseDatos.Transaccion;
    SelectSQL.Assign(dmTablaCitas.sqlConsultar);
    SelectSQL.Add('WHERE TIPOTAREA = ''' + TextoTipoCita[Ord(tcMedicion)] + '''');
    InsertSQL.Assign(dmTablaCitas.sqlInsertar);
    ModifySQL.Assign(dmTablaCitas.sqlModificar);
    DeleteSQL.Assign(dmTablaCitas.sqlEliminar);
    RefreshSQL.Assign(dmTablaCitas.sqlRefrescar);
    RefreshSQL.Add('and TIPOTAREA = ''' + TextoTipoCita[Ord(tcMedicion)]  + '''');

    BeforePost := TablaCitasBeforePost;
    AfterPost := TablaCitasAfterPost;
    Prepare;
  end;

  with TablaVendedores do
  begin
    Database := dmBaseDatos.BD;
    Transaction := dmBaseDatos.Transaccion;
    SelectSQL.Add('select * from VENDEDORES');
    Prepare;
  end;
}
end;

function TfrViewCalendarioConFiltro.getResources: TcxCheckListBox;
begin
  Result := cxResources;
end;

end.
