Modifiche generali alle vendite.

git-svn-id: svn://10.65.10.50/trunk@2237 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
matteo 1995-12-04 17:41:06 +00:00
parent ce0a332775
commit 407c8a6a87
18 changed files with 4109 additions and 3660 deletions

View File

@ -2,6 +2,28 @@
#include "sconti.h" #include "sconti.h"
#endif #endif
#ifndef __VEUML_H
#include "veuml.h"
#endif
#ifndef __VEUML2_H
#include "veuml2.h"
#endif
#ifndef __TCLIFOR_H
#include "tclifor.h"
#endif
#ifndef __CONFIG_H
#include "config.h"
#endif
#ifndef __VECONF_H
#include "veconf.h"
#endif
#define A_ANAMAG 0
const real TSconto::cento( "100" ); const real TSconto::cento( "100" );
void TSconto::set( const TString& exp, bool signal ) void TSconto::set( const TString& exp, bool signal )
@ -67,7 +89,7 @@ void TSconto::set( const TString& exp, bool signal )
_errorpos = i; _errorpos = i;
break; break;
} }
// Se occorrenva un numero ci metto lo 0 // Se occorreva un numero ci metto lo 0
if( startnum ) if( startnum )
num << '0'; num << '0';
// Interpreto la virgola come punto // Interpreto la virgola come punto
@ -109,8 +131,189 @@ real TSconto::sconto( )
return ( ( _part * cento ) - cento ); return ( ( _part * cento ) - cento );
} }
void calcola_sconto_riga( TRectype riga )
TSconto_riga::TSconto_riga( TCliFor& clifo, TMask * testa, TMask * riga ) : _condv( LF_CONDV ), _rcondv( LF_RCONDV ), _anamag( LF_ANAGR ), _sconti( LF_SCONTI ), _ditta( CONFIG_DITTA )
{
_clifo = &clifo;
_testa = testa;
_riga = riga;
}
bool TSconto_riga::cerca_condv( int tiporicerca )
{
TString s1 = _anamag.get( "CODART" );
TString s2 = riga( ).get( FS_CODART );
if( s1 != s2 )
{
_anamag.setkey( 1 );
_anamag.zero( );
_anamag.put( "CODART", riga( ).get( FS_CODART ) );
int ret = _anamag.read( );
CHECK( ret == NOERR, "Articolo non trovato in anagrafica di magazzino!" );
}
if( tiporicerca == A_ANAMAG )
// Se ricercavo per anagrafica, ho già finito
return TRUE;
if( _ditta.get_bool( "GES", "ve", tiporicerca ) )
{
// Se è attiva la gestione contratti ...
_condv.setkey( 1 );
_condv.zero( );
switch( tiporicerca )
{
case A_CONTRATTI:
_condv.put( "TIPO", "C" );
_condv.blank( "CATVEN" );
if( _ditta.get_bool( "GESSCONCC", "ve" ) )
{
// Se in ditta è abilitata la gestione del cliente in chiave
// al contratto, lo carico con gioia
_condv.put( "TIPOCF", clifo( ).tipocf( ) );
_condv.put( "CODCF", clifo( ).codcf( ) );
}
else
{
_condv.blank( "TIPOCF" );
_condv.blank( "CODCF" );
}
_condv.put( "COD", testa( ).get( F_CODCONT ) );
break;
case A_LISTINI:
_condv.put( "TIPO", "L" );
if( _ditta.get_bool( "GESLISCV", "ve" ) )
{
// Se in ditta è abilitata la gestione del cliente in chiave
// al contratto, lo carico con gioia
_condv.put( "TIPOCF", clifo( ).tipocf( ) );
_condv.put( "CODCF", clifo( ).codcf( ) );
}
else
{
_condv.blank( "TIPOCF" );
_condv.blank( "CODCF" );
}
_condv.blank( "CATVEN" );
_condv.put( "COD", testa( ).get( F_CODLIST ) );
break;
case A_OFFERTE:
_condv.put( "TIPO", "O" );
_condv.blank( "CATVEN" );
_condv.blank( "TIPOCF" );
_condv.blank( "CODCF" );
_condv.put( "COD", testa( ).get( F_CODCAMP ) );
break;
}
if( _condv.read( ) == NOERR )
{
_rcondv.setkey( 2 );
_rcondv.zero( );
_rcondv.put( "TIPO", _condv.get( "TIPO" ) );
_rcondv.put( "CATVEN", _condv.get( "CATVEN" ) );
_rcondv.put( "TIPOCF", _condv.get( "TIPOCF" ) );
_rcondv.put( "CODCF", _condv.get( "CODCF" ) );
if( _condv.get_bool( "GESTUM" ) )
{
_rcondv.put( "UM", riga( ).get( FS_UMQTA ) );
}
else
{
_rcondv.blank( "UM" );
}
if( _condv.get_bool( "GESTSCA" ) )
{
_rcondv.put( "QLIM", riga( ).get( FS_QTA ) );
}
else
{
_rcondv.blank( "QLIM" );
}
const TString16 seqricrighe( _condv.get( "SEQRIC" ) );
for( int i = 0; i < seqricrighe.len( ); i ++ )
{ {
char ricerca = seqricrighe[ i ];
_rcondv.put( "TIPORIGA", ricerca );
switch( ricerca )
{
case 'A':
_rcondv.put( "CODRIGA", _anamag.get( "CODART" ) );
if( _rcondv.read( ) == NOERR ) return TRUE;
break;
case 'R':
_rcondv.put( "CODRIGA", _anamag.get( "RAGGFIS" ) );
if( _rcondv.read( ) == NOERR ) return TRUE;
break;
case 'G':
_rcondv.put( "CODRIGA", _anamag.get( "GRMERC1" ) );
if( _rcondv.read( ) == NOERR ) return TRUE;
_rcondv.put( "CODRIGA", _anamag.get( "GRMERC2" ) );
if( _rcondv.read( ) == NOERR ) return TRUE;
_rcondv.put( "CODRIGA", _anamag.get( "GRMERC3" ) );
if( _rcondv.read( ) == NOERR ) return TRUE;
break;
default:
CHECK( FALSE, "Tipo di ricerca righe non valido!" );
}
}
// Ricerca fallita
return FALSE;
}
else
// Ricerca fallita
return FALSE;
}
else
// La ricerca non è gestita, impossibile trovarlo ...
return FALSE;
}
// Probabilmente dovrebbe lavorare sulla maschera, ma per ora la lasciamo così
void TSconto_riga::calcola( )
{
char gestione = _ditta.get_char( "GESSCORIGA", "ve" );
bool trovato = TRUE;
switch( gestione )
{
case 'N':
// Sconti di riga non gestiti
set( "" );
break;
case 'L':
// Percentuale su contratti/offerte/listini/anagrafica
trovato = cerca_condv( A_CONTRATTI );
if( !trovato ) trovato = cerca_condv( A_OFFERTE );
if( !trovato ) trovato = cerca_condv( A_LISTINI );
if( !trovato )
set( _rcondv.get( "SCONTO" ) );
else
{
if( cerca_condv( A_ANAMAG ) )
set( _anamag.get( "SCONTO" ) );
else
CHECK( FALSE, "Sconto non trovato!( 1 )" );
}
break;
case 'A':
// Posiziono l'anagrafica
cerca_condv( A_ANAMAG );
_sconti.setkey( 1 );
_sconti.put( "TIPO", "R" );
_sconti.put( "CODART", _anamag.get( "CODART" ) );
if( _ditta.get_bool( "GESSCORIGACV", "ve" ) )
{
_sconti.put( "CODCAT", clifo( ).get( LF_CFVEN, "SCONTO" ) );
}
if( _ditta.get_bool( "GESSCORIGAUM", "ve" ) )
{
_sconti.put( "UM", riga( ).get( FS_UMQTA ) );
}
if( _sconti.read( ) == NOERR )
// Bravo, hai vinto una bambolina
set( _sconti.get( "SCONTO" ) );
else
CHECK( FALSE, "Sconto non trovato!( 2 )" );
break;
case 'C':
set( clifo( ).get( LF_CFVEN, "SCONTO" ) );
}
} }

View File

@ -5,6 +5,19 @@
#include <real.h> #include <real.h>
#endif #endif
#ifndef __TCLIFOR_H
#include "tclifor.h"
#endif
#ifndef __MASK_H
#include <mask.h>
#endif
#ifndef __CONFIG_H
#include <config.h>
#endif
#define CHKVALID CHECK( _valid, "Tentativo di usare uno sconto non valido!" ) #define CHKVALID CHECK( _valid, "Tentativo di usare uno sconto non valido!" )
class TSconto : public TObject class TSconto : public TObject
@ -28,4 +41,35 @@ public:
}; };
#undef CHKVALID #undef CHKVALID
class TSconto_riga : public TSconto
{
private:
TCliFor* _clifo;
// TRelation _condv;
// Invece che la relazione uso i due files, poichè mi interessa sempre
// solo una delle righe
TLocalisamfile _condv;
TLocalisamfile _rcondv;
TLocalisamfile _anamag;
TLocalisamfile _sconti;
TConfig _ditta;
TMask* _testa;
TMask* _riga;
protected:
public:
TSconto_riga( TCliFor& clifo, TMask * testa = NULL, TMask * riga = NULL );
TCliFor& clifo( ){ return *_clifo; }
void set_testa( TMask& testa ){ _testa = &testa; }
TMask& testa( ){ return *_testa; }
void set_riga( TMask& riga ){ _riga = &riga; }
TMask& riga( ){ return *_riga; }
bool cerca_condv( int tiporicerca );
void calcola( );
};
#endif #endif

View File

@ -151,18 +151,25 @@ void TCliForVendite::update_mask( TMask_vendite& m, bool onload )
} }
if ( !stato.blank( ) ) if ( !stato.blank( ) )
m.set( F_DESSTATOCF, get( "%STA", stato, "S0" ) ); m.set( F_DESSTATOCF, get( "%STA", stato, "S0" ) );
TString16 tmpstr( m.get( F_CODPAG ) ); m.check_field( F_CODPAG );
if( !tmpstr.blank( ) ) m.check_field( F_CODLIN );
{ // m.check_field( F_CODABIA );
m.field( F_CODPAG ).on_hit( ); m.check_field( F_CODCABA );
m.field( F_CODPAG ).check( ); // m.check_field( F_CODABIP );
} m.check_field( F_CODCABP );
tmpstr = m.get( F_CODLIN ); m.check_field( F_CODINDSP );
if( !tmpstr.blank( ) ) m.check_field( F_CODAG );
m.field( F_CODLIN ).check( ); m.check_field( F_CODSPMEZZO );
m.check_field( F_CODPORTO );
m.check_field( F_CODNOTESP1 );
m.check_field( F_CODNOTESP2 );
m.check_field( F_CODVETT1 );
m.check_field( F_CODVETT2 );
m.check_field( F_CODVETT3 );
imposta_dati_comune( m ); imposta_dati_comune( m );
imposta_indirizzo_spedizione( m ); imposta_indirizzo_spedizione( m );
imposta_sconto_testa( m ); imposta_sconto_testa( m );
imposta_valuta( m );
} }
void TCliFor::edita_occasionale( ) void TCliFor::edita_occasionale( )
@ -289,15 +296,27 @@ void TCliForVendite::imposta_sconto_testa( TMask_vendite& m )
codsconto = get( LF_CFVEN, "CODSCC" ); codsconto = get( LF_CFVEN, "CODSCC" );
if( !codsconto.blank( ) ) if( !codsconto.blank( ) )
{ {
TLocalisamfile sconti( LF_SCONTI ); // ARCHIVIO SVCONTI PER SCONTO CLIENTE
// TLocalisamfile sconti( LF_SCONTI );
// sconti.setkey( 1 );
// sconti.zero( );
// sconti.put( "TIPO", "D" );
// sconti.put( "CODCAT", codsconto );
// if( sconti.read( ) == NOERR )
// m.set( F_SCONTOPERC, sconti.get( "SCONTO" ) );
// else
// message_box( "Sconto non trovato nella tabella sconti!" );
TTable sconti( "%SCC" );
sconti.setkey( 1 ); sconti.setkey( 1 );
sconti.zero( ); sconti.zero( );
sconti.put( "TIPO", "D" ); // sconti.put( "TIPO", "D" );
sconti.put( "CODCAT", codsconto ); sconti.put( "CODTAB", codsconto );
if( sconti.read( ) == NOERR ) if( sconti.read( ) == NOERR )
m.set( F_SCONTOPERC, sconti.get( "SCONTO" ) ); m.set( F_SCONTOPERC, sconti.get( "S1" ) );
#ifdef DBG
else else
message_box( "Sconto non trovato nella tabella sconti!" ); message_box( "Sconto non trovato nella tabella sconti!" );
#endif
} }
return; return;
break; break;
@ -307,29 +326,59 @@ void TCliForVendite::imposta_sconto_testa( TMask_vendite& m )
sconti.zero( ); sconti.zero( );
sconti.put( "TIPO", "I" ); sconti.put( "TIPO", "I" );
if( ditta.get_bool( "SCOKEY", "ve", 1 ) ) if( ditta.get_bool( "SCOKEY", "ve", 1 ) )
{
sconti.put( "CODCAT", get( LF_CFVEN, "CATVEN" ) ); sconti.put( "CODCAT", get( LF_CFVEN, "CATVEN" ) );
if( ditta.get_bool( "SCOKEY", "ve", 2 ) ) if( ditta.get_bool( "SCOKEY", "ve", 2 ) )
{ codart << get( LF_CFVEN, "CODSCC" );
codart= get( LF_CFVEN, "CODSCC" ); else
codart << " ";
if( ditta.get_bool( "SCOKEY", "ve", 3 ) ) if( ditta.get_bool( "SCOKEY", "ve", 3 ) )
{
codart << get( LF_CFVEN, "CODZONA" ); codart << get( LF_CFVEN, "CODZONA" );
else
codart << " ";
if( ditta.get_bool( "SCOKEY", "ve", 4 ) ) if( ditta.get_bool( "SCOKEY", "ve", 4 ) )
codart << get( LF_CLIFO, "CODPAG" ); codart << get( LF_CLIFO, "CODPAG" );
}
}
}
sconti.put( "CODART", codart ); sconti.put( "CODART", codart );
if( sconti.read( ) == NOERR ) if( sconti.read( ) == NOERR )
{
m.set( F_SCONTOPERC, sconti.get( "SCONTO" ) ); m.set( F_SCONTOPERC, sconti.get( "SCONTO" ) );
} #ifdef DBG
else else
{ message_box( FALSE, "Sconto non trovato nell'archivio sconti!" );
message_box( "Sconto non trovato nell'archivio sconti!" ); #endif
}
return; return;
break; break;
} }
} }
void TCliForVendite::imposta_valuta( TMask_vendite& m )
{
TConfig ditta( CONFIG_DITTA );
if( ditta.get_bool( "GESVALAC", "ve" ) )
{
TTable cambi( "%CAM" );
cambi.zero( );
TString16 val( m.get( F_CODVAL ) );
TString16 codtab( ( const char * ) val );
codtab << m.get( F_DATADOC );
cambi.put( "CODTAB", codtab );
const int result = cambi.read( _isgteq );
if( result == _iseof )
cambi.prev( );
codtab = cambi.get( "CODTAB" );
if ( codtab.sub( 0, 2 ) == val )
{
m.set( F_CAMBIO, cambi.get( "R10" ) );
m.set( F_DATACAMBIO, cambi.get( "D0" ) );
return;
}
}
TTable valuta( "VAL" );
valuta.zero( );
valuta.put( "CODTAB", m.get( F_CODVAL ) );
if( valuta.read( ) == NOERR )
{
m.set( F_CAMBIO, valuta.get( "R10" ) );
m.set( F_DATACAMBIO, valuta.get( "D0" ) );
}
}

