From 2a2192541b73e593368604c4eea0636c5255c792 Mon Sep 17 00:00:00 2001 From: matteo Date: Thu, 14 Sep 1995 13:59:52 +0000 Subject: [PATCH] Create le maschere e il programma per la configurazione delle vendite git-svn-id: svn://10.65.10.50/trunk@1825 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/tclifor.cpp | 447 +++++---- ve/tclifor.h | 142 +-- ve/totale.ini | 41 +- ve/ve0100.cpp | 2408 ++++++++++++++++++++++++----------------------- ve/ve0100.h | 1 + ve/ve0100c.cpp | 220 +++-- ve/ve0100c.h | 15 +- ve/ve0200.cpp | 182 ++-- ve/ve0200a.uml | 270 ++++++ ve/ve0200b.h | 12 + ve/ve0200b.uml | 509 ++++++++++ ve/ve0200c.uml | 130 +++ ve/ve0200d.uml | 630 +++++++++++++ ve/ve0200e.uml | 305 ++++++ ve/ve0300.cpp | 2440 ++++++++++++++++++++++++------------------------ ve/ve0300a.src | 5 +- ve/ve2100.cpp | 200 ++-- ve/ve2200.cpp | 536 +++++------ ve/ve2300.cpp | 506 +++++----- ve/veuml1.h | 127 +-- 20 files changed, 5617 insertions(+), 3509 deletions(-) create mode 100755 ve/ve0200a.uml create mode 100755 ve/ve0200b.h create mode 100755 ve/ve0200b.uml create mode 100755 ve/ve0200c.uml create mode 100755 ve/ve0200d.uml create mode 100755 ve/ve0200e.uml diff --git a/ve/tclifor.cpp b/ve/tclifor.cpp index c99c9c124..ab0d607eb 100755 --- a/ve/tclifor.cpp +++ b/ve/tclifor.cpp @@ -1,182 +1,265 @@ -#ifndef __TCLIFOR_H -#include "tclifor.h" -#endif - -#ifndef __VEUML1_H -#include "veuml1.h" -#endif - -#ifndef __VE1000O_H -#include "ve1000o.h" -#endif - -const TString& TData_picker::get( const TString& table, const TString& codtab, const TString& field ) -{ - if( table != _tablename ) - { - delete _table; - _table = new TTable( table ); - _tablename = table; - } - if( codtab != _table->curr( ).get( "CODTAB" ) ) - { - _table->zero( ); - _table->put( "CODTAB", codtab ); - _table->read( ); - } - return _table->get( field ); -}; - -void TData_picker::set( TMask& m, const int mskfield, const TString& value ) -{ - if( present( m, mskfield ) ) - { - m.set( mskfield, value, TRUE ); - m.field( mskfield ).check( ); - } -}; - -const TString& TData_picker::get( const int file, const TString& fieldname ) -{ - return lfile( file ).get( fieldname ); -} - -int TData_picker::get_int( const int file, const TString& fieldname ) -{ - return lfile( file ).get_int( fieldname ); -} - -long TData_picker::get_long( const int file, const TString& fieldname ) -{ - return lfile( file ).get_long( fieldname ); -} - -bool TData_picker::get_bool( const int file, const TString& fieldname ) -{ - return lfile( file ).get_bool( fieldname ); -} - -int TCliFor::write_occas( ) -{ - if( !occasionale( ) ) - return NOERR; - TRelation occas( LF_OCCAS ); - occas_mask( ).autosave( &occas ); - return occas.write( ); -} - -TCliFor::TCliFor( ) : TData_picker( LF_CLIFO ), _occas_mask( "ve1000o" ) -{ - _occas_mask.set_handler( O_CODICE, occas_code_handler ); - add( LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF" ); -} - -void TCliFor::load( const char tipocf, const long codcf, const TString& ocfpi ) -{ - _tipocf = tipocf; - _codcf = codcf; - zero( ); - curr( ).put( "TIPOCF", tipocf ); - curr( ).put( "CODCF", codcf ); - lfile( ).setkey( 1 ); - if( read( ) != NOERR ) - yesnofatal_box( "Il %s %d non è stato trovato!", tipocf == 'C'?"cliente":"fornitore", codcf ); - _occas = curr().get_bool( "OCCAS" ); - if ( occasionale( ) ) - { - TRelation occrel( LF_OCCAS ); - occrel.curr( ).zero( ); - occrel.curr( ).put( "CFPI", ocfpi ); - occrel.read( ); - occas_mask( ).autoload( &occrel ); - } -} - -void TCliForVendite::update_mask( TMask& m, bool onload ) -{ - // Setta i campi che appartengono al file LF_CLIFO - bool occas = occasionale( ); - show( m, F_OCFPI, occas ); - show( m, F_OCCASEDIT, occas ); - // In forse per l'Occasionale, sicuri per il Normale - m.show( F_COFI, !occas ); - m.show( F_STATOPAIVA, !occas ); - m.show( F_PAIVA, !occas ); - set( m, F_RAGSOC, LF_CLIFO, "RAGSOC" ); - if( !onload ) - { - set( m, F_CODVAL, LF_CLIFO, "CODVAL" ); - set( m, F_CODLIN, LF_CLIFO, "CODLIN" ); - set( m, F_CODPAG, LF_CLIFO, "CODPAG" ); - // Questo nonb va qua, ma nella read - set( m, F_DATAINSC, m.get( F_DATADOC ) ); - set( m, F_CODABIA, LF_CLIFO, "CODABI" ); - set( m, F_CODCABA, LF_CLIFO, "CODCAB" ); - // Setta i campi che appartengono al file LF_CFVEN - set( m, F_CODABIP, LF_CFVEN, "CODABIPR" ); - set( m, F_CODCABP, LF_CFVEN, "CODCABPR" ); - set( m, F_RAGGR, LF_CFVEN, "RAGGDOC" ); - set( m, F_CODINDSP, LF_CFVEN, "CODINDSP" ); - set( m, F_CODAG, LF_CFVEN, "CODAG" ); - set( m, F_CODSPMEZZO, LF_CFVEN, "CODSPMEZZO" ); - set( m, F_CODPORTO, LF_CFVEN, "CODPORTO" ); - set( m, F_CODNOTESP1, LF_CFVEN, "CODNOTESP1" ); - set( m, F_CODNOTESP2, LF_CFVEN, "CODNOTESP2" ); - set( m, F_CODVETT1, LF_CFVEN, "CODVETT1" ); - set( m, F_CODVETT2, LF_CFVEN, "CODVETT2" ); - set( m, F_CODVETT3, LF_CFVEN, "CODVETT3" ); - set( m, F_SPESEINC, LF_CFVEN, "ADDSPINC" ); - set( m, F_ADDBRB, LF_CFVEN, "ADDBOLLIRB" ); - set( m, F_ADDBTR, LF_CFVEN, "ADDBOLLITR" ); - } - if ( occasionale ( ) ) - { - // set( m, F_COFI, "" ); - // set( m, F_PAIVA, "" ); - set( m, F_OCFPI, occas_mask( ).get( O_CODICE ) ); - set( m, F_RAGSOC, occas_mask( ).get( O_RAGSOC ) ); - set( m, F_INDCF, occas_mask( ).get( O_INDIRIZZO ) ); - set( m, F_CIVCF, occas_mask( ).get( O_NUMERO ) ); - set( m, F_CAPCF, occas_mask( ).get( O_CAP ) ); - set( m, F_COMCF, occas_mask( ).get( O_COMUNE ) ); - set( m, F_STATOCF, occas_mask( ).get( O_STATO ) ); - } - else - { - set( m, F_COFI, LF_CLIFO, "COMCF" ); - set( m, F_INDCF, LF_CLIFO, "INDCF" ); - set( m, F_CIVCF, LF_CLIFO, "CIVCF" ); - set( m, F_STATOPAIVA, LF_CLIFO, "STATOPAIV" ); - set( m, F_PAIVA, LF_CLIFO, "PAIV" ); - set( m, F_LOCALITACF, LF_CLIFO, "LOCALITACF" ); - set( m, F_CAPCF, LF_CLIFO, "CAPCF" ); - set( m, F_COMCF, LF_CLIFO, "COMCF" ); - set( m, F_STATOCF, LF_CLIFO, "STATOCF" ); - } -} - -void TCliFor::edita_occasionale( ) -{ - CHECK( occasionale( ), "Impossibile editare come occasionale un cliente non occasionale!" ); - _occas_mask.run( ); -}; - -bool TCliFor::occas_code_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB) - { - const char* code = f.get(); - if (*code) - { - TRelation occas(LF_OCCAS); - occas.lfile().put("CFPI", code); - if (occas.read(_isequal) == NOERR) - { - f.mask().autoload(&occas); - f.mask().send_key(K_TAB, O_COMUNE); // Forza decodifica comuni - f.mask().send_key(K_TAB, O_COMUNENAS); - } - } - } - return TRUE; -} +#ifndef __TCLIFOR_H +#include "tclifor.h" +#endif + +#ifndef __VEUML1_H +#include "veuml1.h" +#endif + +#ifndef __VE1000O_H +#include "ve1000o.h" +#endif + +const TString& TData_picker::get( const TString& table, const TString& codtab, const TString& field ) +{ + if( table != _tablename ) + { + delete _table; + _table = new TTable( table ); + _tablename = table; + } + if( codtab != _table->curr( ).get( "CODTAB" ) ) + { + _table->zero( ); + _table->put( "CODTAB", codtab ); + _table->read( ); + } + return _table->get( field ); +}; + +const TString& TData_picker::get( const int file, const TString& fieldname ) +{ + return lfile( file ).get( fieldname ); +} + +int TData_picker::get_int( const int file, const TString& fieldname ) +{ + return lfile( file ).get_int( fieldname ); +} + +long TData_picker::get_long( const int file, const TString& fieldname ) +{ + return lfile( file ).get_long( fieldname ); +} + +bool TData_picker::get_bool( const int file, const TString& fieldname ) +{ + return lfile( file ).get_bool( fieldname ); +} + +int TCliFor::write_occas( ) +{ + if( !occasionale( ) ) + return NOERR; + TRelation occas( LF_OCCAS ); + occas_mask( ).autosave( &occas ); + return occas.write( ); +} + +TCliFor::TCliFor( ) : TData_picker( LF_CLIFO ), _occas_mask( "ve1000o" ) +{ + _occas_mask.set_handler( O_CODICE, occas_code_handler ); + add( LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF" ); +} + +void TCliFor::load( const char tipocf, const long codcf, const TString& ocfpi ) +{ + _tipocf = tipocf; + _codcf = codcf; + zero( ); + curr( ).put( "TIPOCF", tipocf ); + curr( ).put( "CODCF", codcf ); + lfile( ).setkey( 1 ); + if( read( ) != NOERR ) + yesnofatal_box( "Il %s %d non è stato trovato!", tipocf == 'C'?"cliente":"fornitore", codcf ); + _occas = curr().get_bool( "OCCAS" ); + if ( occasionale( ) ) + { + TRelation occrel( LF_OCCAS ); + occrel.curr( ).zero( ); + occrel.curr( ).put( "CFPI", ocfpi ); + occrel.read( ); + occas_mask( ).autoload( &occrel ); + } +} + +void TCliForVendite::update_mask( TMask_vendite& m, bool onload ) +{ + TString16 stato; + + // Setta i campi che appartengono al file LF_CLIFO + bool occas = occasionale( ); + m.show( F_OCFPI, occas ); + m.show( F_OCCASEDIT, occas ); + // In forse per l'Occasionale, sicuri per il Normale + m.show( F_COFI, !occas ); + m.show( F_STATOPAIVA, !occas ); + m.show( F_PAIVA, !occas ); + set( m, F_RAGSOC, LF_CLIFO, "RAGSOC" ); + if( !onload ) + { + set( m, F_CODVAL, LF_CLIFO, "CODVAL" ); + set( m, F_CODLIN, LF_CLIFO, "CODLIN" ); + set( m, F_CODPAG, LF_CLIFO, "CODPAG" ); + set( m, F_CODABIA, LF_CLIFO, "CODABI" ); + set( m, F_CODCABA, LF_CLIFO, "CODCAB" ); + // Setta i campi che appartengono al file LF_CFVEN + set( m, F_CODABIP, LF_CFVEN, "CODABIPR" ); + set( m, F_CODCABP, LF_CFVEN, "CODCABPR" ); + set( m, F_RAGGR, LF_CFVEN, "RAGGDOC" ); + set( m, F_CODINDSP, LF_CFVEN, "CODINDSP" ); + set( m, F_CODAG, LF_CFVEN, "CODAG" ); + set( m, F_CODSPMEZZO, LF_CFVEN, "CODSPMEZZO" ); + set( m, F_CODPORTO, LF_CFVEN, "CODPORTO" ); + set( m, F_CODNOTESP1, LF_CFVEN, "CODNOTESP1" ); + set( m, F_CODNOTESP2, LF_CFVEN, "CODNOTESP2" ); + set( m, F_CODVETT1, LF_CFVEN, "CODVETT1" ); + set( m, F_CODVETT2, LF_CFVEN, "CODVETT2" ); + set( m, F_CODVETT3, LF_CFVEN, "CODVETT3" ); + set( m, F_SPESEINC, LF_CFVEN, "ADDSPINC" ); + set( m, F_ADDBRB, LF_CFVEN, "ADDBOLLIRB" ); + set( m, F_ADDBTR, LF_CFVEN, "ADDBOLLITR" ); + } + if ( occasionale ( ) ) + { + m.set( F_COFI, "" ); + m.set( F_PAIVA, "" ); + m.set( F_OCFPI, occas_mask( ).get( O_CODICE ) ); + m.set( F_RAGSOC, occas_mask( ).get( O_RAGSOC ) ); + m.set( F_INDCF, occas_mask( ).get( O_INDIRIZZO ) ); + m.set( F_CIVCF, occas_mask( ).get( O_NUMERO ) ); + m.set( F_CAPCF, occas_mask( ).get( O_CAP ) ); + m.set( F_COMCF, occas_mask( ).get( O_COMUNE ) ); + m.set( F_STATOCF, stato = occas_mask( ).get( O_STATO ) ); + } + else + { + set( m, F_COFI, LF_CLIFO, "COFI" ); + set( m, F_INDCF, LF_CLIFO, "INDCF" ); + set( m, F_CIVCF, LF_CLIFO, "CIVCF" ); + set( m, F_STATOPAIVA, LF_CLIFO, "STATOPAIV" ); + set( m, F_PAIVA, LF_CLIFO, "PAIV" ); + set( m, F_LOCALITACF, LF_CLIFO, "LOCALITACF" ); + set( m, F_CAPCF, LF_CLIFO, "CAPCF" ); + set( m, F_COMCF, LF_CLIFO, "COMCF" ); + stato = get( LF_CLIFO, "STATOCF" ); + m.set( F_STATOCF, stato ); + } + if ( !stato.blank( ) ) + m.set( F_DESSTATOCF, get( "%STA", stato, "S0" ) ); + TString16 tmpstr( m.get( F_CODPAG ) ); + if( !tmpstr.blank( ) ) + { + m.field( F_CODPAG ).on_hit( ); + m.field( F_CODPAG ).check( ); + } + tmpstr = m.get( F_CODLIN ); + if( !tmpstr.blank( ) ) + m.field( F_CODLIN ).check( ); + imposta_dati_comune( m ); + imposta_indirizzo_spedizione( m ); +} + +void TCliFor::edita_occasionale( ) +{ + CHECK( occasionale( ), "Impossibile editare come occasionale un cliente non occasionale!" ); + _occas_mask.run( ); +}; + +bool TCliFor::occas_code_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB) + { + const char* code = f.get(); + if (*code) + { + TRelation occas(LF_OCCAS); + occas.lfile().put("CFPI", code); + if (occas.read(_isequal) == NOERR) + { + f.mask().autoload(&occas); + f.mask().send_key(K_TAB, O_COMUNE); // Forza decodifica comuni + f.mask().send_key(K_TAB, O_COMUNENAS); + } + } + } + return TRUE; +} + +void TCliForVendite::imposta_dati_comune( TMask_vendite& m ) +{ + TLocalisamfile comuni(LF_COMUNI); + comuni.setkey( 1 ); + if( occasionale( ) ) + { + comuni.put( "COM", occas_mask( ).get( O_COMUNE )); + comuni.put( "STATO", occas_mask( ).get( O_STATO ) ); + } + else + { + comuni.put( "COM", get( LF_CLIFO, "COMCF" )); + comuni.put( "STATO", get( LF_CLIFO, "STATOCF" ) ); + } + comuni.read( ); + m.set( F_DENCOM, comuni.get( "DENCOM" ) ); + m.set( F_PROVCOM, comuni.get( "PROVCOM" ) ); +} + +void TCliForVendite::imposta_indirizzo_spedizione( TMask_vendite& m ) +{ + TString16 stato; + if( occasionale( ) ) + { + m.set( F_CODINDSP, "" ); + m.disable( F_CODINDSP ); + m.set( F_RAGSOCSP, occas_mask( ).get( O_RAGSOC ) ); + m.set( F_INDSP, occas_mask( ).get( O_INDIRIZZO ) ); + m.set( F_CIVSP, occas_mask( ).get( O_NUMERO ) ); + // Sugli occasionali non c'è la località + m.set( F_LOCALITASP, "" ); + m.set( F_CAPSP, occas_mask( ).get( O_CAP ) ); + m.set( F_COMSP, occas_mask( ).get( O_COMUNE ) ); + m.set( F_STATOSP, stato = occas_mask( ).get( O_STATO ) ); + } + else + { + TString16 codindsp( m.get( F_CODINDSP ) ); + if( codindsp.blank( ) ) + { + m.set( F_RAGSOCSP, "" ); + m.set( F_INDSP, "" ); + m.set( F_CIVSP, "" ); + m.set( F_LOCALITASP, "" ); + m.set( F_CAPSP, "" ); + m.set( F_COMSP, "" ); + m.set( F_STATOSP, "" ); + return; + } + else + { + TLocalisamfile indsped( LF_INDSP ); + indsped.setkey( 1 ); + indsped.put( "TIPOCF", _tipocf ); + indsped.put( "CODCF", _codcf ); + indsped.put( "CODIND", atoi( codindsp ) ); + if( indsped.read( ) != NOERR ) + yesnofatal_box( "Indirizzo di spedizione non trovato!" ); + m.set( F_RAGSOCSP, indsped.get( "RAGSOC" ) ); + m.set( F_INDSP, indsped.get( "INDIR" ) ); + m.set( F_CIVSP, indsped.get( "CIV" ) ); + m.set( F_LOCALITASP, indsped.get( "LOCALITA" ) ); + m.set( F_CAPSP, indsped.get( "CAP" ) ); + m.set( F_COMSP, indsped.get( "COM" ) ); + m.set( F_STATOSP, stato = indsped.get( "STATO" ) ); + } + } + if ( !stato.blank( ) ) + m.set( F_DESSTATOSP, get( "%STA", stato, "S0" ) ); + TLocalisamfile comuni(LF_COMUNI); + comuni.setkey( 1 ); + comuni.put( "COM", m.get( F_COMSP ) ); + comuni.put( "STATO", m.get( F_STATOSP ) ); + comuni.read( ); + m.set( F_DENCOMSP, comuni.get( "DENCOM" ) ); + m.set( F_PROVCOMSP, comuni.get( "PROVCOM" ) ); +} \ No newline at end of file diff --git a/ve/tclifor.h b/ve/tclifor.h index 51919a0bb..27ea82539 100755 --- a/ve/tclifor.h +++ b/ve/tclifor.h @@ -1,70 +1,72 @@ -#ifndef __TCLIFOR_H -#define __TCLIFOR_H - -#ifndef __CHECKS_H -#include -#endif - -#ifndef __RELATION_H -#include -#endif - -#ifndef __TABUTIL_H -#include -#endif - - -#ifndef __MASK_H -#include -#endif - -class TData_picker : public TRelation -{ -private: - - TTable* _table; - TString16 _tablename; - -public: - TData_picker( const int mainfile ) : TRelation ( mainfile ) { } - const TString& get( const TString& table, const TString& codtab, const TString& field ); - const TString& get( const int file, const TString& fieldname ); - int get_int( const int file, const TString& fieldname ); - long get_long( const int file, const TString& fieldname ); - bool get_bool( const int file, const TString& fieldname ); - bool present( TMask& m, const int mskfield ){ return ( m.id2pos( mskfield ) >= 0 ); } - void set( TMask& m, const int mskfield, const int file, const TString& filefield ){ set( m, mskfield, get( file, filefield ) ); }; - void set( TMask& m, const int mskfield, const TString& value ); - void show( TMask& m, const int mskfield, const bool show = TRUE ){ if( present( m, mskfield ) ) m.show( mskfield, show ); }; - void hide( TMask& m, const int mskfield ){ show( m, mskfield, FALSE ); }; -}; - -class TCliFor : public TData_picker -{ -private: - - char _tipocf; - long _codcf; - bool _occas; - TMask _occas_mask; - -public: - - TCliFor( ); - void load( const char tipocf, const long codcf, const TString& ocfpi ); - bool occasionale( ){ return get_bool( LF_CLIFO, "OCCAS" ); }; -TMask& occas_mask( ){ return _occas_mask; }; - static bool occas_code_handler(TMask_field& f, KEY key); - int write_occas( ); - void edita_occasionale( ); - -}; - -class TCliForVendite : public TCliFor -{ -public: - - void update_mask( TMask& m, bool onload = FALSE ); -}; - -#endif +#ifndef __TCLIFOR_H +#define __TCLIFOR_H + +#ifndef __CHECKS_H +#include +#endif + +#ifndef __RELATION_H +#include +#endif + +#ifndef __TABUTIL_H +#include +#endif + + +#ifndef __TMASKVEN_H +#include "tmaskven.h" +#endif + +class TData_picker : public TRelation +{ +private: + + TTable* _table; + TString16 _tablename; + +public: + TData_picker( const int mainfile ) : TRelation ( mainfile ) { } + const TString& get( const TString& table, const TString& codtab, const TString& field ); + const TString& get( const int file, const TString& fieldname ); + int get_int( const int file, const TString& fieldname ); + long get_long( const int file, const TString& fieldname ); + bool get_bool( const int file, const TString& fieldname ); + void set( TMask_vendite& m, const int mskfield, const int file, const TString& filefield ){ m.set( mskfield, get( file, filefield ) ); }; +}; + +class TCliFor : public TData_picker +{ + private: + + bool _occas; + TMask _occas_mask; + + protected: + + char _tipocf; + long _codcf; + + public: + + TCliFor( ); + void load( const char tipocf, const long codcf, const TString& ocfpi ); + bool occasionale( ){ return get_bool( LF_CLIFO, "OCCAS" ); }; + TMask& occas_mask( ){ return _occas_mask; }; + static bool occas_code_handler(TMask_field& f, KEY key); + int write_occas( ); + void edita_occasionale( ); +}; + +class TCliForVendite : public TCliFor +{ + + public: + + void update_mask( TMask_vendite& m, bool onload = FALSE ); + void imposta_dati_comune( TMask_vendite& m ); + void imposta_indirizzo_spedizione( TMask_vendite& m ); + +}; + +#endif diff --git a/ve/totale.ini b/ve/totale.ini index bb3c34b86..63d89d175 100755 --- a/ve/totale.ini +++ b/ve/totale.ini @@ -73,7 +73,7 @@ TIPOCF = 2 CODCF = 3 RAGSOC = 2 OCCAS = 0 -OCFPI = 0 +OCFPI = 1 COFI = 1 STATOPAIV = 1 PAIVA = 1 @@ -177,6 +177,7 @@ DESUMPNETTO = 2 DESUMTARA = 2 DESCRMAG1 = 2 DESCRMAG2 = 2 +OCCASEDIT = 2 [SHEET] NCOLS=4 @@ -208,6 +209,23 @@ NHANDLER=0 [PROFILOGRUPPO] = +1000 = 0 +2000 = 0 +1400 = 0 +2400 = 0 +1800 = 0 +2800 = +1100 = 0 +2100 = 0 +1500 = 0 +2500 = 0 +1900 = 0 +2900 = +1200 = 0 +2200 = 0 +29 = +1600 = 0 +2600 = 0 101 = 0 100 = 2 200 = 2 @@ -215,24 +233,11 @@ NHANDLER=0 400 = 2 500 = 2 600 = 2 +1300 = 0 700 = 2 +2300 = 0 800 = 2 900 = 2 -1000 = 2 -1100 = 2 -1200 = 2 -1300 = 2 -1400 = 2 -1500 = 2 -1600 = 2 -1700 = 2 -1800 = 2 -1900 = 2 -2000 = 2 -2100 = 2 -2200 = 2 -2300 = 2 -2400 = 2 -2500 = 2 -2600 = 2 +1700 = 0 +2700 = diff --git a/ve/ve0100.cpp b/ve/ve0100.cpp index b7d7923f0..593f3c2fa 100755 --- a/ve/ve0100.cpp +++ b/ve/ve0100.cpp @@ -1,1172 +1,1236 @@ -#include - -#ifndef __CHECKS_H -#include -#endif - -#ifndef __TABUTIL_H -#include -#endif - -#ifndef __BRWAPP_H -#include -#endif - -#ifndef __RELAPP_H -#include -#endif - -#ifndef __CONFIG_H -#include -#endif - -#ifndef __LFFILES_H -#include -#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 -#endif - -#ifndef __REAL_H -#include -#endif - -#ifndef __MSKSHEET_H -#include -#endif - -#ifndef __VE0100_H -#include "ve0100.h" -#endif - -#ifndef __VE0100C_H -#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 - -// 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* _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 liente o un 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 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( ); } - -int TMotore_application::user_function( int index ) -{ - switch( index ) - { - case 1: - break; - default: - yesnofatal_box( "Chiamata ad una procedura utente non definita: %d", index ); - return FALSE; - break; - }; - return NOERR; -}; - -// Funzione che dato il profilo di riga ottiene la maschera -// 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 ) -{ - static TMask* m; - - if ( destroy ) - { - delete m; - return( NULL ); - } - else - { - TFilename nome_proriga( fullmask.get( 103 ) ); - nome_proriga.ext( "ini" ); - TConfig proriga( nome_proriga ); - m = new TMask( proriga.get( "MSK", "MAIN" ) ); - int numhandler = proriga.get_int( "NHANDLER", "HANDLERS" ); - for( int i = 1; i <= numhandler; i ++ ) - { - TString chiave; - chiave.format( "%d", i ); - TToken_string riga = proriga.get( chiave, "HANDLERS" ); - app().user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ), m ); - }; - return( m ); - } -} - -real TMotore_application::user_row_calculate( TRectype& r, int index ) -{ - switch( index ) - { - 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 ) -{ - if( !m ) - m = &edit_mask( ); - switch( index ) - { - case 1: - m->set_handler( fieldid, ora_hndl ); - break; - case 2: - m->set_handler( fieldid, codcli_hndl ); - break; - case 3: - m->set_handler( fieldid, dummy_hndl ); - break; - default: - CHECK( FALSE, "Tentativo di installare un handler non definito" ); - break; - } -}; - -bool TMotore_application::ss_handler( TSheet_field& ss, int r, KEY key ) -{ - if ( key == K_SPACE ) // Inizio modifica - { - app().azzera_piedi( TRUE ); - TRelation rdoc( LF_RIGHEDOC ); - ss.sheet_mask( ).autosave( &rdoc ); - // Mi calcolo nei piedi temporanei la riga - app().calcola_riga( rdoc.curr( ), TRUE ); - } - if ( key == K_INS ) // Inserimento - { - TMask& m = *app( )._msk1; - TTable tabtr( "%TRI" ); - tabtr.zero( ); - tabtr.put( "CODTAB", m.get( F_LBTIPORIGA ) ); - tabtr.read( ); - TToken_string& riga = ss.row( r ); - riga.add( 1, 0 ); - riga.add( m.get( F_LBTIPORIGA ), 1 ); - riga.add( tabtr.get( "S4" ), 2 ); - return TRUE; - } - if ( key == K_CTRL + K_INS ) // Dopo inserimento - { - TMask& m = *app( )._msk1; - 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 ); - return TRUE; - } - if ( key == K_DEL ) // Cancellazione - { - // Sottraggo la riga appena cancellata ai totalizzatori - app().sottrai_piedi( ); - app().carica_piedi( ); - } - if ( key == K_ENTER ) // Modifica - { - app().sottrai_piedi( ); - TRelation rdoc( LF_RIGHEDOC ); - ss.sheet_mask( ).autosave( &rdoc ); - // Sommo la riga ai totalizzatori - app().calcola_riga( rdoc.curr( ) ); - app().sottrai_piedi( ); - } - return TRUE; -}; - -bool TMotore_application::num_handler( TMask_field& f, KEY key ) -{ - // Ottengo la maschera - TMask& m = f.mask( ); - - if (key == K_TAB && m.is_running( ) ) - { - // Se la numerazione non è specificata, - const TString16 value( m.get( F_CODNUM ) ); - if ( value.blank( ) ) - { - // Pulisce la descrizione - m.set(F_DESNUM, "" ); - // Pulisce i tipi di documento consentiti - m.set(F_TIPIDOCS, "" ); - // Pulisce il tipo di documento - m.set(F_TIPODOC, "" ); - return TRUE; - } - // Apro la tabella numerazioni - TTable tabnum( "NUM" ); - tabnum.zero( ); - tabnum.put( "CODTAB", value ); - if( tabnum.read( ) == NOERR ) - { - // Copio la descrizione della numerazione - m.set(F_DESNUM, tabnum.get("S0") ); - // Copio i tipi di documento validi per la numerazione - const TString tipidocs( tabnum.get("S2") ); - m.set(F_TIPIDOCS, tipidocs ); - // Propone il primo tipo di documento come default - m.set(F_TIPODOC, tipidocs.left( 4 ) ); - // m.field( F_TIPODOC ).check( ); - m.send_key( K_TAB, F_TIPODOC ); - - // Se per questa numerazione è abilitata le numerazione provvisoria - if ( tabnum.get_bool ( "B0" ) ) - { - // Setta di default la numerazione provvisoria - m.set( F_PROVV, "P" ); - // Abilita il campo per la selezione della numerazione - m.enable( F_PROVV ); - } - else // Altrimenti ... - { - // Setta la numerazione a definitiva - m.set( F_PROVV, "D" ); - // Disabilita il campo per la selezione della numerazione - m.disable( F_PROVV ); - }; - return TRUE; - } - message_box( "Numerazione non valida!" ); - return FALSE; - } - if (key == K_ENTER && m.is_running( ) ) - { // Se la numerazione non è specificata, - const TString16 value( m.get( F_CODNUM ) ); - if ( value.blank( ) ) - { - message_box( "Occorre una numerazione per inserire un documento!" ); - m.first_focus( F_NDOC ); - return FALSE; - } - } - return TRUE; -} - -bool TMotore_application::occas_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE && f.mask( ).is_running( ) ) - { - TMask& om = app( ).clifo( ). occas_mask( ); - om.run( ); - f.set_focus( ); - } - return TRUE; -} - - -bool TMotore_application::tip_handler(TMask_field& f, KEY key) -{ - TMask& m = f.mask( ); - if (key == K_TAB && m.is_running( ) ) - { - const TString16 value( m.get( F_TIPODOC ) ); - if ( value.blank( ) ) - { - // Pulisce il profilo - m.set(F_PROFILO, "" ); - return TRUE; - } - TString tipi_consentiti( m.get( F_TIPIDOCS ) ); - TString16 tipo( f.get( ) ); - tipo.trim( ); - bool tipo_valido = FALSE; - for ( int i = 0; i < 10; i ++ ) - { - TString16 curtipo( tipi_consentiti.mid( i * 4, 4 ) ); - curtipo.trim( ); - if( curtipo == tipo ) - { - tipo_valido = TRUE; - break; - } - } - if( ! tipo_valido ) - { - message_box( "Tipo non valido per la numerazione selezionata!" ); - f.set( "" ); - return FALSE; - } - TTable tabtip( "%TIP" ); - tabtip.read( ); - m.set(F_DESTIPODOC, tabtip.get("S0") ); - m.set(F_PROFILO, tabtip.get("S4") ); - } - if (key == K_ENTER && m.is_running( ) ) - { TString tipo( f.get( ) ); - if ( ! tipo.blank( ) ) - { TTable tabtip( "%TIP" ); - tabtip.read( ); - m.set(F_PROFILO, tabtip.get("S4") ); - } - else - { message_box( "Occorre un tipo documento per inserire un documento!" ); - m.first_focus( F_TIPODOC ); - return FALSE; - } - } - return TRUE; -} - -bool TMotore_application::ndoc_handler(TMask_field& f, KEY key) -{ - TMask& m = f.mask( ); - if (key == K_TAB && m.is_running( ) ) - { TLocalisamfile& doc = app( ).rel( ).lfile( ); - doc.zero( ); - doc.put("CODNUM", m.get( F_CODNUM ) ); - doc.put("PROVV", m.get( F_PROVV ) ); - doc.put("ANNO", m.get( F_ANNO ) ); - doc.put("NDOC", f.get( ) ); - if ( doc.read( ) == NOERR ) - { m.set(F_TIPODOC, doc.get( "TIPODOC" ) ); - m.set(F_STATO, doc.get( "STATO" ) ); - TTable tabtip( "%TIP" ); - tabtip.put( "CODTAB", doc.get( "TIPODOC" ) ); - tabtip.read( ); - m.set(F_PROFILO, tabtip.get("S4") ); - m.stop_run( K_AUTO_ENTER ); - } - } - return TRUE; -} - -bool TMotore_application::clifo_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB && f.active()) - { - TMask& m = f.mask(); - - const char cf = app().tipocf(); - TLocalisamfile& clifo = ((TEdit_field&)f).browse()->cursor()->file(); - - if (clifo.get_char("TIPOCF") != cf || clifo.get("CODCF") != f.get()) - { - clifo.setkey(1); - clifo.put("TIPOCF", cf); - clifo.put("CODCF", f.get()); - clifo.read(); - CHECK(clifo.good(), "Impossibile ritrovare il clifo" ); - } - CHECKD(f.is_edit(), "Can't check suspension of a non edit-field ", f.dlg()); - const TEdit_field& c = (const TEdit_field&)f; - const TBrowse* b = c.browse(); - CHECKD(b, "Can't check suspension of a edit-field without a USE ", f.dlg()); - const TLocalisamfile& i = b->cursor()->file(); - // Tabella File - const char* sf = i.tab() ? "B2" : "SOSPESO"; - const bool suspended = i.get_bool(sf); - if (suspended) - { - sf = f.get(); - return f.error_box("Il codice '%s' e' sospeso e non puo' essere utilizzato", sf); - } - /* - if (!m.is_running() || f.dirty()) - { - // Equichecazzociva? - - } - */ - // Disabilitazioni varie, ma le demando all'oggetto cliente - if (f.focusdirty()) - { - app().clifo( ).load( cf, atol( f.get( ) ), "" ); - app().clifo( ).update_mask( m ); - if ( app( ).clifo( ).occasionale( ) && app( ).clifo( ).occas_mask( ).get(O_CODICE).empty( ) ) - m.send_key(K_SPACE, F_OCCASEDIT); // Lancia maschera occasionali - } - } - 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( ) -{ - TToken_string s( pro( ).get( "PROGPIEDE", "MAIN" ) ); - int i = s.get_int( ); - int j = 0; - while( i != 0 ) - { - real strpiede( _piedi[ i ] ); - edit_mask( ).set( BASE_PIEDE + ( ++j ), strpiede.stringa( 15 ) ); - i = s.get_int( ); - } -} - -void TMotore_application::somma_piedi( ) -{ - for ( int i = 0; i < NPIEDI; i++ ) - _piedi[ i ] += _piedi_temp[ i ]; -} - -void TMotore_application::sottrai_piedi( ) -{ - for ( int i = 0; i < NPIEDI; i++ ) - _piedi[ i ] -= _piedi_temp[ i ]; -} - -bool TMotore_application::changing_mask(int mode) -{ - static int lastmode = NO_MODE; - - const bool change = ( mode != lastmode ); - lastmode = mode; - return change; - -} - -void TMotore_application::configura_sheet( TSheet_field& sheet, TConfig& config ) -{ - int ncols = config.get_int( "NCOLS", "SHEET" ); - for( int i = 1; i <= ncols; i ++ ) - { - TString col; - col.format( "%d", i ); - TToken_string sheet_col( config.get( col, "SHEET" ) ); - const TString descr( sheet_col.get( 1 ) ); - if ( ! descr.blank( ) ) - sheet.set_column_header( i, descr ); - TString size( sheet_col.get( 2 ) ); - if ( ! size.blank( ) ) - sheet.set_column_width( i, sheet_col.get_int( 2 ) ); - int coltomove = sheet_col.get_int( 0 ) - 1; - sheet.move_column( coltomove, i ); - }; - for ( int j = MAX_COLUMNS; j >= i - 1; j -- ) - sheet.delete_column( j ); -}; - -void TMotore_application::get_edit_mask( void ) -{ - TFilename fn; - - fn = query_mask( ).get( F_PROFILO ); - // query_mask( ).enable(DLG_NEWREC); - fn.ext( "ini" ); - fn.upper( ); - if ( _pro ) - { - if( (*_proname) == fn ) - return; - delete _pro; - }; - _pro = new TConfig( fn ); - _proname = new TFilename( fn ); - _proname->upper( ); - if ( _msk1 ) delete _msk1; - _msk1 = new TMask( pro( ).get( "MSKFILE", "MAIN" ) ); - // edit_mask( ).set( F_PROFILO, query_mask( ).get( F_PROFILO ) ); - edit_mask( ).set( F_DESNUM, query_mask( ).get( F_DESNUM ) ); - _sheet = &(TSheet_field &)edit_mask( ).field(F_SHEET); - sheet( ).set_notify( ss_handler ); - TString tipocf( app( ).pro( ).get( "TIPOCF", "MAIN" ) ); - app( ).tipocf( tipocf[ 0 ] ); - configura_sheet( *_sheet, *_pro ); - TList_field& listbox = ( TList_field& ) _msk1->field( F_LBTIPORIGA ); - const int numtr = app( ).pro( ).get_int( "NTIPIRIGA", "RIGHE" ); - TTable tabtr( "%TRI" ); - TToken_string keys( "" ), descrs( "" ); - for ( int i = 1; i <= numtr; i ++ ) - { - TString chiave; - TToken_string item; - chiave.format( "%d", i ); - tabtr.zero( ); - TString tiporiga( app( ).pro( ).get( chiave, "RIGHE" ) ); - tabtr.put( "CODTAB", tiporiga ); - if ( tabtr.read( ) == NOERR ) - { - keys.add( tabtr.get( "CODTAB" ) ); - descrs.add( tabtr.get( "S0" ) ); - } - else - { - yesnofatal_box( "Inserito un tipo di riga non valido (%s)", (const char *)tiporiga ); - } - } - listbox.replace_items( keys, descrs ); - sheet( ).set_getmask( ss_getmask ); - int numhandler = pro( ).get_int( "NHANDLER", "HANDLERS" ); - for( i = 1; i <= numhandler; i ++ ) - { - TString chiave; - chiave.format( "%d", i ); - TToken_string riga = pro( ).get( chiave, "HANDLERS" ); - user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ) ); - }; -} - -TMask* TMotore_application::get_mask( int mode ) -{ - switch ( mode ) - { - case MODE_INS: - case MODE_MOD: - get_edit_mask( ); - edit_mask( ).enable( DLG_PRINT, ( mode == MODE_MOD ) ); - edit_mask( ).set_handler( F_OCCASEDIT, occas_handler ); - edit_mask( ).set_handler( F_CODCF, clifo_handler ); - return ( _msk1 ); - break; - default: - return _msk; - break; - }; -} - -void TMotore_application::set_descr(int i, const char * dfi) -{ - TToken_string& r = ss( ).row(i); - r.add(dfi, 0); -} - -void TMotore_application::carica_righe_libere(int from) -{ - if (from < 0) from = ss( ).items( ); - for (int i = from; i < 20; i++) - set_descr( i, "" ); - ss( ).force_update( ); -} - -const char* TMotore_application::get_next_key( ) -{ - TToken_string key; - TMask& m = curr_mask( ); - - TString value = m.get( F_CODNUM ); - if ( value.blank( ) ) - return NULL; - TTable tabnum( "NUM" ); - tabnum.zero( ); - tabnum.put( "CODTAB", value ); - if( tabnum.read( ) == NOERR ) - { - // Se per questa numerazione è abilitata le numerazione automatica - if( tabnum.get_bool ( "B1" ) ) - { - TLocalisamfile doc( LF_DOC ); - doc.zero( ); - doc.put( "CODNUM", value ); - doc.put( "ANNO", m.get( F_ANNO ) ); - doc.put( "NDOC", 9999999L ); - // Se per questa numerazione è abilitata le numerazione provvisoria - if( tabnum.get_bool ( "B0" ) ) - { - doc.put( "PROVV", "P" ); - } - else // Altrimenti ... - { - doc.put( "PROVV", "D" ); - }; - if( doc.read( _isgteq ) == NOERR ) - { - doc.prev( ); - } - long num = ( value == doc.get( "CODNUM" ) ) ? doc.get_long( "NDOC" ) : 0; - key.format( "%d|%d", F_NDOC, num + 1 ); - return key; - } - }; - return NULL; -} - -int TMotore_application::read(TMask& m) -{ - azzera_piedi( ); - m.reset( ); - clifo( ).occas_mask( ).reset( ); - int err = TRelation_application::read( m ); - if ( err == NOERR ) - { - TString16 tipocf( m.get( F_TIPOCF ) ); - clifo( ).load( tipocf[ 0 ], m.get_int( F_CODCF ), rel( ).curr( ).get( "OCFPI" ) ); - clifo( ).update_mask( m, TRUE ); - TLocalisamfile& rdoc = rel( ).lfile(LF_RIGHEDOC); - TRectype r = rdoc.curr( ); - r.zero( ); - r.put( "CODNUM", m.get( F_CODNUM ) ); - r.put( "PROVV", m.get( F_PROVV ) ); - r.put( "ANNO", m.get( F_ANNO ) ); - r.put( "NDOC", m.get_long( F_NDOC ) ); - _righe_rec->read( r ); - TSheet_field& f = (TSheet_field&) m.field( F_SHEET ); - f.destroy( ); - int last = _righe_rec->last_row( ); - for( int i = 1; i <= last; i ++ ) - { - TRectype &rec = _righe_rec->row( i, TRUE ); - load_riga( f, i - 1, rec ); - calcola_riga( rec ); - }; - carica_piedi( ); - } - return err; -} - -bool TMotore_application::check_key( TLocalisamfile& rdoc, TString16 codnum, bool provv, TString16 anno, TString16 ndoc ) -{ - return ( ( rdoc.get("CODNUM") == codnum ) && - ( rdoc.get("NDOC") == ndoc ) && - ( rdoc.get("ANNO" ) == anno ) && - ( rdoc.get_bool( "PROVV" ) == provv ) ); -} - -int TMotore_application::write(const TMask& m) -{ - int err; - if ( esegui_procedura( OP_NUOVO ) != NOERR ) - return FALSE; - err = NOERR; // avanza_numero( m.get_bool( F_PROVV ) ); - if ( err == NOERR ) - { - err = app( ).clifo( ).write_occas( ); - } - - if ( err == NOERR ) - { - err = TRelation_application::write( m ); - if ( err == NOERR ) - { - TSheet_field& f = ss( ); - _righe_rec->destroy_rows( ); - if ( m.insert_mode( ) ) - _righe_rec->renum_key( "NRIGA", 1 ); - for ( int i = 0; i < f.items( ); i ++ ) - { - TToken_string& t = f.row( i ); - TRectype& rec = _righe_rec->row(i + 1, TRUE); - store_riga( f, i, rec ); - } - err = _righe_rec->write( ); - } - } - return err; -}; - -int TMotore_application::rewrite(const TMask& m) -{ - if ( ! valida_operazione( OP_MODIFICA ) ) - return FALSE; - int err = TRelation_application::rewrite( m ); - if ( err == NOERR ) - { - TSheet_field& f = ss( ); - _righe_rec->destroy_rows( ); - if ( m.insert_mode( ) ) - _righe_rec->renum_key( "NRIGA", 1 ); - for ( int i = 0; i < f.items( ); i ++ ) - { - TToken_string& t = f.row( i ); - TRectype& rec = _righe_rec->row(i + 1, TRUE); - store_riga( f, i, rec ); - } - err = _righe_rec->rewrite( ); - } - return err; -}; - - -// La funzione si trova in ve0100b - -long TMotore_application::prossimo_numero( bool provv ) -{ - long ret; - TTable tabnum( "NUM" ); - - tabnum.read( ); - if ( provv ) - ret = tabnum.get_long( "I0" ) + 1; - else - ret = tabnum.get_long( "I1" ) + 1; - return ( ret ); -}; - -int TMotore_application::avanza_numero( bool provv ) -{ - TTable tabnum( "NUM" ); - - int err = tabnum.read( ); - if ( err == NOERR ) - { - if ( provv ) - tabnum.put( "I0", tabnum.get_long( "I0" ) + 1 ); - else - tabnum.put( "I1", tabnum.get_long( "I1" ) + 1 ); - err = tabnum.rewrite( ); - } - return err; -}; - -bool TMotore_application::remove( void ) -{ - if ( ! valida_operazione( OP_CANCELLA ) ) - return FALSE; - return TRelation_application::remove && ( _righe_rec->remove( ) == NOERR ); -} - -void TMotore_application::load_riga( TSheet_field& f, int numrig, TRectype& r ) -{ - TToken_string& riga = f.row(numrig); - riga = r.get( "STATORIGA" ); - riga.add( r.get( "TIPORIGA" ) ); - TFilename proname( r.get( "PROFRIGA" ) ); - riga.add( proname ); - riga.add( r.get( "CODMAG" ) ); - riga.add( r.get( "CODART" ) ); - riga.add( r.get( "DESCR" ) ); - riga.add( r.get( "DESCLUNGA" ) ); - riga.add( r.get( "PREZZO" ) ); - riga.add( r.get( "UMQTA" ) ); - riga.add( r.get_real( "QTA" ).string(11) ); - riga.add( r.get( "QTAEVASA" ) ); - riga.add( r.get( "RIGAEVASA" ) ); - riga.add( r.get( "TARA" ) ); - riga.add( r.get( "PNETTO" ) ); - riga.add( r.get( "NCOLLI" ) ); - riga.add( r.get( "DAEVADERE" ) ); - riga.add( r.get( "SCONTO" ) ); - riga.add( r.get( "PERCPROV" ) ); - riga.add( r.get( "IMPFISSO" ) ); - riga.add( r.get( "IMPFISUN" ) ); - riga.add( r.get( "CODIVA" ) ); - riga.add( r.get( "ADDIVA" ) ); - riga.add( r.get( "ASPBENI" ) ); - proname.ext( "ini" ); - TConfig pro( proname ); - int ncols = pro.get_int( "NCOLS", "COLUMNS" ); - // Disabilita tutte le colonne - for( int i = 1; i <= MAX_COLUMNS; i ++ ) - f.disable_cell ( f.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" ); - f.enable_cell ( numrig - 1, coltoenable - 1 ); - } -} - -void TMotore_application::store_riga( TSheet_field& f, int numrig, TRectype& r ) -{ - TToken_string& riga = f.row(numrig); - - r.put( "CODNUM", edit_mask( ).get( F_CODNUM ) ); - r.put( "ANNO", edit_mask( ).get( F_ANNO ) ); - r.put( "PROVV", edit_mask( ).get( F_PROVV ) ); - 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( ) -{ - _clifor = new TCliForVendite( ); - azzera_piedi( ); - _msk = new TMask("VE1000A"); - query_mask( ).set_handler( F_NDOC, ndoc_handler ); - query_mask( ).set_handler( F_CODNUM, num_handler ); - query_mask( ).set_handler( F_TIPODOC, tip_handler ); - // La maschera di inserimento/modifica per ora non la so! - // Viene letta dal profilo non appena trovato il record - _msk1 = NULL; - - // Metto in relazione testata e righe - _rel = new TRelation(LF_DOC); - rel( ).add( LF_RIGHEDOC,"CODNUM=CODNUM|ANNO=ANNO|PROVV=PROVV|NDOC=NDOC" ); - - // Inizializzo il Record_array - _righe_rec = new TRecord_array( LF_RIGHEDOC, "NRIGA", 1 ); - - return TRUE; -} - -bool TMotore_application::user_destroy( ) -{ - // Se è ancora allocata, distruggo la maschera di modifica - if ( _msk1 ) delete _msk1; - - // Distruggo la maschera di modifica - delete _msk; - - // Distruggo la relazione - delete _rel; - - // Distruggo il Record_array - delete _righe_rec; - - return TRUE; -} - -int TMotore_application::esegui_procedura( int operazione ) -{ - // Accesso unico alla chiamata di procedure tramite operazione - int index = ( int )pro( ).get_long( nome_sezione( operazione ), "MAIN" ); - if ( index ) - return ( user_function( index ) ); - return ( NOERR ); -} - - -bool TMotore_application::valida_operazione( int operazione ) -{ - if ( operazione != OP_NUOVO ) - { - if ( !stato_valido( stato_corrente( ), operazione ) ) - { - segnala_stato_non_valido( operazione ); - return FALSE; - } - }; - if ( esegui_procedura( operazione ) == NOERR ) - return FALSE; - return TRUE; -} - -const char * TMotore_application::nome_sezione( int op ) -{ - switch( op ) - { - case OP_NUOVO: - return "INSERIMENTO"; - break; - case OP_MODIFICA: - return "MODIFICA"; - break; - case OP_CANCELLA: - return "CANCELLAZIONE"; - break; - case OP_STAMPA: - return "STAMPA"; - break; - case OP_RAGGRUPPA: - return "RAGGRUPPA"; - break; - case OP_USER: - return "SPECIALE"; - break; - default: - CHECK( FALSE, "tentativo di ottenere il nome di una operazione inesistente!" ); - // Per evitare la warning - return ""; - break; - } -} - -int TMotore_application::stato_finale( int operazione ) -{ - TString s( pro( ).get( "STATOFINALE", nome_sezione( operazione ) ) ); - if( strcmp( s, "N" ) == 0 ) return NO_CHANGE_STATUS; - return ( atoi( s ) ); -}; - -bool TMotore_application::stato_valido( int stato, int operazione ) -{ -#ifdef _DEBUG - warning_box( "Controllo stati validi!\nStato corrente %d.\nStati validi %s.", stato_corrente( ), ( const char * )stati_validi( operazione ) ); -#endif - char p[2] = "0"; - TToken_string ret ( stati_validi( operazione ), ',' ); - p[0] += (char)stato; - return ( ret.get_pos( p ) != -1 ); -}; - -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 ) ); - TString p; - p.format( "%d", nuovostato ); - - TLocalisamfile& doc = rel( ).lfile(LF_DOC); - - p[0] += (char)nuovostato; - doc.put("STATO", p); - doc.rewrite( ); - 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 ) ); -} - -int TMotore_application::stato_corrente( ) -{ - int i = query_mask( ).get_int( F_STATO ); - return ( i == 0 ? NO_DOC_STATUS : i ); -}; - -void TMotore_application::segnala_stato_non_valido( int operazione ) -{ - TString messaggio; - switch( operazione ) - { - case OP_NUOVO: - // Sempre valido - break; - case OP_MODIFICA: - messaggio = "Il documento non si trova in uno stato valido per poter essere modificato!"; - break; - case OP_CANCELLA: - messaggio = "Il documento non si trova in uno stato valido per poter essere cancellato!"; - break; - case OP_STAMPA: - messaggio = "Il documento non si trova in uno stato valido per poter essere stampato!"; - break; - case OP_RAGGRUPPA: - messaggio = "Il documento non si trova in uno stato valido per poter essere raggruppato!"; - break; - case OP_USER: - messaggio = "Il documento non si trova in uno stato valido per effettuare la operazione richiesta!"; - break; - default: - CHECK( FALSE, "Tentativo di segnalare stato non valido di una operazione non esistente!" ); - break; - }; - messaggio << "\nStato corrente :%d.\nStati validi :%s."; - warning_box( messaggio, stato_corrente( ), ( const char * )stati_validi( operazione ) ); -}; - -int ve0100(int argc, char** argv) -{ - TMotore_application a; - - a.run(argc, argv, "Gestione documenti"); - return 0; -} +#include + +#ifndef __CHECKS_H +#include +#endif + +#ifndef __TABUTIL_H +#include +#endif + +#ifndef __BRWAPP_H +#include +#endif + +#ifndef __RELAPP_H +#include +#endif + +#ifndef __CONFIG_H +#include +#endif + +#ifndef __LFFILES_H +#include +#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 +#endif + +#ifndef __REAL_H +#include +#endif + +#ifndef __MSKSHEET_H +#include +#endif + +#ifndef __VE0100_H +#include "ve0100.h" +#endif + +#ifndef __VE0100C_H +#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 + + + +// 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 liente o un 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 ) +{ + m.set( F_DATAINSC, m.get( F_DATADOC ) ); + m.reset( ); + clifo( ).occas_mask( ).reset( ); +}; + +int TMotore_application::user_function( int index ) +{ + switch( index ) + { + case 1: + break; + default: + yesnofatal_box( "Chiamata ad una procedura utente non definita: %d", index ); + return NOERR; + break; + }; + return NOERR; +}; + +// Funzione che dato il profilo di riga ottiene la maschera +// 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 ) +{ + static TMask* m; + + if ( destroy ) + { + delete m; + return( NULL ); + } + else + { + TFilename nome_proriga( fullmask.get( 103 ) ); + nome_proriga.ext( "ini" ); + TConfig proriga( nome_proriga ); + m = new TMask( proriga.get( "MSK", "MAIN" ) ); + int numhandler = proriga.get_int( "NHANDLER", "HANDLERS" ); + for( int i = 1; i <= numhandler; i ++ ) + { + TString chiave; + chiave.format( "%d", i ); + TToken_string riga = proriga.get( chiave, "HANDLERS" ); + app().user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ), m ); + }; + return( m ); + } +} + +real TMotore_application::user_row_calculate( TRectype& r, int index ) +{ + switch( index ) + { + 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 ) +{ + if( !m ) + m = &edit_mask( ); + switch( index ) + { + case 1: + m->set_handler( fieldid, ora_hndl ); + break; + case 2: + m->set_handler( fieldid, codcli_hndl ); + break; + case 3: + m->set_handler( fieldid, dummy_hndl ); + break; + default: + CHECK( FALSE, "Tentativo di installare un handler non definito" ); + break; + } +}; + +bool TMotore_application::ss_handler( TSheet_field& ss, int r, KEY key ) +{ + if ( key == K_SPACE ) // Inizio modifica + { + app().azzera_piedi( TRUE ); + TRelation rdoc( LF_RIGHEDOC ); + 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 + { + TRelation rdoc( LF_RIGHEDOC ); + TToken_string riga( ss.row( r ) ); + rdoc.curr( ).zero( ); + rdoc.curr( ).put( "CODNUM", app( ).edit_mask( ).get( F_CODNUM ) ); + 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 + { + TRelation rdoc( LF_RIGHEDOC ); + TToken_string riga( ss.row( r ) ); + rdoc.curr( ).zero( ); + rdoc.curr( ).put( "CODNUM", app( ).edit_mask( ).get( F_CODNUM ) ); + 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 ).autosave( &rdoc ); + rdoc.write( ); + } + if ( key == K_INS ) // Inserimento + { + TMask& m = *app( )._msk1; + TTable tabtr( "%TRI" ); + tabtr.zero( ); + tabtr.put( "CODTAB", m.get( F_LBTIPORIGA ) ); + tabtr.read( ); + TToken_string& riga = ss.row( r ); + riga.add( 1, 0 ); + riga.add( m.get( F_LBTIPORIGA ), 1 ); + riga.add( tabtr.get( "S4" ), 2 ); + return TRUE; + } + if ( key == K_CTRL + K_INS ) // Dopo inserimento + { + TMask& m = *app( )._msk1; + 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 ); + return TRUE; + } + if ( key == K_DEL ) // Cancellazione + { + // Sottraggo la riga appena cancellata ai totalizzatori + app().sottrai_piedi( ); + app().carica_piedi( ); + } + if ( key == K_ENTER ) // Modifica + { + app().sottrai_piedi( ); + TRelation rdoc( LF_RIGHEDOC ); + ss.sheet_mask( ).autosave( &rdoc ); + // Sommo la riga ai totalizzatori + app().calcola_riga( rdoc.curr( ) ); + app().sottrai_piedi( ); + } + return TRUE; +}; + +bool TMotore_application::num_handler( TMask_field& f, KEY key ) +{ + // Ottengo la maschera + TMask& m = f.mask( ); + + if (key == K_TAB && m.is_running( ) ) + { + // Se la numerazione non è specificata, + const TString16 value( m.get( F_CODNUM ) ); + if ( value.blank( ) ) + { + // Pulisce la descrizione + m.set(F_DESNUM, "" ); + // Pulisce i tipi di documento consentiti + m.set(F_TIPIDOCS, "" ); + // Pulisce il tipo di documento + m.set(F_TIPODOC, "" ); + return TRUE; + } + // Apro la tabella numerazioni + TTable tabnum( "NUM" ); + tabnum.zero( ); + tabnum.put( "CODTAB", value ); + if( tabnum.read( ) == NOERR ) + { + // Copio la descrizione della numerazione + m.set(F_DESNUM, tabnum.get("S0") ); + // Copio i tipi di documento validi per la numerazione + const TString tipidocs( tabnum.get("S2") ); + m.set(F_TIPIDOCS, tipidocs ); + TString16 curtipo( m.get( F_TIPODOC ) ); + if( curtipo.blank( ) ) + { + // Propone il primo tipo di documento come default + m.set(F_TIPODOC, tipidocs.left( 4 ) ); + // m.field( F_TIPODOC ).check( ); + m.send_key( K_TAB, F_TIPODOC ); + } + // Se per questa numerazione è abilitata le numerazione provvisoria + if ( tabnum.get_bool ( "B0" ) ) + { + // Setta di default la numerazione provvisoria + m.set( F_PROVV, "P" ); + // Abilita il campo per la selezione della numerazione + m.enable( F_PROVV ); + } + else // Altrimenti ... + { + // Setta la numerazione a definitiva + m.set( F_PROVV, "D" ); + // Disabilita il campo per la selezione della numerazione + m.disable( F_PROVV ); + }; + return TRUE; + } + message_box( "Numerazione non valida!" ); + return FALSE; + } + if (key == K_ENTER && m.is_running( ) ) + { // Se la numerazione non è specificata, + const TString16 value( m.get( F_CODNUM ) ); + if ( value.blank( ) ) + { + message_box( "Occorre una numerazione per inserire un documento!" ); + m.first_focus( F_NDOC ); + return FALSE; + } + } + return TRUE; +} + +bool TMotore_application::occas_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE && f.mask( ).is_running( ) ) + { + TMask& om = app( ).clifo( ). occas_mask( ); + om.run( ); + f.set_focus( ); + } + return TRUE; +} + + +bool TMotore_application::tip_handler(TMask_field& f, KEY key) +{ + TMask& m = f.mask( ); + if (key == K_TAB && m.is_running( ) ) + { + const TString16 value( m.get( F_TIPODOC ) ); + if ( value.blank( ) ) + { + // Pulisce il profilo + m.set(F_PROFILO, "" ); + return TRUE; + } + TString tipi_consentiti( m.get( F_TIPIDOCS ) ); + TString16 tipo( f.get( ) ); + tipo.trim( ); + bool tipo_valido = FALSE; + for ( int i = 0; i < 10; i ++ ) + { + TString16 curtipo( tipi_consentiti.mid( i * 4, 4 ) ); + curtipo.trim( ); + if( curtipo == tipo ) + { + tipo_valido = TRUE; + break; + } + } + if( ! tipo_valido ) + { + message_box( "Tipo non valido per la numerazione selezionata!" ); + f.set( "" ); + return FALSE; + } + TTable tabtip( "%TIP" ); + tabtip.zero( ); + tabtip.put( "CODTAB", tipo ); + tabtip.read( ); + m.set(F_DESTIPODOC, tabtip.get("S0") ); + m.set(F_PROFILO, tabtip.get("S4") ); + } + if (key == K_ENTER && m.is_running( ) ) + { TString tipo( f.get( ) ); + if ( ! tipo.blank( ) ) + { TTable tabtip( "%TIP" ); + tabtip.read( ); + m.set(F_PROFILO, tabtip.get("S4") ); + } + else + { message_box( "Occorre un tipo documento per inserire un documento!" ); + m.first_focus( F_TIPODOC ); + return FALSE; + } + } + return TRUE; +} + +bool TMotore_application::ndoc_handler(TMask_field& f, KEY key) +{ + TMask& m = f.mask( ); + if (key == K_TAB && m.is_running( ) ) + { TLocalisamfile& doc = app( ).rel( ).lfile( ); + doc.zero( ); + doc.put("CODNUM", m.get( F_CODNUM ) ); + doc.put("PROVV", m.get( F_PROVV ) ); + doc.put("ANNO", m.get( F_ANNO ) ); + doc.put("NDOC", f.get( ) ); + if ( doc.read( ) == NOERR ) + { m.set(F_TIPODOC, doc.get( "TIPODOC" ) ); + m.set(F_STATO, doc.get( "STATO" ) ); + TTable tabtip( "%TIP" ); + tabtip.put( "CODTAB", doc.get( "TIPODOC" ) ); + tabtip.read( ); + m.set(F_PROFILO, tabtip.get("S4") ); + m.stop_run( K_AUTO_ENTER ); + } + } + return TRUE; +} + +bool TMotore_application::clifo_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.active()) + { + TMask& m = f.mask(); + + const char cf = app().tipocf(); + TLocalisamfile& clifo = ((TEdit_field&)f).browse()->cursor()->file(); + + if (clifo.get_char("TIPOCF") != cf || clifo.get("CODCF") != f.get()) + { + clifo.setkey(1); + clifo.put("TIPOCF", cf); + clifo.put("CODCF", f.get()); + clifo.read(); + CHECK(clifo.good(), "Impossibile ritrovare il clifo" ); + } + CHECKD(f.is_edit(), "Can't check suspension of a non edit-field ", f.dlg()); + const TEdit_field& c = (const TEdit_field&)f; + const TBrowse* b = c.browse(); + CHECKD(b, "Can't check suspension of a edit-field without a USE ", f.dlg()); + const TLocalisamfile& i = b->cursor()->file(); + // Tabella File + const char* sf = i.tab() ? "B2" : "SOSPESO"; + const bool suspended = i.get_bool(sf); + if (suspended) + { + sf = f.get(); + return f.error_box("Il codice '%s' e' sospeso e non puo' essere utilizzato", sf); + } + /* + if (!m.is_running() || f.dirty()) + { + // Equichecazzociva? + + } + */ + // Disabilitazioni varie, ma le demando all'oggetto cliente + if (f.focusdirty()) + { + app().clifo( ).load( cf, atol( f.get( ) ), "" ); + app().clifo( ).update_mask( ( TMask_vendite& ) m ); + if ( app( ).clifo( ).occasionale( ) && app( ).clifo( ).occas_mask( ).get(O_CODICE).empty( ) ) + m.send_key(K_SPACE, F_OCCASEDIT); // Lancia maschera occasionali + } + } + 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( ) +{ + TToken_string s( pro( ).get( "PROGPIEDE", "MAIN" ) ); + int i = s.get_int( ); + int j = 0; + while( i != 0 ) + { + real strpiede( _piedi[ i ] ); + edit_mask( ).set( BASE_PIEDE + ( ++j ), strpiede.stringa( 15 ) ); + i = s.get_int( ); + } +} + +void TMotore_application::somma_piedi( ) +{ + for ( int i = 0; i < NPIEDI; i++ ) + _piedi[ i ] += _piedi_temp[ i ]; +} + +void TMotore_application::sottrai_piedi( ) +{ + for ( int i = 0; i < NPIEDI; i++ ) + _piedi[ i ] -= _piedi_temp[ i ]; +} + +bool TMotore_application::changing_mask(int mode) +{ + static int lastmode = NO_MODE; + + const bool change = ( mode != lastmode ); + lastmode = mode; + return change; + +} + +void TMotore_application::configura_sheet( TSheet_field& sheet, TConfig& config ) +{ + int ncols = config.get_int( "NCOLS", "SHEET" ); + for( int i = 1; i <= ncols; i ++ ) + { + TString col; + col.format( "%d", i ); + TToken_string sheet_col( config.get( col, "SHEET" ) ); + const TString descr( sheet_col.get( 1 ) ); + if ( ! descr.blank( ) ) + sheet.set_column_header( i, descr ); + TString size( sheet_col.get( 2 ) ); + if ( ! size.blank( ) ) + sheet.set_column_width( i, sheet_col.get_int( 2 ) ); + int coltomove = sheet_col.get_int( 0 ) - 1; + sheet.move_column( coltomove, i ); + }; + for ( int j = MAX_COLUMNS; j >= i - 1; j -- ) + sheet.delete_column( j ); +}; + +void TMotore_application::get_edit_mask( void ) +{ + TFilename fn; + + fn = query_mask( ).get( F_PROFILO ); + // query_mask( ).enable(DLG_NEWREC); + fn.ext( "ini" ); + fn.upper( ); + if ( _pro ) + { + if( (*_proname) == fn ) + return; + delete _pro; + }; + _pro = new TConfig( fn ); + _proname = new TFilename( fn ); + _proname->upper( ); + if ( _msk1 ) delete _msk1; + _msk1 = new TMask_vendite( pro( ).get( "MSKFILE", "MAIN" ) ); + // edit_mask( ).set( F_PROFILO, query_mask( ).get( F_PROFILO ) ); + edit_mask( ).set( F_DESNUM, query_mask( ).get( F_DESNUM ) ); + _sheet = &(TSheet_field &)edit_mask( ).field(F_SHEET); + sheet( ).set_notify( ss_handler ); + TString tipocf( app( ).pro( ).get( "TIPOCF", "MAIN" ) ); + app( ).tipocf( tipocf[ 0 ] ); + configura_sheet( *_sheet, *_pro ); + TList_field& listbox = ( TList_field& ) _msk1->field( F_LBTIPORIGA ); + const int numtr = app( ).pro( ).get_int( "NTIPIRIGA", "RIGHE" ); + TTable tabtr( "%TRI" ); + TToken_string keys( "" ), descrs( "" ); + for ( int i = 1; i <= numtr; i ++ ) + { + TString chiave; + TToken_string item; + chiave.format( "%d", i ); + tabtr.zero( ); + TString tiporiga( app( ).pro( ).get( chiave, "RIGHE" ) ); + tabtr.put( "CODTAB", tiporiga ); + if ( tabtr.read( ) == NOERR ) + { + keys.add( tabtr.get( "CODTAB" ) ); + descrs.add( tabtr.get( "S0" ) ); + } + else + { + yesnofatal_box( "Inserito un tipo di riga non valido (%s)", (const char *)tiporiga ); + } + } + listbox.replace_items( keys, descrs ); + sheet( ).set_getmask( ss_getmask ); + int numhandler = pro( ).get_int( "NHANDLER", "HANDLERS" ); + for( i = 1; i <= numhandler; i ++ ) + { + TString chiave; + chiave.format( "%d", i ); + TToken_string riga = pro( ).get( chiave, "HANDLERS" ); + user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ) ); + }; + _msk1->set( F_MEMORIGA, "Riga1" ); +} + +TMask* TMotore_application::get_mask( int mode ) +{ + switch ( mode ) + { + case MODE_INS: + case MODE_MOD: + get_edit_mask( ); + edit_mask( ).enable( DLG_PRINT, ( mode == MODE_MOD ) ); + edit_mask( ).set_handler( F_OCCASEDIT, occas_handler ); + edit_mask( ).set_handler( F_CODCF, clifo_handler ); + edit_mask( ).set_handler( F_CODPAG, condpag_hndl ); + edit_mask( ).set_handler( F_DATAINSC, condpag_hndl ); + return ( _msk1 ); + break; + default: + return _msk; + break; + }; +} + +void TMotore_application::set_descr(int i, const char * dfi) +{ + TToken_string& r = ss( ).row(i); + r.add(dfi, 0); +} + +void TMotore_application::carica_righe_libere(int from) +{ + if (from < 0) from = ss( ).items( ); + for (int i = from; i < 20; i++) + set_descr( i, "" ); + ss( ).force_update( ); +} + +const char* TMotore_application::get_next_key( ) +{ + TToken_string key; + TMask& m = curr_mask( ); + + TString value = m.get( F_CODNUM ); + if ( value.blank( ) ) + return NULL; + TTable tabnum( "NUM" ); + tabnum.zero( ); + tabnum.put( "CODTAB", value ); + if( tabnum.read( ) == NOERR ) + { + // Se per questa numerazione è abilitata le numerazione automatica + if( tabnum.get_bool ( "B1" ) ) + { + TLocalisamfile doc( LF_DOC ); + doc.zero( ); + doc.put( "CODNUM", value ); + doc.put( "ANNO", m.get( F_ANNO ) ); + doc.put( "NDOC", 9999999L ); + // Se per questa numerazione è abilitata le numerazione provvisoria + if( tabnum.get_bool ( "B0" ) ) + { + doc.put( "PROVV", "P" ); + } + else // Altrimenti ... + { + doc.put( "PROVV", "D" ); + }; + if( doc.read( _isgteq ) == NOERR ) + { + doc.prev( ); + } + long num = ( value == doc.get( "CODNUM" ) ) ? doc.get_long( "NDOC" ) : 0; + key.format( "%d|%d", F_NDOC, num + 1 ); + return key; + } + }; + return NULL; +} + +int TMotore_application::read(TMask& m) +{ + azzera_piedi( ); + int err = TRelation_application::read( m ); + if ( err == NOERR ) + { + TString16 tipocf( m.get( F_TIPOCF ) ); + clifo( ).load( tipocf[ 0 ], m.get_int( F_CODCF ), rel( ).curr( ).get( "OCFPI" ) ); + clifo( ).update_mask( ( TMask_vendite& ) m, TRUE ); + TLocalisamfile& rdoc = rel( ).lfile(LF_RIGHEDOC); + TRectype r = rdoc.curr( ); + r.zero( ); + r.put( "CODNUM", m.get( F_CODNUM ) ); + r.put( "PROVV", m.get( F_PROVV ) ); + r.put( "ANNO", m.get( F_ANNO ) ); + r.put( "NDOC", m.get_long( F_NDOC ) ); + _righe_rec->read( r ); + TSheet_field& f = (TSheet_field&) m.field( F_SHEET ); + f.destroy( ); + int last = _righe_rec->last_row( ); + for( int i = 1; i <= last; i ++ ) + { + TRectype &rec = _righe_rec->row( i, TRUE ); + load_riga( f, i - 1, rec ); + calcola_riga( rec ); + }; + carica_piedi( ); + } + return err; +} + +bool TMotore_application::check_key( TLocalisamfile& rdoc, TString16 codnum, bool provv, TString16 anno, TString16 ndoc ) +{ + return ( ( rdoc.get("CODNUM") == codnum ) && + ( rdoc.get("NDOC") == ndoc ) && + ( rdoc.get("ANNO" ) == anno ) && + ( rdoc.get_bool( "PROVV" ) == provv ) ); +} + +int TMotore_application::write(const TMask& m) +{ + int err; + if ( esegui_procedura( OP_NUOVO ) != NOERR ) + return FALSE; + err = NOERR; // avanza_numero( m.get_bool( F_PROVV ) ); + if ( err == NOERR ) + { + err = app( ).clifo( ).write_occas( ); + } + if ( err == NOERR ) + { + err = TRelation_application::write( m ); + if ( err == NOERR ) + { + TSheet_field& f = ss( ); + _righe_rec->destroy_rows( ); + if ( m.insert_mode( ) ) + _righe_rec->renum_key( "NRIGA", 1 ); + for ( int i = 0; i < f.items( ); i ++ ) + { + TToken_string& t = f.row( i ); + TRectype& rec = _righe_rec->row(i + 1, TRUE); + store_riga( f, i, rec ); + } + err = _righe_rec->write( ); + } + } + return err; +}; + +int TMotore_application::rewrite(const TMask& m) +{ + if ( ! valida_operazione( OP_MODIFICA ) ) + return FALSE; + int err = TRelation_application::rewrite( m ); + if ( err == NOERR ) + { + TSheet_field& f = ss( ); + _righe_rec->destroy_rows( ); + if ( m.insert_mode( ) ) + _righe_rec->renum_key( "NRIGA", 1 ); + for ( int i = 0; i < f.items( ); i ++ ) + { + TToken_string& t = f.row( i ); + TRectype& rec = _righe_rec->row(i + 1, TRUE); + store_riga( f, i, rec ); + } + err = _righe_rec->rewrite( ); + } + return err; +}; + + +// La funzione si trova in ve0100b + +long TMotore_application::prossimo_numero( bool provv ) +{ + long ret; + TTable tabnum( "NUM" ); + + tabnum.read( ); + if ( provv ) + ret = tabnum.get_long( "I0" ) + 1; + else + ret = tabnum.get_long( "I1" ) + 1; + return ( ret ); +}; + +int TMotore_application::avanza_numero( bool provv ) +{ + TTable tabnum( "NUM" ); + + int err = tabnum.read( ); + if ( err == NOERR ) + { + if ( provv ) + tabnum.put( "I0", tabnum.get_long( "I0" ) + 1 ); + else + tabnum.put( "I1", tabnum.get_long( "I1" ) + 1 ); + err = tabnum.rewrite( ); + } + return err; +}; + +bool TMotore_application::remove( void ) +{ + if ( ! valida_operazione( OP_CANCELLA ) ) + return FALSE; + return TRelation_application::remove && ( _righe_rec->remove( ) == NOERR ); +} + +void TMotore_application::load_riga( TSheet_field& f, int numrig, TRectype& r ) +{ + TToken_string& riga = f.row(numrig); + riga = r.get( "STATORIGA" ); + riga.add( r.get( "TIPORIGA" ) ); + TFilename proname( r.get( "PROFRIGA" ) ); + riga.add( proname ); + riga.add( r.get( "CODMAG" ) ); + riga.add( r.get( "CODART" ) ); + riga.add( r.get( "DESCR" ) ); + riga.add( r.get( "DESCLUNGA" ) ); + riga.add( r.get( "PREZZO" ) ); + riga.add( r.get( "UMQTA" ) ); + riga.add( r.get_real( "QTA" ).string(11) ); + riga.add( r.get( "QTAEVASA" ) ); + riga.add( r.get( "RIGAEVASA" ) ); + riga.add( r.get( "TARA" ) ); + riga.add( r.get( "PNETTO" ) ); + riga.add( r.get( "NCOLLI" ) ); + riga.add( r.get( "DAEVADERE" ) ); + riga.add( r.get( "SCONTO" ) ); + riga.add( r.get( "PERCPROV" ) ); + riga.add( r.get( "IMPFISSO" ) ); + riga.add( r.get( "IMPFISUN" ) ); + riga.add( r.get( "CODIVA" ) ); + riga.add( r.get( "ADDIVA" ) ); + riga.add( r.get( "ASPBENI" ) ); + proname.ext( "ini" ); + TConfig pro( proname ); + int ncols = pro.get_int( "NCOLS", "COLUMNS" ); + // Disabilita tutte le colonne + for( int i = 1; i <= MAX_COLUMNS; i ++ ) + f.disable_cell ( f.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" ); + f.enable_cell ( numrig - 1, coltoenable - 1 ); + } +} + +void TMotore_application::store_riga( TSheet_field& f, int numrig, TRectype& r ) +{ + TToken_string& riga = f.row(numrig); + + r.put( "CODNUM", edit_mask( ).get( F_CODNUM ) ); + r.put( "ANNO", edit_mask( ).get( F_ANNO ) ); + r.put( "PROVV", edit_mask( ).get( F_PROVV ) ); + 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( ) +{ + _clifor = new TCliForVendite( ); + azzera_piedi( ); + _msk = new TMask("VE1000A"); + query_mask( ).set_handler( F_NDOC, ndoc_handler ); + query_mask( ).set_handler( F_CODNUM, num_handler ); + query_mask( ).set_handler( F_TIPODOC, tip_handler ); + TConfig utente( CONFIG_USER ); + TString16 codnum( utente.get( "CODNUM", "ve") ); + if (!codnum.blank( ) ) + { + query_mask( ).set( F_CODNUM, codnum ); + query_mask( ).set( F_DESNUM, utente.get( "DESNUM", "ve") ); + } + TString16 tipodoc( utente.get( "TIPODOC", "ve") ); + if (!tipodoc.blank( ) ) + { + query_mask( ).set( F_TIPODOC, tipodoc ); + query_mask( ).set( F_DESTIPODOC, utente.get( "DESTIPODOC", "ve") ); + } + // La maschera di inserimento/modifica per ora non la so! + // Viene letta dal profilo non appena trovato il record + _msk1 = NULL; + + // Metto in relazione testata e righe + _rel = new TRelation(LF_DOC); + rel( ).add( LF_RIGHEDOC,"CODNUM=CODNUM|ANNO=ANNO|PROVV=PROVV|NDOC=NDOC" ); + + // Inizializzo il Record_array + _righe_rec = new TRecord_array( LF_RIGHEDOC, "NRIGA", 1 ); + + return TRUE; +} + +bool TMotore_application::user_destroy( ) +{ + // Registro l'ultimo tipo documento e l'ultima numerazione + TConfig utente( CONFIG_USER ); + utente.set( "CODNUM", query_mask( ).get( F_CODNUM ), "ve" ); + utente.set( "TIPODOC", query_mask( ).get( F_TIPODOC ), "ve" ); + utente.set( "DESNUM", query_mask( ).get( F_DESNUM ), "ve" ); + utente.set( "DESTIPODOC", query_mask( ).get( F_DESTIPODOC), "ve" ); + // Se è ancora allocata, distruggo la maschera di modifica + if ( _msk1 ) delete _msk1; + + // Distruggo la maschera di modifica + delete _msk; + + // Distruggo la relazione + delete _rel; + + // Distruggo il Record_array + delete _righe_rec; + + return TRUE; +} + +int TMotore_application::esegui_procedura( int operazione ) +{ + // Accesso unico alla chiamata di procedure tramite operazione + int index = ( int )pro( ).get_long( nome_sezione( operazione ), "MAIN" ); + if ( index ) + return ( user_function( index ) ); + return ( NOERR ); +} + + +bool TMotore_application::valida_operazione( int operazione ) +{ + if ( operazione != OP_NUOVO ) + { + if ( !stato_valido( stato_corrente( ), operazione ) ) + { + segnala_stato_non_valido( operazione ); + return FALSE; + } + }; + if ( esegui_procedura( operazione ) == NOERR ) + return FALSE; + return TRUE; +} + +const char * TMotore_application::nome_sezione( int op ) +{ + switch( op ) + { + case OP_NUOVO: + return "INSERIMENTO"; + break; + case OP_MODIFICA: + return "MODIFICA"; + break; + case OP_CANCELLA: + return "CANCELLAZIONE"; + break; + case OP_STAMPA: + return "STAMPA"; + break; + case OP_RAGGRUPPA: + return "RAGGRUPPA"; + break; + case OP_USER: + return "SPECIALE"; + break; + default: + CHECK( FALSE, "tentativo di ottenere il nome di una operazione inesistente!" ); + // Per evitare la warning + return ""; + break; + } +} + +int TMotore_application::stato_finale( int operazione ) +{ + TString s( pro( ).get( "STATOFINALE", nome_sezione( operazione ) ) ); + if( strcmp( s, "N" ) == 0 ) return NO_CHANGE_STATUS; + return ( atoi( s ) ); +}; + +bool TMotore_application::stato_valido( int stato, int operazione ) +{ +#ifdef _DEBUG + warning_box( "Controllo stati validi!\nStato corrente %d.\nStati validi %s.", stato_corrente( ), ( const char * )stati_validi( operazione ) ); +#endif + char p[2] = "0"; + TToken_string ret ( stati_validi( operazione ), ',' ); + p[0] += (char)stato; + return ( ret.get_pos( p ) != -1 ); +}; + +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 ) ); + TString p; + p.format( "%d", nuovostato ); + + TLocalisamfile& doc = rel( ).lfile(LF_DOC); + + p[0] += (char)nuovostato; + doc.put("STATO", p); + doc.rewrite( ); + 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 ) ); +} + +int TMotore_application::stato_corrente( ) +{ + int i = query_mask( ).get_int( F_STATO ); + return ( i == 0 ? NO_DOC_STATUS : i ); +}; + +void TMotore_application::segnala_stato_non_valido( int operazione ) +{ + TString messaggio; + switch( operazione ) + { + case OP_NUOVO: + // Sempre valido + break; + case OP_MODIFICA: + messaggio = "Il documento non si trova in uno stato valido per poter essere modificato!"; + break; + case OP_CANCELLA: + messaggio = "Il documento non si trova in uno stato valido per poter essere cancellato!"; + break; + case OP_STAMPA: + messaggio = "Il documento non si trova in uno stato valido per poter essere stampato!"; + break; + case OP_RAGGRUPPA: + messaggio = "Il documento non si trova in uno stato valido per poter essere raggruppato!"; + break; + case OP_USER: + messaggio = "Il documento non si trova in uno stato valido per effettuare la operazione richiesta!"; + break; + default: + CHECK( FALSE, "Tentativo di segnalare stato non valido di una operazione non esistente!" ); + break; + }; + messaggio << "\nStato corrente :%d.\nStati validi :%s."; + warning_box( messaggio, stato_corrente( ), ( const char * )stati_validi( operazione ) ); +}; + +int ve0100(int argc, char** argv) +{ + TMotore_application a; + + a.run(argc, argv, "Gestione documenti"); + return 0; +} diff --git a/ve/ve0100.h b/ve/ve0100.h index 7d01f6b0b..d3d16680a 100755 --- a/ve/ve0100.h +++ b/ve/ve0100.h @@ -14,4 +14,5 @@ #define NO_DOC_STATUS -2 #define F_SHEET 500 +#define F_MEMORIGA 501 #define BASE_PIEDE 600 diff --git a/ve/ve0100c.cpp b/ve/ve0100c.cpp index 78e5e0f21..17862dcaf 100755 --- a/ve/ve0100c.cpp +++ b/ve/ve0100c.cpp @@ -1,95 +1,125 @@ -// Handler di marco sui campi delle maschere -#ifndef __CHECKS_H -#include -#endif - -#ifndef __MASK_H -#include -#endif - -#ifndef __MASKFLD_H -#include -#endif - -#ifndef __KEYS_H -#include -#endif - -#ifndef __STRINGS_H -#include -#endif - -#ifndef __VEUML_H -#include "VeUML.h" -#endif - -#ifndef __VEUML1_H -#include "VeUML1.h" -#endif - -#ifndef __VE0100C_H -#include "ve0100c.h" -#endif - -bool ora_hndl(TMask_field& field, KEY key) -{ - if (key == K_TAB) - { - if (field.to_check(key)) - { - TFixed_string ora(field.get(),6); - ora.trim(); - if (ora.not_empty() || field.required()) - { - // bool changed = FALSE; - if (isdigit(ora[0])) - { - if (ora[2] != ':') - { - if (ora.len()>4) ora.overwrite(":",2); - else ora.insert(":", 2); - // changed = TRUE; - } - } - bool ok; - ok = ((isdigit(ora[0]))&&(isdigit(ora[1]))&&(isdigit(ora[3]))&&(isdigit(ora[4]))); - ok &= ((atoi(&(ora[0]))<24)&&(atoi(&(ora[3]))<60)); - if (!ok) - { - error_box("Ora errata o formato non valido"); - return FALSE; - } - else /* if (changed) */ - { - field.set((ora)); - // field.picture_data((ora),TRUE); - // field.picture_data((ora.strip(":")),FALSE); - } - } - } - } - 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) -{ - warning_box("Al campo %d è arrivato un KEY %d",field.dlg(),key); - return TRUE; -} +// Handler di marco sui campi delle maschere +#ifndef __CHECKS_H +#include +#endif + +#ifndef __MASK_H +#include +#endif + +#ifndef __MASKFLD_H +#include +#endif + +#ifndef __KEYS_H +#include +#endif + +#ifndef __STRINGS_H +#include +#endif + +#ifndef __VEUML_H +#include "VeUML.h" +#endif + +#ifndef __VEUML1_H +#include "VeUML1.h" +#endif + +#ifndef __VE0100C_H +#include "ve0100c.h" +#endif + +#ifndef __PAGAMENT_H +#include "..\cg\pagament.h" +#endif + +bool ora_hndl(TMask_field& field, KEY key) +{ + if (key == K_TAB) + { + if (field.to_check(key)) + { + TFixed_string ora(field.get(),6); + ora.trim(); + if (ora.not_empty() || field.required()) + { + // bool changed = FALSE; + if (isdigit(ora[0])) + { + if (ora[2] != ':') + { + if (ora.len()>4) ora.overwrite(":",2); + else ora.insert(":", 2); + // changed = TRUE; + } + } + bool ok; + ok = ((isdigit(ora[0]))&&(isdigit(ora[1]))&&(isdigit(ora[3]))&&(isdigit(ora[4]))); + ok &= ((atoi(&(ora[0]))<24)&&(atoi(&(ora[3]))<60)); + if (!ok) + { + error_box("Ora errata o formato non valido"); + return FALSE; + } + else /* if (changed) */ + { + field.set((ora)); + // field.picture_data((ora),TRUE); + // field.picture_data((ora.strip(":")),FALSE); + } + } + } + } + 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) +{ + warning_box("Al campo %d è arrivato un KEY %d",field.dlg(),key); + return TRUE; +} + +bool condpag_hndl(TMask_field& field, KEY key) +{ + + if (key == K_TAB) + { + if (field.to_check(key)) + { + TMask& m = field.mask( ); + TString16 condpag( m.get( F_CODPAG ) ); + TString16 data( m.get( F_DATAINSC ) ); + if ( condpag.blank( ) || data.blank( ) ) + return TRUE; + TPagamento pag( condpag, data ); + pag.set_total( 100, 10, 10 ); + pag.set_rate_auto( ); + int numrate = pag.n_rate( ); + for( int i = 0; i < numrate; i ++ ) + m.set( F_DATASCAD1 + i, pag.data_rata( i ).string( ) ); + for( ; i < 5; i ++ ) + m.hide( F_DATASCAD1 + i ); + } + } + return TRUE; +} + diff --git a/ve/ve0100c.h b/ve/ve0100c.h index af9808da8..40a587441 100755 --- a/ve/ve0100c.h +++ b/ve/ve0100c.h @@ -1,7 +1,8 @@ -#define __VE0100C_H - -// Handlers per i campi delle bolle - -extern bool ora_hndl(TMask_field& field, KEY key); -extern bool codcli_hndl(TMask_field& field, KEY key); -extern bool dummy_hndl(TMask_field& field, KEY key); +#define __VE0100C_H + +// Handlers per i campi delle bolle + +extern bool ora_hndl(TMask_field& field, KEY key); +extern bool codcli_hndl(TMask_field& field, KEY key); +extern bool dummy_hndl(TMask_field& field, KEY key); +extern bool condpag_hndl(TMask_field& field, KEY key); \ No newline at end of file diff --git a/ve/ve0200.cpp b/ve/ve0200.cpp index be3af6dd4..47dbdf494 100755 --- a/ve/ve0200.cpp +++ b/ve/ve0200.cpp @@ -1,67 +1,115 @@ -#include - -#ifndef __CHECKS_H -#include -#endif - -#ifndef __CONFAPP_H -#include -#endif - -#ifndef __EXECP_H -#include -#endif - -#ifndef __TABUTIL_H -#include -#endif - -// #include "ve5.h" - -class Conf_vendite_app : public TConfig_application -{ - -public: - virtual bool preprocess_config (TMask& mask, TConfig& config); - virtual bool postprocess_config (TMask& mask, TConfig& config); - - Conf_vendite_app() : TConfig_application(CONFIG_DITTA) {} - virtual ~Conf_vendite_app() {} -}; - -bool Conf_vendite_app::preprocess_config (TMask& mask, TConfig& config) -{ - disable_menu_item(M_FILE_NEW); - disable_menu_item(M_FILE_REVERT); - return TRUE; -} - -bool Conf_vendite_app::postprocess_config(TMask& mask, TConfig& config) -{ TExternal_app *cl; - TTable t("TIP"); - t.first(); - while( ! t.eof() ) - { - TString s( "Eseguirò \"vegenmsk " ); - s << t.get( "S1" ); - s << "\"!"; - message_box( s ); - s = "vegenmsk "; - s << t.get( "S1" ); - cl = new TExternal_app( s ); - cl->run( ); - delete cl; - t.next(); - } - enable_menu_item(M_FILE_NEW); - enable_menu_item(M_FILE_REVERT); - return TRUE; -} - -int ve0200(int argc, char** argv) -{ - Conf_vendite_app appc; - - appc.run(argc, argv, "Parametri gestione vendite"); - return 0; -} +#include + +#ifndef __CHECKS_H +#include +#endif + +#ifndef __CONFAPP_H +#include +#endif + +#ifndef __EXECP_H +#include +#endif + +#ifndef __TABUTIL_H +#include +#endif + +class TConf_vendite : public TConfig_application +{ + private: + + bool _changed; + + public: + virtual bool preprocess_config (TMask& mask, TConfig& config); + virtual bool postprocess_config_changed (const char* par, const char* var, + const char* oldv, const char* newv); + virtual bool postprocess_config (TMask& mask, TConfig& config); + virtual bool user_create( ); + virtual bool user_destroy( ); + + TConf_vendite() : TConfig_application( CONFIG_DITTA ){ } + virtual ~TConf_vendite( ){ } +}; + +bool TConf_vendite::preprocess_config (TMask& mask, TConfig& config) +{ + disable_menu_item(M_FILE_NEW); + disable_menu_item(M_FILE_REVERT); + return TRUE; +} + +bool TConf_vendite::postprocess_config (TMask& mask, TConfig& config) +{ + _changed = FALSE; + enable_menu_item(M_FILE_NEW); + enable_menu_item(M_FILE_REVERT); + return TRUE; +} + + +bool TConf_vendite::postprocess_config_changed (const char* par, const char* var, + const char* oldv, const char* newv) +{ + // Notifica al motore che la configurazione è cambiata: occorre rigenerare le maschere + _changed = TRUE; + return TRUE; +} + +bool TConf_vendite::user_create( ) +{ + char msk = argv(2)[0]; + // Devo usare un puntatore così deletandolo si registra + TConfig confditta( CONFIG_DITTA ); + switch( msk ) + { + case 'a': + case 'A': + confditta.set( "EdMask", "ve0200a" "ve" ); + break; + case 'b': + case 'B': + confditta.set( "EdMask", "ve0200b" "ve" ); + break; + case 'c': + case 'C': + confditta.set( "EdMask", "ve0200c" "ve" ); + break; + case 'd': + case 'D': + confditta.set( "EdMask", "ve0200d" "ve" ); + break; + case 'e': + case 'E': + confditta.set( "EdMask", "ve0200e" "ve" ); + break; + default: + fatal_box( "Sintassi: VE0 -2 [a|b|c|d|e]" ); + return FALSE; + break; + } + return TRUE; +} + +bool TConf_vendite::user_destroy( ) +{ + if( _changed ) + { + TConfig confditta( CONFIG_DITTA ); + confditta.set( "EdMask", "", "ve" ); + confditta.set( "CHANGED", "X", "ve" ); + } + return TRUE; +} + +int ve0200(int argc, char** argv) +{ + TConf_vendite appc; + + if( argc < 3 ) + fatal_box( "Sintassi: VE0 -2 [a|b|c|d|e]" ); + appc.run(argc, argv, "Parametri gestione vendite"); + return 0; +} diff --git a/ve/ve0200a.uml b/ve/ve0200a.uml new file mode 100755 index 000000000..65f71a7a1 --- /dev/null +++ b/ve/ve0200a.uml @@ -0,0 +1,270 @@ +/* toolbar */ +#include "ve0200b.h" + +TOOLBAR "" 0 20 0 2 + +BUTTON DLG_OK 10 2 +BEGIN +PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 10 2 +BEGIN +PROMPT -22 -1 "" +END + +ENDPAGE + + +PAGE "Tabelle di installazione" 1 1 60 14 + +GROUPBOX DLG_NULL 78 15 +BEGIN +PROMPT 0 0 "Gestione listini/contratti/campagne 1/2" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 2 "Cumula articolo/listino/listino" +FIELD CUMULAALC +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 3 "Gestione archivio listini" +MESSAGE FALSE DISABLE,1@ +MESSAGE TRUE ENABLE,1@ +FIELD GESLIS +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 4 "Gestione codice categoria vendite+codice listino" +FIELD GESLISCV +GROUP 1 +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 5 "Gestione listini per unita di misura" +FIELD GESLISUM +GROUP 1 +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 6 "Gestione listino a scaglioni" +FIELD GESLISSCA +GROUP 1 +END + + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 7 "Gestione sconti/omaggio articoli" +FIELD GESLISSO +GROUP 1 +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 9 "Gestione archivio contratti" +MESSAGE FALSE DISABLE,2@ +MESSAGE TRUE ENABLE,2@ +FIELD GESCON +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 10 "Gestione codice contratto" +FIELD GESCONCC +GROUP 2 +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 11 "Gestione contratti per unita di misura" +FIELD GESCONUM +GROUP 2 +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 12 "Gestione contratto a scaglioni" +FIELD GESCONSCA +GROUP 2 +END + + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 13 "Gestione sconti/omaggio articoli" +FIELD GESCONSO +GROUP 2 +END + +ENDPAGE + +PAGE "Tabelle di installazione" 1 1 60 14 + +GROUPBOX DLG_NULL 78 15 +BEGIN +PROMPT 0 0 "Gestione listini/contratti/campagne 2/2" +END + + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 2 "Gestione archivio campagne" +MESSAGE TRUE ENABLE,3@ +MESSAGE FALSE DISABLE,3@ +FIELD GESCAM +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 3 "Gestione campagne per unita di misura" +FIELD GESCAMUM +GROUP 3 +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 4 "Gestione campagne a scaglioni" +FIELD GESCAMSCA +GROUP 3 +END + + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 5 "Gestione sconti/omaggio articoli" +FIELD GESCAMSO +GROUP 3 +END + +LIST DLG_NULL 40 +BEGIN +PROMPT 2 7 "Sequenza di ricerca righe" +ITEM "A|Codice articolo" +ITEM "L|Codice linea" +ITEM "C|Codice linea/categoria" +ITEM "R|Codice raggruppamento fiscale" +ITEM " | " +FIELD SEQRICRIGHE[ 1 ] +END + +LIST DLG_NULL 40 +BEGIN +PROMPT 2 8 " " +ITEM "A|Codice articolo" +ITEM "L|Codice linea" +ITEM "C|Codice linea/categoria" +ITEM "R|Codice raggruppamento fiscale" +ITEM " | " +FIELD SEQRICRIGHE[ 2 ] +END + +LIST DLG_NULL 40 +BEGIN +PROMPT 2 9 " " +ITEM "A|Codice articolo" +ITEM "L|Codice linea" +ITEM "C|Codice linea/categoria" +ITEM "R|Codice raggruppamento fiscale" +ITEM " | " +FIELD SEQRICRIGHE[ 3 ] +END + +LIST DLG_NULL 40 +BEGIN +PROMPT 2 10 " " +ITEM "A|Codice articolo" +ITEM "L|Codice linea" +ITEM "C|Codice linea/categoria" +ITEM "R|Codice raggruppamento fiscale" +ITEM " | " +FIELD SEQRICRIGHE[ 4 ] +END + +ENDPAGE + +PAGE "Tabella gestione sconti " 1 1 60 14 + +GROUPBOX DLG_NULL 78 10 +BEGIN +PROMPT 0 0 "Gestione Sconti" +END + +LIST DLG_NULL 36 +BEGIN +PROMPT 2 1 "Tipo gestione sconti documenti " +ITEM "N|Non gestire" +ITEM "P|Percentuale su anagrafica " +ITEM "T|Gestione tabella sconti " +ITEM "A|Gestione archivio sconti " +FIELD GESSCO +END + +LIST DLG_NULL 36 +BEGIN +PROMPT 2 2 "Chiave archivio sconti " +ITEM "V|Tab. categorie vendite " +ITEM "C|Tab. sconti clienti " +ITEM "Z|Tab. zone " +ITEM "M|Tab. modalità di pagamento " +FIELD SCOKEY +END + +LIST DLG_NULL 36 +BEGIN +PROMPT 2 3 "Tipo calcolo sconti documento " +ITEM "R|Sconti sulle righe merci " +ITEM "G|Sconti sul valore globale merci " +FIELD SCOTIPCAL +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 4 "Gestione sconti ad importo " +FIELD GESSCOIMP +END + +LIST DLG_NULL 36 +BEGIN +PROMPT 2 5 "Tipo gestione sconti riga " +ITEM "N|Non gestire" +ITEM "L|Perc. su anagrafica/listini/contratti " +ITEM "A|Gest. arch. sconti " +ITEM "V|Gest. arch. con cat. vendita cliente " +ITEM "C|Perc. indicata su anagrafica cliente " +FIELD GESSCORIGA +END + +LIST DLG_NULL 36 +BEGIN +PROMPT 2 6 "Chiave archivio sconti di riga " +ITEM "A|Codice articolo " +ITEM "L|Codice linea " +ITEM "C|Codice linea/categoria " +ITEM "R|Codice raggruppamento fiscale " +FIELD +SCORIGAKEY +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 7 "Gestione archivio sconti a scaglioni " +GESSCOSCA +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 8 "Gestione archivio sconti unità di misura " +GESSCOUM +END + +ENDPAGE + +ENDMASK + diff --git a/ve/ve0200b.h b/ve/ve0200b.h new file mode 100755 index 000000000..a86612125 --- /dev/null +++ b/ve/ve0200b.h @@ -0,0 +1,12 @@ +#define F_TIPOPERC 101 +#define F_GESARCHPROV 102 +#define F_ARCHPROV1 103 +#define F_ARCHPROV2 104 +#define F_ARCHPROV3 105 +#define F_ARCHPROV4 106 +#define F_TIPOLIQPROV 107 +#define F_GESVAL 108 +#define F_GESLIN 109 +#define F_GESSOSPIMP 110 +#define F_GESOCCAS 111 +#define F_GESOCCHK 112 diff --git a/ve/ve0200b.uml b/ve/ve0200b.uml new file mode 100755 index 000000000..81d983e01 --- /dev/null +++ b/ve/ve0200b.uml @@ -0,0 +1,509 @@ +/* toolbar */ +#include "ve0200b.h" + +TOOLBAR "" 0 20 0 2 + +BUTTON DLG_OK 10 2 +BEGIN +PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 10 2 +BEGIN +PROMPT -22 -1 "" +END + +ENDPAGE + +PAGE "Tabelle di installazione" 1 1 60 14 + +GROUPBOX DLG_NULL 78 10 +BEGIN +PROMPT 0 0 "Gestione degli agenti" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 1 "Gestione agenti " +MESSAGE FALSE DISABLE,8@ +MESSAGE TRUE ENABLE,8@ +FIELD GESAGE +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 2 "Gestione subagenti " +FIELD GESSUBAGE +GROUP 8 +END + +LIST F_TIPOPERC 33 +BEGIN +FIELD AGETIPOPERC +PROMPT 2 3 "Tipo percentuale da proporre " +ITEM "V|Tab. categorie vendite agenti " +ITEM "A|Tab. agenti " +ITEM "C|Archivio clienti " +ITEM "L|Archivio listini o contratti " +ITEM "P|Provvigioni sulla tabella agenti " +GROUP 1 +END + +BOOLEAN F_GESARCHPROV +BEGIN +PROMPT 2 4 "Gestione archivio provvigioni " +FIELD AGEARCPROVV +GROUP 1 +END + +STRING F_ARCHPROV1 4 +BEGIN +PROMPT 2 5 "Chiavi archivio provvigioni " +FIELD AGEKEYPROVV[1] +GROUP 1 +END + +STRING F_ARCHPROV2 4 +BEGIN +PROMPT 2 6 " " +FIELD AGEKEYPROVV[2] +GROUP 1 +END + +STRING F_ARCHPROV3 4 +BEGIN +PROMPT 2 7 " " +FIELD AGEKEYPROVV[3] +GROUP 1 +END + +STRING F_ARCHPROV4 4 +BEGIN +PROMPT 2 8 " " +FIELD AGEKEYPROVV[4] +GROUP 1 +END + +LIST F_TIPOLIQPROV 41 +BEGIN +PROMPT 2 9 "Tipo liquidazione provvigione " +ITEM "F|Liquidate sul valore del fatturato " +ITEM "M|Liq. sul valore fatt. e sul valore merce " +FIELD AGELIQPROVV +GROUP 1 +END + +ENDPAGE + +PAGE "Tabelle di installazione" 1 1 60 14 + +GROUPBOX DLG_NULL 78 10 +BEGIN +PROMPT 0 0 "Gestione dati generali" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 2 "Gestione documenti in valuta" +MESSAGE TRUE ENABLE,@7 +MESSAGE FALSE DISABLE,@7 +FIELD GESVAL +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 3 "Gestione archivio cambi " +FIELD GESVALAC +END + +BOOLEAN F_GESLIN +BEGIN +PROMPT 2 4 "Gestione documenti in lingua" +FIELD GESLIN +END + +BOOLEAN F_GESSOSPIMP +BEGIN +PROMPT 2 6 "Gestione documenti in sospensione di imposta" +FIELD GESSOSPIMP +END + +BOOLEAN F_GESOCCAS +BEGIN +PROMPT 2 8 "Gestione archivio clienti occasionali" +FIELD GESOCCAS +MESSAGE FALSE DISABLE,F_GESOCCHK +END + +BOOLEAN F_GESOCCHK +BEGIN +PROMPT 2 10 "Controllo p.iva/cod.fiscale cliente occasionale" +FIELD GESOCCCHK +END + +ENDPAGE + +PAGE "Tabelle di installazione" 1 1 60 2 + +GROUPBOX DLG_NULL 78 16 +BEGIN +PROMPT 0 0 "Etichette totalizzatori piede documento 1/4" +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 2 " 1:" +FIELD PIEDE[ 1] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 3 " 2:" +FIELD PIEDE[ 2] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 4 " 3:" +FIELD PIEDE[ 3] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 5 " 4:" +FIELD PIEDE[ 4] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 6 " 5:" +FIELD PIEDE[ 5] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 7 " 6:" +FIELD PIEDE[ 6] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 8 " 7:" +FIELD PIEDE[ 7] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 9 " 8:" +FIELD PIEDE[ 8] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 10 " 9:" +FIELD PIEDE[ 9] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 11 "10:" +FIELD PIEDE[10] +END + +ENDPAGE + +PAGE "Tabelle di installazione" 1 1 60 2 + +GROUPBOX DLG_NULL 78 16 +BEGIN +PROMPT 0 0 "Etichette totalizzatori piede documento 2/4" +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 2 "11:" +FIELD PIEDE[11] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 3 "12:" +FIELD PIEDE[12] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 4 "13:" +FIELD PIEDE[13] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 5 "14:" +FIELD PIEDE[14] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 6 "15:" +FIELD PIEDE[15] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 7 "16:" +FIELD PIEDE[16] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 8 "17:" +FIELD PIEDE[17] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 9 "18:" +FIELD PIEDE[18] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 10 "19:" +FIELD PIEDE[19] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 11 "20:" +FIELD PIEDE[20] +END + +ENDPAGE + +PAGE "Tabelle di installazione" 1 1 60 2 + +GROUPBOX DLG_NULL 78 16 +BEGIN +PROMPT 0 0 "Etichette totalizzatori piede documento 3/4" +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 2 "21:" +FIELD PIEDE[21] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 3 "22:" +FIELD PIEDE[22] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 4 "23:" +FIELD PIEDE[23] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 5 "24:" +FIELD PIEDE[24] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 6 "25:" +FIELD PIEDE[25] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 7 "26:" +FIELD PIEDE[26] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 8 "27:" +FIELD PIEDE[27] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 9 "28:" +FIELD PIEDE[28] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 10 "29:" +FIELD PIEDE[29] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 11 "30:" +FIELD PIEDE[30] +END + +ENDPAGE + +PAGE "Tabelle di installazione" 1 1 60 2 + +GROUPBOX DLG_NULL 78 16 +BEGIN +PROMPT 0 0 "Etichette totalizzatori piede documento 4/4" +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 2 "31:" +FIELD PIEDE[31] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 3 "32:" +FIELD PIEDE[32] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 4 "33:" +FIELD PIEDE[33] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 5 "34:" +FIELD PIEDE[34] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 6 "35:" +FIELD PIEDE[35] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 7 "36:" +FIELD PIEDE[36] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 8 "37:" +FIELD PIEDE[37] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 9 "38:" +FIELD PIEDE[38] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 10 "39:" +FIELD PIEDE[39] +END + +STRING DLG_NULL 40 +BEGIN +PROMPT 2 11 "40:" +FIELD PIEDE[40] +END + +ENDPAGE + +PAGE "Tabella arrotondamenti " 1 1 60 14 + +GROUPBOX DLG_NULL 78 9 +BEGIN +PROMPT 0 0 "Dati anagrafici ditta " +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 1 "Arrot. prezzi: fino a lire " +FIELD ARRLIV[ 1 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 42 1 "" +FIELD ARRARG[ 1 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 29 2 "" +FIELD ARRLIV[ 2 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 42 2 "" +FIELD ARRARG[ 2 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 29 3 "" +FIELD ARRLIV[ 3 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 42 3 "" +FIELD ARRARG[ 3 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 29 4 "" +FIELD ARRLIV[ 4 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 42 4 "" +FIELD ARRARG[ 4 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 29 5 "" +FIELD ARRLIV[ 5 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 42 5 "" +FIELD ARRARG[ 5 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 29 6 "" +FIELD ARRLIV[ 6 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 42 6 "" +FIELD ARRARG[ 6 ] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 29 7 "oltre " +FIELD ARRARG[ 7 ] +END + +ENDPAGE + +ENDMASK diff --git a/ve/ve0200c.uml b/ve/ve0200c.uml new file mode 100755 index 000000000..b38aa2ce8 --- /dev/null +++ b/ve/ve0200c.uml @@ -0,0 +1,130 @@ +/* toolbar */ +#include "ve0200b.h" + +TOOLBAR "" 0 20 0 2 + +BUTTON DLG_OK 10 2 +BEGIN +PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 10 2 +BEGIN +PROMPT -22 -1 "" +END + +ENDPAGE + + +PAGE "Tabella gestione sconto a percentuale " 1 1 60 14 + +GROUPBOX DLG_NULL 78 9 +BEGIN +PROMPT 0 0 "Gestione spese/sconti " +END + +STRING DLG_NULL 3 +BEGIN +PROMPT 2 1 "Codice tabella sconto cliente " +FIELD SCOPRCOD +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 2 3 "Descrizione " +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 5 "Cod. contabilità " +FIELD SCOPRCODCON[1,2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 29 5 "" +FIELD SCOPRCODCON[3,4] +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 35 5 "" +FIELD SCOPRCODCON[5,10] +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 47 5 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 7 "Num. campo piede documento " +FIELD SCOPRNPIEDE +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 34 7 "" +END + +ENDPAGE + +PAGE "Tabella gestione sconto ad importo " 1 1 60 14 + +GROUPBOX DLG_NULL 78 9 +BEGIN +PROMPT 0 0 "Gestione sconto ad importo " +END + +STRING DLG_NULL 3 +BEGIN +PROMPT 2 1 "Codice tabella sconto ad importo " +FIELD SCOIMCOD +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 2 3 "Descrizione " +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 5 "Cod. contabilità " +FIELD SCOIMCODCON[1,2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 29 5 "" +FIELD SCOIMCODCON[3,4] +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 35 5 "" +FIELD SCOIMCODCON[5,10] +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 47 5 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 7 "Num. campo piede documento " +FIELD SCOIMNPIEDE +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 34 7 "" +END + +ENDPAGE + + +ENDMASK + + diff --git a/ve/ve0200d.uml b/ve/ve0200d.uml new file mode 100755 index 000000000..88588a70c --- /dev/null +++ b/ve/ve0200d.uml @@ -0,0 +1,630 @@ + +/* toolbar */ +#include "ve0200b.h" + +TOOLBAR "" 0 20 0 2 + +BUTTON DLG_OK 10 2 +BEGIN +PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 10 2 +BEGIN +PROMPT -22 -1 "" +END + +ENDPAGE + +PAGE "Tabella gestione spese d'incasso " 1 1 60 14 + +GROUPBOX DLG_NULL 78 17 +BEGIN +PROMPT 0 0 "Gestione spese d'incasso" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 1 "Addebito spese d'incasso " +FIELD SPINADD +END + +STRING DLG_NULL 3 +BEGIN +PROMPT 2 2 "Codice tabelle spese " +FIELD SPINCODSP +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 2 3 "Descrizione " +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 4 "Cod. Iva " +FIELD SPINCODIVA +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 29 4 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 5 "Cod. contabilità " +FIELD SPINCODCON[ 1,2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 29 5 "" +FIELD SPINCODCON[3,4] +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 35 5 "" +FIELD SPINCODCON[5,10] +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 47 5 "" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 6 "Incasso prima rata " +FIELD SPININCPR +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 7 "Num. campo piede documento " +FIELD SPINNPIEDE +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 34 7 "" +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 8 "Importo spese per rimesse dirette " +FIELD SPINIMRD +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 9 "Importo spese per tratte " +FIELD SPINIMTR +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 10 "Importo spese per ricevute bancarie " +FIELD SPINIMRB +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 11 "Importo spese per cessioni " +FIELD SPINIMCES +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 12 "Importo spese per pagherò " +FIELD SPINIMPAG +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 12 "Importo spese per lettere di credito " +FIELD SPINIMLET +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 13 "Importo spese per tratte accettate " +FIELD SPINIMTA +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 14 "Importo spese per R.I.D. " +FIELD SPINIMRID +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 15 "Importo spese per bonifici " +FIELD SPINIMBON +END + +ENDPAGE + +PAGE "Tabella gestione spese d'incasso " 1 1 60 14 + +GROUPBOX DLG_NULL 78 19 +BEGIN +PROMPT 0 0 "Gestione spese bolli ricevute bancarie" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 1 "Addebito spese bolli ricevute bancarie " +FIELD SPBRBADD +END + +STRING DLG_NULL 3 +BEGIN +PROMPT 2 2 "Codice tabelle spese " +FIELD SPBRBCODSP +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 2 3 "Descrizione " +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 4 "Cod. Iva " +FIELD SPBRBCODIVA +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 29 4 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 5 "Cod. contabilità " +FIELD SPBRBCODCONT[1,2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 29 5 "" +FIELD SPBRBCODCONT[3,4] +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 35 5 "" +FIELD SPBRBCODCONT[5,10] +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 47 5 "" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 6 "Incasso prima rata " +FIELD SPBRBINCPR +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 7 "Num. campo piede documento " +FIELD SPBRBNPIEDE +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 34 7 "" +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 8 "Scaglione " +FIELD SPBRBSCA[1] +END + +NUMBER DLG_NULL 6 +BEGIN +PROMPT 25 8 "Importo " +FIELD SPBRBIMP[1] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 9 "Scaglione " +FIELD SPBRBSCA[2] +END + +NUMBER DLG_NULL 6 +BEGIN +PROMPT 25 9 "Importo " +FIELD SPBRBIMP[2] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 10 "Scaglione " +FIELD SPBRBSCA[3] +END + +NUMBER DLG_NULL 6 +BEGIN +PROMPT 25 10 "Importo " +FIELD SPBRBIMP[3] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 11 "Scaglione " +FIELD SPBRBSCA[4] +END + +NUMBER DLG_NULL 6 +BEGIN +PROMPT 25 11 "Importo " +FIELD SPBRBIMP[4] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 12 "Scaglione " +FIELD SPBRBSCA[5] +END + +NUMBER DLG_NULL 6 +BEGIN +PROMPT 25 12 "Importo " +FIELD SPBRBIMP[5] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 13 "Scaglione " +FIELD SPBRBSCA[6] +END + +NUMBER DLG_NULL 6 +BEGIN +PROMPT 25 13 "Importo " +FIELD SPBRBIMP[6] +END + +NUMBER DLG_NULL 9 +BEGIN +PROMPT 2 14 "Scaglione " +FIELD SPBRBSCA[7] +END + +NUMBER DLG_NULL 6 +BEGIN +PROMPT 25 14 "Importo " +FIELD SPBRBIMP[7] +END + +STRING DLG_NULL 5 +BEGIN +PROMPT 2 15 "Importo minimo R.B./1000 " +FIELD SPBRBIMPMINRB +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 16 "Cod. pag. alternativo " +FIELD SPBRBCODPAGALT +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 36 16 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 17 "Classif. pag. RB a richiesta " +FIELD SPBRBCLAPAGRB +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 36 17 "" +END + +ENDPAGE + +PAGE "Tabella gestione spese d'incasso " 1 1 60 14 + +GROUPBOX DLG_NULL 78 11 +BEGIN +PROMPT 0 0 "Gestione bolli fatture esenti" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 1 "Addebito bolli fatture esenti " +FIELD SPBFEADD +END + +STRING DLG_NULL 3 +BEGIN +PROMPT 2 2 "Codice tabelle spese " +FIELD SPBFECODSP +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 2 3 "Descrizione " +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 4 "Cod. Iva " +FIELD SPBFECODIVA +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 29 4 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 5 "Cod. contabilità " +FIELD SPBFECODCONT[1,2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 29 5 "" +FIELD SPBFECODCONT[3,4] +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 35 5 "" +FIELD SPBFECODCONT[5,10] +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 47 5 "" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 6 "Incasso prima rata " +FIELD SPBFEINCPR +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 7 "Num. campo piede documento " +FIELD SPBFENPIEDE +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 34 7 "" +END + +STRING DLG_NULL 9 +BEGIN +PROMPT 2 8 "Importo minimo fattura " +FIELD SPBFEIMPMINFAT +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 2 9 "Importo bollo " +FIELD SPBFEIMPBOLLO +END + +ENDPAGE + +PAGE "Tabella gestione bolli tratte Italia " 1 1 60 14 + +GROUPBOX DLG_NULL 78 14 +BEGIN +PROMPT 0 0 "Gestione bolli su tratte Italia" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 1 "Addebito bolli su tratte Italia " +FIELD SPTRADD +END + +STRING DLG_NULL 3 +BEGIN +PROMPT 2 2 "Codice tabelle spese " +FIELD SPTRCODSP +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 2 3 "Descrizione " +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 4 "Cod. Iva " +FIELD SPTRCODIVA +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 29 4 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 5 "Cod. contabilità " +FIELD SPTRCODCON[1,2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 29 5 "" +FIELD SPTRCODCON[3,4] +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 35 5 "" +FIELD SPTRCODCON[5,10] +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 47 5 "" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 6 "Incasso prima rata " +FIELD SPTRINCPR +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 7 "Num. campo piede documento " +FIELD SPTRNPIEDE +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 34 7 "" +END + +NUMBER DLG_NULL 5 2 +BEGIN +PROMPT 2 8 "Percentuale spese tratte " +FIELD SPTRPERCSPTR +END + +STRING DLG_NULL 5 +BEGIN +PROMPT 2 9 "Importo minimo bollo " +FIELD SPTRIMPMINBOL +END + +STRING DLG_NULL 5 +BEGIN +PROMPT 2 10 "Importo minimo tratte /1000 " +FIELD SPTRIMPMINTR +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 11 "Condizione pagam. alternativa " +FIELD SPTRCODPAGALT +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 42 11 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 12 "Classif. pagamento TR a richiesta " +FIELD SPTRCLASPAG +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 42 12 "" +END + +ENDPAGE + +PAGE "Tabella gestione bolli tratte estero " 1 1 60 14 + +GROUPBOX DLG_NULL 78 10 +BEGIN +PROMPT 0 0 "Gestione spese tratta estera" +END + +STRING DLG_NULL 3 +BEGIN +PROMPT 2 1 "Codice tabella spesa tratta estera " +FIELD SPTECODSP +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 2 2 "Descrizione " +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 3 "Cod. Iva " +FIELD SPTECODIVA +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 29 3 "" +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 4 "Cod. contabilità " +FIELD SPTECODCON[1,2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 29 4 "" +FIELD SPTECODCON[3,4] +END + +STRING DLG_NULL 6 +BEGIN +PROMPT 35 4 "" +FIELD SPTECODCON[5,10] +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 47 4 "" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 5 "Incasso prima rata " +FIELD SPTEINCPR +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 2 6 "Num. campo piede documento " +FIELD SPTENPIEDE +END + +STRING DLG_NULL 26 +BEGIN +PROMPT 34 6 "" +END + +NUMBER DLG_NULL 5 2 +BEGIN +PROMPT 2 7 "Percentuale spese tratte " +FIELD SPTEPERCSPTR +END + +STRING DLG_NULL 5 +BEGIN +PROMPT 2 8 "Importo minimo bollo " +FIELD SPTEIMPMINBOL +END + +ENDPAGE + +ENDMASK + + diff --git a/ve/ve0200e.uml b/ve/ve0200e.uml new file mode 100755 index 000000000..708f0a605 --- /dev/null +++ b/ve/ve0200e.uml @@ -0,0 +1,305 @@ +/* toolbar */ +#include "ve0200b.h" + +TOOLBAR "" 0 20 0 2 + +BUTTON DLG_OK 10 2 +BEGIN +PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 10 2 +BEGIN +PROMPT -22 -1 "" +END + +ENDPAGE + +PAGE "Tabella descrizione codice articolo " 1 1 60 14 + +GROUPBOX DLG_NULL 78 18 +BEGIN +PROMPT 0 0 "Personalizzazione procedura" +END + +TEXT DLG_NULL +BEGIN +PROMPT 2 1 "Descr. Cod. " +END + +TEXT DLG_NULL +BEGIN +PROMPT 14 1 "Descrizione " +END + +TEXT DLG_NULL +BEGIN +PROMPT 48 1 "Lungh. campi " +END + +TEXT DLG_NULL +BEGIN +PROMPT 63 1 "Tipo campi " +END + +TEXT DLG_NULL +BEGIN +PROMPT 2 2 "Cod. art. " +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 14 2 "" +FIELD CODARTDES +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 48 2 "" +FIELD CODARTLUN[1] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 52 2 "" +FIELD CODARTLUN[2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 56 2 "" +FIELD CODARTLUN[3] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 63 2 "" +FIELD CODARTPIC[1] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 67 2 "" +FIELD CODARTPIC[2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 71 2 "" +FIELD CODARTPIC[3] +END + +TEXT DLG_NULL +BEGIN +PROMPT 2 3 "I° indice " +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 14 3 "" +FIELD INDARTDES[1] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 48 3 "" +FIELD INDARTLUN[1] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 63 3 "" +FIELD INDARTPIC[1] +END + +TEXT DLG_NULL +BEGIN +PROMPT 2 4 "II° indice " +END + +STRING DLG_NULL 30 +BEGIN +PROMPT 14 4 "" +FIELD INDARTDES[2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 48 4 "" +FIELD INDARTLUN[2] +END + +STRING DLG_NULL 2 +BEGIN +PROMPT 63 4 "" +FIELD INDARTPIC[2] +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 6 "Gestione articoli in lingua " +FIELD ARTGESLIN +END + +NUMBER DLG_NULL 1 +BEGIN +PROMPT 5 7 "Codice lingua n.1 " +FIELD ARTCODLIN[1] +END + +NUMBER DLG_NULL 1 +BEGIN +PROMPT 5 8 "Codice lingua n.2 " +FIELD ARTCODLIN[2] +END + +NUMBER DLG_NULL 1 +BEGIN +PROMPT 5 9 "Codice lingua n.3 " +FIELD ARTCODLIN[3] +END + +NUMBER DLG_NULL 1 +BEGIN +PROMPT 5 10 "Codice lingua n.4 " +FIELD ARTCODLIN[4] +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 11 "Gestione più magazzini " +FIELD ARTGESMAG +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 12 "Gestione depositi " +FIELD ARTGESDEP +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 13 "Gestione commesse " +FIELD ARTGESCOMM +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 14 "Gestione quantità in decimali " +FIELD ARTGESQDEC +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 15 "Gestione valuta " +FIELD ARTGESVAL +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 16 "Ripetizione primo indice " +FIELD ARTRIPIND +END + +ENDPAGE + +PAGE "Tabella personalizzazione anagrafico articoli " 1 1 60 14 + +GROUPBOX DLG_NULL 78 18 +BEGIN +PROMPT 0 0 "Gestione archivio articoli" +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 1 "Gestione descrizioni estese " +FIELD ARTGESDESCEST +END + +LIST DLG_NULL 35 +BEGIN +PROMPT 2 2 "Gestione art. per lotti " +ITEM "N|Non gestire" +ITEM "D|Gestiti con lotto data " +ITEM "Q|Gestiti con lotto descr. qualità " +FIELD ARTGESLOTTI +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 3 "Gestione articoli per taglia " +FIELD ARTGESTAGLIA +END + +STRING DLG_NULL 10 +BEGIN +PROMPT 2 4 "Descrizione campi chiave " +FIELD ARTDESCHI[1] +END + +STRING DLG_NULL 10 +BEGIN +PROMPT 2 5 "Descrizione campi chiave " +FIELD ARTDESCHI[2] +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 6 "Gestione più unità di misura " +FIELD ARTGESUM +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 7 "Gestione secondo codice iva " +FIELD ARTGESCODIVA +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 8 "Gestione campi peso lordo/netto " +FIELD ARTGESPLN +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 9 "Gestione campo aspetto dei beni " +FIELD ARTGESASPBEN +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 10 "Gestione campo codice gruppo articolo " +FIELD ARTGESCODGR +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 11 "Gestione campo distinta base " +FIELD ARTGESDB +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 12 "Gestione campo categorie vendite " +FIELD ARTGESCATVEN +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 13 "Gestione campo categorie acquisti " +FIELD ARTGESCATACQ +END + +BOOLEAN DLG_NULL +BEGIN +PROMPT 2 14 "Gestione codice fornitore " +FIELD ARTGESCODFOR +END + +ENDPAGE + + +ENDMASK + + diff --git a/ve/ve0300.cpp b/ve/ve0300.cpp index d6c6c0d05..0e4d140c7 100755 --- a/ve/ve0300.cpp +++ b/ve/ve0300.cpp @@ -1,1213 +1,1227 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - "Compilatore di profili" per la gestione vendite. - Considerando: - - Profilo documento - - Configurazione vendite per la ditta - - Condizioni atmosferiche - genera le maschere appropriate. - Accetta sulla riga di comando il nome del profilo documento per cui deve generare - la maschera. Il nome del file .MSK viene dedotto dal profilo documento stesso. - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef __CHECKS_H -#include -#endif - -#ifndef __FSTREAM_H -#include -#endif - -#ifndef __SCANNER_H -#include -#endif - -#ifndef __CONFIG_H -#include -#endif - -#ifndef __APPLICATION_H -#include -#endif - -#ifndef __UTILITY_H -#include -#endif - -#ifndef __DEFMASK_H -#include -#endif - -#ifndef __VE0100_H -#include "ve0100.h" -#endif - -#ifndef __VEUML_H -#include "veuml.h" -#endif - -#ifndef __LFFILES_H -#include "lffiles.h" -#endif - -#ifndef __VEINI_H -#include "veini.h" -#endif - -// Significato delle colonne nella tabella _tab0300b -#define B_NOME 0 -#define B_MSKTYPE 1 -#define B_MSKSIZE 2 -#define B_DESCR 3 -#define B_WIDTH 4 - -// Significato dei campi nel profilo del documento -#define P_STATO 0 -#define P_PROMPT 1 -#define P_HELP 2 -#define P_WARNING 3 - - -// Numero massimo di linee per pagina - -#define MAX_LINES_PER_PAGE 16 -#define MASK_FIRST_LINE 6 - -class TMaschera : public TObject -{ - -private: - - // Linea corrente - int _curline; - - // Pagina corrente - int _curpage; - -public: - - void advance_line( ){ _curline ++; }; - - // Genera 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 ); - - // CHECKTYPE - void check( const int i ); - - // PAGE - void pagina( const int i ){ _out << "PA \"Pagina " << i << "\" 11 60 14\n"; }; - - // PROMPT - void prompt( const int x, const int y, const TString& s = "" ){ _out << "PR " << x << " " << y << " \"" << s << "\"\n"; }; - - // BEGIN - void begin( void ) { outline ( "BE" ); }; - - // END - void end( void ) { outline ( "EN" ); }; - - // ENDMASK - void endmask( void ) { outline ( "ENDMASK" ); }; - - // FLAG - void flag( const TString& s ) { _out << "FLAG \"" << s << "\"\n"; }; - - // HELP - void help( const TString& s ) { _out << "HE \"" << s << "\"\n"; }; - - // WARNING - void warning( const TString& s ) { _out << "WA \"" << s << "\"\n"; }; - - // GROUP - void group( const int g ) { _out << "GR " << g << "\n"; }; - - // FIELD - void field( const TString& s ) { outline( s, "FI "); }; - - // ITEM - void item( const TString& s ); - - // MESSAGE - void message( const TString& s ) { outline( s, "ME "); }; - - // USE - void use( const TString& s ){ outline( s, "US " ); }; - void use( const int file, const int key ){ _out << "US " << file << " KEY " << key << "\n"; }; - - // DISPLAY - void display( const TString& s ){ outline( s, "DI " ); }; - - // INPUT - void input( const TString& s ){ outline( s, "IN " ); }; - - // OUTPUT - void output( const TString& s ){ outline( s, "OU " ); }; - - // Funzioni per la lettura/scrittura di CURPAGE - int page( ) { return _curpage; }; - void page( const int i ){ _curpage = i; }; - - // Funzioni per la lettura/scrittura di CURLINE - int line( ) { return _curline; }; - void line( const int i ){ _curline = i; }; - - // Costruttore, vuole il nome del file .INI - TMaschera( const TFilename outfile ); - - // Vero se la pagina è aperta - bool _pageopen; - - // File .MSK di output - ofstream _out; - - -}; - - -TMaschera::TMaschera( const TFilename outfile ) : _out( outfile ) -{ - _curline = 1; - _curpage = 1; - _pageopen = FALSE; - bool _groupopen = FALSE; -} - -void TMaschera::outline( const TString& s, const TString& prefix, const char sep ) -{ - if ( s.left( 1 ) == "@" ) - _out << "CO " << prefix << s.mid( 1 ) << "\n"; - else - { TToken_string u( s, sep ); - for ( int i = 0; i < u.items(); i ++ ) - _out << prefix << u.get( i ) << "\n"; - } -} - -void TMaschera::check( const int i ) -{ - switch( i ) - { - case S_OBBLIGATORIO: - outline ( "CH REQUIRED" ); - break; - default: - outline ( "CH NORMAL" ); - break; - } -} - -void TMaschera::control( const int type, const int id, const int size ) -{ - switch ( type ) - { - case T_DATA: - _out << "DA"; - break; - case T_STRINGA: - _out << "ST"; - break; - case T_CHECKBOX: - _out << "BO"; - break; - case T_NUMERO: - _out << "NU"; - break; - case T_LISTA: - _out << "LI"; - break; - case T_MEMO: - _out << "ME"; - break; - case T_CORNICE: - _out << "GR"; - break; - case T_BOTTONE: - _out << "BU"; - break; - } - _out << " " << id; - if ( size > 0 ) - { - if ( size > 100 ) - _out << " " << ( int )( size / 100 ) << " " << ( size % 100 ); - else - _out << " " << size; - } - _out << "\n"; -} - -void TMaschera::item( const TString& str ) -{ - int i, j; - TToken_string u( str, '@' ); - TToken_string s; - - for( i = 0; i < u.items(); i ++ ) - { - _out << "IT \"" << s[ 0 ] << "\"\n"; - for( j = 1; j < s.items(); j ++ ) - _out << "ME " << s[ j ] << "\n"; - } -} - -class TGruppo : public TObject -{ -protected: - - int _id; - int _height; - bool _present; - -public: - - void id( int id ){ _id = id; } - int id( ){ return _id; } - void height( int h ){ _height = h; } - int height( ){ return _height; } - void present( bool p ){ _present = p; } - bool present( ){ return _present; } - - TGruppo ( int i ); - TGruppo ( int i, TConfig& pro ); -}; - -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 -{ -protected: - - TString _nome; - int _gruppo; - int _id; - int _type; - int _size; - int _stato; - int _x, _y; - TString _prompt, _flag, _help, _warning, _fieldname; - TToken_string _use, _input, _display, _output, _special, _items, _configs; - -public: - - TField( TString& campo, TConfig& pro ); - TField( ); - - void genera( TMaschera& _m ); - void configura( TConfig& pro ); - - void x( int x ){ _x = x; } - void y( int y ){ _y = y; } - void gruppo( int gruppo ){ _gruppo = gruppo; } - void id( int id ){ _id = id; } - void type( int type ){ _type = type; } - void size( int size ){ _size = size; } - void stato( int stato ){ _stato = stato; } - int x( ){ return _x; } - int y( ){ return _y; } - int gruppo( ){ return _gruppo; } - int id( ){ return _id; } - int type( ){ return _type; } - int size( ){ return _size; } - int stato( ){ return _stato; } - - - void nome( TString& nome ){ _nome = nome; } - void prompt( TString& prompt ){ _prompt = prompt; } - void flag( TString& flag ){ _flag = flag; } - void help( TString& help ){ _help = help; } - void warning( TString& warning ){ _warning = warning; } - void fieldname( TString& fieldname ){ _fieldname = fieldname; } - TString& nome( ){ return _nome; } - TString& prompt( ){ return _prompt; } - TString& flag( ){ return _flag; } - TString& help( ){ return _help; } - TString& warning( ){ return _warning; } - TString& fieldname( ){ return _fieldname; } - - void use( TToken_string& use ){ _use = use; } - void input( TToken_string& input ){ _input = input; } - void display( TToken_string& display ){ _display = display; } - void output( TToken_string& output ){ _output = output; } - void special( TToken_string& special ){ _special = special; } - void items( TToken_string& items ){ _items = items; } - void configs( TToken_string& configs ){ _configs = configs; } - TToken_string& use( ){ return _use; } - TToken_string& input( ){ return _input; } - TToken_string& display( ){ return _display; } - TToken_string& output( ){ return _output; } - TToken_string& special( ){ return _special; } - TToken_string& items( ){ return _items; } - TToken_string& configs( ){ return _configs; } - - - 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 ) -{ - int g1 = ((TField * )( *o1 ))->_gruppo; - int g2 = ((TField * )( *o2 ))->_gruppo; - return ( g1 < g2 ) ? -1 : ( ( g1 = g2 ) ? 0 : 1 ); -}; - -TField::TField( TString& campo, TConfig& pro ) : _nome( campo ) -{ - _nome.trim( ); - _fieldname = pro.get( "FIELDNAME", campo ); - _x = _gruppo = pro.get_int( "X", campo ); - _y = _gruppo = pro.get_int( "Y", campo ); - _gruppo = pro.get_int( "GROUP", campo ); - CHECK( _gruppo != 0, "Gruppo uguale a 0" ); - _id = pro.get_int( "MSKID", campo ); - CHECK( _id != 0, "Campo con MSKID uguale a 0" ); - _type = pro.get_int( "TYPE", campo ); - _size = pro.get_int( "SIZE", campo ); - _prompt = pro.get( "PROMPT", campo ); - if( _prompt[ 0 ] == '\"' ) - { - _prompt.ltrim( 1 ); - _prompt.rtrim( 1 ); - }; - _flag = pro.get( "FLAG", campo ); - _help = pro.get( "FLAG", campo ); - _warning = pro.get( "FLAG", campo ); - _use = pro.get( "USE", campo ); - _use.separator( '~' ); - _input = pro.get( "INPUT", campo ); - _input.separator( '~' ); - _display = pro.get( "DISPLAY", campo ); - _display.separator( '~' ); - _output = pro.get( "OUTPUT", campo ); - _output.separator( '~' ); - _special = pro.get( "SPECIAL", campo ); - _special.separator( '~' ); - _configs = pro.get( "CONFIGS", campo ); - _configs.separator( '~' ); - _items = ""; - int last = pro.get_int( "NITEMS", campo ); - for( int i = 1; i <= last; i ++ ) - _items.add( pro.get( "ITEM", campo, i ) ); -}; - -TField::TField( ) -{ - _nome = ""; - _fieldname = ""; - _x = 0; - _y = 0; - _gruppo = 0; - _id = 0; - _type = 0; - _size = 0; - _prompt = ""; - _flag = ""; - _help = ""; - _warning = ""; - _use = ""; - _use.separator( '~' ); - _input = ""; - _input.separator( '~' ); - _display = ""; - _display.separator( '~' ); - _output = ""; - _output.separator( '~' ); - _special = ""; - _special.separator( '~' ); - _configs = ""; - _configs.separator( '~' ); - _items = ""; - _items.separator( '@' ); -} - -void TField::configura( TConfig& pro ) -{ - TToken_string riga_profilo( pro.get( _nome, "PROFILO" ) ); - TString newprompt( riga_profilo.get( P_PROMPT ) ) ; - TString newhelp( riga_profilo.get( P_HELP ) ) ; - TString newwarning( riga_profilo.get( P_WARNING ) ) ; - if ( ! newprompt.blank( ) ) - _prompt = newprompt; - if ( ! newhelp.blank( ) ) - _help = newhelp; - if ( ! newwarning.blank( ) ) - _warning = newwarning; -} - -void TField::genera( TMaschera& m ) -{ - TString s; - - if ( _stato == S_NASCOSTO ) - return; - if ( _size != 0 ) - m.control( _type, _id, _size ); - else - m.control( _type, _id ); - m.begin(); - switch( _stato ) - { - case S_DISABILITATO : - m.prompt( _x, _y + m.line( ), _prompt ); - s = "D"; - s << _flag; - m.flag( s ) ; - break; - case S_NORMALE : - case S_OBBLIGATORIO : - m.prompt( _x, _y + m.line( ), _prompt ); - m.flag( _flag ); - break; - } - m.check( _stato ); - if ( !_fieldname.blank( ) ) m.field( _fieldname ); - if ( !_items.blank( ) ) m.item( _items ); - if ( !_use.blank( ) ) m.use( _use ); - if ( !_input.blank( ) ) m.input( _input ); - if ( !_display.blank( ) ) m.display( _display ); - if ( !_output.blank( ) ) m.output( _output ); - if ( !_help.blank( ) ) m.help( _help ); - if ( !_warning.blank( ) ) m.warning( _warning ); - if ( !_special.blank( ) ) m.outline( _special ); - m.end(); - if ( ( m.line() > MAX_LINES_PER_PAGE ) && ( m._pageopen == TRUE)) - { - m.end(); - m._pageopen = FALSE; - m.line( MASK_FIRST_LINE ); - } -} - - -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; - -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( ); - - // Distruttore - virtual ~TMask_generator( ); - -}; - -// Definizione dei metodi di TMask_generator -// ----------------------------------------- - -TMask_generator::TMask_generator( const TString& profilo ) : _proname( profilo ), _fieldsini( "ve0300a.ini" ), _groupsini( "ve0300c.ini" ), _ditta( CONFIG_DITTA ) -{ - // All'inizio il gruppo è 'chiuso' - _groupopen = FALSE; - - // Forza l'estensione al profilo - _proname.ext( "ini" ); - - // Se il file di profilo non esiste, esci con un errore fatale - if ( !fexist( _proname ) ) - fatal_box( "Il file %s non esiste!", ( const char * )_proname ); - - CHECK( fexist( "ve0300a.ini" ), "Il file ve0300a.ini non esiste!" ); - _fieldsini.list_paragraphs( _fields ); - CHECK( fexist( "ve0300b.dat" ), "Il file ve0300b.dat non esiste!" ); - carica_tabella( "ve0300b.dat", _tab0300b ); - - _pro = new TConfig( _proname ); - - TFilename _mskname( _pro->get( "MSKFILE", "MAIN") ); - _mskname.ext( "msk" ); - - - _m = new TMaschera( _mskname ); - -}; - -TMask_generator::~TMask_generator( ) -{ - delete _m; - delete _pro; -}; - - -void TMask_generator::carica_dati_campi( const TFilename& fn, TArray& a ) -{ - TScanner infile( fn ); - TString line; - TField *campo = NULL; - - while ( infile.ok( ) ) - { - line = infile.line( ); - line.trim( ); - while ( ( line.empty() || line[ 0 ] == '#' || line.left( 2 ) == "//" ) && infile.ok( ) ) - { - line = infile.line( ); - line.trim(); - } - if( infile.ok( ) ) - { - if ( line[ 0 ] == '[' ) // Carica un un campo - { - line.strip( "[]" ); - if ( campo ) - a.add( campo ); - campo = new TField(); - campo->nome( line ); - } - else - { - int pos; - if( ( pos = line.find( '=' ) ) == 0 ) - yesnofatal_box( "Linea errata nel file.INI: %s", (const char *) line ); - else - { - TString key = line.sub( 0, pos ); - key.trim(); - TString value = line.mid( pos + 1 ); - value.trim(); - if( key == "X" ) - campo->x( atoi( value ) ); - else if( key == "Y" ) - campo->y( atoi( value ) ); - else if( key == "GROUP" ) - campo->gruppo( atoi( value ) ); - else if( key == "FIELDNAME" ) - campo->fieldname( value ); - else if( key == "MSKID" ) - campo->id( atoi( value ) ); - else if( key == "TYPE" ) - campo->type( atoi( value ) ); - else if( key == "SIZE" ) - campo->size( atoi( value ) ); - else if( key == "PROMPT" ) - { - if( value[ 0 ] == '"' ) - { - value.rtrim( 1 ); - value.ltrim( 1 ); - }; - campo->prompt( value ); - } - else if( key == "FLAG" ) - campo->flag( value ); - else if( key == "USE" ) - campo->use( (TToken_string & ) value ); - else if( key == "INPUT" ) - campo->input( (TToken_string & )value ); - else if( key == "DISPLAY" ) - campo->display( (TToken_string & )value ); - else if( key == "OUTPUT" ) - campo->output( (TToken_string & )value ); - else if( key == "WARNING" ) - campo->warning( value ); - else if( key == "HELP" ) - campo->help( value ); - else if( key == "SPECIAL" ) - campo->special( (TToken_string & )value ); - else if( key == "ITEMS" ) - campo->items( (TToken_string & )value ); - else if( key == "CONFIGS" ) - campo->configs( (TToken_string & )value ); - else yesnofatal_box( "Chiave non trovata(%s)", (const char *) key ); - } - } - } - } - if ( campo ) - a.add( campo ); -} - -void TMask_generator::carica_tabella( const TFilename& fn, TString_array& tabella ) -{ TScanner in( fn ); - TToken_string line = in.line(); - while( line.not_empty( ) ) - { // Attacca tutte le righe che finiscono con § - while ( line.right( 1 ) == "§" ) - { line.rtrim( 1 ); - line << in.line( ); - }; - tabella.add( 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 ) -{ - const int type( _line.get_int( B_MSKTYPE ) ); - _m->control( type, id( ), _line.get_int( B_MSKSIZE ) ); - _m->begin( ); - _m->prompt( 2, 2 ); - _m->field( _line.get( B_NOME ) ); - _m->end( ); -} - -void TMask_generator::genera_item_sheet( TToken_string _line ) -{ - _m->_out << "IT \"" << _line.get( B_DESCR ); - _m->_out << "@" << _line.get_int( B_WIDTH ) << "\"\n"; -} - -void TMask_generator::intestazione_pagina( ) -{ - _m->page( _m->page( ) + 1 ); - _m->pagina( _m->page( ) ); - - _m->control( T_CORNICE, DLG_NULL, 7806 ); - _m->begin( ); - _m->prompt( 1, 0, "" ); - _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->begin(); - _m->prompt( 24, 1 ); - _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->group( 5 ); - _m->end(); - - _m->control( T_NUMERO, DLG_NULL, 6 ); - _m->begin(); - _m->prompt( 2, 3, "Doc.: nr. " ); - _m->group( 6 ); - _m->flag( "D" ); - _m->end(); - - _m->control( T_DATA ); - _m->begin(); - _m->prompt( 24, 3, "Data " ); - _m->group( 7 ); - _m->flag( "D" ); - _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->begin(); - _m->prompt( 24, 4, "" ); - _m->flag( "D" ); - _m->group( 11 ); - _m->end(); - -} - -void TMask_generator::genera( ) -{ - int i; - TString temp_s; - - - // Definizione della toolbar - - - _m->outline( "TOOLBAR \"\" 0 20 0 2" ); - - _m->control( T_BOTTONE, 18, 802 ); - _m->begin(); - _m->prompt( -15, -1, "~Registra" ); - _m->message( "EXIT,20082" ); - _m->end(); - - _m->control( T_BOTTONE, 17, 802 ); - _m->begin(); - _m->prompt( -25, -1, "~Elimina" ); - _m->message( "EXIT,127" ); - _m->end(); - - _m->control( T_BOTTONE, 99, 802 ); - _m->begin(); - _m->prompt( -35, -1, "E~labora" ); - _m->message( "EXIT,345" ); - _m->end(); - - _m->control( T_BOTTONE, 24, 802 ); - _m->begin(); - _m->prompt( -45, -1 ); - _m->message( "EXIT,346" ); - _m->end(); - - _m->control( T_BOTTONE, 2, 802 ); - _m->begin(); - _m->prompt( -55, -1 ); - _m->message( "EXIT,27" ); - _m->end(); - - // End della toolbar - _m->end(); - - - // Header della prima pagina - - _m->outline( "PA \"Pagina \" 11 60 14" ); - - _m->control( T_CORNICE, DLG_NULL, 7806 ); - _m->begin( ); - _m->prompt( 1, 0, "" ); - _m->end( ); - - _m->control( T_STRINGA, F_CODNUM, 4 ); - _m->begin(); - _m->prompt( 2, 1, "Cod. num. " ); - _m->field( "CODNUM" ); - _m->flag( "GDUZ" ); - _m->message( "CO,2@" ); - _m->end(); - - _m->control( T_STRINGA, F_DESNUM, 50 ); - _m->begin(); - _m->prompt( 24, 1 ); - _m->flag( "GDU" ); - _m->message( "CO,3@" ); - _m->end(); - - _m->control( T_STRINGA, F_TIPODOC, 4 ); - _m->begin(); - _m->prompt( 2, 2, "Tipo doc. " ); - _m->flag( "GDU" ); - _m->message( "CO,4@" ); - _m->end(); - - _m->control( T_STRINGA, F_TIPOCF, 1 ); - _m->begin(); - _m->prompt( 2, 2, "Tipo CF " ); - _m->field( "TIPOCF" ); - _m->flag( "H" ); - _m->end(); - - _m->control( T_STRINGA, F_PROVV, 1 ); - _m->begin(); - _m->prompt( 2, 2, "

