e39175d953
git-svn-id: svn://10.65.10.50/branches/R_10_00@22762 c028cbd2-c16b-5b4b-a496-9718f37d4682
1823 lines
46 KiB
C++
Executable File
1823 lines
46 KiB
C++
Executable File
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||
|
||
"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.
|
||
|
||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||
|
||
#include <applicat.h>
|
||
#include <progind.h>
|
||
#include <tabutil.h>
|
||
#include <urldefid.h>
|
||
#include <utility.h>
|
||
|
||
#include "veuml.h"
|
||
#include "veuml1.h"
|
||
|
||
#include "veini.h"
|
||
#include "ve0100.h"
|
||
|
||
// 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 23
|
||
#define MASK_FIRST_LINE 6
|
||
|
||
#define GROUPKEY(x) format( "%5d", x )
|
||
|
||
#define Usage "Sintassi: VE0 -3 <Nome file di profilo> [-f<stdfile>]"
|
||
|
||
#define B0_POSITION 47
|
||
#define B1_POSITION 48
|
||
#define S0_POSITION 2
|
||
#define I0_POSITION 14
|
||
|
||
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 page, const TString& title = EMPTY_STRING );
|
||
|
||
// 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" ); };
|
||
|
||
// FLAGS
|
||
void flag( const char* s ) { _out << "FL \"" << 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"; };
|
||
|
||
// MODULE
|
||
void module( const TString& m ) { _out << "MO " << m << "\n"; };
|
||
|
||
// PICTURE
|
||
void picture( const int p) { _out << "PI " << p << "\n"; };
|
||
// void picture( const TString & s) { _out << "PI " << '\"' << s << "\"\n"; };
|
||
void picture( const char* s) { _out << "PI " << '\"' << s << "\"\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 TString& s );
|
||
void use( const int file, const int key ){ _out << "US " << file << " KEY " << key << "\n"; };
|
||
void use( const TString& tab, const int key ){ _out << "US " << tab << " 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 " ); };
|
||
|
||
// copy
|
||
void copy( const TString& s ){ outline( s, "CO " ); };
|
||
|
||
// Funzioni per la lettura/scrittura di CURPAGE
|
||
int page( ) { return _curpage; };
|
||
void page( const int i ){ _curpage = i; };
|
||
|
||
void output_row( const TString& row){ _out << row << "\n"; };
|
||
|
||
// 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 ho gia' generato lo sheet
|
||
bool _sheet_generated;
|
||
|
||
// File .MSK di output
|
||
ofstream _out;
|
||
|
||
};
|
||
|
||
void TMaschera::pagina(const int page, const TString& title)
|
||
{
|
||
_out << "PA \"" << (title.blank() ? TString("Pag.") << " " << page : title) << "\" 11 60 14\n";
|
||
}
|
||
|
||
// Classe per memorizzare gli elementi di FRD
|
||
class _TableItem : public TObject
|
||
{
|
||
bool _b0, _b1;
|
||
TString _s0;
|
||
int _i0;
|
||
|
||
public:
|
||
virtual TObject* dup() const { return new _TableItem(*this); }
|
||
const bool b0() { return _b0;}
|
||
const bool b1() { return _b1;}
|
||
const TString& s0() { return _s0;}
|
||
int i0() { return _i0;}
|
||
void set_b0(const bool b) { _b0 = b;}
|
||
void set_b1(const bool b) { _b1 = b;}
|
||
void set_s0(const TString& s) { _s0 = s;}
|
||
void set_i0(int i) { _i0 = i;}
|
||
_TableItem() {_b0 = FALSE;}
|
||
virtual ~_TableItem() {}
|
||
};
|
||
|
||
class TMask_generator
|
||
{
|
||
// Identificatore corrente per lo sheet
|
||
int _curid;
|
||
|
||
// vero se il gruppo h aperto
|
||
bool _groupopen;
|
||
|
||
// nome del file di .INI di input
|
||
TFilename _proname;
|
||
|
||
// File .INI di riferimento per i campi
|
||
TConfig _fieldsini;
|
||
|
||
// File .INI di riferimento per i gruppi
|
||
TConfig _groupsini;
|
||
|
||
// File .INI di input
|
||
TConfig* _pro;
|
||
|
||
//TConfig _ditta;
|
||
|
||
// Tabelle per la generazione
|
||
|
||
// Campi dei documenti
|
||
TString_array _fields;
|
||
|
||
// Campi dello sheet
|
||
TString_array _tab0300b;
|
||
|
||
TAssoc_array _gruppi;
|
||
|
||
// Tabella caricata dal file testo
|
||
TAssoc_array _frdtable;
|
||
TString _tablefile;
|
||
|
||
TMaschera *_m;
|
||
|
||
protected:
|
||
|
||
// Carica un file di tabella in un TString array
|
||
void carica_tabella( const TFilename& fn, TString_array& tabella );
|
||
|
||
// Scrive sul file di output una serie di righe uguali per funzione ( DISPLAY, ecc. )
|
||
void outline( const TString& s = "", const TString& prefix = "", const char sep = '~' );
|
||
|
||
|
||
// Crea un controllo del tipo specificato
|
||
void control( const int type, const int id = DLG_NULL, const int size = -1 );
|
||
|
||
// Ritorna vero se una componente della maschera h presente
|
||
int present( const int i, TToken_string line ){ const TString s = line.get( i ); return !(s.blank( )); };
|
||
|
||
// Carica dati dei campi
|
||
void carica_dati_campi( const TFilename& fn, TAssoc_array& a );
|
||
|
||
// Funzioni di accesso alle variabili private
|
||
// ------------------------------------------
|
||
|
||
// Funzioni per la lettura/scrittura di ID. Si incrementa da solo.
|
||
int id ( ) { return( _curid++ ); };
|
||
void id( const int i ){ _curid = i; };
|
||
|
||
|
||
// Funzioni di generazione ad alto livello
|
||
// ---------------------------------------
|
||
|
||
// Genera un campo a partire da una linea del file VE0300A.DAT
|
||
void genera_campo( TToken_string _line );
|
||
|
||
// Genera la colonna dello sheet a partire da una linea del file VE0300B.DAT
|
||
void genera_item_sheet( TToken_string _line );
|
||
bool check_file(const char* filename) const;
|
||
|
||
public:
|
||
|
||
|
||
TMaschera& maschera( ){ return *_m; }
|
||
|
||
void genera_sheet(int line = 5, bool show_list = true, bool genera_disp = true);
|
||
// Attiva la generazione della maschera
|
||
void genera( const TString& profilo);
|
||
|
||
void genera_testata_1();
|
||
// Genera l'intestazione di una pagina ( non la prima )
|
||
void intestazione_pagina( const char* def_title = TR("Parametri"));
|
||
|
||
// Carica la tabella FRD da file testo
|
||
void load_table();
|
||
|
||
TConfig& profilo( ){ return *_pro; }
|
||
TConfig& groupsini( ){ return _groupsini; }
|
||
TConfig& fieldsini( ){ return _fieldsini; }
|
||
|
||
// Costruttore, vuole il nome del file .INI
|
||
TMask_generator(const TString& tablefile);
|
||
|
||
// Distruttore
|
||
virtual ~TMask_generator( ) {}
|
||
|
||
};
|
||
|
||
TMaschera::TMaschera( const TFilename outfile ) : _out( outfile )
|
||
{
|
||
_curline = 1;
|
||
_curpage = 1;
|
||
_sheet_generated = 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";
|
||
FOR_EACH_TOKEN(u, t)
|
||
_out << prefix << t << '\n';
|
||
}
|
||
}
|
||
|
||
void TMaschera::check( const int i )
|
||
{
|
||
switch( i )
|
||
{
|
||
case S_OBBLIGATORIO:
|
||
outline ( "CH REQUIRED" );
|
||
break;
|
||
case S_NORMALE:
|
||
outline ( "CH NORMAL" );
|
||
break;
|
||
default:
|
||
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_ZOOM:
|
||
_out << "ZO";
|
||
break;
|
||
case T_GOLEM:
|
||
_out << "GO";
|
||
break;
|
||
case T_CURRENCY:
|
||
_out << "CU";
|
||
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 ++ )
|
||
{
|
||
s = u.get();
|
||
|
||
_out << "IT \"" << s.get(0) << "\"\n";
|
||
for( j = 1; j < s.items( ); j ++ )
|
||
_out << "ME " << s.get() << "\n";
|
||
}
|
||
}
|
||
|
||
void TMaschera::use(const TString& s)
|
||
{
|
||
if ( s.left( 1 ) == "@" )
|
||
_out << "CO US " << s.mid( 1 ) << "\n";
|
||
else
|
||
{
|
||
TToken_string u( s, '~');
|
||
_out << "US " << u.get(0) << "\n";
|
||
for ( int i = 1; i < u.items( ); i ++ )
|
||
_out << u.get( i ) << "\n";
|
||
}
|
||
}
|
||
|
||
class TField;
|
||
|
||
class TGruppo : public TObject
|
||
{
|
||
protected:
|
||
|
||
int _id;
|
||
int _height;
|
||
bool _present;
|
||
TArray _fields;
|
||
TMask_generator * _mg;
|
||
|
||
public:
|
||
|
||
TMaschera& maschera( ){ return generatore( ).maschera( ); }
|
||
TMask_generator& generatore( ) const { CHECK( _mg, "Generatore nullo!" ); return *_mg; }
|
||
void generatore( TMask_generator& mg ) { _mg = &mg; }
|
||
void id( int id ) { _id = id; }
|
||
int id( ) const { return _id; }
|
||
void height( int h ) { _height = h; }
|
||
int height( ) const { return _height; }
|
||
void present( bool p ) { _present = p; }
|
||
bool present( ) const { return _present; }
|
||
TArray& campi( ) { return _fields; }
|
||
const bool is_testata() const;
|
||
virtual TObject* dup() const;
|
||
|
||
TGruppo ( int i );
|
||
TGruppo ( int i, int height );
|
||
void genera( );
|
||
void add( TField * field );
|
||
|
||
};
|
||
|
||
class TField : public TObject
|
||
{
|
||
TString _nome;
|
||
// Gruppo di appartenenza
|
||
TGruppo * _grp;
|
||
|
||
int _gruppo;
|
||
int _id;
|
||
int _type;
|
||
int _size;
|
||
int _stato;
|
||
int _x, _y;
|
||
TString _prompt, _flag, _help, _warning, _fieldname, _modules;
|
||
TToken_string _use, _input, _display, _output, _special, _items, _configs;
|
||
TToken_string _copy;
|
||
|
||
public:
|
||
|
||
TField( TString& campo, TConfig& pro );
|
||
TField( );
|
||
virtual TObject* dup() const;
|
||
|
||
void genera( );
|
||
void configura( TConfig& pro );
|
||
|
||
void x( int x ){ _x = x; }
|
||
void y( int y ){ _y = y; }
|
||
void gruppo(int gruppo) { _gruppo = gruppo; }
|
||
void grp(TGruppo * grp) { _grp = grp; }
|
||
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( ) const { return _x; }
|
||
int y( ) const { return _y; }
|
||
int gruppo( ) const{ return _gruppo; }
|
||
TGruppo& grp( ) const { CHECK(_grp, "NULL group in field"); return *_grp; }
|
||
int id( ) const { return _id; }
|
||
int type( ){ return _type; }
|
||
int size( ){ return _size; }
|
||
int stato( ){ return _stato; }
|
||
int stato_reale( );
|
||
|
||
void nome( const TString& nome ){ _nome = nome; }
|
||
void prompt( const TString& prompt ){ _prompt = prompt; }
|
||
void flag( const TString& flag ){ _flag = flag; }
|
||
void help( const TString& help ){ _help = help; }
|
||
void warning( const TString& warning ){ _warning = warning; }
|
||
void fieldname( const TString& fieldname ){ _fieldname = fieldname; }
|
||
void modules( const TString& m ){ _modules = m; }
|
||
TString& nome( ){ return _nome; }
|
||
TString& prompt( ){ return _prompt; }
|
||
TString& flag( ){ return _flag; }
|
||
TString& help( ){ return _help; }
|
||
TString& warning( ){ return _warning; }
|
||
TString& fieldname( ){ return _fieldname; }
|
||
TString& modules( ){ return _modules; }
|
||
|
||
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 copy( TToken_string& copy ){ _copy = copy; }
|
||
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& copy( ){ return _copy; }
|
||
TToken_string& special( ){ return _special; }
|
||
TToken_string& items( ){ return _items; }
|
||
TToken_string& configs( ){ return _configs; }
|
||
|
||
TConfig& profilo( ) { CHECK(_grp, "NULL group in field"); return grp().generatore().profilo(); }
|
||
//TConfig& ditta( ) { CHECK(_grp, "NULL group in field"); return grp().generatore().ditta(); }
|
||
TConfig& groupsini( ) { CHECK(_grp, "NULL group in field"); return grp().generatore().groupsini(); }
|
||
TConfig& fieldsini( ) { CHECK(_grp, "NULL group in field"); return grp().generatore().fieldsini(); }
|
||
|
||
};
|
||
|
||
void TGruppo::add( TField * field )
|
||
{
|
||
_fields.add(field);
|
||
field->grp(this);
|
||
}
|
||
|
||
const bool TGruppo::is_testata() const
|
||
{
|
||
FOR_EACH_ARRAY_ITEM(_fields, i, o)
|
||
{
|
||
TField* campo = (TField*) o;
|
||
if(campo->id() == F_STATO)
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
TGruppo::TGruppo( int i )
|
||
{
|
||
_id = i;
|
||
_height = 0;
|
||
}
|
||
|
||
TGruppo::TGruppo( int i, int height )
|
||
{
|
||
_id = i;
|
||
_height = height;
|
||
}
|
||
|
||
static void genera_campo( const TObject& campo )
|
||
{
|
||
// Per evitare 3000 casts ...
|
||
TField& cmp = (TField&) campo;
|
||
|
||
cmp.configura(cmp.grp().generatore().profilo());
|
||
cmp.genera();
|
||
}
|
||
|
||
static void verifica_campo( const TObject& campo )
|
||
{
|
||
// Per evitare 3000 casts ...
|
||
TField& cmp = (TField&)campo;
|
||
TGruppo & gruppo = cmp.grp();
|
||
|
||
cmp.stato(cmp.stato_reale());
|
||
if (cmp.stato() != S_NASCOSTO && cmp.stato() != S_NON_VISIBILE)
|
||
{
|
||
int h = cmp.y() + 1;
|
||
if (cmp.type() == T_CORNICE || cmp.type() == T_MEMO || cmp.type() == T_GOLEM )
|
||
h += cmp.size()%100 - 1;
|
||
if (gruppo.height() < h)
|
||
gruppo.height(h);
|
||
if (!gruppo.present())
|
||
gruppo.present(TRUE);
|
||
}
|
||
}
|
||
|
||
HIDDEN TProgind* _bar = NULL;
|
||
|
||
static void genera_gruppo( const TObject& gruppo )
|
||
{
|
||
// Per evitare 3000 casts
|
||
static TMask_generator * _mask_generator = NULL;
|
||
if (gruppo.class_id() == CLASS_STRING)
|
||
{
|
||
TFilename fname((TString &) gruppo);
|
||
TMask_generator & g = *_mask_generator;
|
||
TMaschera & m = g.maschera();
|
||
int row = m.line( ) - 1;
|
||
|
||
if (fname.starts_with("SHEET"))
|
||
{
|
||
g.genera_sheet(row, fname.find("LIST") > 0, fname.find("GIAC") > 0);
|
||
g.intestazione_pagina(TR("Righe"));
|
||
}
|
||
else
|
||
{
|
||
if (fname.ext()[0] == '\0')
|
||
fname.ext("msk");
|
||
if (fexist(fname))
|
||
{
|
||
TScanner scanner(fname);
|
||
TString line(128);
|
||
|
||
line = scanner.line();
|
||
|
||
while (scanner.ok())
|
||
{
|
||
int row_pos = line.find("%R");
|
||
const bool new_line = (row_pos > 0);
|
||
if (!new_line)
|
||
row_pos = line.find("%S");
|
||
const bool field = line.left(2) == "%F";
|
||
|
||
if (field && row > MAX_LINES_PER_PAGE)
|
||
{
|
||
// Passa alla pagina successiva
|
||
m.end( );
|
||
g.intestazione_pagina();
|
||
}
|
||
if (row_pos > 0)
|
||
{
|
||
if (new_line)
|
||
row++;
|
||
|
||
TString4 wrk; wrk.format("%02d", row);
|
||
line[row_pos++] = wrk[0];
|
||
line[row_pos] = wrk[1];
|
||
}
|
||
if (field)
|
||
m.output_row("");
|
||
else
|
||
m.output_row(line);
|
||
line = scanner.line();
|
||
}
|
||
m.line(row + 1);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
TGruppo & grp = (TGruppo &) gruppo;
|
||
|
||
grp.present(FALSE);
|
||
if (_mask_generator == NULL)
|
||
_mask_generator = &(grp.generatore());
|
||
|
||
grp.campi().for_each(verifica_campo);
|
||
do_events();
|
||
if (grp.present())
|
||
grp.genera();
|
||
if (_bar)
|
||
_bar->addstatus(1);
|
||
}
|
||
|
||
}
|
||
|
||
TObject* TGruppo::dup() const
|
||
|
||
{
|
||
TGruppo* g = new TGruppo(id(), height());
|
||
|
||
g->generatore(generatore());
|
||
g->present(present());
|
||
g->_fields = _fields;
|
||
TArray & fields = g->campi();
|
||
const int items = fields.items();
|
||
|
||
for (int i = 0; i < items; i++)
|
||
((TField &)fields[i]).grp(g);
|
||
return g;
|
||
}
|
||
|
||
void TGruppo::genera( )
|
||
{
|
||
// Se il gruppo non sta sulla pagina ...
|
||
int oldlinea = maschera( ).line( );
|
||
if ( oldlinea + _height > MAX_LINES_PER_PAGE )
|
||
{
|
||
// Passa alla pagina successiva
|
||
maschera( ).end( );
|
||
generatore( ).intestazione_pagina( );
|
||
maschera( ).line( MASK_FIRST_LINE );
|
||
oldlinea = MASK_FIRST_LINE;
|
||
}
|
||
_fields.for_each( genera_campo );
|
||
maschera( ).line( oldlinea + _height );
|
||
}
|
||
|
||
TField::TField( TString& campo, TConfig& pro ) : _nome( campo )
|
||
{
|
||
_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.rtrim(1);
|
||
_prompt.ltrim(1);
|
||
};
|
||
_flag = pro.get( "FLAG", campo );
|
||
_help = pro.get( "HELP", campo );
|
||
_warning = pro.get( "WARNING", campo );
|
||
_modules = pro.get( "MODULE", campo ); _modules.strip("\"");
|
||
_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( '~' );
|
||
_copy = pro.get( "COPY", campo );
|
||
_copy.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;
|
||
_stato = 0;
|
||
_grp = NULL;
|
||
_id = 0;
|
||
_type = 0;
|
||
_size = 0;
|
||
_prompt = "";
|
||
_flag = "";
|
||
_help = "";
|
||
_warning = "";
|
||
_modules = "";
|
||
_use = "";
|
||
_use.separator( '~' );
|
||
_input = "";
|
||
_input.separator( '~' );
|
||
_display = "";
|
||
_display.separator( '~' );
|
||
_output = "";
|
||
_output.separator( '~' );
|
||
_copy = "";
|
||
_copy.separator( '~' );
|
||
_special = "";
|
||
_special.separator( '~' );
|
||
_configs = "";
|
||
_configs.separator( '~' );
|
||
_items = "";
|
||
_items.separator( '@' );
|
||
}
|
||
|
||
TObject* TField::dup() const
|
||
{
|
||
TField * f = new TField;
|
||
|
||
f->_nome = _nome;
|
||
f->_fieldname = _fieldname;
|
||
f->_x = _x;
|
||
f->_y = _y;
|
||
f->_gruppo = _gruppo;
|
||
f->_stato = _stato;
|
||
f->_type = _type;
|
||
f->_size = _size;
|
||
f->_prompt = _prompt;
|
||
f->_flag = _flag;
|
||
f->_help = _help;
|
||
f->_warning = _warning;
|
||
f->_modules = _modules;
|
||
f->_use = _use;
|
||
f->_id = _id;
|
||
f->_input = _input;
|
||
f->_display = _display;
|
||
f->_output = _output;
|
||
f->_copy = _copy;
|
||
f->_special = _special;
|
||
f->_items = _items;
|
||
f->_configs = _configs;
|
||
return f;
|
||
}
|
||
|
||
int TField::stato_reale()
|
||
{
|
||
// Strategia al 28/08/95
|
||
// Se il campo, nel file .INI di definizione dei campi, <20> legato a qualche voce in
|
||
// configurazione, legge il suo stato, altrimenti assume il massimo.
|
||
// Va poi a verificare nel .INI da compilare, e verifica l<> la impostazione.
|
||
// Controlla poi la impostazione per il gruppo, come impostato nel file .INI
|
||
// e nella sezione CONFIGS nel .INI di definizione dei gruppi.
|
||
// Utilizza poi la minore delle due.
|
||
int stato = S_OBBLIGATORIO;
|
||
|
||
TToken_string riga_profilo(grp().generatore().profilo().get(_nome, "PROFILO"));
|
||
const int stato_profilo = riga_profilo.get_int(P_STATO);
|
||
|
||
if (stato > stato_profilo )
|
||
stato = stato_profilo;
|
||
|
||
if (stato > S_NON_VISIBILE)
|
||
{
|
||
const TString80 gruppo(fieldsini().get("GROUP", _nome));
|
||
int stato_gruppo = S_OBBLIGATORIO;
|
||
if (stato > stato_gruppo)
|
||
stato = stato_gruppo;
|
||
|
||
const int stato_gruppo_profilo = grp().generatore().profilo().get_int(gruppo, "PROFILOGRUPPO");
|
||
|
||
if (stato > stato_gruppo_profilo)
|
||
stato = stato_gruppo_profilo;
|
||
}
|
||
return stato;
|
||
}
|
||
|
||
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 = grp().maschera();
|
||
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_NON_VISIBILE :
|
||
m.prompt( 50, 50, _prompt );
|
||
s = "D";
|
||
s << _flag;
|
||
m.flag( s ) ;
|
||
break;
|
||
case S_DISABILITATO :
|
||
m.prompt( _x, _y + m.line( ), _prompt );
|
||
s = "D";
|
||
s << _flag;
|
||
m.flag( s ) ;
|
||
break;
|
||
case S_NORMALE :
|
||
case S_OBBLIGATORIO :
|
||
case S_NOCHECK :
|
||
m.prompt( _x, _y + m.line( ), _prompt );
|
||
if (_flag.full()) m.flag( _flag );
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
if ((_type == T_DATA || _type == T_STRINGA ||
|
||
_type == T_NUMERO || _type == T_MEMO || _type == T_ZOOM ||
|
||
_type == T_GOLEM || _type == T_CURRENCY) &&
|
||
(_stato == S_OBBLIGATORIO || (!_use.blank())))
|
||
m.check( _stato );
|
||
if ( _fieldname.full( ) ) m.field( _fieldname );
|
||
if ( _items.full( ) ) m.item( _items );
|
||
if ( _use.full( ) ) m.use( _use );
|
||
if ( _input.full( ) ) m.input( _input );
|
||
if ( _display.full( ) ) m.display( _display );
|
||
if ( _output.full( ) ) m.output( _output );
|
||
if ( _copy.full( ) ) m.copy( _copy );
|
||
if ( _help.full( ) ) m.help( _help );
|
||
if ( _warning.full( ) ) m.warning( _warning );
|
||
if ( _special.full( ) ) m.outline( _special );
|
||
if ( _modules.full()) m.module(_modules);
|
||
m.end( );
|
||
if ( ( m.line( ) > MAX_LINES_PER_PAGE ))
|
||
m.end( );
|
||
}
|
||
|
||
// Definizione dei metodi di_generator
|
||
// -----------------------------------------
|
||
|
||
bool TMask_generator::check_file(const char* filename) const
|
||
{
|
||
if (fsize(filename) <= 0)
|
||
return cantread_box(filename);
|
||
return true;
|
||
}
|
||
|
||
TMask_generator::TMask_generator(const TString& tablefile) : _fieldsini( "ve0300a.ini" ), _groupsini( "ve0300c.ini" )
|
||
{
|
||
if (!check_file("ve0300a.ini") || !check_file("ve0300b.dat"))
|
||
exit(1);
|
||
|
||
_fieldsini.list_paragraphs( _fields );
|
||
carica_tabella( "ve0300b.dat", _tab0300b );
|
||
carica_dati_campi( "ve0300a.ini", _gruppi );
|
||
_tablefile = tablefile;
|
||
}
|
||
|
||
void TMask_generator::carica_dati_campi( const TFilename& fn, TAssoc_array& a )
|
||
{
|
||
TScanner infile( fn );
|
||
TString line;
|
||
TField *campo = NULL;
|
||
TGruppo *gruppo = NULL;
|
||
TString8 curgruppo;
|
||
|
||
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 )
|
||
{
|
||
const TString8 fieldkey = GROUPKEY( campo->gruppo( ) );
|
||
if ( fieldkey != curgruppo )
|
||
{
|
||
if ( gruppo )
|
||
{
|
||
a.add( curgruppo, gruppo );
|
||
}
|
||
TString16 taggruppo;
|
||
taggruppo.format( "%d", campo->gruppo( ) );
|
||
gruppo = new TGruppo( campo->gruppo( ));
|
||
gruppo->generatore( *this );
|
||
}
|
||
gruppo->add( campo );
|
||
curgruppo = GROUPKEY( campo->gruppo( ) );
|
||
}
|
||
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 == "COPY" )
|
||
campo->copy( (TToken_string & )value );
|
||
else if( key == "WARNING" )
|
||
campo->warning( value );
|
||
else if( key == "HELP" )
|
||
campo->help( value );
|
||
else if( key == "MODULE" )
|
||
campo->modules( 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 )
|
||
{
|
||
if( format( "%5d", campo->gruppo( ) ) != curgruppo )
|
||
{
|
||
if( gruppo )
|
||
{
|
||
a.add( curgruppo, gruppo );
|
||
}
|
||
TString16 taggruppo;
|
||
taggruppo.format("%d", campo->gruppo());
|
||
gruppo = new TGruppo(campo->gruppo());
|
||
gruppo->generatore( *this );
|
||
}
|
||
gruppo->add( campo );
|
||
curgruppo = GROUPKEY( campo->gruppo( ) );
|
||
a.add( curgruppo, gruppo );
|
||
}
|
||
}
|
||
|
||
void TMask_generator::carica_tabella( const TFilename& fn, TString_array& tabella )
|
||
{
|
||
TScanner in( fn );
|
||
TToken_string line(in.line());
|
||
while( line.not_empty( ) )
|
||
{ // Attacca tutte le righe che finiscono con <20>
|
||
while ( line.right( 1 ) == "<EFBFBD>" )
|
||
{ line.rtrim( 1 );
|
||
line << in.line( );
|
||
};
|
||
tabella.add( line );
|
||
line = in.line( );
|
||
}
|
||
}
|
||
|
||
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( const char* def_title)
|
||
{
|
||
_m->line( MASK_FIRST_LINE );
|
||
_m->page( _m->page( ) + 1 );
|
||
|
||
const TString80 title(profilo().get("Title", "MAIN", _m->page(), def_title));
|
||
|
||
_m->pagina( _m->page(), title);
|
||
|
||
_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->flag( "D" );
|
||
_m->group( 2 );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, DLG_NULL, 50 );
|
||
_m->begin( );
|
||
_m->prompt( 24, 1 );
|
||
_m->flag( "D" );
|
||
_m->group( 3 );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, DLG_NULL, 4 );
|
||
_m->begin( );
|
||
_m->prompt( 2, 2, "Tipo doc. " );
|
||
_m->flag( "D" );
|
||
_m->group( 4 );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, DLG_NULL, 50 );
|
||
_m->begin( );
|
||
_m->prompt( 24, 2 );
|
||
_m->flag( "D" );
|
||
_m->group( 5 );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, DLG_NULL, 4 );
|
||
_m->begin( );
|
||
_m->prompt( 2, 3, "Esercizio " );
|
||
_m->group( 9 );
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
_m->control( T_NUMERO, DLG_NULL, 6 );
|
||
_m->begin( );
|
||
_m->prompt( 24, 3, "Numero doc. " );
|
||
_m->group( 6 );
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
_m->control( T_DATA, DLG_NULL );
|
||
_m->begin( );
|
||
_m->prompt( 46, 3, "Data " );
|
||
_m->group( 7 );
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, DLG_NULL, 1 );
|
||
_m->begin( );
|
||
_m->prompt( 67, 3, "Stato " );
|
||
_m->group( 8 );
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
_m->control( T_NUMERO, DLG_NULL, 6 );
|
||
_m->begin( );
|
||
if ( _pro->get( "TIPOCF", "MAIN" ) == "C" )
|
||
_m->prompt( 2, 4, "Cliente " );
|
||
else
|
||
_m->prompt( 2, 4, "Fornitore " );
|
||
_m->group( 10 );
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, DLG_NULL, 50 );
|
||
_m->begin( );
|
||
_m->prompt( 24, 4, "" );
|
||
_m->group( 11 );
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
}
|
||
|
||
void TMask_generator::load_table()
|
||
{
|
||
_frdtable.destroy();
|
||
if (!fexist(_tablefile))
|
||
fatal_box("Il file %s per il caricamento formule documento non esiste.", (const char*) _tablefile);
|
||
|
||
TScanner f(_tablefile);
|
||
TToken_string s(1024);
|
||
TString token;
|
||
int b0pos = B0_POSITION, s0pos = S0_POSITION, i0pos = I0_POSITION, b1pos = B1_POSITION;
|
||
if (f.paragraph("Header"))
|
||
{
|
||
s = f.line();
|
||
if (s.find("Version") > -1)
|
||
s = f.line();
|
||
if (s.find("File") > -1)
|
||
s = f.line();
|
||
int totitem = 0;
|
||
while (s.find("Fields") > -1)
|
||
{
|
||
const int items = s.items();
|
||
for (int i = 0; i < items; i++)
|
||
{
|
||
int pos = totitem + i;
|
||
if (strstr(s.get(i),"S0,") != NULL)
|
||
s0pos = pos;
|
||
if (strstr(s.get(i),"I0,") != NULL)
|
||
i0pos = pos;
|
||
if (strstr(s.get(i),"B0,") != NULL)
|
||
b0pos = pos;
|
||
if (strstr(s.get(i),"B1,") != NULL)
|
||
b1pos = pos;
|
||
}
|
||
totitem += items;
|
||
s = f.line();
|
||
}
|
||
}
|
||
|
||
if (!f.paragraph("Data"))
|
||
fatal_box("Manca il paragrafo [Data] nel file %s.", (const char*) _tablefile);
|
||
s = f.line();
|
||
while (s.not_empty())
|
||
{
|
||
s.restart();
|
||
token = s.get(0);
|
||
if (token == "FRD")
|
||
{
|
||
token = s.get(1);
|
||
if (_frdtable.objptr(token) == NULL)
|
||
{
|
||
_TableItem* t = new _TableItem;
|
||
t->set_b0(s.get_char(b0pos) == 'X');
|
||
t->set_b1(s.get_char(b1pos) == 'X');
|
||
t->set_s0(s.get(s0pos));
|
||
t->set_i0(s.get_int(i0pos));
|
||
_frdtable.add(token, t);
|
||
}
|
||
}
|
||
s = f.line();
|
||
}
|
||
}
|
||
|
||
void TMask_generator::genera_sheet(int line, bool show_list, bool genera_disp)
|
||
{
|
||
line++;
|
||
if (genera_disp)
|
||
{
|
||
// Generazione del campo con la giacenza della riga corrente
|
||
_m->control ( T_NUMERO, F_CURGIAC, 15 );
|
||
_m->begin( );
|
||
_m->prompt( 2, line, "Riga corrente: Giacenza ");
|
||
_m->flag("D");
|
||
_m->picture(".5");
|
||
_m->end( );
|
||
|
||
// Generazione del campo con la disponibilita' della riga corrente
|
||
_m->control ( T_NUMERO, F_CURDISP, 15 );
|
||
_m->begin( );
|
||
_m->prompt( 44, line++, "Disponibilita' ");
|
||
_m->flag("D");
|
||
_m->picture(".5");
|
||
_m->end( );
|
||
}
|
||
|
||
// Generazione del listbox per i tipi di riga da aggiungere nello sheet
|
||
_m->control ( T_LISTA, F_LBTIPORIGA, 30 );
|
||
_m->begin( );
|
||
_m->prompt( 2, show_list ? line : -1, "Tipo riga da aggiungere " );
|
||
if (show_list)
|
||
line++;
|
||
else
|
||
_m->flag("H");
|
||
_m->end( );
|
||
|
||
// Generazione dello sheet : vedi il profilo
|
||
const int sh_y = profilo().get_int("SHEET_LINE");
|
||
if (sh_y > 0)
|
||
line = sh_y;
|
||
TScanner sheet_in( "ve0300b.dat" );
|
||
_m->_out << "SPREADSHEET " << F_SHEET << "\n";
|
||
_m->begin( );
|
||
_m->prompt( 2, line );
|
||
do_events();
|
||
for(int i = 0; i < _tab0300b.items( ); i ++ )
|
||
genera_item_sheet( _tab0300b.row( i ) );
|
||
_m->end( );
|
||
_m->end( );
|
||
_m->_sheet_generated = true;
|
||
}
|
||
|
||
void TMask_generator::genera_testata_1()
|
||
{
|
||
TString temp_s;
|
||
const char tipo_cf = _pro->get_char("TIPOCF", "MAIN");
|
||
|
||
_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(DOC_CODNUM);
|
||
_m->use("%NUM", 1);
|
||
temp_s.format("CODTAB %d", F_CODNUM);
|
||
_m->input(temp_s);
|
||
_m->display("\"Codice\" CODTAB~\"Descrizione@50\" S0");
|
||
temp_s.format("%d S0", F_DESNUM);
|
||
_m->output(temp_s);
|
||
_m->check(S_NORMALE);
|
||
_m->flag( "GDU" );
|
||
_m->message( "CO,2@" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, F_DESNUM, 50 );
|
||
_m->begin( );
|
||
_m->prompt( 24, 1 );
|
||
_m->flag( "GD" );
|
||
_m->message( "CO,3@" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, F_TIPODOC, 4 );
|
||
_m->begin( );
|
||
_m->field( DOC_TIPODOC );
|
||
_m->prompt( 2, 2, "Tipo doc. " );
|
||
_m->use("%TIP" , 1);
|
||
temp_s.format("CODTAB %d", F_TIPODOC);
|
||
_m->input(temp_s);
|
||
_m->display("\"Codice\" CODTAB~\"Descrizione@50\" S0");
|
||
temp_s.format("%d S0", F_DESTIPODOC);
|
||
_m->output(temp_s);
|
||
_m->check(S_NORMALE);
|
||
_m->flag( "GDU" );
|
||
_m->message( "CO,4@" );
|
||
_m->end( );
|
||
|
||
_m->control( T_LISTA, F_TIPOCF, 9 );
|
||
_m->begin( );
|
||
_m->prompt( 100, 100, "" );
|
||
_m->field( DOC_TIPOCF );
|
||
_m->item(tipo_cf == 'C' ? "C|Cliente" : "F|Fornitore");
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, F_PROVV, 1 );
|
||
_m->begin( );
|
||
_m->prompt( 100, 100, "<D><P> " );
|
||
_m->field( DOC_PROVV );
|
||
_m->flag( "D" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, F_DESTIPODOC, 50 );
|
||
_m->begin( );
|
||
_m->prompt( 24, 2 );
|
||
_m->flag( "GD" );
|
||
_m->message( "CO,5@" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, F_ANNO, 4 );
|
||
_m->begin( );
|
||
_m->prompt( 2, 3, "Esercizio " );
|
||
_m->field( DOC_ANNO );
|
||
_m->flag( "GD" );
|
||
_m->message( "CO,9@" );
|
||
_m->end( );
|
||
|
||
_m->control( T_NUMERO, F_NDOC, 6 );
|
||
_m->begin( );
|
||
_m->prompt( 24, 3, "Numero doc. " );
|
||
_m->field( DOC_NDOC );
|
||
_m->message( "CO,6@" );
|
||
_m->flag( "GDR" );
|
||
_m->end( );
|
||
|
||
_m->control( T_DATA, F_DATADOC );
|
||
_m->begin( );
|
||
_m->prompt( 46, 3, "Data " );
|
||
_m->field( DOC_DATADOC );
|
||
TString m("CO,7@");
|
||
_m->message(m);
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, F_STATO, 1 );
|
||
_m->begin( );
|
||
_m->prompt( 67, 3, "Stato " );
|
||
_m->field( DOC_STATO );
|
||
_m->use("%STD", 1);
|
||
_m->input("CODTAB 105");
|
||
_m->display("\"Codice\" CODTAB");
|
||
_m->display("\"Descrizione@50\" S0");
|
||
_m->output("105 CODTAB");
|
||
_m->message( "CO,8@" );
|
||
_m->check(S_NORMALE);
|
||
_m->flag( "DG" );
|
||
_m->end( );
|
||
|
||
_m->control( T_NUMERO, F_CODCF, 6 );
|
||
_m->begin( );
|
||
if ( tipo_cf == '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( DOC_CODCF );
|
||
_m->group( 1 );
|
||
_m->use( LF_CLIFO, 1 );
|
||
temp_s.format( "TIPOCF \"%c\"~CODCF %d", tipo_cf, 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 );
|
||
temp_s.format( "ADD RU cg0 -1 %c", tipo_cf);
|
||
_m->outline( temp_s );
|
||
_m->message( "CO,10@" );
|
||
_m->end( );
|
||
|
||
_m->control( T_STRINGA, F_RAGSOC, 50 );
|
||
_m->begin( );
|
||
if ( tipo_cf == '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", tipo_cf, 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 );
|
||
temp_s.format( "ADD RU cg0 -1 %c", tipo_cf);
|
||
_m->outline( temp_s );
|
||
_m->message( "CO,11@" );
|
||
_m->end( );
|
||
_m->line( MASK_FIRST_LINE );
|
||
}
|
||
|
||
void TMask_generator::genera( const TString& profilo )
|
||
{
|
||
if( profilo == "-all" || profilo[0] == '*')
|
||
{
|
||
TString_array profiles;
|
||
|
||
{
|
||
TAssoc_array profiles_array;
|
||
TRelation rel("%TIP");
|
||
TCursor t( &rel );
|
||
long count = t.items();
|
||
|
||
for( t = 0; t.pos( ) < count; ++t )
|
||
{
|
||
const TString profile_name(t.curr().get("S4"));
|
||
TFilename profile(profile_name);
|
||
|
||
profile.ext("ini");
|
||
if (fexist(profile) && !profiles_array.is_key(profile_name))
|
||
profiles_array.add(profile_name);
|
||
}
|
||
profiles_array.get_keys(profiles);
|
||
}
|
||
|
||
TProgind bar( profiles.items(), "Generazione automatica profili", FALSE, TRUE);
|
||
const int items = profiles.items();
|
||
|
||
for (int i = 0; i < items; i++)
|
||
{
|
||
const TString &profile = profiles.row(i);
|
||
|
||
genera(profile);
|
||
bar.addstatus(1);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
int i, last;
|
||
TString temp_s;
|
||
TFilename proname( profilo );
|
||
|
||
// All'inizio il gruppo h 'chiuso'
|
||
_groupopen = false;
|
||
|
||
// Forza l'estensione al profilo
|
||
proname.ext( "ini" );
|
||
|
||
// Se il file di profilo non esiste, esci con un errore fatale
|
||
if (!proname.exist())
|
||
{
|
||
cantread_box(profilo);
|
||
return;
|
||
}
|
||
|
||
_pro = new TConfig( proname );
|
||
|
||
const char tipo_cf = _pro->get_char("TIPOCF", "MAIN");
|
||
|
||
TFilename _mskname(profilo);
|
||
_mskname.ext( "msk" );
|
||
|
||
do_events();
|
||
// Mi serve per ordinare i gruppi a seconda del documento
|
||
TAssoc_array grouporder;
|
||
|
||
_m = new TMaschera( _mskname );
|
||
|
||
// Definizione della toolbar
|
||
|
||
_m->outline( "TOOLBAR \"\" 0 0 0 2" );
|
||
|
||
_m->control( T_BOTTONE, DLG_NEWREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 1, 1, "~Nuovo" );
|
||
_m->message( "EXIT,312" );
|
||
_m->picture(TOOL_NEWREC);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_SAVEREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 2, 1, "~Registra" );
|
||
_m->message( "EXIT,20082" );
|
||
_m->picture(TOOL_SAVEREC);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_DELREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 3, 1, "~Elimina" );
|
||
_m->message( "EXIT,127" );
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_NULL, 202 );
|
||
_m->begin( );
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_ELABORA, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 4, 1, "E~labora" );
|
||
_m->picture(TOOL_ELABORA);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_PREVIEW, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 5, 1, "Antepr." );
|
||
_m->picture(TOOL_PREVIEW);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_PRINT, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 5, 1 );
|
||
_m->message( "EXIT,20082" );
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_EMAIL, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 6, 1, "~Mail" );
|
||
_m->picture(TOOL_EMAIL);
|
||
_m->message( "EXIT,20082" );
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_CONFERMA, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 7, 1, "~Conferma");
|
||
_m->picture(TOOL_OK);
|
||
_m->flag("D");
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_NULL, 202 );
|
||
_m->begin( );
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_FIRSTREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 8, 1, "Primo");
|
||
_m->message( "EXIT,309" );
|
||
_m->picture(TOOL_FIRSTREC);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_PREVREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 9, 1, "Prec.");
|
||
_m->message( "EXIT,305" );
|
||
_m->picture(TOOL_PREVREC);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_FINDREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 10, 1, "Ri~cerca");
|
||
_m->message( "EXIT,339" );
|
||
_m->picture(TOOL_FINDREC);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_NEXTREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 11, 1, "Succ.");
|
||
_m->message( "EXIT,306" );
|
||
_m->picture(TOOL_NEXTREC);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_LASTREC, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 12, 1 , "Ultimo");
|
||
_m->message( "EXIT,310" );
|
||
_m->picture(TOOL_LASTREC);
|
||
_m->end( );
|
||
|
||
_m->control( T_BOTTONE, DLG_NULL, 202 );
|
||
_m->begin( );
|
||
_m->end( );
|
||
|
||
/* Occupa spazio prezioso
|
||
_m->control( T_BOTTONE, DLG_INFO, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 12, 1, "Info");
|
||
_m->message( "EXIT,332" );
|
||
_m->picture(TOOL_INFO);
|
||
_m->end( );
|
||
*/
|
||
|
||
_m->control( T_BOTTONE, DLG_CANCEL, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 14, 1, PR("Indietro") );
|
||
_m->message( "EXIT,27" );
|
||
_m->end( );
|
||
|
||
/* Occupa spazio prezioso
|
||
_m->control( T_BOTTONE, DLG_QUIT, 202 );
|
||
_m->begin( );
|
||
_m->prompt( 14, 1 );
|
||
_m->message( "EXIT,20334" );
|
||
_m->end( );
|
||
*/
|
||
|
||
// End della toolbar
|
||
_m->end( );
|
||
|
||
|
||
do_events();
|
||
|
||
// Header della prima pagina
|
||
const TString80 title(_pro->get("Title", "MAIN", _m->page(), TR("Testata")));
|
||
|
||
_m->pagina( _m->page( ), title);
|
||
|
||
TArray sortedgroups;
|
||
TString16 chiave, chiavegruppo;
|
||
last = _pro->get_int( "NGROUPS", "ORDINEGRUPPI" );
|
||
for( i = 1; i <= last; i ++ )
|
||
{
|
||
chiave.format("%d", i );
|
||
const TString& key = _pro->get( chiave, "ORDINEGRUPPI");
|
||
|
||
if (key.full())
|
||
{
|
||
if (isdigit(key[0]))
|
||
{
|
||
chiavegruppo = GROUPKEY(atoi(key));
|
||
if( _gruppi.is_key( chiavegruppo ) )
|
||
sortedgroups.add( _gruppi[ (chiavegruppo) ] );
|
||
}
|
||
else
|
||
sortedgroups.add(key);
|
||
}
|
||
}
|
||
|
||
// Generazione
|
||
// Scorro l'array dei gruppi, e ne creo una copia ordinata
|
||
// con solo i gruppi visibili
|
||
|
||
TString80 message;
|
||
|
||
_m->_sheet_generated = false;
|
||
message.format("Generazione profilo : %s", (const char *)profilo);
|
||
_bar = new TProgind(sortedgroups.items(), message, FALSE, TRUE);
|
||
|
||
TGruppo* gruppo1 = (TGruppo*)sortedgroups.objptr(0);
|
||
|
||
if (gruppo1->is_testata())
|
||
_m->line(0);
|
||
else
|
||
genera_testata_1();
|
||
|
||
sortedgroups.for_each( genera_gruppo );
|
||
delete _bar; _bar = NULL;
|
||
_m->end( );
|
||
if (!_m->_sheet_generated)
|
||
{
|
||
intestazione_pagina(TR("Righe"));
|
||
genera_sheet();
|
||
}
|
||
|
||
// Generazione pagina dei piedi
|
||
{
|
||
TToken_string s(_pro->get("CAMPICALC", "MAIN"));
|
||
const bool usefiles = _tablefile.empty();
|
||
|
||
if (s.not_empty())
|
||
{
|
||
intestazione_pagina(TR("Totali"));
|
||
TTable* frd = NULL;
|
||
|
||
if (usefiles)
|
||
frd = new TTable( "%FRD" );
|
||
else
|
||
load_table();
|
||
|
||
int nr = 1;
|
||
int id = 0;
|
||
for (const char * cp = s.get(0); cp && *cp; cp = s.get())
|
||
{
|
||
const TString16 codpiede(cp);
|
||
do_events();
|
||
if (usefiles)
|
||
{
|
||
frd->zero( );
|
||
frd->put( "CODTAB", codpiede );
|
||
}
|
||
_TableItem* t = (_TableItem*) _frdtable.objptr(codpiede);
|
||
if ( (usefiles && frd->read( ) == NOERR) || t != NULL )
|
||
{
|
||
int len = usefiles ? frd->get_int( "I0") : t->i0();
|
||
|
||
if (len <= 0 || len > 18)
|
||
len = 18;
|
||
id++;
|
||
|
||
if( nr + MASK_FIRST_LINE > MAX_LINES_PER_PAGE )
|
||
{
|
||
_m->end( );
|
||
intestazione_pagina(TR("Totali"));
|
||
nr = 1;
|
||
}
|
||
|
||
const bool currency = usefiles ? frd->get_bool("B0") : t->b0();
|
||
_m->control( currency ? T_CURRENCY : T_STRINGA, BASE_PIEDE + id, len);
|
||
_m->begin( );
|
||
|
||
TString80 header(usefiles ? frd->get("S0") : t->s0());
|
||
header.left_just(58 - len);
|
||
|
||
_m->prompt( 2, 7 + nr, header );
|
||
_m->field(codpiede);
|
||
|
||
const bool importo = usefiles ? frd->get_bool("B1") : t->b1();
|
||
|
||
TString16 flags("D");
|
||
if (!importo)
|
||
flags << "U";
|
||
_m->flag( flags );
|
||
TString16 driven; driven.format("DRIVENBY %d", F_CODVAL);
|
||
|
||
_m->outline(driven);
|
||
_m->end( );
|
||
nr++;
|
||
}
|
||
}
|
||
_m->end( );
|
||
|
||
if (frd != NULL)
|
||
delete frd;
|
||
}
|
||
}
|
||
_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
|
||
delete _m;
|
||
fcopy("verig00.msk", _mskname, TRUE);
|
||
delete _pro;
|
||
}
|
||
}
|
||
|
||
|
||
// Applicazione guscio
|
||
|
||
class TGenMask_application : public TSkeleton_application
|
||
{
|
||
bool _use_files;
|
||
TString _tablefile;
|
||
|
||
protected:
|
||
virtual bool use_files() const { return _use_files; }
|
||
|
||
public:
|
||
virtual void main_loop();
|
||
// @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata
|
||
virtual bool check_autorization() const { return false; }
|
||
void set_files(const bool b = true) { _use_files = b; }
|
||
void set_tablefile(const TString& t) {_tablefile = t; }
|
||
};
|
||
|
||
|
||
void TGenMask_application::main_loop( )
|
||
{
|
||
TFilename profilo = argv(2);
|
||
profilo.lower();
|
||
if (profilo.find("ve0300a") >= 0)
|
||
{
|
||
return; //se trova ve0300a DEVE compilare SOLO il .ini, quindi DEVE uscire qui!!!! errore rilevato il 15/02/2009..
|
||
//..ovvero la prima volta che sono stati introdotti i title delle pagine dei profili standard
|
||
}
|
||
|
||
TMask_generator gen(_tablefile);
|
||
gen.genera(profilo);
|
||
}
|
||
|
||
int ve0300( int argc, char* argv[])
|
||
{
|
||
if (argc < 3)
|
||
{
|
||
error_box(Usage);
|
||
return -1;
|
||
}
|
||
|
||
TGenMask_application a;
|
||
|
||
a.set_files(true);
|
||
TString tablefile;
|
||
|
||
if ( argc > 3)
|
||
{
|
||
if (strncmp(argv[3],"-f",2) == 0)
|
||
{
|
||
a.set_files(false);
|
||
if (argv[3][2] > ' ')
|
||
{
|
||
tablefile = argv[3];
|
||
tablefile.ltrim(2);
|
||
}
|
||
else
|
||
tablefile = "vetabcom.txt";
|
||
}
|
||
}
|
||
a.set_tablefile(tablefile);
|
||
a.run(argc, argv, TR("Generazione profili"));
|
||
return 0;
|
||
}
|