<commit_before>#!/bin/env python
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
# Name:         contab/sitfidicli.py
# Author:       <NAME> <<EMAIL>>
# Copyright:    (C) 2011 <NAME>. <NAME>, 122 18038 Sanremo (IM)
# ------------------------------------------------------------------------------
# This file is part of X4GA
# 
# X4GA is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# X4GA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with X4GA.  If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------

import wx
import awc.controls.windows as aw
import awc.controls.dbgrid as dbgrid

import contab.pdcint_wdr as wdr

import magazz.dbtables as dbm

import Env
bt = Env.Azienda.BaseTab

import report as rpt


class SitFidiClientiGrid(dbgrid.ADB_Grid):
    
    def __init__(self, parent, dbfid):
        
        self.dbfid = fid = dbfid
        cli = fid.anag
        mpa = cli.modpag
        
        dbgrid.ADB_Grid.__init__(self, parent, db_table=dbfid, can_edit=False, on_menu_select='row')
        
        AC = self.AddColumn
        I = self.TypeFloat(5, bt.VALINT_DECIMALS)
        N = self.TypeInteger(5)
        self.COL_CLICOD = AC(fid, 'codice', label='Cod.', col_width=50)
        self.COL_CLIDES = AC(fid, 'descriz', label='Cliente', col_width=200, is_fittable=True)
        self.COL_CLICOD = AC(mpa, 'codice', label='C.', col_width=50)
        self.COL_CLIDES = AC(mpa, 'descriz', label='Mod.Pag.', col_width=120)
        self.COL_SCOATT = AC(fid, 'fido_scoatt', label='Scoperto', col_type=I)
        self.COL_SCOMAX = AC(cli, 'fido_maximp', label='Scop.MAX', col_type=I)
        self.COL_ESPATT = AC(fid, 'fido_espatt', label='Esposiz.', col_type=I)
        self.COL_ESPMAX = AC(cli, 'fido_maxesp', label='Esp.MAX', col_type=I)
        self.COL_PCFATT = AC(fid, 'fido_pcfatt', label='Scad.', col_type=N)
        self.COL_PCFMAX = AC(cli, 'fido_maxpcf', label='Sc.M.', col_type=N)
        self.COL_GGSATT = AC(fid, 'fido_ggsatt', label='G.Rit', col_type=N)
        self.COL_GGSMAX = AC(cli, 'fido_maxggs', label='GR.M.', col_type=N)
        self.COL_CLI_ID = AC(fid, 'id', label='#pdc', col_width=1)
        
        self.CreateGrid()
        
#        def gfi(tab, col):
#            return tab._GetFieldIndex(col, inline=True)
#        self.AddTotalsRow(self.COL_DESCLI, 'Totali', (gfi(pcf, 'saldo'),
#                                                      gfi(pcf, 'interessi'),))


class SitFidiClientiPanel(aw.Panel):
    
    def __init__(self, *args, **kwargs):
        aw.Panel.__init__(self, *args, **kwargs)
        wdr.SitFidiClientiFunc(self)
        cn = self.FindWindowByName
        self.dbfid = dbm.SituazioneFidiClienti()
        self.gridfid = SitFidiClientiGrid(cn('pangridfid'), self.dbfid)
#        self.UpdateData()
        self.Bind(wx.EVT_BUTTON, self.OnUpdateData, cn('butupdate'))
        self.Bind(wx.EVT_BUTTON, self.OnPrintData, cn('butprint'))
    
    def OnUpdateData(self, event):
        self.UpdateData()
        event.Skip()
    
    def UpdateData(self):
        
        cn = self.FindWindowByName
        
        fid = self.dbfid
        fid.ClearFilters()
        id_agente = cn('id_agente').GetValue()
        cf_all = cn('clifid_all').IsChecked()
        cf_sco = cn('clifid_sco').IsChecked()
        cf_esp = cn('clifid_esp').IsChecked()
        cf_pcf = cn('clifid_pcf').IsChecked()<commit_msg>implementati apertura scheda cliente e situazione dettagliata fido del cliente selezionato<commit_after>#!/bin/env python
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
# Name:         contab/sitfidicli.py
# Author:       <NAME> <<EMAIL>>
# Copyright:    (C) 2011 Astra S.r.l. C.<NAME>, 122 18038 Sanremo (IM)
# ------------------------------------------------------------------------------
# This file is part of X4GA
# 
# X4GA is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# X4GA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with X4GA.  If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------

import wx
import awc.controls.windows as aw
import awc.controls.dbgrid as dbgrid

import contab.pdcint_wdr as wdr

import magazz.dbtables as dbm

import Env
bt = Env.Azienda.BaseTab

import report as rpt

