You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1448 lines
41 KiB
1448 lines
41 KiB
unit ufrmCentralPlanilhamento;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, StrUtils, System.win.ComObj, System.UITypes,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstMaster, Data.DB, ZAbstractRODataset,
|
|
ZDataset, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls, Vcl.CheckLst, Vcl.Grids,
|
|
Vcl.DBGrids, Vcl.Menus, Vcl.DBCtrls;
|
|
|
|
type
|
|
TfrmCentralPlanilhamento = class(TmstMaster)
|
|
dbgrd_pesquisa: TDBGrid;
|
|
sbx_filtro: TScrollBox;
|
|
pnl_providências: TPanel;
|
|
Label5: TLabel;
|
|
Label6: TLabel;
|
|
cb_providencias: TCheckBox;
|
|
clb_providencias: TCheckListBox;
|
|
pnl_filtroprov: TPanel;
|
|
rg_filtroprov: TRadioGroup;
|
|
dtp_provin: TDateTimePicker;
|
|
dtp_provfim: TDateTimePicker;
|
|
cb_periodoprov: TCheckBox;
|
|
cb_bacalhau: TCheckBox;
|
|
edt_pprov: TEdit;
|
|
pnl_beneficiarios: TPanel;
|
|
Label11: TLabel;
|
|
Label12: TLabel;
|
|
Label13: TLabel;
|
|
Label14: TLabel;
|
|
cb_beneficiarios: TCheckBox;
|
|
clb_beneficiarios: TCheckListBox;
|
|
edt_pcredor: TEdit;
|
|
cb_credorentrada: TCheckBox;
|
|
dtp_credorentrada1: TDateTimePicker;
|
|
dtp_credorentrada2: TDateTimePicker;
|
|
cb_credorvencimento: TCheckBox;
|
|
dtp_credorvenc1: TDateTimePicker;
|
|
dtp_credorvenc2: TDateTimePicker;
|
|
cb_credortptitulo: TCheckBox;
|
|
Panel3: TPanel;
|
|
rg_credortptitulo: TRadioGroup;
|
|
pnl_agendamento: TPanel;
|
|
lbl_agendcomeco: TLabel;
|
|
lbl_agendfim: TLabel;
|
|
cb_agendamento: TCheckBox;
|
|
dtp_agendcomeco: TDateTimePicker;
|
|
dtp_agendfim: TDateTimePicker;
|
|
pnl_alfabeto: TPanel;
|
|
Label7: TLabel;
|
|
Label8: TLabel;
|
|
cb_faixanome: TCheckBox;
|
|
edt_nomein: TEdit;
|
|
edt_nomefim: TEdit;
|
|
pnl_atraso: TPanel;
|
|
Label9: TLabel;
|
|
Label10: TLabel;
|
|
cb_atraso: TCheckBox;
|
|
edt_atrasoin: TEdit;
|
|
edt_atrasofim: TEdit;
|
|
pnl_tipopessoa: TPanel;
|
|
cb_tipopessoa: TCheckBox;
|
|
Panel1: TPanel;
|
|
rg_tipopessoa: TRadioGroup;
|
|
btn_planilha: TButton;
|
|
dtsQuery: TDataSource;
|
|
roqryPesquisa: TZReadOnlyQuery;
|
|
btn_pesquisa: TButton;
|
|
ppm_marcar: TPopupMenu;
|
|
MarcarTodos1: TMenuItem;
|
|
DesmarcarTodos1: TMenuItem;
|
|
N1: TMenuItem;
|
|
cb_cobradoresprov: TCheckBox;
|
|
edt_puserprov: TEdit;
|
|
clb_usuariosprov: TCheckListBox;
|
|
clb_usuariosagenda: TCheckListBox;
|
|
cb_cobradoresagenda: TCheckBox;
|
|
edt_puseragenda: TEdit;
|
|
Panel2: TPanel;
|
|
rg_agendamento: TRadioGroup;
|
|
gb_telefones: TGroupBox;
|
|
cb_telefones: TCheckBox;
|
|
Panel4: TPanel;
|
|
rg_situacaotel: TRadioGroup;
|
|
Panel5: TPanel;
|
|
rg_tptel: TRadioGroup;
|
|
cb_email: TCheckBox;
|
|
gb_email: TGroupBox;
|
|
Panel6: TPanel;
|
|
rg_email: TRadioGroup;
|
|
edt_nomeplanilha: TEdit;
|
|
lbl_nome: TLabel;
|
|
cb_reltitulos: TCheckBox;
|
|
lbl_linhas: TLabel;
|
|
dblulb_provs: TDBLookupComboBox;
|
|
cb_retornaprov: TCheckBox;
|
|
lbl_prov: TLabel;
|
|
btn_provs: TButton;
|
|
ppmnuFichaDev: TPopupMenu;
|
|
mnuEntrarnaFichadoDevedor: TMenuItem;
|
|
ppmnuAcoes: TPopupMenu;
|
|
Panel7: TPanel;
|
|
rg_sms: TRadioGroup;
|
|
procedure cb_beneficiariosClick(Sender: TObject);
|
|
procedure edt_pcredorChange(Sender: TObject);
|
|
procedure cb_credorentradaClick(Sender: TObject);
|
|
procedure cb_credorvencimentoClick(Sender: TObject);
|
|
procedure cb_credortptituloClick(Sender: TObject);
|
|
procedure cb_providenciasClick(Sender: TObject);
|
|
procedure cb_periodoprovClick(Sender: TObject);
|
|
procedure cb_cobradoresprovClick(Sender: TObject);
|
|
procedure cb_agendamentoClick(Sender: TObject);
|
|
procedure rg_agendamentoClick(Sender: TObject);
|
|
procedure cb_cobradoresagendaClick(Sender: TObject);
|
|
procedure edt_pprovChange(Sender: TObject);
|
|
procedure edt_puserprovChange(Sender: TObject);
|
|
procedure edt_puseragendaChange(Sender: TObject);
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure clb_beneficiariosClickCheck(Sender: TObject);
|
|
procedure clb_providenciasClickCheck(Sender: TObject);
|
|
procedure clb_usuariosprovClickCheck(Sender: TObject);
|
|
procedure clb_usuariosagendaClickCheck(Sender: TObject);
|
|
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
|
|
Shift: TShiftState; X, Y: Integer);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure btn_pesquisaClick(Sender: TObject);
|
|
procedure cb_faixanomeClick(Sender: TObject);
|
|
procedure cb_atrasoClick(Sender: TObject);
|
|
procedure cb_tipopessoaClick(Sender: TObject);
|
|
procedure cb_telefonesClick(Sender: TObject);
|
|
procedure cb_emailClick(Sender: TObject);
|
|
procedure btn_planilhaClick(Sender: TObject);
|
|
procedure cb_reltitulosClick(Sender: TObject);
|
|
procedure btn_provsClick(Sender: TObject);
|
|
procedure mnuEntrarnaFichadoDevedorClick(Sender: TObject);
|
|
procedure rg_tptelClick(Sender: TObject);
|
|
private
|
|
controller_name: string;
|
|
posi: TPoint;
|
|
total_titulos: Integer;
|
|
valor_total: double;
|
|
procedure marca_todos(clb: TCheckListBox);
|
|
procedure HandlePopupItem(Sender: TObject);
|
|
procedure AdjustCheckListBox(var CB: TCheckListBox);
|
|
function FindControlAtPos(AScreenPos: TPoint): TControl;
|
|
function FindSubcontrolAtPos(AControl: TControl;
|
|
AScreenPos, AClientPos: TPoint): TControl;
|
|
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmCentralPlanilhamento: TfrmCentralPlanilhamento;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem, ucadDevedores;
|
|
|
|
procedure TfrmCentralPlanilhamento.AdjustCheckListBox(var CB: TCheckListBox);
|
|
var
|
|
i, nMaxWidth, nItemWidth: Integer;
|
|
begin
|
|
// ajustar os checklistbox para poder ter scroll horizontal
|
|
nMaxWidth := CB.ClientWidth;
|
|
for i := 0 to CB.Items.Count - 1 do
|
|
begin
|
|
nItemWidth := CB.Canvas.TextWidth(CB.Items[i]) + 20;
|
|
if (nItemWidth > nMaxWidth) then
|
|
nMaxWidth := nItemWidth;
|
|
end;
|
|
if (nMaxWidth > CB.ClientWidth) then
|
|
begin
|
|
CB.ScrollWidth := nMaxWidth;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.btn_pesquisaClick(Sender: TObject);
|
|
var
|
|
string_selecionados, dt_inicio, dt_fim: string;
|
|
i: Integer;
|
|
begin
|
|
|
|
if (not cb_beneficiarios.Checked) and (not cb_providencias.Checked) and
|
|
(not cb_agendamento.Checked) and (not cb_faixanome.Checked) and
|
|
(not cb_atraso.Checked) and (not cb_tipopessoa.Checked) then
|
|
begin
|
|
Messagedlg('Por favor escolha um filtro para a pesquisa.', mtWarning,
|
|
[mbok], 0);
|
|
abort;
|
|
end;
|
|
|
|
valor_total := 0;
|
|
total_titulos := 0;
|
|
|
|
string_selecionados := '';
|
|
|
|
// começa o sofrimento
|
|
roqryPesquisa.SQL.Clear;
|
|
with roqryPesquisa.SQL do // início dasql
|
|
begin
|
|
Add('select');
|
|
Add('d.tx_nome,');
|
|
Add('case when d.tp_cliente = ' + QuotedStr('F') + ' then d.cd_cpf');
|
|
Add('when d.tp_cliente = ' + QuotedStr('J') + ' then d.cd_cnpj');
|
|
Add('end as tx_documento');
|
|
if cb_telefones.Checked then
|
|
begin
|
|
Add(',tel.nr_ddd,tel.nr_numero');
|
|
end;
|
|
if cb_email.Checked then
|
|
begin
|
|
Add(',e.tx_email');
|
|
end;
|
|
if cb_reltitulos.Checked then
|
|
begin
|
|
Add(',t.tx_produto, t.dt_entrada, t.vl_titulo, t.dt_vencimento , t.vl_corrigido, t.dt_pagamento');
|
|
end;
|
|
Add(', t.id_devedor from chg_titulos t');
|
|
Add('left join chg_devedores d on d.id_devedor = t.id_devedor');
|
|
if cb_telefones.Checked then
|
|
begin
|
|
Add('left join chg_telefones tel on t.id_devedor = tel.id_devedor');
|
|
end;
|
|
if cb_email.Checked then
|
|
begin
|
|
Add('left join chg_emails e on t.id_devedor = e.id_devedor');
|
|
end;
|
|
Add('where');
|
|
if cb_email.Checked then
|
|
begin
|
|
case rg_email.ItemIndex of
|
|
0:
|
|
begin
|
|
Add('char_length(e.tx_email) > 3 and');
|
|
end;
|
|
1:
|
|
begin
|
|
Add('(char_length(e.tx_email) < 3 or e.tx_email is null) and');
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if cb_beneficiarios.Checked then // se beneficiarios tá selecionado
|
|
begin
|
|
for i := 1 to clb_beneficiarios.Items.Count - 1 do
|
|
begin
|
|
if clb_beneficiarios.Checked[i] then
|
|
begin
|
|
dtmSystem.tblCHGEmpresa.RecNo := i;
|
|
string_selecionados := string_selecionados +
|
|
dtmSystem.tblCHGEmpresaID_EMPRESA.AsString + ',';
|
|
end;
|
|
end;
|
|
string_selecionados := LeftStr(string_selecionados,
|
|
length(string_selecionados) - 1);
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('t.id_empresa in ');
|
|
Add('(' + string_selecionados + ')');
|
|
if cb_credorentrada.Checked then
|
|
begin
|
|
dt_inicio := DateToStr(dtp_credorentrada1.Date);
|
|
dt_inicio := RightStr(dt_inicio, 4) + '-' + copy(dt_inicio, 4, 2) + '-'
|
|
+ LeftStr(dt_inicio, 2);
|
|
dt_fim := DateToStr(dtp_credorentrada2.Date);
|
|
dt_fim := RightStr(dt_fim, 4) + '-' + copy(dt_fim, 4, 2) + '-' +
|
|
LeftStr(dt_fim, 2);
|
|
Add('and');
|
|
Add('cast(t.dt_entrada as date) >= ' + QuotedStr(dt_inicio) + ' and ');
|
|
Add('cast(t.dt_entrada as date) <= ' + QuotedStr(dt_fim));
|
|
end;
|
|
if cb_credorvencimento.Checked then
|
|
begin
|
|
dt_inicio := DateToStr(dtp_credorvenc1.Date);
|
|
dt_inicio := RightStr(dt_inicio, 4) + '-' + copy(dt_inicio, 4, 2) + '-'
|
|
+ LeftStr(dt_inicio, 2);
|
|
dt_fim := DateToStr(dtp_credorvenc2.Date);
|
|
dt_fim := RightStr(dt_fim, 4) + '-' + copy(dt_fim, 4, 2) + '-' +
|
|
LeftStr(dt_fim, 2);
|
|
Add('and');
|
|
Add('cast(t.dt_vencimento as date) >= ' + QuotedStr(dt_inicio)
|
|
+ ' and ');
|
|
Add('cast(t.dt_vencimento as date) <= ' + QuotedStr(dt_fim));
|
|
end;
|
|
if cb_credortptitulo.Checked then
|
|
begin
|
|
Add('and');
|
|
case rg_credortptitulo.ItemIndex of
|
|
0:
|
|
begin
|
|
Add('t.TP_SITUACAO <> ' + QuotedStr('Ç'));
|
|
end;
|
|
1:
|
|
begin
|
|
Add('(t.TP_SITUACAO = ' + QuotedStr('A') + 'or t.TP_SITUACAO = ' +
|
|
QuotedStr('AC') + ')');
|
|
end;
|
|
2:
|
|
begin
|
|
Add('(t.TP_SITUACAO = ' + QuotedStr('B') + ' OR');
|
|
Add('t.TP_SITUACAO = ' + QuotedStr('QC') + ' OR');
|
|
Add('t.TP_SITUACAO = ' + QuotedStr('QB') + ')');
|
|
end;
|
|
end;
|
|
end;
|
|
Add('and ');
|
|
end;
|
|
string_selecionados := '';
|
|
end;
|
|
|
|
if cb_providencias.Checked then // se providências ta selecionado
|
|
begin
|
|
for i := 1 to clb_providencias.Items.Count - 1 do
|
|
begin
|
|
if clb_providencias.Checked[i] then
|
|
begin
|
|
dtmSystem.tblProvidencias.RecNo := i;
|
|
string_selecionados := string_selecionados +
|
|
dtmSystem.tblProvidenciasID_PROVIDENCIA.AsString + ',';
|
|
end;
|
|
end;
|
|
string_selecionados := LeftStr(string_selecionados,
|
|
length(string_selecionados) - 1);
|
|
if rg_filtroprov.ItemIndex >= 0 then
|
|
// se escolheu algum filtro
|
|
begin
|
|
case rg_filtroprov.ItemIndex of
|
|
0: // contenha providencia
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('t.id_devedor in');
|
|
Add('(select h.id_devedor from chg_historico h');
|
|
Add('where h.id_providencia in');
|
|
Add('(' + string_selecionados + ')');
|
|
end;
|
|
end;
|
|
1: // não contenha
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('t.id_devedor not in');
|
|
Add('(select h.id_devedor from chg_historico h');
|
|
Add('where h.id_providencia in');
|
|
Add('(' + string_selecionados + ')');
|
|
end;
|
|
end;
|
|
2: // seja a última providencia lançada
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('t.id_devedor in');
|
|
Add('(select h.id_devedor from chg_historico h');
|
|
Add('inner join (SELECT h.id_devedor, MAX(h.ID_HISTORICO) AS MAXHIST FROM CHG_HISTORICO h');
|
|
Add('group by id_devedor)');
|
|
Add('hist on hist.id_devedor = h.id_devedor and h.id_historico = hist.maxhist');
|
|
Add('where h.id_providencia in');
|
|
Add('(' + string_selecionados + ')');
|
|
end;
|
|
end;
|
|
3: // positivas
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('t.id_devedor in');
|
|
Add('(select h.id_devedor from chg_historico h');
|
|
Add('where');
|
|
Add('h.id_providencia in');
|
|
Add('(select p.id_providencia from chg_providencias p where');
|
|
Add('p.tp_providencia = ' + QuotedStr('Positiva') + ')');
|
|
end;
|
|
end;
|
|
4: // negativas
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('t.id_devedor in');
|
|
Add('(select h.id_devedor from chg_historico h');
|
|
Add('where');
|
|
Add('h.id_providencia in');
|
|
Add('(select p.id_providencia from chg_providencias p where');
|
|
Add('p.tp_providencia = ' + QuotedStr('Negativa') + ')');
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if cb_periodoprov.Checked then
|
|
// se escolheu um período de lançamento da providencia
|
|
begin
|
|
dt_inicio := DateToStr(dtp_provin.Date);
|
|
dt_inicio := RightStr(dt_inicio, 4) + '-' + copy(dt_inicio, 4, 2) + '-'
|
|
+ LeftStr(dt_inicio, 2);
|
|
dt_fim := DateToStr(dtp_provfim.Date);
|
|
dt_fim := RightStr(dt_fim, 4) + '-' + copy(dt_fim, 4, 2) + '-' +
|
|
LeftStr(dt_fim, 2);
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('and ');
|
|
Add('cast(h.dt_contato as date) >= ' + QuotedStr(dt_inicio));
|
|
Add('and ');
|
|
Add('cast(h.dt_contato as date) <= ' + QuotedStr(dt_fim));
|
|
end;
|
|
end;
|
|
if cb_cobradoresprov.Checked then
|
|
begin
|
|
string_selecionados := '';
|
|
for i := 1 to clb_usuariosprov.Items.Count - 1 do
|
|
begin
|
|
if clb_usuariosprov.Checked[i] then
|
|
begin
|
|
dtmSystem.tblUsuariosConsulta.RecNo := i;
|
|
string_selecionados := string_selecionados +
|
|
dtmSystem.tblUsuariosConsultaID_USUARIO.AsString + ',';
|
|
end;
|
|
end;
|
|
string_selecionados := LeftStr(string_selecionados,
|
|
length(string_selecionados) - 1);
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add('and ');
|
|
Add('t.id_devedor in');
|
|
Add('(select h.id_devedor from chg_historico h');
|
|
Add('where h.id_cobrador in');
|
|
Add('(' + string_selecionados + '))');
|
|
end;
|
|
end;
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
Add(') ');
|
|
Add('and');
|
|
end;
|
|
string_selecionados := '';
|
|
end;
|
|
end;
|
|
|
|
if cb_tipopessoa.Checked then // tipo de pessoa
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
case rg_tipopessoa.ItemIndex of
|
|
0:
|
|
begin
|
|
Add('d.tp_cliente = ' + QuotedStr('F'));
|
|
Add('and ');
|
|
end;
|
|
1:
|
|
begin
|
|
Add('d.tp_cliente = ' + QuotedStr('J'));
|
|
Add('and ');
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if cb_agendamento.Checked then // Agendamento
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
case rg_agendamento.ItemIndex of
|
|
0:
|
|
begin
|
|
|
|
end;
|
|
1:
|
|
begin
|
|
Add('t.id_devedor in');
|
|
Add('(select a.id_devedor from chg_agenda a where a.tp_situacao = '
|
|
+ QuotedStr('A') + ')');
|
|
Add('and ');
|
|
end;
|
|
2:
|
|
begin
|
|
dt_inicio := DateToStr(dtp_agendcomeco.Date);
|
|
dt_inicio := RightStr(dt_inicio, 4) + '-' + copy(dt_inicio, 4, 2) +
|
|
'-' + LeftStr(dt_inicio, 2);
|
|
dt_fim := DateToStr(dtp_agendfim.Date);
|
|
dt_fim := RightStr(dt_fim, 4) + '-' + copy(dt_fim, 4, 2) + '-' +
|
|
LeftStr(dt_fim, 2);
|
|
Add('t.id_devedor in');
|
|
Add('(select a.id_devedor from chg_agenda a where a.tp_situacao = '
|
|
+ QuotedStr('A'));
|
|
Add('and ');
|
|
Add('cast(dt_agendada as date) >= ' + QuotedStr(dt_inicio) + ' ');
|
|
Add('and ');
|
|
Add('cast(dt_agendada as date) <= ' + QuotedStr(dt_fim) + ')');
|
|
Add('and ');
|
|
end;
|
|
3:
|
|
begin
|
|
Add('t.id_devedor in');
|
|
Add('(select a.id_devedor from chg_agenda a where a.tp_situacao = '
|
|
+ QuotedStr('A'));
|
|
Add('and ');
|
|
Add('a.dt_agendada <= ' + QuotedStr(FormatDateTime('YYYY-MM-DD',
|
|
Date)) + ')');
|
|
Add('and ');
|
|
end;
|
|
4:
|
|
begin
|
|
Add('t.id_devedor not in');
|
|
Add('(select a.id_devedor from chg_agenda a where tp_situacao = ' +
|
|
QuotedStr('A') + ')');
|
|
Add('and ');
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if cb_faixanome.Checked then // faixa de nomes
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
// Upper(d.TX_NOME) similar to '[A-M]_*'
|
|
Add('Upper(d.TX_NOME) similar to ' + '''[' + edt_nomein.Text + '-' +
|
|
edt_nomefim.Text + ']_*''');
|
|
Add('and ');
|
|
end;
|
|
end;
|
|
|
|
if cb_atraso.Checked then // dias de atraso no título
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
// datediff(day,t.dt_vencimento,cast('now' as date)) >= 1
|
|
Add('datediff(day,cast(t.dt_vencimento as date),cast(''now'' as date)) >= '
|
|
+ edt_atrasoin.Text);
|
|
Add('and ');
|
|
Add('datediff(day,cast(t.dt_vencimento as date),cast(''now'' as date)) <= '
|
|
+ edt_atrasofim.Text);
|
|
Add('and ');
|
|
end;
|
|
end;
|
|
if cb_telefones.Checked then
|
|
begin
|
|
with roqryPesquisa.SQL do
|
|
begin
|
|
if rg_situacaotel.ItemIndex > -1 then
|
|
begin
|
|
case rg_situacaotel.ItemIndex of
|
|
0:
|
|
begin
|
|
Add('tel.tp_ativo = ' + QuotedStr('S'));
|
|
Add('and ');
|
|
end;
|
|
1:
|
|
begin
|
|
Add('tel.tp_ativo = ' + QuotedStr('N'));
|
|
Add('and ');
|
|
end;
|
|
2:
|
|
begin
|
|
Add('tel.tp_ativo <> ' + QuotedStr('Ç'));
|
|
Add('and ');
|
|
end;
|
|
3:
|
|
begin
|
|
Add('tel.tp_ativo <> ' + QuotedStr('N'));
|
|
Add('and ');
|
|
end;
|
|
end;
|
|
end;
|
|
if rg_tptel.ItemIndex > -1 then
|
|
begin
|
|
case rg_tptel.ItemIndex of
|
|
0:
|
|
begin
|
|
Add('tel.tp_tipotel = ' + QuotedStr('F'));
|
|
Add('and ');
|
|
end;
|
|
1:
|
|
begin
|
|
Add('tel.tp_tipotel = ' + QuotedStr('M'));
|
|
Add('and ');
|
|
case rg_sms.ItemIndex of
|
|
0:
|
|
begin
|
|
Add('tel.tp_SMS = ' + QuotedStr('S'));
|
|
Add('and ');
|
|
end;
|
|
1:
|
|
begin
|
|
Add('tel.tp_SMS = ' + QuotedStr('N'));
|
|
Add('and ');
|
|
end;
|
|
2:
|
|
begin
|
|
Add('tel.tp_SMS in (' + QuotedStr('S') + ',' +
|
|
QuotedStr('N') + ')');
|
|
Add('and ');
|
|
end;
|
|
3:
|
|
begin
|
|
// Add('tel.tp_SMS <> ' + QuotedStr('Ç'));
|
|
// Add('and ');
|
|
end;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
Add('tel.tp_tipotel in (' + QuotedStr('F') + ',' +
|
|
QuotedStr('M') + ')');
|
|
Add('and ');
|
|
end;
|
|
3:
|
|
begin
|
|
Add('tel.tp_tipotel <> ' + QuotedStr('Ç'));
|
|
Add('and ');
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
roqryPesquisa.SQL.Delete(roqryPesquisa.SQL.Count - 1);
|
|
// roqryPesquisa.SQL.Add('group by d.ID_DEVEDOR, d.TX_NOME, TX_DOCUMENTO');
|
|
// agrupar a query
|
|
if cb_telefones.Checked then
|
|
begin
|
|
roqryPesquisa.SQL.Add
|
|
('group by d.tx_nome, tx_documento, tel.nr_ddd, tel.nr_numero, t.id_devedor');
|
|
end;
|
|
if cb_email.Checked then
|
|
begin
|
|
roqryPesquisa.SQL.Add
|
|
('group by d.tx_nome, tx_documento, e.tx_email, t.id_devedor');
|
|
end;
|
|
roqryPesquisa.SQL.Add('order by d.tx_nome');
|
|
|
|
Screen.Cursor := crHourGlass;
|
|
Application.ProcessMessages;
|
|
roqryPesquisa.Open;
|
|
Application.ProcessMessages;
|
|
total_titulos := 0;
|
|
roqryPesquisa.First;
|
|
|
|
Screen.Cursor := crDefault;
|
|
if roqryPesquisa.RecordCount > 0 then
|
|
begin
|
|
// btn_ok.Enabled := true;
|
|
// pb_campanha.max := queryCampanha.RecordCount;
|
|
roqryPesquisa.First;
|
|
end
|
|
else
|
|
begin
|
|
// btn_ok.Enabled := false;
|
|
end;
|
|
// pnl_txt.Caption := 'Pesquisa realizada.';
|
|
lbl_linhas.Caption := 'Quantidade de linhas: ' +
|
|
inttostr(roqryPesquisa.RecordCount);
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.btn_planilhaClick(Sender: TObject);
|
|
var
|
|
OpenOffice, OpenDesktop, OOCalc, OOExec, Planilha, LoadParams, Param,
|
|
FilterParams, Param2: Variant;
|
|
i, j: Integer;
|
|
pathFile: string;
|
|
begin
|
|
|
|
if edt_nomeplanilha.Text = '' then
|
|
begin
|
|
Messagedlg('Por favor escolha um nome para a pesquisa.', mtWarning,
|
|
[mbok], 0);
|
|
abort;
|
|
end;
|
|
|
|
if AnsiPos('/', edt_nomeplanilha.Text) <> 0 then
|
|
begin
|
|
Messagedlg('Não é possível criar um arquivo que contenha ''/'' em seu nome. Por favor escolha outro.', mtWarning,
|
|
[mbok], 0);
|
|
abort;
|
|
end;
|
|
|
|
Screen.Cursor := crHourGlass;
|
|
|
|
// gera uma planilha conforme o string grid do layout
|
|
if VarIsEmpty(OpenOffice) then
|
|
begin
|
|
OpenOffice := CreateOleObject('com.sun.star.ServiceManager');
|
|
end;
|
|
OpenDesktop := OpenOffice.CreateInstance('com.sun.star.frame.Desktop');
|
|
|
|
LoadParams := VarArrayCreate([0, 0], varVariant);
|
|
Param := OpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
|
|
Param.Name := 'Hidden';
|
|
Param.Value := true;
|
|
LoadParams[0] := Param;
|
|
|
|
OOExec := OpenDesktop.LoadComponentFromURL('private:factory/scalc', '_blank',
|
|
0, LoadParams);
|
|
OOCalc := OOExec.Sheets;
|
|
Planilha := OOCalc.getbyIndex(0);
|
|
|
|
for i := 0 to roqryPesquisa.FieldCount - 1 do
|
|
begin
|
|
Planilha.getCellByPosition(i, 0).string := roqryPesquisa.Fields[i]
|
|
.FieldName;
|
|
end;
|
|
roqryPesquisa.First;
|
|
// i := 1;
|
|
// while not roqryPesquisa.EoF do
|
|
// begin
|
|
// for j := 0 to roqryPesquisa.FieldCount - 1 do
|
|
// begin
|
|
// Planilha.getCellByPosition(j, i).string :=
|
|
// roqryPesquisa.FieldByName(roqryPesquisa.Fields[j].FieldName).AsString;
|
|
// Planilha.getCellByPosition(i, j).getColumns.getbyIndex(0)
|
|
// .OptimalWidth := true;
|
|
// end;
|
|
// Inc(i, 1);
|
|
// roqryPesquisa.Next;
|
|
// end;
|
|
|
|
for i := 1 to roqryPesquisa.RecordCount do
|
|
begin
|
|
for j := 0 to roqryPesquisa.FieldCount - 1 do
|
|
begin
|
|
Planilha.getCellByPosition(j, i).string :=
|
|
roqryPesquisa.FieldByName(roqryPesquisa.Fields[j].FieldName).AsString;
|
|
Planilha.getCellByPosition(j, i).getColumns.getbyIndex(0)
|
|
.OptimalWidth := true;
|
|
end;
|
|
roqryPesquisa.Next;
|
|
end;
|
|
|
|
FilterParams := VarArrayCreate([0, 1], varVariant);
|
|
|
|
Param2 := OpenDesktop.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
|
|
Param2.Name := 'FilterName';
|
|
Param2.Value := 'MS Excel 97';
|
|
FilterParams[0] := Param2;
|
|
Param2.Name := 'Overwrite';
|
|
Param2.Value := true;
|
|
FilterParams[1] := Param2;
|
|
|
|
// pathFile := GetCurrentDir;
|
|
pathFile := dtmSystem.path_executavel;
|
|
pathFile := 'file:///' + pathFile + '\Planilhas\' + edt_nomeplanilha.Text;
|
|
pathFile := StringReplace(pathFile, '\', '/', [rfReplaceAll]);
|
|
|
|
try
|
|
OOExec.StoreAsURL(pathFile + '.xls', FilterParams);
|
|
OOExec.Close(false);
|
|
finally
|
|
OpenOffice := Unassigned;
|
|
end;
|
|
|
|
Screen.Cursor := crDefault;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.btn_provsClick(Sender: TObject);
|
|
var
|
|
prov_anterior: Integer;
|
|
begin
|
|
if roqryPesquisa.RecordCount > 0 then
|
|
begin
|
|
Screen.Cursor := crHourGlass;
|
|
with dtmSystem do
|
|
begin
|
|
roqryPesquisa.First;
|
|
while not roqryPesquisa.EoF do
|
|
begin
|
|
if cb_retornaprov.Checked then
|
|
begin
|
|
tblDevedores.Locate('ID_DEVEDOR',
|
|
roqryPesquisa.FieldByName('id_devedor').AsInteger, []);
|
|
tblHistorico.First;
|
|
if not tblHistorico.IsEmpty then
|
|
begin
|
|
prov_anterior := tblHistoricoID_PROVIDENCIA.AsInteger;
|
|
end
|
|
else
|
|
begin
|
|
prov_anterior := -1;
|
|
end;
|
|
tblHistorico.Append;
|
|
tblHistoricoID_DEVEDOR.AsInteger :=
|
|
roqryPesquisa.FieldByName('id_devedor').AsInteger;
|
|
tblHistoricoID_COBRADOR.AsInteger := id_usuario;
|
|
tblHistoricoID_PROVIDENCIA.AsInteger := dblulb_provs.KeyValue;
|
|
tblHistoricoDT_CONTATO.AsDateTime := Now;
|
|
tblHistoricoTL_MEMO.AsString := 'Providência lançada: ' +
|
|
tblProvidenciasTX_NOME.AsString + '.';
|
|
tblHistorico.Post;
|
|
if prov_anterior <> -1 then
|
|
begin
|
|
tblHistorico.Append;
|
|
tblHistoricoID_DEVEDOR.AsInteger :=
|
|
roqryPesquisa.FieldByName('id_devedor').AsInteger;
|
|
tblHistoricoID_COBRADOR.AsInteger := id_usuario;
|
|
tblHistoricoID_PROVIDENCIA.AsInteger := prov_anterior;
|
|
tblHistoricoTL_MEMO.AsString :=
|
|
'Retorno da providência lançada pré envio de emails.';
|
|
tblHistoricoDT_CONTATO.AsDateTime := Now;
|
|
tblHistorico.Post;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
tblHistorico.Append;
|
|
tblHistoricoID_DEVEDOR.AsInteger :=
|
|
roqryPesquisa.FieldByName('id_devedor').AsInteger;
|
|
tblHistoricoID_COBRADOR.AsInteger := id_usuario;
|
|
tblHistoricoID_PROVIDENCIA.AsInteger := dblulb_provs.KeyValue;
|
|
tblHistoricoDT_CONTATO.AsDateTime := Now;
|
|
tblHistoricoTL_MEMO.AsString := 'Providência lançada: ' +
|
|
tblProvidenciasTX_NOME.AsString + '.';
|
|
tblHistorico.Post;
|
|
end;
|
|
roqryPesquisa.Next;
|
|
Application.ProcessMessages;
|
|
end;
|
|
end;
|
|
cb_retornaprov.Checked := false;
|
|
end;
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_agendamentoClick(Sender: TObject);
|
|
begin
|
|
case cb_agendamento.Checked of
|
|
true:
|
|
begin
|
|
rg_agendamento.Enabled := cb_agendamento.Checked;
|
|
cb_cobradoresagenda.Enabled := cb_agendamento.Checked;
|
|
end;
|
|
false:
|
|
begin
|
|
rg_agendamento.Enabled := cb_agendamento.Checked;
|
|
cb_cobradoresagenda.Enabled := cb_agendamento.Checked;
|
|
edt_puseragenda.Enabled := cb_agendamento.Checked;
|
|
clb_usuariosagenda.Enabled := cb_agendamento.Checked;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_atrasoClick(Sender: TObject);
|
|
begin
|
|
edt_atrasoin.Enabled := cb_atraso.Checked;
|
|
edt_atrasofim.Enabled := cb_atraso.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_beneficiariosClick(Sender: TObject);
|
|
begin
|
|
case cb_beneficiarios.Checked of
|
|
true:
|
|
begin
|
|
clb_beneficiarios.Enabled := cb_beneficiarios.Checked;
|
|
edt_pcredor.Enabled := cb_beneficiarios.Checked;
|
|
cb_credorentrada.Enabled := cb_beneficiarios.Checked;
|
|
cb_credorvencimento.Enabled := cb_beneficiarios.Checked;
|
|
cb_credortptitulo.Enabled := cb_beneficiarios.Checked;
|
|
end;
|
|
false:
|
|
begin
|
|
clb_beneficiarios.Enabled := cb_beneficiarios.Checked;
|
|
edt_pcredor.Enabled := cb_beneficiarios.Checked;
|
|
cb_credorentrada.Enabled := cb_beneficiarios.Checked;
|
|
cb_credorentrada.Checked := cb_beneficiarios.Checked;
|
|
dtp_credorentrada1.Enabled := cb_beneficiarios.Checked;
|
|
dtp_credorentrada2.Enabled := cb_beneficiarios.Checked;
|
|
cb_credorvencimento.Enabled := cb_beneficiarios.Checked;
|
|
cb_credorvencimento.Checked := cb_beneficiarios.Checked;
|
|
dtp_credorvenc1.Enabled := cb_beneficiarios.Checked;
|
|
dtp_credorvenc2.Enabled := cb_beneficiarios.Checked;
|
|
cb_credortptitulo.Enabled := cb_beneficiarios.Checked;
|
|
rg_credortptitulo.ItemIndex := -1;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_cobradoresagendaClick(Sender: TObject);
|
|
begin
|
|
edt_puseragenda.Enabled := cb_cobradoresagenda.Checked;
|
|
clb_usuariosagenda.Enabled := cb_cobradoresagenda.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_cobradoresprovClick(Sender: TObject);
|
|
begin
|
|
edt_puserprov.Enabled := cb_cobradoresprov.Checked;
|
|
clb_usuariosprov.Enabled := cb_cobradoresprov.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_credorentradaClick(Sender: TObject);
|
|
begin
|
|
dtp_credorentrada1.Enabled := cb_credorentrada.Checked;
|
|
dtp_credorentrada2.Enabled := cb_credorentrada.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_credortptituloClick(Sender: TObject);
|
|
begin
|
|
rg_credortptitulo.Enabled := cb_credortptitulo.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_credorvencimentoClick(Sender: TObject);
|
|
begin
|
|
dtp_credorvenc1.Enabled := cb_credorvencimento.Checked;
|
|
dtp_credorvenc2.Enabled := cb_credorvencimento.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_emailClick(Sender: TObject);
|
|
begin
|
|
gb_email.Enabled := cb_email.Checked;
|
|
if cb_email.Checked then
|
|
begin
|
|
cb_telefones.Checked := false;
|
|
cb_reltitulos.Checked := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_faixanomeClick(Sender: TObject);
|
|
begin
|
|
edt_nomein.Enabled := cb_faixanome.Checked;
|
|
edt_nomefim.Enabled := cb_faixanome.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_periodoprovClick(Sender: TObject);
|
|
begin
|
|
dtp_provin.Enabled := cb_periodoprov.Checked;
|
|
dtp_provfim.Enabled := cb_periodoprov.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_providenciasClick(Sender: TObject);
|
|
begin
|
|
case cb_providencias.Checked of
|
|
true:
|
|
begin
|
|
clb_providencias.Enabled := cb_providencias.Checked;
|
|
edt_pprov.Enabled := cb_providencias.Checked;
|
|
rg_filtroprov.Enabled := cb_providencias.Checked;
|
|
cb_periodoprov.Enabled := cb_providencias.Checked;
|
|
cb_cobradoresprov.Enabled := cb_providencias.Checked;
|
|
end;
|
|
false:
|
|
begin
|
|
clb_providencias.Enabled := cb_providencias.Checked;
|
|
edt_pprov.Enabled := cb_providencias.Checked;
|
|
rg_filtroprov.Enabled := cb_providencias.Checked;
|
|
dtp_provin.Enabled := cb_providencias.Checked;
|
|
dtp_provfim.Enabled := cb_providencias.Checked;
|
|
cb_periodoprov.Enabled := cb_providencias.Checked;
|
|
cb_cobradoresprov.Enabled := cb_providencias.Checked;
|
|
edt_puserprov.Enabled := cb_providencias.Checked;
|
|
clb_usuariosprov.Enabled := cb_providencias.Checked;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_reltitulosClick(Sender: TObject);
|
|
begin
|
|
if cb_reltitulos.Checked then
|
|
begin
|
|
cb_email.Checked := false;
|
|
cb_telefones.Checked := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_telefonesClick(Sender: TObject);
|
|
begin
|
|
gb_telefones.Enabled := cb_telefones.Checked;
|
|
if cb_telefones.Checked then
|
|
begin
|
|
cb_email.Checked := false;
|
|
cb_reltitulos.Checked := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.cb_tipopessoaClick(Sender: TObject);
|
|
begin
|
|
rg_tipopessoa.Enabled := cb_tipopessoa.Checked;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.clb_beneficiariosClickCheck(Sender: TObject);
|
|
begin
|
|
marca_todos(clb_beneficiarios);
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.clb_providenciasClickCheck(Sender: TObject);
|
|
begin
|
|
marca_todos(clb_providencias);
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.clb_usuariosagendaClickCheck
|
|
(Sender: TObject);
|
|
begin
|
|
marca_todos(clb_usuariosagenda);
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.clb_usuariosprovClickCheck(Sender: TObject);
|
|
begin
|
|
marca_todos(clb_usuariosprov);
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.edt_pcredorChange(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
for i := 0 to clb_beneficiarios.Items.Count do
|
|
begin
|
|
try
|
|
if ContainsText(clb_beneficiarios.Items[i], edt_pcredor.Text) then
|
|
begin
|
|
clb_beneficiarios.ItemIndex := i;
|
|
break;
|
|
end;
|
|
except
|
|
break;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.edt_pprovChange(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
for i := 0 to clb_providencias.Items.Count do
|
|
begin
|
|
try
|
|
if ContainsText(clb_providencias.Items[i], edt_pprov.Text) then
|
|
begin
|
|
clb_providencias.ItemIndex := i;
|
|
break;
|
|
end;
|
|
except
|
|
break;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.edt_puseragendaChange(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
for i := 0 to clb_usuariosagenda.Items.Count do
|
|
begin
|
|
try
|
|
if ContainsText(clb_usuariosagenda.Items[i], edt_puseragenda.Text) then
|
|
begin
|
|
clb_usuariosagenda.ItemIndex := i;
|
|
break;
|
|
end;
|
|
except
|
|
break;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.edt_puserprovChange(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
for i := 0 to clb_usuariosprov.Items.Count do
|
|
begin
|
|
try
|
|
if ContainsText(clb_usuariosprov.Items[i], edt_puserprov.Text) then
|
|
begin
|
|
clb_usuariosprov.ItemIndex := i;
|
|
break;
|
|
end;
|
|
except
|
|
break;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.mnuEntrarnaFichadoDevedorClick
|
|
(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
try
|
|
if dtmSystem.tblDevedores.Locate('ID_DEVEDOR',
|
|
roqryPesquisa.FieldByName('ID_DEVEDOR').AsInteger, []) then
|
|
begin
|
|
cadDevedores := TcadDevedores.Create(self);
|
|
cadDevedores.ShowModal;
|
|
end;
|
|
except
|
|
end;
|
|
|
|
end;
|
|
|
|
function TfrmCentralPlanilhamento.FindControlAtPos(AScreenPos: TPoint)
|
|
: TControl;
|
|
var
|
|
i: Integer;
|
|
f, m: TForm;
|
|
p: TPoint;
|
|
r: TRect;
|
|
begin
|
|
// função para descobrir o controle que se encontra abaixo do mouse
|
|
Result := nil;
|
|
for i := Screen.FormCount - 1 downto 0 do
|
|
begin
|
|
f := Screen.Forms[i];
|
|
if f.Visible and (f.Parent = nil) and (f.FormStyle <> fsMDIChild) and
|
|
TRect.Create(f.Left, f.Top, f.Left + f.Width, f.Top + f.Height)
|
|
.Contains(AScreenPos) then
|
|
Result := f;
|
|
end;
|
|
Result := FindSubcontrolAtPos(Result, AScreenPos, AScreenPos);
|
|
if (Result is TForm) and (TForm(Result).ClientHandle <> 0) then
|
|
begin
|
|
Winapi.Windows.GetWindowRect(TForm(Result).ClientHandle, r);
|
|
p := TPoint.Create(AScreenPos.X - r.Left, AScreenPos.Y - r.Top);
|
|
m := nil;
|
|
for i := TForm(Result).MDIChildCount - 1 downto 0 do
|
|
begin
|
|
f := TForm(Result).MDIChildren[i];
|
|
if TRect.Create(f.Left, f.Top, f.Left + f.Width, f.Top + f.Height)
|
|
.Contains(p) then
|
|
m := f;
|
|
end;
|
|
if m <> nil then
|
|
Result := FindSubcontrolAtPos(m, AScreenPos, p);
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralPlanilhamento.FindSubcontrolAtPos(AControl: TControl;
|
|
AScreenPos, AClientPos: TPoint): TControl;
|
|
var
|
|
i: Integer;
|
|
C: TControl;
|
|
begin
|
|
Result := nil;
|
|
C := AControl;
|
|
if (C = nil) or not C.Visible or not TRect.Create(C.Left, C.Top,
|
|
C.Left + C.Width, C.Top + C.Height).Contains(AClientPos) then
|
|
exit;
|
|
Result := AControl;
|
|
if AControl is TWinControl then
|
|
for i := 0 to TWinControl(AControl).ControlCount - 1 do
|
|
begin
|
|
C := FindSubcontrolAtPos(TWinControl(AControl).Controls[i], AScreenPos,
|
|
AControl.ScreenToClient(AScreenPos));
|
|
if C <> nil then
|
|
Result := C;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.FormCreate(Sender: TObject);
|
|
var
|
|
Item: TMenuItem;
|
|
begin
|
|
with dtmSystem do
|
|
begin
|
|
if not(tblCHGEmpresa.Active) then
|
|
begin
|
|
tblCHGEmpresa.Open;
|
|
end
|
|
else
|
|
begin
|
|
tblCHGEmpresa.Refresh;
|
|
end;
|
|
tblCHGEmpresa.First;
|
|
clb_beneficiarios.Items.Add('Marcar Todos');
|
|
while not tblCHGEmpresa.EoF do // preenche o list box
|
|
begin
|
|
clb_beneficiarios.Items.Add(tblCHGEmpresaTX_NOME.AsString);
|
|
tblCHGEmpresa.Next;
|
|
end;
|
|
if not(tblDevedores.Active) then
|
|
begin
|
|
tblDevedores.Open;
|
|
end
|
|
else
|
|
begin
|
|
tblDevedores.Refresh;
|
|
end;
|
|
if not(tblHistorico.Active) then
|
|
begin
|
|
tblHistorico.Open;
|
|
end
|
|
else
|
|
begin
|
|
tblHistorico.Refresh;
|
|
end;
|
|
if not(tblProvidencias.Active) then
|
|
begin
|
|
tblProvidencias.Open;
|
|
end
|
|
else
|
|
begin
|
|
tblProvidencias.Refresh;
|
|
end;
|
|
|
|
if not(tblUsuariosConsulta.Active) then
|
|
begin
|
|
tblUsuariosConsulta.Open;
|
|
end;
|
|
tblUsuariosConsulta.First;
|
|
clb_usuariosprov.Items.Add('Marcar Todos');
|
|
clb_usuariosagenda.Items.Add('Marcar Todos');
|
|
while not tblUsuariosConsulta.EoF do // preenche o list box
|
|
begin
|
|
clb_usuariosprov.Items.Add(tblUsuariosConsultaTX_NOME.AsString);
|
|
clb_usuariosagenda.Items.Add(tblUsuariosConsultaTX_NOME.AsString);
|
|
tblUsuariosConsulta.Next;
|
|
end;
|
|
|
|
if not(tblProvidencias.Active) then
|
|
begin
|
|
tblProvidencias.Open;
|
|
end;
|
|
tblProvidencias.First;
|
|
clb_providencias.Items.Add('Marcar Todos');
|
|
while not tblProvidencias.EoF do // preenche o list box
|
|
begin
|
|
clb_providencias.Items.Add(tblProvidenciasTX_NOME.AsString);
|
|
tblProvidencias.Next;
|
|
end;
|
|
|
|
if not(tblGrupos.Active) then
|
|
begin
|
|
tblGrupos.Open;
|
|
end;
|
|
tblGrupos.First;
|
|
while not tblGrupos.EoF do
|
|
begin
|
|
Item := TMenuItem.Create(ppm_marcar);
|
|
Item.Caption := tblGruposTX_NOME.AsString;
|
|
// cria os menus extras do popupmenu
|
|
Item.Visible := false; // conforme necessidade dos grupos
|
|
Item.OnClick := HandlePopupItem;
|
|
ppm_marcar.Items.Add(Item);
|
|
tblGrupos.Next;
|
|
end;
|
|
|
|
if not tblFiltros.Active then
|
|
begin
|
|
tblFiltros.Open;
|
|
end;
|
|
|
|
dtp_agendcomeco.Enabled := false;
|
|
dtp_agendfim.Enabled := false;
|
|
|
|
end;
|
|
dtp_provin.Date := Date;
|
|
dtp_provfim.Date := Date;
|
|
|
|
// id_old := -1;
|
|
|
|
AdjustCheckListBox(clb_beneficiarios);
|
|
AdjustCheckListBox(clb_providencias);
|
|
AdjustCheckListBox(clb_usuariosprov);
|
|
AdjustCheckListBox(clb_usuariosagenda);
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.FormMouseDown(Sender: TObject;
|
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|
begin
|
|
if Button = mbRight then
|
|
begin
|
|
posi := Mouse.CursorPos;
|
|
controller_name := FindControlAtPos(posi).Name;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.FormShow(Sender: TObject);
|
|
begin
|
|
sbx_filtro.VertScrollBar.Position := 0;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.HandlePopupItem(Sender: TObject);
|
|
var
|
|
menuItem: TMenuItem;
|
|
helper: string;
|
|
// handler dos menus extras do popupmenu
|
|
id_helper: string;
|
|
i, cont_helper, cont_helper2: Integer;
|
|
begin
|
|
cont_helper := 0;
|
|
cont_helper2 := 0;
|
|
menuItem := TMenuItem(Sender);
|
|
helper := ReplaceStr(menuItem.Caption, '&', '');
|
|
with dtmSystem do
|
|
begin
|
|
tblGrupos.Open;
|
|
tblGrupos.First;
|
|
while not tblGrupos.EoF do
|
|
begin
|
|
if helper = tblGruposTX_NOME.AsString then
|
|
begin
|
|
id_helper := tblGruposID_GRUPO.AsString;
|
|
end;
|
|
tblGrupos.Next;
|
|
end;
|
|
end;
|
|
|
|
if controller_name = 'clb_usuariosprov' then
|
|
begin
|
|
for i := 1 to clb_usuariosprov.Items.Count - 1 do
|
|
begin
|
|
dtmSystem.tblUsuariosConsulta.Locate('TX_NOME',
|
|
clb_usuariosprov.Items[i], []);
|
|
if dtmSystem.tblUsuariosConsultaID_GRUPO.AsString = id_helper then
|
|
begin
|
|
if clb_usuariosprov.Checked[i] = false then
|
|
begin
|
|
clb_usuariosprov.Checked[i] := true;
|
|
end
|
|
else
|
|
begin
|
|
clb_usuariosprov.Checked[i] := false;
|
|
end;
|
|
end;
|
|
|
|
if (clb_usuariosprov.Checked[i] = false) and (i > 0) then
|
|
begin
|
|
cont_helper := cont_helper + 1
|
|
end;
|
|
if (clb_usuariosprov.Checked[i] = true) and (i > 0) then
|
|
begin
|
|
cont_helper2 := cont_helper2 + 1
|
|
end;
|
|
|
|
end;
|
|
|
|
if cont_helper = clb_usuariosprov.Items.Count - 1 then
|
|
begin
|
|
clb_usuariosprov.Checked[0] := false;
|
|
end;
|
|
if cont_helper2 = clb_usuariosprov.Items.Count - 1 then
|
|
begin
|
|
clb_usuariosprov.Checked[0] := true;
|
|
end;
|
|
end;
|
|
if controller_name = 'clb_usuariosagenda' then
|
|
begin
|
|
for i := 1 to clb_usuariosagenda.Items.Count - 1 do
|
|
begin
|
|
dtmSystem.tblUsuariosConsulta.Locate('TX_NOME',
|
|
clb_usuariosagenda.Items[i], []);
|
|
if dtmSystem.tblUsuariosConsultaID_GRUPO.AsString = id_helper then
|
|
begin
|
|
if clb_usuariosagenda.Checked[i] = false then
|
|
begin
|
|
clb_usuariosagenda.Checked[i] := true;
|
|
end
|
|
else
|
|
begin
|
|
clb_usuariosagenda.Checked[i] := false;
|
|
end;
|
|
end;
|
|
|
|
if (clb_usuariosagenda.Checked[i] = false) and (i > 0) then
|
|
begin
|
|
cont_helper := cont_helper + 1
|
|
end;
|
|
if (clb_usuariosagenda.Checked[i] = true) and (i > 0) then
|
|
begin
|
|
cont_helper2 := cont_helper2 + 1
|
|
end;
|
|
|
|
end;
|
|
|
|
if cont_helper = clb_usuariosagenda.Items.Count - 1 then
|
|
begin
|
|
clb_usuariosagenda.Checked[0] := false;
|
|
end;
|
|
if cont_helper2 = clb_usuariosagenda.Items.Count - 1 then
|
|
begin
|
|
clb_usuariosagenda.Checked[0] := true;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.marca_todos(clb: TCheckListBox);
|
|
var
|
|
i, j: Integer;
|
|
begin
|
|
|
|
with clb do
|
|
begin
|
|
if Checked[ItemIndex] then
|
|
begin
|
|
Items.beginupdate;
|
|
// marcou o marca todos, marca todos
|
|
for i := 0 to Items.Count - 1 do
|
|
begin
|
|
if (ItemIndex = 0) and (Checked[i] = true) then
|
|
begin
|
|
for j := 1 to Items.Count - 1 do
|
|
begin
|
|
Checked[j] := true;
|
|
end;
|
|
end;
|
|
Items.EndUpdate;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
Items.beginupdate;
|
|
for i := 0 to Items.Count - 1 do
|
|
// desmarcou o marca todos, desmarca todos
|
|
begin
|
|
if (ItemIndex = 0) and (Checked[i] = false) then
|
|
begin
|
|
for j := 1 to Items.Count - 1 do
|
|
begin
|
|
Checked[j] := false;
|
|
end;
|
|
end;
|
|
Items.EndUpdate;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.rg_agendamentoClick(Sender: TObject);
|
|
begin
|
|
if rg_agendamento.ItemIndex = 2 then
|
|
begin
|
|
dtp_agendcomeco.Enabled := true;
|
|
dtp_agendfim.Enabled := true;
|
|
end
|
|
else
|
|
begin
|
|
dtp_agendcomeco.Enabled := false;
|
|
dtp_agendfim.Enabled := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralPlanilhamento.rg_tptelClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if rg_tptel.ItemIndex = 1 then
|
|
begin
|
|
rg_sms.Enabled := true;
|
|
end
|
|
else
|
|
begin
|
|
rg_sms.Enabled := false;
|
|
end;
|
|
end;
|
|
|
|
end.
|
|
|
|
|
|
|