View File

@ -56,6 +56,8 @@ class TCliFor : public TData_picker
static bool occas_code_handler(TMask_field& f, KEY key); static bool occas_code_handler(TMask_field& f, KEY key);
int write_occas( ); int write_occas( );
void edita_occasionale( ); void edita_occasionale( );
char tipocf( ){ return _tipocf; }
long codcf( ){ return _codcf; }
}; };
class TCliForVendite : public TCliFor class TCliForVendite : public TCliFor
@ -65,6 +67,7 @@ class TCliForVendite : public TCliFor
void update_mask( TMask_vendite& m, bool onload = FALSE ); void update_mask( TMask_vendite& m, bool onload = FALSE );
void imposta_dati_comune( TMask_vendite& m ); void imposta_dati_comune( TMask_vendite& m );
void imposta_valuta( TMask_vendite& m );
void imposta_indirizzo_spedizione( TMask_vendite& m ); void imposta_indirizzo_spedizione( TMask_vendite& m );
void imposta_sconto_testa( TMask_vendite& m ); void imposta_sconto_testa( TMask_vendite& m );

View File

@ -1,242 +1,28 @@
#include <xvt_defs.h>
#ifndef __CHECKS_H
#include <checks.h>
#endif
#ifndef __TABUTIL_H
#include <tabutil.h>
#endif
#ifndef __BRWAPP_H
#include <brwapp.h>
#endif
#ifndef __RELAPP_H
#include <relapp.h>
#endif
#ifndef __CONFIG_H
#include <config.h>
#endif
#ifndef __LFFILES_H
#include <lffiles.h>
#endif
#ifndef __DEFMASK_H
#include "defmask.h"
#endif
#ifndef __VEUML_H
#include "veuml.h"
#endif
#ifndef __VEUML1_H
#include "veuml1.h"
#endif
#ifndef __SHEET_H
#include <sheet.h>
#endif
#ifndef __REAL_H
#include <real.h>
#endif
#ifndef __MSKSHEET_H
#include <msksheet.h>
#endif
#ifndef __VE0100_H #ifndef __VE0100_H
#include "ve0100.h" #include "ve0100.h"
#endif #endif
#ifndef __VE0100C_H TMotore_application& app( ) { return ( TMotore_application& ) main_app( ); }
#include "ve0100c.h"
#endif
#ifndef __VE0100D_H
#include "ve0100d.h"
#endif
#ifndef __TCLIFOR_H
#include "tclifor.h"
#endif
#ifndef __VE1000O_H
#include "ve1000o.h"
#endif
#ifndef __TMASKVEN_H
#include "tmaskven.h"
#endif
#ifndef __EXECP_H
#include "execp.h"
#endif
#ifndef __SCONTI_H
#include "sconti.h"
#endif
#define CHANGE_MESSAGE "Sono state effettuate modifiche alla configurazione.\nPrima di eseguire la gestione documenti occorrerà rigenerare le maschere.\nDesideri farlo ora ?"
// Numero di colonne presenti sullo sheet totale
#define MAX_COLUMNS 22
#define F_LBTIPORIGA 175
#define NPIEDI 40
typedef real array_piede[ NPIEDI ];
// Definizione della classe dell'applicazione motore
class TMotore_application : public TRelation_application
{
// Array di totalizzatori
array_piede _piedi;
array_piede _piedi_temp;
// Record array per la gestione delle righe
TRecord_array* _righe_rec;
// Puntatore al profilo del documento caricato
TConfig* _pro;
// Puntatore al nome, per evitare di ricrearlo se è uguale
TFilename* _proname;
// Puntatore alla maschera di ricerca
TMask* _msk;
// Puntatore alla maschera di modifica/inserimento ( dipende dal profilo )
TMask_vendite* _msk1;
// puntatore alla relazione
TRelation* _rel;
// Puntatore allo sheet delle righe documento
TSheet_field* _sheet;
// Oggetto cliente per il motore
TCliForVendite* _clifor;
// Indica se il documento ha come soggetto un <C>liente o un <F>ornitore
char _tipocf;
// Ridefinizione dei metodi virtuali
virtual bool user_create( );
virtual bool user_destroy( );
virtual TMask* get_mask(int mode);
virtual bool changing_mask(int mode);
virtual TRelation* get_relation( ) const { return _rel;}
virtual void init_insert_mode( TMask& m );
virtual int read( TMask& m );
virtual bool remove( void );
virtual int write(const TMask& m);
virtual int rewrite(const TMask& m);
// Punti di ingresso per le funzioni utente
// Funzioni da associare ad ogni procedura
int user_function( int index );
// Funzioni per il calcolo delle righe
real user_row_calculate( TRectype& row, int index );
void user_set_handler( int fieldid, int index, TMask* m = NULL );
long prossimo_numero( bool provv );
int avanza_numero( bool provv );
void get_edit_mask( void );
void azzera_piedi( bool temp = FALSE );
void carica_piedi( );
void somma_piedi( );
void sottrai_piedi( );
// Esegue, se c'è, la procedura utente relativa ad una certa operazione
int esegui_procedura( int operazione );
protected:
// Procedure e funzioni per la gestione della maschera e dei files
void read_rdoc(TMask& m);
// formato dipendente dallo sheet (sono le varie colonne)
void load_riga( TSheet_field& f, int numrig, TRectype& r );
void store_riga( TSheet_field& f, int numrig, TRectype& r );
void save(TRelation* r) const;
void set_descr (int numrig, const char* descr);
void carica_righe_libere(int from = -1);
bool check_key( TLocalisamfile& rdoc, TString16 codnum, bool provv, TString16 _anno, TString16 _ndoc );
// Procedure e funzioni per la gestione degli stati
void setta_stato_corrente( int nuovostato );
const char* nome_sezione( int op );
int stato_corrente( );
int stato_finale( int operazione );
bool stato_valido( int stato, int operazione );
void segnala_stato_non_valido( int operazione );
TString& stati_validi( int operazione ){ return ( pro( ).get( "STATIVALIDI", nome_sezione( operazione ) ) );};
void calcola_riga( TRectype& rdoc, bool temp = FALSE );
// Handle che ritorna la maschera per le righe
static TMask * ss_getmask( int numriga, TMask& fullmask, bool destroy );
// Handler che gestisce la richiesta del tipo riga in inserimento
static bool ss_handler( TSheet_field& ss, int r, KEY key );
// Handler per la maschera di ricerca
static bool ndoc_handler(TMask_field& f, KEY key);
static bool num_handler(TMask_field& f, KEY key);
static bool tip_handler(TMask_field& f, KEY key);
// Handler per la maschera di modifica
static bool clifo_handler(TMask_field& f, KEY key);
static bool occas_handler(TMask_field& f, KEY key);
// Configurazione dello sheet dato il profilo
void configura_sheet( TSheet_field& sheet, TConfig& config );
public:
// Funzioni di accesso alle variabili privste
TRecord_array& righe_rec( ) { CHECK( _righe_rec, "Record array delle righe nullo!" ); return * _righe_rec; };
TConfig& pro( ) { CHECK( _pro, "Profilo del documento nullo!" ); return *_pro; };
TFilename& proname( ) { CHECK( _proname, "Nome del profilo nullo!" ); return *_proname; };
TMask& query_mask( ) { CHECK( _msk, "Maschera di ricerca nulla!" ); return *_msk; };
TMask& edit_mask( ) { CHECK( _msk1, "Maschera di modifica nulla!" ); return *_msk1; };
TRelation& rel( ) { CHECK( _rel, "Relazione nulla!" ); return *_rel; };
TSheet_field& sheet( ) { CHECK( _sheet, "Sheet nullo!" ); return *_sheet; };
TCliForVendite& clifo( ) { CHECK( _clifor, "Oggetto cliente nullo!" ); return *_clifor; };
// Operazione
const char tipocf( ){ return _tipocf; }
void tipocf( const char tcf ){ _tipocf = tcf; }
bool valida_operazione( int operazione );
TSheet_field& ss( ) const { return *_sheet; }
TMotore_application( ) { _pro = NULL; }
virtual ~TMotore_application( ) { if ( _pro ) delete _pro; }
virtual const char* get_next_key( );
};
HIDDEN TMotore_application& app( ) { return (TMotore_application&) main_app( ); }
void TMotore_application::init_insert_mode( TMask& m ) void TMotore_application::init_insert_mode( TMask& m )
{ {
TString tipocf( "A" );
tipocf[ 0 ] = app( ).tipocf( );
// m.reset( );
m.set( F_DATAINSC, m.get( F_DATADOC ) ); m.set( F_DATAINSC, m.get( F_DATADOC ) );
m.reset( ); m.set( F_TIPOCF, tipocf );
clifo( ).occas_mask( ).reset( ); clifo( ).occas_mask( ).reset( );
}; int ndefaults = pro( ).get_int( "NDEFAULTS", "DEFAULT" );
for( int i = 1; i <= ndefaults; i++ )
{
TString16 chiave;
chiave.format( "%d", i );
TToken_string valore( pro( ).get( chiave, "DEFAULT" ) );
int campo( valore.get_int( 0 ) );
TString default_val( valore.get( 1 ) );
edit_mask( ).set( campo, default_val, TRUE );
}
}
int TMotore_application::user_function( int index ) int TMotore_application::user_function( int index )
{ {
@ -248,68 +34,46 @@ int TMotore_application::user_function( int index )
yesnofatal_box( "Chiamata ad una procedura utente non definita: %d", index ); yesnofatal_box( "Chiamata ad una procedura utente non definita: %d", index );
return NOERR; return NOERR;
break; break;
}; }
return NOERR; return NOERR;
}; }
// Funzione che dato il profilo di riga ottiene la maschera // Funzione che dato il profilo di riga ottiene la maschera
// Serve per ottenere una maschera diversa per ogni riga // Serve per ottenere una maschera diversa per ogni riga
// Da migliorare, mettendo una cache
TMask *TMotore_application::ss_getmask( int numriga, TMask& fullmask, bool destroy ) TMask *TMotore_application::ss_getmask( int numriga, TMask& fullmask, bool destroy )
{ {
static TMask* m; static TRiga* r = NULL;
static TMask* m = NULL;
if ( destroy ) if ( destroy )
{ {
delete m; delete r;
r = NULL;
return( NULL ); return( NULL );
} }
else else
{ {
TFilename nome_proriga( fullmask.get( 103 ) ); TSheet_field* ss = fullmask.get_sheet( );
nome_proriga.ext( "ini" ); TToken_string& riga = ss->row( numriga );
TConfig proriga( nome_proriga ); TString16 profilo( riga.get( FS_PROFRIGA - 101 ) );
m = new TMask( proriga.get( "MSK", "MAIN" ) ); if ( profilo.blank( ) ) return &fullmask;
int numhandler = proriga.get_int( "NHANDLER", "HANDLERS" ); if( r && ( r->profilo( ) == profilo ) )
for( int i = 1; i <= numhandler; i ++ )
{ {
TString chiave; return( m );
chiave.format( "%d", i ); }
TToken_string riga = proriga.get( chiave, "HANDLERS" ); if ( !r )
app().user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ), m ); r = new TRiga;
}; r->load( riga );
m = &(r->getmask( ));
m->set_sheet( ss );
return( m ); return( m );
} }
} }
real TMotore_application::user_row_calculate( TRectype& r, int index ) void TMotore_application::azzera_piedi( )
{ {
switch( index ) _piede.destroy( );
{
case 100:
return( f100( r ) );
break;
case 200:
return( f200( r ) );
break;
case 300:
return( f300( r ) );
break;
case 400:
return( f400( r ) );
break;
case 500:
return( f500( r ) );
break;
case 600:
return( f600( r ) );
break;
default:
CHECK( FALSE, "Tentativo di chiamare una funzione di calcolo riga inesistente!" );
return 0.0;
} }
};
void TMotore_application::user_set_handler( int fieldid, int index, TMask* m ) void TMotore_application::user_set_handler( int fieldid, int index, TMask* m )
{ {
@ -320,9 +84,6 @@ void TMotore_application::user_set_handler( int fieldid, int index, TMask* m )
case 1: case 1:
m->set_handler( fieldid, ora_hndl ); m->set_handler( fieldid, ora_hndl );
break; break;
case 2:
m->set_handler( fieldid, codcli_hndl );
break;
case 3: case 3:
m->set_handler( fieldid, dummy_hndl ); m->set_handler( fieldid, dummy_hndl );
break; break;
@ -330,102 +91,78 @@ void TMotore_application::user_set_handler( int fieldid, int index, TMask* m )
CHECK( FALSE, "Tentativo di installare un handler non definito" ); CHECK( FALSE, "Tentativo di installare un handler non definito" );
break; break;
} }
}; }
bool TMotore_application::ss_handler( TSheet_field& ss, int r, KEY key ) bool TMotore_application::ss_handler( TSheet_field& ss, int r, KEY key )
{ {
static TRiga* riga;
if ( key == K_SPACE ) // Inizio modifica if ( key == K_SPACE ) // Inizio modifica
{ {
app().azzera_piedi( TRUE ); TPiede_documento& piede = app( ).piede( );
TRelation rdoc( LF_RIGHEDOC ); riga->edit_keys( key, piede );
ss.sheet_mask( ).autosave( &rdoc );
// Mi calcolo nei piedi temporanei la riga
app().calcola_riga( rdoc.curr( ), TRUE );
} }
if ( key == K_TAB ) // Mi posiziono su di una riga nello sheet if ( key == K_TAB ) // Mi posiziono su di una riga nello sheet
{ {
TRelation rdoc( LF_RIGHEDOC ); if ( riga )
TToken_string riga( ss.row( r ) ); delete riga;
rdoc.curr( ).zero( ); riga = new TRiga;
rdoc.curr( ).put( "CODNUM", app( ).edit_mask( ).get( F_CODNUM ) ); riga->load( ss.row( r ) );
rdoc.curr( ).put( "ANNO", app( ).edit_mask( ).get( F_ANNO ) );
rdoc.curr( ).put( "PROVV", app( ).edit_mask( ).get( F_PROVV ) );
rdoc.curr( ).put( "NDOC", app( ).edit_mask( ).get( F_NDOC ) );
rdoc.curr( ).put( "NRIGA", riga.get( 1 ) );
rdoc.read( );
app( ).edit_mask( ).field( F_MEMORIGA ).autoload( &rdoc );
} }
if ( key == K_TAB ) // Lascio una riga nello sheet if ( key == K_CTRL + K_TAB ) // Lascio una riga nello sheet
{ {
TRelation rdoc( LF_RIGHEDOC ); // TRelation rdoc( LF_RIGHEDOC );
TToken_string riga( ss.row( r ) ); // TToken_string riga( ss.row( r ) );
rdoc.curr( ).zero( ); // rdoc.curr( ).zero( );
rdoc.curr( ).put( "CODNUM", app( ).edit_mask( ).get( F_CODNUM ) ); // rdoc.curr( ).put( "CODNUM", app( ).edit_mask( ).get( F_CODNUM ) );
rdoc.curr( ).put( "ANNO", app( ).edit_mask( ).get( F_ANNO ) ); // rdoc.curr( ).put( "ANNO", app( ).edit_mask( ).get( F_ANNO ) );
rdoc.curr( ).put( "PROVV", app( ).edit_mask( ).get( F_PROVV ) ); // rdoc.curr( ).put( "PROVV", app( ).edit_mask( ).get( F_PROVV ) );
rdoc.curr( ).put( "NDOC", app( ).edit_mask( ).get( F_NDOC ) ); // rdoc.curr( ).put( "NDOC", app( ).edit_mask( ).get( F_NDOC ) );
rdoc.curr( ).put( "NRIGA", riga.get( 1 ) ); // rdoc.curr( ).put( "NRIGA", riga.get( 1 ) );
rdoc.read( ); // rdoc.read( );
app( ).edit_mask( ).field( F_MEMORIGA ).autosave( &rdoc ); // app( ).edit_mask( ).field( F_MEMORIGA ).autosave( &rdoc );
rdoc.write( ); // rdoc.write( );
} }
if ( key == K_INS ) // Inserimento if ( key == K_INS ) // Inserimento
{ {
TMask& m = *app( )._msk1;
TTable tabtr( "%TRI" ); TTable tabtr( "%TRI" );
tabtr.zero( ); tabtr.zero( );
tabtr.put( "CODTAB", m.get( F_LBTIPORIGA ) ); tabtr.put( "CODTAB", app( ).edit_mask( ).get( F_LBTIPORIGA ) );
tabtr.read( ); tabtr.read( );
TToken_string& riga = ss.row( r ); TToken_string& tsr = ss.row( r );
riga.add( 1, 0 ); tsr.add( app( ).edit_mask( ).get( F_ANNO ), FS_ANNO - 101 );
riga.add( m.get( F_LBTIPORIGA ), 1 ); tsr.add( app( ).edit_mask( ).get( F_PROVV ), FS_PROVV - 101 );
riga.add( tabtr.get( "S4" ), 2 ); tsr.add( app( ).edit_mask( ).get( F_NDOC ), FS_NDOC - 101 );
tsr.add( app( ).edit_mask( ).get( F_CODNUM ), FS_CODNUM - 101 );
tsr.add( app( ).edit_mask( ).get( F_LBTIPORIGA ), FS_TIPORIGA - 101 );
// tsr.add( app( ).edit_mask( ).get( F_PROFILO ), FS_PROFRIGA - 101 );
tsr.add( tabtr.get( "S4" ), FS_PROFRIGA - 101 );
if ( riga )
delete riga;
riga = new TRiga;
riga->load( tsr );
return TRUE; return TRUE;
} }
if ( key == K_CTRL + K_INS ) // Dopo inserimento if ( key == K_CTRL + K_INS ) // Dopo inserimento
{ {
TMask& m = *app( )._msk1; riga->configura_sheet( ss, r );
TTable tabtr( "%TRI" );
tabtr.zero( );
tabtr.put( "CODTAB", m.get( F_LBTIPORIGA ) );
tabtr.read( );
TToken_string& riga = ss.row( r );
TFilename nome_proriga( tabtr.get( "S4" ) );
nome_proriga.ext( "ini" );
TConfig pro( nome_proriga );
int ncols = pro.get_int( "NCOLS", "COLUMNS" );
// Disabilita tutte le colonne
for( int i = 1; i <= MAX_COLUMNS; i ++ )
ss.disable_cell ( ss.items( ) - 1, i );
// Abilita le colonne indicate nel profilo della riga
for( i = 1; i <= ncols; i ++ )
{
TString16 chiave;
chiave.format( "%d", i );
int coltoenable = pro.get_int( chiave, "COLUMNS" );
ss.enable_cell ( ss.items( ) - 1, coltoenable - 1 );
};
ss.force_update( );
app( ).curr_mask( ).send_key( K_ROWEDIT, F_SHEET ); app( ).curr_mask( ).send_key( K_ROWEDIT, F_SHEET );
return TRUE; return TRUE;
} }
if ( key == K_DEL ) // Cancellazione if ( key == K_DEL ) // Cancellazione
{ {
// Sottraggo la riga appena cancellata ai totalizzatori TPiede_documento& piede = app( ).piede( );
app().sottrai_piedi( ); riga->edit_keys( key, piede );
app().carica_piedi( ); return TRUE;
} }
if ( key == K_ENTER ) // Modifica if ( key == K_ENTER ) // Modifica
{ {
app().sottrai_piedi( ); TPiede_documento& piede = app( ).piede( );
TRelation rdoc( LF_RIGHEDOC ); riga->edit_keys( key, piede );
ss.sheet_mask( ).autosave( &rdoc ); return TRUE;
// Sommo la riga ai totalizzatori
app().calcola_riga( rdoc.curr( ) );
app().sottrai_piedi( );
} }
return TRUE; return TRUE;
}; }
bool TMotore_application::num_handler( TMask_field& f, KEY key ) bool TMotore_application::num_handler( TMask_field& f, KEY key )
{ {
@ -479,7 +216,7 @@ bool TMotore_application::num_handler( TMask_field& f, KEY key )
m.set( F_PROVV, "D" ); m.set( F_PROVV, "D" );
// Disabilita il campo per la selezione della numerazione // Disabilita il campo per la selezione della numerazione
m.disable( F_PROVV ); m.disable( F_PROVV );
}; }
return TRUE; return TRUE;
} }
message_box( "Numerazione non valida!" ); message_box( "Numerazione non valida!" );
@ -498,6 +235,18 @@ bool TMotore_application::num_handler( TMask_field& f, KEY key )
return TRUE; return TRUE;
} }
bool TMotore_application::val_handler( TMask_field& f, KEY key )
{
// Ottengo la maschera
TMask& m = f.mask( );
// m.set( F_CAMBIO, "" );
// m.set( F_DATACAMBIO, "" );
app( ).clifo( ).imposta_valuta( ( TMask_vendite& ) m );
return TRUE;
}
bool TMotore_application::occas_handler( TMask_field& f, KEY key ) bool TMotore_application::occas_handler( TMask_field& f, KEY key )
{ {
if ( key == K_SPACE && f.mask( ).is_running( ) ) if ( key == K_SPACE && f.mask( ).is_running( ) )
@ -552,12 +301,14 @@ bool TMotore_application::tip_handler(TMask_field& f, KEY key)
if ( key == K_ENTER && m.is_running( ) ) if ( key == K_ENTER && m.is_running( ) )
{ TString tipo( f.get( ) ); { TString tipo( f.get( ) );
if ( ! tipo.blank( ) ) if ( ! tipo.blank( ) )
{ TTable tabtip( "%TIP" ); {
TTable tabtip( "%TIP" );
tabtip.read( ); tabtip.read( );
m.set( F_PROFILO, tabtip.get( "S4" ) ); m.set( F_PROFILO, tabtip.get( "S4" ) );
} }
else else
{ message_box( "Occorre un tipo documento per inserire un documento!" ); {
message_box( "Occorre un tipo documento per inserire un documento!" );
m.first_focus( F_TIPODOC ); m.first_focus( F_TIPODOC );
return FALSE; return FALSE;
} }
@ -569,14 +320,16 @@ bool TMotore_application::ndoc_handler(TMask_field& f, KEY key)
{ {
TMask& m = f.mask( ); TMask& m = f.mask( );
if ( key == K_TAB && m.is_running( ) ) if ( key == K_TAB && m.is_running( ) )
{ TLocalisamfile& doc = app( ).rel( ).lfile( ); {
TLocalisamfile& doc = app( ).rel( ).lfile( );
doc.zero( ); doc.zero( );
doc.put( "CODNUM", m.get( F_CODNUM ) ); doc.put( "CODNUM", m.get( F_CODNUM ) );
doc.put( "PROVV", m.get( F_PROVV ) ); doc.put( "PROVV", m.get( F_PROVV ) );
doc.put( "ANNO", m.get( F_ANNO ) ); doc.put( "ANNO", m.get( F_ANNO ) );
doc.put( "NDOC", f.get( ) ); doc.put( "NDOC", f.get( ) );
if ( doc.read( ) == NOERR ) if ( doc.read( ) == NOERR )
{ m.set(F_TIPODOC, doc.get( "TIPODOC" ) ); {
m.set( F_TIPODOC, doc.get( "TIPODOC" ) );
m.set( F_STATO, doc.get( "STATO" ) ); m.set( F_STATO, doc.get( "STATO" ) );
TTable tabtip( "%TIP" ); TTable tabtip( "%TIP" );
tabtip.put( "CODTAB", doc.get( "TIPODOC" ) ); tabtip.put( "CODTAB", doc.get( "TIPODOC" ) );
@ -630,45 +383,48 @@ bool TMotore_application::clifo_handler(TMask_field& f, KEY key)
{ {
app( ).clifo( ).load( cf, atol( f.get( ) ), "" ); app( ).clifo( ).load( cf, atol( f.get( ) ), "" );
app( ).clifo( ).update_mask( ( TMask_vendite& ) m ); app( ).clifo( ).update_mask( ( TMask_vendite& ) m );
if( f.mask( ).id2pos( F_OCCASEDIT ) > 0 )
{
if ( app( ).clifo( ).occasionale( ) && app( ).clifo( ).occas_mask( ).get( O_CODICE ).empty( ) ) if ( app( ).clifo( ).occasionale( ) && app( ).clifo( ).occas_mask( ).get( O_CODICE ).empty( ) )
m.send_key( K_SPACE, F_OCCASEDIT ); // Lancia maschera occasionali m.send_key( K_SPACE, F_OCCASEDIT ); // Lancia maschera occasionali
} }
} }
}
return TRUE; return TRUE;
} }
void TMotore_application::azzera_piedi( bool temp )
{
for ( int i = 0; i < NPIEDI; i++ )
if ( temp )
_piedi_temp[ i ] = 0.0;
else
_piedi[ i ] = 0.0;
}
void TMotore_application::carica_piedi( ) void TMotore_application::carica_piedi( )
{ {
TToken_string s( pro( ).get( "PROGPIEDE", "MAIN" ) ); TToken_string s( pro( ).get( "PROGPIEDE", "MAIN" ) );
int i = s.get_int( ); TString s1 = s.get( );
int j = 0; TTable ppd( "PPD" );
while( i != 0 ) while( !s1.blank( ) )
{ {
real strpiede( _piedi[ i ] ); ppd.zero( );
edit_mask( ).set( BASE_PIEDE + ( ++j ), strpiede.stringa( 15 ) ); ppd.put( "CODTAB", s1 );
i = s.get_int( ); if( ppd.read( ) == NOERR )
{
real valpiede( "0.0" );
if ( _piede.is_key( s1 ) )
valpiede = ( real & )( _piede[ s1 ] );
edit_mask( ).set( BASE_PIEDE + ppd.get_int( "I0" ), valpiede.stringa( 15 ) );
}
else
message_box( "Piede non trovato( %s )", ( const char * )s1 );
s1 = s.get( );
} }
} }
void TMotore_application::somma_piedi( ) void TMotore_application::somma_piedi( )
{ {
for ( int i = 0; i < NPIEDI; i++ ) /*for ( int i = 0; i < NPIEDI; i++ )
_piedi[ i ] += _piedi_temp[ i ]; _piedi[ i ] += _piedi_temp[ i ];*/
} }
void TMotore_application::sottrai_piedi( ) void TMotore_application::sottrai_piedi( )
{ {
for ( int i = 0; i < NPIEDI; i++ ) /*for ( int i = 0; i < NPIEDI; i++ )
_piedi[ i ] -= _piedi_temp[ i ]; _piedi[ i ] -= _piedi_temp[ i ];*/
} }
bool TMotore_application::changing_mask( int mode ) bool TMotore_application::changing_mask( int mode )
@ -678,7 +434,6 @@ bool TMotore_application::changing_mask(int mode)
const bool change = ( mode != lastmode ); const bool change = ( mode != lastmode );
lastmode = mode; lastmode = mode;
return change; return change;
} }
void TMotore_application::configura_sheet( TSheet_field& sheet, TConfig& config ) void TMotore_application::configura_sheet( TSheet_field& sheet, TConfig& config )
@ -697,16 +452,15 @@ void TMotore_application::configura_sheet( TSheet_field& sheet, TConfig& config
sheet.set_column_width( i, sheet_col.get_int( 2 ) ); sheet.set_column_width( i, sheet_col.get_int( 2 ) );
int coltomove = sheet_col.get_int( 0 ) - 1; int coltomove = sheet_col.get_int( 0 ) - 1;
sheet.move_column( coltomove, i ); sheet.move_column( coltomove, i );
}; }
for ( int j = MAX_COLUMNS; j >= i - 1; j -- ) for ( int j = MAX_COLUMNS; j >= i - 1; j -- )
sheet.delete_column( j ); sheet.delete_column( j );
}; }
void TMotore_application::get_edit_mask( void ) void TMotore_application::get_edit_mask( const char * profilo )
{ {
TFilename fn; TFilename fn( profilo );
fn = query_mask( ).get( F_PROFILO );
// query_mask( ).enable( DLG_NEWREC ); // query_mask( ).enable( DLG_NEWREC );
fn.ext( "ini" ); fn.ext( "ini" );
fn.upper( ); fn.upper( );
@ -715,14 +469,14 @@ void TMotore_application::get_edit_mask( void )
if ( ( *_proname ) == fn ) if ( ( *_proname ) == fn )
return; return;
delete _pro; delete _pro;
}; }
_pro = new TConfig( fn ); _pro = new TConfig( fn );
_proname = new TFilename( fn ); _proname = new TFilename( fn );
_proname->upper( ); _proname->upper( );
if ( _msk1 ) delete _msk1; if ( _msk1 ) delete _msk1;
_msk1 = new TMask_vendite( pro( ).get( "MSKFILE", "MAIN" ) ); _msk1 = new TMask_vendite( pro( ).get( "MSKFILE", "MAIN" ) );
// edit_mask( ).set( F_PROFILO, query_mask( ).get( F_PROFILO ) ); // edit_mask( ).set( F_PROFILO, query_mask( ).get( F_PROFILO ) );
edit_mask( ).set( F_DESNUM, query_mask( ).get( F_DESNUM ) ); // edit_mask( ).set( F_DESNUM, query_mask( ).get( F_DESNUM ) );
_sheet = &( TSheet_field& )edit_mask( ).field( F_SHEET ); _sheet = &( TSheet_field& )edit_mask( ).field( F_SHEET );
sheet( ).set_notify( ss_handler ); sheet( ).set_notify( ss_handler );
TString tipocf( app( ).pro( ).get( "TIPOCF", "MAIN" ) ); TString tipocf( app( ).pro( ).get( "TIPOCF", "MAIN" ) );
@ -759,28 +513,41 @@ void TMotore_application::get_edit_mask( void )
chiave.format( "%d", i ); chiave.format( "%d", i );
TToken_string riga = pro( ).get( chiave, "HANDLERS" ); TToken_string riga = pro( ).get( chiave, "HANDLERS" );
user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ) ); user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ) );
}; }
_msk1->set( F_MEMORIGA, "Riga1" ); // _msk1->set( F_MEMORIGA, "Riga1" );
} }
TMask* TMotore_application::get_mask( int mode ) TMask* TMotore_application::get_mask( int mode )
{ {
TString profilo( query_mask( ).get( F_PROFILO ) );
switch ( mode ) switch ( mode )
{ {
case MODE_INS: case MODE_INS:
case MODE_MOD: case MODE_MOD:
get_edit_mask( ); if( !_msk )
edit_mask( ).enable( DLG_PRINT, ( mode == MODE_MOD ) ); delete _msk;
get_edit_mask( profilo );
if ( edit_mask( ).id2pos( F_OCCASEDIT ) > 0 )
edit_mask( ).set_handler( F_OCCASEDIT, occas_handler ); edit_mask( ).set_handler( F_OCCASEDIT, occas_handler );
if ( edit_mask( ).id2pos( F_CODVAL ) > 0 )
edit_mask( ).set_handler( F_CODVAL, val_handler );
edit_mask( ).set_handler( F_CODCF, clifo_handler ); edit_mask( ).set_handler( F_CODCF, clifo_handler );
edit_mask( ).set_handler( F_CODPAG, condpag_hndl ); edit_mask( ).set_handler( F_CODPAG, condpag_hndl );
edit_mask( ).set_handler( F_DATAINSC, condpag_hndl ); edit_mask( ).set_handler( F_DATAINSC, condpag_hndl );
return( _msk1 ); return( _msk1 );
break; break;
default: default:
if( !_msk )
{
_msk = new TMask( "ve1000a" );
}
if( !_msk1 )
{
delete _msk1;
}
return _msk; return _msk;
break; break;
}; }
} }
void TMotore_application::set_descr( int i, const char * dfi ) void TMotore_application::set_descr( int i, const char * dfi )
@ -826,7 +593,7 @@ const char* TMotore_application::get_next_key( )
else // Altrimenti ... else // Altrimenti ...
{ {
doc.put( "PROVV", "D" ); doc.put( "PROVV", "D" );
}; }
if ( doc.read( _isgteq ) == NOERR ) if ( doc.read( _isgteq ) == NOERR )
{ {
doc.prev( ); doc.prev( );
@ -835,7 +602,7 @@ const char* TMotore_application::get_next_key( )
key.format( "%d|%d", F_NDOC, num + 1 ); key.format( "%d|%d", F_NDOC, num + 1 );
return key; return key;
} }
}; }
return NULL; return NULL;
} }
@ -845,26 +612,33 @@ int TMotore_application::read(TMask& m)
int err = TRelation_application::read( m ); int err = TRelation_application::read( m );
if ( err == NOERR ) if ( err == NOERR )
{ {
TString16 tipocf( m.get( F_TIPOCF ) ); edit_mask( ).set( F_DESNUM, query_mask( ).get( F_DESNUM ) );
clifo( ).load( tipocf[ 0 ], m.get_int( F_CODCF ), rel( ).curr( ).get( "OCFPI" ) ); edit_mask( ).set( F_DESTIPODOC, query_mask( ).get( F_DESTIPODOC ) );
const char tipocf = m.get( F_TIPOCF )[ 0 ];
clifo( ).load( tipocf, m.get_int( F_CODCF ), rel( ).curr( ).get( "OCFPI" ) );
clifo( ).update_mask( ( TMask_vendite& ) m, TRUE ); clifo( ).update_mask( ( TMask_vendite& ) m, TRUE );
TLocalisamfile& rdoc = rel( ).lfile( LF_RIGHEDOC ); TLocalisamfile& rdoc = rel( ).lfile( LF_RIGHEDOC );
TRectype r = rdoc.curr( ); TRectype r = rdoc.curr( );
TRectype& trec = get_relation( )->curr( );
r.zero( ); r.zero( );
r.put( "CODNUM", m.get( F_CODNUM ) ); r.put( "CODNUM", trec.get( "CODNUM" ) );
r.put( "PROVV", m.get( F_PROVV ) ); r.put( "PROVV", trec.get( "PROVV" ) );
r.put( "ANNO", m.get( F_ANNO ) ); r.put( "ANNO", trec.get( "ANNO" ) );
r.put( "NDOC", m.get_long( F_NDOC ) ); r.put( "NDOC", trec.get_long( "NDOC" ) );
_righe_rec->read( r ); _righe_rec->read( r );
TSheet_field& f = ( TSheet_field& ) m.field( F_SHEET ); TSheet_field& f = ( TSheet_field& ) m.field( F_SHEET );
f.destroy( ); f.destroy( );
int last = _righe_rec->last_row( ); int last = _righe_rec->last_row( );
TRiga currentrow;
for ( int i = 1; i <= last; i ++ ) for ( int i = 1; i <= last; i ++ )
{ {
TRectype &rec = _righe_rec->row( i, TRUE ); TToken_string& srow = f.row( i - 1 );
load_riga( f, i - 1, rec ); TRectype& rec = _righe_rec->row( i, FALSE );
calcola_riga( rec ); currentrow.load( rec );
}; currentrow.save( srow );
currentrow.configura_sheet( f, i - 1 );
currentrow.somma( _piede );
}
carica_piedi( ); carica_piedi( );
} }
return err; return err;
@ -883,9 +657,11 @@ int TMotore_application::write(const TMask& m)
int err; int err;
if ( esegui_procedura( OP_NUOVO ) != NOERR ) if ( esegui_procedura( OP_NUOVO ) != NOERR )
return FALSE; return FALSE;
m.field( F_STATO ).set( _pro->get( "STATOFINALE", "INSERIMENTO" ) );
err = NOERR; // avanza_numero( m.get_bool( F_PROVV ) ); err = NOERR; // avanza_numero( m.get_bool( F_PROVV ) );
if ( err == NOERR ) if ( err == NOERR )
{ {
if ( m.id2pos( F_OCCASEDIT) > 0 )
err = app( ).clifo( ).write_occas( ); err = app( ).clifo( ).write_occas( );
} }
if ( err == NOERR ) if ( err == NOERR )
@ -907,13 +683,20 @@ int TMotore_application::write(const TMask& m)
} }
} }
return err; return err;
}; }
int TMotore_application::rewrite( const TMask& m ) int TMotore_application::rewrite( const TMask& m )
{ {
int err = NOERR;
if ( ! valida_operazione( OP_MODIFICA ) ) if ( ! valida_operazione( OP_MODIFICA ) )
return FALSE; return FALSE;
int err = TRelation_application::rewrite( m ); if ( err == NOERR )
{
err = app( ).clifo( ).write_occas( );
}
if ( err == NOERR )
{
err = TRelation_application::rewrite( m );
if ( err == NOERR ) if ( err == NOERR )
{ {
TSheet_field& f = ss( ); TSheet_field& f = ss( );
@ -928,8 +711,9 @@ int TMotore_application::rewrite(const TMask& m)
} }
err = _righe_rec->rewrite( ); err = _righe_rec->rewrite( );
} }
}
return err; return err;
}; }
// La funzione si trova in ve0100b // La funzione si trova in ve0100b
@ -945,7 +729,7 @@ long TMotore_application::prossimo_numero( bool provv )
else else
ret = tabnum.get_long( "I1" ) + 1; ret = tabnum.get_long( "I1" ) + 1;
return ( ret ); return ( ret );
}; }
int TMotore_application::avanza_numero( bool provv ) int TMotore_application::avanza_numero( bool provv )
{ {
@ -961,7 +745,7 @@ int TMotore_application::avanza_numero( bool provv )
err = tabnum.rewrite( ); err = tabnum.rewrite( );
} }
return err; return err;
}; }
bool TMotore_application::remove( void ) bool TMotore_application::remove( void )
{ {
@ -1015,59 +799,15 @@ void TMotore_application::load_riga( TSheet_field& f, int numrig, TRectype& r )
void TMotore_application::store_riga( TSheet_field& f, int numrig, TRectype& r ) void TMotore_application::store_riga( TSheet_field& f, int numrig, TRectype& r )
{ {
TToken_string& riga = f.row(numrig); TToken_string& rigastr = f.row( numrig );
TRiga riga;
r.put( "CODNUM", edit_mask( ).get( F_CODNUM ) ); riga.load( rigastr );
r.put( "ANNO", edit_mask( ).get( F_ANNO ) ); riga.set_numero( numrig + 1 );
r.put( "PROVV", edit_mask( ).get( F_PROVV ) ); riga.save( r );
r.put( "NDOC", edit_mask( ).get_long( F_NDOC ) );
r.put( "STATORIGA", riga.get( 0 ) );
r.put( "TIPORIGA", riga.get( 1 ) );
r.put( "PROFRIGA", riga.get( 2 ) );
r.put( "CODMAG", riga.get( 3 ) );
r.put( "CODART", riga.get( 4 ) );
r.put( "DESCR", riga.get( 5 ) );
r.put( "DESCLUNGA", riga.get( 6 ) );
r.put( "PREZZO", riga.get( 7 ) );
r.put( "UMQTA", riga.get( 8 ) );
r.put( "QTA", riga.get( 9 ) );
r.put( "QTAEVASA", riga.get( 10 ) );
r.put( "RIGAEVASA", riga.get( 11 ) );
r.put( "TARA", riga.get( 12 ) );
} }
void TMotore_application::calcola_riga( TRectype& r, bool temp )
{
TFilename proriganame( r.get("PROFRIGA") );
proriganame.ext( "INI" );
TConfig proriga( proriganame );
TToken_string s(proriga.get("PROGPIEDE", "MAIN"));
int func = s.get_int( );
while( func )
{
if ( temp )
_piedi_temp[ s.get_int( ) ] += user_row_calculate( r, func );
else
_piedi[ s.get_int( ) ] += user_row_calculate( r, func );
func = s.get_int( );
}
}
bool TMotore_application::user_create( ) bool TMotore_application::user_create( )
{ {
TSconto s;
s.set( "12 - 23 + 12.2 +.5 ", TRUE );
if( s.is_valid( ) )
warning_box( "Sconto: %s( %s )", (const char *)s.get( ), (const char *)s.scontostr( ) );
s.set( ".5-.5", TRUE );
if( s.is_valid( ) )
warning_box( "Sconto: %s( %s )", (const char *)s.get( ), (const char *)s.scontostr( ) );
s.set( "12 - 2.3 + 12.2.1 +.5 ", TRUE );
if( s.is_valid( ) )
warning_box( "Sconto: %s( %s )", (const char *)s.get( ), (const char *)s.scontostr( ) );
TConfig ditta( CONFIG_DITTA ); TConfig ditta( CONFIG_DITTA );
// Controllo se sono cambiate le impostazioni delle vendite. // Controllo se sono cambiate le impostazioni delle vendite.
@ -1144,7 +884,6 @@ int TMotore_application::esegui_procedura( int operazione )
return ( NOERR ); return ( NOERR );
} }
bool TMotore_application::valida_operazione( int operazione ) bool TMotore_application::valida_operazione( int operazione )
{ {
if ( operazione != OP_NUOVO ) if ( operazione != OP_NUOVO )
@ -1154,8 +893,8 @@ bool TMotore_application::valida_operazione( int operazione )
segnala_stato_non_valido( operazione ); segnala_stato_non_valido( operazione );
return FALSE; return FALSE;
} }
}; }
if ( esegui_procedura( operazione ) == NOERR ) if ( esegui_procedura( operazione ) != NOERR )
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -1195,7 +934,7 @@ int TMotore_application::stato_finale( int operazione )
TString s( pro( ).get( "STATOFINALE", nome_sezione( operazione ) ) ); TString s( pro( ).get( "STATOFINALE", nome_sezione( operazione ) ) );
if ( strcmp( s, "N" ) == 0 ) return NO_CHANGE_STATUS; if ( strcmp( s, "N" ) == 0 ) return NO_CHANGE_STATUS;
return ( atoi( s ) ); return ( atoi( s ) );
}; }
bool TMotore_application::stato_valido( int stato, int operazione ) bool TMotore_application::stato_valido( int stato, int operazione )
{ {
@ -1206,9 +945,9 @@ bool TMotore_application::stato_valido( int stato, int operazione )
TToken_string ret ( stati_validi( operazione ), ',' ); TToken_string ret ( stati_validi( operazione ), ',' );
p[0] += ( char )stato; p[0] += ( char )stato;
return ( ret.get_pos( p ) != -1 ); return ( ret.get_pos( p ) != -1 );
}; }
void TMotore_application::setta_stato_corrente( int nuovostato ) /*void TMotore_application::setta_stato_corrente( int nuovostato )
{ {
// warning_box( "Settaggio stati validi!\nStato corrente %s.\nStati validi %s.\nStato finale %s.", stato_corrente( ), stati_validi( operazione ), stato_finale( operazione ) ); // warning_box( "Settaggio stati validi!\nStato corrente %s.\nStati validi %s.\nStato finale %s.", stato_corrente( ), stati_validi( operazione ), stato_finale( operazione ) );
TString p; TString p;
@ -1221,17 +960,18 @@ void TMotore_application::setta_stato_corrente( int nuovostato )
doc.rewrite( ); doc.rewrite( );
query_mask( ).set( F_STATO, p ); query_mask( ).set( F_STATO, p );
// warning_box( "Settaggio stati validi!\nStato corrente %s.\nStati validi %s.\nStato finale %s.", stato_corrente( ), stati_validi( operazione ), stato_finale( operazione ) ); // warning_box( "Settaggio stati validi!\nStato corrente %s.\nStati validi %s.\nStato finale %s.", stato_corrente( ), stati_validi( operazione ), stato_finale( operazione ) );
} } */
int TMotore_application::stato_corrente( ) int TMotore_application::stato_corrente( )
{ {
int i = query_mask( ).get_int( F_STATO ); int i = query_mask( ).get_int( F_STATO );
return ( i == 0 ? NO_DOC_STATUS : i ); return ( i == 0 ? NO_DOC_STATUS : i );
}; }
void TMotore_application::segnala_stato_non_valido( int operazione ) void TMotore_application::segnala_stato_non_valido( int operazione )
{ {
TString messaggio; TString messaggio;
switch( operazione ) switch( operazione )
{ {
case OP_NUOVO: case OP_NUOVO:
@ -1255,10 +995,10 @@ void TMotore_application::segnala_stato_non_valido( int operazione )
default: default:
CHECK( FALSE, "Tentativo di segnalare stato non valido di una operazione non esistente!" ); CHECK( FALSE, "Tentativo di segnalare stato non valido di una operazione non esistente!" );
break; break;
}; }
messaggio << "\nStato corrente :%d.\nStati validi :%s."; messaggio << "\nStato corrente :%d.\nStati validi :%s.";
warning_box( messaggio, stato_corrente( ), ( const char * )stati_validi( operazione ) ); warning_box( messaggio, stato_corrente( ), ( const char * )stati_validi( operazione ) );
}; }
int ve0100( int argc, char** argv ) int ve0100( int argc, char** argv )
{ {

View File

@ -1,4 +1,5 @@
#define _VE0100_H #ifndef __VE0100_H
#define __VE0100_H
// Operazioni che può fare il motore su un documento // Operazioni che può fare il motore su un documento
#define OP_NUOVO 1 #define OP_NUOVO 1
@ -16,3 +17,252 @@
#define F_SHEET 500 #define F_SHEET 500
#define F_MEMORIGA 501 #define F_MEMORIGA 501
#define BASE_PIEDE 600 #define BASE_PIEDE 600
#define CHANGE_MESSAGE "Sono state effettuate modifiche alla configurazione.\nPrima di eseguire la gestione documenti occorrerà rigenerare le maschere.\nDesideri farlo ora ?"
// Modifiche pianificate per il dopo/cattolica:
// Rorganizzazione del codice come:
// Oggetto documento
// che contiene:
// Array di oggetti riga
// Oggetto Cliente
// Oggetto Cambio
// Oggetto Sconto testa
#define F_LBTIPORIGA 175
#define NPIEDI 40
#include <xvt_defs.h>
#ifndef __CHECKS_H
#include <checks.h>
#endif
#ifndef __EXPR_H
#include <expr.h>
#endif
#ifndef __TABUTIL_H
#include <tabutil.h>
#endif
#ifndef __BRWAPP_H
#include <brwapp.h>
#endif
#ifndef __RELAPP_H
#include <relapp.h>
#endif
#ifndef __CONFIG_H
#include <config.h>
#endif
#ifndef __LFFILES_H
#include <lffiles.h>
#endif
#ifndef __DEFMASK_H
#include "defmask.h"
#endif
#ifndef __VEUML_H
#include "veuml.h"
#endif
#ifndef __VEUML1_H
#include "veuml1.h"
#endif
#ifndef __VEUML2_H
#include "veuml2.h"
#endif
#ifndef __SHEET_H
#include <sheet.h>
#endif
#ifndef __REAL_H
#include <real.h>
#endif
#ifndef __MSKSHEET_H
#include <msksheet.h>
#endif
#ifndef __VE0100C_H
#include "ve0100c.h"
#endif
#ifndef __VE0100D_H
#include "ve0100d.h"
#endif
#ifndef __TCLIFOR_H
#include "tclifor.h"
#endif
#ifndef __RIGHEDOC_H
#include "righedoc.h"
#endif
#ifndef __VE1000O_H
#include "ve1000o.h"
#endif
#ifndef __TMASKVEN_H
#include "tmaskven.h"
#endif
#ifndef __EXECP_H
#include "execp.h"
#endif
#ifndef __SCONTI_H
#include "sconti.h"
#endif
// Definizione della classe dell'applicazione motore
class TMotore_application : public TRelation_application
{
// Array di totalizzatori
TPiede_documento _piede;
// Record array per la gestione delle righe
TRecord_array* _righe_rec;
// Puntatore al profilo del documento caricato
TConfig* _pro;
// Puntatore al nome, per evitare di ricrearlo se è uguale
TFilename* _proname;
// Puntatore alla maschera di ricerca
TMask* _msk;
// Puntatore alla maschera di modifica/inserimento ( dipende dal profilo )
TMask_vendite* _msk1;
// puntatore alla relazione
TRelation* _rel;
// Puntatore allo sheet delle righe documento
TSheet_field* _sheet;
// Oggetto cliente per il motore
TCliForVendite* _clifor;
// Indica se il documento ha come soggetto un <C>liente o un <F>ornitore
char _tipocf;
// Ridefinizione dei metodi virtuali
virtual bool user_create( );
virtual bool user_destroy( );
virtual TMask* get_mask( int mode );
virtual bool changing_mask( int mode );
virtual TRelation* get_relation( ) const { return _rel;}
virtual void init_insert_mode( TMask& m );
virtual int read( TMask& m );
virtual bool remove( void );
virtual int write( const TMask& m );
virtual int rewrite( const TMask& m );
// Punti di ingresso per le funzioni utente
// Funzioni da associare ad ogni procedura
int user_function( int index );
// Funzioni per il calcolo delle righe
real user_row_calculate( TRectype& row, int index );
void user_set_handler( int fieldid, int index, TMask* m = NULL );
long prossimo_numero( bool provv );
int avanza_numero( bool provv );
void get_edit_mask( const char * profilo );
void azzera_piedi( );
void carica_piedi( );
void somma_piedi( );
void sottrai_piedi( );
// Esegue, se c'è, la procedura utente relativa ad una certa operazione
int esegui_procedura( int operazione );
protected:
// Procedure e funzioni per la gestione della maschera e dei files
void read_rdoc( TMask& m );
// formato dipendente dallo sheet ( sono le varie colonne )
void load_riga( TSheet_field& f, int numrig, TRectype& r );
void store_riga( TSheet_field& f, int numrig, TRectype& r );
void save( TRelation* r ) const;
void set_descr ( int numrig, const char* descr );
void carica_righe_libere( int from = -1 );
bool check_key( TLocalisamfile& rdoc, TString16 codnum, bool provv, TString16 _anno, TString16 _ndoc );
// Procedure e funzioni per la gestione degli stati
// void setta_stato_corrente( int nuovostato );
const char* nome_sezione( int op );
int stato_corrente( );
int stato_finale( int operazione );
bool stato_valido( int stato, int operazione );
void segnala_stato_non_valido( int operazione );
TString& stati_validi( int operazione ){ return ( pro( ).get( "STATIVALIDI", nome_sezione( operazione ) ) );}
// Handle che ritorna la maschera per le righe
static TMask * ss_getmask( int numriga, TMask& fullmask, bool destroy );
// Handler che gestisce la richiesta del tipo riga in inserimento
static bool ss_handler( TSheet_field& ss, int r, KEY key );
// Handler per la maschera di ricerca
static bool ndoc_handler( TMask_field& f, KEY key );
static bool num_handler( TMask_field& f, KEY key );
static bool tip_handler( TMask_field& f, KEY key );
// Handler per la maschera di modifica
static bool clifo_handler( TMask_field& f, KEY key );
static bool occas_handler( TMask_field& f, KEY key );
static bool val_handler( TMask_field& f, KEY key );
// Configurazione dello sheet dato il profilo
void configura_sheet( TSheet_field& sheet, TConfig& config );
// Funzione per la sostituzione delle variabili nella decodifica
// delle espressioni di una riga
void carica_variabile( TExpression& e, const char * varname, TRectype r );
public:
// Funzioni di accesso alle variabili private
TRecord_array& righe_rec( ) { CHECK( _righe_rec, "Record array delle righe nullo!" ); return * _righe_rec; }
TConfig& pro( ) { CHECK( _pro, "Profilo del documento nullo!" ); return *_pro; }
TFilename& proname( ) { CHECK( _proname, "Nome del profilo nullo!" ); return *_proname; }
TMask& query_mask( ) { CHECK( _msk, "Maschera di ricerca nulla!" ); return *_msk; }
TMask& edit_mask( ) { CHECK( _msk1, "Maschera di modifica nulla!" ); return *_msk1; }
TRelation& rel( ) { CHECK( _rel, "Relazione nulla!" ); return *_rel; }
TSheet_field& sheet( ) { CHECK( _sheet, "Sheet nullo!" ); return *_sheet; }
TCliForVendite& clifo( ) { CHECK( _clifor, "Oggetto cliente nullo!" ); return *_clifor; }
TPiede_documento& piede( ){ return _piede; }
// Operazione
const char tipocf( ){ return _tipocf; }
void tipocf( const char tcf ){ _tipocf = tcf; }
bool valida_operazione( int operazione );
TSheet_field& ss( ) const { return *_sheet; }
TMotore_application( ) { _pro = NULL; }
virtual ~TMotore_application( ) { if ( _pro ) delete _pro; }
virtual const char* get_next_key( );
};
TMotore_application& app( );
#endif

View File

@ -1,4 +1,5 @@
// Handler di marco sui campi delle maschere // Handler di MarcoclaD sui campi delle maschere
#ifndef __CHECKS_H #ifndef __CHECKS_H
#include <checks.h> #include <checks.h>
#endif #endif
@ -35,6 +36,10 @@
#include "..\cg\pagament.h" #include "..\cg\pagament.h"
#endif #endif
#ifndef __SCONTI_H
#include "sconti.h"
#endif
bool ora_hndl( TMask_field& field, KEY key ) bool ora_hndl( TMask_field& field, KEY key )
{ {
if (key == K_TAB) if (key == K_TAB)
@ -45,14 +50,14 @@ bool ora_hndl(TMask_field& field, KEY key)
ora.trim( ); ora.trim( );
if (ora.not_empty( ) || field.required( ) ) if (ora.not_empty( ) || field.required( ) )
{ {
// bool changed = FALSE;
if ( isdigit( ora[ 0 ] ) ) if ( isdigit( ora[ 0 ] ) )
{ {
if ( ora[ 2 ] != ':') if ( ora[ 2 ] != ':')
{ {
if (ora.len()>4) ora.overwrite(":",2); if ( ora.len( ) > 4 )
else ora.insert(":", 2); ora.overwrite( ":", 2 );
// changed = TRUE; else
ora.insert( ":", 2 );
} }
} }
bool ok; bool ok;
@ -63,11 +68,9 @@ bool ora_hndl(TMask_field& field, KEY key)
error_box("Ora errata o formato non valido"); error_box("Ora errata o formato non valido");
return FALSE; return FALSE;
} }
else /* if (changed) */ else
{ {
field.set((ora)); field.set((ora));
// field.picture_data((ora),TRUE);
// field.picture_data((ora.strip(":")),FALSE);
} }
} }
} }
@ -75,35 +78,16 @@ bool ora_hndl(TMask_field& field, KEY key)
return TRUE; return TRUE;
} }
bool codcli_hndl(TMask_field& field, KEY key)
{
if (key == K_TAB)
{
if (field.to_check(key))
{
field.send_key(K_TAB,F_CODVAL);
field.send_key(K_TAB,F_CODLIN);
field.send_key(K_TAB,F_CODPAG);
field.send_key(K_TAB,F_CODABIA);
field.send_key(K_TAB,F_CODCABA);
field.send_key(K_TAB,F_INDSP);
}
}
return TRUE;
}
bool dummy_hndl( TMask_field& field, KEY key ) bool dummy_hndl( TMask_field& field, KEY key )
{ {
warning_box( "Al campo %d è arrivato un KEY %d", field.dlg( ), key ); warning_box( "Al campo %d è arrivato un KEY %d", field.dlg( ), key );
return TRUE; return TRUE;
} }
// Handler per il calcolo delle date di pagamento
bool condpag_hndl( TMask_field& field, KEY key ) bool condpag_hndl( TMask_field& field, KEY key )
{ {
if ( key == K_TAB ) if ( key == K_TAB )
{
if (field.to_check(key))
{ {
TMask& m = field.mask( ); TMask& m = field.mask( );
TString16 condpag( m.get( F_CODPAG ) ); TString16 condpag( m.get( F_CODPAG ) );
@ -119,7 +103,26 @@ bool condpag_hndl(TMask_field& field, KEY key)
for( ; i < 5; i ++ ) for( ; i < 5; i ++ )
m.hide( F_DATASCAD1 + i ); m.hide( F_DATASCAD1 + i );
} }
}
return TRUE; return TRUE;
} }
// handler per la validazione di una stringa/sconto
bool sconto_hndl( TMask_field& field, KEY key )
{
if ( field.to_check( key, TRUE ) )
{
if (key == K_TAB)
{
TSconto s;
s.set( field.get( ), TRUE );
if( s.is_valid( ) )
{
field.set( s.get( ) );
return TRUE;
}
else
return FALSE;
}
}
return TRUE;
}

