inherited frmClientesEditor: TfrmClientesEditor
  Caption = 'Editor de Cliente'
  ClientHeight = 680
  ClientWidth = 1073
  OnShow = FormShow
  ExplicitWidth = 1089
  ExplicitHeight = 719
  PixelsPerInch = 96
  TextHeight = 17
  inherited pnlToolbar: TPanel
    Width = 1073
    ExplicitWidth = 1073
    inherited btnAyuda: TBitBtn
      Left = 963
      ExplicitLeft = 963
    end
    inherited btnSalir: TBitBtn
      Left = 1018
      ExplicitLeft = 1018
    end
  end
  inherited pnlMain: TPanel
    Width = 1073
    Height = 515
    ExplicitWidth = 1073
    ExplicitHeight = 515
    inherited pgcDetails: TPageControl
      Width = 1073
      Height = 515
      ExplicitWidth = 1073
      ExplicitHeight = 515
      inherited tsDatosEnvio: TTabSheet
        Caption = 'Datos del Cliente / Sucursales'
        ExplicitWidth = 1065
        ExplicitHeight = 485
        inherited dbgItems: TDBGrid
          Top = 290
          Width = 990
          Height = 195
        end
        inherited pnlSideToolbar: TPanel
          Left = 990
          Top = 290
          Height = 195
          ExplicitLeft = 990
          ExplicitTop = 290
          ExplicitHeight = 195
        end
        inherited pnlHeader: TPanel
          Width = 1065
          Height = 290
          ExplicitWidth = 1065
          ExplicitHeight = 290
          object lblCodigoCliente: TLabel
            Left = 20
            Top = 15
            Width = 82
            Height = 15
            Caption = 'C'#243'digo Cliente:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblNIF: TLabel
            Left = 200
            Top = 15
            Width = 49
            Height = 15
            Caption = 'NIF / CIF:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblNombreFiscal: TLabel
            Left = 20
            Top = 75
            Width = 79
            Height = 15
            Caption = 'Nombre Fiscal:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblNombreComercial: TLabel
            Left = 470
            Top = 75
            Width = 104
            Height = 15
            Caption = 'Nombre Comercial:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblDomicilio: TLabel
            Left = 20
            Top = 125
            Width = 54
            Height = 15
            Caption = 'Domicilio:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblPoblacion: TLabel
            Left = 20
            Top = 175
            Width = 56
            Height = 15
            Caption = 'Poblaci'#243'n:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblCodigoPostal: TLabel
            Left = 280
            Top = 175
            Width = 77
            Height = 15
            Caption = 'C'#243'digo Postal:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblProvincia: TLabel
            Left = 430
            Top = 175
            Width = 52
            Height = 15
            Caption = 'Provincia:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblTelefono: TLabel
            Left = 600
            Top = 175
            Width = 48
            Height = 15
            Caption = 'Tel'#233'fono:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblEmail: TLabel
            Left = 600
            Top = 125
            Width = 32
            Height = 15
            Caption = 'Email:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblCredito: TLabel
            Left = 20
            Top = 230
            Width = 103
            Height = 15
            Caption = 'L'#237'mite Cr'#233'dito ('#226#130#172'):'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblPorcentajeBloqueo: TLabel
            Left = 200
            Top = 230
            Width = 104
            Height = 15
            Caption = '% Margen Bloqueo:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblEanCliente: TLabel
            Left = 600
            Top = 231
            Width = 66
            Height = 15
            Caption = 'EAN Cliente:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblGrupoCliente: TLabel
            Left = 410
            Top = 15
            Width = 92
            Height = 15
            Caption = 'Grupo de Cliente:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object lblFormaPago: TLabel
            Left = 650
            Top = 15
            Width = 83
            Height = 15
            Caption = 'Forma de Pago:'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = []
            ParentFont = False
          end
          object edtCodigoCliente: TEdit
            Left = 20
            Top = 35
            Width = 100
            Height = 25
            TabOrder = 0
          end
          object edtEanCliente: TEdit
            Left = 600
            Top = 252
            Width = 200
            Height = 25
            TabOrder = 15
          end
          object edtNIF: TEdit
            Left = 135
            Top = 35
            Width = 140
            Height = 25
            TabOrder = 1
          end
          object edtNombreFiscal: TEdit
            Left = 20
            Top = 95
            Width = 420
            Height = 25
            TabOrder = 2
          end
          object edtNombreComercial: TEdit
            Left = 470
            Top = 95
            Width = 420
            Height = 25
            TabOrder = 3
          end
          object edtDomicilio: TEdit
            Left = 20
            Top = 145
            Width = 550
            Height = 25
            TabOrder = 4
          end
          object edtPoblacion: TEdit
            Left = 20
            Top = 195
            Width = 230
            Height = 25
            TabOrder = 5
          end
          object edtCodigoPostal: TEdit
            Left = 280
            Top = 195
            Width = 120
            Height = 25
            TabOrder = 6
          end
          object edtProvincia: TEdit
            Left = 430
            Top = 195
            Width = 140
            Height = 25
            TabOrder = 7
          end
          object edtTelefono: TEdit
            Left = 600
            Top = 195
            Width = 200
            Height = 25
            TabOrder = 8
          end
          object edtEmail: TEdit
            Left = 600
            Top = 145
            Width = 290
            Height = 25
            TabOrder = 9
          end
          object chkActivo: TCheckBox
            Left = 290
            Top = 37
            Width = 105
            Height = 17
            Caption = 'Cliente Activo'
            TabOrder = 10
          end
          object edtCredito: TEdit
            Left = 20
            Top = 250
            Width = 150
            Height = 25
            TabOrder = 11
          end
          object edtPorcentajeBloqueo: TEdit
            Left = 200
            Top = 250
            Width = 120
            Height = 25
            TabOrder = 12
          end
          object cbGrupoCliente: TComboBox
            Left = 410
            Top = 35
            Width = 220
            Height = 25
            Style = csDropDownList
            TabOrder = 13
          end
          object cbFormaPago: TComboBox
            Left = 650
            Top = 35
            Width = 240
            Height = 25
            Style = csDropDownList
            TabOrder = 14
          end
          object chkBloquear: TCheckBox
            Left = 352
            Top = 259
            Width = 150
            Height = 17
            Caption = 'Bloquear Cliente'
            TabOrder = 16
          end
          object chkAsegurado: TCheckBox
            Left = 352
            Top = 236
            Width = 160
            Height = 17
            Caption = 'Cliente Asegurado'
            TabOrder = 17
          end
        end
      end
      inherited TsListado: TTabSheet
        ExplicitWidth = 1065
        ExplicitHeight = 485
      end
      object tsProductosSuministrados: TTabSheet
        Caption = 'Productos Suministrados'
        ImageIndex = 2
        object pnlFiltroSuministrados: TPanel
          Left = 0
          Top = 0
          Width = 1065
          Height = 90
          Align = alTop
          BevelOuter = bvNone
          TabOrder = 0
          object rgAgrupacionSuministrados: TRadioGroup
            Tag = 999
            Left = 0
            Top = 0
            Width = 400
            Height = 50
            Align = alLeft
            Caption = 'Agrupaci'#243'n'
            Columns = 3
            ItemIndex = 1
            Items.Strings = (
              'Totales'
              'Por A'#241'o'
              'Por Mes y A'#241'o')
            TabOrder = 0
            OnClick = RefrescarSuministrados
          end
          object chkTodasEmpresasSuministrados: TCheckBox
            Tag = 999
            AlignWithMargins = True
            Left = 420
            Top = 15
            Width = 300
            Height = 32
            Margins.Left = 20
            Margins.Top = 15
            Align = alLeft
            Caption = 'Mostrar todas las empresas (Agrupado por empresa)'
            TabOrder = 1
            OnClick = RefrescarSuministrados
          end
          object pnlFiltroSuministradosSub: TPanel
            Left = 0
            Top = 50
            Width = 1065
            Height = 40
            Align = alBottom
            BevelOuter = bvNone
            TabOrder = 2
            object lblFiltroFamilia: TLabel
              Left = 10
              Top = 12
              Width = 43
              Height = 17
              Caption = 'Familia:'
            end
            object lblFiltroDescripcion: TLabel
              Left = 230
              Top = 12
              Width = 71
              Height = 17
              Caption = 'Descripci'#243'n:'
            end
            object lblTotalesSeleccion: TLabel
              Left = 620
              Top = 12
              Width = 275
              Height = 15
              Caption = 'Seleccionados: 0 | Cantidad: 0,00 | Importe: 0,00 '#8364
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -12
              Font.Name = 'Segoe UI'
              Font.Style = [fsBold]
              ParentFont = False
            end
            object cbbFiltroFamilia: TComboBox
              Tag = 999
              Left = 60
              Top = 8
              Width = 150
              Height = 25
              Style = csDropDownList
              TabOrder = 0
              OnChange = RefrescarSuministrados
            end
            object edtFiltroDescripcion: TEdit
              Tag = 999
              Left = 300
              Top = 8
              Width = 200
              Height = 25
              TabOrder = 1
              OnKeyPress = RefrescarSuministradosKeyPress
            end
            object btnFiltrarSuministrados: TButton
              Left = 520
              Top = 6
              Width = 80
              Height = 27
              Caption = 'Filtrar'
              TabOrder = 2
              OnClick = RefrescarSuministrados
            end
          end
        end
        object dbgProductosSuministrados: TDBGrid
          Left = 0
          Top = 90
          Width = 1065
          Height = 395
          Align = alClient
          DataSource = dsProductosSuministrados
          Options = [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit, dgMultiSelect, dgTitleClick, dgTitleHotTrack]
          ReadOnly = True
          TabOrder = 1
          TitleFont.Charset = DEFAULT_CHARSET
          TitleFont.Color = clWindowText
          TitleFont.Height = -13
          TitleFont.Name = 'Segoe UI'
          TitleFont.Style = []
        end
      end
      object tsDocumentosRelacionados: TTabSheet
        Caption = 'Documentos Relacionados'
        ImageIndex = 3
        object pnlFiltroDocs: TPanel
          Left = 0
          Top = 0
          Width = 1065
          Height = 80
          Align = alTop
          BevelOuter = bvNone
          TabOrder = 0
          object lblFiltroTipoDoc: TLabel
            Left = 10
            Top = 12
            Width = 56
            Height = 17
            Caption = 'Tipo Doc:'
          end
          object lblFiltroDocEjercicio: TLabel
            Left = 235
            Top = 12
            Width = 51
            Height = 17
            Caption = 'Ejercicio:'
          end
          object lblFiltroDocTexto: TLabel
            Left = 565
            Top = 12
            Width = 41
            Height = 17
            Caption = 'Buscar:'
          end
          object cbbFiltroTipoDoc: TComboBox
            Tag = 999
            Left = 70
            Top = 8
            Width = 150
            Height = 25
            Style = csDropDownList
            ItemIndex = 0
            TabOrder = 0
            Text = '[Todos]'
            OnChange = RefrescarDocumentosRelacionados
            Items.Strings = (
              '[Todos]'
              'Presupuestos'
              'Pedidos'
              'Albaranes'
              'Facturas'
              'Env'#237'os / Recogidas')
          end
          object cbbFiltroDocEjercicio: TComboBox
            Tag = 999
            Left = 290
            Top = 8
            Width = 95
            Height = 25
            Style = csDropDownList
            ItemIndex = 0
            TabOrder = 1
            Text = '[Todos]'
            OnChange = RefrescarDocumentosRelacionados
            Items.Strings = (
              '[Todos]')
          end
          object chkTodasEmpresasDocs: TCheckBox
            Tag = 999
            Left = 400
            Top = 11
            Width = 150
            Height = 17
            Caption = 'Todas las empresas'
            TabOrder = 2
            OnClick = RefrescarDocumentosRelacionados
          end
          object edtFiltroDocTexto: TEdit
            Tag = 999
            Left = 615
            Top = 8
            Width = 140
            Height = 25
            TabOrder = 3
            OnKeyPress = RefrescarDocumentosKeyPress
          end
          object btnFiltrarDocs: TButton
            Left = 765
            Top = 6
            Width = 70
            Height = 27
            Caption = 'Filtrar'
            TabOrder = 4
            OnClick = RefrescarDocumentosRelacionados
          end
          object btnAbrirDoc: TButton
            Left = 845
            Top = 6
            Width = 95
            Height = 27
            Caption = 'Abrir Doc'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -12
            Font.Name = 'Segoe UI'
            Font.Style = [fsBold]
            ParentFont = False
            TabOrder = 5
            OnClick = btnAbrirDocClick
          end
          object btnTrazabilidadDoc: TButton
            Left = 950
            Top = 6
            Width = 105
            Height = 27
            Caption = 'Trazabilidad'
            TabOrder = 6
            OnClick = btnTrazabilidadDocClick
          end
          object pnlFiltroDocsSub: TPanel
            Left = 0
            Top = 48
            Width = 1065
            Height = 32
            Align = alBottom
            BevelOuter = bvNone
            TabOrder = 7
            object lblResumenDocs: TLabel
              Left = 10
              Top = 6
              Width = 380
              Height = 15
              Caption = 
                'Total Documentos: 0 | Base Acumulada: 0,00 '#8364' | Importe Total: 0,' +
                '00 '#8364
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -12
              Font.Name = 'Segoe UI'
              Font.Style = [fsBold]
              ParentFont = False
            end
          end
        end
        object dbgDocumentosRelacionados: TDBGrid
          Left = 0
          Top = 80
          Width = 1065
          Height = 405
          Align = alClient
          DataSource = dsDocumentosRelacionados
          Options = [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit, dgTitleClick, dgTitleHotTrack]
          ReadOnly = True
          TabOrder = 1
          TitleFont.Charset = DEFAULT_CHARSET
          TitleFont.Color = clWindowText
          TitleFont.Height = -13
          TitleFont.Name = 'Segoe UI'
          TitleFont.Style = []
          OnDblClick = dbgDocumentosRelacionadosDblClick
          OnTitleClick = dbgDocumentosRelacionadosTitleClick
        end
      end
    end
  end
  inherited pnlFooter: TPanel
    Top = 580
    Width = 1073
    ExplicitTop = 580
    ExplicitWidth = 1073
  end
  object qryDestinos: TFDQuery
    Connection = dmgMain.dbConn
    SQL.Strings = (
      'SELECT id, id_cliente, descripcion, direccion, poblacion, cp, '
      'provincia, pais, activo '
      'FROM ge_clientes_destinos '
      'WHERE id_cliente = :id_cliente')
    Left = 320
    Top = 340
    ParamData = <
      item
        Name = 'ID_CLIENTE'
        DataType = ftString
        ParamType = ptInput
      end>
  end
  object dsDestinos: TDataSource
    DataSet = qryDestinos
    Left = 400
    Top = 340
  end
  object qryProductosSuministrados: TFDQuery
    Connection = dmgMain.dbConn
    SQL.Strings = (
      'SELECT '
      '  MAX(codigo) AS codigo,'
      '  descripcion,'
      '  periodo,'
      '  SUM(cantidad) AS cantidad,'
      
        '  SUM(cantidad * precio_neto) / NULLIF(SUM(cantidad), 0) AS prec' +
        'io_medio,'
      '  MAX(fecha) AS ultima_fecha'
      'FROM ('
      '  SELECT '
      
        '    CONVERT(COALESCE(al.articulo_codigo, '#39#39') USING utf8mb4) COLL' +
        'ATE utf8mb4_general_ci AS codigo,'
      
        '    CONVERT(COALESCE(al.descripcion, '#39#39') USING utf8mb4) COLLATE ' +
        'utf8mb4_general_ci AS descripcion,'
      '    al.cantidad AS cantidad,'
      
        '    (al.precio - COALESCE(al.descuento_precio, 0)) AS precio_net' +
        'o,'
      '    a.fecha AS fecha,'
      
        '    CONVERT(DATE_FORMAT(a.fecha, '#39'%Y-%m'#39') USING utf8mb4) COLLATE' +
        ' utf8mb4_general_ci AS periodo_orden,'
      
        '    CONVERT(DATE_FORMAT(a.fecha, '#39'%m/%Y'#39') USING utf8mb4) COLLATE' +
        ' utf8mb4_general_ci AS periodo'
      '  FROM ge_albaranes_lineas al'
      '  INNER JOIN ge_albaranes a ON al.albaran_id = a.id'
      
        '  WHERE a.cliente_id = :cliente_id AND a.empresa_id = :empresa_i' +
        'd'
      '  '
      '  UNION ALL'
      '  '
      '  SELECT '
      
        '    CONVERT(COALESCE(fl.articulo_codigo, '#39#39') USING utf8mb4) COLL' +
        'ATE utf8mb4_general_ci AS codigo,'
      
        '    CONVERT(COALESCE(fl.descripcion, '#39#39') USING utf8mb4) COLLATE ' +
        'utf8mb4_general_ci AS descripcion,'
      '    fl.cantidad AS cantidad,'
      '    (fl.precio - COALESCE(fl.descuento_cant, 0)) AS precio_neto,'
      '    f.fecha AS fecha,'
      
        '    CONVERT(DATE_FORMAT(f.fecha, '#39'%Y-%m'#39') USING utf8mb4) COLLATE' +
        ' utf8mb4_general_ci AS periodo_orden,'
      
        '    CONVERT(DATE_FORMAT(f.fecha, '#39'%m/%Y'#39') USING utf8mb4) COLLATE' +
        ' utf8mb4_general_ci AS periodo'
      '  FROM ge_facturas_lineas fl'
      '  INNER JOIN ge_facturas f ON fl.factura_id = f.id'
      
        '  WHERE f.cliente_id = :cliente_id AND f.empresa_id = :empresa_i' +
        'd'
      ') temp'
      'GROUP BY descripcion, periodo, periodo_orden'
      'ORDER BY periodo_orden DESC, descripcion ASC')
    Left = 480
    Top = 340
    ParamData = <
      item
        Name = 'CLIENTE_ID'
        DataType = ftString
        ParamType = ptInput
      end
      item
        Name = 'EMPRESA_ID'
        DataType = ftString
        ParamType = ptInput
      end>
  end
  object dsProductosSuministrados: TDataSource
    DataSet = qryProductosSuministrados
    Left = 560
    Top = 340
  end
  object qryDocumentosRelacionados: TFDQuery
    Connection = dmgMain.dbConn
    Left = 640
    Top = 340
  end
  object dsDocumentosRelacionados: TDataSource
    DataSet = qryDocumentosRelacionados
    Left = 720
    Top = 340
  end
end
