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.
 

2282 lines
71 KiB

unit ufrmCobranca;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.UITypes, Data.DB, ZAbstractRODataset, ZAbstractDataset, ZDataset,
Vcl.Menus, Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.Controls,
System.Classes, Vcl.Graphics, Vcl.Forms, Vcl.Dialogs, System.Math,
Vcl.Grids, Vcl.DBGrids, IniFiles, RLPreview, RLPreviewForm, DateUtils,
FireDAC.Stan.Def, FireDAC.Phys.IBWrapper, FireDAC.Phys.FBDef,
FireDAC.UI.Intf, FireDAC.VCLUI.Wait, FireDAC.Comp.UI, FireDAC.Phys,
System.StrUtils, IoUtils,
FireDAC.Phys.IBBase, FireDAC.Phys.FB, FireDAC.Stan.Intf, Datasnap.DBClient,
Vcl.DBCtrls, Vcl.AppEvnts;
const
WM_STARTUP = WM_USER;
type
TfrmCobranca = class(TForm)
tmr_login: TTimer;
mnu_main: TMainMenu;
mnuCadastros: TMenuItem;
mnuCredores: TMenuItem;
mnuUsuarios: TMenuItem;
mnuOpcoes: TMenuItem;
mnu_ajuda: TMenuItem;
mnu_login: TMenuItem;
mnu_altlogin: TMenuItem;
pnl_principal: TPanel;
N1: TMenuItem;
mnuEmpresa: TMenuItem;
mnuDevedores: TMenuItem;
stsbar: TStatusBar;
mnuProvidencias: TMenuItem;
mnuFerramentas: TMenuItem;
mnuCobrancaTel: TMenuItem;
mnuPesquisa: TMenuItem;
mnuGerCampanha: TMenuItem;
timer_display: TTimer;
dtsAgenda: TDataSource;
queryagenda: TZQuery;
Visualizar1: TMenuItem;
Agenda1: TMenuItem;
mnuAtendimento: TMenuItem;
N2: TMenuItem;
mnuIndices: TMenuItem;
mnuRelatorios: TMenuItem;
mnuEntrada: TMenuItem;
mnuModeloRepasse: TMenuItem;
mnuPrestacaoContas: TMenuItem;
mnuAgendamento: TMenuItem;
tmr_sessao: TTimer;
mnu_RecibosEmitidos: TMenuItem;
mnuBancoDados: TMenuItem;
N3: TMenuItem;
mnuConfLayout: TMenuItem;
mnuRecibos: TMenuItem;
mnuBackup: TMenuItem;
mnuRestaurar: TMenuItem;
N4: TMenuItem;
mnuEnvBancoOnline: TMenuItem;
N5: TMenuItem;
mnuDigito9: TMenuItem;
N6: TMenuItem;
mnuTxtEmail: TMenuItem;
pnl_alertaagenda: TPanel;
mnuMandaEmail: TMenuItem;
ConfiguraodoPopUpdeInicializao1: TMenuItem;
N7: TMenuItem;
mnuImptcc: TMenuItem;
mnuCentralPlanilhamento: TMenuItem;
PrestaodeContasTCC1: TMenuItem;
mnuAgenda: TMenuItem;
N8: TMenuItem;
mnuVerrecibos: TMenuItem;
mnuRankings: TMenuItem;
RelatriodeGerncia1: TMenuItem;
Departamentos1: TMenuItem;
mnuLog: TMenuItem;
mnuRelAcordos: TMenuItem;
N9: TMenuItem;
mnuBoletos: TMenuItem;
memo_update: TMemo;
tmr_update: TTimer;
ImportaodeDevedores1: TMenuItem;
mnuContas: TMenuItem;
mnuRemessa: TMenuItem;
appEvents: TApplicationEvents;
procedure tmr_loginTimer(Sender: TObject);
procedure mnu_altloginClick(Sender: TObject);
procedure mnuCredoresClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure mnuEmpresaClick(Sender: TObject);
procedure mnuUsuariosClick(Sender: TObject);
procedure mnuDevedoresClick(Sender: TObject);
procedure mnuProvidenciasClick(Sender: TObject);
procedure mnuCobrancaTelClick(Sender: TObject);
procedure mnuPesquisaClick(Sender: TObject);
procedure mnuGerCampanhaClick(Sender: TObject);
procedure stsbarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
const Rect: TRect);
procedure timer_displayTimer(Sender: TObject);
procedure Agenda1Click(Sender: TObject);
procedure Panel2MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure Panel2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Panel2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure mnuAtendimentoClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure mnuIndicesClick(Sender: TObject);
procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer;
var Resize: Boolean);
procedure FormShow(Sender: TObject);
procedure mnuEntradaClick(Sender: TObject);
procedure mnuModeloRepasseClick(Sender: TObject);
procedure mnuPrestacaoContasClick(Sender: TObject);
procedure stsbarDblClick(Sender: TObject);
procedure mnuAgendamentoClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure tmr_sessaoTimer(Sender: TObject);
procedure mnu_RecibosEmitidosClick(Sender: TObject);
procedure mnuContasClick(Sender: TObject);
procedure mnuConfLayoutClick(Sender: TObject);
procedure mnuRecibosClick(Sender: TObject);
procedure mnuRestaurarClick(Sender: TObject);
procedure mnuEnvBancoOnlineClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure mnuDigito9Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure mnuTxtEmailClick(Sender: TObject);
procedure mnuMandaEmailClick(Sender: TObject);
procedure ConfiguraodoPopUpdeInicializao1Click(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure mnuImptccClick(Sender: TObject);
procedure mnuCentralPlanilhamentoClick(Sender: TObject);
procedure PrestaodeContasTCC1Click(Sender: TObject);
procedure mnuAgendaClick(Sender: TObject);
procedure mnuVerrecibosClick(Sender: TObject);
procedure mnuRankingsClick(Sender: TObject);
procedure RelatriodeGerncia1Click(Sender: TObject);
procedure Departamentos1Click(Sender: TObject);
procedure mnuLogClick(Sender: TObject);
procedure mnuRelAcordosClick(Sender: TObject);
procedure mnuBoletosClick(Sender: TObject);
procedure tmr_updateTimer(Sender: TObject);
procedure ImportaodeDevedores1Click(Sender: TObject);
procedure mnuRemessaClick(Sender: TObject);
procedure appEventsException(Sender: TObject; E: Exception);
private
FValidKeyCombo: Boolean;
procedure ChecaPermissoes;
procedure WMStartup(var Msg: TMessage); message WM_STARTUP;
{ Private declarations }
public
{ Public declarations }
acesso: Boolean;
dia_atrasado, tempo_atrasado, eh_hoje: Boolean;
quanto_faltat: TTime;
MouseDownSpot: TPoint;
Capturing: bool;
after_show: Boolean;
campanha: Integer;
pesquisa_camp: Boolean;
importar: Boolean;
procedure fecharformsabertas(name_form: string);
procedure atualizaagenda();
end;
var
frmCobranca: TfrmCobranca;
implementation
{$R *.dfm}
uses
ufrmLogin, udtmSystem, ucadCredor, ucadEmpresa,
ucadUsuarios, ucadDevedores, ufrmVerIE, ufrmProgressEC, ucadProvidencias,
ufrmEfetuarCobranca, ufrmCampanha, ufrmPesquisa,
ufrmEscolheCampanha, urelRecibo, ufrmAgenda, ufrmAtendimento, ucadIndices,
uconfrelBordero, ucadModeloRepasse, uconfrelPrestacaoContas, ufrmAgendamento,
uconfrelRecibosEmitidos, urelTeste, ucadContas, uconfLayouts, ufrmAchaRecibo,
ufrmLiberaPermissao, ufrmDigito9, ucadTextEmail, ufrmMandaMensagem, ufrmPopUp,
urelHistorico, ufrmCentralPlanilhamento,
ufrmRankings, uimpDevedores, urelRelacaoAcordo, urelPrestacaoAnaSin,
uconfRelGerencia, ufrmDepartamentos, ufrmLogActions, uconfrelAcordos,
ufrmCentralBoletos, ufrmRemessa, uHelperFunctions;
procedure TfrmCobranca.FormCanResize(Sender: TObject;
var NewWidth, NewHeight: Integer; var Resize: Boolean);
begin
// método para impedir que a form seja redimensionada
if after_show then
begin
Resize := false;
end
else
begin
Resize := true;
end;
end;
procedure TfrmCobranca.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// parte do método pra verificar a sessão do usuário
// aqui a sessão dele é terminada se o programa foi fechado corretamente
// desabilitada a pedido da Bruna
// with dtmSystem do
// begin
// tblLogins.Open;
// tblLogins.Filter := 'ID_USUARIO = ' + inttostr(id_usuario);
// tblLogins.Filtered := true;
// tblLogins.Last;
// tblLogins.Edit;
// tblLoginsDT_LOGOFF.AsDateTime := Date;
// tblLoginsHR_LOGOFF.AsDateTime := now;
// tblLogins.Post;
// tblLogins.Filter := '';
// tblLogins.Filtered := false;
// tblLogins.Close;
// if not tblSessao.Active then
// begin
// tblSessao.Open;
// end;
// if tblSessao.Locate('ID_USUARIO', id_usuario, []) then
// begin
// tblSessao.Delete;
// tblSessao.Close;
// end;
// end;
// dtmSystem.LogaDC('mandou fechar programa ' + inttostr(dtmSystem.id_usuario));
// Application.Terminate;
end;
procedure TfrmCobranca.FormCreate(Sender: TObject);
var
logo: TImage;
// hoje: string;
begin
// pnl_principal.visible := false;
// Faz com que a janela ocupe a tela inteira
Width := Screen.WorkAreaWidth;
Height := Screen.WorkAreaHeight;
BoundsRect := Screen.WorkAreaRect;
dtmSystem.mostrar_senha := false;
after_show := false;
stsbar.Panels[3].Width := stsbar.Width - stsbar.Panels[0].Width -
stsbar.Panels[1].Width - stsbar.Panels[2].Width - 150;
// Carrega o logo do programa
try
logo := TImage.Create(pnl_principal);
logo.Parent := pnl_principal;
logo.Picture.LoadFromFile(ExtractFileDir(Application.ExeName) +
'\nexverse-logo.jpg');
logo.Height := logo.Picture.Height;
logo.Width := logo.Picture.Width;
logo.Top := Round((logo.Parent.Height / 2) - (logo.Height / 2));
logo.Left := Round((logo.Parent.Width / 2) - (logo.Width / 2));
logo.Visible := true;
except
end;
// inicializa o histórico da pesquisa
dtmSystem.cdsHist.Close;
dtmSystem.cdsHist.CreateDataSet;
dtmSystem.tblDepartamentos.Open;
dtmSystem.tx_formulario := TForm(Sender).Caption;
importar := false;
end;
procedure TfrmCobranca.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
// var
// i: Integer;
begin
// método para dar permissões "on the fly"
if (Key = 75) and (Shift = [ssCtrl]) then
begin
frmLiberaPermissao := TfrmLiberaPermissao.Create(self);
with frmLiberaPermissao do
begin
level := 0;
string_permissoes.Add('CBR.01');
string_permissoes.Add('CBR.01.01');
string_permissoes.Add('CBR.01.02');
string_permissoes.Add('CBR.01.03');
string_permissoes.Add('CBR.01.04');
string_permissoes.Add('CBR.01.05');
string_permissoes.Add('CBR.01.06');
string_permissoes.Add('CBR.01.07');
string_permissoes.Add('CBR.01.08');
string_permissoes.Add('CBR.01.09');
string_permissoes.Add('CBR.01.10');
string_permissoes.Add('CBR.01.11');
string_permissoes.Add('CBR.02');
string_permissoes.Add('CBR.02.01');
string_permissoes.Add('CBR.02.02');
string_permissoes.Add('CBR.02.03');
string_permissoes.Add('CBR.02.04');
string_permissoes.Add('CBR.02.05');
string_permissoes.Add('CBR.02.06');
string_permissoes.Add('CBR.02.07');
string_permissoes.Add('CBR.03');
string_permissoes.Add('CBR.03.01');
string_permissoes.Add('CBR.03.02');
string_permissoes.Add('CBR.03.03');
string_permissoes.Add('CBR.03.04');
string_permissoes.Add('CBR.04');
string_permissoes.Add('CBR.04.01');
string_permissoes.Add('CBR.04.02');
string_permissoes.Add('CBR.04.03.01');
string_permissoes.Add('CBR.04.03.02');
string_permissoes.Add('CBR.04.04');
string_permissoes.Add('CBR.04.05');
string_permissoes.Add('CBR.04.06');
ShowModal;
if ModalResult = mrOk then
begin
case dtmSystem.cod_liberapermissao of
0:
mnuFerramentas.Visible := true;
1:
begin
mnuFerramentas.Visible := true;
mnuCobrancaTel.Visible := true;
end;
2:
begin
mnuFerramentas.Visible := true;
mnuPesquisa.Visible := true;
end;
3:
begin
mnuFerramentas.Visible := true;
mnuAtendimento.Visible := true;
end;
4:
begin
mnuFerramentas.Visible := true;
mnuGerCampanha.Visible := true;
end;
5:
begin
mnuFerramentas.Visible := true;
mnuAgendamento.Visible := true;
end;
6:
begin
mnuFerramentas.Visible := true;
mnuMandaEmail.Visible := true;
end;
7:
begin
mnuFerramentas.Visible := true;
mnuDigito9.Visible := true;
end;
8:
begin
mnuFerramentas.Visible := true;
mnuImptcc.Visible := true;
end;
9:
begin
mnuFerramentas.Visible := true;
mnuCentralPlanilhamento.Visible := true;
end;
10:
begin
mnuFerramentas.Visible := true;
mnuVerrecibos.Visible := true;
end;
11:
begin
mnuFerramentas.Visible := true;
mnuRankings.Visible := true;
end;
12:
mnuCadastros.Visible := true;
13:
begin
mnuCadastros.Visible := true;
mnuDevedores.Visible := true;
end;
14:
begin
mnuCadastros.Visible := true;
mnuCredores.Visible := true;
end;
15:
begin
mnuCadastros.Visible := true;
mnuUsuarios.Visible := true;
end;
16:
begin
mnuCadastros.Visible := true;
mnuProvidencias.Visible := true;
end;
17:
begin
mnuCadastros.Visible := true;
mnuEmpresa.Visible := true;
end;
18:
begin
// mnuCadastros.Visible := true;
// mnuContas.Visible := true;
end;
19:
begin
mnuCadastros.Visible := true;
mnuTxtEmail.Visible := true;
end;
20:
mnuRelatorios.Visible := true;
21:
begin
mnuRelatorios.Visible := true;
mnuEntrada.Visible := true;
end;
22:
begin
mnuRelatorios.Visible := true;
mnuPrestacaoContas.Visible := true;
end;
23:
begin
mnuRelatorios.Visible := true;
mnu_RecibosEmitidos.Visible := true;
end;
24:
begin
mnuRelatorios.Visible := true;
// PrestaodeContasTCC1.Visible := true;
end;
25:
mnuOpcoes.Visible := true;
26:
begin
mnuOpcoes.Visible := true;
mnuIndices.Visible := true;
end;
27:
begin
mnuOpcoes.Visible := true;
mnuModeloRepasse.Visible := true;
end;
28:
begin
mnuOpcoes.Visible := true;
// mnuBancoDados.Visible := true;
mnuBackup.Visible := true;
end;
29:
begin
mnuOpcoes.Visible := true;
// mnuBancoDados.Visible := true;
mnuRestaurar.Visible := true;
end;
30:
begin
mnuOpcoes.Visible := true;
mnuConfLayout.Visible := true;
end;
31:
begin
mnuOpcoes.Visible := true;
ConfiguraodoPopUpdeInicializao1.Visible := true;
end;
end;
end;
end;
{ // If (GetKeyState(Ord('Q'))<0) and (GetKeyState(Ord('N'))<0) and (GetKeyState(VK_CONTROL)<0)
// Then ShowMessage('You did it :)');
// Função pra facilitar a troca de versão por hora. Rename no executável pra poder colocar um novo na pasta
if (Key in [82, 78]) then
begin
if (Shift = [ssCtrl]) then
begin
FValidKeyCombo := true;
end;
end;
if FValidKeyCombo and (Shift = [ssCtrl]) then
begin
case Key of
// 82:
// if GetKeyState(78) < 0 then
// begin
// RenameFile('Cobrança.exe', 'Cobrança_old.exe');
// end;
78:
if GetKeyState(82) < 0 then
begin
if dtmSystem.id_usuario = 71 then
begin
if FileExists('Cobrança_old.exe') then
begin
i := 1;
while FileExists('Cobrança_old' + inttostr(i) + '.exe') do
begin
Inc(i, 1);
end;
if (i - 1) = 0 then
begin
RenameFile('Cobrança_old.exe', 'Cobrança_old' + inttostr(i)
+ '.exe');
end
else
begin
RenameFile('Cobrança_old' + inttostr(i - 1) + '.exe',
'Cobrança_old' + inttostr(i) + '.exe');
end;
end
else
begin
RenameFile('Cobrança.exe', 'Cobrança_old.exe');
end;
end;
end;
end;
end;
// FValidKeyCombo := ((Shift = [ssCtrl]) and (Key in [82, 77]));
// RenameFile('Cobrança.exe', 'Cobrança_old.exe'); }
end;
end;
procedure TfrmCobranca.FormKeyPress(Sender: TObject; var Key: Char);
begin
FValidKeyCombo := false;
end;
procedure TfrmCobranca.FormShow(Sender: TObject);
begin
// saber que a form já foi mostrada para impedir o redimensionamento
after_show := true;
PostMessage(Handle, WM_STARTUP, 0, 0);
end;
procedure TfrmCobranca.ImportaodeDevedores1Click(Sender: TObject);
begin
impDevedores := TimpDevedores.Create(self);
impDevedores.ShowModal;
end;
procedure TfrmCobranca.mnuAgendaClick(Sender: TObject);
begin
frmAgenda := TfrmAgenda.Create(self);
frmAgenda.Show;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
end;
procedure TfrmCobranca.mnuAgendamentoClick(Sender: TObject);
begin
frmAgendamento := TfrmAgendamento.Create(self);
frmAgendamento.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuAgendamento.Visible := dtmSystem.VerificarPermissao('CBR.01.05');
end;
procedure TfrmCobranca.mnuAtendimentoClick(Sender: TObject);
begin
// mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.04');
// mnuAtendimento.Visible := dtmSystem.VerificarPermissao('CBR.04.04');
// abertura da janela de atendimento
dtmSystem.OpenOrRefresh(dtmSystem.tblDevedores);
if dtmSystem.tblDevedores.RecordCount = 0 then
begin
MessageDlg
('Não há devedores cadastrados para que um atendimento possa ser feito.' +
' Não é possível abrir o atendimento.', mtWarning, [mbOK], 0);
end
else
begin
frmAtendimento := TfrmAtendimento.Create(self);
frmAtendimento.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuAtendimento.Visible := dtmSystem.VerificarPermissao('CBR.01.03');
end;
end;
procedure TfrmCobranca.mnuEntradaClick(Sender: TObject);
begin
// chama janela de config do relatório de entrada
confrelBordero := TconfrelBordero.Create(self);
confrelBordero.ShowModal;
mnuRelatorios.Visible := dtmSystem.VerificarPermissao('CBR.03');
mnuEntrada.Visible := dtmSystem.VerificarPermissao('CBR.03.01');
end;
procedure TfrmCobranca.mnuEnvBancoOnlineClick(Sender: TObject);
begin
// primeiros testes pro envio do banco online para site de cobrança
// with dtmSystem do
// begin
// try
// JsonBuilderOnline(tblEstados, 'cobranca.estado', 'ID_ESTADO',
// 'http://192.168.0.154:8000/api/cobranca/estados');
// Except
//
// end;
// end;
mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.04');
mnuEnvBancoOnline.Visible := dtmSystem.VerificarPermissao('CBR.04.06');
end;
procedure TfrmCobranca.mnuIndicesClick(Sender: TObject);
begin
mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.04');
mnuIndices.Visible := dtmSystem.VerificarPermissao('CBR.04.01');
// chama janela de cadastro de índices
cadIndices := TcadIndices.Create(self);
cadIndices.ShowModal;
end;
procedure TfrmCobranca.mnuLogClick(Sender: TObject);
begin
frmLogActions := TfrmLogActions.Create(self);
frmLogActions.ShowModal;
end;
procedure TfrmCobranca.mnuMandaEmailClick(Sender: TObject);
begin
frmMandaMensagem := TfrmMandaMensagem.Create(self);
frmMandaMensagem.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuMandaEmail.Visible := dtmSystem.VerificarPermissao('CBR.01.06');
end;
procedure TfrmCobranca.mnuModeloRepasseClick(Sender: TObject);
begin
mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.04');
mnuModeloRepasse.Visible := dtmSystem.VerificarPermissao('CBR.04.02');
// chama a janela de modelos de repasse
cadModeloRepasse := TcadModeloRepasse.Create(self);
cadModeloRepasse.ShowModal;
end;
procedure TfrmCobranca.mnuPrestacaoContasClick(Sender: TObject);
begin
// mnuRelatorios.Visible := dtmSystem.VerificarPermissao('CBR.03');
// mnuPrestacaoContas.Visible := dtmSystem.VerificarPermissao('CBR.03.02');
// chama a janela de config do relatório de prestação de contas
confrelPrestacaoContas := TconfrelPrestacaoContas.Create(self);
confrelPrestacaoContas.ShowModal;
mnuRelatorios.Visible := dtmSystem.VerificarPermissao('CBR.03');
mnuPrestacaoContas.Visible := dtmSystem.VerificarPermissao('CBR.03.02');
end;
procedure TfrmCobranca.mnu_altloginClick(Sender: TObject);
var
hoje: string;
begin
// Alterar o tipo de usuário logado
// tmr_sessao.Enabled := false;
with dtmSystem do
begin
// abre a tabela usuários
OpenOrRefresh(tblUsuarios);
if tblUsuarios.IsEmpty then
begin
// tmr_sessao.Enabled := true;
exit; // se vazia, sai
end;
// parte do processo de controle de sessão de ususário
// desabilitado a pedido da Bruna
// with dtmSystem do
// begin
// tblLogins.Open;
// tblLogins.Filter := 'ID_USUARIO = ' + inttostr(id_usuario);
// tblLogins.Filtered := true;
// tblLogins.Last;
// tblLogins.Edit;
// tblLoginsDT_LOGOFF.AsDateTime := Date;
// tblLoginsHR_LOGOFF.AsDateTime := now;
// tblLogins.Post;
// tblLogins.Filter := '';
// tblLogins.Filtered := false;
// tblLogins.Close;
// if not tblSessao.Active then
// begin
// tblSessao.Open;
// end;
// if tblSessao.Locate('ID_USUARIO', id_usuario, []) then
// begin
// tblSessao.Delete;
// tblSessao.Close;
// end;
// end;
with TfrmLogin.Create(nil) do
begin
try
ShowModal; // abre a janela login (frmLogin)
finally
Free;
end;
end;
if acesso = false then
begin
Application.Terminate;
// se o usuário não teve acesso (qualquer motivo), fecha o programa
end;
// abre as tabelas pra ver os acessos
OpenOrRefresh(tblPermissoes);
OpenOrRefresh(tblGrupos);
OpenOrRefresh(tblGruposPermissoes);
if acesso = true then
begin
// código de tratamento de usuário vem aqui a princípio
stsbar.Panels[0].Text := 'Usuário: ' + dtmSystem.tx_usuario + ' Grupo: ' +
dtmSystem.tx_grupo;
stsbar.Panels[1].Text := 'Ctrl+k para conceder permissões';
stsbar.Panels[2].Text := 'Banco de dados: ' +
dtmSystem.ZConnection.Database;
stsbar.Panels[3].Text := 'Versão: ' + GetAppVersionStr;
timer_display.Interval := 1;
hoje := DateToStr(Date);
hoje := RightStr(hoje, 4) + '-' + copy(hoje, 4, 2) + '-' +
LeftStr(hoje, 2);
with zroqryContatos.SQL do
begin
Clear;
Add('select');
Add('h.id_cobrador,');
Add('case when u.tx_nome is not NULL then u.tx_nome when u.tx_nome is NULL then '
+ Quotedstr('Usuário Inexistente') + ' end as NOME,');
Add('COUNT (DISTINCT h.ID_DEVEDOR) as qtde_acionamentos');
Add('from chg_historico h');
Add('left join sys_usuarios u on h.id_cobrador = u.id_usuario');
Add('where h.id_cobrador in (select id_usuario from sys_usuarios where tp_ativo = '
+ Quotedstr('S') + ')');
Add('and CAST(h.dt_contato AS DATE) >= ' + Quotedstr(hoje) + ' and');
Add('CAST(h.dt_contato AS DATE) <= ' + Quotedstr(hoje));
Add('and h.id_cobrador = ' + inttostr(dtmSystem.id_usuario));
Add('group by h.id_cobrador, u.tx_nome');
Add('order by NOME, qtde_acionamentos desc');
end;
zroqryContatos.Open;
MakePermissoes;
ChecaPermissoes;
perm_caddev := true;
perm_cobtel := true;
atualizaagenda;
with TIniFile.Create(ExtractFilePath(Application.ExeName) +
'sistema.ini') do
begin
dtmSystem.public_key := ReadString('cert', 'pub-key', '');
dtmSystem.private_key := ReadString('cert', 'priv-key', '');
dtmSystem.certificate_key := ReadString('cert', 'cert-key', '');
dtmSystem.conta_corrente := ReadString('cert', 'cc', '');
end;
if (dtmSystem.public_key <> '') and (dtmSystem.id_grupo = 1) then
begin
mnuBoletos.Visible := true;
end
else
begin
mnuBoletos.Visible := false;
end;
// parte do processo de controle e sessão do usuário
// desabilitado a pedido da Bruna
// with dtmSystem do
// begin
// tblLogins.Open;
// tblLogins.Append;
// tblLoginsID_USUARIO.AsInteger := id_usuario;
// tblLoginsDT_LOGIN.AsDateTime := Date;
// tblLoginsHR_LOGIN.AsDateTime := now;
// tblLogins.Post;
// tblLogins.Close;
// if not tblSessao.Active then
// begin
// tblSessao.Open;
// end;
// if not(tblSessao.Locate('ID_USUARIO', id_usuario, [])) then
// begin
// tblSessao.Append;
// tblSessaoID_USUARIO.AsInteger := id_usuario;
// tblSessaoTP_ATIVA.AsInteger := 1;
// tblSessao.Post;
// end;
// end;
// tmr_sessao.Enabled := true;
end;
end;
end;
procedure TfrmCobranca.mnuImptccClick(Sender: TObject);
begin
// frmImpTCC := TfrmImpTCC.Create(self);
// frmImpTCC.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01.08');
end;
procedure TfrmCobranca.mnu_RecibosEmitidosClick(Sender: TObject);
begin
confrelRecibosEmitidos := TconfrelRecibosEmitidos.Create(self);
confrelRecibosEmitidos.ShowModal;
mnuRelatorios.Visible := dtmSystem.VerificarPermissao('CBR.03');
mnu_RecibosEmitidos.Visible := dtmSystem.VerificarPermissao('CBR.03.03');
end;
procedure TfrmCobranca.mnuDevedoresClick(Sender: TObject);
begin
// mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
// mnuDevedores.Visible := dtmSystem.VerificarPermissao('CBR.02.03');
// chamada da janela de devedores
if not dtmSystem.tblCHGEmpresa.Active then
begin
dtmSystem.tblCHGEmpresa.Open;
end;
if dtmSystem.tblCHGEmpresa.IsEmpty then
begin
MessageDlg
('Por favor cadastre Beneficiários antes de cadastrar algum Devedor.',
mtWarning, [mbOK], 0);
end
else
begin
Screen.Cursor := crHourGlass;
cadDevedores := TcadDevedores.Create(self); // abre a janela devedores
cadDevedores.pesquisa := 0;
// sinaliza que não foi aberto através de pesquisa
cadDevedores.ShowModal;
if importar then
begin
with TimpDevedores.Create(self) do
begin
ShowModal;
end;
end;
end;
mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
mnuDevedores.Visible := dtmSystem.VerificarPermissao('CBR.02.01');
end;
procedure TfrmCobranca.mnuDigito9Click(Sender: TObject);
begin
// Método para adicionar o dígito 9 aos telefones celulares e garantir que estão marcados como fixo/celular de forma correta
if (MessageDlg
('Esta operação irá adicionar o dígito 9 a todos os números de celular que ainda não o possuam.'
+ ' Isso pode demorar alguns minutos. Deseja continuar?', mtConfirmation,
mbYesNo, 0) = mrYes) then
begin
frmDigito9 := TfrmDigito9.Create(self);
frmDigito9.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuDigito9.Visible := dtmSystem.VerificarPermissao('CBR.01.07');
end;
end;
procedure TfrmCobranca.mnuUsuariosClick(Sender: TObject);
begin
// mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
// mnuUsuarios.Visible := dtmSystem.VerificarPermissao('CBR.02.02');
// abrir a janela de usuários - é instânciado a classe numa variável para que possamos
// acessar as variáveis dentro da classe
cadUsuarios := TcadUsuarios.Create(self);
cadUsuarios.ShowModal;
mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
mnuUsuarios.Visible := dtmSystem.VerificarPermissao('CBR.02.03');
end;
procedure TfrmCobranca.Panel2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
// teste pra poder mover um componentes arrastanto com o mouse
//SetCapture(Panel2.Handle);
Capturing := true;
MouseDownSpot.X := X;
MouseDownSpot.Y := Y;
end;
procedure TfrmCobranca.Panel2MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
Left, Top: Integer;
begin
// teste pra poder mover um componentes arrastanto com o mouse
if Capturing then
begin
//Left := Panel2.Left - (MouseDownSpot.X - X);
//Top := Panel2.Top - (MouseDownSpot.Y - Y);
if Left <= 1 then
begin
Left := 1;
end;
if Top <= 1 then
begin
Top := 1;
end;
// if Left >= (frmCobranca.ClientWidth - Panel2.Width) then
// begin
// Left := (frmCobranca.ClientWidth - Panel2.Width);
// end;
// if Top >= (frmCobranca.ClientHeight - Panel2.Height) then
// begin
// Top := (frmCobranca.ClientHeight - Panel2.Height);
// end;
// Panel2.Left := Left;
// Panel2.Top := Top;
end;
end;
procedure TfrmCobranca.Panel2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Left, Top: Integer;
begin
// teste pra poder mover um componentes arrastanto com o mouse
if Capturing then
begin
ReleaseCapture;
Capturing := false;
//Left := Panel2.Left - (MouseDownSpot.X - X);
//Top := Panel2.Top - (MouseDownSpot.Y - Y);
if Left <= 1 then
begin
Left := 1;
end;
if Top <= 1 then
begin
Top := 1;
end;
//Panel2.Left := Left;
//Panel2.Top := Top;
end;
end;
procedure TfrmCobranca.PrestaodeContasTCC1Click(Sender: TObject);
begin
// confrelRelatorioTCC := TconfrelRelatorioTCC.Create(self);
// confrelRelatorioTCC.ShowModal;
mnuRelatorios.Visible := dtmSystem.VerificarPermissao('CBR.03');
PrestaodeContasTCC1.Visible := dtmSystem.VerificarPermissao('CBR.03.04');
end;
procedure TfrmCobranca.RelatriodeGerncia1Click(Sender: TObject);
begin
confRelGerencia := TconfRelGerencia.Create(self);
confRelGerencia.ShowModal;
end;
procedure TfrmCobranca.mnuPesquisaClick(Sender: TObject);
begin
// abrir a pesquisa de devedores
if frmPesquisa <> nil then
begin
frmPesquisa.SetFocus;
abort;
end;
frmPesquisa := TfrmPesquisa.Create(self);
frmPesquisa.Show;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuPesquisa.Visible := dtmSystem.VerificarPermissao('CBR.01.02');
end;
procedure TfrmCobranca.mnuRankingsClick(Sender: TObject);
begin
frmRanking := TfrmRanking.Create(self);
frmRanking.ShowModal;
mnuRankings.Visible := dtmSystem.VerificarPermissao('CBR.01.11');
end;
procedure TfrmCobranca.mnuRecibosClick(Sender: TObject);
begin
frmAchaRecibo := TfrmAchaRecibo.Create(self);
frmAchaRecibo.ShowModal;
end;
procedure TfrmCobranca.mnuRelAcordosClick(Sender: TObject);
begin
confrelAcordos := TconfrelAcordos.Create(self);
confrelAcordos.ShowModal;
end;
procedure TfrmCobranca.mnuRemessaClick(Sender: TObject);
begin
frmRemessa := TfrmRemessa.Create(self);
frmRemessa.ShowModal;
end;
procedure TfrmCobranca.mnuProvidenciasClick(Sender: TObject);
begin
// mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
// mnuReferencias.Visible := dtmSystem.VerificarPermissao('CBR.02.04');
// chama a janela de providências/referências
cadProvidencias := TcadProvidencias.Create(self);
cadProvidencias.ShowModal;
mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
mnuProvidencias.Visible := dtmSystem.VerificarPermissao('CBR.02.04');
end;
procedure TfrmCobranca.mnuRestaurarClick(Sender: TObject);
begin
// Restauração de Banco de Dados
// mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.01');
// mnuBancoDados.Visible := dtmSystem.VerificarPermissao('CBR.01.03');
// if MessageDlg
// ('Você está prestes a restaurar o Banco de dados para uma versão mais antiga. Realmente deseja continuar? '
// + 'Esta ação se realizada incorretamente pode causar erros gravíssimos. ' +
// 'Após a restauração o programa deve ser reiniciado.', mtWarning,
// [mbYes, mbNo], 0) = mrYes then
// begin
// with odRestore do
// begin
// Execute;
// if odRestore.FileName <> '' then
// begin
// try
// dtmSystem.ZConnection.Disconnect;
// dtmSystem.ZConnection.Connect;
// // tmr_sessao.Enabled := false;
// timer_display.Enabled := false;
// with FDIBRestore do
// begin
// UserName := 'SYSDBA';
// Password := 'masterkey';
// Host := copy(dtmSystem.ZConnection.Database, 1,
// pos(':', dtmSystem.ZConnection.Database) - 1);
// Protocol := ipTCPIP;
// Verbose := true;
// Options := [roDeactivateIdx, roNoShadow, roNoValidity, roOneAtATime,
// roReplace, roValidate];
// Database := stringreplace(copy(dtmSystem.ZConnection.Database,
// pos(':', dtmSystem.ZConnection.Database) + 1,
// length(dtmSystem.ZConnection.Database)), 'CHARGE.GDB', 'TEMP.GDB',
// [rfReplaceAll, rfIgnoreCase]);
// BackupFiles.Add(odRestore.FileName);
// Restore;
// end;
// DeleteFile(ExtractFilePath(Application.ExeName) + 'CHARGE.GDB');
// RenameFile(ExtractFilePath(Application.ExeName) + 'TEMP.GDB',
// ExtractFilePath(Application.ExeName) + 'CHARGE.GDB');
// MessageDlg('Banco de dados restaurado com sucesso!' + sLineBreak +
// 'Fechando o programa.', mtInformation, [mbOK], 0);
// Close;
// except
// on E: Exception do
// begin
// MessageDlg('Erro ao restaurar o banco de dados!' + sLineBreak +
// E.message, mtError, [mbOK], 0);
// atualizaagenda;
// // tmr_sessao.Enabled := true;
// timer_display.Enabled := true;
// end;
// end;
// end;
//
// end;
// end;
// mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.04');
// mnuBancoDados.Visible := dtmSystem.VerificarPermissao('CBR.04.03');
// mnuRestaurar.Visible := dtmSystem.VerificarPermissao('CBR.04.03.02');
end;
procedure TfrmCobranca.mnuTxtEmailClick(Sender: TObject);
begin
cadTextEmail := TcadTextEmail.Create(self);
cadTextEmail.ShowModal;
mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
mnuTxtEmail.Visible := dtmSystem.VerificarPermissao('CBR.02.07');
end;
procedure TfrmCobranca.stsbarDblClick(Sender: TObject);
var
mouseInStatusBar: TPoint;
pWidth, i: Integer;
begin
// dblclick da status bar para abrir a agenda
with stsbar do
begin
if (SimplePanel) OR (stsbar.Panels.Count = 0) then
i := 0
else
begin
mouseInStatusBar := ScreenToClient(Mouse.CursorPos);
pWidth := 0;
for i := 0 to stsbar.Panels.Count - 2 do
begin
pWidth := pWidth + Panels[i].Width;
if mouseInStatusBar.X <= pWidth then
Break;
end;
end;
if i = 4 then
begin
if not Assigned(frmAgenda) then
begin
frmAgenda := TfrmAgenda.Create(self);
frmAgenda.Show;
end
else
begin
if frmAgenda.WindowState = wsMinimized then
begin
frmAgenda.WindowState := wsNormal;
end;
end;
end;
end;
end;
procedure TfrmCobranca.stsbarDrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
var
tempo1, tempo2, tempo3: TTime;
Text: string;
begin
// desenha os paineis da status bar conforme o atraso da agenda
tempo1 := StrToTime('00:45:00');
tempo2 := StrToTime('00:15:00');
tempo3 := StrToTime('00:00:00');
if (Panel = stsbar.Panels[4]) then
begin
if dia_atrasado then
begin
StatusBar.Canvas.Brush.Color := clRed;
StatusBar.Canvas.Font.Style := StatusBar.Canvas.Font.Style + [fsbold];
pnl_alertaagenda.Visible := false;
Text := 'COBRANÇA ATRASADA';
end
else if (tempo_atrasado) and (eh_hoje = true) then
begin
if CompareTime(quanto_faltat, tempo1) > 0 then
begin
StatusBar.Canvas.Brush.Color := clRed;
StatusBar.Canvas.Font.Style := StatusBar.Canvas.Font.Style + [fsbold];
pnl_alertaagenda.Visible := false;
Text := 'COBRANÇA ATRASADA';
end
else if (CompareTime(quanto_faltat, tempo1) < 0) and
(CompareTime(quanto_faltat, tempo2) >= 0) then
begin
StatusBar.Canvas.Brush.Color := clYellow;
StatusBar.Canvas.Font.Style := StatusBar.Canvas.Font.Style + [fsbold];
pnl_alertaagenda.Visible := true;
Text := 'COBRANÇA ATRASADA';
end
else if (CompareTime(quanto_faltat, tempo2) < 0) and
(CompareTime(quanto_faltat, tempo3) >= 0) then
begin
StatusBar.Canvas.Brush.Color := clGreen;
StatusBar.Canvas.Font.Style := StatusBar.Canvas.Font.Style - [fsbold];
pnl_alertaagenda.Visible := true;
Text := 'COBRAR AGENDADO';
end;
end
else
begin
StatusBar.Canvas.Brush.Color := clSkyBlue;
pnl_alertaagenda.Visible := false;
StatusBar.Canvas.Font.Style := StatusBar.Canvas.Font.Style - [fsbold];
if queryagenda.IsEmpty then
begin
StatusBar.Canvas.Brush.Color := clBtnFace;
pnl_alertaagenda.Visible := false;
StatusBar.Canvas.Font.Style := StatusBar.Canvas.Font.Style - [fsbold];
Text := '';
end
else
begin
StatusBar.Canvas.Brush.Color := clSkyBlue;
pnl_alertaagenda.Visible := false;
StatusBar.Canvas.Font.Style := StatusBar.Canvas.Font.Style - [fsbold];
Text := 'DEVEDOR AGENDADO';
end;
end;
end;
StatusBar.Canvas.FillRect(Rect);
StatusBar.Canvas.TextOut(Rect.Left + 5, Rect.Top, Text);
// StatusBar.Canvas.FrameRect(Rect);
end;
procedure TfrmCobranca.mnuBoletosClick(Sender: TObject);
begin
frmCentralBoletos := TfrmCentralBoletos.Create(self);
frmCentralBoletos.ShowModal;
end;
procedure TfrmCobranca.mnuCredoresClick(Sender: TObject);
begin
// mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
// mnuBeneficiarios.Visible := dtmSystem.VerificarPermissao('CBR.02.01');
cadCredor := TcadCredor.Create(self);
cadCredor.ShowModal;
mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
mnuCredores.Visible := dtmSystem.VerificarPermissao('CBR.02.02');
// abre a janela de cadastro beneficiários
end;
procedure TfrmCobranca.timer_displayTimer(Sender: TObject);
var
hora_marcada, agorat: TTime;
data_marcada, agorad: TDate;
// quanto_faltad: Integer;
begin
// timer_display.Interval := 60000;
// Cálculo do atraso da Agenda que é usado em outras partes do programa
//Label1.Caption := inttostr(queryagenda.RecordCount);
timer_display.Interval := 5000;
queryagenda.Refresh;
dia_atrasado := false;
tempo_atrasado := false;
eh_hoje := false;
if not queryagenda.IsEmpty then
begin
// queryagenda.First;
hora_marcada := StrToTime(FormatDateTime('t',
queryagenda.FieldByName('HR_AGENDADA').AsDateTime));
agorat := StrToTime(FormatDateTime('t', now));
quanto_faltat := hora_marcada - agorat;
data_marcada := queryagenda.FieldByName('DT_AGENDADA').AsDateTime;
agorad := Date;
// quanto_faltad := DaysBetween(data_marcada, agorad);
if (agorad > data_marcada) then
begin
dia_atrasado := true;
end;
if (agorat > hora_marcada) then
begin
tempo_atrasado := true;
end;
if data_marcada = Date then
begin
eh_hoje := true;
end;
end;
stsbar.Repaint;
// if FileExists(ExtractFilePath(Application.ExeName) + 'Cobrança_old.exe') then
// begin
// try
// DeleteFile(ExtractFilePath(Application.ExeName) + 'Cobrança_old.exe');
// except
// end;
// end;
// Label1.Caption := inttostr(dtmSystem.id_usuario);
end;
procedure TfrmCobranca.tmr_loginTimer(Sender: TObject);
var
msg, hoje: string;
data_termino: TDate;
// hmin, hmax: TTime;
// diff: Integer;
begin
// primeiro login ao abrir o programa
// verificar alterar login para comentários na maioria das coisas aqui
tmr_login.Enabled := false;
// para o timer pra não ficar ocorrendo a cada segundo
// abre o arquivo ini para ler o caminho do banco
with dtmSystem do
begin
tblUsuarios.Open;
if tblUsuarios.IsEmpty then
begin
exit;
end;
with TfrmLogin.Create(nil) do
begin
try
ShowModal;
finally
Free;
end;
end;
if dtmSystem.acesso_manager = true then
begin
exit;
end;
tblPermissoes.Open;
tblGrupos.Open;
tblGruposPermissoes.Open;
if acesso = false then
begin
Application.Terminate;
end;
if acesso = true then
begin
if dtmSystem.VerificarVersao = true then
begin
MessageDlg('Este programa se encontra desatualizado.' +
' Ele será fechado para atualizar para a mais nova versão.',
mtWarning, [mbOK], 0);
CopyFile(PCHAR(StringReplace(dtmSystem.ZConnection.Database,
'\Charge.gdb', '', [rfIgnoreCase]) + '\Cobrança.exe'),
PCHAR(ExtractFilePath(Application.ExeName) +
'Cobrança__update.exe'), true);
WinExec('Updater.exe', 0);
Application.ShowMainForm := false;
Application.Terminate;
end;
tmr_update.Enabled := true;
memo_update.Left := memo_update.Parent.Width - memo_update.Width;
dtmSystem.tblEstados.Open;
dtmSystem.tblCidades.Open;
if dtmSystem.tblEstados.IsEmpty then
begin
frmProgressEC := TfrmProgressEC.Create(self);
frmProgressEC.ShowModal;
end;
// dtmSystem.tblEstados.Close;
// dtmSystem.tblCidades.Close;
stsbar.Panels[0].Text := 'Usuário: ' + dtmSystem.tx_usuario;
stsbar.Panels[1].Text := 'Grupo: ' + dtmSystem.tx_grupo;
stsbar.Panels[2].Text := 'Banco de dados: ' +
dtmSystem.ZConnection.Database;
stsbar.Panels[3].Text := 'Versão: ' + GetAppVersionStr;
hoje := DateToStr(Date);
hoje := RightStr(hoje, 4) + '-' + copy(hoje, 4, 2) + '-' +
LeftStr(hoje, 2);
with dtmSystem.zroqryContatos.SQL do
begin
Clear;
Add('select');
Add('h.id_cobrador,');
Add('case when u.tx_nome is not NULL then u.tx_nome when u.tx_nome is NULL then '
+ Quotedstr('Usuário Inexistente') + ' end as NOME,');
Add('COUNT (DISTINCT h.ID_DEVEDOR) as qtde_acionamentos');
Add('from chg_historico h');
Add('left join sys_usuarios u on h.id_cobrador = u.id_usuario');
Add('where h.id_cobrador in (select id_usuario from sys_usuarios where tp_ativo = '
+ Quotedstr('S') + ')');
Add('and CAST(h.dt_contato AS DATE) >= ' + Quotedstr(hoje) + ' and');
Add('CAST(h.dt_contato AS DATE) <= ' + Quotedstr(hoje));
Add('and h.id_cobrador = ' + inttostr(dtmSystem.id_usuario));
Add('group by h.id_cobrador, u.tx_nome');
Add('order by NOME, qtde_acionamentos desc');
end;
dtmSystem.zroqryContatos.Open;
// verificação de permissão de acessos
MakePermissoes;
ChecaPermissoes;
// showmessage(dtmSystem.path_executavel);
// showmessage(dtmSystem.GetAppVersionStr + ' - ' + dtmSystem.version);
// if id_usuario <> 71 then
// begin
// mnuRankings.Visible := false;
// end;
atualizaagenda;
timer_display.Enabled := true;
timer_display.Interval := 1;
// Parte do processo de controle de sessão do usuário
// Desabilitado a pedido da Bruna
// with dtmSystem do
// begin
// tblLogins.Open;
// tblLogins.Append;
// tblLoginsID_USUARIO.AsInteger := id_usuario;
// tblLoginsDT_LOGIN.AsDateTime := Date;
// tblLoginsHR_LOGIN.AsDateTime := now;
// tblLogins.Post;
// tblLogins.Close;
// if not tblSessao.Active then
// begin
// tblSessao.Open;
// end;
// if not(tblSessao.Locate('ID_USUARIO', id_usuario, [])) then
// begin
// tblSessao.Append;
// tblSessaoID_USUARIO.AsInteger := id_usuario;
// tblSessaoTP_ATIVA.AsInteger := 1;
// tblSessao.Post;
// end;
// end;
// tmr_sessao.Enabled := true;
if not(tblEmpresa.Active) then
begin
tblEmpresa.Open;
end;
if tblEmpresa.IsEmpty then // gera a empresa padrão caso não tenha
begin
MessageDlg
('A empresa do programa não se encontra cadastrada. Por favor configure uma nova.',
mtWarning, [mbOK], 0);
with TcadEmpresa.Create(self) do
begin
ShowModal;
end;
end;
if not(tblCHGEmpresa.Active) then
begin
tblCHGEmpresa.Open;
end;
if tblCHGEmpresa.IsEmpty then
begin
MessageDlg
('Para que o financiamento possa ser realizado de forma correta por' +
' favor cadastre o primeiro credor com os dados da empresa compradora do programa.',
mtWarning, [mbOK], 0);
with TcadCredor.Create(self) do
begin
ShowModal;
end;
end;
// with TIniFile.Create(ExtractFilePath(Application.ExeName) +
// 'popup.ini') do
with TIniFile.Create(dtmSystem.path_executavel + '\popup.ini') do
begin
msg := ReadString('MENSAGEM', 'Texto', '');
try
data_termino := StrToDate(ReadString('MENSAGEM', 'Data-Fim', ''));
except
data_termino := 0;
end;
end;
if msg <> '' then
begin
if now < data_termino then
begin
MessageDlg(msg, mtInformation, [mbOK], 0);
end;
end;
with TIniFile.Create(ExtractFilePath(Application.ExeName) +
'sistema.ini') do
begin
dtmSystem.public_key := ReadString('cert', 'pub-key', '');
dtmSystem.private_key := ReadString('cert', 'priv-key', '');
dtmSystem.certificate_key := ReadString('cert', 'cert-key', '');
dtmSystem.conta_corrente := ReadString('cert', 'cc', '');
end;
if (dtmSystem.public_key <> '') and (dtmSystem.id_grupo = 1) then
begin
mnuBoletos.Visible := true;
end
else
begin
mnuBoletos.Visible := false;
end;
end;
end;
frmCobranca.BorderIcons := frmCobranca.BorderIcons - [biMaximize];
// desabilita o botão de maximizar
end;
procedure TfrmCobranca.tmr_sessaoTimer(Sender: TObject);
var
admin: string;
begin
// Timer de controle de sessão do usuário
// Desabilitado a pedido da Bruna
// Label1.Caption := TimeToStr(now);
with TIniFile.Create(ExtractFilePath(Application.ExeName) + 'sistema.ini') do
begin
admin := ReadString('DEVELOPER', 'admin', '');
if admin = 'sim' then
begin
abort;
end;
end;
with dtmSystem do
begin
if not tblSessao.Active then
begin
tblSessao.Open;
end;
tblSessao.Refresh;
if tblSessao.Locate('ID_USUARIO', id_usuario, []) then
begin
if tblSessaoTP_ATIVA.AsInteger = 0 then
begin
// tmr_sessao.Enabled := false;
MessageDlg
('Sua sessão acaba de ser terminada por um administrador. O programa irá terminar agora.',
mtWarning, [mbOK], 0);
tblSessao.Delete;
tblSessao.Close;
Close;
end;
end;
end;
end;
procedure TfrmCobranca.tmr_updateTimer(Sender: TObject);
begin
with TMemIniFile.Create(dtmSystem.path_executavel + '\version_control.ini',
TEncoding.UTF8) do
begin
dtmSystem.version := ReadString('Dados', 'version', '');
end;
if dtmSystem.VerificarVersao = true then
begin
memo_update.Visible := true;
end;
end;
procedure TfrmCobranca.WMStartup(var Msg: TMessage);
var
hoje: string;
begin
// primeiro login ao abrir o programa
// verificar alterar login para comentários na maioria das coisas aqui
tmr_login.Enabled := false;
// para o timer pra não ficar ocorrendo a cada segundo
// abre o arquivo ini para ler o caminho do banco
with dtmSystem do
begin
OpenOrRefresh(tblUsuarios);
if tblUsuarios.IsEmpty then
begin
exit;
end;
with TfrmLogin.Create(nil) do
begin
try
ShowModal;
finally
Free;
end;
end;
if acesso = false then
begin
Application.Terminate;
end;
if dtmSystem.acesso_manager = true then
begin
exit;
end;
//tblPermissoes.Open;
OpenOrRefresh(tblGrupos);
OpenOrRefresh(tblGruposPermissoes);
if acesso = true then
begin
if VerificarVersao = true then
begin
MessageDlg('Este programa se encontra desatualizado.' +
' Ele será fechado para atualizar para a mais nova versão.',
mtWarning, [mbOK], 0);
TFile.copy(dtmSystem.path_att + '\' + dtmSystem.exe + '.exe',
ExtractFilePath(Application.ExeName) + dtmSystem.exe +
'__update.exe');
WinExec('Updater.exe', 0);
Application.ShowMainForm := false;
Application.Terminate;
end;
tmr_update.Enabled := true;
memo_update.Left := memo_update.Parent.Width - memo_update.Width;
{*if tblEstados.IsEmpty then
begin
frmProgressEC := TfrmProgressEC.Create(self);
frmProgressEC.ShowModal;
end;}
// dtmSystem.tblEstados.Close;
// dtmSystem.tblCidades.Close;
stsbar.Panels[0].Text := 'Usuário: ' + dtmSystem.tx_usuario;
stsbar.Panels[1].Text := 'Grupo: ' + dtmSystem.tx_grupo;
stsbar.Panels[2].Text := 'Banco de dados: ' +
dtmSystem.ZConnection.Database;
stsbar.Panels[3].Text := 'Versão: ' + GetAppVersionStr;
hoje := DateToStr(Date);
hoje := RightStr(hoje, 4) + '-' + copy(hoje, 4, 2) + '-' +
LeftStr(hoje, 2);
with zroqryContatos.SQL do
begin
Clear;
Add('select');
Add('h.id_cobrador,');
Add('case when u.tx_nome is not NULL then u.tx_nome when u.tx_nome is NULL then '
+ Quotedstr('Usuário Inexistente') + ' end as NOME,');
Add('COUNT (DISTINCT h.ID_DEVEDOR) as qtde_acionamentos');
Add('from chg_historico h');
Add('left join sys_usuarios u on h.id_cobrador = u.id_usuario');
Add('where h.id_cobrador in (select id_usuario from sys_usuarios where tp_ativo = '
+ Quotedstr('S') + ')');
Add('and CAST(h.dt_contato AS DATE) >= ' + Quotedstr(hoje) + ' and');
Add('CAST(h.dt_contato AS DATE) <= ' + Quotedstr(hoje));
Add('and h.id_cobrador = ' + inttostr(dtmSystem.id_usuario));
Add('group by h.id_cobrador, u.tx_nome');
Add('order by NOME, qtde_acionamentos desc');
end;
zroqryContatos.Open;
// verificação de permissão de acessos
MakePermissoes;
ChecaPermissoes;
// showmessage(dtmSystem.path_executavel);
// showmessage(dtmSystem.GetAppVersionStr + ' - ' + dtmSystem.version);
// if id_usuario <> 71 then
// begin
// mnuRankings.Visible := false;
// end;
atualizaagenda;
timer_display.Enabled := true;
timer_display.Interval := 1;
// Parte do processo de controle de sessão do usuário
// Desabilitado a pedido da Bruna
// with dtmSystem do
// begin
// tblLogins.Open;
// tblLogins.Append;
// tblLoginsID_USUARIO.AsInteger := id_usuario;
// tblLoginsDT_LOGIN.AsDateTime := Date;
// tblLoginsHR_LOGIN.AsDateTime := now;
// tblLogins.Post;
// tblLogins.Close;
// if not tblSessao.Active then
// begin
// tblSessao.Open;
// end;
// if not(tblSessao.Locate('ID_USUARIO', id_usuario, [])) then
// begin
// tblSessao.Append;
// tblSessaoID_USUARIO.AsInteger := id_usuario;
// tblSessaoTP_ATIVA.AsInteger := 1;
// tblSessao.Post;
// end;
// end;
// tmr_sessao.Enabled := true;
{*if tblEmpresa.IsEmpty then // gera a empresa padrão caso não tenha
begin
MessageDlg
('A empresa do programa não se encontra cadastrada. Por favor configure uma nova.',
mtWarning, [mbOK], 0);
with TcadEmpresa.Create(self) do
begin
ShowModal;
end;
end;}
{*if not(tblCHGEmpresa.Active) then
begin
tblCHGEmpresa.Open;
end;
if tblCHGEmpresa.IsEmpty then
begin
MessageDlg
('Para que o financiamento possa ser realizado de forma correta por' +
' favor cadastre o primeiro credor com os dados da empresa compradora do programa.',
mtWarning, [mbOK], 0);
with TcadCredor.Create(self) do
begin
ShowModal;
end;
end;}
// with TIniFile.Create(ExtractFilePath(Application.ExeName) +
// 'popup.ini') do
{*with TIniFile.Create(dtmSystem.path_executavel + '\popup.ini') do
begin
msg := ReadString('MENSAGEM', 'Texto', '');
try
data_termino := StrToDate(ReadString('MENSAGEM', 'Data-Fim', ''));
except
data_termino := 0;
end;
end;
if msg <> '' then
begin
if now < data_termino then
begin
MessageDlg(msg, mtInformation, [mbOK], 0);
end;
end;}
with TIniFile.Create(ExtractFilePath(Application.ExeName) +
'sistema.ini') do
begin
dtmSystem.public_key := ReadString('cert', 'pub-key', '');
dtmSystem.private_key := ReadString('cert', 'priv-key', '');
dtmSystem.certificate_key := ReadString('cert', 'cert-key', '');
dtmSystem.conta_corrente := ReadString('cert', 'cc', '');
end;
if (dtmSystem.public_key <> '') and (dtmSystem.id_grupo = 1) then
begin
mnuBoletos.Visible := true;
end
else
begin
mnuBoletos.Visible := false;
end;
end;
end;
frmCobranca.BorderIcons := frmCobranca.BorderIcons - [biMaximize];
// desabilita o botão de maximizar
end;
procedure TfrmCobranca.mnuVerrecibosClick(Sender: TObject);
begin
frmAchaRecibo := TfrmAchaRecibo.Create(self);
frmAchaRecibo.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuVerrecibos.Visible := dtmSystem.VerificarPermissao('CBR.01.10');
end;
// \[T]/ PRAISE THE SUN \[T]/
procedure TfrmCobranca.mnuEmpresaClick(Sender: TObject);
begin
// mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
// mnuEmpresa.Visible := dtmSystem.VerificarPermissao('CBR.02.05');
cadEmpresa := TcadEmpresa.Create(self);
cadEmpresa.ShowModal;
mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
mnuEmpresa.Visible := dtmSystem.VerificarPermissao('CBR.02.05');
// abre a janela de cadastro da empresa que comprou o programa
end;
procedure TfrmCobranca.mnuGerCampanhaClick(Sender: TObject);
begin
// mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.04');
// mnuGerCampanha.Visible := dtmSystem.VerificarPermissao('CBR.04.03');
frmCampanha := TfrmCampanha.Create(self);
frmCampanha.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuGerCampanha.Visible := dtmSystem.VerificarPermissao('CBR.01.04');
end;
procedure TfrmCobranca.mnuCentralPlanilhamentoClick(Sender: TObject);
begin
frmCentralPlanilhamento := TfrmCentralPlanilhamento.Create(self);
frmCentralPlanilhamento.ShowModal;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuImptcc.Visible := dtmSystem.VerificarPermissao('CBR.01.09');
end;
procedure TfrmCobranca.mnuCobrancaTelClick(Sender: TObject);
begin
pesquisa_camp := false;
if not dtmSystem.tblDevedores.Active then
begin
dtmSystem.tblDevedores.Open;
end;
if dtmSystem.tblDevedores.RecordCount = 0 then
begin
MessageDlg
('Não há devedores cadastrados para que uma cobrança possa ser feita.' +
' Não é possível abrir a cobrança.', mtWarning, [mbOK], 0);
end
else
begin
Screen.Cursor := crHourGlass;
with dtmSystem do
begin
// verifica as campanhas ativas para o usuário em questão
qryConsulta.SQL.Text :=
'select id_campanha, tx_nome from chg_campanhas where id_campanha in (select id_campanha from chg_campanhas_cobradores where id_cobrador = '
+ inttostr(id_usuario) + ') and tp_ativa = ''1'' order by id_campanha';
qryConsulta.Open;
end;
if dtmSystem.qryConsulta.IsEmpty then
begin
MessageDlg
('Este usuário não se encontra inserido em nenhuma campanha ativa no momento.',
mtInformation, [mbOK], 0);
Screen.Cursor := crDefault;
end
else
begin
// janela de escolha de campanha a ser cobrada
frmEscolheCampanha := TfrmEscolheCampanha.Create(self);
frmEscolheCampanha.ShowModal;
if frmEscolheCampanha.ModalResult = mrOk then
begin
Screen.Cursor := crHourGlass;
if not dtmSystem.tblCampanhaDevedores.Active then
begin
dtmSystem.tblCampanhaDevedores.Open;
end;
frmEfetuarCobranca := TfrmEfetuarCobranca.Create(self);
frmEfetuarCobranca.id_campanha := dtmSystem.qryConsulta.FieldByName
('ID_CAMPANHA').AsInteger;
frmEfetuarCobranca.tx_campanha := dtmSystem.qryConsulta.FieldByName
('TX_NOME').AsString;
with frmEfetuarCobranca do
begin
dtmSystem.tblCampanhaDevedores.Filtered := false;
dtmSystem.tblCampanhaDevedores.Filter := 'ID_CAMPANHA = ' +
inttostr(id_campanha);
dtmSystem.tblCampanhaDevedores.Filtered := true;
queryagenda.Refresh;
if (not queryagenda.IsEmpty) then
begin
if Dateof(frmCobranca.queryagenda.FieldByName('DT_AGENDADA')
.AsDateTime) < Dateof(Date) then
begin
dtmSystem.tblDevedores.Locate('ID_DEVEDOR',
frmCobranca.queryagenda.FieldByName('ID_DEVEDOR').AsString, []);
atendimento := 'cobrando';
cb_agendar.Checked := false;
edt_protocolo1.Text := '';
cb_descquit.Checked := false;
cb_descquitClick(frmEfetuarCobranca.cb_descquit);
cb_descpar.Checked := false;
cb_descparClick(frmEfetuarCobranca.cb_descpar);
cb_nmulta.Checked := false;
cb_nmultaClick(frmEfetuarCobranca.cb_nmulta);
pgCobranca.TabIndex := 0;
btn_protocolo.Enabled := true;
MessageDlg
('Você acaba de entrar na sua Agenda. Devedor agendado: ' +
dtmSystem.tblDevedoresTX_NOME.AsString + '. Data agendada: ' +
frmCobranca.queryagenda.FieldByName('DT_AGENDADA').AsString +
'. Hora agendada: ' + frmCobranca.queryagenda.FieldByName
('HR_AGENDADA').AsString + '.', mtWarning, [mbOK], 0);
entrou_agenda := true;
end
else
begin
if Dateof(frmCobranca.queryagenda.FieldByName('DT_AGENDADA')
.AsDateTime) = Dateof(Date) then
begin
if Timeof(frmCobranca.queryagenda.FieldByName('HR_AGENDADA')
.AsFloat) <= Timeof(now) then
begin
dtmSystem.tblDevedores.Locate('ID_DEVEDOR',
frmCobranca.queryagenda.FieldByName('ID_DEVEDOR')
.AsString, []);
atendimento := 'cobrando';
cb_agendar.Checked := false;
edt_protocolo1.Text := '';
cb_descquit.Checked := false;
cb_descquitClick(frmEfetuarCobranca.cb_descquit);
cb_descpar.Checked := false;
cb_descparClick(frmEfetuarCobranca.cb_descpar);
cb_nmulta.Checked := false;
cb_nmultaClick(frmEfetuarCobranca.cb_nmulta);
pgCobranca.TabIndex := 0;
btn_protocolo.Enabled := true;
MessageDlg
('Você acaba de entrar na sua Agenda. Devedor agendado: ' +
dtmSystem.tblDevedoresTX_NOME.AsString + '. Data agendada: '
+ frmCobranca.queryagenda.FieldByName('DT_AGENDADA')
.AsString + '. Hora agendada: ' +
frmCobranca.queryagenda.FieldByName('HR_AGENDADA').AsString
+ '.', mtWarning, [mbOK], 0);
entrou_agenda := true;
end
else
begin
entrou_agenda := false;
end;
end
else
begin
entrou_agenda := false;
end;
end;
end
else
begin
entrou_agenda := false;
end;
if not entrou_agenda then
begin
dtmSystem.tblCampanhaDevedores.Filtered := false;
dtmSystem.tblCampanhaDevedores.Filter := 'ID_CAMPANHA = ' +
inttostr(id_campanha) + ' and TP_ESTADO = ''A''';
dtmSystem.tblCampanhaDevedores.Filtered := true;
dtmSystem.tblCampanhaDevedores.First;
dtmSystem.tblCampanhaDevedores.DisableControls;
// Acha o devedor que deve ser cobrado
while not(dtmSystem.tblCampanhaDevedores.Eof) do
begin
Application.ProcessMessages;
if dtmSystem.tblCampanhaDevedoresTP_COBRANDO.AsInteger <> -1 then
// procura se tem um devedor que estava no meio do processo de ser cobrado pelo cobrador X
begin
if dtmSystem.tblCampanhaDevedoresTP_COBRANDO.AsInteger =
dtmSystem.id_usuario then
begin
dtmSystem.tblDevedores.Locate('ID_DEVEDOR',
dtmSystem.tblCampanhaDevedoresID_DEVEDOR.AsInteger, []);
dtmSystem.tblCampanhaDevedores.EnableControls;
dtmSystem.tblCampanhaDevedores.Filtered := false;
dtmSystem.tblCampanhaDevedores.Filter := 'ID_CAMPANHA = ' +
inttostr(id_campanha);
dtmSystem.tblCampanhaDevedores.Filtered := true;
Break;
end
else
begin
dtmSystem.tblCampanhaDevedores.Next;
end;
end
else
begin
dtmSystem.tblCampanhaDevedores.Edit;
dtmSystem.tblCampanhaDevedoresTP_COBRANDO.AsInteger :=
dtmSystem.id_usuario;
dtmSystem.tblCampanhaDevedores.Post;
dtmSystem.tblDevedores.Locate('ID_DEVEDOR',
dtmSystem.tblCampanhaDevedoresID_DEVEDOR.AsInteger, []);
dtmSystem.tblCampanhaDevedores.EnableControls;
dtmSystem.tblCampanhaDevedores.Filtered := false;
dtmSystem.tblCampanhaDevedores.Filter := 'ID_CAMPANHA = ' +
inttostr(id_campanha);
dtmSystem.tblCampanhaDevedores.Filtered := true;
Break;
end;
end;
Screen.Cursor := crDefault;
dtmSystem.tblCampanhaDevedores.EnableControls;
if dtmSystem.tblCampanhaDevedores.Eof then
begin
MessageDlg
('Não há mais devedores nesta campanha que este usuário possa cobrar.',
mtInformation, [mbOK], 0);
Screen.Cursor := crDefault;
abort;
end;
// dtmSystem.tblCampanhaDevedores.Filtered := false;
end;
end;
Application.ProcessMessages;
Screen.Cursor := crDefault;
frmEfetuarCobranca.ShowModal;
// if pesquisa_camp then
// begin
// frmPesquisa := TfrmPesquisa.Create(self);
// frmPesquisa.Show;
// end;
mnuFerramentas.Visible := dtmSystem.VerificarPermissao('CBR.01');
mnuCobrancaTel.Visible := dtmSystem.VerificarPermissao('CBR.01.01');
end;
end;
end;
end;
procedure TfrmCobranca.mnuContasClick(Sender: TObject);
begin
// mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
// mnuContas.Visible := dtmSystem.VerificarPermissao('CBR.02.06');
cadContas := TcadContas.Create(self);
cadContas.ShowModal;
// mnuCadastros.Visible := dtmSystem.VerificarPermissao('CBR.02');
end;
procedure TfrmCobranca.fecharformsabertas(name_form: string);
// entre com o nome da form que você NÃO quer fechar
var // não estou mais usando esta função a princípio
i: Integer;
begin
pnl_principal.Visible := true;
for i := 0 to Screen.FormCount - 1 do
begin
if (Screen.Forms[i].Showing) and (Screen.Forms[i].Name <> 'frmCobranca') and
(Screen.Forms[i].Name <> name_form) then
begin
Screen.Forms[i].Close;
end;
end;
end;
procedure TfrmCobranca.Agenda1Click(Sender: TObject);
begin
frmAgenda := TfrmAgenda.Create(self);
frmAgenda.Show;
end;
procedure TfrmCobranca.appEventsException(Sender: TObject; E: Exception);
begin
LogError('Exceptions', Format('%s - %s', ['ToString', E.ToString]));
LogError('Exceptions', Format('%s - %s', ['HelpContext', InttoStr(E.HelpContext)]));
LogError('Exceptions', Format('%s - %s', ['Message', E.Message]));
LogError('Exceptions', Format('%s - %s', ['ToString', E.UnitName]));
LogError('Exceptions', Format('%s - %s', ['StackTrace', E.StackTrace]));
if AnsiPos('-902', E.Message) > 0 then
begin
timer_display.Enabled := false;
showmessage
('Perda de conexão com o banco de dados. O programa será finalizado.');
Application.Terminate;
end;
end;
procedure TfrmCobranca.atualizaagenda;
var
ontem, amanha: string;
begin
// Método para atualizar a situação da agenda
DateTimeToString(ontem, 'DD/MM/YYYY', IncDay(Date, -1));
DateTimeToString(amanha, 'DD/MM/YYYY', IncDay(Date, 1));
with queryagenda.SQL do
begin
Text := 'select first 1 * from chg_agenda where id_cobrador = ' +
inttostr(dtmSystem.id_usuario) +
' and tp_situacao = ''A'' order by DT_AGENDADA, HR_AGENDADA';
end;
// queryagenda.Filter := 'DT_AGENDADA >= ' + QuotedStr(ontem) +
// ' and DT_AGENDADA <= ' + QuotedStr(amanha);
// queryagenda.Filtered := true;
queryagenda.Open;
end;
procedure TfrmCobranca.Button1Click(Sender: TObject);
// var
// str, year, month, day: string;
begin
// botão de testes
// dtmSystem.tblEmpresa.Open;
// year := inttostr(YearOf(Date));
// month := inttostr(Monthof(Date)).PadLeft(2, '0');
// day := inttostr(Dayof(Date)).PadLeft(2, '0');
// str := 'CLI_ CRB_' + dtmSystem.tblEmpresaCD_BENEFICIARIO.AsString +
// year + month + day + '_CNAB240REM'
// + '.00001';
end;
procedure TfrmCobranca.Button2Click(Sender: TObject);
// var
// antes: TTime;
begin
// botão de testes
// dtmSystem.tblDevedores.Next;
// dtmSystem.tblTitulos.Locate('ID_DEVEDOR',1337,[]);
// ZQuery1.SQL.Clear;
// ZQuery1.SQL.Text := 'select * from chg_historico where id_devedor = ' +
// dtmSystem.tblDevedoresID_DEVEDOR.AsString;
// antes := Now;
// ZQuery1.Open;
// showmessage(inttostr(MilliSecondsBetween(antes, now)));
// dtmSystem.tblCampanhaDevedores.Open;
// DataSource1.DataSet.Filtered := false;
// DataSource1.DataSet.Filter := 'DT_AGENDADA >= ''03/12/2018''';
// DataSource1.DataSet.Filtered := true;
// Label1.Caption := inttostr(ZQuery2.RecordCount);
// dtmSystem.tblCampanhaDevedores.Open;
// dtmSystem.tblCampanhaDevedores.First;
// while not(dtmSystem.tblCampanhaDevedores.Eof) do
// begin
// dtmSystem.tblCampanhaDevedores.Edit;
// dtmSystem.tblCampanhaDevedoresTP_COBRANDO.AsInteger := -1;
// dtmSystem.tblCampanhaDevedores.Post;
// dtmSystem.tblCampanhaDevedores.Next;
// end;
// dtmSystem.tblDevedores.Open;
// dtmSystem.tblDevedores.Filtered := false;
// dtmSystem.tblDevedores.Filter := 'ID_DEVEDOR = 1';
// dtmSystem.tblDevedores.Filtered := true;
// relTeste := TrelTeste.Create(self);
// relTeste.frRecibo.PreviewModal;
// DataSource1.DataSet.Locate('ID_HISTORICO', 1, [loPartialKey]);
if (dtmSystem.tblDevedores.Locate('CD_CPF', '741.334.467-04', [])) or
(dtmSystem.tblDevedores.Locate('CD_CNPJ', 'aaa', [])) then
begin
end;
end;
procedure TfrmCobranca.Button3Click(Sender: TObject);
begin
// botão de testes
// dtmSystem.tblCobCampanha.Next;
// if dtmSystem.tblCobCampanha.Eof then
// begin
// dtmSystem.tblCobCampanha.First;
// end;
// DataSource1.DataSet.Filtered := false;
// Label1.Caption := inttostr(ZQuery2.RecordCount);
// with TfrmCentralPlanilhamento.Create(self) do
// begin
// ShowModal;
// end;
dtmSystem.tblHistorico.Post;
end;
procedure TfrmCobranca.ChecaPermissoes;
begin
with dtmSystem do
begin
mnuFerramentas.Visible := VerificarPermissao('CBR.01');
{ } mnuCobrancaTel.Visible := VerificarPermissao('CBR.01.01');
{ } mnuPesquisa.Visible := VerificarPermissao('CBR.01.02');
{ } mnuAtendimento.Visible := VerificarPermissao('CBR.01.03');
{ } mnuGerCampanha.Visible := VerificarPermissao('CBR.01.04');
{ } mnuAgendamento.Visible := VerificarPermissao('CBR.01.05');
{ } mnuMandaEmail.Visible := VerificarPermissao('CBR.01.06');
{ } mnuDigito9.Visible := VerificarPermissao('CBR.01.07');
{ } mnuImptcc.Visible := VerificarPermissao('CBR.01.08');
{ } mnuCentralPlanilhamento.Visible := VerificarPermissao('CBR.01.09');
{ } mnuVerrecibos.Visible := VerificarPermissao('CBR.01.10');
{ } mnuRankings.Visible := VerificarPermissao('CBR.01.11');
mnuCadastros.Visible := VerificarPermissao('CBR.02');
{ } mnuDevedores.Visible := VerificarPermissao('CBR.02.01');
{ } mnuCredores.Visible := VerificarPermissao('CBR.02.02');
{ } mnuUsuarios.Visible := VerificarPermissao('CBR.02.03');
{ } mnuProvidencias.Visible := VerificarPermissao('CBR.02.04');
{ } mnuEmpresa.Visible := VerificarPermissao('CBR.02.05');
// { } mnuContas.Visible := VerificarPermissao('CBR.02.06');
{ } mnuTxtEmail.Visible := VerificarPermissao('CBR.02.07');
mnuRelatorios.Visible := VerificarPermissao('CBR.03');
{ } mnuEntrada.Visible := VerificarPermissao('CBR.03.01');
{ } mnuPrestacaoContas.Visible := VerificarPermissao('CBR.03.02');
{ } mnu_RecibosEmitidos.Visible := VerificarPermissao('CBR.03.03');
// { } PrestaodeContasTCC1.Visible := VerificarPermissao('CBR.03.04');
mnuOpcoes.Visible := VerificarPermissao('CBR.04');
{ } mnuIndices.Visible := VerificarPermissao('CBR.04.01');
{ } mnuModeloRepasse.Visible := VerificarPermissao('CBR.04.02');
// { } mnuBancoDados.Visible := VerificarPermissao('CBR.04.03');
{ } mnuBackup.Visible := VerificarPermissao('CBR.04.03.01');
{ } mnuRestaurar.Visible := VerificarPermissao('CBR.04.03.02');
{ } mnuConfLayout.Visible := VerificarPermissao('CBR.04.04');
{ } ConfiguraodoPopUpdeInicializao1.Visible :=
VerificarPermissao('CBR.04.05');
{ } mnuEnvBancoOnline.Visible := VerificarPermissao('CBR.04.06');
end;
if dtmSystem.id_grupo = 1 then
begin
mnuLog.Visible := true;
Visualizar1.Visible := true;
end
else
begin
mnuLog.Visible := false;
Visualizar1.Visible := false;
end;
end;
procedure TfrmCobranca.ConfiguraodoPopUpdeInicializao1Click(Sender: TObject);
begin
frmPopUp := TfrmPopUp.Create(self);
frmPopUp.ShowModal;
mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.04');
ConfiguraodoPopUpdeInicializao1.Visible := dtmSystem.VerificarPermissao
('CBR.04.05');
end;
procedure TfrmCobranca.Departamentos1Click(Sender: TObject);
begin
frmDepartamentos := TfrmDepartamentos.Create(self);
frmDepartamentos.ShowModal;
end;
procedure TfrmCobranca.mnuConfLayoutClick(Sender: TObject);
begin
// mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.01');
// mnuConfLayout.Visible := dtmSystem.VerificarPermissao('CBR.01.04');
confLayouts := TconfLayouts.Create(self);
confLayouts.ShowModal;
mnuOpcoes.Visible := dtmSystem.VerificarPermissao('CBR.04');
mnuConfLayout.Visible := dtmSystem.VerificarPermissao('CBR.04.04');
end;
{ if (not Panel1.Visible) then
begin
AnimateWindow(Panel1.Handle, 200, AW_BLEND or AW_ACTIVATE or
AW_VER_POSITIVE or AW_HOR_POSITIVE);
Panel1.Visible := true;
end
else
begin
AnimateWindow(Panel1.Handle, 200, AW_BLEND or AW_HIDE or AW_VER_NEGATIVE or
AW_HOR_NEGATIVE);
Panel1.Visible := false;
end; }
end.