View File

@ -16,7 +16,7 @@
#include <tabutil.h> #include <tabutil.h>
#endif #endif
#define SINTASSI "Sintassi: VE0 -2 [a|b|c|d|e]" #define SINTASSI "Sintassi: VE0 -2 -[1|2|3|4|5]"
class TConf_vendite : public TConfig_application class TConf_vendite : public TConfig_application
{ {

View File

@ -15,6 +15,10 @@
#include <checks.h> #include <checks.h>
#endif #endif
#ifndef __URLDEFID_H
#include <urldefid.h>
#endif
#ifndef __FSTREAM_H #ifndef __FSTREAM_H
#include <fstream.h> #include <fstream.h>
#endif #endif
@ -51,10 +55,6 @@
#include <relation.h> #include <relation.h>
#endif #endif
#ifndef __VE0100_H
#include "ve0100.h"
#endif
#ifndef __VEUML_H #ifndef __VEUML_H
#include "veuml.h" #include "veuml.h"
#endif #endif
@ -71,6 +71,11 @@
#include "veini.h" #include "veini.h"
#endif #endif
#ifndef __VE0100_H
#include "ve0100.h"
#endif
// Significato delle colonne nella tabella _tab0300b // Significato delle colonne nella tabella _tab0300b
#define B_NOME 0 #define B_NOME 0
#define B_MSKTYPE 1 #define B_MSKTYPE 1
@ -86,13 +91,13 @@
// Numero massimo di linee per pagina // Numero massimo di linee per pagina
#define MAX_LINES_PER_PAGE 18
#define MASK_FIRST_LINE 5
#define MAX_LINES_PER_PAGE 16 #define GROUPKEY(x) format( "%5d", x )
#define MASK_FIRST_LINE 6
class TMaschera : public TObject class TMaschera : public TObject
{ {
private: private:
// Linea corrente // Linea corrente
@ -115,7 +120,7 @@ public:
void check( const int i ); void check( const int i );
// PAGE // PAGE
void pagina( const int i ){ _out << "PA \"Pagina " << i << "\" 11 60 14\n"; }; void pagina( const int i, const TString& title = "Pagina " ){ _out << "PA \"" << title << " " << i << "\" 11 60 14\n"; };
// PROMPT // PROMPT
void prompt( const int x, const int y, const TString& s = "" ){ _out << "PR " << x << " " << y << " \"" << s << "\"\n"; }; void prompt( const int x, const int y, const TString& s = "" ){ _out << "PR " << x << " " << y << " \"" << s << "\"\n"; };
@ -180,6 +185,107 @@ public:
// File .MSK di output // File .MSK di output
ofstream _out; ofstream _out;
};
class TMask_generator
{
private:
// Identificatore corrente per lo sheet
int _curid;
// vero se il gruppo è aperto
bool _groupopen;
// nome del file di .INI di input
TFilename _proname;
// File .INI di riferimento per i campi
TConfig _fieldsini;
// File .INI di riferimento per i gruppi
TConfig _groupsini;
// File .INI di input
TConfig* _pro;
TConfig _ditta;
// Tabelle per la generazione
// Campi dei documenti
TString_array _fields;
// Campi dello sheet
TString_array _tab0300b;
TAssoc_array _gruppi;
TMaschera *_m;
protected:
// Carica un file di tabella in un TString array
void carica_tabella( const TFilename& fn, TString_array& tabella );
// Scrive sul file di output una serie di righe uguali per funzione ( DISPLAY, ecc. )
void outline( const TString& s = "", const TString& prefix = "", const char sep = '~' );
// Crea un controllo del tipo specificato
void control( const int type, const int id = DLG_NULL, const int size = -1 );
// Ritorna vero se una componente della maschera è presente
int present( const int i, TToken_string line ){ const TString s = line.get( i ); return !(s.blank( )); };
// Carica dati dei campi
void carica_dati_campi( const TFilename& fn, TAssoc_array& a );
// Funzioni di accesso alle variabili private
// ------------------------------------------
// Funzioni per la lettura/scrittura di ID. Si incrementa da solo.
int id ( ) { return( _curid++ ); };
void id( const int i ){ _curid = i; };
// Funzioni di generazione ad alto livello
// ---------------------------------------
// Genera un campo a partire da una linea del file VE0300A.DAT
void genera_campo( TToken_string _line );
// Genera un campo dello sheet a partire da una linea del file VE0300B.DAT
void genera_campo_sheet( TToken_string _line );
// Genera la colonna dello sheet a partire da una linea del file VE0300B.DAT
void genera_item_sheet( TToken_string _line );
public:
TMaschera& maschera( ){ return *_m; }
// Costruttore, vuole il nome del file .INI
TMask_generator( const TString& profilo );
// Attiva la generazione della maschera
void genera( const TString& );
// Genera l'intestazione di una pagina ( non la prima )
void intestazione_pagina( );
TConfig& profilo( ){ return *_pro; }
TConfig& ditta( ){ return _ditta; }
TConfig& groupsini( ){ return _groupsini; }
TConfig& fieldsini( ){ return _fieldsini; }
// Distruttore
virtual ~TMask_generator( );
}; };
@ -197,7 +303,8 @@ void TMaschera::outline( const TString& s, const TString& prefix, const char sep
if ( s.left( 1 ) == "@" ) if ( s.left( 1 ) == "@" )
_out << "CO " << prefix << s.mid( 1 ) << "\n"; _out << "CO " << prefix << s.mid( 1 ) << "\n";
else else
{ TToken_string u( s, sep ); {
TToken_string u( s, sep );
for ( int i = 0; i < u.items( ); i ++ ) for ( int i = 0; i < u.items( ); i ++ )
_out << prefix << u.get( i ) << "\n"; _out << prefix << u.get( i ) << "\n";
} }
@ -270,6 +377,8 @@ void TMaschera::item( const TString& str )
} }
} }
class TField;
class TGruppo : public TObject class TGruppo : public TObject
{ {
protected: protected:
@ -277,31 +386,27 @@ protected:
int _id; int _id;
int _height; int _height;
bool _present; bool _present;
TArray _fields;
TMask_generator * _mg;
public: public:
TMaschera& maschera( ){ return generatore( ).maschera( ); }
TMask_generator& generatore( ){ CHECK( _mg, "Generatore nullo!" ); return *_mg; }
void generatore( TMask_generator& mg ){ _mg = &mg; }
void id( int id ){ _id = id; } void id( int id ){ _id = id; }
int id( ){ return _id; } int id( ){ return _id; }
void height( int h ){ _height = h; } void height( int h ){ _height = h; }
int height( ){ return _height; } int height( ){ return _height; }
void present( bool p ){ _present = p; } void present( bool p ){ _present = p; }
bool present( ){ return _present; } bool present( ){ return _present; }
TArray& campi( ){ return _fields; }
TGruppo ( int i ); TGruppo ( int i );
TGruppo ( int i, TConfig& pro ); TGruppo ( int i, int height );
}; void genera( );
void add( TField * field );
TGruppo::TGruppo( int i )
{
TConfig pro( "ve0300c.ini" );
_id = i;
_height = pro.get_int( "HEIGHT", format( "%d", i ) );
};
TGruppo::TGruppo( int i, TConfig& pro )
{
_id = i;
_height = pro.get_int( "HEIGHT", format( "%d", i ) );
}; };
class TField : public TObject class TField : public TObject
@ -309,6 +414,9 @@ class TField : public TObject
protected: protected:
TString _nome; TString _nome;
// Gruppo di appartenenza
TGruppo *_grp;
int _gruppo; int _gruppo;
int _id; int _id;
int _type; int _type;
@ -323,12 +431,13 @@ public:
TField( TString& campo, TConfig& pro ); TField( TString& campo, TConfig& pro );
TField( ); TField( );
void genera( TMaschera& _m ); void genera( );
void configura( TConfig& pro ); void configura( TConfig& pro );
void x( int x ){ _x = x; } void x( int x ){ _x = x; }
void y( int y ){ _y = y; } void y( int y ){ _y = y; }
void gruppo( int gruppo ){ _gruppo = gruppo; } void gruppo( int gruppo ){ _gruppo = gruppo; }
void grp( TGruppo& grp ){ _grp = &grp; }
void id( int id ){ _id = id; } void id( int id ){ _id = id; }
void type( int type ){ _type = type; } void type( int type ){ _type = type; }
void size( int size ){ _size = size; } void size( int size ){ _size = size; }
@ -336,10 +445,12 @@ public:
int x( ){ return _x; } int x( ){ return _x; }
int y( ){ return _y; } int y( ){ return _y; }
int gruppo( ){ return _gruppo; } int gruppo( ){ return _gruppo; }
TGruppo& grp( ) const { return *_grp; }
int id( ){ return _id; } int id( ){ return _id; }
int type( ){ return _type; } int type( ){ return _type; }
int size( ){ return _size; } int size( ){ return _size; }
int stato( ){ return _stato; } int stato( ){ return _stato; }
int stato_reale( );
void nome( TString& nome ){ _nome = nome; } void nome( TString& nome ){ _nome = nome; }
@ -370,17 +481,78 @@ public:
TToken_string& items( ){ return _items; } TToken_string& items( ){ return _items; }
TToken_string& configs( ){ return _configs; } TToken_string& configs( ){ return _configs; }
TConfig& profilo( ) { return grp( ).generatore( ).profilo( ); }
TConfig& ditta( ) { return grp( ).generatore( ).ditta( ); }
TConfig& groupsini( ) { return grp( ).generatore( ).groupsini( ); }
TConfig& fieldsini( ) { return grp( ).generatore( ).fieldsini( ); }
friend int sort_by_group(const TObject** o1, const TObject** o2 );
// friend int TMask_generator::group( const TField& f1 );
}; };
int sort_by_group(const TObject** o1, const TObject** o2 ) void TGruppo::add( TField * field )
{ {
int g1 = ((TField * )( *o1 ))->_gruppo; _fields.add( field );
int g2 = ((TField * )( *o2 ))->_gruppo; field->grp( *this );
return ( g1 < g2 ) ? -1 : ( ( g1 = g2 ) ? 0 : 1 ); }
};
TGruppo::TGruppo( int i )
{
TConfig pro( "ve0300c.ini" );
_id = i;
_height = pro.get_int( "HEIGHT", format( "%d", i ) );
}
TGruppo::TGruppo( int i, int height )
{
_id = i;
_height = height;
}
static void genera_campo( const TObject& campo )
{
// Per evitare 3000 casts ...
TField& cmp = ( TField& )campo;
cmp.configura( cmp.grp( ).generatore( ).profilo( ) );
cmp.genera( );
}
static void verifica_campo( const TObject& campo )
{
// Per evitare 3000 casts ...
TField& cmp = ( TField& )campo;
int stato = cmp.stato_reale( );
cmp.stato( stato );
if( cmp.stato( ) != S_NASCOSTO )
cmp.grp( ).present( TRUE );
}
static void genera_gruppo( const TObject& gruppo )
{
// Per evitare 3000 casts ...
TGruppo& grp = ( TGruppo& )gruppo;
grp.present( FALSE );
grp.campi( ).for_each( verifica_campo );
if( grp.present( ) )
grp.genera( );
}
void TGruppo::genera( )
{
// Se il gruppo non sta sulla pagina ...
int oldlinea = maschera( ).line( );
if ( oldlinea + _height > MAX_LINES_PER_PAGE )
{
// Passa alla pagina successiva
maschera( ).end( );
generatore( ).intestazione_pagina( );
maschera( ).line( MASK_FIRST_LINE );
oldlinea = MASK_FIRST_LINE;
}
_fields.for_each( genera_campo );
maschera( ).line( oldlinea + _height );
}
TField::TField( TString& campo, TConfig& pro ) : _nome( campo ) TField::TField( TString& campo, TConfig& pro ) : _nome( campo )
{ {
@ -451,6 +623,56 @@ TField::TField( )
_items.separator( '@' ); _items.separator( '@' );
} }
int TField::stato_reale( )
{
// Strategia al 28/08/95
// Se il campo, nel file .INI di definizione dei campi, è legato a qualche voce in
// configurazione, legge il suo stato, altrimenti assume il massimo.
// Va poi a verificare nel .INI da compilare, e verifica li' la impostazione.
// Controlla poi la impostazione per il gruppo, come impostato nel file .INI
// e nella sezione CONFIGS nel .INI di definizione dei gruppi.
// Utilizza poi la minore delle due.
TToken_string config( fieldsini( ).get( "CONFIGS", _nome ) );
TString reale;
int items = config.items( );
int stato = S_OBBLIGATORIO;
for ( int i = 0; i < items; i += 3 )
{ TString chiave = config.get( i );
TString valore = config.get( i + 1 );
TString reale = ditta( ).get( chiave, "ve" );
int pos = chiave.find( '[' );
if ( pos >= 0 )
{
TString index = chiave.sub( pos + 1, chiave.find( ']' ) );
chiave = chiave.sub( 0, pos );
reale = ditta( ).get( chiave, "ve", atoi( index ) );
}
else
reale = ditta( ).get( chiave, "ve" );
if ( reale == valore )
stato = atoi( ( char * ) config.get( i + 2 ) );
};
TToken_string riga_profilo( grp( ).generatore( ).profilo( ).get( _nome, "PROFILO" ) );
int stato_profilo = riga_profilo.get_int( P_STATO );
stato = ( stato < stato_profilo )? stato : stato_profilo;
TString gruppo ( fieldsini( ).get( "GROUP", _nome ) );
gruppo.trim( );
config = ( groupsini( ).get( "CONFIGS", gruppo ) );
items = config.items( );
int stato_gruppo = S_OBBLIGATORIO;
for ( i = 0; i < items; i += 3 )
{ TString chiave = config.get( i );
TString valore = config.get( i + 1 );
reale = ditta( ).get( chiave, "ve" );
if ( reale == valore )
stato_gruppo = atoi( ( char * ) config.get( i + 2 ) );
};
stato = ( stato < stato_gruppo )? stato : stato_gruppo;
int stato_gruppo_profilo = grp( ).generatore( ).profilo( ).get_int( gruppo, "PROFILOGRUPPO" );
stato = ( stato < stato_gruppo_profilo )? stato : stato_gruppo_profilo;
return stato;
}
void TField::configura( TConfig& pro ) void TField::configura( TConfig& pro )
{ {
TToken_string riga_profilo( pro.get( _nome, "PROFILO" ) ); TToken_string riga_profilo( pro.get( _nome, "PROFILO" ) );
@ -465,8 +687,9 @@ void TField::configura( TConfig& pro )
_warning = newwarning; _warning = newwarning;
} }
void TField::genera( TMaschera& m ) void TField::genera( )
{ {
TMaschera& m = grp( ).maschera( );
TString s; TString s;
if ( _stato == S_NASCOSTO ) if ( _stato == S_NASCOSTO )
@ -509,103 +732,7 @@ void TField::genera( TMaschera& m )
} }
} }
// Definizione dei metodi di_generator
class TMask_generator
{
private:
// Identificatore corrente per lo sheet
int _curid;
// vero se il gruppo è aperto
bool _groupopen;
// nome del file di .INI di input
TFilename _proname;
// File .INI di riferimento per i campi
TConfig _fieldsini;
// File .INI di riferimento per i gruppi
TConfig _groupsini;
// File .INI di input
TConfig* _pro;
TConfig _ditta;
// Tabelle per la generazione
// Campi dei documenti
TString_array _fields;
// Campi dello sheet
TString_array _tab0300b;
TArray _campi;
protected:
// Carica un file di tabella in un TString array
void carica_tabella( const TFilename& fn, TString_array& tabella );
// Scrive sul file di output una serie di righe uguali per funzione ( DISPLAY, ecc. )
void outline( const TString& s = "", const TString& prefix = "", const char sep = '~' );
// Crea un controllo del tipo specificato
void control( const int type, const int id = DLG_NULL, const int size = -1 );
// Ritorna vero se una componente della maschera è presente
int present( const int i, TToken_string line ){ const TString s = line.get( i ); return !(s.blank( )); };
// Carica dati dei campi
void carica_dati_campi( const TFilename& fn, TArray& a );
// Funzioni di accesso alle variabili private
// ------------------------------------------
// Funzioni per la lettura/scrittura di ID. Si incrementa da solo.
int id ( ) { return( _curid++ ); };
void id( const int i ){ _curid = i; };
// Funzioni di generazione ad alto livello
// ---------------------------------------
// Genera un campo a partire da una linea del file VE0300A.DAT
void genera_campo( TToken_string _line );
// Genera un campo dello sheet a partire da una linea del file VE0300B.DAT
void genera_campo_sheet( TToken_string _line );
// Genera la colonna dello sheet a partire da una linea del file VE0300B.DAT
void genera_item_sheet( TToken_string _line );
// Genera l'intestazione di una pagina ( non la prima )
void intestazione_pagina( );
// Ritorna lo stato che dovrà avere il campo sulla maschera da generare
int stato_del_campo( TString campo );
public:
TMaschera * _m;
// Costruttore, vuole il nome del file .INI
TMask_generator( const TString& profilo );
// Attiva la generazione della maschera
void genera( const TString& );
// Distruttore
virtual ~TMask_generator( );
};
// Definizione dei metodi di TMask_generator
// ----------------------------------------- // -----------------------------------------
TMask_generator::TMask_generator( const TString& profilo ) : _fieldsini( "ve0300a.ini" ), _groupsini( "ve0300c.ini" ), _ditta( CONFIG_DITTA ) TMask_generator::TMask_generator( const TString& profilo ) : _fieldsini( "ve0300a.ini" ), _groupsini( "ve0300c.ini" ), _ditta( CONFIG_DITTA )
@ -614,20 +741,18 @@ TMask_generator::TMask_generator( const TString& profilo ) : _fieldsini( "ve0300
_fieldsini.list_paragraphs( _fields ); _fieldsini.list_paragraphs( _fields );
CHECK( fexist( "ve0300b.dat" ), "Il file ve0300b.dat non esiste!" ); CHECK( fexist( "ve0300b.dat" ), "Il file ve0300b.dat non esiste!" );
carica_tabella( "ve0300b.dat", _tab0300b ); carica_tabella( "ve0300b.dat", _tab0300b );
carica_dati_campi( "ve0300a.ini", _campi ); carica_dati_campi( "ve0300a.ini", _gruppi );
TString16 param( profilo ); TString16 param( profilo );
param.lower( ); param.lower( );
if( param == "-all" ) if( param == "-all" )
{ {
TRelation rel("TIP"); TRelation rel("%TIP");
TCursor t( &rel ); TCursor t( &rel );
long count = t.items( ); long count = t.items( );
TProgind bar( count, "Generazione delle maschere", FALSE, TRUE); TProgind bar( count, "Generazione delle maschere", FALSE, TRUE);
t = 0; for( t = 0; t.pos( ) < count; ++t )
while( t.ok() )
{ {
genera( t.curr( ).get( "S4" ) ); genera( t.curr( ).get( "S4" ) );
++t;
bar.addstatus(1); bar.addstatus(1);
} }
} }
@ -639,12 +764,39 @@ TMask_generator::~TMask_generator( )
}; };
/*
void TMask_generator::carica_dati_campi( const TFilename& fn, TArray& a ) void TMask_generator::carica_ordine_gruppi( )
{
int last, i;
last = _gruppi.items( );
for( i = 1; i <= last; i ++ )
{
TString16 chiavepro, chiavegruppi;
chiavepro.format( "%d", i );
const int gruppo( _pro->get_int( chiavepro, "ORDINEGRUPPI" ) );
chiavegruppo.format( "%5d", gruppo );
( ( TGruppo& )_gruppi[ chiavegruppo ] ).ordine( i );
}
last = _pro->get( "NGRUPPI", "ORDINEGRUPPI" );
for( i = 1; i <= last; i ++ )
{
TString16 chiavepro, chiavegruppi;
chiavepro.format( "%d", i );
const int gruppo( _pro->get_int( chiavepro, "ORDINEGRUPPI" ) );
chiavegruppo.format( "%5d", gruppo );
( ( TGruppo& )_gruppi[ chiavegruppo ] ).ordine( i );
}
}
*/
void TMask_generator::carica_dati_campi( const TFilename& fn, TAssoc_array& a )
{ {
TScanner infile( fn ); TScanner infile( fn );
TString line; TString line;
TField *campo = NULL; TField *campo = NULL;
TGruppo *gruppo = NULL;
TString16 curgruppo( "" );
while ( infile.ok( ) ) while ( infile.ok( ) )
{ {
@ -661,7 +813,23 @@ void TMask_generator::carica_dati_campi( const TFilename& fn, TArray& a )
{ {
line.strip( "[]" ); line.strip( "[]" );
if ( campo ) if ( campo )
a.add( campo ); {
TString16 fieldkey = GROUPKEY( campo->gruppo( ) );
if ( fieldkey != curgruppo )
{
if ( gruppo )
{
a.add( curgruppo, gruppo );
}
TString16 taggruppo;
taggruppo.format( "%d", campo->gruppo( ) );
int hgruppo = _groupsini.get_int( "HEIGHT", taggruppo );
gruppo = new TGruppo( campo->gruppo( ), hgruppo );
gruppo->generatore( *this );
}
gruppo->add( campo );
curgruppo = GROUPKEY( campo->gruppo( ) );
}
campo = new TField( ); campo = new TField( );
campo->nome( line ); campo->nome( line );
} }
@ -725,11 +893,28 @@ void TMask_generator::carica_dati_campi( const TFilename& fn, TArray& a )
} }
} }
if ( campo ) if ( campo )
a.add( campo ); {
if( format( "%5d", campo->gruppo( ) ) != curgruppo )
{
if( gruppo )
{
a.add( curgruppo, gruppo );
}
TString16 taggruppo;
taggruppo.format( "%d", campo->gruppo( ) );
int hgruppo = _groupsini.get_int( "HEIGHT", taggruppo );
gruppo = new TGruppo( campo->gruppo( ), hgruppo );
gruppo->generatore( *this );
}
gruppo->add( campo );
curgruppo = GROUPKEY( campo->gruppo( ) );
a.add( curgruppo, gruppo );
}
} }
void TMask_generator::carica_tabella( const TFilename& fn, TString_array& tabella ) void TMask_generator::carica_tabella( const TFilename& fn, TString_array& tabella )
{ TScanner in( fn ); {
TScanner in( fn );
TToken_string line = in.line( ); TToken_string line = in.line( );
while( line.not_empty( ) ) while( line.not_empty( ) )
{ // Attacca tutte le righe che finiscono con § { // Attacca tutte le righe che finiscono con §
@ -740,46 +925,6 @@ void TMask_generator::carica_tabella( const TFilename& fn, TString_array& tabell
tabella.add( line ); tabella.add( line );
line = in.line( ); line = in.line( );
} }
};
int TMask_generator::stato_del_campo( TString campo )
{
// Strategia al 28/08/95
// Se il campo, nel file .INI di definizione dei campi, è legato a qualche voce in
// configurazione, legge il suo stato, altrimenti assume il massimo.
// Va poi a verificare nel .INI da compilare, e verifica li' la impostazione.
// Controlla poi la impostazione per il gruppo, come impostato nel file .INI
// e nella sezione CONFIGS nel .INI di defiunizione dei gruppi.
// Utilizza poi la minore delle due.
TToken_string config( _fieldsini.get( "CONFIGS", campo ) );
int items = config.items( );
int stato = S_OBBLIGATORIO;
for ( int i = 0; i < items; i += 3 )
{ TString chiave = config[ i ];
TString valore = config[ i + 1 ];
TString reale = _ditta.get( chiave, "VE" );
if ( reale == valore )
stato = atoi( ( char * ) config[ i + 2 ] );
};
TToken_string riga_profilo( _pro->get( campo, "PROFILO" ) );
int stato_profilo = riga_profilo.get_int( P_STATO );
stato = ( stato < stato_profilo )? stato : stato_profilo;
TString gruppo ( _fieldsini.get( "GROUP", campo ) );
gruppo.trim( );
config = ( _groupsini.get( "CONFIGS", gruppo ) );
int stato_gruppo = S_OBBLIGATORIO;
for ( i = 0; i < items; i += 3 )
{ TString chiave = config[ i ];
TString valore = config[ i + 1 ];
TString reale = _ditta.get( chiave, "VE" );
if ( reale == valore )
stato_gruppo = atoi( ( char * ) config[ i + 2 ] );
};
stato = ( stato < stato_gruppo )? stato : stato_gruppo;
int stato_gruppo_profilo = _pro->get_int( gruppo, "PROFILOGRUPPO" );
stato = ( stato < stato_gruppo_profilo )? stato : stato_gruppo_profilo;
return stato;
} }
void TMask_generator::genera_campo_sheet( TToken_string _line ) void TMask_generator::genera_campo_sheet( TToken_string _line )
@ -801,82 +946,40 @@ void TMask_generator::genera_item_sheet( TToken_string _line )
void TMask_generator::intestazione_pagina( ) void TMask_generator::intestazione_pagina( )
{ {
_m->page( _m->page( ) + 1 ); _m->page( _m->page( ) + 1 );
_m->pagina( _m->page( ) ); _m->pagina( _m->page( ), _pro->get( "TYPE", "MAIN" ) );
_m->control( T_CORNICE, DLG_NULL, 7806 ); _m->control( T_CORNICE, DLG_NULL, 7805 );
_m->begin( ); _m->begin( );
_m->prompt( 1, 0, "" ); _m->prompt( 1, 0, "" );
_m->end( ); _m->end( );
_m->control( T_STRINGA, DLG_NULL, 4 );
_m->begin();
_m->prompt( 2, 1, "Cod. num. " );
_m->group( 2 );
_m->flag( "DUZ" );
_m->end();
_m->control( T_STRINGA, DLG_NULL, 50 ); _m->control( T_STRINGA, DLG_NULL, 50 );
_m->begin( ); _m->begin( );
_m->prompt( 24, 1 ); _m->prompt( 2, 1, "Tipo doc. " );
_m->flag( "DU" );
_m->group( 3 );
_m->end();
_m->control( T_STRINGA, DLG_NULL, 4 );
_m->begin();
_m->prompt( 2, 2, "Tipo doc. " );
_m->flag( "DU" );
_m->group( 4 );
_m->end();
_m->control( T_STRINGA, DLG_NULL, 50 );
_m->begin();
_m->prompt( 24, 2 );
_m->flag( "DU" ); _m->flag( "DU" );
_m->group( 5 ); _m->group( 5 );
_m->end( ); _m->end( );
_m->control( T_NUMERO, DLG_NULL, 6 ); _m->control( T_NUMERO, DLG_NULL, 6 );
_m->begin( ); _m->begin( );
_m->prompt( 2, 3, "Doc.: nr. " ); _m->prompt( 2, 2, "Doc.: nr. " );
_m->group( 6 ); _m->group( 6 );
_m->flag( "D" ); _m->flag( "D" );
_m->end( ); _m->end( );
_m->control( T_DATA ); _m->control( T_DATA );
_m->begin( ); _m->begin( );
_m->prompt( 24, 3, "Data " ); _m->prompt( 24, 2 );
_m->group( 7 ); _m->group( 7 );
_m->flag( "D" ); _m->flag( "D" );
_m->end( ); _m->end( );
_m->control( T_NUMERO, DLG_NULL, 1 );
_m->begin();
_m->prompt( 50, 3, "Stato " );
_m->group( 8 );
_m->flag( "D" );
_m->end();
_m->control( T_STRINGA, DLG_NULL, 4 );
_m->begin();
_m->prompt( 66, 3, "Es. " );
_m->flag( "D" );
_m->group( 9 );
_m->end();
_m->control( T_STRINGA, DLG_NULL, 6 );
_m->begin();
if ( _pro->get( "TIPOCF", "MAIN" ) == "C" )
_m->prompt( 2, 4, "Cliente " );
else
_m->prompt( 2, 4, "Fornitore " );
_m->flag( "D" );
_m->group( 10 );
_m->end();
_m->control( T_STRINGA, DLG_NULL, 50 ); _m->control( T_STRINGA, DLG_NULL, 50 );
_m->begin( ); _m->begin( );
_m->prompt( 24, 4, "" ); if ( _pro->get( "TIPOCF", "MAIN" ) == "C" )
_m->prompt( 2, 3, "Cliente " );
else
_m->prompt( 2, 3, "Fornitore " );
_m->flag( "D" ); _m->flag( "D" );
_m->group( 11 ); _m->group( 11 );
_m->end( ); _m->end( );
@ -885,7 +988,7 @@ void TMask_generator::intestazione_pagina( )
void TMask_generator::genera( const TString& profilo ) void TMask_generator::genera( const TString& profilo )
{ {
int i; int i, last;
TString temp_s; TString temp_s;
TFilename proname( profilo ), TFilename proname( profilo ),
// All'inizio il gruppo è 'chiuso' // All'inizio il gruppo è 'chiuso'
@ -903,6 +1006,8 @@ void TMask_generator::genera( const TString& profilo )
TFilename _mskname( _pro->get( "MSKFILE", "MAIN") ); TFilename _mskname( _pro->get( "MSKFILE", "MAIN") );
_mskname.ext( "msk" ); _mskname.ext( "msk" );
// Mi serve per ordinare i gruppi a seconda del documento
TAssoc_array grouporder;
_m = new TMaschera( _mskname ); _m = new TMaschera( _mskname );
@ -945,7 +1050,7 @@ void TMask_generator::genera( const TString& profilo )
// Header della prima pagina // Header della prima pagina
_m->outline( "PA \"Pagina \" 11 60 14" ); _m->pagina( _m->page( ), _pro->get( "TYPE", "MAIN" ) );
_m->control( T_CORNICE, DLG_NULL, 7806 ); _m->control( T_CORNICE, DLG_NULL, 7806 );
_m->begin( ); _m->begin( );
@ -969,6 +1074,7 @@ void TMask_generator::genera( const TString& profilo )
_m->control( T_STRINGA, F_TIPODOC, 4 ); _m->control( T_STRINGA, F_TIPODOC, 4 );
_m->begin( ); _m->begin( );
_m->field( "TIPODOC" );
_m->prompt( 2, 2, "Tipo doc. " ); _m->prompt( 2, 2, "Tipo doc. " );
_m->flag( "GDU" ); _m->flag( "GDU" );
_m->message( "CO,4@" ); _m->message( "CO,4@" );
@ -988,7 +1094,6 @@ void TMask_generator::genera( const TString& profilo )
_m->flag( "H" ); _m->flag( "H" );
_m->end( ); _m->end( );
_m->control( T_STRINGA, F_DESTIPODOC, 50 ); _m->control( T_STRINGA, F_DESTIPODOC, 50 );
_m->begin( ); _m->begin( );
_m->prompt( 24, 2 ); _m->prompt( 24, 2 );
@ -1035,7 +1140,6 @@ void TMask_generator::genera( const TString& profilo )
_m->prompt( 2, 4, "Cliente " ); _m->prompt( 2, 4, "Cliente " );
_m->warning( "Cliente assente" ); _m->warning( "Cliente assente" );
_m->help( "Codice del cliente del documento" ); _m->help( "Codice del cliente del documento" );
} }
else else
{ {
@ -1063,7 +1167,6 @@ void TMask_generator::genera( const TString& profilo )
{ {
_m->warning( "Cliente assente" ); _m->warning( "Cliente assente" );
_m->help( "Ragione sociale del cliente del documento" ); _m->help( "Ragione sociale del cliente del documento" );
} }
else else
{ {
@ -1082,15 +1185,36 @@ void TMask_generator::genera( const TString& profilo )
_m->outline( "ADD RU cg0 -1 C" ); _m->outline( "ADD RU cg0 -1 C" );
_m->message( "CO,11@" ); _m->message( "CO,11@" );
_m->end( ); _m->end( );
_m->line( MASK_FIRST_LINE ); _m->line( MASK_FIRST_LINE + 1 );
_m->_pageopen = TRUE;
// Generazione // Generazione
// Scorro l'array dei campi, per vedere gli stati ed i gruppi // carica_ordine_gruppi( );
// Scorro l'array dei gruppi, e ne creo una copia ordinata
// con solo i gruppi visibili
TAssoc_array gruppi; TArray sortedgroups;
TString16 chiave, chiavegruppo;
last = _pro->get_int( "NGROUPS", "ORDINEGRUPPI" );
for( i = 1; i <= last; i ++ )
{
chiave.format( "%d", i );
chiavegruppo.GROUPKEY( _pro->get_int( chiave, "ORDINEGRUPPI" ) );
if( _gruppi.is_key( chiavegruppo ) )
sortedgroups.add( &_gruppi[ (chiavegruppo) ] );
}
sortedgroups.for_each( genera_gruppo );
if ( _m->_pageopen == TRUE )
{
_m->end( );
intestazione_pagina( );
}
int last = _campi.items( ); /*
last = _campi.items( );
for( i = 0; i < last; i ++ ) for( i = 0; i < last; i ++ )
{ {
TString nome = (( TField & )_campi[ i ]).nome( ); TString nome = (( TField & )_campi[ i ]).nome( );
@ -1098,16 +1222,25 @@ void TMask_generator::genera( const TString& profilo )
if( stato != S_NASCOSTO ) if( stato != S_NASCOSTO )
{ {
const int addgruppo = (( TField & )_campi[ i ]).gruppo( ); const int addgruppo = (( TField & )_campi[ i ]).gruppo( );
const int ordine = 0; //ordine_del_gruppo( addgruppo );
if( ordine )
{
TString16 chiave; TString16 chiave;
chiave.format( "%5d", addgruppo ); chiave.format( "%5d", addgruppo );
if ( !gruppi.is_key( chiave ) ) if ( !gruppi.is_key( chiave ) )
gruppi.add( chiave, new TGruppo( addgruppo, _groupsini ) ); gruppi.add( chiave, new TGruppo( addgruppo, _groupsini ) );
} }
else
{
// Se il gruppo non compare nell'elenco dei gruppi,
stato = S_NASCOSTO;
}
}
(( TField & )_campi[ i ]).stato( stato ); (( TField & )_campi[ i ]).stato( stato );
// (( TField & )_campi[ i ]).ordine( ordine );
}; };
// Si ordinano a mano nel .INI per velocizzare il processo di generazione
// campi.sort( sort_by_group );
_campi.sort( );
// Generazione vera e propria // Generazione vera e propria
_m->_pageopen = TRUE; _m->_pageopen = TRUE;
last = _campi.items( ); last = _campi.items( );
@ -1151,48 +1284,68 @@ void TMask_generator::genera( const TString& profilo )
if ( _m->_pageopen == TRUE ) _m->end( ); if ( _m->_pageopen == TRUE ) _m->end( );
intestazione_pagina( ); intestazione_pagina( );
*/
// Generazione del listbox per i tipi di riga da aggiungere nello sheet // Generazione del listbox per i tipi di riga da aggiungere nello sheet
_m->control ( T_LISTA, F_LBTIPORIGA, 30 ); _m->control ( T_LISTA, F_LBTIPORIGA, 30 );
_m->begin( ); _m->begin( );
_m->prompt( 2, 7, "Tipo riga da aggiungere " ); _m->prompt( 2, 6, "Tipo riga da aggiungere " );
_m->end( ); _m->end( );
// Generazione dello sheet : vedi il profilo // Generazione dello sheet : vedi il profilo
TScanner sheet_in( "ve0300b.dat" ); TScanner sheet_in( "ve0300b.dat" );
_m->_out << "SPREADSHEET " << F_SHEET << " 76 6 \n"; _m->_out << "SPREADSHEET " << F_SHEET << " 76 6 \n";
// _m->_out << "SPREADSHEET " << F_SHEET << " 76 10 \n";
_m->begin( ); _m->begin( );
_m->prompt( 2, 8 ); _m->prompt( 2, 7 );
for( i = 0; i < _tab0300b.items( ); i ++ ) for( i = 0; i < _tab0300b.items( ); i ++ )
genera_item_sheet( _tab0300b.row( i ) ); genera_item_sheet( _tab0300b.row( i ) );
_m->end( ); _m->end( );
// Campo memo per mostrare le righe
_m->control( T_MEMO, F_MEMORIGA, 7604 ); _m->control( T_MEMO, F_MEMORIGA, 7604 );
_m->begin( ); _m->begin( );
_m->prompt( 2, 15, " " ); _m->prompt( 2, 14, " " );
_m->field( "34->DESCEST" ); _m->field( "34->DESCEST" );
_m->flag( "D" );
_m->end( ); _m->end( );
_m->end( ); _m->end( );
// Generazione pagina dei piedi // Generazione pagina dei piedi
TToken_string s(_pro->get( "PROGPIEDE", "MAIN" ) ); TToken_string s(_pro->get( "PROGPIEDE", "MAIN" ) );
TTable tab( "PPD" );
if ( s.not_empty( ) ) if ( s.not_empty( ) )
{ {
intestazione_pagina( ); intestazione_pagina( );
TString16 codpiede( s.get( ) );
int cp = 1; int cp = 1;
int piede = s.get_int();; while ( !codpiede.empty( ) )
while ( piede != 0 )
{ {
_m->control( T_NUMERO, BASE_PIEDE + cp, 1805 ); tab.zero( );
tab.put( "CODTAB", codpiede );
if ( tab.read( ) == NOERR )
{
TString picture( tab.get( "S3" ) );
_m->control( T_NUMERO, BASE_PIEDE + tab.get_int( "I0" ), 1805 );
_m->begin( ); _m->begin( );
TString header = _ditta.get( "PIEDE", "ve", piede ); TString header = tab.get( "S1" );
while( header.len() < 40 ) header << " "; header.trim( );
while( header.len( ) < 40 - picture.len( ) )
header << " ";
_m->prompt( 2, 7 + cp, header ); _m->prompt( 2, 7 + cp, header );
_m->flag( "D" ); _m->flag( "D" );
_m->end( ); _m->end( );
cp ++; cp ++;
piede = s.get_int(); if( cp + MASK_FIRST_LINE > MAX_LINES_PER_PAGE )
{
_m->end( );
intestazione_pagina( );
_m->line( MASK_FIRST_LINE );
cp = 1;
}
}
codpiede = s.get( );
} }
_m->end( ); _m->end( );
}; };
@ -1224,23 +1377,24 @@ class TGenMask_application : public TApplication
protected: protected:
virtual bool create ( ); virtual bool create ( );
virtual bool menu( MENU_TAG _m ); virtual bool destroy( );
// virtual bool menu( MENU_TAG ); // Controlla il menu
}; };
bool TGenMask_application::menu(MENU_TAG _m)
{
TMask_generator a( argv( 2 ) );
return( TRUE );
};
bool TGenMask_application::create( ) bool TGenMask_application::create( )
{ {
TApplication::create( ); TApplication::create( );
menu( 0 ); TMask_generator a( argv( 2 ) );
return FALSE; return FALSE;
}; }
bool TGenMask_application::destroy( )
{
return TApplication::destroy() ;
}
int ve0300( int argc, char** argv ) int ve0300( int argc, char** argv )
{ {

View File

@ -2,4 +2,3 @@
#define F_D_CODCAT 112 #define F_D_CODCAT 112
#define F_D_SCONTO 113 #define F_D_SCONTO 113
#define F_D_DESCR 114 #define F_D_DESCR 114


View File

@ -6,4 +6,3 @@
#define F_R_DESART 126 #define F_R_DESART 126
#define F_R_SCONTO 127 #define F_R_SCONTO 127
#define F_R_DESCAT 128 #define F_R_DESCAT 128


View File

@ -100,8 +100,8 @@ bool TCondizioni_vendita::user_create() {
DESTROY(F_L_DESSUCC); DESTROY(F_L_DESSUCC);
_codcon_codcf= prassid.get_bool("GESCONCC"); // setta il booleano di abilitazione di TIPOCF e CODCF _codcon_codcf= prassid.get_bool("GESCONCC"); // setta il booleano di abilitazione di TIPOCF e CODCF
if (!_codcon_codcf) { // disabilita i campi di gestione clienti/fornitori in base al flag. di config. if (!_codcon_codcf) { // disabilita i campi di gestione clienti/fornitori in base al flag. di config.
KILL(F_R_C_TIPOCF); KILL(F_C_TIPOCF);
KILL(F_R_C_CODCF); KILL(F_C_CODCF);
} }
set_search_field(F_C_COD); // impostazione del campo di ricerca set_search_field(F_C_COD); // impostazione del campo di ricerca
_gest_um= prassid.get_bool("GESUM", NULL, A_CONTRATTI); // setta il booleano di abilitazione delle unità di misura _gest_um= prassid.get_bool("GESUM", NULL, A_CONTRATTI); // setta il booleano di abilitazione delle unità di misura

Binary file not shown.

View File

@ -14,7 +14,7 @@
#define F_RAGSOC 301 #define F_RAGSOC 301
#define F_INDCF 302 #define F_INDCF 302
#define F_CIVCF 303 #define F_CIVCF 303
#define F_NOME_VAL 304 #define F_RAGSOCSP 304
#define F_DESCODPAG 305 #define F_DESCODPAG 305
// I prossimi 5 campi devono essere consecutivi come numerazione // I prossimi 5 campi devono essere consecutivi come numerazione
// perchè faccio un ciclo per settarli // perchè faccio un ciclo per settarli
@ -61,5 +61,4 @@
#define F_STATOSP 346 #define F_STATOSP 346
#define F_DESSTATOSP 347 #define F_DESSTATOSP 347
#define F_DESLIST 348 #define F_DESLIST 348
#define F_RAGSOCSP 349
#endif // __VEUML1_H #endif // __VEUML1_H

View File

@ -1,28 +1,34 @@
#ifndef __SHEET_FIELDS #ifndef __SHEET_FIELDS
#define __SHEET_FIELDS #define __SHEET_FIELDS
#define FS_STATORIGA 101 #define FS_CODNUM 101
#define FS_TIPORIGA 102 #define FS_ANNO 102
#define FS_PROFRIGA 103 #define FS_PROVV 103
#define FS_CODMAG 104 #define FS_NDOC 104
#define FS_CODART 105 #define FS_STATORIGA 105
#define FS_DESCR 106 #define FS_TIPORIGA 106
#define FS_DESCLUNGA 107 #define FS_PROFRIGA 107
#define FS_PREZZO 108 #define FS_CODMAG 108
#define FS_UMQTA 109 #define FS_CODDEP 109
#define FS_QTA 110 #define FS_CODART 110
#define FS_QTAEVASA 111 #define FS_DESCR 111
#define FS_RIGAEVASA 112 #define FS_DESCLUNGA 112
#define FS_TARA 113 #define FS_PREZZO 113
#define FS_PNETTO 114 #define FS_UMQTA 114
#define FS_NCOLLI 115 #define FS_QTA 115
#define FS_DAEVADERE 116 #define FS_QTAEVASA 116
#define FS_SCONTO 117 #define FS_RIGAEVASA 117
#define FS_PERCPROV 118 #define FS_TARA 118
#define FS_IMPFISSO 119 #define FS_PNETTO 119
#define FS_IMPFISUN 120 #define FS_NCOLLI 120
#define FS_CODIVA 121 #define FS_DAEVADERE 121
#define FS_ADDIVA 122 #define FS_SCONTO 122
#define FS_ASPBENI 123 #define FS_PERCPROV 123
#define FS_IMPFISSO 124
#define FS_IMPFISUN 125
#define FS_CODIVA 126
#define FS_ADDIVA 127
#define FS_ASPBENI 128
#define FS_G1 129
#endif // __SHEET_FIELDS #endif // __SHEET_FIELDS