import contab.pdcint as pdcint
from magazz.dataentry import DisplayFidoDialog


class SitFidiClientiGrid(dbgrid.ADB_Grid):
    
    def __init__(self, parent, dbfid):
        
        self.dbfid = fid = dbfid
        cli = fid.anag
        mpa = cli.modpag
        
        dbgrid.ADB_Grid.__init__(self, parent, db_table=dbfid, can_edit=False, on_menu_select='row')
        
        AC = self.AddColumn
        I = self.TypeFloat(5, bt.VALINT_DECIMALS)
        N = self.TypeInteger(5)
        self.COL_CLICOD = AC(fid, 'codice', label='Cod.', col_width=50)
        self.COL_CLIDES = AC(fid, 'descriz', label='Cliente', col_width=200, is_fittable=True)
        self.COL_CLICOD = AC(mpa, 'codice', label='C.', col_width=50)
        self.COL_CLIDES = AC(mpa, 'descriz', label='Mod.Pag.', col_width=120)
        self.COL_SCOATT = AC(fid, 'fido_scoatt', label='Scoperto', col_type=I)
        self.COL_SCOMAX = AC(cli, 'fido_maximp', label='Scop.MAX', col_type=I)
        self.COL_ESPATT = AC(fid, 'fido_espatt', label='Esposiz.', col_type=I)
        self.COL_ESPMAX = AC(cli, 'fido_maxesp', label='Esp.MAX', col_type=I)
        self.COL_PCFATT = AC(fid, 'fido_pcfatt', label='Scad.', col_type=N)
        self.COL_PCFMAX = AC(cli, 'fido_maxpcf', label='Sc.M.', col_type=N)
        self.COL_GGSATT = AC(fid, 'fido_ggsatt', label='G.Rit', col_type=N)
        self.COL_GGSMAX = AC(cli, 'fido_maxggs', label='GR.M.', col_type=N)
        self.COL_CLI_ID = AC(fid, 'id', label='#pdc', col_width=1)
        
        self.CreateGrid()
    
    def OnContextMenu(self, event):
        self.ResetContextMenu()
        row = event.GetRow()
        def on_scheda_cliente(event):
            dlg = None
            self.dbfid.MoveRow(row)
            wx.BeginBusyCursor()
            try:
                dlg = pdcint.ClientiInterrDialog(self, onecodeonly=self.dbfid.id)
                dlg.OneCardOnly(self.dbfid.id)
                dlg.DisplayTab('mastro')
            finally:
                wx.EndBusyCursor()
            if dlg:
                dlg.ShowModal()
                dlg.Destroy()
        self.AppendContextMenuVoice("Apri scheda cliente", on_scheda_cliente)
        def on_apri_fido(event):
            dlg = None
            self.dbfid.MoveRow(row)
            wx.BeginBusyCursor()
            try:
                f = dbm.CtrFidoCliente()
                f.CheckFido(self.dbfid.id)
                dlg = DisplayFidoDialog(self)
                dlg.UpdateValues(f)
            finally:
                wx.EndBusyCursor()
            if dlg:
                dlg.ShowModal()
                dlg.Destroy()
        self.AppendContextMenuVoice("Dettaglio affidamento", on_apri_fido)
        return dbgrid.ADB_Grid.OnContextMenu(self, event)


class SitFidiClientiPanel(aw.Panel):
    
    def __init__(self, *args, **kwargs):
        aw.Panel.__init__(self, *args, **kwargs)
        wdr.SitFidiClientiFunc(self)
        cn = self.FindWindowByName
        self.dbfid = dbm.SituazioneFidiClienti()
        self.gridfid = SitFidiClientiGrid(cn('pangridfid'), self.dbfid)
#        self.UpdateData()
        self.Bind(wx.EVT_BUTTON, self.OnUpdateData, cn('butupdate'))
        self.Bind(wx.EVT_BUTTON, self.OnPrintData, cn('butprint'))
    
    def OnUpdateData(self, event):
        self.UpdateData()
        event.Skip()
    
    def UpdateData(self):
        
        cn = self.FindWindowByName
        
        fid = self.dbfid
        fid.ClearFilters()
        id_agente = cn('id_agente').GetValue()
        cf_all = cn('clifid_all').IsChecked()
        cf_sco = cn('clifid_sco').IsChecked()
        cf_esp = cn('clifid_esp').IsChecked()
        cf_pcf = cn('clifid_pcf').IsChecked()
{'fraction_non_alphanumeric': 0.1669814465059438, 'fraction_numerical': 0.0068881235418286856, 'mean_word_length': 2.169718309859155, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7516592', 'n_tokens_mistral': 3080, 'n_tokens_neox': 3018, 'n_words': 653}