" ); - _m->field( "PROVV" ); - _m->flag( "H" ); - _m->end(); - - - _m->control( T_STRINGA, F_DESTIPODOC, 50 ); - _m->begin(); - _m->prompt( 24, 2 ); - _m->flag( "GDU" ); - _m->message( "CO,5@" ); - _m->end(); - - _m->control( T_NUMERO, F_NDOC, 6 ); - _m->begin(); - _m->prompt( 2, 3, "Doc.: nr. " ); - _m->field( "NDOC" ); - _m->message( "CO,6@" ); - _m->flag( "GDR" ); - _m->end(); - - _m->control( T_DATA, F_DATADOC ); - _m->begin(); - _m->prompt( 24, 3, "Data " ); - _m->field( "DATADOC" ); - _m->message( "CO,7@" ); - _m->flag( "A" ); - _m->end(); - - _m->control( T_NUMERO, F_STATO, 1 ); - _m->begin(); - _m->prompt( 50, 3, "Stato " ); - _m->field( "STATO" ); - _m->message( "CO,8@" ); - _m->flag( "D" ); - _m->end(); - - _m->control( T_STRINGA, F_ANNO, 4 ); - _m->begin(); - _m->prompt( 66, 3, "Es. " ); - _m->field( "ANNO" ); - _m->flag( "GD" ); - _m->message( "CO,9@" ); - _m->end(); - - _m->control( T_STRINGA, F_CODCF, 6 ); - _m->begin(); - if ( _pro->get( "TIPOCF", "MAIN" ) == "C" ) - { - _m->prompt( 2, 4, "Cliente " ); - _m->warning( "Cliente assente" ); - _m->help( "Codice del cliente del documento" ); - - } - else - { - _m->prompt( 2, 4, "Fornitore " ); - _m->warning( "Fornitore assente" ); - _m->help( "Codice del fornitore del documento" ); - } - _m->flag( "R" ); - _m->field( "CODCF" ); - _m->group( 1 ); - _m->use( LF_CLIFO, 1 ); - temp_s.format( "TIPOCF \"C\"~CODCF %d", F_CODCF); - _m->input( temp_s ); - _m->display( "\"Codice\" CODCF~\"Ragione Sociale@50\" RAGSOC~\"Partita IVA@12\" PAIV~\"Sospeso\" SOSPESO" ); - temp_s.format( "%d CODCF~%d RAGSOC", F_CODCF, F_DESCF ); - _m->output( temp_s ); - _m->check( S_OBBLIGATORIO ); - _m->outline( "ADD RU cg0 -1 C" ); - _m->end(); - - _m->control( T_STRINGA, F_DESCF, 50 ); - _m->begin( ); - if ( _pro->get( "TIPOCF", "MAIN" ) == "C" ) - { - _m->warning( "Cliente assente" ); - _m->help( "Ragione sociale del cliente del documento" ); - - } - else - { - _m->warning( "Fornitore assente" ); - _m->help( "Ragione sociale del fornitore del documento" ); - } - _m->prompt( 24, 4, "" ); - _m->group( 1 ); - _m->use( LF_CLIFO, 2 ); - temp_s.format( "TIPOCF \"C\"~RAGSOC %d", F_DESCF); - _m->input( temp_s ); - _m->display( "\"Ragione Sociale@50\" RAGSOC~\"Partita IVA@12\" PAIV~\"Codice\" CODCF" ); - temp_s.format( "%d CODCF~%d RAGSOC", F_CODCF, F_DESCF ); - _m->output( temp_s ); - _m->check( S_OBBLIGATORIO ); - _m->outline( "ADD RU cg0 -1 C" ); - _m->end(); - _m->line( MASK_FIRST_LINE ); - - // Generazione - - // Scorro l'array dei campi, per vedere gli stati ed i gruppi - - TArray campi; - TAssoc_array gruppi; - - carica_dati_campi( "ve0300a.ini", campi ); - int last = campi.items( ); - for( i = 0; i < last; i ++ ) - { - TString nome = (( TField & )campi[ i ]).nome( ); - int stato = stato_del_campo( nome ); - if( stato != S_NASCOSTO ) - { - const int addgruppo = (( TField & )campi[ i ]).gruppo( ); - TString16 chiave; - chiave.format( "%5d", addgruppo ); - if ( !gruppi.is_key( chiave ) ) - gruppi.add( chiave, new TGruppo( addgruppo, _groupsini ) ); - } - (( TField & )campi[ i ]).stato( stato ); - }; - campi.sort( sort_by_group ); - - // Generazione vera e propria - _m->_pageopen = TRUE; - last = campi.items( ); - int curgruppo = 0; - for( i = 0; i < last; i ++ ) - { - if ( _m->_pageopen == FALSE) - { - intestazione_pagina( ); - _m->_pageopen = TRUE; - } - TField& campo = ( TField& ) campi[ i ]; - if ( campo.gruppo( ) != curgruppo ) - { - TString16 chiave; - chiave.format( "%5d", campo.gruppo( ) ); - if ( gruppi.is_key( chiave ) ) - { - TGruppo& gruppo = ( TGruppo& ) gruppi[ chiave ]; - if ( _m->line( ) + gruppo.height( ) > MAX_LINES_PER_PAGE ) - { - _m->end( ); - intestazione_pagina( ); - _m->line( MASK_FIRST_LINE ); - } - else - { - TString16 vecchiachiave; - vecchiachiave.format( "%5d", curgruppo ); - if ( gruppi.is_key( vecchiachiave ) ) - { - _m->line( _m->line( ) + ( ( TGruppo& ) gruppi[ vecchiachiave ]).height( ) ); - } - } - }; - curgruppo = campo.gruppo( ); - }; - campo.configura( *_pro ); - campo.genera( *_m ); - } - if ( _m->_pageopen == TRUE ) _m->end( ); - intestazione_pagina( ); - - // Generazione del listbox per i tipi di riga da aggiungere nello sheet - _m->control ( T_LISTA, F_LBTIPORIGA, 30 ); - _m->begin(); - _m->prompt( 2, 7, "Tipo riga da aggiungere " ); - _m->end( ); - - // Generazione dello sheet : vedi il profilo - TScanner sheet_in( "ve0300b.dat" ); - _m->_out << "SPREADSHEET " << F_SHEET << "\n"; - _m->begin(); - _m->prompt( 2, 8 ); - for( i = 0; i < _tab0300b.items( ); i ++ ) - genera_item_sheet( _tab0300b.row( i ) ); - _m->end(); - _m->end(); - - // Generazione pagina dei piedi - TToken_string s(_pro->get( "PROGPIEDE", "MAIN" ) ); - if ( s.not_empty() ) - { - intestazione_pagina( ); - int cp = 1; - int piede = s.get_int();; - while ( piede != 0 ) - { - _m->control( T_NUMERO, BASE_PIEDE + cp, 1805 ); - _m->begin(); - TString header = _ditta.get( "PIEDE", "ve", piede ); - while( header.len() < 40 ) header << " "; - _m->prompt( 2, 7 + cp, header ); - _m->flag( "D" ); - _m->end(); - cp ++; - piede = s.get_int(); - } - _m->end(); - }; - _m->endmask( ); - - // Stategia al 30/06/95 - // Creo una maschera con tutte le colonne, poi, a RUNTIME, - // dal motore, nascondo e adatto le colonne. - - // Generazione maschera dello sheet - _m->_out << "PA \"Pagina 1\" 8 5 64 13\n"; - - id( 101 ); - for( i = 0; i < _tab0300b.items( ); i ++ ) - genera_campo_sheet( _tab0300b.row( i ) ); - _m->end(); - _m->end(); - _m->endmask( ); -} - - -// Applicazione guscio - -class TGenMask_application : public TApplication -{ - -protected: - - virtual bool create( ); - virtual bool menu( MENU_TAG _m ); - -}; - - -bool TGenMask_application::menu(MENU_TAG _m) -{ - TMask_generator a( argv( 2 ) ); - a.genera( ); - return( TRUE ); -}; - -bool TGenMask_application::create( ) -{ - TApplication::create(); - menu( 0 ); - return FALSE; -}; - -int ve0300( int argc, char** argv ) -{ - - if ( argc < 3 ) - fatal_box( "Sintassi: VE0 -3 " ); - - TGenMask_application a; - a.run ( argc, argv, "Generazione in corso ..." ); - return 0; -} +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + "Compilatore di profili" per la gestione vendite. + Considerando: + - Profilo documento + - Configurazione vendite per la ditta + - Condizioni atmosferiche + genera le maschere appropriate. + Accetta sulla riga di comando il nome del profilo documento per cui deve generare + la maschera. Il nome del file .MSK viene dedotto dal profilo documento stesso. + + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef __CHECKS_H +#include +#endif + +#ifndef __FSTREAM_H +#include +#endif + +#ifndef __SCANNER_H +#include +#endif + +#ifndef __CONFIG_H +#include +#endif + +#ifndef __APPLICATION_H +#include +#endif + +#ifndef __UTILITY_H +#include +#endif + +#ifndef __DEFMASK_H +#include +#endif + +#ifndef __VE0100_H +#include "ve0100.h" +#endif + +#ifndef __VEUML_H +#include "veuml.h" +#endif + +#ifndef __VEUML1_H +#include "veuml1.h" +#endif + +#ifndef __LFFILES_H +#include "lffiles.h" +#endif + +#ifndef __VEINI_H +#include "veini.h" +#endif + +// Significato delle colonne nella tabella _tab0300b +#define B_NOME 0 +#define B_MSKTYPE 1 +#define B_MSKSIZE 2 +#define B_DESCR 3 +#define B_WIDTH 4 + +// Significato dei campi nel profilo del documento +#define P_STATO 0 +#define P_PROMPT 1 +#define P_HELP 2 +#define P_WARNING 3 + + +// Numero massimo di linee per pagina + +#define MAX_LINES_PER_PAGE 16 +#define MASK_FIRST_LINE 6 + +class TMaschera : public TObject +{ + +private: + + // Linea corrente + int _curline; + + // Pagina corrente + int _curpage; + +public: + + void advance_line( ){ _curline ++; }; + + // Genera 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 ); + + // CHECKTYPE + void check( const int i ); + + // PAGE + void pagina( const int i ){ _out << "PA \"Pagina " << i << "\" 11 60 14\n"; }; + + // PROMPT + void prompt( const int x, const int y, const TString& s = "" ){ _out << "PR " << x << " " << y << " \"" << s << "\"\n"; }; + + // BEGIN + void begin( void ) { outline ( "BE" ); }; + + // END + void end( void ) { outline ( "EN" ); }; + + // ENDMASK + void endmask( void ) { outline ( "ENDMASK" ); }; + + // FLAG + void flag( const TString& s ) { _out << "FLAG \"" << s << "\"\n"; }; + + // HELP + void help( const TString& s ) { _out << "HE \"" << s << "\"\n"; }; + + // WARNING + void warning( const TString& s ) { _out << "WA \"" << s << "\"\n"; }; + + // GROUP + void group( const int g ) { _out << "GR " << g << "\n"; }; + + // FIELD + void field( const TString& s ) { outline( s, "FI "); }; + + // ITEM + void item( const TString& s ); + + // MESSAGE + void message( const TString& s ) { outline( s, "ME "); }; + + // USE + void use( const TString& s ){ outline( s, "US " ); }; + void use( const int file, const int key ){ _out << "US " << file << " KEY " << key << "\n"; }; + + // DISPLAY + void display( const TString& s ){ outline( s, "DI " ); }; + + // INPUT + void input( const TString& s ){ outline( s, "IN " ); }; + + // OUTPUT + void output( const TString& s ){ outline( s, "OU " ); }; + + // Funzioni per la lettura/scrittura di CURPAGE + int page( ) { return _curpage; }; + void page( const int i ){ _curpage = i; }; + + // Funzioni per la lettura/scrittura di CURLINE + int line( ) { return _curline; }; + void line( const int i ){ _curline = i; }; + + // Costruttore, vuole il nome del file .INI + TMaschera( const TFilename outfile ); + + // Vero se la pagina è aperta + bool _pageopen; + + // File .MSK di output + ofstream _out; + + +}; + + +TMaschera::TMaschera( const TFilename outfile ) : _out( outfile ) +{ + _curline = 1; + _curpage = 1; + _pageopen = FALSE; + bool _groupopen = FALSE; +} + +void TMaschera::outline( const TString& s, const TString& prefix, const char sep ) +{ + if ( s.left( 1 ) == "@" ) + _out << "CO " << prefix << s.mid( 1 ) << "\n"; + else + { TToken_string u( s, sep ); + for ( int i = 0; i < u.items(); i ++ ) + _out << prefix << u.get( i ) << "\n"; + } +} + +void TMaschera::check( const int i ) +{ + switch( i ) + { + case S_OBBLIGATORIO: + outline ( "CH REQUIRED" ); + break; + default: + outline ( "CH NORMAL" ); + break; + } +} + +void TMaschera::control( const int type, const int id, const int size ) +{ + switch ( type ) + { + case T_DATA: + _out << "DA"; + break; + case T_STRINGA: + _out << "ST"; + break; + case T_CHECKBOX: + _out << "BO"; + break; + case T_NUMERO: + _out << "NU"; + break; + case T_LISTA: + _out << "LI"; + break; + case T_MEMO: + _out << "ME"; + break; + case T_CORNICE: + _out << "GR"; + break; + case T_BOTTONE: + _out << "BU"; + break; + } + _out << " " << id; + if ( size > 0 ) + { + if ( size > 100 ) + _out << " " << ( int )( size / 100 ) << " " << ( size % 100 ); + else + _out << " " << size; + } + _out << "\n"; +} + +void TMaschera::item( const TString& str ) +{ + int i, j; + TToken_string u( str, '@' ); + TToken_string s; + + for( i = 0; i < u.items(); i ++ ) + { + _out << "IT \"" << s[ 0 ] << "\"\n"; + for( j = 1; j < s.items(); j ++ ) + _out << "ME " << s[ j ] << "\n"; + } +} + +class TGruppo : public TObject +{ +protected: + + int _id; + int _height; + bool _present; + +public: + + void id( int id ){ _id = id; } + int id( ){ return _id; } + void height( int h ){ _height = h; } + int height( ){ return _height; } + void present( bool p ){ _present = p; } + bool present( ){ return _present; } + + TGruppo ( int i ); + TGruppo ( int i, TConfig& pro ); +}; + +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 +{ +protected: + + TString _nome; + int _gruppo; + int _id; + int _type; + int _size; + int _stato; + int _x, _y; + TString _prompt, _flag, _help, _warning, _fieldname; + TToken_string _use, _input, _display, _output, _special, _items, _configs; + +public: + + TField( TString& campo, TConfig& pro ); + TField( ); + + void genera( TMaschera& _m ); + void configura( TConfig& pro ); + + void x( int x ){ _x = x; } + void y( int y ){ _y = y; } + void gruppo( int gruppo ){ _gruppo = gruppo; } + void id( int id ){ _id = id; } + void type( int type ){ _type = type; } + void size( int size ){ _size = size; } + void stato( int stato ){ _stato = stato; } + int x( ){ return _x; } + int y( ){ return _y; } + int gruppo( ){ return _gruppo; } + int id( ){ return _id; } + int type( ){ return _type; } + int size( ){ return _size; } + int stato( ){ return _stato; } + + + void nome( TString& nome ){ _nome = nome; } + void prompt( TString& prompt ){ _prompt = prompt; } + void flag( TString& flag ){ _flag = flag; } + void help( TString& help ){ _help = help; } + void warning( TString& warning ){ _warning = warning; } + void fieldname( TString& fieldname ){ _fieldname = fieldname; } + TString& nome( ){ return _nome; } + TString& prompt( ){ return _prompt; } + TString& flag( ){ return _flag; } + TString& help( ){ return _help; } + TString& warning( ){ return _warning; } + TString& fieldname( ){ return _fieldname; } + + void use( TToken_string& use ){ _use = use; } + void input( TToken_string& input ){ _input = input; } + void display( TToken_string& display ){ _display = display; } + void output( TToken_string& output ){ _output = output; } + void special( TToken_string& special ){ _special = special; } + void items( TToken_string& items ){ _items = items; } + void configs( TToken_string& configs ){ _configs = configs; } + TToken_string& use( ){ return _use; } + TToken_string& input( ){ return _input; } + TToken_string& display( ){ return _display; } + TToken_string& output( ){ return _output; } + TToken_string& special( ){ return _special; } + TToken_string& items( ){ return _items; } + TToken_string& configs( ){ return _configs; } + + + 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 ) +{ + int g1 = ((TField * )( *o1 ))->_gruppo; + int g2 = ((TField * )( *o2 ))->_gruppo; + return ( g1 < g2 ) ? -1 : ( ( g1 = g2 ) ? 0 : 1 ); +}; + +TField::TField( TString& campo, TConfig& pro ) : _nome( campo ) +{ + _nome.trim( ); + _fieldname = pro.get( "FIELDNAME", campo ); + _x = _gruppo = pro.get_int( "X", campo ); + _y = _gruppo = pro.get_int( "Y", campo ); + _gruppo = pro.get_int( "GROUP", campo ); + CHECK( _gruppo != 0, "Gruppo uguale a 0" ); + _id = pro.get_int( "MSKID", campo ); + CHECK( _id != 0, "Campo con MSKID uguale a 0" ); + _type = pro.get_int( "TYPE", campo ); + _size = pro.get_int( "SIZE", campo ); + _prompt = pro.get( "PROMPT", campo ); + if( _prompt[ 0 ] == '\"' ) + { + _prompt.ltrim( 1 ); + _prompt.rtrim( 1 ); + }; + _flag = pro.get( "FLAG", campo ); + _help = pro.get( "FLAG", campo ); + _warning = pro.get( "FLAG", campo ); + _use = pro.get( "USE", campo ); + _use.separator( '~' ); + _input = pro.get( "INPUT", campo ); + _input.separator( '~' ); + _display = pro.get( "DISPLAY", campo ); + _display.separator( '~' ); + _output = pro.get( "OUTPUT", campo ); + _output.separator( '~' ); + _special = pro.get( "SPECIAL", campo ); + _special.separator( '~' ); + _configs = pro.get( "CONFIGS", campo ); + _configs.separator( '~' ); + _items = ""; + int last = pro.get_int( "NITEMS", campo ); + for( int i = 1; i <= last; i ++ ) + _items.add( pro.get( "ITEM", campo, i ) ); +}; + +TField::TField( ) +{ + _nome = ""; + _fieldname = ""; + _x = 0; + _y = 0; + _gruppo = 0; + _id = 0; + _type = 0; + _size = 0; + _prompt = ""; + _flag = ""; + _help = ""; + _warning = ""; + _use = ""; + _use.separator( '~' ); + _input = ""; + _input.separator( '~' ); + _display = ""; + _display.separator( '~' ); + _output = ""; + _output.separator( '~' ); + _special = ""; + _special.separator( '~' ); + _configs = ""; + _configs.separator( '~' ); + _items = ""; + _items.separator( '@' ); +} + +void TField::configura( TConfig& pro ) +{ + TToken_string riga_profilo( pro.get( _nome, "PROFILO" ) ); + TString newprompt( riga_profilo.get( P_PROMPT ) ) ; + TString newhelp( riga_profilo.get( P_HELP ) ) ; + TString newwarning( riga_profilo.get( P_WARNING ) ) ; + if ( ! newprompt.blank( ) ) + _prompt = newprompt; + if ( ! newhelp.blank( ) ) + _help = newhelp; + if ( ! newwarning.blank( ) ) + _warning = newwarning; +} + +void TField::genera( TMaschera& m ) +{ + TString s; + + if ( _stato == S_NASCOSTO ) + return; + if ( _size != 0 ) + m.control( _type, _id, _size ); + else + m.control( _type, _id ); + m.begin(); + switch( _stato ) + { + case S_DISABILITATO : + m.prompt( _x, _y + m.line( ), _prompt ); + s = "D"; + s << _flag; + m.flag( s ) ; + break; + case S_NORMALE : + case S_OBBLIGATORIO : + m.prompt( _x, _y + m.line( ), _prompt ); + m.flag( _flag ); + break; + } + m.check( _stato ); + if ( !_fieldname.blank( ) ) m.field( _fieldname ); + if ( !_items.blank( ) ) m.item( _items ); + if ( !_use.blank( ) ) m.use( _use ); + if ( !_input.blank( ) ) m.input( _input ); + if ( !_display.blank( ) ) m.display( _display ); + if ( !_output.blank( ) ) m.output( _output ); + if ( !_help.blank( ) ) m.help( _help ); + if ( !_warning.blank( ) ) m.warning( _warning ); + if ( !_special.blank( ) ) m.outline( _special ); + m.end(); + if ( ( m.line() > MAX_LINES_PER_PAGE ) && ( m._pageopen == TRUE)) + { + m.end(); + m._pageopen = FALSE; + m.line( MASK_FIRST_LINE ); + } +} + + +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; + +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( ); + + // Distruttore + virtual ~TMask_generator( ); + +}; + +// Definizione dei metodi di TMask_generator +// ----------------------------------------- + +TMask_generator::TMask_generator( const TString& profilo ) : _proname( profilo ), _fieldsini( "ve0300a.ini" ), _groupsini( "ve0300c.ini" ), _ditta( CONFIG_DITTA ) +{ + // All'inizio il gruppo è 'chiuso' + _groupopen = FALSE; + + // Forza l'estensione al profilo + _proname.ext( "ini" ); + + // Se il file di profilo non esiste, esci con un errore fatale + if ( !fexist( _proname ) ) + fatal_box( "Il file %s non esiste!", ( const char * )_proname ); + + CHECK( fexist( "ve0300a.ini" ), "Il file ve0300a.ini non esiste!" ); + _fieldsini.list_paragraphs( _fields ); + CHECK( fexist( "ve0300b.dat" ), "Il file ve0300b.dat non esiste!" ); + carica_tabella( "ve0300b.dat", _tab0300b ); + + _pro = new TConfig( _proname ); + + TFilename _mskname( _pro->get( "MSKFILE", "MAIN") ); + _mskname.ext( "msk" ); + + + _m = new TMaschera( _mskname ); + +}; + +TMask_generator::~TMask_generator( ) +{ + delete _m; + delete _pro; +}; + + +void TMask_generator::carica_dati_campi( const TFilename& fn, TArray& a ) +{ + TScanner infile( fn ); + TString line; + TField *campo = NULL; + + while ( infile.ok( ) ) + { + line = infile.line( ); + line.trim( ); + while ( ( line.empty() || line[ 0 ] == '#' || line.left( 2 ) == "//" ) && infile.ok( ) ) + { + line = infile.line( ); + line.trim(); + } + if( infile.ok( ) ) + { + if ( line[ 0 ] == '[' ) // Carica un un campo + { + line.strip( "[]" ); + if ( campo ) + a.add( campo ); + campo = new TField(); + campo->nome( line ); + } + else + { + int pos; + if( ( pos = line.find( '=' ) ) == 0 ) + yesnofatal_box( "Linea errata nel file.INI: %s", (const char *) line ); + else + { + TString key = line.sub( 0, pos ); + key.trim(); + TString value = line.mid( pos + 1 ); + value.trim(); + if( key == "X" ) + campo->x( atoi( value ) ); + else if( key == "Y" ) + campo->y( atoi( value ) ); + else if( key == "GROUP" ) + campo->gruppo( atoi( value ) ); + else if( key == "FIELDNAME" ) + campo->fieldname( value ); + else if( key == "MSKID" ) + campo->id( atoi( value ) ); + else if( key == "TYPE" ) + campo->type( atoi( value ) ); + else if( key == "SIZE" ) + campo->size( atoi( value ) ); + else if( key == "PROMPT" ) + { + if( value[ 0 ] == '"' ) + { + value.rtrim( 1 ); + value.ltrim( 1 ); + }; + campo->prompt( value ); + } + else if( key == "FLAG" ) + campo->flag( value ); + else if( key == "USE" ) + campo->use( (TToken_string & ) value ); + else if( key == "INPUT" ) + campo->input( (TToken_string & )value ); + else if( key == "DISPLAY" ) + campo->display( (TToken_string & )value ); + else if( key == "OUTPUT" ) + campo->output( (TToken_string & )value ); + else if( key == "WARNING" ) + campo->warning( value ); + else if( key == "HELP" ) + campo->help( value ); + else if( key == "SPECIAL" ) + campo->special( (TToken_string & )value ); + else if( key == "ITEMS" ) + campo->items( (TToken_string & )value ); + else if( key == "CONFIGS" ) + campo->configs( (TToken_string & )value ); + else yesnofatal_box( "Chiave non trovata(%s)", (const char *) key ); + } + } + } + } + if ( campo ) + a.add( campo ); +} + +void TMask_generator::carica_tabella( const TFilename& fn, TString_array& tabella ) +{ TScanner in( fn ); + TToken_string line = in.line(); + while( line.not_empty( ) ) + { // Attacca tutte le righe che finiscono con § + while ( line.right( 1 ) == "§" ) + { line.rtrim( 1 ); + line << in.line( ); + }; + tabella.add( 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 ) +{ + const int type( _line.get_int( B_MSKTYPE ) ); + _m->control( type, id( ), _line.get_int( B_MSKSIZE ) ); + _m->begin( ); + _m->prompt( 2, 2 ); + _m->field( _line.get( B_NOME ) ); + _m->end( ); +} + +void TMask_generator::genera_item_sheet( TToken_string _line ) +{ + _m->_out << "IT \"" << _line.get( B_DESCR ); + _m->_out << "@" << _line.get_int( B_WIDTH ) << "\"\n"; +} + +void TMask_generator::intestazione_pagina( ) +{ + _m->page( _m->page( ) + 1 ); + _m->pagina( _m->page( ) ); + + _m->control( T_CORNICE, DLG_NULL, 7806 ); + _m->begin( ); + _m->prompt( 1, 0, "" ); + _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->begin(); + _m->prompt( 24, 1 ); + _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->group( 5 ); + _m->end(); + + _m->control( T_NUMERO, DLG_NULL, 6 ); + _m->begin(); + _m->prompt( 2, 3, "Doc.: nr. " ); + _m->group( 6 ); + _m->flag( "D" ); + _m->end(); + + _m->control( T_DATA ); + _m->begin(); + _m->prompt( 24, 3, "Data " ); + _m->group( 7 ); + _m->flag( "D" ); + _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->begin(); + _m->prompt( 24, 4, "" ); + _m->flag( "D" ); + _m->group( 11 ); + _m->end(); + +} + +void TMask_generator::genera( ) +{ + int i; + TString temp_s; + + + // Definizione della toolbar + + + _m->outline( "TOOLBAR \"\" 0 20 0 2" ); + + _m->control( T_BOTTONE, 18, 802 ); + _m->begin(); + _m->prompt( -15, -1, "~Registra" ); + _m->message( "EXIT,20082" ); + _m->end(); + + _m->control( T_BOTTONE, 17, 802 ); + _m->begin(); + _m->prompt( -25, -1, "~Elimina" ); + _m->message( "EXIT,127" ); + _m->end(); + + _m->control( T_BOTTONE, 99, 802 ); + _m->begin(); + _m->prompt( -35, -1, "E~labora" ); + _m->message( "EXIT,345" ); + _m->end(); + + _m->control( T_BOTTONE, 24, 802 ); + _m->begin(); + _m->prompt( -45, -1 ); + _m->message( "EXIT,346" ); + _m->end(); + + _m->control( T_BOTTONE, 2, 802 ); + _m->begin(); + _m->prompt( -55, -1 ); + _m->message( "EXIT,27" ); + _m->end(); + + // End della toolbar + _m->end(); + + + // Header della prima pagina + + _m->outline( "PA \"Pagina \" 11 60 14" ); + + _m->control( T_CORNICE, DLG_NULL, 7806 ); + _m->begin( ); + _m->prompt( 1, 0, "" ); + _m->end( ); + + _m->control( T_STRINGA, F_CODNUM, 4 ); + _m->begin(); + _m->prompt( 2, 1, "Cod. num. " ); + _m->field( "CODNUM" ); + _m->flag( "GDUZ" ); + _m->message( "CO,2@" ); + _m->end(); + + _m->control( T_STRINGA, F_DESNUM, 50 ); + _m->begin(); + _m->prompt( 24, 1 ); + _m->flag( "GDU" ); + _m->message( "CO,3@" ); + _m->end(); + + _m->control( T_STRINGA, F_TIPODOC, 4 ); + _m->begin(); + _m->prompt( 2, 2, "Tipo doc. " ); + _m->flag( "GDU" ); + _m->message( "CO,4@" ); + _m->end(); + + _m->control( T_STRINGA, F_TIPOCF, 1 ); + _m->begin(); + _m->prompt( 2, 2, "Tipo CF " ); + _m->field( "TIPOCF" ); + _m->flag( "H" ); + _m->end(); + + _m->control( T_STRINGA, F_PROVV, 1 ); + _m->begin(); + _m->prompt( 2, 2, "

" ); + _m->field( "PROVV" ); + _m->flag( "H" ); + _m->end(); + + + _m->control( T_STRINGA, F_DESTIPODOC, 50 ); + _m->begin(); + _m->prompt( 24, 2 ); + _m->flag( "GDU" ); + _m->message( "CO,5@" ); + _m->end(); + + _m->control( T_NUMERO, F_NDOC, 6 ); + _m->begin(); + _m->prompt( 2, 3, "Doc.: nr. " ); + _m->field( "NDOC" ); + _m->message( "CO,6@" ); + _m->flag( "GDR" ); + _m->end(); + + _m->control( T_DATA, F_DATADOC ); + _m->begin(); + _m->prompt( 24, 3, "Data " ); + _m->field( "DATADOC" ); + _m->message( "CO,7@" ); + _m->flag( "A" ); + _m->end(); + + _m->control( T_NUMERO, F_STATO, 1 ); + _m->begin(); + _m->prompt( 50, 3, "Stato " ); + _m->field( "STATO" ); + _m->message( "CO,8@" ); + _m->flag( "D" ); + _m->end(); + + _m->control( T_STRINGA, F_ANNO, 4 ); + _m->begin(); + _m->prompt( 66, 3, "Es. " ); + _m->field( "ANNO" ); + _m->flag( "GD" ); + _m->message( "CO,9@" ); + _m->end(); + + _m->control( T_STRINGA, F_CODCF, 6 ); + _m->begin(); + if ( _pro->get( "TIPOCF", "MAIN" ) == "C" ) + { + _m->prompt( 2, 4, "Cliente " ); + _m->warning( "Cliente assente" ); + _m->help( "Codice del cliente del documento" ); + + } + else + { + _m->prompt( 2, 4, "Fornitore " ); + _m->warning( "Fornitore assente" ); + _m->help( "Codice del fornitore del documento" ); + } + _m->flag( "R" ); + _m->field( "CODCF" ); + _m->group( 1 ); + _m->use( LF_CLIFO, 1 ); + temp_s.format( "TIPOCF \"C\"~CODCF %d", F_CODCF); + _m->input( temp_s ); + _m->display( "\"Codice\" CODCF~\"Ragione Sociale@50\" RAGSOC~\"Partita IVA@12\" PAIV~\"Sospeso\" SOSPESO" ); + temp_s.format( "%d CODCF~%d RAGSOC", F_CODCF, F_RAGSOC ); + _m->output( temp_s ); + _m->check( S_OBBLIGATORIO ); + _m->outline( "ADD RU cg0 -1 C" ); + _m->message( "CO,10@" ); + _m->end(); + + _m->control( T_STRINGA, F_RAGSOC, 50 ); + _m->begin( ); + if ( _pro->get( "TIPOCF", "MAIN" ) == "C" ) + { + _m->warning( "Cliente assente" ); + _m->help( "Ragione sociale del cliente del documento" ); + + } + else + { + _m->warning( "Fornitore assente" ); + _m->help( "Ragione sociale del fornitore del documento" ); + } + _m->prompt( 24, 4, "" ); + _m->group( 1 ); + _m->use( LF_CLIFO, 2 ); + temp_s.format( "TIPOCF \"C\"~RAGSOC %d", F_RAGSOC ); + _m->input( temp_s ); + _m->display( "\"Ragione Sociale@50\" RAGSOC~\"Partita IVA@12\" PAIV~\"Codice\" CODCF" ); + temp_s.format( "%d CODCF~%d RAGSOC", F_CODCF, F_RAGSOC ); + _m->output( temp_s ); + _m->check( S_OBBLIGATORIO ); + _m->outline( "ADD RU cg0 -1 C" ); + _m->message( "CO,11@" ); + _m->end(); + _m->line( MASK_FIRST_LINE ); + + // Generazione + + // Scorro l'array dei campi, per vedere gli stati ed i gruppi + + TArray campi; + TAssoc_array gruppi; + + carica_dati_campi( "ve0300a.ini", campi ); + int last = campi.items( ); + for( i = 0; i < last; i ++ ) + { + TString nome = (( TField & )campi[ i ]).nome( ); + int stato = stato_del_campo( nome ); + if( stato != S_NASCOSTO ) + { + const int addgruppo = (( TField & )campi[ i ]).gruppo( ); + TString16 chiave; + chiave.format( "%5d", addgruppo ); + if ( !gruppi.is_key( chiave ) ) + gruppi.add( chiave, new TGruppo( addgruppo, _groupsini ) ); + } + (( TField & )campi[ i ]).stato( stato ); + }; + campi.sort( sort_by_group ); + + // Generazione vera e propria + _m->_pageopen = TRUE; + last = campi.items( ); + int curgruppo = 0; + for( i = 0; i < last; i ++ ) + { + if ( _m->_pageopen == FALSE) + { + intestazione_pagina( ); + _m->_pageopen = TRUE; + } + TField& campo = ( TField& ) campi[ i ]; + if ( campo.gruppo( ) != curgruppo ) + { + TString16 chiave; + chiave.format( "%5d", campo.gruppo( ) ); + if ( gruppi.is_key( chiave ) ) + { + TGruppo& gruppo = ( TGruppo& ) gruppi[ chiave ]; + if ( _m->line( ) + gruppo.height( ) > MAX_LINES_PER_PAGE ) + { + _m->end( ); + intestazione_pagina( ); + _m->line( MASK_FIRST_LINE ); + } + else + { + TString16 vecchiachiave; + vecchiachiave.format( "%5d", curgruppo ); + if ( gruppi.is_key( vecchiachiave ) ) + { + _m->line( _m->line( ) + ( ( TGruppo& ) gruppi[ vecchiachiave ]).height( ) ); + } + } + }; + curgruppo = campo.gruppo( ); + }; + campo.configura( *_pro ); + campo.genera( *_m ); + } + if ( _m->_pageopen == TRUE ) _m->end( ); + intestazione_pagina( ); + + // Generazione del listbox per i tipi di riga da aggiungere nello sheet + _m->control ( T_LISTA, F_LBTIPORIGA, 30 ); + _m->begin(); + _m->prompt( 2, 7, "Tipo riga da aggiungere " ); + _m->end( ); + + // Generazione dello sheet : vedi il profilo + TScanner sheet_in( "ve0300b.dat" ); + _m->_out << "SPREADSHEET " << F_SHEET << " 76 6 \n"; + _m->begin(); + _m->prompt( 2, 8 ); + for( i = 0; i < _tab0300b.items( ); i ++ ) + genera_item_sheet( _tab0300b.row( i ) ); + _m->end(); + + _m->control( T_MEMO, F_MEMORIGA, 7604 ); + _m->begin(); + _m->prompt( 2, 15, " " ); + _m->field( "34->DESCEST" ); + _m->end( ); + + + _m->end(); + + // Generazione pagina dei piedi + TToken_string s(_pro->get( "PROGPIEDE", "MAIN" ) ); + if ( s.not_empty() ) + { + intestazione_pagina( ); + int cp = 1; + int piede = s.get_int();; + while ( piede != 0 ) + { + _m->control( T_NUMERO, BASE_PIEDE + cp, 1805 ); + _m->begin(); + TString header = _ditta.get( "PIEDE", "ve", piede ); + while( header.len() < 40 ) header << " "; + _m->prompt( 2, 7 + cp, header ); + _m->flag( "D" ); + _m->end(); + cp ++; + piede = s.get_int(); + } + _m->end(); + }; + _m->endmask( ); + + // Stategia al 30/06/95 + // Creo una maschera con tutte le colonne, poi, a RUNTIME, + // dal motore, nascondo e adatto le colonne. + + // Generazione maschera dello sheet + _m->_out << "PA \"Pagina 1\" 8 5 64 13\n"; + + id( 101 ); + for( i = 0; i < _tab0300b.items( ); i ++ ) + genera_campo_sheet( _tab0300b.row( i ) ); + _m->end(); + _m->end(); + _m->endmask( ); +} + + +// Applicazione guscio + +class TGenMask_application : public TApplication +{ + +protected: + + virtual bool create( ); + virtual bool menu( MENU_TAG _m ); + +}; + + +bool TGenMask_application::menu(MENU_TAG _m) +{ + TMask_generator a( argv( 2 ) ); + a.genera( ); + return( TRUE ); +}; + +bool TGenMask_application::create( ) +{ + TApplication::create(); + menu( 0 ); + return FALSE; +}; + +int ve0300( int argc, char** argv ) +{ + + if ( argc < 3 ) + fatal_box( "Sintassi: VE0 -3 " ); + + TGenMask_application a; + a.run ( argc, argv, "Generazione in corso ..." ); + return 0; +} diff --git a/ve/ve0300a.src b/ve/ve0300a.src index b68706fbe..afe203df6 100755 --- a/ve/ve0300a.src +++ b/ve/ve0300a.src @@ -362,6 +362,7 @@ DISPLAY="Codice" CODTAB~"Descrizione@50" S0 OUTPUT=F_CODPAG CODTAB~F_DESCODPAG S0 WARNING=Codice tipo pagamento non trovato HELP=Inserisci il codice del tipo di pagamento +SPECIAL=ADD RU BA3 -6 [DESCODPAG] GROUP=400 @@ -578,12 +579,12 @@ HELP=Inserisci il codice dell'indirizzo di spedizione GROUP=900 X=24 Y=0 -MSKID=F_RAGSOC +MSKID=F_RAGSOCSP TYPE=T_STRINGA SIZE=50 FLAG=U USE=20 KE 2 -INPUT=RAGSOC 301 +INPUT=RAGSOC F_RAGSOCSP DISPLAY="Ragione sociale@50" 20->RAGSOC~"Codice" 20->CODCF~"Indrizzo@35" 20->INDCF SPECIAL=JO 17 TO 20 KE 1 INTO TIPOCF=TIPOCF CODCF=CODCF WARNING=Ragione sociale non trovata diff --git a/ve/ve2100.cpp b/ve/ve2100.cpp index 9b26f14e8..bae767b25 100755 --- a/ve/ve2100.cpp +++ b/ve/ve2100.cpp @@ -1,100 +1,100 @@ - -#include -#include - -#include "ve2100.h" - - - -class TTabelle_sconti: public TRelation_application { - TMask *_msk; // maschera principale - TRelation *_rel; // relazione principale - - char _sconti; // carattere che indica il tipo di tabella - short _sci_k_id[4]; // vettore degli identificatori dei campi chiave per la maschera degli sconti incondizionati - bool _sci_k_enabled[4]; // vettore di abilitazione dei campi chiave per la maschera degli sconti incondizionati - - virtual bool user_create(); - virtual bool user_destroy(); - virtual TMask *get_mask(int) { return _msk; } - virtual bool changing_mask(int) { return FALSE; } - virtual TRelation *get_relation() const { return _rel; } - - virtual void init_query_mode(TMask &); // handler chiamato quando la maschera passa in modo ricerca - -public: - TTabelle_sconti() {} - virtual ~TTabelle_sconti() {} -}; - - - -bool TTabelle_sconti::user_create() { - bool gotcha= FALSE; // booleano di avvenuta inizializzazione - - _sconti= '*'; // inizializzazione dell'indicatore del tipo di tabella - if (argc()>2) _sconti= toupper((argv(2))[0]); // se c'è, prende il tipo di tabella dalla linea di comando - else { - TMask choose("VE2100"); // istanzia la maschera di scelta del tipo di tabella - if (choose.run() == K_ENTER) _sconti= toupper((choose.get(F_TIPOSC))[0]); // prende il tipo di tabella dalla maschera - } - switch (_sconti) { - case 'D': { // sconti documento - _msk= new TMask("VE2100D"); // apre la maschera relativa - gotcha= TRUE; - break; - } - case 'R': { // sconti di riga - _msk= new TMask("VE2100R"); // apre la maschera relativa - set_search_field(F_R_RICERCA); // setta il campo di ricerca - gotcha= TRUE; - break; - } - case 'I': { // sconti incondizionati - _msk= new TMask("VE2100I"); // apre la maschera relativa - set_search_field(F_I_RICERCA); // setta il campo di ricerca - TConfig prassid(CONFIG_DITTA); // apre il file di configurazione di ditta - _sci_k_id[0]= F_I_CATVEN; // inizializza l'array dei campi da disabilitare condizionalmente - _sci_k_id[1]= F_I_SCCLIENTI; - _sci_k_id[2]= F_I_ZONE; - _sci_k_id[3]= F_I_CONDPAG; - for (int i=0; i<4; i++) { - if (prassid.get("K_SCONTI_INC", "ve", i).empty()) _sci_k_enabled[i]= FALSE; // se nel file di config. il campo non è abilitato, viene indicato nel vettore di abilitazione - else _sci_k_enabled[i]= gotcha= TRUE; // se c'è almeno un campo abilitato "gotcha" esce TRUE dal ciclo - } - if (!gotcha) error_box("Non ci sono campi chiave abilitati nella configurazione della ditta"); - break; - } - default: { // messaggio di errore se si indica una tabella non valida - error_box("Indicare la tabella sulla linea di comando (D, R o I) oppure selezionarla dalla maschera di partenza"); - break; - } - } - if (gotcha) _rel= new TRelation(LF_SCONTI); // se è stata selezionata una tabella, apre la relazione (un unico file) - return (gotcha); -} - -bool TTabelle_sconti::user_destroy() { - delete _rel; - delete _msk; - return TRUE; -} - -void TTabelle_sconti::init_query_mode(TMask &m) { - for (int i=0; i<4; i++) { - if (_sci_k_enabled[i]) { // se il campo deve essere abilitato... - m.enable(_sci_k_id[i]); // ...lo abilita... - m.efield(_sci_k_id[i]).check_type(CHECK_REQUIRED); // ...e lo rende richiesto... - } else { // ...altrimenti... - m.disable(_sci_k_id[i]); // ...lo disabilita... - m.efield(_sci_k_id[i]).check_type(CHECK_NORMAL); // ...e lo rende non richiesto - } - } -} - -int ve2100(int argc, char* argv[]) { - TTabelle_sconti a; - - a.run(argc, argv, "Tabella sconti "); - return 0; -} + +#include +#include + +#include "ve2100.h" + + + +class TTabelle_sconti: public TRelation_application { + TMask *_msk; // maschera principale + TRelation *_rel; // relazione principale + + char _sconti; // carattere che indica il tipo di tabella + short _sci_k_id[4]; // vettore degli identificatori dei campi chiave per la maschera degli sconti incondizionati + bool _sci_k_enabled[4]; // vettore di abilitazione dei campi chiave per la maschera degli sconti incondizionati + + virtual bool user_create(); + virtual bool user_destroy(); + virtual TMask *get_mask(int) { return _msk; } + virtual bool changing_mask(int) { return FALSE; } + virtual TRelation *get_relation() const { return _rel; } + + virtual void init_query_mode(TMask &); // handler chiamato quando la maschera passa in modo ricerca + +public: + TTabelle_sconti() {} + virtual ~TTabelle_sconti() {} +}; + + + +bool TTabelle_sconti::user_create() { + bool gotcha= FALSE; // booleano di avvenuta inizializzazione + + _sconti= '*'; // inizializzazione dell'indicatore del tipo di tabella + if (argc()>2) _sconti= toupper((argv(2))[0]); // se c'è, prende il tipo di tabella dalla linea di comando + else { + TMask choose("VE2100"); // istanzia la maschera di scelta del tipo di tabella + if (choose.run() == K_ENTER) _sconti= toupper((choose.get(F_TIPOSC))[0]); // prende il tipo di tabella dalla maschera + } + switch (_sconti) { + case 'D': { // sconti documento + _msk= new TMask("VE2100D"); // apre la maschera relativa + gotcha= TRUE; + break; + } + case 'R': { // sconti di riga + _msk= new TMask("VE2100R"); // apre la maschera relativa + set_search_field(F_R_RICERCA); // setta il campo di ricerca + gotcha= TRUE; + break; + } + case 'I': { // sconti incondizionati + _msk= new TMask("VE2100I"); // apre la maschera relativa + set_search_field(F_I_RICERCA); // setta il campo di ricerca + TConfig prassid(CONFIG_DITTA); // apre il file di configurazione di ditta + _sci_k_id[0]= F_I_CATVEN; // inizializza l'array dei campi da disabilitare condizionalmente + _sci_k_id[1]= F_I_SCCLIENTI; + _sci_k_id[2]= F_I_ZONE; + _sci_k_id[3]= F_I_CONDPAG; + for (int i=0; i<4; i++) { + if (prassid.get("K_SCONTI_INC", "ve", i).empty()) _sci_k_enabled[i]= FALSE; // se nel file di config. il campo non è abilitato, viene indicato nel vettore di abilitazione + else _sci_k_enabled[i]= gotcha= TRUE; // se c'è almeno un campo abilitato "gotcha" esce TRUE dal ciclo + } + if (!gotcha) error_box("Non ci sono campi chiave abilitati nella configurazione della ditta"); + break; + } + default: { // messaggio di errore se si indica una tabella non valida + error_box("Indicare la tabella sulla linea di comando (D, R o I) oppure selezionarla dalla maschera di partenza"); + break; + } + } + if (gotcha) _rel= new TRelation(LF_SCONTI); // se è stata selezionata una tabella, apre la relazione (un unico file) + return (gotcha); +} + +bool TTabelle_sconti::user_destroy() { + delete _rel; + delete _msk; + return TRUE; +} + +void TTabelle_sconti::init_query_mode(TMask &m) { + for (int i=0; i<4; i++) { + if (_sci_k_enabled[i]) { // se il campo deve essere abilitato... + m.enable(_sci_k_id[i]); // ...lo abilita... + m.efield(_sci_k_id[i]).check_type(CHECK_REQUIRED); // ...e lo rende richiesto... + } else { // ...altrimenti... + m.disable(_sci_k_id[i]); // ...lo disabilita... + m.efield(_sci_k_id[i]).check_type(CHECK_NORMAL); // ...e lo rende non richiesto + } + } +} + +int ve2100(int argc, char* argv[]) { + TTabelle_sconti a; + + a.run(argc, argv, "Tabella sconti "); + return 0; +} diff --git a/ve/ve2200.cpp b/ve/ve2200.cpp index 0e492e174..b0e512d70 100755 --- a/ve/ve2200.cpp +++ b/ve/ve2200.cpp @@ -1,268 +1,268 @@ - -#include -#include -#include -#include -#include -#include - -#include "ve2200.h" -#include "ve2300x.h" // include anche il file dei campi della maschera delle righe - -#define RCONDVEN_APP "ve2 -2 " // nome dell'applicazione di gestione delle righe - - - -class TCondizioni_vendita: public TRelation_application { - TMask *_msk; // maschera principale - TRelation *_rel; // relazione principale - - TString16 _condven; // stringa che indica il tipo di archivio - TBit_array _tohide; // vettore degli identificatori di campi che devono essere nascosti - bool _catven_on; // booleano di abilitazione del campo CATVEN - - virtual bool user_create(); - virtual bool user_destroy(); - virtual TMask *get_mask(int) { return _msk; } - virtual bool changing_mask(int) { return FALSE; } - virtual TRelation *get_relation() const { return _rel; } - - static bool handle_mask(TMask &, KEY); // handler custom della maschera (per il tasto di aggancio alle righe) - static bool handle_datacam(TMask_field &, KEY); // handler del campo DATACAM (data cambio) - static bool handle_valfin(TMask_field &, KEY); // handler del campo VALFIN (data fine validità) - static bool handle_codlissucc(TMask_field &, KEY); // handler del campo CODLISSUCC (codice listino successivo) - static bool handle_seqric(TMask_field &, KEY); // handler del campo SEQRIC (sequenza di ricerca) - - virtual int write(const TMask &); // metodo usato per scrivere il record sul file - virtual int rewrite(const TMask &); // metodo usato per aggiornare il record sul file - - virtual void init_query_mode(TMask &); // handler chiamato quando la maschera passa in modo ricerca - - public: - TCondizioni_vendita() {} - virtual ~TCondizioni_vendita() {} -}; - - - -TCondizioni_vendita &app() { // funzione che ritorna il riferimento alla classe principale dell'applicazione - return (TCondizioni_vendita &)main_app(); -} - -bool TCondizioni_vendita::user_create() { - bool gotcha= FALSE; // booleano di avvenuta inizializzazione - - _condven= "*"; // inizializzazione dell'indicatore del tipo di archivio - if (argc()>2) _condven= argv(2); // se c'è, prende il tipo di archivio dalla linea di comando - else { - TMask choose("VE2200"); // istanzia la maschera di scelta del tipo di archivio - if (choose.run() == K_ENTER) _condven= choose.get(F_TIPOCV); // prende il tipo di archivio dalla maschera - } - _condven.upper(); // rende la stringa upper-case - _msk= new TMask("VE2200X"); - switch (_condven[0]) { - case 'L': { // listini - // settaggio dei campi da eliminare - _tohide.set(F_C_COD); - _tohide.set(F_O_COD); - _tohide.set(F_C_TIPOCF); - _tohide.set(F_C_CODCF); - _tohide.set(F_C_OBBLIG); - set_search_field(F_L_COD); // impostazione del campo di ricerca - TConfig prassid(CONFIG_DITTA, "ve"); // apre il file di configurazione della ditta corrente - _catven_on= (toupper(prassid.get("CATVEN_ON")[0])!='T'); // setta il booleano di abilitazione di CATVEN - _msk->set_handler(F_L_CODLISSUCC, handle_codlissucc); // setta l'handler per il campo di codice successivo - gotcha= TRUE; - break; - } - case 'C': // contratti - // settaggio dei campi da eliminare - _tohide.set(F_L_COD); - _tohide.set(F_O_COD); - _tohide.set(F_L_CATVEN); - _tohide.set(F_L_CODLISSUCC); - set_search_field(F_C_COD); // impostazione del campo di ricerca - gotcha= TRUE; - break; - case 'O': // offerte - // settaggio dei campi da eliminare - _tohide.set(F_L_COD); - _tohide.set(F_C_COD); - _tohide.set(F_L_CATVEN); - _tohide.set(F_C_TIPOCF); - _tohide.set(F_C_CODCF); - _tohide.set(F_C_OBBLIG); - _tohide.set(F_L_CODLISSUCC); - set_search_field(F_O_COD); // impostazione del campo di ricerca - gotcha= TRUE; - break; - default: // messaggio di errore se si indica un archivio non valido - error_box("Indicare l'archivio sulla linea di comando (L, C o O) oppure selezionarla dalla maschera di partenza"); - break; - } - if (gotcha) { // se è stato selezionato correttamente un archivio completa l'inizializzazione - _rel= new TRelation(LF_CONDV); // apre la relazione (un unico file) - _msk->set_handler(handle_mask); // imposta l'handler generale della maschera - _msk->set_handler(F_DATACAM, handle_datacam); // imposta l'handler per il campo della data del cambio - _msk->set_handler(F_VALFIN, handle_valfin); // imposta l'handler per il campo di fine validità - _msk->set_handler(F_SEQRIC, handle_seqric); // imposta l'handler per il campo di sequenza di ricerca - } - return (gotcha); -} - -bool TCondizioni_vendita::user_destroy() { - delete _rel; - delete _msk; - return TRUE; -} - -bool TCondizioni_vendita::handle_mask(TMask &m, KEY k) { - if (k==K_F5) { // se viene premuto F5 o selezionato il tasto "Righe" viene lanciata l'applicazione di editing - TString &_condven= app()._condven; // prende l'indicatore del tipo di archivio - bool &_catven_on= app()._catven_on; // prende il booleano di attivazione del campo CATVEN - TString appname(RCONDVEN_APP); // istanzia e inizializza la stringa con il nome dell'applicazione da lanciare - TString body; // istanzia la stringa contenente il corpo del messaggio (lista di inizializzazione dei campi della maschera) - switch (_condven[0]) { - case 'L': // listini - body << F_R_L_RICERCA; // appende l'id del campo di ricerca - body << "|"; // appende il separatore - body << F_R_TIPO << "=" << _condven; // appende il filtro sul tipo - body << "|"; // appende il separatore - body << F_R_L_CATVEN << "="; // appende il filtro sulla categoria di vendita... - if (_catven_on) body << m.get(F_L_CATVEN); // ... - body << "|"; // appende il separatore - body << F_R_L_COD << "=" << m.get(F_L_COD); // appende il filtro sul campo codice - break; - case 'C': // contratti - body << F_R_C_RICERCA; // appende l'id del campo di ricerca - body << "|"; // appende il separatore - body << F_R_TIPO << "=" << _condven; // appende il filtro sul tipo - body << "|"; // appende il separatore - body << F_R_C_TIPOCF << "=" << m.get(F_C_TIPOCF); // appende il filtro sul campo tipo cliente/fornitore - body << "|"; // appende il separatore - body << F_R_C_CODCF << "=" << m.get(F_C_CODCF); // appende il filtro sul campo codice cliente/fornitore - body << "|"; // appende il separatore - body << F_R_C_COD << "=" << m.get(F_C_COD); // appende il filtro sul campo codice - break; - case 'O': // offerte - body << F_R_O_RICERCA; // appende l'id del campo di ricerca - body << "|"; // appende il separatore - body << F_R_TIPO << "=" << _condven; // appende il filtro sul tipo - body << "|"; // appende il separatore - body << F_R_O_COD << "=" << m.get(F_O_COD); // appende il filtro sul campo codice - break; - } - appname << _condven; // aggiunge al lancio dell'applicazione la selezione del tipo di archivio - TMessage msg(cmd2name(appname), MSG_FS, (const char *)body); // istanzia il messaggio per l'applicazione - msg.send(); // invia il messaggio all'applicazione - TExternal_app ve2_2(appname); // istanzia l'applicazione esterna... - ve2_2.run(); // ...la lancia e rimane in attesa del suo termine - } - return TRUE; -} - -bool TCondizioni_vendita::handle_datacam(TMask_field &fld, KEY k) { - if (k==K_TAB) { // ad ogni perdita di fuoco viene tentato un accoppiamento tra valuta e data per ottenere il cambio preciso - TString datacam(fld.get()); // legge la data di cambio nel campo corrente - if (datacam.not_empty()) { - TMask &m= fld.mask(); // prende la maschera principale - TString codval(m.get(F_CODVAL)); // prende il codice della valuta - if (codval.not_empty()) { - TTable cam("CAM"); // apre la tabella cambi - cam.put("CODTAB", codval << datacam); // riempie la chiave - if (cam.read() == NOERR) m.set(F_CAMBIO, cam.get("R10")); // se la lettura riesce il valore del cambio viene posto nel campo CAMBIO della maschera - } - } - } - return TRUE; -} - -bool TCondizioni_vendita::handle_valfin(TMask_field &fld, KEY k) { - if (k==K_TAB) { - if (fld.get().not_empty()) { - TMask &m= fld.mask(); // prende la maschera principale - if (m.get(F_VALIN).not_empty()) { - TDate valfin(fld.get()); // prende la data di fine validità - TDate valin(m.get(F_VALIN)); // prende la data di inizio validità - if (valfinlfile(); // prende il file principale della relazione - TRectype &r= f.curr(); // prende il record corrente del file principale - f.zero("TIPOCF"); // svuota il campo TIPOCF - } - _rel->write(); // invoca la scrittura della relazione - return (_rel->status()); // ritorna lo stato della relazione -} - -int TCondizioni_vendita::rewrite(const TMask &m) { - m.autosave(_rel); // scrive il contenuto della maschera nel record della relazione - if (_condven != "C") { // se non si sta lavorando sui contratti il campo TIPOCF deve essere svuotato sul file - TLocalisamfile &f= _rel->lfile(); // prende il file principale della relazione - TRectype &r= f.curr(); // prende il record corrente del file principale - f.zero("TIPOCF"); // svuota il campo TIPOCF - } - _rel->rewrite(); // invoca la riscrittura della relazione - return (_rel->status()); // ritorna lo stato della relazione -} - -void TCondizioni_vendita::init_query_mode(TMask &m) { - for (short i=(short)_tohide.first_one(); i<=(short)_tohide.last_one(); i++) { - if (_tohide[i]) { - if (_msk->field(i).is_edit()) _msk->efield(i).check_type(CHECK_NORMAL); // disabilita il checking sul campo se è editabile - _msk->hide(i); // rende invisibile il campo - } - } - if (!_catven_on) { // se il booleano di abil. di CATVEN è falso... - _msk->efield(F_L_CATVEN).check_type(CHECK_NONE); // ...viene rimosso dal checking... - _msk->disable(F_L_CATVEN); // ...e disabilitato - } - _msk->set(F_TIPO, _condven); // settaggio del campo di tipo archivio -} - -int ve2200(int argc, char* argv[]) { - TCondizioni_vendita a; - - a.run(argc, argv, "Condizioni di vendita "); - return 0; -} + +#include +#include +#include +#include +#include +#include + +#include "ve2200.h" +#include "ve2300x.h" // include anche il file dei campi della maschera delle righe + +#define RCONDVEN_APP "ve2 -2 " // nome dell'applicazione di gestione delle righe + + + +class TCondizioni_vendita: public TRelation_application { + TMask *_msk; // maschera principale + TRelation *_rel; // relazione principale + + TString16 _condven; // stringa che indica il tipo di archivio + TBit_array _tohide; // vettore degli identificatori di campi che devono essere nascosti + bool _catven_on; // booleano di abilitazione del campo CATVEN + + virtual bool user_create(); + virtual bool user_destroy(); + virtual TMask *get_mask(int) { return _msk; } + virtual bool changing_mask(int) { return FALSE; } + virtual TRelation *get_relation() const { return _rel; } + + static bool handle_mask(TMask &, KEY); // handler custom della maschera (per il tasto di aggancio alle righe) + static bool handle_datacam(TMask_field &, KEY); // handler del campo DATACAM (data cambio) + static bool handle_valfin(TMask_field &, KEY); // handler del campo VALFIN (data fine validità) + static bool handle_codlissucc(TMask_field &, KEY); // handler del campo CODLISSUCC (codice listino successivo) + static bool handle_seqric(TMask_field &, KEY); // handler del campo SEQRIC (sequenza di ricerca) + + virtual int write(const TMask &); // metodo usato per scrivere il record sul file + virtual int rewrite(const TMask &); // metodo usato per aggiornare il record sul file + + virtual void init_query_mode(TMask &); // handler chiamato quando la maschera passa in modo ricerca + + public: + TCondizioni_vendita() {} + virtual ~TCondizioni_vendita() {} +}; + + + +TCondizioni_vendita &app() { // funzione che ritorna il riferimento alla classe principale dell'applicazione + return (TCondizioni_vendita &)main_app(); +} + +bool TCondizioni_vendita::user_create() { + bool gotcha= FALSE; // booleano di avvenuta inizializzazione + + _condven= "*"; // inizializzazione dell'indicatore del tipo di archivio + if (argc()>2) _condven= argv(2); // se c'è, prende il tipo di archivio dalla linea di comando + else { + TMask choose("VE2200"); // istanzia la maschera di scelta del tipo di archivio + if (choose.run() == K_ENTER) _condven= choose.get(F_TIPOCV); // prende il tipo di archivio dalla maschera + } + _condven.upper(); // rende la stringa upper-case + _msk= new TMask("VE2200X"); + switch (_condven[0]) { + case 'L': { // listini + // settaggio dei campi da eliminare + _tohide.set(F_C_COD); + _tohide.set(F_O_COD); + _tohide.set(F_C_TIPOCF); + _tohide.set(F_C_CODCF); + _tohide.set(F_C_OBBLIG); + set_search_field(F_L_COD); // impostazione del campo di ricerca + TConfig prassid(CONFIG_DITTA, "ve"); // apre il file di configurazione della ditta corrente + _catven_on= (prassid.get_bool("CODLISCV")); // setta il booleano di abilitazione di CATVEN + _msk->set_handler(F_L_CODLISSUCC, handle_codlissucc); // setta l'handler per il campo di codice successivo + gotcha= TRUE; + break; + } + case 'C': // contratti + // settaggio dei campi da eliminare + _tohide.set(F_L_COD); + _tohide.set(F_O_COD); + _tohide.set(F_L_CATVEN); + _tohide.set(F_L_CODLISSUCC); + set_search_field(F_C_COD); // impostazione del campo di ricerca + gotcha= TRUE; + break; + case 'O': // offerte + // settaggio dei campi da eliminare + _tohide.set(F_L_COD); + _tohide.set(F_C_COD); + _tohide.set(F_L_CATVEN); + _tohide.set(F_C_TIPOCF); + _tohide.set(F_C_CODCF); + _tohide.set(F_C_OBBLIG); + _tohide.set(F_L_CODLISSUCC); + set_search_field(F_O_COD); // impostazione del campo di ricerca + gotcha= TRUE; + break; + default: // messaggio di errore se si indica un archivio non valido + error_box("Indicare l'archivio sulla linea di comando (L, C o O) oppure selezionarla dalla maschera di partenza"); + break; + } + if (gotcha) { // se è stato selezionato correttamente un archivio completa l'inizializzazione + _rel= new TRelation(LF_CONDV); // apre la relazione (un unico file) + _msk->set_handler(handle_mask); // imposta l'handler generale della maschera + _msk->set_handler(F_DATACAM, handle_datacam); // imposta l'handler per il campo della data del cambio + _msk->set_handler(F_VALFIN, handle_valfin); // imposta l'handler per il campo di fine validità + _msk->set_handler(F_SEQRIC, handle_seqric); // imposta l'handler per il campo di sequenza di ricerca + } + return (gotcha); +} + +bool TCondizioni_vendita::user_destroy() { + delete _rel; + delete _msk; + return TRUE; +} + +bool TCondizioni_vendita::handle_mask(TMask &m, KEY k) { + if (k==K_F5) { // se viene premuto F5 o selezionato il tasto "Righe" viene lanciata l'applicazione di editing + TString &_condven= app()._condven; // prende l'indicatore del tipo di archivio + bool &_catven_on= app()._catven_on; // prende il booleano di attivazione del campo CATVEN + TString appname(RCONDVEN_APP); // istanzia e inizializza la stringa con il nome dell'applicazione da lanciare + TString body; // istanzia la stringa contenente il corpo del messaggio (lista di inizializzazione dei campi della maschera) + switch (_condven[0]) { + case 'L': // listini + body << F_R_L_RICERCA; // appende l'id del campo di ricerca + body << "|"; // appende il separatore + body << F_R_TIPO << "=" << _condven; // appende il filtro sul tipo + body << "|"; // appende il separatore + body << F_R_L_CATVEN << "="; // appende il filtro sulla categoria di vendita... + if (_catven_on) body << m.get(F_L_CATVEN); // ... + body << "|"; // appende il separatore + body << F_R_L_COD << "=" << m.get(F_L_COD); // appende il filtro sul campo codice + break; + case 'C': // contratti + body << F_R_C_RICERCA; // appende l'id del campo di ricerca + body << "|"; // appende il separatore + body << F_R_TIPO << "=" << _condven; // appende il filtro sul tipo + body << "|"; // appende il separatore + body << F_R_C_TIPOCF << "=" << m.get(F_C_TIPOCF); // appende il filtro sul campo tipo cliente/fornitore + body << "|"; // appende il separatore + body << F_R_C_CODCF << "=" << m.get(F_C_CODCF); // appende il filtro sul campo codice cliente/fornitore + body << "|"; // appende il separatore + body << F_R_C_COD << "=" << m.get(F_C_COD); // appende il filtro sul campo codice + break; + case 'O': // offerte + body << F_R_O_RICERCA; // appende l'id del campo di ricerca + body << "|"; // appende il separatore + body << F_R_TIPO << "=" << _condven; // appende il filtro sul tipo + body << "|"; // appende il separatore + body << F_R_O_COD << "=" << m.get(F_O_COD); // appende il filtro sul campo codice + break; + } + appname << _condven; // aggiunge al lancio dell'applicazione la selezione del tipo di archivio + TMessage msg(cmd2name(appname), MSG_FS, (const char *)body); // istanzia il messaggio per l'applicazione + msg.send(); // invia il messaggio all'applicazione + TExternal_app ve2_2(appname); // istanzia l'applicazione esterna... + ve2_2.run(); // ...la lancia e rimane in attesa del suo termine + } + return TRUE; +} + +bool TCondizioni_vendita::handle_datacam(TMask_field &fld, KEY k) { + if (k==K_TAB) { // ad ogni perdita di fuoco viene tentato un accoppiamento tra valuta e data per ottenere il cambio preciso + TString datacam(fld.get()); // legge la data di cambio nel campo corrente + if (datacam.not_empty()) { + TMask &m= fld.mask(); // prende la maschera principale + TString codval(m.get(F_CODVAL)); // prende il codice della valuta + if (codval.not_empty()) { + TTable cam("CAM"); // apre la tabella cambi + cam.put("CODTAB", codval << datacam); // riempie la chiave + if (cam.read() == NOERR) m.set(F_CAMBIO, cam.get("R10")); // se la lettura riesce il valore del cambio viene posto nel campo CAMBIO della maschera + } + } + } + return TRUE; +} + +bool TCondizioni_vendita::handle_valfin(TMask_field &fld, KEY k) { + if (k==K_TAB) { + if (fld.get().not_empty()) { + TMask &m= fld.mask(); // prende la maschera principale + if (m.get(F_VALIN).not_empty()) { + TDate valfin(fld.get()); // prende la data di fine validità + TDate valin(m.get(F_VALIN)); // prende la data di inizio validità + if (valfinlfile(); // prende il file principale della relazione + TRectype &r= f.curr(); // prende il record corrente del file principale + f.zero("TIPOCF"); // svuota il campo TIPOCF + } + _rel->write(); // invoca la scrittura della relazione + return (_rel->status()); // ritorna lo stato della relazione +} + +int TCondizioni_vendita::rewrite(const TMask &m) { + m.autosave(_rel); // scrive il contenuto della maschera nel record della relazione + if (_condven != "C") { // se non si sta lavorando sui contratti il campo TIPOCF deve essere svuotato sul file + TLocalisamfile &f= _rel->lfile(); // prende il file principale della relazione + TRectype &r= f.curr(); // prende il record corrente del file principale + f.zero("TIPOCF"); // svuota il campo TIPOCF + } + _rel->rewrite(); // invoca la riscrittura della relazione + return (_rel->status()); // ritorna lo stato della relazione +} + +void TCondizioni_vendita::init_query_mode(TMask &m) { + for (short i=(short)_tohide.first_one(); i<=(short)_tohide.last_one(); i++) { + if (_tohide[i]) { + if (_msk->field(i).is_edit()) _msk->efield(i).check_type(CHECK_NORMAL); // disabilita il checking sul campo se è editabile + _msk->hide(i); // rende invisibile il campo + } + } + if (!_catven_on) { // se il booleano di abil. di CATVEN è falso... + _msk->efield(F_L_CATVEN).check_type(CHECK_NONE); // ...viene rimosso dal checking... + _msk->disable(F_L_CATVEN); // ...e disabilitato + } + _msk->set(F_TIPO, _condven); // settaggio del campo di tipo archivio +} + +int ve2200(int argc, char* argv[]) { + TCondizioni_vendita a; + + a.run(argc, argv, "Condizioni di vendita "); + return 0; +} diff --git a/ve/ve2300.cpp b/ve/ve2300.cpp index 1418db13a..85ec60e56 100755 --- a/ve/ve2300.cpp +++ b/ve/ve2300.cpp @@ -1,253 +1,253 @@ - -#include -#include - -#include "ve2300.h" - - - -class TRighe_condizioni_vendita: public TRelation_application { - TMask *_msk; // maschera principale - TRelation *_rel; // relazione principale - - bool _catven_on; // booleano di abilitazione del campo CATVEN - - virtual bool user_create(); - virtual bool user_destroy(); - virtual TMask *get_mask(int) { return _msk; } - virtual bool changing_mask(int) { return FALSE; } - virtual TRelation *get_relation() const { return _rel; } - - static void hide_and_show_codriga(TMask &); // procedura di abilitazione/disabilitazione dei tre campi CODRIGA (codice riga) - - static bool handle_tiporiga(TMask_field &, KEY); // handler del campo TIPORIGA (articolo, gruppo merc., ragg. fiscale) - static bool handle_cod(TMask_field &, KEY); // handler del campo COD (codice listino, numero contratto, codice offerta) - - virtual int write(const TMask &); // metodo usato per scrivere il record sul file - virtual int rewrite(const TMask &); // metodo usato per aggiornare il record sul file - - virtual void init_query_mode(TMask &); // handler chiamato quando la maschera passa in modo ricerca - -public: - TString16 _rcondven; // stringa che indica il tipo di archivio - TBit_array _tohide; // vettore degli identificatori di campi che devono essere nascosti - - TRighe_condizioni_vendita() {} - virtual ~TRighe_condizioni_vendita() {} -}; - - - -TRighe_condizioni_vendita &app() { // funzione che ritorna il riferimento alla classe principale dell'applicazione - return (TRighe_condizioni_vendita &)main_app(); -} - -bool TRighe_condizioni_vendita::user_create() { - bool gotcha= FALSE; // booleano di avvenuta inizializzazione - - _rcondven= "*"; // inizializzazione dell'indicatore del tipo di archivio - if (argc()>2) { // se c'è, prende il tipo di archivio dalla linea di comando - TString temp(argv(2)); - _rcondven= temp.left(1); // prende solo il primo carattere - } else { - TMask choose("VE2300"); // istanzia la maschera di scelta del tipo di archivio - if (choose.run() == K_ENTER) _rcondven= choose.get(F_TIPORCV); // prende il tipo di archivio dalla maschera - } - _rcondven.upper(); // rende la stringa upper-case - _msk= new TMask("VE2300X"); - _tohide.reset(); // resetta il vettore dei campi da eliminare - switch (_rcondven[0]) { - case 'L': { // listini - _tohide.set(F_R_C_TIPOCF); // settaggio dei campi da eliminare... - _tohide.set(F_R_C_CODCF); - _tohide.set(F_R_C_COD); - _tohide.set(F_R_O_COD); - _tohide.set(F_R_C_RICERCA); - _tohide.set(F_R_O_RICERCA); - _tohide.set(F_R_CO_CODLOTTO); - _tohide.set(F_R_O_ARTES); - TConfig prassid(CONFIG_DITTA, "ve"); // apre il file di configurazione della ditta corrente - _catven_on= (toupper(prassid.get("CATVEN_ON")[0])!='T'); // setta il booleano di abilitazione di CATVEN - set_search_field(F_R_L_RICERCA); // impostazione del campo di ricerca - _msk->set_handler(F_R_L_COD, handle_cod); // impostazione dell'handler sul campo di controllo della testata - gotcha= TRUE; - break; - } - case 'C': // contratti - _tohide.set(F_R_L_CATVEN); // settaggio dei campi da eliminare... - _tohide.set(F_R_L_COD); - _tohide.set(F_R_O_COD); - _tohide.set(F_R_LO_UM); - _tohide.set(F_R_L_RICERCA); - _tohide.set(F_R_O_RICERCA); - _tohide.set(F_R_O_ARTES); - set_search_field(F_R_C_RICERCA); // impostazione del campo di ricerca - _msk->set_handler(F_R_C_COD, handle_cod); // impostazione dell'handler sul campo di controllo della testata - gotcha= TRUE; - break; - case 'O': // offerte - _tohide.set(F_R_L_CATVEN); // settaggio dei campi da eliminare... - _tohide.set(F_R_C_TIPOCF); - _tohide.set(F_R_C_CODCF); - _tohide.set(F_R_L_COD); - _tohide.set(F_R_C_COD); - _tohide.set(F_R_L_RICERCA); - _tohide.set(F_R_C_RICERCA); - set_search_field(F_R_O_RICERCA); // impostazione del campo di ricerca - _msk->set_handler(F_R_O_COD, handle_cod); // impostazione dell'handler sul campo di controllo della testata - gotcha= TRUE; - break; - default: // messaggio di errore se si indica un archivio non valido - error_box("Indicare l'archivio sulla linea di comando (L, C o O) oppure selezionarla dalla maschera di partenza"); - break; - } - if (gotcha) { // se è stato selezionato correttamente un archivio completa l'inizializzazione - _rel= new TRelation(LF_RCONDV); // apre la relazione (un unico file) - _msk->set_handler(F_R_TIPORIGA, handle_tiporiga); // impostazione dell'handler sul campo di selezione del tipo della riga - hide_and_show_codriga(*_msk); // invoca la procedura di controllo della mutua esclusione dei tre campi CODRIGA - } - return (gotcha); -} - -bool TRighe_condizioni_vendita::user_destroy() { - delete _rel; - delete _msk; - return TRUE; -} - -void TRighe_condizioni_vendita::hide_and_show_codriga(TMask &m) { - short id_campi[3]= { F_R_CODRIGA_A, F_R_CODRIGA_G, F_R_CODRIGA_R }; // vettore degli identificatori dei tre campi CODRIGA in mutua esclusione - char tag_campi[3]= { 'A', 'G', 'R' }; // vettore dei tag di TIPORIGA per i tre campi CODRIGA in mutua esclusione - char tag_campo= m.get(F_R_TIPORIGA)[0]; // prende il tag in TIPORIGA del campo da abilitare - TString &_rcondven= app()._rcondven; // prende il riferimento alla stringa di tipo di archivio - TBit_array &_tohide= app()._tohide; // prende il riferimento all'array di campi da eliminare - for (int i=0; i<3; i++) { // ciclo sui tre campi CODRIGA - if (tag_campo == tag_campi[i]) { // il campo indicato con il tag viene... - m.efield(id_campi[i]).check_type(CHECK_REQUIRED); // ...abilitato al checking... - m.show(id_campi[i]); // ...mostrato... - _tohide.reset(id_campi[i]); // ...e rimosso dal vettore di eliminazione... - } else { // ...mentre gli altri vengono... - m.efield(id_campi[i]).check_type(CHECK_NONE); // ...disabilitati dal checking... - m.hide(id_campi[i]); // ...nascosti... - _tohide.set(id_campi[i]); // ...e aggiunti al vettore di eliminazione - } - } - if (_rcondven != "C") { // se non stiamo lavorando sui contratti... - if (tag_campo=='A') { // ...ed è stata selezionata una riga di articoli... - m.efield(F_R_LO_UM).check_type(CHECK_REQUIRED); // ...l'unità di misura viene attivata al checking... - m.enable(F_R_LO_UM); // ...e abilitata... - } else { // ...altrimenti, se è stata selezionata una riga non di articoli... - m.efield(F_R_LO_UM).check_type(CHECK_NONE); // ...l'unità di misura viene rimossa dal checking... - m.disable(F_R_LO_UM); // ...e disabilitata - } - } -} - -bool TRighe_condizioni_vendita::handle_tiporiga(TMask_field &fld, KEY k) { - if (k==K_TAB) hide_and_show_codriga(fld.mask()); // invoca la procedura di controllo della mutua esclusione dei tre campi CODRIGA - return TRUE; -} - -bool TRighe_condizioni_vendita::handle_cod(TMask_field &fld, KEY k) { - if ((k==K_TAB) && fld.get().not_empty()) { - TString &_rcondven= app()._rcondven; // prende il riferimento alla stringa di indicazione del tipo di archivio - TMask &m= fld.mask(); // prende la maschera principale - TLocalisamfile condv(LF_CONDV); // apre il file della testata (condizioni di vendita) - condv.put("TIPO", _rcondven); // riempie il campo "TIPO" - switch (_rcondven[0]) { - case 'L': // riempie il resto della chiave dei listini - condv.put("CATVEN", m.get(F_R_L_CATVEN)); - condv.put("COD", m.get(F_R_L_COD)); - break; - case 'C': // riempie il resto della chiave dei contratti - condv.put("TIPOCF", m.get(F_R_C_TIPOCF)); - condv.put("CODCF", m.get(F_R_C_CODCF)); - condv.put("COD", m.get(F_R_C_COD)); - break; - case 'O': // riempie il resto della chiave delle offerte - condv.put("COD", m.get(F_R_O_COD)); - break; - } - if (condv.read()==NOERR) { // se la lettura è andata a buon fine abilita/disabilita i campi della maschera in base ai booleani della testata - if (!condv.get_bool("GESTUM")) { - m.efield(F_R_LO_UM).check_type(CHECK_NONE); // disabilita il checking sul campo "unità di misura" - m.disable(F_R_LO_UM); // disabilita il campo "unità di misura" - } else { - m.efield(F_R_LO_UM).check_type(CHECK_REQUIRED); // abilita il checking sul campo "unità di misura" - m.enable(F_R_LO_UM); // abilita il campo "unità di misura" - } - if (!condv.get_bool("GESTSCAGL")) { - m.efield(F_R_NSCAGL).check_type(CHECK_NONE); // disabilita il checking sul campo "quantità limite scaglione" - m.disable(F_R_NSCAGL); // disabilita il campo "quantità limite scaglione" - m.disable(F_R_QLIM); // disabilita il campo "quantità limite scaglione" - } else { - m.efield(F_R_NSCAGL).check_type(CHECK_REQUIRED); // abilita il checking sul campo "quantità limite scaglione" - m.enable(F_R_NSCAGL); // abilita il campo "quantità limite scaglione" - m.enable(F_R_QLIM); // abilita il campo "quantità limite scaglione" - } - if (!condv.get_bool("GESTSCO")) { - m.disable(F_R_SCONTO); // disabilita il campo "sconto" - m.disable(F_R_QOM); // disabilita il campo "quantità art. omaggio" - m.disable(F_R_QBASE); // disabilita il campo "quantità base x sconto" - m.disable(F_R_CODARTOM); // disabilita il campo "codice articolo omaggio" - m.disable(F_R_PROMAGGIO); // disabilita il campo "prezzo omaggio" - m.disable(F_R_UMOM); // disabilita il campo "unità di misura art. omaggio" - } else { - m.enable(F_R_SCONTO); // abilita il campo "sconto" - m.enable(F_R_QOM); // abilita il campo "quantità art. omaggio" - m.enable(F_R_QBASE); // abilita il campo "quantità base x sconto" - m.enable(F_R_CODARTOM); // abilita il campo "codice articolo omaggio" - m.enable(F_R_PROMAGGIO); // abilita il campo "prezzo omaggio" - m.enable(F_R_UMOM); // abilita il campo "unità di misura art. omaggio" - } - return TRUE; - } else { - error_box("Non esiste una testata corrispondente alla chiave specificata"); - return FALSE; - } - } else return TRUE; -} - -int TRighe_condizioni_vendita::write(const TMask &m) { - m.autosave(_rel); // scrive il contenuto della maschera nel record della relazione - if (_rcondven != "C") { // se non si sta lavorando sui contratti il campo TIPOCF deve essere svuotato sul file - TLocalisamfile &f= _rel->lfile(); // prende il file principale della relazione - TRectype &r= f.curr(); // prende il record corrente del file principale - f.zero("TIPOCF"); // svuota il campo TIPOCF - } - _rel->write(); // invoca la scrittura della relazione - return (_rel->status()); // ritorna lo stato della relazione -} - -int TRighe_condizioni_vendita::rewrite(const TMask &m) { - m.autosave(_rel); // scrive il contenuto della maschera nel record della relazione - if (_rcondven != "C") { // se non si sta lavorando sui contratti il campo TIPOCF deve essere svuotato sul file - TLocalisamfile &f= _rel->lfile(); // prende il file principale della relazione - TRectype &r= f.curr(); // prende il record corrente del file principale - f.zero("TIPOCF"); // svuota il campo TIPOCF - } - _rel->rewrite(); // invoca la riscrittura della relazione - return (_rel->status()); // ritorna lo stato della relazione -} - -void TRighe_condizioni_vendita::init_query_mode(TMask &m) { - for (short i=(short)_tohide.first_one(); i<=(short)_tohide.last_one(); i++) { // ciclo sul vettore dei campi da eliminare - if (_tohide[i]) { - if (_msk->field(i).is_edit()) _msk->efield(i).check_type(CHECK_NONE); // disabilita il checking sul campo se è editabile - _msk->hide(i); // rende invisibile il campo - } - } - if (!_catven_on) { // se il booleano di abil. di CATVEN è falso... - _msk->efield(F_R_L_CATVEN).check_type(CHECK_NONE); // ...viene rimosso dal checking... - _msk->disable(F_R_L_CATVEN); // ...e disabilitato - } - _msk->set(F_R_TIPO, _rcondven); // settaggio del campo di tipo archivio -} - -int ve2300(int argc, char* argv[]) { - TRighe_condizioni_vendita a; - - a.run(argc, argv, "Righe condizioni vendita "); - return 0; -} - + +#include +#include + +#include "ve2300.h" + + + +class TRighe_condizioni_vendita: public TRelation_application { + TMask *_msk; // maschera principale + TRelation *_rel; // relazione principale + + bool _catven_on; // booleano di abilitazione del campo CATVEN + + virtual bool user_create(); + virtual bool user_destroy(); + virtual TMask *get_mask(int) { return _msk; } + virtual bool changing_mask(int) { return FALSE; } + virtual TRelation *get_relation() const { return _rel; } + + static void hide_and_show_codriga(TMask &); // procedura di abilitazione/disabilitazione dei tre campi CODRIGA (codice riga) + + static bool handle_tiporiga(TMask_field &, KEY); // handler del campo TIPORIGA (articolo, gruppo merc., ragg. fiscale) + static bool handle_cod(TMask_field &, KEY); // handler del campo COD (codice listino, numero contratto, codice offerta) + + virtual int write(const TMask &); // metodo usato per scrivere il record sul file + virtual int rewrite(const TMask &); // metodo usato per aggiornare il record sul file + + virtual void init_query_mode(TMask &); // handler chiamato quando la maschera passa in modo ricerca + +public: + TString16 _rcondven; // stringa che indica il tipo di archivio + TBit_array _tohide; // vettore degli identificatori di campi che devono essere nascosti + + TRighe_condizioni_vendita() {} + virtual ~TRighe_condizioni_vendita() {} +}; + + + +TRighe_condizioni_vendita &app() { // funzione che ritorna il riferimento alla classe principale dell'applicazione + return (TRighe_condizioni_vendita &)main_app(); +} + +bool TRighe_condizioni_vendita::user_create() { + bool gotcha= FALSE; // booleano di avvenuta inizializzazione + + _rcondven= "*"; // inizializzazione dell'indicatore del tipo di archivio + if (argc()>2) { // se c'è, prende il tipo di archivio dalla linea di comando + TString temp(argv(2)); + _rcondven= temp.left(1); // prende solo il primo carattere + } else { + TMask choose("VE2300"); // istanzia la maschera di scelta del tipo di archivio + if (choose.run() == K_ENTER) _rcondven= choose.get(F_TIPORCV); // prende il tipo di archivio dalla maschera + } + _rcondven.upper(); // rende la stringa upper-case + _msk= new TMask("VE2300X"); + _tohide.reset(); // resetta il vettore dei campi da eliminare + switch (_rcondven[0]) { + case 'L': { // listini + _tohide.set(F_R_C_TIPOCF); // settaggio dei campi da eliminare... + _tohide.set(F_R_C_CODCF); + _tohide.set(F_R_C_COD); + _tohide.set(F_R_O_COD); + _tohide.set(F_R_C_RICERCA); + _tohide.set(F_R_O_RICERCA); + _tohide.set(F_R_CO_CODLOTTO); + _tohide.set(F_R_O_ARTES); + TConfig prassid(CONFIG_DITTA, "ve"); // apre il file di configurazione della ditta corrente + _catven_on= prassid.get_bool("GESLISCV"); // setta il booleano di abilitazione di CATVEN + set_search_field(F_R_L_RICERCA); // impostazione del campo di ricerca + _msk->set_handler(F_R_L_COD, handle_cod); // impostazione dell'handler sul campo di controllo della testata + gotcha= TRUE; + break; + } + case 'C': // contratti + _tohide.set(F_R_L_CATVEN); // settaggio dei campi da eliminare... + _tohide.set(F_R_L_COD); + _tohide.set(F_R_O_COD); + _tohide.set(F_R_LO_UM); + _tohide.set(F_R_L_RICERCA); + _tohide.set(F_R_O_RICERCA); + _tohide.set(F_R_O_ARTES); + set_search_field(F_R_C_RICERCA); // impostazione del campo di ricerca + _msk->set_handler(F_R_C_COD, handle_cod); // impostazione dell'handler sul campo di controllo della testata + gotcha= TRUE; + break; + case 'O': // offerte + _tohide.set(F_R_L_CATVEN); // settaggio dei campi da eliminare... + _tohide.set(F_R_C_TIPOCF); + _tohide.set(F_R_C_CODCF); + _tohide.set(F_R_L_COD); + _tohide.set(F_R_C_COD); + _tohide.set(F_R_L_RICERCA); + _tohide.set(F_R_C_RICERCA); + set_search_field(F_R_O_RICERCA); // impostazione del campo di ricerca + _msk->set_handler(F_R_O_COD, handle_cod); // impostazione dell'handler sul campo di controllo della testata + gotcha= TRUE; + break; + default: // messaggio di errore se si indica un archivio non valido + error_box("Indicare l'archivio sulla linea di comando (L, C o O) oppure selezionarla dalla maschera di partenza"); + break; + } + if (gotcha) { // se è stato selezionato correttamente un archivio completa l'inizializzazione + _rel= new TRelation(LF_RCONDV); // apre la relazione (un unico file) + _msk->set_handler(F_R_TIPORIGA, handle_tiporiga); // impostazione dell'handler sul campo di selezione del tipo della riga + hide_and_show_codriga(*_msk); // invoca la procedura di controllo della mutua esclusione dei tre campi CODRIGA + } + return (gotcha); +} + +bool TRighe_condizioni_vendita::user_destroy() { + delete _rel; + delete _msk; + return TRUE; +} + +void TRighe_condizioni_vendita::hide_and_show_codriga(TMask &m) { + short id_campi[3]= { F_R_CODRIGA_A, F_R_CODRIGA_G, F_R_CODRIGA_R }; // vettore degli identificatori dei tre campi CODRIGA in mutua esclusione + char tag_campi[3]= { 'A', 'G', 'R' }; // vettore dei tag di TIPORIGA per i tre campi CODRIGA in mutua esclusione + char tag_campo= m.get(F_R_TIPORIGA)[0]; // prende il tag in TIPORIGA del campo da abilitare + TString &_rcondven= app()._rcondven; // prende il riferimento alla stringa di tipo di archivio + TBit_array &_tohide= app()._tohide; // prende il riferimento all'array di campi da eliminare + for (int i=0; i<3; i++) { // ciclo sui tre campi CODRIGA + if (tag_campo == tag_campi[i]) { // il campo indicato con il tag viene... + m.efield(id_campi[i]).check_type(CHECK_REQUIRED); // ...abilitato al checking... + m.show(id_campi[i]); // ...mostrato... + _tohide.reset(id_campi[i]); // ...e rimosso dal vettore di eliminazione... + } else { // ...mentre gli altri vengono... + m.efield(id_campi[i]).check_type(CHECK_NONE); // ...disabilitati dal checking... + m.hide(id_campi[i]); // ...nascosti... + _tohide.set(id_campi[i]); // ...e aggiunti al vettore di eliminazione + } + } + if (_rcondven != "C") { // se non stiamo lavorando sui contratti... + if (tag_campo=='A') { // ...ed è stata selezionata una riga di articoli... + m.efield(F_R_LO_UM).check_type(CHECK_REQUIRED); // ...l'unità di misura viene attivata al checking... + m.enable(F_R_LO_UM); // ...e abilitata... + } else { // ...altrimenti, se è stata selezionata una riga non di articoli... + m.efield(F_R_LO_UM).check_type(CHECK_NONE); // ...l'unità di misura viene rimossa dal checking... + m.disable(F_R_LO_UM); // ...e disabilitata + } + } +} + +bool TRighe_condizioni_vendita::handle_tiporiga(TMask_field &fld, KEY k) { + if (k==K_TAB) hide_and_show_codriga(fld.mask()); // invoca la procedura di controllo della mutua esclusione dei tre campi CODRIGA + return TRUE; +} + +bool TRighe_condizioni_vendita::handle_cod(TMask_field &fld, KEY k) { + if ((k==K_TAB) && fld.get().not_empty()) { + TString &_rcondven= app()._rcondven; // prende il riferimento alla stringa di indicazione del tipo di archivio + TMask &m= fld.mask(); // prende la maschera principale + TLocalisamfile condv(LF_CONDV); // apre il file della testata (condizioni di vendita) + condv.put("TIPO", _rcondven); // riempie il campo "TIPO" + switch (_rcondven[0]) { + case 'L': // riempie il resto della chiave dei listini + condv.put("CATVEN", m.get(F_R_L_CATVEN)); + condv.put("COD", m.get(F_R_L_COD)); + break; + case 'C': // riempie il resto della chiave dei contratti + condv.put("TIPOCF", m.get(F_R_C_TIPOCF)); + condv.put("CODCF", m.get(F_R_C_CODCF)); + condv.put("COD", m.get(F_R_C_COD)); + break; + case 'O': // riempie il resto della chiave delle offerte + condv.put("COD", m.get(F_R_O_COD)); + break; + } + if (condv.read()==NOERR) { // se la lettura è andata a buon fine abilita/disabilita i campi della maschera in base ai booleani della testata + if (!condv.get_bool("GESTUM")) { + m.efield(F_R_LO_UM).check_type(CHECK_NONE); // disabilita il checking sul campo "unità di misura" + m.disable(F_R_LO_UM); // disabilita il campo "unità di misura" + } else { + m.efield(F_R_LO_UM).check_type(CHECK_REQUIRED); // abilita il checking sul campo "unità di misura" + m.enable(F_R_LO_UM); // abilita il campo "unità di misura" + } + if (!condv.get_bool("GESTSCAGL")) { + m.efield(F_R_NSCAGL).check_type(CHECK_NONE); // disabilita il checking sul campo "quantità limite scaglione" + m.disable(F_R_NSCAGL); // disabilita il campo "quantità limite scaglione" + m.disable(F_R_QLIM); // disabilita il campo "quantità limite scaglione" + } else { + m.efield(F_R_NSCAGL).check_type(CHECK_REQUIRED); // abilita il checking sul campo "quantità limite scaglione" + m.enable(F_R_NSCAGL); // abilita il campo "quantità limite scaglione" + m.enable(F_R_QLIM); // abilita il campo "quantità limite scaglione" + } + if (!condv.get_bool("GESTSCO")) { + m.disable(F_R_SCONTO); // disabilita il campo "sconto" + m.disable(F_R_QOM); // disabilita il campo "quantità art. omaggio" + m.disable(F_R_QBASE); // disabilita il campo "quantità base x sconto" + m.disable(F_R_CODARTOM); // disabilita il campo "codice articolo omaggio" + m.disable(F_R_PROMAGGIO); // disabilita il campo "prezzo omaggio" + m.disable(F_R_UMOM); // disabilita il campo "unità di misura art. omaggio" + } else { + m.enable(F_R_SCONTO); // abilita il campo "sconto" + m.enable(F_R_QOM); // abilita il campo "quantità art. omaggio" + m.enable(F_R_QBASE); // abilita il campo "quantità base x sconto" + m.enable(F_R_CODARTOM); // abilita il campo "codice articolo omaggio" + m.enable(F_R_PROMAGGIO); // abilita il campo "prezzo omaggio" + m.enable(F_R_UMOM); // abilita il campo "unità di misura art. omaggio" + } + return TRUE; + } else { + error_box("Non esiste una testata corrispondente alla chiave specificata"); + return FALSE; + } + } else return TRUE; +} + +int TRighe_condizioni_vendita::write(const TMask &m) { + m.autosave(_rel); // scrive il contenuto della maschera nel record della relazione + if (_rcondven != "C") { // se non si sta lavorando sui contratti il campo TIPOCF deve essere svuotato sul file + TLocalisamfile &f= _rel->lfile(); // prende il file principale della relazione + TRectype &r= f.curr(); // prende il record corrente del file principale + f.zero("TIPOCF"); // svuota il campo TIPOCF + } + _rel->write(); // invoca la scrittura della relazione + return (_rel->status()); // ritorna lo stato della relazione +} + +int TRighe_condizioni_vendita::rewrite(const TMask &m) { + m.autosave(_rel); // scrive il contenuto della maschera nel record della relazione + if (_rcondven != "C") { // se non si sta lavorando sui contratti il campo TIPOCF deve essere svuotato sul file + TLocalisamfile &f= _rel->lfile(); // prende il file principale della relazione + TRectype &r= f.curr(); // prende il record corrente del file principale + f.zero("TIPOCF"); // svuota il campo TIPOCF + } + _rel->rewrite(); // invoca la riscrittura della relazione + return (_rel->status()); // ritorna lo stato della relazione +} + +void TRighe_condizioni_vendita::init_query_mode(TMask &m) { + for (short i=(short)_tohide.first_one(); i<=(short)_tohide.last_one(); i++) { // ciclo sul vettore dei campi da eliminare + if (_tohide[i]) { + if (_msk->field(i).is_edit()) _msk->efield(i).check_type(CHECK_NONE); // disabilita il checking sul campo se è editabile + _msk->hide(i); // rende invisibile il campo + } + } + if (!_catven_on) { // se il booleano di abil. di CATVEN è falso... + _msk->efield(F_R_L_CATVEN).check_type(CHECK_NONE); // ...viene rimosso dal checking... + _msk->disable(F_R_L_CATVEN); // ...e disabilitato + } + _msk->set(F_R_TIPO, _rcondven); // settaggio del campo di tipo archivio +} + +int ve2300(int argc, char* argv[]) { + TRighe_condizioni_vendita a; + + a.run(argc, argv, "Righe condizioni vendita "); + return 0; +} + diff --git a/ve/veuml1.h b/ve/veuml1.h index 615c91ca7..9a51c5858 100755 --- a/ve/veuml1.h +++ b/ve/veuml1.h @@ -1,62 +1,65 @@ -#ifndef __VEUML1_H -#define __VEUML1_H - -#ifndef __VEUML_H -#include "VEUML.H" -#endif - -// gruppo dei vettori - -#define GR_VETTORI 15 - -// campi della maschera totale - -#define F_RAGSOC 301 -#define F_INDCF 302 -#define F_CIVCF 303 -#define F_NOME_VAL 304 -#define F_DESCODPAG 305 -#define F_DATASCAD1 306 -#define F_DATASCAD2 307 -#define F_DATASCAD3 308 -#define F_DATASCAD4 309 -#define F_DATASCAD5 310 -#define F_BANCA_APP 311 -#define F_BANCA_PRE 312 -#define F_INDSP 313 -#define F_CIVSP 314 -#define F_CAPSP 315 -#define F_LOCALITASP 316 -#define F_PORTO 317 -#define F_DENCAUSTRASP 318 -#define F_NOMEVETT1 319 -#define F_NOMEVETT2 320 -#define F_NOMEVETT3 321 -#define F_DESCRBENI1 322 -#define F_DESCRBENI2 323 -#define F_DESUMTARA 324 -#define F_DESUMPNETTO 325 -#define F_DESCRMAG1 326 -#define F_DESCRMAG2 327 -#define F_COFI 328 -#define F_STATOPAIVA 329 -#define F_LOCALITACF 330 -#define F_CAPCF 331 -#define F_COMCF 332 -#define F_PROVCOM 333 -#define F_STATOCF 334 -#define F_DATACAMBIO 335 -#define F_DESBANAPP 336 -#define F_DESLIN 337 -#define F_DESBANPRE 338 -#define F_NOMEVAL 339 -#define F_PAIVA 340 -#define F_DENCOM 341 -#define F_DESSTATOCF 342 -#define F_COMSP 343 -#define F_DENCOMSP 344 -#define F_PROVCOMSP 345 -#define F_STATOSP 346 -#define F_DESSTATOSP 347 -#define F_DESLIST 348 -#endif // __VEUML1_H +#ifndef __VEUML1_H +#define __VEUML1_H + +#ifndef __VEUML_H +#include "VEUML.H" +#endif + +// gruppo dei vettori + +#define GR_VETTORI 15 + +// campi della maschera totale + +#define F_RAGSOC 301 +#define F_INDCF 302 +#define F_CIVCF 303 +#define F_NOME_VAL 304 +#define F_DESCODPAG 305 +// I prossimi 5 campi devono essere consecutivi come numerazione +// perchè faccio un ciclo per settarli +#define F_DATASCAD1 306 +#define F_DATASCAD2 307 +#define F_DATASCAD3 308 +#define F_DATASCAD4 309 +#define F_DATASCAD5 310 +#define F_BANCA_APP 311 +#define F_BANCA_PRE 312 +#define F_INDSP 313 +#define F_CIVSP 314 +#define F_CAPSP 315 +#define F_LOCALITASP 316 +#define F_PORTO 317 +#define F_DENCAUSTRASP 318 +#define F_NOMEVETT1 319 +#define F_NOMEVETT2 320 +#define F_NOMEVETT3 321 +#define F_DESCRBENI1 322 +#define F_DESCRBENI2 323 +#define F_DESUMTARA 324 +#define F_DESUMPNETTO 325 +#define F_DESCRMAG1 326 +#define F_DESCRMAG2 327 +#define F_COFI 328 +#define F_STATOPAIVA 329 +#define F_LOCALITACF 330 +#define F_CAPCF 331 +#define F_COMCF 332 +#define F_PROVCOM 333 +#define F_STATOCF 334 +#define F_DATACAMBIO 335 +#define F_DESBANAPP 336 +#define F_DESLIN 337 +#define F_DESBANPRE 338 +#define F_NOMEVAL 339 +#define F_PAIVA 340 +#define F_DENCOM 341 +#define F_DESSTATOCF 342 +#define F_COMSP 343 +#define F_DENCOMSP 344 +#define F_PROVCOMSP 345 +#define F_STATOSP 346 +#define F_DESSTATOSP 347 +#define F_DESLIST 348 +#define F_RAGSOCSP 349 +#endif // __VEUML1_H