Patch level : 4.0 649

Ricompilazione Demo : [ ]
Commento            :

Riportata la versione 3.1 patch 848


git-svn-id: svn://10.65.10.50/trunk@14993 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2007-03-06 16:37:44 +00:00
parent e9c990f6f4
commit 046e2c06cb
213 changed files with 19036 additions and 870 deletions

View File

@ -57,6 +57,7 @@ Item_11 = "Motivi per controlli sanitari", "ba3 -0 mtc", ""
Item_12 = "Professioni", "ba3 -0 prf", "" Item_12 = "Professioni", "ba3 -0 prf", ""
Item_13 = "Tipi di donazione", "ba3 -0 tdn", "" Item_13 = "Tipi di donazione", "ba3 -0 tdn", ""
Item_14 = "Tipi/Esiti controlli sanitari", "ba3 -0 tcs", "" Item_14 = "Tipi/Esiti controlli sanitari", "ba3 -0 tcs", ""
Item_15 = "Singoli controlli sanitari", "ba3 -0 scs", ""
[AVIS_002] [AVIS_002]
Caption = "Convocazioni" Caption = "Convocazioni"
@ -150,13 +151,14 @@ Item_01 = "Sezioni", "at6 -1", ""
Item_02 = "Medici", "at6 -0", "" Item_02 = "Medici", "at6 -0", ""
Item_03 = "Categorie donatori", "ba3 -1 ctd", "" Item_03 = "Categorie donatori", "ba3 -1 ctd", ""
Item_04 = "Categorie non donatori", "ba3 -1 ctn", "" Item_04 = "Categorie non donatori", "ba3 -1 ctn", ""
Item_05 = "Controlli sanitari", "ba3 -1 tcs", "" Item_05 = "Gruppi aziendali", "ba3 -1 gaz", ""
Item_06 = "Gruppi aziendali", "ba3 -1 gaz", "" Item_06 = "Localita' postali", "ba3 -1 lcp", ""
Item_07 = "Localita' postali", "ba3 -1 lcp", "" Item_07 = "Punti di prelievo", "ba3 -1 ldn", ""
Item_08 = "Punti di prelievo", "ba3 -1 ldn", "" Item_08 = "Luoghi di lavoro", "ba3 -1 ldl", ""
Item_09 = "Luoghi di lavoro", "ba3 -1 ldl", "" Item_09 = "Motivi per controlli", "ba3 -1 mtc", ""
Item_10 = "Motivi per controlli", "ba3 -1 mtc", "" Item_10 = "Professioni", "ba3 -1 prf", ""
Item_11 = "Professioni", "ba3 -1 prf", "" Item_11 = "Tipi/Esiti Controlli sanitari", "ba3 -1 tcs", ""
Item_12 = "Singoli controlli san.", "ba3 -1 scs", ""
[AVIS_005] [AVIS_005]
Caption = "Statistiche" Caption = "Statistiche"

View File

@ -147,12 +147,33 @@ static int compare_date(const TObject** o1, const TObject** o2)
return d; return d;
} }
static int compare_benem(const TObject** o1, const TObject** o2)
{
TToken_string* s1 = (TToken_string*)*o1;
TToken_string* s2 = (TToken_string*)*o2;
const TString16 b1(s1->get(0));
const TString16 b2(s2->get(0));
int b=0;
if (b1>b2) b=+1;
else
if (b1<b2) b=-1;
return b;
}
void ordina_sheet_data(TSheet_field& s) void ordina_sheet_data(TSheet_field& s)
{ {
TArray& as = s.rows_array(); TArray& as = s.rows_array();
as.sort(compare_date); as.sort(compare_date);
} }
void ordina_sheet_benem(TSheet_field& s)
{
TArray& as = s.rows_array();
as.sort(compare_benem);
}
void d_datepross(TSheet_field& s) void d_datepross(TSheet_field& s)
// calcola le date di prossima donazione in base a: donazioni, stato attuale, idoneità // calcola le date di prossima donazione in base a: donazioni, stato attuale, idoneità
{ {
@ -1697,7 +1718,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri)
key->put(BEN_CODICE, m.get(F_CODICE)); key->put(BEN_CODICE, m.get(F_CODICE));
_sbenemerenze->set_key(key); _sbenemerenze->set_key(key);
ordina_sheet_data(s); ordina_sheet_benem(s);
for (r=s.items(); r>0; r--) for (r=s.items(); r>0; r--)
{ {

View File

@ -39,7 +39,7 @@ class TAttribuzioneBenemerenze : public TPrintapp
TString16 _gruppoazie, _oldben; TString16 _gruppoazie, _oldben;
int _bonus; int _bonus;
TDate _dataela, _datapre; TDate _dataela, _datapre;
bool _attgruppi,_anchegruppi, _prevista; bool _attgruppi,_anchegruppi, _prevista, _nuovicriteri;
bool _definitiva; bool _definitiva;
TParagraph_string _cognome_nome; TParagraph_string _cognome_nome;
int _numdon; int _numdon;
@ -171,8 +171,9 @@ void TAttribuzioneBenemerenze::set_page(int file, int cnt)
set_row(1,"@26g@S", FLD(LF_SOGGETTI,SOG_CATDON)); set_row(1,"@26g@S", FLD(LF_SOGGETTI,SOG_CATDON));
set_row(1,"@29g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS)); set_row(1,"@29g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS));
set_row(1,"@39g@pn", FLD(LF_SOGGETTI,SOG_TOTDON,"###")); set_row(1,"@39g@pn", FLD(LF_SOGGETTI,SOG_TOTDON,"###"));
set_row(1,"@48g@ld", FLD(LF_SOGGETTI,SOG_DATAISC));
if (_prevista) if (_prevista)
set_row(1,"@48g#3d", &_numdon); set_row(1,"@59g#3d", &_numdon);
} }
else else
set_row(1,""); set_row(1,"");
@ -196,6 +197,7 @@ bool TAttribuzioneBenemerenze::set_print(int)
tasto = _msk->run(); tasto = _msk->run();
if (tasto == K_ENTER) if (tasto == K_ENTER)
{ {
const TDate datarif = TDate("16/05/2004");
_oldben = "**"; _oldben = "**";
_contatore = 0; _contatore = 0;
_prevista = (_msk->get(F_SITUAZIONE)[0] == 'P'); _prevista = (_msk->get(F_SITUAZIONE)[0] == 'P');
@ -205,6 +207,7 @@ bool TAttribuzioneBenemerenze::set_print(int)
_gruppoazie = _msk->get(F_GRUPPOAZIE); _gruppoazie = _msk->get(F_GRUPPOAZIE);
_anchegruppi = _msk->get_bool(F_ANCHEGRUPPI); _anchegruppi = _msk->get_bool(F_ANCHEGRUPPI);
_definitiva = _msk->get_bool(F_DEFINITIVA); _definitiva = _msk->get_bool(F_DEFINITIVA);
_nuovicriteri = _msk->get_bool(F_NUOVICRITERI);
_catdon.destroy(); _catdon.destroy();
const TString16 catpri = _msk->get(F_CAT1); const TString16 catpri = _msk->get(F_CAT1);
const TString16 catsec = _msk->get(F_CAT2); const TString16 catsec = _msk->get(F_CAT2);
@ -230,8 +233,15 @@ bool TAttribuzioneBenemerenze::set_print(int)
{ {
TString16 codben = ben.get("CODTAB"); TString16 codben = ben.get("CODTAB");
int numdonben = ben.get_int("I0"); int numdonben = ben.get_int("I0");
real* oggetto = new real(numdonben); int m_numdon = ben.get_int("I1");
_tabben.add((const char*)codben, (TObject*) oggetto); int m_anni = ben.get_int("I2");
TToken_string* condizioni = new TToken_string();;
condizioni->add(numdonben);
condizioni->add(m_numdon);
condizioni->add(m_anni);
_tabben.add((const char*)codben, (TObject*) condizioni);
//real* oggetto = new real(numdonben);
//_tabben.add((const char*)codben, (TObject*) oggetto);
} }
TString80 filtro; TString80 filtro;
if (_attgruppi) if (_attgruppi)
@ -293,6 +303,9 @@ bool TAttribuzioneBenemerenze::set_print(int)
} }
if (filtrato) if (filtrato)
{ {
const char sesso = sog.get(SOG_SESSO)[0];
const TDate datanasc = sog.get_date(SOG_DATANASC);
const TDate dataisc = sog.get_date(SOG_DATAISC);
TRectype* key = new TRectype(LF_DONAZ); TRectype* key = new TRectype(LF_DONAZ);
key->put(DON_CODICE, codice); key->put(DON_CODICE, codice);
int err = _sdonazioni->read(key); int err = _sdonazioni->read(key);
@ -301,13 +314,45 @@ bool TAttribuzioneBenemerenze::set_print(int)
int precsi = sog.get_int(SOG_DONPRECSI); int precsi = sog.get_int(SOG_DONPRECSI);
int precaf = sog.get_int(SOG_DONPRECAF); int precaf = sog.get_int(SOG_DONPRECAF);
int numdon = precsi + precaf; int numdon = precsi + precaf;
int donxanno = 0;
int anno = 0;
for (int r=1; r<=_sdonazioni->rows(); r++) for (int r=1; r<=_sdonazioni->rows(); r++)
{ {
const TRectype& riga = _sdonazioni->row(r); const TRectype& riga = _sdonazioni->row(r);
TDate datadon = riga.get_date(DON_DATADON); const TDate datadon = riga.get_date(DON_DATADON);
const TString16 tipodon = riga.get(DON_TIPODON);
if (datadon<=_dataela) if (datadon<=_dataela)
{
if (_nuovicriteri && datadon>datarif) // 16/05/2004
{
if (anno != datadon.year())
{
if (donxanno > 4)
donxanno = 4;
numdon += donxanno;
donxanno = 0;
}
donxanno++;
int eta = datadon.year() - datanasc.year();
if (datadon.month() < datanasc.month())
eta--;
else
if (datadon.month() == datanasc.month())
if (datadon.day() < datanasc.day())
eta--;
if ((tipodon == "SI" || tipodon=="SN") && (sesso == '2') && (eta < 50))
donxanno++;
}
else
numdon++; numdon++;
} }
}
if (_nuovicriteri)
{
if (donxanno > 4)
donxanno = 4;
numdon += donxanno;
}
if (_prevista) if (_prevista)
{ {
// aggiungo le donazioni che puo' fare da oggi alla data elaborazione // aggiungo le donazioni che puo' fare da oggi alla data elaborazione
@ -345,21 +390,47 @@ bool TAttribuzioneBenemerenze::set_print(int)
ultben = "**"; ultben = "**";
} }
} }
long bonusctrl = 0; //long bonusctrl = 0;
int bonusctrl = 0;
int m_bonusctrl = 0;
int m_annictrl = 0;
if (ultben != "**") if (ultben != "**")
{ {
real& ndonult = (real&) _tabben.find((const char*) ultben); //real& ndonult = (real&) _tabben.find((const char*) ultben);
bonusctrl = ndonult.integer(); //bonusctrl = ndonult.integer();
TToken_string& condizioni = (TToken_string&) _tabben.find((const char*) ultben);
TString str = condizioni.get();
bonusctrl = atoi(str);
str = condizioni.get();
m_bonusctrl = atoi(str);
str = condizioni.get();
m_annictrl = atoi(str);
str = condizioni.get();
} }
_tabben.restart(); _tabben.restart();
real* c; TToken_string* c;
for (c = (real*) _tabben.first_item(); c != NULL; c = (real*) _tabben.succ_item()) for (c = (TToken_string*) _tabben.first_item(); c != NULL; c = (TToken_string*) _tabben.succ_item())
{ {
const char* tipoben = _tabben.get_hashobj()->key(); const char* tipoben = _tabben.get_hashobj()->key();
long bonus = c->integer(); //long bonus = c->integer();
TString str = c->get(0);
int bonus = atoi(str);
str = c->get();
int m_bonus = atoi(str);
str = c->get();
int m_anni = atoi(str);
str = c->get();
if (bonus > bonusctrl) if (bonus > bonusctrl)
{ {
bool attribuisci = false;
if (numdon >= bonus) if (numdon >= bonus)
attribuisci = true;
if (_nuovicriteri && !attribuisci && (m_bonus > 0 || m_anni > 0)) // se uso nuovi criteri e non ne ha diritto col vecchio sistema quardo se ne ha diritto con i nuovi criteri
{
const int anniisc = (_dataela - dataisc)/360;
attribuisci = (numdon >= m_bonus) && (anniisc >= m_anni);
}
if (attribuisci)
{ {
// controllo che non abbia ricevuto la benemerenza // controllo che non abbia ricevuto la benemerenza
_benem->zero(); _benem->zero();
@ -403,6 +474,8 @@ void TAttribuzioneBenemerenze::crea_intestazione()
TString sep(132); TString sep(132);
sep = "ATTRIBUZIONE BENEMERENZE "; sep = "ATTRIBUZIONE BENEMERENZE ";
if (_nuovicriteri)
sep << "CON NUOVI CRITERI ";
if (_prevista) if (_prevista)
sep << " PREVISTE "; sep << " PREVISTE ";
if (_definitiva) if (_definitiva)
@ -422,13 +495,13 @@ void TAttribuzioneBenemerenze::crea_intestazione()
set_header(3, (const char *) sep); set_header(3, (const char *) sep);
if (_prevista) if (_prevista)
{ {
set_header(4,"@0gCognome e nome@26gC.@29gTessera@39gTot.don.@48gDon.pre."); set_header(4,"@0gCognome e nome@26gC.@29gTessera@39gTot.don.@48gData isc.@59gDon.pre.");
set_header(5,"@0-------------------------@26g--@29g--------@39g--------@48g--------"); set_header(5,"@0-------------------------@26g--@29g--------@39g--------@48g----------@59g--------");
} }
else else
{ {
set_header(4,"@0gCognome e nome@26gC.@29gTessera@39gTot.don."); set_header(4,"@0gCognome e nome@26gC.@29gTessera@39gTot.don.@48gData isc.");
set_header(5,"@0-------------------------@26g--@29g--------@39g--------"); set_header(5,"@0-------------------------@26g--@29g--------@39g--------@48g----------");
} }
} }

View File

@ -19,7 +19,8 @@
#define F_CAT6 211 #define F_CAT6 211
#define F_D_CAT6 212 #define F_D_CAT6 212
#define F_SITUAZIONE 308 #define F_SITUAZIONE 307
#define F_NUOVICRITERI 308
#define F_DATAELA 309 #define F_DATAELA 309
#define F_DATAPRE 310 #define F_DATAPRE 310
#define F_ATTGRUPPI 311 #define F_ATTGRUPPI 311

View File

@ -214,6 +214,11 @@ BEGIN
ITEM "P|Prevista" ITEM "P|Prevista"
END END
BOOLEAN F_NUOVICRITERI
BEGIN
PROMPT 30 10 "Usa anche nuovi criteri per attribuzione"
END
DATE F_DATAELA DATE F_DATAELA
BEGIN BEGIN
PROMPT 2 11 "Data elaborazione " PROMPT 2 11 "Data elaborazione "

View File

@ -496,15 +496,20 @@ bool TStampaIscritti::user_create()
_etlarghezza = config.get_int("EtLarghezza"); _etlarghezza = config.get_int("EtLarghezza");
_etcolonne = config.get_int("EtColonne"); _etcolonne = config.get_int("EtColonne");
_form_eti = new TEti_iscritti_form(etformato); _form_eti = new TEti_iscritti_form(etformato);
TFilename iscrname = "iscritti"; TFilename iscrname = "iscritti";
iscrname.ext("dbf"); iscrname.ext("dbf");
TFilename iscrtrr = "iscritti"; TFilename iscrtrr = "iscritti";
iscrtrr.ext("trr"); iscrtrr.ext("trr");
if (iscrtrr.exist()) if (!iscrtrr.custom_path())
{
iscrtrr = "recdesc/iscritti";
iscrtrr.ext("trr");
}
_fileiscr = new TExternisamfile(iscrname, iscrtrr, false); _fileiscr = new TExternisamfile(iscrname, iscrtrr, false);
return true;
return TRUE;
} }
bool TStampaIscritti::user_destroy() bool TStampaIscritti::user_destroy()

View File

@ -1252,12 +1252,18 @@ bool TStampaPerCategorie::user_create()
_sfamiglia = new TRecord_array(LF_FAMIGLIE,FAM_PROGFAM); _sfamiglia = new TRecord_array(LF_FAMIGLIE,FAM_PROGFAM);
add_cursor(new TSorted_cursor(_rel,"SOG_CODSEZ|SOG_CODSOT","",3)); add_cursor(new TSorted_cursor(_rel,"SOG_CODSEZ|SOG_CODSOT","",3));
_msk = new TMask("at2700a"); _msk = new TMask("at2700a");
TFilename filename = "filecat"; TFilename filename = "filecat";
filename.ext("dbf"); filename.ext("dbf");
TFilename filetrr = "filecat"; TFilename filetrr = "filecat";
filetrr.ext("trr"); filetrr.ext("trr");
filetrr.custom_path(); if (!filetrr.custom_path())
{
filetrr = "recdesc/filecat";
filetrr.ext("trr");
}
_file = new TExternisamfile(filename, filetrr, FALSE); _file = new TExternisamfile(filename, filetrr, FALSE);
TFilename namepers("filepers"); TFilename namepers("filepers");
namepers.ext("dbf"); namepers.ext("dbf");
if (namepers.exist()) if (namepers.exist())

View File

@ -18,6 +18,8 @@ int main(int argc,char** argv)
rt = at9200(argc,argv) ; break; // Estrazione archivi per aggiornamento rt = at9200(argc,argv) ; break; // Estrazione archivi per aggiornamento
case 2: case 2:
rt = at9300(argc,argv) ; break; // Aggiornamento archivi da estrazione rt = at9300(argc,argv) ; break; // Aggiornamento archivi da estrazione
case 3:
rt = at9400(argc,argv) ; break; // Aggiornamento soggetti
default: default:
error_box(usage, argv[0]) ; break; error_box(usage, argv[0]) ; break;
} }

View File

@ -4,6 +4,7 @@
int at9100(int argc, char* argv[]); // statistica soggetti sospesi (NON UTILIZZARE) int at9100(int argc, char* argv[]); // statistica soggetti sospesi (NON UTILIZZARE)
int at9200(int argc, char* argv[]); // Parma: estrazione archivi per aggiornamento int at9200(int argc, char* argv[]); // Parma: estrazione archivi per aggiornamento
int at9300(int argc, char* argv[]); // Parma: aggiornamento archivi da estrazione int at9300(int argc, char* argv[]); // Parma: aggiornamento archivi da estrazione
int at9400(int argc, char* argv[]); // aggiornamento sit. sogg.
#endif // __AT9_H #endif // __AT9_H

236
at/at9400.cpp Executable file
View File

@ -0,0 +1,236 @@
#include <applicat.h>
#include <execp.h>
#include <mask.h>
#include <msksheet.h>
#include <mailbox.h>
#include <prefix.h>
#include <progind.h>
#include <recarray.h>
#include <relation.h>
#include <tabutil.h>
#include <urldefid.h>
#include <validate.h>
#include <lffiles.h>
#include "at9.h"
#include "atlib.h"
// nomi dei campi
#include "soggetti.h"
#include "donaz.h"
#include "contsan.h"
#include "idoneita.h"
#include "rconvoc.h"
class TReconstruction : public TApplication
{
TMask* _msk;
TRelation* _rel;
TLocalisamfile* _soggetti;
TLocalisamfile* _donaz;
TLocalisamfile* _contsan;
TLocalisamfile* _idoneita;
TRecord_array* _sdonazioni;
TRecord_array* _scontrolli;
TRecord_array* _sidoneita;
// parametri di sezione
int _intsi_f1, _intsi_f2, _intsi_m, _intaf_m, _etadonne;
int _numdon1, _numdon2;
TString16 _catini1, _catfin1, _catini2, _catfin2, _motivoid;
bool _sttess2, _dataisc, _nomessage, _autoid;
protected:
virtual bool create();
virtual bool destroy();
virtual bool menu(MENU_TAG m);
virtual TMask& get_mask() { return *_msk; }
virtual TRelation* get_relation() const { return _rel; }
int write(TSheet_field& s);
public:
TReconstruction() {}
};
HIDDEN inline TReconstruction& app() { return (TReconstruction&) main_app(); }
bool TReconstruction::create()
{
TApplication::create();
_msk = new TMask("at9400a");
_rel = new TRelation(LF_SOGGETTI);
_donaz = new TLocalisamfile(LF_DONAZ);
_contsan = new TLocalisamfile(LF_CONTSAN);
_idoneita = new TLocalisamfile(LF_IDONEITA);
_sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON);
_scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON);
_sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO);
TConfig config(CONFIG_STUDIO);
_numdon1 = config.get_int("NumDon1");
_numdon2 = config.get_int("NumDon2");
_catini1 = config.get("CatIni1");
_catfin1 = config.get("CatFin1");
_catini2 = config.get("CatIni2");
_catfin2 = config.get("CatFin2");
_sttess2 = config.get_bool("StTess2");
_dataisc = config.get_bool("DataIsc");
_nomessage = config.get_bool("NoMessage");
_etadonne = config.get_int("EtaDonne");
_intsi_f1 = config.get_int("IntSI_F1");
_intsi_f2 = config.get_int("IntSI_F2");
_intsi_m = config.get_int("IntSI_M");
_intaf_m = config.get_int("IntAF_M");
dispatch_e_menu(BAR_ITEM(1));
return TRUE;
}
bool TReconstruction::destroy()
{
delete _sidoneita;
delete _scontrolli;
delete _sdonazioni;
delete _idoneita;
delete _contsan;
delete _donaz;
delete _rel;
delete _msk;
return TApplication::destroy();
}
static int compare_date(const TObject** o1, const TObject** o2)
{
const TRectype& s1 = *((TRectype*)*o1);
const TRectype& s2 = *((TRectype*)*o2);
const TDate d1(s1.get(IDO_DATAIDO));
const TDate d2(s2.get(IDO_DATAIDO));
int d=0;
if (d1>d2) d=+1;
else
if (d1<d2) d=-1;
return d;
}
bool TReconstruction::menu(MENU_TAG m)
{
bool _calcolacat = FALSE;
KEY tasto = _msk->run();
if (tasto == K_ENTER)
{
TLocalisamfile rconvoc(LF_RCONVOC);
_rel->lfile().setkey(1);
bool modificato = FALSE;
TDate oggi(TODAY);
TRectype& recsog = _rel->curr();
TProgind pi(_rel->items(),"Aggiornamento situazione soggetti da appoggio", TRUE, TRUE, 10);
pi.setstatus(1);
for (_rel->first(); _rel->ok(); _rel->next())
{
pi.addstatus(1);
if (pi.iscancelled()) break;
const long codsog = recsog.get_long("CODICE");
TRectype* keyd = new TRectype(LF_DONAZ);
keyd->put(DON_CODICE, codsog);
int err = _sdonazioni->read(keyd);
calcola_donazioni_lib(recsog, _sdonazioni);
_sdonazioni->rewrite();
recsog.rewrite(_rel->lfile());
TRectype* key = new TRectype(LF_IDONEITA);
key->put(IDO_CODICE, recsog.get(SOG_CODICE));
err = _sidoneita->read(key);
_sidoneita->sort(compare_date);
_sidoneita->rewrite();
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, recsog.get(SOG_CODICE));
_scontrolli->read(keyc);
if (_scontrolli->rows()>0 || _sidoneita->rows()>0)
{
con_reord(recsog,_scontrolli,_sidoneita);
recsog.rewrite(_rel->lfile());
}
if (_calcolacat)
{
TTable ctd("CTD");
TString16 catdon = recsog.get(SOG_CATDON);
const int totdon = recsog.get_int(SOG_TOTDON);
ctd.put("CODTAB",catdon);
if (ctd.read() == NOERR)
{
bool dimissione = ctd.get_bool("B0");
if (dimissione)
{
recsog.put(SOG_CATDON,ctd.get("S6"));
if (ctd.get("S6").not_empty())
catdon = ctd.get("S6");
}
if ((catdon == _catini1 || _catini1.empty()) && (totdon>=_numdon1) && _catfin1.not_empty())
{
recsog.put(SOG_CATDON, _catfin1);
catdon = _catfin1;
}
const bool tstampata = recsog.get_bool(SOG_T_STAMPATA);
if ((catdon == _catini2 || _catini2.empty()) && (totdon>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || tstampata))
{
recsog.put(SOG_CATDON, _catfin2);
catdon = _catfin2;
}
}
}
TDate dataiscsog = recsog.get_date(SOG_DATAISC);
if (!dataiscsog.ok() && _dataisc)
{
if (!recsog.get_date(SOG_DATAPRISI) == NULLDATE)
recsog.put(SOG_DATAISC,recsog.get(SOG_DATAPRISI));
else
{
const TRectype& riga = _sdonazioni->row(1);
recsog.put(SOG_DATAISC,riga.get(DON_DATADON));
}
}
const TDate dataprossi = recsog.get_date(SOG_DATAPROSSI);
const TDate dataconv = recsog.get_date(SOG_DATACONV);
const char stato = modstato_tcs(recsog.get(SOG_STATO));
const TString16 statosi = recsog.get(SOG_STATOSI);
if ((stato == 'S') || (statosi == SOSPENSIONE) || (dataprossi > dataconv) || !dataprossi.ok())
{
rconvoc.setkey(3);
rconvoc.zero();
rconvoc.put(RCV_CODICE, recsog.get(SOG_CODICE));
rconvoc.put(RCV_DATACONV, recsog.get(SOG_DATACONV));
if (rconvoc.read() == NOERR)
{
rconvoc.put(RCV_ANNULLATO, TRUE);
int err = rconvoc.write();
}
const TDate datanulla(NULLDATE);
recsog.put(SOG_DATACONV, datanulla);
recsog.put(SOG_DATAULTSOL, datanulla);
const int numzero = 0;
recsog.put(SOG_NUMCONV,numzero);
}
recsog.put(SOG_DATAULTAGG, oggi);
recsog.put(SOG_UTENULTAGG, "CONVE");
recsog.rewrite(_rel->lfile());
}
}
return FALSE;
}
int TReconstruction::write(TSheet_field& s)
{
return NOERR;
}
int at9400(int argc, char* argv[])
{
TReconstruction a;
a.run(argc, argv, "Aggiornamento situazione soggetti");
return 0;
}

13
at/at9400a.uml Executable file
View File

@ -0,0 +1,13 @@
PAGE "Aggiornamento situazione soggetti" -1 -1 78 20
BUTTON DLG_OK 9 2
BEGIN
PROMPT -12 14 ""
END
BUTTON DLG_QUIT 9 2
BEGIN
PROMPT -22 14 ""
END
ENDPAGE
ENDMASK

16
at/bastscs.uml Executable file
View File

@ -0,0 +1,16 @@
//DEFINIZIONE MASCHERA PER STAMPA TABELLA SINGOLI CONTROLLI SANITARI
PAGE "Stampa Tabella Singoli controlli sanitari" -1 -1 56 8
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -2,4 +2,6 @@
#define F_TABBNZ_DESCR 101 #define F_TABBNZ_DESCR 101
#define F_TABBNZ_NDON 102 #define F_TABBNZ_NDON 102
#define F_TABBNZ_STATUTO 103 #define F_TABBNZ_STATUTO 103
#define DLG_DEL 105 #define F_TABBNZ_M_NDON 104
#define F_TABBNZ_M_ANNI 105
#define DLG_DEL 108

View File

@ -52,5 +52,26 @@ BEGIN
HELP "La benemerenza Š prevista nello statuto AVIS?" HELP "La benemerenza Š prevista nello statuto AVIS?"
END END
GROUPBOX DLG_NULL 77 4
BEGIN
PROMPT 1 7 "Nuovi criteri per benemerenza"
END
NUMBER F_TABBNZ_M_NDON 3
BEGIN
PROMPT 2 8 "Numero donazioni "
FIELD I1
HELP "Inserire il numero di donazioni necessarie per ottenere la benemerenza"
FLAGS "U"
END
NUMBER F_TABBNZ_M_ANNI 2
BEGIN
PROMPT 2 9 "Anni di iscrizione "
FIELD I2
HELP "Inserire il numero di anni di iscrizione necessari"
FLAGS "U"
END
ENDPAGE ENDPAGE
ENDMASK ENDMASK

3
at/batbscs.h Executable file
View File

@ -0,0 +1,3 @@
#define F_TABSCS_CODTAB 100
#define F_TABSCS_DESCR 101
#define DLG_DEL 105

9
at/batbscs.rpt Executable file
View File

@ -0,0 +1,9 @@
[Headers]
80
Tabella singoli controlli sanitari
1|@0g%s|Codice
1|@7g%s|Descrizione
[Rows]
1|CODTAB|@0g@2s
1|S0|@7g@30,ls

40
at/batbscs.uml Executable file
View File

@ -0,0 +1,40 @@
#include "batbscs.h"
TOOLBAR "" 0 20 0 2
#include <toolbar.h>
ENDPAGE
PAGE "Singoli controlli sanitari" -1 -1 78 7
STRING F_TABSCS_CODTAB 2
BEGIN
PROMPT 2 1 "Codice "
FIELD CODTAB
HELP "Inserire il codice del singolo controllo"
USE SCS
CHECKTYPE REQUIRED
INPUT CODTAB F_TABSCS_CODTAB
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@30" S0
OUTPUT F_TABSCS_CODTAB CODTAB
OUTPUT F_TABSCS_DESCR S0
KEY 1
FLAGS "U"
END
STRING F_TABSCS_DESCR 30
BEGIN
PROMPT 2 3 "Descrizione "
FIELD S0
HELP "Inserire la descrizione del singolo controllo"
USE SCS KEY 2
CHECKTYPE REQUIRED
INPUT S0 F_TABSCS_DESCR
DISPLAY "Descrizione@30" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT F_TABSCS_CODTAB
KEY 2
END
ENDPAGE
ENDMASK

View File

@ -1,3 +1,3 @@
158 158
1 0
$righef24|0|0|138|0|Righe di delega F24||| $righef24|0|0|175|0|Righe di delega F24|||

View File

@ -1,5 +1,5 @@
158 158
14 18
PROGR|3|6|0|Progressivo riga PROGR|3|6|0|Progressivo riga
F24|3|6|0|Numero F24 a cui la riga e' associata F24|3|6|0|Numero F24 a cui la riga e' associata
TRIBUTO|1|4|0|Codice tributo TRIBUTO|1|4|0|Codice tributo
@ -10,10 +10,14 @@ DATASCAD|5|8|0|Data scadenza
DATAVERS|5|8|0|Data versamento DATAVERS|5|8|0|Data versamento
ABI|10|5|0|ABI banca su cio e' stato effettuato il versamento ABI|10|5|0|ABI banca su cio e' stato effettuato il versamento
CAB|10|5|0|CAB CAB|10|5|0|CAB
RRP|1|4|0|Rateazione/Regione/Prov. RATEAZIONE|1|8|0|Rateazione/Regione/Prov.
ANNO|2|4|0|Anno di riferimento ANNO|2|4|0|Anno di riferimento
IMPORTODEB|4|15|2|Importo a debito IMPORTODEB|4|15|2|Importo a debito
IMPORTOCRE|4|15|2|Importo a credito IMPORTOCRE|4|15|2|Importo a credito
SEDE|1|4|0|Sede sezione INPS
MATRICOLA|1|17|0|Matricola
PERIODODA|10|6|0|Inizio periodo di riferimento
PERIODOA|10|6|0|Fine periodo di riferimento
3 3
PROGR| PROGR|
F24+PROGR| F24+PROGR|

14
gv/gv0.cpp Executable file
View File

@ -0,0 +1,14 @@
#include <xvt.h>
#include "gv0.h"
int main(int argc, char** argv)
{
const int n = argc > 1 ? argv[1][1]-'0' : 0;
switch (n)
{
case 4: gv0500(argc, argv); break;
case 5: gv0600(argc, argv); break;
default: break;
}
return 0;
}

2
gv/gv0.h Executable file
View File

@ -0,0 +1,2 @@
int gv0500(int argc, char* argv[]);
int gv0600(int argc, char* argv[]);

741
gv/gv0500.cpp Executable file
View File

@ -0,0 +1,741 @@
#include "gv0.h"
#include "gv0500a.h"
#include "gvlib.h"
#include <automask.h>
#include <defmask.h>
#include <recarray.h>
#include <relapp.h>
#include <anagr.h>
#include <clifo.h>
#include <nditte.h>
///////////////////////////////////////////////////////////
// Utilities
///////////////////////////////////////////////////////////
// Trasforma un codice tributo in sezione F24
static char trib2sec(const TString& trib)
{
const TString& sec = cache().get("%TRB", trib, "S6");
return sec[0];
}
// Traformazione da codice sheet a codice tributo e viceversa
static const short ids[] = { F_ERARIO, F_INPS, 0 };
static const char sec[] = { 'E', 'I', '\0' };
static char sheet2sec(short id)
{
int i;
for (i = 0; ids[i] && ids[i] != id; i++);
return sec[i];
}
static short sec2sheet(char s)
{
int i;
for (i = 0; sec[i] && sec[i] != s; i++);
return ids[i];
}
///////////////////////////////////////////////////////////
// TF24_query_mask
///////////////////////////////////////////////////////////
class TF24_query_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TF24_query_mask() : TAutomask("gv0500a") {}
};
bool TF24_query_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
{
case F_DISTINTA:
if (e == fe_button)
{
TArray_sheet sheet(-1, -1, 60, 20, TR("Distinte"),
HR("F24@6|Progr.|Data@10|Tipo|Codice|ABI@5|CAB@5"));
TElencoF24_set delega(1); // Distinte non inviate
const long abi = get_long(F_ABI);
const long cab = get_long(F_CAB);
const char tipo = get(F_TIPOINTEST)[0];
const long f24 = atol(o.get());
long sel = 0;
for (bool ok = delega.move_first(); ok; ok = delega.move_next())
{
const long dist = delega.get(F24_F24).as_int();
bool keep = dist > 0;
if (keep && cab > 0)
keep = delega.get(F24_ABI).as_int()==abi && delega.get(F24_CAB).as_int()==cab;
if (keep && tipo > ' ')
keep = delega.get(F24_TIPOINTEST).as_string()[0] == tipo;
if (keep)
{
if (dist == f24)
sel = sheet.items();
TToken_string row;
row << dist;
row.add(delega.get(F24_PROGR).as_int());
row.add(delega.get(F24_DATASCAD).as_string());
row.add(delega.get(F24_TIPOINTEST).as_string());
row.add(delega.get(F24_INTEST).as_string());
row.add(delega.get(F24_ABI).as_string());
row.add(delega.get(F24_CAB).as_string());
sheet.add(row);
}
}
if (sel > 0)
sheet.select(sel);
if (sheet.run() == K_ENTER)
{
TToken_string& row = sheet.row();
set(F_DISTINTA, row.get_long(0));
//set(F_PROGR, row.get_long(1));
stop_run(K_AUTO_ENTER);
}
}
if (e == fe_modify)
{
TF24_set delega(atol(o.get()));
if (delega.move_first())
set(F_PROGR, delega.get(F24_PROGR).as_int());
}
break;
case F_PROGR:
if (e == fe_button)
{
// Metodo astuto come un cervo per ottenere le righe F24 non assegnate
TRigheF24_set riga(0x1);
TArray_sheet sheet(-1, -1, -3, -3, TR("Righe"),
HR("@1|Progr.|Trib.|Data@10|Debito@15R|Credito@15R|Tipo|Codice|ABI@5|CAB@5"));
const long abi = get_long(F_ABI);
const long cab = get_long(F_CAB);
const char tipo = get(F_TIPOINTEST)[0];
const long f24 = atol(o.get());
for (bool ok = riga.move_first(); ok; ok = riga.move_next())
{
bool keep = true;
if (keep && cab > 0)
keep = riga.get(F24_ABI).as_int()==abi && riga.get(F24_CAB).as_int()==cab;
if (keep && tipo > ' ')
keep = riga.get(F24_TIPOINTEST).as_string()[0] == tipo;
if (keep)
{
TToken_string row;
row = " ";
row.add(riga.get(F24_PROGR).as_int());
row.add(riga.get(F24_TRIBUTO).as_string());
row.add(riga.get(F24_DATASCAD).as_string());
row.add(riga.get(F24_IMPORTODEB).as_string());
row.add(riga.get(F24_IMPORTOCRE).as_string());
row.add(riga.get(F24_TIPOINTEST).as_string());
row.add(riga.get(F24_INTEST).as_string());
row.add(riga.get(F24_ABI).as_string());
row.add(riga.get(F24_CAB).as_string());
sheet.add(row);
}
}
if (sheet.run() == K_ENTER)
{
TToken_string& row = sheet.row();
set(F_PROGR, row.get_long(1));
set(F_DISTINTA, get_next_f24());
stop_run(K_INS);
}
}
break;
default:
break;
}
return true;
}
///////////////////////////////////////////////////////////
// TF24_mask
///////////////////////////////////////////////////////////
class TF24_edit_mask : public TAutomask
{
private:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
protected:
int find_empty_row(TSheet_field& s) const;
bool load_row(short id, const TRecordset& riga, int pos) const;
void link_tributo(TOperable_field& o);
void compute_total(short id, int rows);
public:
bool add_row(const TRecordset& riga, int pos = -1);
void compute_totals(int mode = 0xFF);
TF24_edit_mask() : TAutomask("gv0500b") {}
};
void TF24_edit_mask::compute_total(short id, int rows)
{
TSheet_field& s = sfield(id);
TMask& m = s.sheet_mask();
const TMask_field* debito = m.find_by_fieldname(F24_IMPORTODEB);
const TMask_field* credito = m.find_by_fieldname(F24_IMPORTOCRE);
const int posdeb = s.cid2index(debito->dlg());
const int poscre = s.cid2index(credito->dlg());
const bool needs_update = s.items() < rows;
real a, b;
for (int r = 0; r < rows; r++)
{
TToken_string& row = s.row(r);
a += real(row.get(posdeb));
b += real(row.get(poscre));
}
set(id+1, a);
set(id+2, b);
set(id+3, real(a-b));
if (needs_update)
s.force_update();
}
void TF24_edit_mask::compute_totals(int mode)
{
if (mode & 1)
compute_total(F_ERARIO, 6);
if (mode & 2)
compute_total(F_INPS, 4);
real saldo;
saldo += get_real(F_ERARIO_AB);
saldo += get_real(F_INPS_CD);
set(F_SALDO, saldo);
}
void TF24_edit_mask::link_tributo(TOperable_field& o)
{
TSheet_field& sheet = *o.mask().get_sheet();
const char sez[2] = { sheet2sec(sheet.dlg()), '\0' };
TString query = "USE RIGHEF24 KEY 2 SELECT 4->S6=#SEC";
query << "\nJOIN %TRB INTO CODTAB==TRIBUTO";
query << "\nTO PROGR=999999";
TISAM_recordset delega(query);
delega.set_var("#SEC", TVariant(sez));
if (delega.items() > 0)
{
TCursor_sheet s(delega.cursor(),
" |PROGR|TRIBUTO|DATASCAD|IMPORTODEB|IMPORTOCRE|ABI|CAB|TIPOINTEST|INTEST",
TR("Righe disponibili"),
HR("@1|Progr.|Trib.|Data@10|Debito@15R|Credito@15R|ABI@5|CAB@5|Tipo|Codice"),
0, 1);
if (s.run() == K_ENTER)
{
if (!s.one_checked())
s.check(s.selected());
TISAM_recordset riga("USE RIGHEF24\nFROM PROGR=#RIGA\nTO PROGR=#RIGA");
for (TRecnotype i = 0; i < s.items(); i++) if (s.checked(i))
{
const long progr = s.row(i).get_long(1);
riga.set_var("#RIGA", TVariant(progr));
if (riga.move_first())
{
const int pos = sheet.selected();
add_row(riga, pos);
if (o.mask().is_running())
sheet.update_mask(pos);
else
sheet.force_update(pos);
}
}
}
}
else
warning_box(TR("Non esistono righe F24 compatibili"));
}
int TF24_edit_mask::find_empty_row(TSheet_field& s) const
{
int i = 0;
for (i = 0; i < 6 && i < s.items(); i++)
{
const TToken_string& row = s.row(i);
if (row.empty_items())
break;
}
return i;
}
bool TF24_edit_mask::load_row(short id, const TRecordset& riga, int pos) const
{
TSheet_field& s = sfield(id);
if (pos < 0 || pos >= 6)
pos = find_empty_row(s);
bool ok = pos >= 0 && pos < 6;
if (ok)
{
TMask& m = s.sheet_mask();
TToken_string& row = s.row(pos);
row.cut(0);
FOR_EACH_MASK_FIELD(m, i, f)
{
const TFieldref* fr = f->field();
if (fr != NULL)
{
const int j = s.cid2index(f->dlg());
row.add(riga.get(fr->name()).as_string(), j);
}
}
}
return ok;
}
bool TF24_edit_mask::add_row(const TRecordset& riga, int pos)
{
const TString& tributo = riga.get(F24_TRIBUTO).as_string();
const char sec = trib2sec(tributo);
const short id = sec2sheet(sec);
bool ok = id > 0 && load_row(id, riga, pos);
if (!ok)
{
const long progr = riga.get(F24_PROGR).as_int();
error_box(FR("Impossibile aggiungere la riga %ld (%s) alla delega"),
progr, (const char*)tributo);
}
return ok;
}
bool TF24_edit_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
bool ok = true;
switch (o.dlg())
{
case DLG_USER:
if (e == fe_button && jolly > 0)
link_tributo(o);
break;
case F_ERARIO:
switch (e)
{
case se_notify_modify:
case se_notify_del:
compute_totals(0x1);
break;
case se_query_add:
ok = false;
break;
default:
break;
}
break;
case F_INPS:
switch (e)
{
case se_notify_modify:
case se_notify_del:
compute_totals(0x2);
break;
case se_query_add:
ok = false;
break;
default:
break;
}
break;
default:
break;
}
return ok;
}
///////////////////////////////////////////////////////////
// TF24_app
// TRelation_application molto all'avanguardia
// avendo un recorset filtrato come sorgente dati principale.
// Notare l'arguta implementazione dei metodi get_filtered_cursor
// e get_relation in modo far funzionare bene le ricerche
///////////////////////////////////////////////////////////
class TF24_app : public TRelation_application
{
TPointer_array _progr;
TElencoF24_set* _recset;
TArray _msk;
private:
int riscrivi(const TMask& mask);
void init_mask(TMask& mask) const;
protected:
virtual bool user_create();
virtual bool user_destroy();
virtual bool has_filtered_cursor() const { return _recset != NULL; }
virtual TCursor& get_filtered_cursor() const { return *_recset->cursor(); }
virtual TRelation* get_relation() const { return get_filtered_cursor().relation(); }
virtual bool get_next_key(TToken_string& key);
virtual bool changing_mask(int mode) { return true; }
virtual TMask* get_mask(int mode);
virtual void init_query_mode(TMask& m);
virtual void init_insert_mode(TMask& m);
virtual void init_modify_mode(TMask& m);
virtual int read(TMask& m);
virtual int write(const TMask& mask);
virtual int rewrite(const TMask& mask);
virtual bool remove();
};
bool TF24_app::user_create()
{
_recset = new TElencoF24_set(1); // Elenco di tutti gli F24 da inviare
_msk.add(new TF24_query_mask);
_msk.add(new TF24_edit_mask);
set_search_field(F_DISTINTA);
return _recset->cursor() != NULL;
}
bool TF24_app::user_destroy()
{
_msk.destroy();
delete _recset;
return true;
}
bool TF24_app::get_next_key(TToken_string& key)
{
key.cut(0);
key.add(F_DISTINTA, 0);
key.add(get_next_f24(), 1);
return true;
}
TMask* TF24_app::get_mask(int mode)
{
const int n = (mode == MODE_QUERY) ? 0 : 1;
return (TMask*)_msk.objptr(n);
}
void TF24_app::init_mask(TMask& mask) const
{
TF24_edit_mask& m = (TF24_edit_mask&)mask;
char ti = m.get(F_TIPOINTEST)[0];
long intest = m.get_long(F_PERSON);
TString codfis, ragsoc, key;
if (ti == 'C')
{
key.cut(0) << "C|" << intest;
const TRectype& cli = cache().get(LF_CLIFO, key);
codfis = cli.get(CLI_COFI);
ragsoc = cli.get(CLI_RAGSOC);
if (codfis.blank())
codfis = cli.get(CLI_PAIV);
}
else
{
if (ti == 'D' || ti <= ' ')
{
ti = prefix().firm().get(NDT_TIPOA)[0];
intest = prefix().firm().get_long(NDT_CODANAGR);
}
key.cut(0) << ti << '|' << intest;
const TRectype& anag = cache().get(LF_ANAG, key);
ragsoc = anag.get(ANA_RAGSOC);
codfis = anag.get(ANA_COFI);
if (codfis.blank())
codfis = anag.get(ANA_PAIV);
}
m.set(F_PERSON, intest);
m.set(F_COFI, codfis);
m.set(F_RAGSOC, ragsoc);
m.compute_totals();
}
void TF24_app::init_query_mode(TMask& /*mask*/)
{
}
void TF24_app::init_insert_mode(TMask& mask)
{
init_mask(mask);
const TMask& q = *get_mask(MODE_QUERY);
const long progr = q.get_long(F_PROGR);
if (progr > 0)
{
TISAM_recordset riga("USE RIGHEF24\nFROM PROGR=#RIGA\nTO PROGR=#RIGA");
riga.set_var("#RIGA", progr);
if (riga.move_first())
{
TF24_edit_mask& m = (TF24_edit_mask&)mask;
m.add_row(riga);
}
}
}
void TF24_app::init_modify_mode(TMask& mask)
{
init_mask(mask);
}
int TF24_app::read(TMask& mask)
{
const int err = TRelation_application::read(mask);
_progr.destroy(); // Azzera lista delle righe
FOR_EACH_MASK_SHEET(mask, i, s)
s->destroy();
if (err == NOERR)
{
TF24_edit_mask& m = (TF24_edit_mask&)mask;
TF24_set delega(m.get_long(F_DISTINTA));
for (bool ok = delega.move_first(); ok; ok = delega.move_next())
{
if (m.add_row(delega))
{
const long p = delega.get(F24_PROGR).as_int();
_progr.add_long(p); // Tengo traccia delle righe lette
}
}
}
return err;
}
int TF24_app::riscrivi(const TMask& mask)
{
TPointer_array righe;
if (mask.sheets() > 0) // dummy test
{
// Compila la lista di tutte le righe F24 nella distinta corrente
FOR_EACH_MASK_SHEET(mask, i, s)
{
const TMask_field* friga = s->sheet_mask().find_by_fieldname(F24_PROGR);
const int pos = s->cid2index(friga->dlg());
FOR_EACH_SHEET_ROW(*s, r, row)
{
const long progr = row->get_long(pos);
if (progr > 0)
righe.add_long(progr);
}
}
}
TLocalisamfile righef24(LF_RIGHEF24);
if (_progr.items() > 0)
{
// Scollega tutte le righe f24 ora non piu' presenti
for (int r = 0; r < _progr.items(); r++)
{
const long progr = _progr.get_long(r);
if (righe.find_long(progr) < 0) // Questa riga c'era prima ma ora non piu'
{
righef24.put("PROGR", progr);
int err = righef24.read(_isequal, _lock);
if (err == NOERR)
{
righef24.zero("F24");
err = righef24.rewrite();
}
if (err != NOERR)
error_box("Errore %d di scollegamento della riga %ld", err, progr);
}
}
}
// Tenta eventuale rinumerazione della distinta
if (mask.insert_mode())
{
righef24.setkey(2);
long f24 = 0;
for (f24 = mask.get_long(F_DISTINTA); ; f24++)
{
righef24.zero();
righef24.put("F24", f24);
int err = righef24.read(_isgreat);
if (err != NOERR || righef24.get_long("F24") != f24)
break;
}
((TMask&)mask).set(F_DISTINTA, f24); // Aggiorna numero distinta
}
// Mi preparo a numerare le eventuali righe nuove
long next_progr = get_next_progr_f24();
// Salva le righe F24 nella distinta corrente
FOR_EACH_MASK_SHEET(mask, i, s)
{
// Calcolo le posizioni dei campi importanti nella TToken_string
const TMask_field* frig = s->sheet_mask().find_by_fieldname(F24_PROGR);
const TMask_field* fdeb = s->sheet_mask().find_by_fieldname(F24_IMPORTODEB);
const TMask_field* fcre = s->sheet_mask().find_by_fieldname(F24_IMPORTOCRE);
const int pos_pro = s->cid2index(frig->dlg()); // Progressivo
const int pos_deb = s->cid2index(fdeb->dlg()); // Debito
const int pos_cre = s->cid2index(fcre->dlg()); // Credito
// Scandisco le righe dello sheet
FOR_EACH_SHEET_ROW(*s, r, row)
{
const real deb = row->get(pos_deb);
const real cre = row->get(pos_cre);
const bool is_empty = deb.is_zero() && cre.is_zero();
long progr = row->get_long(pos_pro);
int err = NOERR;
if (progr <= 0 && !is_empty) // E' una riga nuova con importi validi?
{
do
{
progr = next_progr++;
righef24.zero();
righef24.put(F24_PROGR, progr);
righef24.put(F24_F24, mask.get(F_DISTINTA));
err = righef24.write();
} while (err == _isreinsert);
if (err != NOERR)
{
error_box(FR("Errore %d nell'inserimento righe F24"), err);
return err;
}
row->add(progr, pos_pro); // Aggiorno il progressivo nella riga nuova
}
if (progr > 0) // E' una riga da aggiornare?
{
righef24.zero();
righef24.put(F24_PROGR, progr);
if (is_empty)
{
err = righef24.remove();
}
else
{
err = righef24.read(_isequal, _lock);
if (err == NOERR)
{
FOR_EACH_MASK_FIELD(s->sheet_mask(), i, f)
{
const TFieldref* fr = f->field();
if (fr != NULL)
{
const int pos = s->cid2index(f->dlg());
righef24.put(fr->name(), row->get(pos));
}
}
// Metto anche la roba di testata uguale per tutti
FOR_EACH_MASK_FIELD(mask, j, g)
{
const TFieldref* fr = g->field();
if (fr != NULL)
righef24.put(fr->name(), g->get());
}
err = righef24.rewrite();
}
}
if (err != NOERR)
{
error_box(FR("Errore %d nell'aggiornamento righe F24"), err);
return err;
}
}
}
}
_recset->requery(); // Aggiorno la lista delle distinte
_progr = righe; // Forse verra' fatto comunque dalla prossima read
// Sembra utile non passare in modifica della distinta successiva!
TRectype& rec = get_filtered_cursor().curr();
rec.put(F24_F24, mask.get(F_DISTINTA));
rec.zero(F24_PROGR);
get_filtered_cursor().read();
return NOERR;
}
int TF24_app::write(const TMask& mask)
{
_progr.destroy(); // Precauzione inutile? Chissa'!
return riscrivi(mask);
}
int TF24_app::rewrite(const TMask& mask)
{
return riscrivi(mask);
}
// Azzera il campo F24 nelle righe della distinta corrente
bool TF24_app::remove()
{
const long f24 = get_relation()->curr().get_long(F24_F24);
/*
// Vecchio modo
TRectype rec(LF_RIGHEF24);
rec.put(F24_F24, f24);
TCursor cur(get_relation(), "", 2, &rec, &rec);
const TRecnotype items = cur.items();
cur.freeze();
for (cur = 0; cur.pos() < items; ++cur)
{
cur.curr().zero(F24_F24);
cur.relation()->rewrite();
}
*/
// Lezione di stile
TF24_set cur(f24);
TRelation& rel = *cur.cursor()->relation();
for (bool ok = cur.move_first(); ok; ok = cur.move_next())
{
rel.curr().zero(F24_F24);
rel.rewrite();
}
return true;
}
int gv0500(int argc, char* argv[])
{
TF24_app app;
app.run(argc, argv, "F24");
return 0;
}

27
gv/gv0500a.h Executable file
View File

@ -0,0 +1,27 @@
#define F_ABI 202
#define F_CAB 203
#define F_DESABI 204
#define F_DESCAB 205
#define F_TIPOINTEST 211
#define F_CLIFO 212
#define F_PERSON 213
#define F_DISTINTA 214
#define F_PROGR 215
#define F_COFI 301
#define F_RAGSOC 302
#define F_ERARIO 401
#define F_ERARIO_A 402
#define F_ERARIO_B 403
#define F_ERARIO_AB 404
#define F_INPS 501
#define F_INPS_C 502
#define F_INPS_D 503
#define F_INPS_CD 504
#define F_SALDO 999

115
gv/gv0500a.uml Executable file
View File

@ -0,0 +1,115 @@
#include "gv0500a.h"
TOOLBAR "" 0 -2 0 2
#include <toolbar.h>
ENDPAGE
PAGE "F24" 0 0 0 -3
GROUPBOX DLG_NULL 78 5
BEGIN
PROMPT 1 0 "@bSelezione"
END
NUMBER F_ABI 5
BEGIN
PROMPT 2 1 "ABI "
CHECKTYPE NORMAL
FLAGS "Z"
END
NUMBER F_CAB 5
BEGIN
PROMPT 2 2 "CAB "
USE BNP
JOIN %BAN ALIAS 883 INTO CODTAB==CODTAB[1,5]
JOIN %BAN ALIAS 884 INTO CODTAB==CODTAB
INPUT CODTAB[1,5] F_ABI
INPUT CODTAB[6,10] F_CAB
DISPLAY "ABI@5" CODTAB[1,5]
DISPLAY "CAB@5" CODTAB[6,10]
DISPLAY "Descrizione@50" 884@->S0
OUTPUT F_ABI CODTAB[1,5]
OUTPUT F_CAB CODTAB[6,10]
OUTPUT F_DESABI 883@->S0
OUTPUT F_DESCAB 884@->S0
CHECKTYPE NORMAL
FLAGS "Z"
END
STRING F_DESABI 70 50
BEGIN
PROMPT 26 1 ""
FLAGS "D"
END
STRING F_DESCAB 70 50
BEGIN
PROMPT 26 2 ""
USE BNP KEY 2
JOIN %BAN ALIAS 883 INTO CODTAB==CODTAB[1,5]
JOIN %BAN ALIAS 884 INTO CODTAB==CODTAB
INPUT S0 F_DESCAB
DISPLAY "Descrizione@50" 884@->S0
DISPLAY "ABI@5" CODTAB[1,5]
DISPLAY "CAB@5" CODTAB[6,10]
COPY OUTPUT F_CAB
CHECKTYPE NORMAL
END
LIST F_TIPOINTEST 1 10
BEGIN
PROMPT 2 3 "Intestatario "
ITEM " |Tutti" MESSAGE HIDE,F_CLIFO|HIDE,F_PERSON
ITEM "D|Ditta" MESSAGE HIDE,F_CLIFO|HIDE,F_PERSON
ITEM "C|Cliente" MESSAGE SHOW,F_CLIFO|HIDE,F_PERSON
ITEM "F|Fisico" MESSAGE HIDE,F_CLIFO|SHOW,F_PERSON
ITEM "G|Giuridico" MESSAGE HIDE,F_CLIFO|SHOW,F_PERSON
END
NUMBER F_CLIFO 6
BEGIN
PROMPT 36 3 ""
USE LF_CLIFO
INPUT TIPOCF "C"
INPUT CODCF F_CLIFO
DISPLAY "Codice" CODCF
DISPLAY "Ragione Sociale@50" RAGSOC
OUTPUT F_CLIFO CODCF
CHECKTYPE NORMAL
ADD RUN cg0 -1 C
END
NUMBER F_PERSON 6
BEGIN
PROMPT 36 3 ""
USE LF_ANAG
INPUT TIPOA F_TIPOINTEST
INPUT CODANAGR F_PERSON
DISPLAY "Codice" CODANAGR
DISPLAY "Ragione Sociale@50" RAGSOC
OUTPUT F_PERSON CODANAGR
CHECKTYPE NORMAL
ADD RUN ba4 -1 #F_TIPOINTEST
END
NUMBER F_DISTINTA 6
BEGIN
PROMPT 2 5 "Distinta "
FIELD F24
KEY 2
FLAGS "B"
CHECKTYPE REQUIRED
END
NUMBER F_PROGR 6
BEGIN
PROMPT 22 5 "Progressivo "
FIELD PROGR
FLAGS "B"
KEY 1
END
ENDPAGE
ENDMASK

7
gv/gv0500b.h Executable file
View File

@ -0,0 +1,7 @@
#define F_FILTER 101
#define F_ABI 102
#define F_CAB 103
#define F_DESBAN 104
#define F_TIPOINTEST 105
#define F_CLIFO 106
#define F_PERSON 107

473
gv/gv0500b.uml Executable file
View File

@ -0,0 +1,473 @@
#include "gv0500a.h"
TOOLBAR "" 0 -3 0 3
#include <toolbar.h>
CURRENCY F_SALDO 15
BEGIN
PROMPT 49 0 "@bSALDO FINALE "
FLAGS "D"
END
ENDPAGE
PAGE "Erario" 0 0 0 -3
GROUPBOX -1 78 4
BEGIN
PROMPT 1 0 "AGENZIA DELLE ENTRATE"
END
TEXT -1
BEGIN
PROMPT 2 1 "@bMODELLO DI PAGAMENTO"
END
TEXT -1
BEGIN
PROMPT 2 2 "@bUNIFICATO"
END
NUMBER F_DISTINTA 6
BEGIN
PROMPT 16 2 ""
FLAGS "D"
FIELD F24
KEY 2
END
NUMBER F_ABI 5
BEGIN
PROMPT 24 1 ""
FLAGS "Z"
FIELD ABI
CHECKTYPE REQUIRED
END
STRING F_DESABI 50 44
BEGIN
PROMPT 32 1 ""
FLAGS "D"
END
NUMBER F_CAB 5
BEGIN
PROMPT 24 2 ""
USE BNP
JOIN %BAN ALIAS 883 INTO CODTAB==CODTAB[1,5]
JOIN %BAN ALIAS 884 INTO CODTAB==CODTAB
INPUT CODTAB[1,5] F_ABI
INPUT CODTAB[6,10] F_CAB
DISPLAY "ABI@5" CODTAB[1,5]
DISPLAY "CAB@5" CODTAB[6,10]
DISPLAY "Descrizione@50" 884@->S0
OUTPUT F_ABI CODTAB[1,5]
OUTPUT F_CAB CODTAB[6,10]
OUTPUT F_DESABI 883@->S0
OUTPUT F_DESCAB 884@->S0
CHECKTYPE REQUIRED
FLAGS "Z"
FIELD CAB
END
STRING F_DESCAB 50 44
BEGIN
PROMPT 32 2 ""
USE BNP KEY 2
JOIN %BAN ALIAS 883 INTO CODTAB==CODTAB[1,5]
JOIN %BAN ALIAS 884 INTO CODTAB==CODTAB
INPUT S0 F_DESCAB
DISPLAY "Descrizione@50" 884@->S0
DISPLAY "ABI@5" CODTAB[1,5]
DISPLAY "CAB@5" CODTAB[6,10]
COPY OUTPUT F_CAB
CHECKTYPE SEARCH
END
GROUPBOX -1 78 4
BEGIN
PROMPT 1 4 "CONTRIBUENTE"
END
LIST F_TIPOINTEST 1 10
BEGIN
PROMPT 2 5 "Intestatario "
ITEM "D|Ditta"
ITEM "C|Cliente"
ITEM "F|Fisico"
ITEM "G|Giuridico"
FLAGS "D"
FIELD TIPOINTEST
END
NUMBER F_PERSON 6
BEGIN
PROMPT 32 5 ""
FIELD INTEST
FLAGS "D"
END
STRING F_COFI 13
BEGIN
PROMPT 47 5 "Codice fiscale "
FLAGS "D"
END
STRING F_RAGSOC 50 58
BEGIN
PROMPT 2 6 "Ragione sociale "
FLAGS "D"
END
TEXT -1
BEGIN
PROMPT 1 10 "@bSEZIONE ERARIO"
END
SPREADSHEET F_ERARIO 0 8
BEGIN
PROMPT 2 11 "Erario"
ITEM "cod.\ntrib.@4"
ITEM "rateazione\nreg./prov.@10"
ITEM "anno\nrif."
ITEM "importi a debito\nversati@18"
ITEM "importi a credito\ncompensati@18"
ITEM "riga@7"
ITEM "descrizione@50"
END
CURRENCY F_ERARIO_A 15
BEGIN
PROMPT 2 20 "@b(A) "
FLAGS "D"
END
CURRENCY F_ERARIO_B 15
BEGIN
PROMPT 26 20 "@b(B) "
FLAGS "D"
END
CURRENCY F_ERARIO_AB 15
BEGIN
PROMPT 50 20 "@bSaldo (A-B) "
FLAGS "D"
END
ENDPAGE
PAGE "INPS/Regioni" -1 -1 0 0
TEXT -1
BEGIN
PROMPT 1 0 "@bSEZIONE INPS"
END
SPREADSHEET F_INPS 0 6
BEGIN
PROMPT 2 1 "INPS"
ITEM "codice\nsede"
ITEM "caus.\ncontr.@5"
ITEM "matricola INPS\ncodice INPS"
ITEM "da mm/aaaa"
ITEM "a mm/aaaa"
ITEM "importi\na debito@15"
ITEM "importi\na credito@15"
ITEM "riga@7"
END
CURRENCY F_INPS_C 15
BEGIN
PROMPT 2 8 "@b(C) "
FLAGS "D"
END
CURRENCY F_INPS_D 15
BEGIN
PROMPT 26 8 "@b(D) "
FLAGS "D"
END
CURRENCY F_INPS_CD 15
BEGIN
PROMPT 50 8 "@bSaldo (C-D) "
FLAGS "D"
END
ENDPAGE
ENDMASK
PAGE "Erario" -1 -1 68 6
TEXT -1
BEGIN
PROMPT 1 0 "codice"
END
TEXT -1
BEGIN
PROMPT 1 1 "tributo"
END
STRING 101 4
BEGIN
PROMPT 1 2 ""
USE %TRB SELECT S6=="E"
INPUT CODTAB 101
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@70" S0
OUTPUT 101 CODTAB
CHECKTYPE REQUIRED
FIELD TRIBUTO
END
TEXT -1
BEGIN
PROMPT 9 0 "rateazione"
END
TEXT -1
BEGIN
PROMPT 9 1 "reg./prov."
END
STRING 102 8
BEGIN
PROMPT 9 2 ""
END
TEXT -1
BEGIN
PROMPT 19 1 "anno"
END
NUMBER 103 4
BEGIN
PROMPT 19 2 ""
FIELD ANNO
END
TEXT -1
BEGIN
PROMPT 25 0 "importi a debito"
END
TEXT -1
BEGIN
PROMPT 25 1 "versati"
END
CURRENCY 104 15
BEGIN
PROMPT 25 2 ""
FIELD IMPORTODEB
END
TEXT -1
BEGIN
PROMPT 45 0 "importi a credito"
END
TEXT -1
BEGIN
PROMPT 45 1 "compensati"
END
CURRENCY 105 15
BEGIN
PROMPT 45 2 ""
FIELD IMPORTOCRE
END
NUMBER 106 7
BEGIN
PROMPT 1 4 "riga "
FLAGS "D"
FIELD PROGR
END
STRING 107 50
BEGIN
PROMPT 10 4 ""
FIELD DESCR
END
BUTTON DLG_USER 10 2
BEGIN
PROMPT -14 -1 ""
PICTURE BMP_LINK
END
BUTTON DLG_DELREC 10 2
BEGIN
PROMPT -24 -1 ""
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -34 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -44 -1 ""
END
ENDPAGE
ENDMASK
PAGE "INPS" -1 -1 78 9
TEXT -1
BEGIN
PROMPT 1 0 "codice"
END
TEXT -1
BEGIN
PROMPT 1 1 "sede"
END
STRING 101 4
BEGIN
PROMPT 1 2 ""
FIELD SEDE
END
TEXT -1
BEGIN
PROMPT 10 0 "causale"
END
TEXT -1
BEGIN
PROMPT 10 1 "contr."
END
STRING 102 4
BEGIN
PROMPT 10 2 ""
USE %TRB SELECT S6=="I"
INPUT CODTAB 101
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@70" S0
OUTPUT 101 CODTAB
CHECKTYPE REQUIRED
FIELD TRIBUTO
END
TEXT -1
BEGIN
PROMPT 21 0 "matricola INPS"
END
TEXT -1
BEGIN
PROMPT 21 1 "codice INPS"
END
STRING 103 17
BEGIN
PROMPT 19 2 ""
FIELD MATRICOLA
END
TEXT -1
BEGIN
PROMPT 40 0 "periodo di riferimento"
END
TEXT -1
BEGIN
PROMPT 40 1 "da mm/aaaa"
END
NUMBER 104 6
BEGIN
PROMPT 48 2 ""
FIELD PERIODODA
END
TEXT -1
BEGIN
PROMPT 48 1 "a mm/aaaa"
END
NUMBER 105 6
BEGIN
PROMPT 40 2 ""
FIELD PERIODOA
END
TEXT -1
BEGIN
PROMPT 1 3 "importi a debito"
END
TEXT -1
BEGIN
PROMPT 1 4 "versati"
END
CURRENCY 106 15
BEGIN
PROMPT 1 5 ""
FIELD IMPORTODEB
END
TEXT -1
BEGIN
PROMPT 18 3 "importi a credito"
END
TEXT -1
BEGIN
PROMPT 18 4 "compensati"
END
CURRENCY 107 15
BEGIN
PROMPT 18 5 ""
FIELD IMPORTOCRE
END
NUMBER 108 7
BEGIN
PROMPT 1 7 "riga "
FIELD PROGR
FLAGS "D"
END
STRING 109 50
BEGIN
PROMPT 10 7 ""
FIELD DESCR
END
BUTTON DLG_USER 10 2
BEGIN
PROMPT -14 -1 ""
PICTURE BMP_LINK
END
BUTTON DLG_DELREC 10 2
BEGIN
PROMPT -24 -1 ""
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -34 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -44 -1 ""
END
ENDPAGE
ENDMASK

1033
gv/gv0600.cpp Executable file

File diff suppressed because it is too large Load Diff

18
gv/gv0600a.h Executable file
View File

@ -0,0 +1,18 @@
#define F_DISTINTE 200
#define F_PATH 201
#define F_FILE 202
#define F_DATAPAG 203
#define F_DATA 204
#define F_FILTER 210
#define F_DATA_DA 211
#define F_DATA_AL 212
#define F_ABI 213
#define F_CAB 214
#define F_DESBAN 215
#define F_TIPOINTEST 216
#define F_CLIFO 217
#define F_PERSON 218
#define F_MITTENTE 301

267
gv/gv0600a.uml Executable file
View File

@ -0,0 +1,267 @@
#include "gv0600a.h"
TOOLBAR "" 0 -2 0 2
BUTTON DLG_ELABORA 10 2
BEGIN
PROMPT -12 -11 "~Elabora"
PICTURE BMP_ELABORA
MESSAGE EXIT,69
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -11 ""
END
ENDPAGE
PAGE "Invio F4" 0 0 0 -3
GROUPBOX DLG_NULL 78 5
BEGIN
PROMPT 1 0 "@bSelezione"
END
LIST F_FILTER 1 13
BEGIN
PROMPT 2 1 "Mostra distinte "
ITEM " |da inviare"
ITEM "I|inviate"
ITEM "Q|qualsiasi"
END
DATE F_DATA_DA
BEGIN
PROMPT 36 1 "Scadenze dal"
END
DATE F_DATA_AL
BEGIN
PROMPT 62 1 "al "
END
NUMBER F_ABI 5
BEGIN
PROMPT 2 2 "Banca (ABI-CAB) "
CHECKTYPE REQUIRED
FLAGS "Z"
FIELD ABI
END
NUMBER F_CAB 5
BEGIN
PROMPT 25 2 " "
USE BNP
JOIN %BAN ALIAS 883 INTO CODTAB==CODTAB
INPUT CODTAB[1,5] F_ABI
INPUT CODTAB[6,10] F_CAB
DISPLAY "ABI@5" CODTAB[1,5]
DISPLAY "CAB@5" CODTAB[6,10]
DISPLAY "Descrizione@50" 883@->S0
OUTPUT F_ABI CODTAB[1,5]
OUTPUT F_CAB CODTAB[6,10]
OUTPUT F_DESBAN 883@->S0
CHECKTYPE REQUIRED
FLAGS "Z"
FIELD CAB
END
STRING F_DESBAN 70 40
BEGIN
PROMPT 36 2 ""
FLAGS "D"
END
LIST F_TIPOINTEST 1 10
BEGIN
PROMPT 2 3 "Intestatario "
ITEM " |Tutti" MESSAGE HIDE,F_CLIFO|HIDE,F_PERSON
ITEM "C|Cliente" MESSAGE SHOW,F_CLIFO|HIDE,F_PERSON
ITEM "D|Ditta" MESSAGE HIDE,F_CLIFO|HIDE,F_PERSON
ITEM "F|Fisico" MESSAGE HIDE,F_CLIFO|SHOW,F_PERSON
ITEM "G|Giuridico" MESSAGE HIDE,F_CLIFO|SHOW,F_PERSON
END
NUMBER F_CLIFO 6
BEGIN
PROMPT 36 3 ""
USE LF_CLIFO
INPUT TIPOCF "C"
INPUT CODCF F_CLIFO
DISPLAY "Codice" CODCF
DISPLAY "Ragione Sociale@50" RAGSOC
OUTPUT F_CLIFO CODCF
CHECKTYPE NORMAL
ADD RUN cg0 -1 C
END
NUMBER F_PERSON 6
BEGIN
PROMPT 36 3 ""
USE LF_ANAG
INPUT TIPOA F_TIPOINTEST
INPUT CODANAGR F_PERSON
DISPLAY "Codice" CODANAGR
DISPLAY "Ragione Sociale@50" RAGSOC
OUTPUT F_PERSON CODANAGR
CHECKTYPE NORMAL
ADD RUN ba4 -1 #F_TIPOINTEST
END
GROUPBOX DLG_NULL 78 5
BEGIN
PROMPT 1 5 "@bParametri"
END
STRING F_MITTENTE 5
BEGIN
PROMPT 2 6 "Codice SIA del mittente "
CHEKCTYPE REQUIRED
FIELD Mittente
END
DATE F_DATA
BEGIN
PROMPT 49 6 "Data di creazione "
CHEKCTYPE REQUIRED
FLAGS "A"
END
DATE F_DATAPAG
BEGIN
PROMPT 49 7 "Data di pagamento "
CHEKCTYPE REQUIRED
END
STRING F_PATH 256 39
BEGIN
PROMPT 2 8 "Cartella "
DSELECT
CHECKTYPE REQUIRED
FIELD F24DestPath
END
STRING F_FILE 18
BEGIN
PROMPT 54 8 "File "
FLAGS "DG"
DRIVENBY F_DATA F_ABI F_MITTENTE
STR_CALC ANSI(#F_DATA)+#F_ABI+#F_MITTENTE
END
SPREADSHEET F_DISTINTE 78
BEGIN
PROMPT 1 10 ""
ITEM "@1"
ITEM "Distinta"
ITEM "Scadenza@10"
ITEM "ABI@5"
ITEM "CAB@5"
ITEM "Tipo@2"
ITEM "Intestatario"
ITEM "Invio@10"
FLAGS "D"
END
ENDPAGE
ENDMASK
PAGE "Distinta" -1 -1 56 12
GROUP DLG_NULL 54 4
BEGIN
PROMPT 1 0 "@bDistinta"
END
BOOLEAN 101
BEGIN
PROMPT 2 1 "Da inviare"
END
NUMBER 102 7
BEGIN
PROMPT 2 2 "Numero "
FLAGS "L"
FIELD F24
END
DATE 103
BEGIN
PROMPT 32 1 "Scadenza "
FLAGS "L"
FIELD DATASCAD
END
DATE 108
BEGIN
PROMPT 32 2 "Inviata il "
FLAGS "L"
FIELD DATAVERS
END
GROUP DLG_NULL 54 4
BEGIN
PROMPT 1 4 "@bBanca"
END
NUMBER 104 5
BEGIN
PROMPT 2 5 "ABI "
FIELD ABI
FLAGS "LZ"
END
NUMBER 105 5
BEGIN
PROMPT 16 5 "CAB "
FIELD CAB
FLAGS "LZ"
USE %BAN
INPUT CODTAB[1,5] 104
INPUT CODTAB[6,10] 105
DISPLAY "ABI@5" CODTAB[1,5]
DISPLAY "CAB@5" CODTAB[6,10]
DISPLAY "Descrizione@50" S0
OUTPUT 115 S0
CHECTYPE NORMAL
END
STRING 115 50
BEGIN
PROMPT 2 6 ""
FLAGS "D"
END
GROUP DLG_NULL 54 3
BEGIN
PROMPT 1 8 "@bIntestatario"
END
LIST 106 1 10
BEGIN
PROMPT 2 9 "Tipo "
ITEM "C|Cliente"
ITEM "D|Ditta"
ITEM "F|Fisico"
ITEM "G|Giuridico"
FIELD TIPOINTEST
FLAGS "L"
END
NUMBER 107 6
BEGIN
PROMPT 26 9 ""
FIELD INTEST
FLAGS "L"
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -11 -1 ""
END
ENDPAGE
ENDMASK

106
gv/gvlib.cpp Executable file
View File

@ -0,0 +1,106 @@
#include "gvlib.h"
#include <relation.h>
///////////////////////////////////////////////////////////
// TRigheF24_set
///////////////////////////////////////////////////////////
// 0=tutte 1=libere 2=assegnate 3=tutte
TRigheF24_set::TRigheF24_set(int flags)
: TISAM_recordset("USE RIGHEF24 KEY 2")
{
switch ((flags & 0x3) % 3)
{
case 1: set("USE RIGHEF24 KEY 2\nTO PROGR=999999"); break;
case 2: set("USE RIGHEF24 KEY 2\nFROM F24=1"); break;
default: break;
}
}
///////////////////////////////////////////////////////////
// TF24_set
///////////////////////////////////////////////////////////
TF24_set::TF24_set(long codice)
: TISAM_recordset("USE RIGHEF24 KEY 2\nFROM F24=#DIST\nTO F24=#DIST")
{
CHECKD(codice > 0, "Distinta ma sospetta:", codice);
set_var("#DIST", TVariant(codice));
}
///////////////////////////////////////////////////////////
// TElencoF24_set
///////////////////////////////////////////////////////////
const TElencoF24_set* TElencoF24_set::_currentF24 = NULL;
bool TElencoF24_set::f24killer(const TRelation* rel)
{
// Il record e' buono se il bit corrispondente e' settato
return _currentF24->_good[rel->file().recno()];
}
TCursor* TElencoF24_set::cursor() const
{
_currentF24 = this;
TCursor* c = TISAM_recordset::cursor();
if (c != NULL && c->filterfunction() == NULL)
{
TBit_array& goodies = ((TElencoF24_set*)this)->_good;
goodies.reset();
long last = 0;
TRecnotype tot = c->items();
const TRectype& curr = c->curr();
for (*c = 0; c->pos() < tot; ++*c)
{
const long f24 = curr.get_long("F24");
bool good = f24 > last;
if (good)
{
last = f24;
if (_flags != 0) // Non voglio tutto?
{
const TDate inv = curr.get(F24_DATAVERS);
good = (_flags == 1) ^ inv.ok();
}
if (good)
goodies.set(c->file().recno());
}
}
c->freeze(false);
c->set_filterfunction(f24killer);
tot = c->items();
c->freeze(true);
}
return c;
}
// 0=tutte 1=da inviare 2=inviate 3=tutte
TElencoF24_set::TElencoF24_set(int flags)
: TRigheF24_set(0x2)
{
_flags = (flags & 0x3) % 3; // isolo i flag = 1 o flag = 2
}
long get_next_f24()
{
long f24 = 1;
TRigheF24_set deleghe(0x2);
if (deleghe.move_last())
f24 += deleghe.get(F24_F24).as_int();
return f24;
}
long get_next_progr_f24()
{
TLocalisamfile righef24(LF_RIGHEF24);
long next_progr = 1;
if (righef24.read(_islast) == NOERR)
next_progr += righef24.get_long(F24_PROGR);
return next_progr;
}

43
gv/gvlib.h Executable file
View File

@ -0,0 +1,43 @@
#ifndef __GVLIB_H
#define __GVLIB_H
#ifndef __RECSET_H
#include <recset.h>
#endif
#ifndef __RIGHE_F24
#include <righef24.h>
#endif
// Elenco di tutte righe + o - assegnate ad un F24
class TRigheF24_set : public TISAM_recordset
{
public:
TRigheF24_set(int flags = 0); // 0=tutte 1=libere 2=assegnate 3=tutte
};
// Elenco delle righe di un singolo F24
class TF24_set : public TISAM_recordset
{
public:
TF24_set(long codice);
};
// Elenco delle distinte F24 (solo la prima riga di ognuna)
class TElencoF24_set : public TRigheF24_set
{
int _flags;
TBit_array _good;
static const TElencoF24_set* _currentF24;
static bool f24killer(const TRelation* rel);
public:
virtual TCursor* cursor() const;
TElencoF24_set(int flags = 0); // 0=tutte 1=da inviare 2=inviate 3=tutte
};
long get_next_f24();
long get_next_progr_f24();
#endif

View File

@ -627,6 +627,13 @@ int TPointer_array::insert(const TObject& object, int index, bool force)
return TArray::insert(&(TObject&)object, index, force); return TArray::insert(&(TObject&)object, index, force);
} }
int TPointer_array::find_long(long value) const
{
int i = 0;
for (i = last(); i >= 0 && get_long(i) != value; i = pred(i));
return i;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TBit_array // TBit_array
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -176,20 +176,20 @@ public:
TArray& operator=(const TArray& a); TArray& operator=(const TArray& a);
// @cmember Rimuove uno o tutti (default) gli elementi // @cmember Rimuove uno o tutti (default) gli elementi
virtual bool destroy(int index = -1, bool pack = FALSE); virtual bool destroy(int index = -1, bool pack = false);
// @cmember Aggiunge un oggetto ad un array. // @cmember Aggiunge un oggetto ad un array.
virtual int add(TObject* obj, int index = -1) ; virtual int add(TObject* obj, int index = -1) ;
// @cmember Inserisce un elemento dell'array nella posizione index // @cmember Inserisce un elemento dell'array nella posizione index
virtual int insert(TObject* obj, int index = 0, bool force = FALSE); virtual int insert(TObject* obj, int index = 0, bool force = false);
// @cmember Aggiunge un oggetto all'array. L'oggetto viene duplicato // @cmember Aggiunge un oggetto all'array. L'oggetto viene duplicato
virtual int add(const TObject& object, int index = -1) ; virtual int add(const TObject& object, int index = -1) ;
// @cmember Inserisce un oggetto alla posizione index // @cmember Inserisce un oggetto alla posizione index
virtual int insert(const TObject& object, int index = 0, bool force = FALSE); virtual int insert(const TObject& object, int index = 0, bool force = false);
// @cmember Elimina l'elemento nella posizione index dell'array // @cmember Elimina l'elemento nella posizione index dell'array
TObject* remove(int index, bool pack = FALSE); TObject* remove(int index, bool pack = false);
// @cmember Elimina l'elemento nella posizione index dell'array // @cmember Elimina l'elemento nella posizione index dell'array
TObject* remove_item(bool pack = FALSE) ; TObject* remove_item(bool pack = false) ;
// @cmember Scambia di posto due elementi dell'array // @cmember Scambia di posto due elementi dell'array
void swap(int i1, int i2); void swap(int i1, int i2);
// @cmember Rende contigui tutti gli elementi non nulli // @cmember Rende contigui tutti gli elementi non nulli
@ -229,10 +229,10 @@ protected:
void copy(const TArray& a); void copy(const TArray& a);
public: public:
virtual bool destroy(int index = -1, bool pack = FALSE); virtual bool destroy(int index = -1, bool pack = false);
virtual int add(TObject* object, int index = -1); virtual int add(TObject* object, int index = -1);
virtual int add(const TObject& object, int index = -1); virtual int add(const TObject& object, int index = -1);
virtual int insert(const TObject& object, int index = 0, bool force = FALSE); virtual int insert(const TObject& object, int index = 0, bool force = false);
virtual TPointer_array& operator= (const TArray& a) { copy(a); return *this; } virtual TPointer_array& operator= (const TArray& a) { copy(a); return *this; }
virtual TPointer_array& operator= (const TPointer_array& a) { copy(a); return *this; } virtual TPointer_array& operator= (const TPointer_array& a) { copy(a); return *this; }
@ -240,6 +240,7 @@ public:
int get_int(int index) const { return (int)get_long(index); } int get_int(int index) const { return (int)get_long(index); }
int add_long(long value, int index = -1) { return add((TObject*)value, index); } int add_long(long value, int index = -1) { return add((TObject*)value, index); }
int insert_long(long value, int index = -1) { return TArray::insert((TObject*)value, index, TRUE); } int insert_long(long value, int index = -1) { return TArray::insert((TObject*)value, index, TRUE); }
int find_long(long value) const;
TPointer_array() { } TPointer_array() { }
TPointer_array(int size) : TArray(size) { } TPointer_array(int size) : TArray(size) { }

View File

@ -266,7 +266,7 @@ TObject& TAssoc_array::find(
TObject* TAssoc_array::objptr( TObject* TAssoc_array::objptr(
const char* key) const // @parm Chiave dell'oggetto da ritornare const char* key) const // @parm Chiave dell'oggetto da ritornare
{ {
bool isnew = FALSE; bool isnew = false;
THash_object* o = ((TAssoc_array*)this)->_lookup(key,isnew); THash_object* o = ((TAssoc_array*)this)->_lookup(key,isnew);
return o ? o->_obj : NULL; return o ? o->_obj : NULL;
} }

View File

@ -25,7 +25,7 @@ vd Vendita al dettaglio
af Autoformazione af Autoformazione
gi Gestione ICI gi Gestione ICI
is Gestione ISI is Gestione ISI
tc Tecnico Contabile tc Trasferimento altre Contabilita'
tm Tecnico Approv. Merci tm Tecnico Approv. Merci
ac Accettazione AVIS ac Accettazione AVIS
av AVIS Assist av AVIS Assist

View File

@ -25,5 +25,6 @@
#define CAU_SOLOIVA "SOLOIVA" #define CAU_SOLOIVA "SOLOIVA"
#define CAU_MOVIND "MOVIND" #define CAU_MOVIND "MOVIND"
#define CAU_PROVV "PROVV" #define CAU_PROVV "PROVV"
#define CAU_CODCAUREG "CODCAUREG"
#endif #endif

View File

@ -138,6 +138,7 @@ int DB_open(const char *filename,int mode,int index)
int DB_close(int handle) int DB_close(int handle)
{ {
if(!handle_ok(handle)) return(-1); if(!handle_ok(handle)) return(-1);
d4close(dbdata[handle]); d4close(dbdata[handle]);
dbdata[handle]=(DATA4 *) 0; dbdata[handle]=(DATA4 *) 0;
code_base.errorCode=0; code_base.errorCode=0;
@ -412,7 +413,10 @@ int DB_rewrite(int handle)
d4recNo(dbdata[handle]) + 1, d4fileName(dbdata[handle])); d4recNo(dbdata[handle]) + 1, d4fileName(dbdata[handle]));
xvt_dm_post_fatal_exit(msg); xvt_dm_post_fatal_exit(msg);
} }
rt=DB_unlock(handle);
if (rt == 0)
rt = DB_flush(handle);
rt = DB_unlock(handle);
return (rt); return (rt);
} }
@ -462,9 +466,9 @@ int DB_add(int handle)
u4delaySec(); u4delaySec();
} }
} }
DB_unlock(handle);
if (is_locked == 0) if (is_locked == 0)
d4unlock(data); DB_unlock(handle);
return(rt); return(rt);
} }
@ -1160,7 +1164,7 @@ char* DB_memoptr( const int handle, const char * fieldname )
return f4memoPtr( f ); return f4memoPtr( f );
} }
int DB_memowrite( const int handle, const char * fieldname, const char * data ) int DB_memowrite( const int handle, const char* fieldname, const char* data )
{ {
FIELD4* f = d4field(dbdata[handle], fieldname ); FIELD4* f = d4field(dbdata[handle], fieldname );
int ret = f4memoAssign( f, (char*)data ); int ret = f4memoAssign( f, (char*)data );

View File

@ -91,6 +91,7 @@ class TPicture_array
public: public:
bool add(short id); bool add(short id);
short add(const char * n);
const TImage& image(short id) const { return (const TImage&)_enabled[id]; } const TImage& image(short id) const { return (const TImage&)_enabled[id]; }
const TImage& disabled_image(short id) const { return (const TImage&)_disabled[id]; } const TImage& disabled_image(short id) const { return (const TImage&)_disabled[id]; }
@ -101,6 +102,15 @@ public:
virtual ~TPicture_array() {} virtual ~TPicture_array() {}
}; };
short TPicture_array::add(const char * n)
{
short id;
for (id = 30000; objptr(id) != NULL; id++);
return TArray::add(new TImage(n), id);
}
bool TPicture_array::add(short id) bool TPicture_array::add(short id)
{ {
TImage* i = (TImage*)_enabled.objptr(id); TImage* i = (TImage*)_enabled.objptr(id);
@ -152,6 +162,8 @@ void TPicture_array::reload()
HIDDEN TPicture_array* _picture = NULL; HIDDEN TPicture_array* _picture = NULL;
HIDDEN XVT_FNTID DEF_FONT = NULL; HIDDEN XVT_FNTID DEF_FONT = NULL;
HIDDEN XVT_FNTID FAT_FONT = NULL; HIDDEN XVT_FNTID FAT_FONT = NULL;
HIDDEN XVT_FNTID BIG_FONT = NULL;
HIDDEN XVT_FNTID BIGFAT_FONT = NULL;
bool is_xvt_font(const char * nome_font) bool is_xvt_font(const char * nome_font)
{ {
@ -168,7 +180,7 @@ bool is_xvt_font(const char * nome_font)
return found; return found;
} }
XVT_FNTID xvt_default_font(bool bold) XVT_FNTID xvt_default_font(bool bold, bool big)
{ {
if (DEF_FONT == NULL) if (DEF_FONT == NULL)
{ {
@ -203,7 +215,18 @@ XVT_FNTID xvt_default_font(bool bold)
xvt_font_map_using_default(FAT_FONT); xvt_font_map_using_default(FAT_FONT);
CHECK(xvt_font_is_mapped(FAT_FONT), "Can't map native font"); CHECK(xvt_font_is_mapped(FAT_FONT), "Can't map native font");
// Compute true text size BIG_FONT = xvt_font_create();
xvt_font_copy(BIG_FONT, DEF_FONT, XVT_FA_ALL);
xvt_font_set_size(BIG_FONT, xvt_font_get_size(DEF_FONT) * 2);
xvt_font_map_using_default(BIG_FONT);
CHECK(xvt_font_is_mapped(BIG_FONT), "Can't map native font");
BIGFAT_FONT = xvt_font_create();
xvt_font_copy(BIGFAT_FONT, FAT_FONT, XVT_FA_ALL);
xvt_font_set_size(BIGFAT_FONT, xvt_font_get_size(FAT_FONT) * 2);
xvt_font_map_using_default(BIGFAT_FONT);
CHECK(xvt_font_is_mapped(BIGFAT_FONT), "Can't map native font");
// Compute true text size
ROWY = (pc.bottom - pc.top) / 25; ROWY = (pc.bottom - pc.top) / 25;
const int COLX = (pc.right - pc.left) / 80; const int COLX = (pc.right - pc.left) / 80;
@ -223,7 +246,13 @@ XVT_FNTID xvt_default_font(bool bold)
CHARY = ROWY-2; CHARY = ROWY-2;
} }
return bold ? FAT_FONT : DEF_FONT; XVT_FNTID f;
if (bold)
f = big ? BIGFAT_FONT : FAT_FONT;
else
f = big ? BIG_FONT : DEF_FONT;
return f;
} }
XVT_FNTID xvt_load_default_font() XVT_FNTID xvt_load_default_font()
@ -238,9 +267,19 @@ XVT_FNTID xvt_load_default_font()
xvt_font_destroy(FAT_FONT); xvt_font_destroy(FAT_FONT);
FAT_FONT = NULL; FAT_FONT = NULL;
} }
if (BIG_FONT)
{
xvt_font_destroy(BIG_FONT);
BIG_FONT = NULL;
}
if (BIGFAT_FONT)
{
xvt_font_destroy(BIGFAT_FONT);
BIGFAT_FONT = NULL;
}
X_FU_MULTIPLE = Y_FU_MULTIPLE = 0; X_FU_MULTIPLE = Y_FU_MULTIPLE = 0;
XVT_FNTID font = xvt_default_font(false); XVT_FNTID font = xvt_default_font();
xi_set_font_id(font); xi_set_font_id(font);
xi_init_sysvals(); // Ricalcola i FU units xi_init_sysvals(); // Ricalcola i FU units
@ -394,6 +433,11 @@ void free_controls()
xvt_font_destroy(FAT_FONT); xvt_font_destroy(FAT_FONT);
FAT_FONT = NULL; FAT_FONT = NULL;
} }
if (BIG_FONT)
{
xvt_font_destroy(BIG_FONT);
BIG_FONT = NULL;
}
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -483,7 +527,7 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
def->v.itf->automatic_back_color = false; def->v.itf->automatic_back_color = false;
def->v.itf->back_color = MASK_BACK_COLOR; def->v.itf->back_color = MASK_BACK_COLOR;
def->v.itf->font_id = xvt_default_font(false); def->v.itf->font_id = xvt_default_font();
def->v.itf->tab_on_enter = true; def->v.itf->tab_on_enter = true;
def->v.itf->win = (XinWindow)win; def->v.itf->win = (XinWindow)win;
def->v.itf->edit_menu = true; // Update edit menu items def->v.itf->edit_menu = true; // Update edit menu items
@ -959,9 +1003,10 @@ unsigned long TControl::flags2attr(const char* flags) const
return attrib; return attrib;
} }
const char* TControl::parse_caption(const char* cap, bool& bold, COLOR& color) const const char* TControl::parse_caption(const char* cap, bool& bold, bool& big, COLOR& color) const
{ {
bold = false; bold = false;
big = false;
color = NORMAL_COLOR; color = NORMAL_COLOR;
const char* t; const char* t;
@ -977,6 +1022,12 @@ const char* TControl::parse_caption(const char* cap, bool& bold, COLOR& color) c
t++; t++;
} }
else else
if (code == 'G')
{
big = true;
t++;
}
else
{ {
NFCHECK("Bad character (%c) after @ in %s", code, cap); NFCHECK("Bad character (%c) after @ in %s", code, cap);
break; break;
@ -1131,6 +1182,13 @@ void TControl::set_read_only(bool on)
change_attrib(XI_ATR_READONLY, on); change_attrib(XI_ATR_READONLY, on);
} }
void TControl::set_pos(int pos)
{
xi_lowlevel_focus(_obj, TRUE);
if (pos >= 0)
xi_aga_field_set_pos(_obj, pos);
}
const char* TControl::caption() const const char* TControl::caption() const
{ {
const char* c = xi_get_text(_obj, NULL, 512); const char* c = xi_get_text(_obj, NULL, 512);
@ -1160,9 +1218,9 @@ TText_control::TText_control(WINDOW win, short cid,
short left, short top, short width, short height, short left, short top, short width, short height,
const char* flags, const char* text) const char* flags, const char* text)
{ {
bool bold; bool bold, big;
COLOR color; COLOR color;
TString t = parse_caption(text, bold, color); TString t = parse_caption(text, bold, big, color);
t.rtrim(); t.rtrim();
if (width <= 0) if (width <= 0)
width = t.len(); width = t.len();
@ -1185,20 +1243,20 @@ TText_control::TText_control(WINDOW win, short cid,
void TText_control::set_caption(const char* text) void TText_control::set_caption(const char* text)
{ {
bool bold; bool bold, big;
COLOR color; COLOR color;
const char* c = parse_caption(text, bold, color); const char* c = parse_caption(text, bold, big, color);
xi_set_text(_obj, (char*)c); xi_set_text(_obj, (char*)c);
_obj->v.text->fore_color = color; _obj->v.text->fore_color = color;
#ifdef XI_R4 #ifdef XI_R4
xi_set_obj_font_id(_obj, xvt_default_font(bold)); xi_set_obj_font_id(_obj, xvt_default_font(bold, big));
#else #else
FONT_OBJ* &font = _obj->v.text->font; FONT_OBJ* &font = _obj->v.text->font;
if (font == NULL) if (font == NULL)
font = (FONT_OBJ*)xi_tree_malloc(sizeof(FONT_OBJ), _obj->v.text); font = (FONT_OBJ*)xi_tree_malloc(sizeof(FONT_OBJ), _obj->v.text);
*font = xi_create_copy_font_id(get_interface(), xvt_default_font(bold), NULL); *font = xi_create_copy_font_id(get_interface(), xvt_default_font(bold. big), NULL);
RCT rct; get_rect(rct); RCT rct; get_rect(rct);
if (bold) if (bold)
@ -1388,7 +1446,12 @@ bool TField_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
break; break;
case XIE_DBL_FIELD: case XIE_DBL_FIELD:
if (!read_only()) if (!read_only())
{
if( true)
notify_key(K_F12);
else
notify_key(K_F9); notify_key(K_F9);
}
break; break;
case XIE_CHAR_FIELD: case XIE_CHAR_FIELD:
{ {
@ -1445,7 +1508,7 @@ void TButton_control::create(WINDOW win, short cid,
const char* flags, const char* text, const char* flags, const char* text,
WIN_TYPE wc, XI_OBJ* container) WIN_TYPE wc, XI_OBJ* container)
{ {
bool bold; bool bold, big;
COLOR color; COLOR color;
TString txt(text); txt.trim(); TString txt(text); txt.trim();
@ -1460,7 +1523,7 @@ void TButton_control::create(WINDOW win, short cid,
mnemonic = txt[underscore+1]; mnemonic = txt[underscore+1];
txt.strip("&~"); txt.strip("&~");
} }
const char* t = parse_caption(txt, bold, color); const char* t = parse_caption(txt, bold, big, color);
if (width <= 0) width = strlen(t)+3; if (width <= 0) width = strlen(t)+3;
RCT rct; coord2rct(win, left, top, width, height, rct); RCT rct; coord2rct(win, left, top, width, height, rct);
@ -1472,7 +1535,11 @@ void TButton_control::create(WINDOW win, short cid,
def->app_data = (long)this; def->app_data = (long)this;
switch (wc) switch (wc)
{ {
case WC_PUSHBUTTON : def->v.btn->type = XIBT_BUTTON; break; case WC_PUSHBUTTON :
def->v.btn->type = XIBT_BUTTON;
if (bold)
def->v.btn->font = (XinFont *)BIG_FONT;
break;
case WC_CHECKBOX : def->v.btn->type = XIBT_CHECKBOX; break; case WC_CHECKBOX : def->v.btn->type = XIBT_CHECKBOX; break;
case WC_RADIOBUTTON: def->v.btn->type = XIBT_RADIOBTN; break; case WC_RADIOBUTTON: def->v.btn->type = XIBT_RADIOBTN; break;
case WC_CHECKBUTTON: def->v.btn->type = XIBT_BUTTON_CHECKBOX; break; case WC_CHECKBUTTON: def->v.btn->type = XIBT_BUTTON_CHECKBOX; break;
@ -1628,9 +1695,10 @@ char TPushbutton_control::mnemonic() const
void TPushbutton_control::set_caption(const char* c) void TPushbutton_control::set_caption(const char* c)
{ {
bool bold; bool bold, big;
COLOR color; COLOR color;
const char* cap = parse_caption(c, bold, color); const char* cap = parse_caption(c, bold, big, color);
if (*cap) if (*cap)
{ {
TControl::set_caption(cap); TControl::set_caption(cap);
@ -1638,17 +1706,10 @@ void TPushbutton_control::set_caption(const char* c)
set_bmp(0, 0); set_bmp(0, 0);
_obj->v.btn->drawable = false; _obj->v.btn->drawable = false;
_obj->v.btn->fore_color = color; _obj->v.btn->fore_color = color;
xi_set_obj_font_id(_obj, xvt_default_font(bold, big));
} }
} }
void TPushbutton_control::set_central_icon(unsigned int hicon)
{
xi_set_icon(_obj, hicon, hicon);
_obj->v.btn->icon_x = (_obj->v.btn->rct.right - _obj->v.btn->rct.left - 32) / 2 - 5;
_obj->v.btn->icon_y = (_obj->v.btn->rct.bottom - _obj->v.btn->rct.top - 32) / 2 - 5;
_obj->v.btn->drawable = false;
}
void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn) void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
{ {
if (bmp_up > 0) if (bmp_up > 0)
@ -1662,6 +1723,22 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
_obj->v.btn->drawable = _bmp_up > 0; _obj->v.btn->drawable = _bmp_up > 0;
} }
void TPushbutton_control::set_bmp(const char * bmp_up, const char * bmp_dn)
{
if (bmp_up && *bmp_up)
{
_bmp_up = _picture->add(bmp_up);
if (bmp_dn && *bmp_dn)
_bmp_dn = _picture->add(bmp_dn);
else
_bmp_dn = _bmp_up;
set_icon(0);
}
else
_bmp_up = _bmp_dn = 0;
_obj->v.btn->drawable = _bmp_up > 0;
}
void TPushbutton_control::update() void TPushbutton_control::update()
{ {
const long attrib = xi_get_attrib(_obj); const long attrib = xi_get_attrib(_obj);
@ -1817,9 +1894,9 @@ TRadiobutton_control::TRadiobutton_control(WINDOW win, short cid,
const unsigned long attrib = flags2attr(flags); const unsigned long attrib = flags2attr(flags);
for (int b = 1; b <= tot; b++) for (int b = 1; b <= tot; b++)
{ {
bool bold; bool bold, big;
COLOR color; COLOR color;
const char* t = parse_caption(testo.get(), bold, color); const char* t = parse_caption(testo.get(), bold, big, color);
const int next = cid + (b+1)*1000; const int next = cid + (b+1)*1000;
XI_OBJ_DEF* btn_def = xi_add_button_def(def, cid + b*1000, NULL, attrib, (char*)t, next); XI_OBJ_DEF* btn_def = xi_add_button_def(def, cid + b*1000, NULL, attrib, (char*)t, next);
@ -1942,9 +2019,9 @@ TTagbutton_control::TTagbutton_control(WINDOW win, short cid,
for (int b = 1; b <= tot; b++) for (int b = 1; b <= tot; b++)
{ {
bool bold; bool bold, big;
COLOR color; COLOR color;
const char* t = parse_caption(titolo.get(), bold, color); const char* t = parse_caption(titolo.get(), bold, big, color);
const int next_bid = b == tot ? cid+1 : cid+b+1; const int next_bid = b == tot ? cid+1 : cid+b+1;
XI_OBJ_DEF* btn_def = xi_add_button_def(cnt_def, cid+b, NULL, attrib, (char*)t, next_bid); XI_OBJ_DEF* btn_def = xi_add_button_def(cnt_def, cid+b, NULL, attrib, (char*)t, next_bid);

View File

@ -20,7 +20,7 @@ struct XI_EVENT;
void init_controls(); void init_controls();
void free_controls(); void free_controls();
XVT_FNTID xvt_default_font(bool bold = FALSE); XVT_FNTID xvt_default_font(bool bold = false, bool big = false);
XVT_FNTID xvt_load_default_font(); XVT_FNTID xvt_load_default_font();
WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
@ -63,7 +63,7 @@ protected:
void coord2rct(WINDOW win, short left, short top, short width, short height, RCT& rct) const; void coord2rct(WINDOW win, short left, short top, short width, short height, RCT& rct) const;
unsigned long flags2attr(const char* flags) const; unsigned long flags2attr(const char* flags) const;
void update_tab_cid(); void update_tab_cid();
const char* parse_caption(const char* cap, bool& bold, COLOR& color) const; const char* parse_caption(const char* cap, bool& bold, bool& big, COLOR& color) const;
void change_attrib(unsigned long attr, bool on, XI_OBJ* obj = NULL); void change_attrib(unsigned long attr, bool on, XI_OBJ* obj = NULL);
@ -115,6 +115,9 @@ public:
virtual RCT& get_rect(RCT& r) const; virtual RCT& get_rect(RCT& r) const;
virtual void set_rect(const RCT& r); virtual void set_rect(const RCT& r);
// @cmember imposta la posizione del cursore a <pos>
void set_pos(int pos = -1);
bool on_key(KEY k); bool on_key(KEY k);
}; };
@ -226,6 +229,7 @@ public:
virtual void set_caption(const char* c); virtual void set_caption(const char* c);
void set_bmp(short up, short dn); void set_bmp(short up, short dn);
void set_bmp(const char * up, const char * dn);
void set_central_icon(unsigned int hicon); void set_central_icon(unsigned int hicon);
char mnemonic() const; char mnemonic() const;

View File

@ -73,39 +73,34 @@ TDate::TDate(const char* s)
{ {
_val = NULLDATE; _val = NULLDATE;
const int len = (s && *s) ? strlen(s) : 0; const int len = (s && *s >= '0') ? strlen(s) : 0;
if (len != 8 && len != 10) if (len != 8 && len != 10) // Chi si azzarda ad aggiungere len != 6 ?
return; return;
int d = 0, m = 0, y = 0, i;
if (len == 8) if (len == 8)
{ {
int i;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
if (!isdigit(s[i])) break; if (!isdigit(s[i])) break;
if (i == 8) if (i == 8)
{ _val = atol(s);
TString8 str(s);
d = atoi(((const char *)str)+6); str.cut(6);
m = atoi(((const char *)str)+4); str.cut(4);
y = atoi(((const char *)str)+0);
}
} }
else else
if (len == 10)
{ {
if (s[2] == s[5] && !isdigit(s[2])) if (s[2] == s[5] && !isdigit(s[2]))
{ {
d = atoi(s); const int d = atoi(s);
m = atoi(&s[3]); const int m = atoi(&s[3]);
y = atoi(&s[6]); const int y = atoi(&s[6]);
_val = makedata(d, m, y);
} }
} }
#ifdef DBG #ifdef DBG
if (d < 1 || d > 31 || m < 1 || m > 12 || y < 0) if (day() < 1 || day() > 31 || month() < 1 || month() > 12 || year() < 0)
yesnofatal_box("Lamentati con Guy se la data %s non viene accettata!", s); yesnofatal_box("Lamentati con Guy se la data '%s' non viene accettata!", s);
#endif #endif
_val = makedata(d, m, y);
} }
TDate::TDate(int day, int month, int year) TDate::TDate(int day, int month, int year)

View File

@ -612,7 +612,7 @@ void TExpression::eval()
{ {
const int len = (int)evalstack.pop_real().integer(); const int len = (int)evalstack.pop_real().integer();
TString & s1 = evalstack.peek_string(); TString & s1 = evalstack.peek_string();
s1 = s1.left(len); s1.cut(len);
} }
break; break;
case _right: case _right:

View File

@ -35,13 +35,46 @@ XVT_IMAGE TImage::set(
// Certified 100% // Certified 100%
// @doc EXTERNAL // @doc EXTERNAL
bool TImage::build_filename(TFilename & file)
{
const char * const exts[] = {"gif", "png", "bmp", "jpg", NULL};
bool ok = false;
if (file.ext()[0] != '\0')
ok = file.custom_path();
if (!ok)
{
for (int i = 0; !ok && exts[i]; i++)
{
file.ext(exts[i]);
ok = file.custom_path();
if (!ok)
{
TFilename res(file);
res.insert("res/");
ok = res.exist();
if (ok)
file = res;
}
}
}
return ok;
}
// @mfunc Legge l'immagine dal file // @mfunc Legge l'immagine dal file
XVT_IMAGE TImage::load( XVT_IMAGE TImage::load(
const char* n) // @parm Nome del file contenente l'immagine const char* n) // @parm Nome del file contenente l'immagine
{ {
XVT_IMAGE i = xvt_image_read((char*)n); TFilename f(n);
XVT_IMAGE i = NULL;
if (build_filename(f))
{
i = xvt_image_read(f);
if (i != NULL) if (i != NULL)
set(i); set(i);
}
return i; return i;
} }

View File

@ -9,6 +9,9 @@
#include <object.h> #include <object.h>
#endif #endif
#ifndef __STRINGS_H
#include <strings.h>
#endif
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TImage // TImage
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -88,6 +91,7 @@ public:
// @cmember Setta l'<p n>.esime entry della paletta al colore <p c> // @cmember Setta l'<p n>.esime entry della paletta al colore <p c>
void set_clut(byte n, COLOR c); void set_clut(byte n, COLOR c);
static bool build_filename(TFilename & file);
// @cmember Costruttore. Viene passato il nome del file // @cmember Costruttore. Viene passato il nome del file
TImage(const char* n); TImage(const char* n);
// @cmember Costruttore. Viene passato l'identificatore dell'immagine sul file di risorsa // @cmember Costruttore. Viene passato l'identificatore dell'immagine sul file di risorsa
@ -100,4 +104,5 @@ public:
virtual ~TImage(); virtual ~TImage();
}; };
#endif #endif

View File

@ -1,22 +1,10 @@
#include <fcntl.h>
#include <diction.h>
#ifdef WIN32
#include <io.h>
#include <share.h>
#include <stdio.h>
#endif
#include <stdlib.h>
#include <sys/stat.h>
#include <codeb.h>
#define __ISAM_CPP #define __ISAM_CPP
#include <config.h> #include <config.h>
#include <execp.h> #include <execp.h>
#include <expr.h> #include <expr.h>
#include <extcdecl.h> #include <extcdecl.h>
#include <diction.h>
#include <mailbox.h> #include <mailbox.h>
#include <postman.h> #include <postman.h>
#include <prefix.h> #include <prefix.h>
@ -28,6 +16,19 @@
#include <tabutil.h> #include <tabutil.h>
#include <varrec.h> #include <varrec.h>
#ifdef WIN32
#include <io.h>
#include <share.h>
#include <stdio.h>
#endif
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <codeb.h>
#ifdef JOURNAL #ifdef JOURNAL
#include <journal.h> #include <journal.h>
@ -2151,10 +2152,14 @@ int TSystemisamfile::update(
return err; return err;
} }
TString s; s << TR("Aggiornamento") << ' ' << fname; TString s(256); s << TR("Aggiornamento") << ' ' << fname;
const TRecnotype nitems = items(); const TRecnotype nitems = items();
TProgind p(nitems > 0 ? nitems : 1, s, true, true); #ifdef DBG
TProgind p(nitems > 0 ? nitems : 1, s, true, true, 78);
#else
TProgind p(nitems > 0 ? nitems : 1, s, false, true, 78);
#endif
TExtrectype nrec(wrec); TExtrectype nrec(wrec);
@ -2173,6 +2178,7 @@ int TSystemisamfile::update(
{ {
if (!p.addstatus(1)) if (!p.addstatus(1))
{ {
err = _iseof; // Simula errore in caso di interruzione
break; break;
} }
ni++; ni++;

View File

@ -316,6 +316,26 @@ bool rpc_UserLogout(const char* appname)
return TRUE; return TRUE;
} }
bool http_isredirected_server(TString & server,
TFilename & remote_file,
const char * authorization)
{
TSocketClient client;
if (!client.IsOk())
return error_box("Impossibile inizializzare il client HTTP");
CONNID connection = client.QueryConnection("80", server);
bool ok = connection != 0;
if (ok)
{
ok = client.HttpIsRedirectedServer(connection, server, remote_file, authorization) != 0;
client.RemoveConnection(connection);
}
return ok;
}
bool http_get(const char* server, bool http_get(const char* server,
const char* remote_file, const char* remote_file,

View File

@ -24,6 +24,7 @@ bool rpc_UserLogout(const char* appname);
bool rpc_Start(); bool rpc_Start();
bool rpc_Stop(); bool rpc_Stop();
bool http_isredirected_server(TString & server, TFilename & remote_file, const char* authorization = NULL);
bool http_get(const char* server, const char* remote_file, bool http_get(const char* server, const char* remote_file,
const char* local_file, const char* authorization = NULL); const char* local_file, const char* authorization = NULL);
bool http_dir(const char* server, const char* remote_dir, TString_array & list); bool http_dir(const char* server, const char* remote_dir, TString_array & list);

View File

@ -848,11 +848,7 @@ bool TMask::on_key(
} }
break; break;
case K_F12: case K_F12:
post_error_message(format("Lettura = %ld\n" send_key(K_F12, focus_field().dlg());
"Creazione = %ld\n"
"Inizializzazione = %ld\n",
_total_time-_build_time, _build_time, _init_time),
1);
break; break;
case K_CTRL+'+': case K_CTRL+'+':
if (is_running()) if (is_running())

View File

@ -1,10 +1,6 @@
#ifndef __MASK_H #ifndef __MASK_H
#define __MASK_H #define __MASK_H
#ifndef __WINDOW_H
#include <window.h>
#endif
#ifndef __MASKFLD_H #ifndef __MASKFLD_H
#include <maskfld.h> #include <maskfld.h>
#endif #endif

View File

@ -19,6 +19,7 @@
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <validate.h> #include <validate.h>
#include <virtkeyb.h>
#include <xvtility.h> #include <xvtility.h>
@ -148,8 +149,7 @@ void TMask_field::update_flags(const char* f, bool reset)
TMask_field::TMask_field(TMask* m) TMask_field::TMask_field(TMask* m)
: _mask(m), _groups(NULL), _ctl(NULL) : _mask(m), _groups(NULL), _ctl(NULL)
{ { }
}
// Certified 100% // Certified 100%
TMask_field::~TMask_field() TMask_field::~TMask_field()
@ -234,6 +234,15 @@ short TMask_field::atodlg(
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Imposta la posizione
void TMask_field::set_pos(
int pos) // @parm Posizione
{
_ctl->set_pos(pos);
}
// @doc EXTERNAL
// @mfunc Costruisce il campo // @mfunc Costruisce il campo
void TMask_field::construct( void TMask_field::construct(
short id, // @parm Identificatore del campo short id, // @parm Identificatore del campo
@ -1199,6 +1208,11 @@ void TButton_field::set_bmp(short up, short dn)
((TPushbutton_control*)_ctl)->set_bmp(up, dn); ((TPushbutton_control*)_ctl)->set_bmp(up, dn);
} }
void TButton_field::set_bmp(const char * up, const char * dn)
{
((TPushbutton_control*)_ctl)->set_bmp(up, dn);
}
void TButton_field::set_central_icon(unsigned icon) void TButton_field::set_central_icon(unsigned icon)
{ {
((TPushbutton_control*)_ctl)->set_icon(icon); ((TPushbutton_control*)_ctl)->set_icon(icon);
@ -3123,9 +3137,14 @@ void TEdit_field::parse_head(TScanner& scanner)
const TBrowse* TEdit_field::parse_browse(TScanner& scanner) const const TBrowse* TEdit_field::parse_browse(TScanner& scanner) const
{ {
const int id = scanner.integer(); const TBrowse* b = NULL;
const TEdit_field& f = mask().efield(id); const pos = mask().id2pos(scanner.integer());
const TBrowse* b = f.browse(); if (pos >= 0)
{
const TMask_field& f = mask().fld(pos);
if (f.is_edit())
b = ((TEdit_field&)f).browse();
}
return b; return b;
} }
@ -3236,10 +3255,8 @@ bool TEdit_field::parse_item(TScanner& scanner)
if (scanner.key() == "CO") // Copyuse if (scanner.key() == "CO") // Copyuse
{ {
const TString16 what(scanner.popkey()); const TString8 what(scanner.popkey());
const TBrowse* b = parse_browse(scanner); const TBrowse* b = parse_browse(scanner);
CHECK(b,"Impossibile copiare la browse da un campo visto che quel campo non l'ha" );
if (b) if (b)
{ {
if (what == "US" || what == "AL") if (what == "US" || what == "AL")
@ -3788,6 +3805,15 @@ bool TEdit_field::on_key(KEY key)
} }
} }
break; break;
case K_F12:
{
TVirtual_keyboard keyboard(*this);
get_window_data();
keyboard.run();
return true;
}
break;
case K_CTRL+K_SPACE: case K_CTRL+K_SPACE:
set_dirty(TRUE); set_dirty(TRUE);
return handler(K_SPACE); return handler(K_SPACE);
@ -4205,6 +4231,15 @@ bool TReal_field::on_key(KEY key)
beep(); beep();
return ok; return ok;
} }
else
if (key == K_F12)
{
TVirtual_numpad numpad(*this);
get_window_data();
numpad.run();
return true;
}
} }
return TEdit_field::on_key(key); return TEdit_field::on_key(key);
@ -4461,6 +4496,14 @@ bool TCurrency_field::on_key(KEY key)
case '-': case '-':
ok = !_flags.uppercase; ok = !_flags.uppercase;
break; break;
case K_F12 :
{
TVirtual_numpad numpad(*this, true);
get_window_data();
numpad.run();
return true;
}
default : default :
ok = strchr("0123456789.,+*-/()", key) != NULL; ok = strchr("0123456789.,+*-/()", key) != NULL;
break; break;

View File

@ -152,6 +152,8 @@ public: // TObject
virtual bool is_kind_of(word cid) const; virtual bool is_kind_of(word cid) const;
public: public:
// @cmember Imposta la posizione a <pos>
void set_pos(int pos = -1);
// @cmember Costruisce il campo da file // @cmember Costruisce il campo da file
void construct(TScanner& scanner, WINDOW parent); void construct(TScanner& scanner, WINDOW parent);
// @cmember Converte una stringa in un identificatore di controllo // @cmember Converte una stringa in un identificatore di controllo
@ -181,6 +183,10 @@ public:
// @cmember Setta lo stato di dirty del campo // @cmember Setta lo stato di dirty del campo
void set_dirty(byte d = true); void set_dirty(byte d = true);
// @cmember ritorna il trim degli spazi
byte trim() const
{ return _flags.trim; }
// @cmember Abilita il trim degli spazi // @cmember Abilita il trim degli spazi
void set_trim(bool t) void set_trim(bool t)
{ _flags.trim = byte(t ? 3 : 0); } { _flags.trim = byte(t ? 3 : 0); }
@ -208,6 +214,10 @@ public:
bool zerofilled() const bool zerofilled() const
{ return _flags.zerofilled; } { return _flags.zerofilled; }
// @cmember Ritorna TRUE se il campo e' password
bool password() const
{ return _flags.password; }
// @cmember Verifica se l'inserimento del carattere pipe e' stato abilitato // @cmember Verifica se l'inserimento del carattere pipe e' stato abilitato
bool pipe_allowed() const bool pipe_allowed() const
{ return _flags.pipeallowed; } { return _flags.pipeallowed; }
@ -548,7 +558,8 @@ public:
{ return _exit_key; } { return _exit_key; }
void set_exit_key(KEY k) { _exit_key = k; } void set_exit_key(KEY k) { _exit_key = k; }
void set_bmp(short up, short dn); void set_bmp(short up, short dn = 0);
void set_bmp(const char * up, const char * dn = NULL);
void set_central_icon(unsigned int icon); void set_central_icon(unsigned int icon);
// @cmember Costruttore // @cmember Costruttore
@ -1132,11 +1143,11 @@ protected:
// @cmember Imposta lo sfondo del campo // @cmember Imposta lo sfondo del campo
void set_background(); void set_background();
// @access Public Member
public:
// @cmember Setta il flag read-only // @cmember Setta il flag read-only
virtual void set_read_only(bool r); virtual void set_read_only(bool r);
// @access Public Member
public:
// @cmember Ritorna l'identificatore della classe // @cmember Ritorna l'identificatore della classe
virtual word class_id() const; virtual word class_id() const;
// @cmember Legge un item del controllo dal file <p scanner> // @cmember Legge un item del controllo dal file <p scanner>

View File

@ -1009,7 +1009,7 @@ bool TSpreadsheet::off_cell_handler(XI_OBJ *cell)
_cell_dirty = FALSE; _cell_dirty = FALSE;
if (_row_dirty) if (_row_dirty)
{ {
owner().mask().notify_focus_field(owner().dlg()); // A volte si diverte a perdere il focus owner().mask().notify_focus_field(id()); // A volte si diverte a perdere il focus
mask2str(_cur_rec); // Update sheet row mask2str(_cur_rec); // Update sheet row
} }
} }
@ -1215,13 +1215,13 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
if (items() > 0 && !owner().append()) if (items() > 0 && !owner().append())
{ {
// XI_OBJ* itf = get_interface(); // XI_OBJ* itf = get_interface();
if (owner().mask().focus_field().dlg() == owner().dlg()) if (owner().mask().focus_field().dlg() == id())
rec = _cur_rec + 1; rec = _cur_rec + 1;
else else
rec = 0; rec = 0;
} }
insert(rec, TRUE, TRUE); insert(rec, true, true);
owner().mask().notify_focus_field(owner().dlg()); owner().mask().notify_focus_field(id());
} }
} }
} }
@ -1348,7 +1348,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
} }
break; break;
case XIE_ON_LIST: case XIE_ON_LIST:
owner().mask().notify_focus_field(owner().dlg()); owner().mask().notify_focus_field(id());
break; break;
case XIE_OFF_LIST: case XIE_OFF_LIST:
on_idle(); on_idle();
@ -1443,12 +1443,12 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
EVENT e; e.type = E_UPDATE; EVENT e; e.type = E_UPDATE;
xi_eh(_obj->itf->v.itf->xvt_win, &e); xi_eh(_obj->itf->v.itf->xvt_win, &e);
#endif #endif
owner().mask().notify_focus_field(id()); // Non si ripete mai abbastanza!
} }
XI_OBJ row; XI_OBJ row;
XI_MAKE_ROW(&row, _obj, _cur_row); XI_MAKE_ROW(&row, _obj, _cur_row);
xi_cell_request(&row); // Update internal values xi_cell_request(&row); // Update internal values
} }
break; break;
case XIE_OFF_CELL: case XIE_OFF_CELL:
@ -1611,13 +1611,13 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
if (items() > 0 && !owner().append()) if (items() > 0 && !owner().append())
{ {
get_interface(); // verificare get_interface(); // verificare
if (owner().mask().focus_field().dlg() == owner().dlg()) if (owner().mask().focus_field().dlg() == id())
rec = _cur_rec + 1; rec = _cur_rec + 1;
else else
rec = 0; rec = 0;
} }
insert(rec, TRUE, TRUE); insert(rec, TRUE, TRUE);
owner().mask().notify_focus_field(owner().dlg()); owner().mask().notify_focus_field(id());
refused = TRUE; refused = TRUE;
} }
else else
@ -2376,7 +2376,7 @@ void TSpreadsheet::str2mask(int riga)
// Certified 100% // Certified 100%
bool TSpreadsheet::notify(int rec, KEY k) bool TSpreadsheet::notify(int rec, KEY k)
{ {
const bool ok = _notify ? _notify(owner(), rec, k) : TRUE; const bool ok = _notify ? _notify(owner(), rec, k) : true;
if (k == K_ENTER) if (k == K_ENTER)
{ {
const bool cell_dirty = _cell_dirty; // preservato lo stato di cell_dirty const bool cell_dirty = _cell_dirty; // preservato lo stato di cell_dirty

View File

@ -276,9 +276,9 @@ public:
}; };
#define FOR_EACH_SHEET_ROW(__sheet, __r, __riga) \ #define FOR_EACH_SHEET_ROW(__sheet, __r, __riga) \
FOR_EACH_ARRAY_ROW(__sheet.rows_array(), __r, __riga) FOR_EACH_ARRAY_ROW((__sheet).rows_array(), __r, __riga)
#define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \ #define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \
FOR_EACH_ARRAY_ROW_BACK(__sheet.rows_array(), __r, __riga) FOR_EACH_ARRAY_ROW_BACK((__sheet).rows_array(), __r, __riga)
#endif #endif

View File

@ -1,8 +1,9 @@
#define XVT_INCL_NATIVE #define XVT_INCL_NATIVE
#include <xvt.h> #include <xvt.h>
#include <progind.h>
#include <config.h>
#include <agasys.h> #include <agasys.h>
#include <diction.h>
#include <progind.h>
#include <utility.h> #include <utility.h>
// skstream.h // skstream.h
@ -713,7 +714,7 @@ bool TSocketClient::ReadLine(CONNID id, TString& str)
TSocket_connection* conn = (TSocket_connection*)GetConnection(id); TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
if (conn) if (conn)
return conn->ReadLine(str); return conn->ReadLine(str);
return FALSE; return false;
} }
void TSocketClient::ReleaseBuffer() void TSocketClient::ReleaseBuffer()
@ -725,84 +726,197 @@ void TSocketClient::ReleaseBuffer()
m_dwSize = 0; m_dwSize = 0;
} }
} }
int TSocketClient::HttpGetHeader(CONNID id, const char* remote, const char* authorization,
bool TSocketClient::HttpGetFile(CONNID id, const char* remote, const char* local, const char* authorization) TString_array& header)
{ {
bool ok = FALSE; int ret = 0;
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
TString buf(8*1024); TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
TString buf(4*1024);
buf << "GET " << remote << " HTTP/1.1\r\n" buf << "GET " << remote << " HTTP/1.1\r\n"
<< "User-Agent: Campo\r\n" << "User-Agent: Campo\r\n"
<< "Host: " << conn->Server() << "\r\n"; << "Host: " << conn->Server() << "\r\n";
if (authorization && *authorization) if (authorization && *authorization)
buf << "Authorization: " << authorization << "\r\n"; buf << "Authorization: " << authorization << "\r\n";
const TFixed_string rem(remote);
buf << "Connection: " << (rem.ends_with("/") ? "Close" : "Keep-Alive") << "\r\n";
buf << "\r\n"; buf << "\r\n";
header.destroy();
if (WriteLine(id, buf)) if (WriteLine(id, buf))
{ {
long size = 0;
for (int r = 0; ; r++) for (int r = 0; ; r++)
{ {
ReadLine(id, buf); ReadLine(id, buf);
if (buf.blank()) if (buf.blank())
break; break;
if (r == 0 && buf.find("200 OK") < 0) if (r == 0)
return FALSE; // File not found ret = atoi(buf.after(' '));
if (buf.compare("Content-length:", 15, TRUE) == 0) header.add(buf);
}
}
return ret;
}
bool TSocketClient::HttpIsRedirectedServer(CONNID id, TString & http_server, TFilename & remote, const char* authorization)
{
TString_array header;
const bool redirected = HttpGetHeader(id, remote, NULL, header) == 302;
if (redirected)
{ {
const int colon = buf.find(':'); FOR_EACH_ARRAY_ROW(header, r, row)
size = atol(buf.mid(colon+1)); {
TString& buf = *row;
if (buf.starts_with("Location:", true))
{
buf = buf.after(':');
if (buf.full())
{
buf.trim();
if (buf.starts_with("http://", true))
buf.ltrim(7);
const int slash = buf.find('/');
if (slash > 0)
{
remote = buf.mid(slash);
if (!remote.ends_with("/"))
remote << '/';
http_server = buf.left(slash);
} }
} }
}
}
}
return redirected;
}
static const TString& bytes2str(long b)
{
TString& tmp = get_tmp_string();
if (b > 0)
{
const long mega = 1024*1024;
if (b >= mega)
tmp.format("%ld MBytes", (b+mega/2)/mega);
else
{
const long kappa = 1024;
if (b >= kappa)
tmp.format("%ld KBytes", (b+kappa/2)/kappa);
else
tmp.format("%ld Bytes", b);
}
}
else
tmp = TR("Dimensione sconosciuta");
return tmp;
}
bool TSocketClient::HttpGetFile(CONNID id, const char* remote, const char* local, const char* authorization)
{
bool ok = false;
TString_array header;
const int ret = HttpGetHeader(id, remote, authorization, header);
if (ret == 200)
{
long size = -1; // Unknown size
FOR_EACH_ARRAY_ROW(header, r, row)
{
if (row->starts_with("Content-length:", true))
{
size = atol(row->after(':'));
break;
}
}
if (size == 0) // File not found
return false;
ofstream outfile(local, ios::out | ios::binary); ofstream outfile(local, ios::out | ios::binary);
if (outfile.good()) if (outfile.good())
{ {
buf.cut(0) << remote << " - " << (size / 1024 + 1) << " KBytes"; TString buf(8*1024);
TProgind pi(size, buf, TRUE, TRUE);
TToken_string strpi(256, '\n');
strpi << remote << " - " << bytes2str(size);
strpi.add(TR("Trasferiti"));
long total = 0; long total = 0;
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
skstream* cur_socket = conn->GetSocket(); skstream* cur_socket = conn->GetSocket();
while (!cur_socket->eof()) if (size > 0) // Dimensione nota
{ {
int nchars = buf.size(); if (size <= buf.size()) // File piccolo: Niente barra di progresso
{
if (size >0 && nchars > size - total) while (total < size && !cur_socket->eof())
nchars = size - total; {
const int nchars = min(buf.size(), size - total);
cur_socket->read(buf.get_buffer(), nchars);
const int count = cur_socket->gcount();
if (count > 0)
{
total += count;
outfile.write(buf, count);
}
}
}
else
{
TProgind pi(size, strpi, true, true);
while (!cur_socket->eof() && !pi.iscancelled())
{
const int nchars = min(buf.size(), size - total);
cur_socket->read(buf.get_buffer(), nchars); cur_socket->read(buf.get_buffer(), nchars);
const int count = cur_socket->gcount(); const int count = cur_socket->gcount();
if (count > 0) if (count > 0)
{ {
outfile.write(buf, count); outfile.write(buf, count);
total += count; total += count;
pi.setstatus(total); if (total >= size || !pi.setstatus(total)) // Controllo se ormai ho finito
if (pi.iscancelled())
break;
if (size > 0 && total >= size)
break; break;
strpi.add(TR("Trasferiti"), 1);
strpi << ' ' << bytes2str(total);
pi.set_text(strpi);
} }
} }
ok = size = 0 ? cur_socket->eof() != 0 : total >= size; }
ok = total >= size; // Ho finito per bene?
}
else // Dimensione ignota
{
TIndwin pi(100, strpi, true, false);
while (!cur_socket->eof() && !pi.iscancelled())
{
cur_socket->read(buf.get_buffer(), buf.size());
const int count = cur_socket->gcount();
if (count > 0)
{
outfile.write(buf, count);
total += count;
strpi.add(TR("Trasferiti"), 1);
strpi << ' ' << bytes2str(total);
pi.set_text(strpi);
}
}
ok = total > 0 && !pi.iscancelled(); // Ho finito per bene?
}
} }
else else
error_box("Impossibile scrivere il file %s", local); error_box(FR("Impossibile scrivere il file %s"), local);
} }
return ok; return ok;
} }
HIDDEN int find_href(const TString& riga) HIDDEN int find_href(const TString& riga, int from)
{ {
int href = -1; int href = -1;
int img = riga.find("<img"); int img = riga.find("<img", from);
if (img >= 0) if (img >= 0)
href = riga.find("href=", img+4); href = riga.find("href=", img+4);
else
{
img = riga.find("<IMG");
if (img >= 0)
href = riga.find("HREF=", img+4);
}
return href; return href;
} }
@ -813,20 +927,21 @@ bool TSocketClient::HttpGetDir(CONNID id, const char* remote, TString_array& lis
if (ok) if (ok)
{ {
ifstream s(local); ifstream s(local);
TString riga(256); TString riga(512);
while (!s.eof()) while (!s.eof())
{ {
s.getline(riga.get_buffer(), riga.size()); s.getline(riga.get_buffer(), riga.size());
const int href = find_href(riga); riga.lower();
if (href > 0) for (int href = find_href(riga, 0); href > 0; href = find_href(riga, href+5))
{ {
const int start = riga.find('"', href) + 1; const int start = riga.find('"', href) + 1;
if (start > href && isalnum(riga[start + 1])) if (start > href)
{ {
const int stop = riga.find('"', start); const int stop = riga.find('"', start);
if (stop > start) if (stop > start)
{ {
const TString& name = riga.sub(start, stop); const TString& name = riga.sub(start, stop);
if (isdigit(name[0]) || (name[0]>='a' && name[0]<='z')) // isalnum non funziona!
list.add(name); list.add(name);
} }
} }

View File

@ -37,6 +37,7 @@ class TSocketClient : public TLanClient
protected: // TLanClient protected: // TLanClient
virtual TConnection* OnQueryConnection(const char* service, const char* server); virtual TConnection* OnQueryConnection(const char* service, const char* server);
int HttpGetHeader(CONNID id, const char* remote, const char* authorization, TString_array& header);
public: public:
virtual bool Request(CONNID id, const char* cmd); virtual bool Request(CONNID id, const char* cmd);
@ -47,6 +48,7 @@ public:
bool WriteLine(CONNID id, const char* str); bool WriteLine(CONNID id, const char* str);
bool ReadLine(CONNID id, TString& str); bool ReadLine(CONNID id, TString& str);
bool HttpIsRedirectedServer(CONNID id, TString & http_server, TFilename & remote, const char* authorization = NULL);
bool HttpGetFile(CONNID id, const char* remote, const char* local, const char* authorization = NULL); bool HttpGetFile(CONNID id, const char* remote, const char* local, const char* authorization = NULL);
bool HttpGetDir(CONNID id, const char* remote, TString_array& list); bool HttpGetDir(CONNID id, const char* remote, TString_array& list);
bool HttpSoap(CONNID id, const char* query); bool HttpSoap(CONNID id, const char* query);

View File

@ -1295,6 +1295,100 @@ bool TPrefix::build_firm_data(long codditta, bool flagcom)
set_codditta(codditta); set_codditta(codditta);
set_autoload_new_files(TRUE); set_autoload_new_files(TRUE);
return TRUE; return true;
} }
///////////////////////////////////////////////////////////
// TTable name converter
///////////////////////////////////////////////////////////
class TTable_names : public TObject
{
TAssoc_array _names;
TArray _ids;
long _filled;
protected:
void fill();
void add_file(int logic, const TString& table);
public:
const TString& name(int logic_num);
int logic_num(const TString& name);
TTable_names() : _filled(-1) { }
} _table_names;
void TTable_names::add_file(int logic, const TString& table)
{
TString8* id = new TString8;
id->format("%d", logic);
_names.add(table, id);
_ids.add(table, logic);
}
void TTable_names::fill()
{
if (_filled != prefix().get_codditta())
{
FileDes dir;
CGetFile(LF_DIR, &dir, _nolock, NORDIR);
const int nfiles = (int)dir.EOD;
TFilename n;
for (int logic = LF_USER; logic <= nfiles; logic++)
{
const FileDes& fd = prefix().get_filedes(logic);
n = fd.SysName; n = n.name(); n.upper();
if (_names.objptr(n) == NULL)
add_file(logic, n);
}
_filled = prefix().get_codditta();
}
}
int TTable_names::logic_num(const TString& n)
{
// Non cambiare: n puo' essere temporaneo e pieno di spazi!
TString80 name = n; name.trim();
if (isdigit(name[0]) || name[0] == '-')
{
int num = atoi(name);
if (name[name.len()-1] == '@')
num = -num;
return num;
}
if (name[0] == '%' && name.len() == 4)
return LF_TABCOM;
name.upper();
TString* str = (TString*)_names.objptr(name);
if (str == NULL)
{
fill();
str = (TString*)_names.objptr(name);
}
if (str == NULL && name.len() == 3)
return LF_TAB;
return str == NULL ? 0 : atoi(*str);
}
const TString& TTable_names::name(int logic_num)
{
TString* str = (TString*)_ids.objptr(logic_num);
if (str == NULL)
{
fill();
str = (TString*)_ids.objptr(logic_num);
}
return str == NULL ? (const TString&)EMPTY_STRING : *str;
}
const TString& logic2table(int logic_num)
{ return _table_names.name(logic_num); }
int table2logic(const TString& name)
{ return _table_names.logic_num(name); }

View File

@ -69,14 +69,13 @@ class TFirm : public TObject
{ {
TAssoc_array _rec; TAssoc_array _rec;
protected:
const TString& get(const char* attr) const;
long get_long(const char* attr) const;
public: public:
bool read(long code); bool read(long code);
TFirm& operator=(long code) { read(code); return *this; } TFirm& operator=(long code) { read(code); return *this; }
const TString& get(const char* attr) const;
long get_long(const char* attr) const;
long codice() const; long codice() const;
const TString& codice_valuta() const; const TString& codice_valuta() const;
const TString& ragione_sociale() const; const TString& ragione_sociale() const;
@ -229,5 +228,8 @@ bool prefix_valid();
TPrefix& prefix(); TPrefix& prefix();
void prefix_destroy(); void prefix_destroy();
const TString& logic2table(int logic_num);
int table2logic(const TString& name);
#endif // __PREFIX_H #endif // __PREFIX_H

View File

@ -248,7 +248,7 @@ void TIndwin::on_button(short id)
// TProgind -------------------------------------------------------------- // TProgind --------------------------------------------------------------
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div) TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
: TIndwin(max, txt, cancel, bar, div) : TIndwin(max, txt, cancel, bar, div), _next_update(0)
{} {}
bool TProgind::setstatus(long l) bool TProgind::setstatus(long l)
@ -258,15 +258,16 @@ bool TProgind::setstatus(long l)
NFCHECK("Negative progind status"); NFCHECK("Negative progind status");
l = 0; l = 0;
} }
const long old_perc = _status * 100L / _max;
_status = l > _max ? _max : l; _status = l > _max ? _max : l;
const long new_perc = _status * 100L / _max;
const bool tictac = new_perc != old_perc; if (clock() > _next_update)
if (tictac)
{ {
update(); update();
do_events(); do_events();
_next_update = clock()+CLOCKS_PER_SEC; // Prossimo aggiornamento tra un secondo
} }
return !iscancelled(); return !iscancelled();
} }

View File

@ -103,6 +103,8 @@ public:
class TProgind : public TIndwin class TProgind : public TIndwin
// @author:(INTERNAL) Villa // @author:(INTERNAL) Villa
{ {
clock_t _next_update;
// @access Public Member // @access Public Member
public: public:
// @cmember Setta lo stato della barra d'attesa // @cmember Setta lo stato della barra d'attesa

View File

@ -199,11 +199,9 @@ bool TRecordset::save_as_html(const char* path)
out << " </thead>" << endl; out << " </thead>" << endl;
TString val; TString val;
for (TRecnotype n = 0; n < items(); n++) for (bool ok = move_first(); ok; ok = move_next())
{ {
move_to(n); if (!pi.addstatus(1))
pi.addstatus(1);
if (pi.iscancelled())
break; break;
out << " <tr>" << endl; out << " <tr>" << endl;
for (unsigned int c = 0; c < columns(); c++) for (unsigned int c = 0; c < columns(); c++)
@ -250,34 +248,36 @@ bool TRecordset::save_as_silk(const char* path)
for (unsigned int c = 0; c < columns(); c++) for (unsigned int c = 0; c < columns(); c++)
{ {
const TRecordset_column_info& ci = column_info(c); const TRecordset_column_info& ci = column_info(c);
out << "C;Y1;X" << (c+1) << ";K\"" << ci._name << '"' << endl; out << 'C';
if (c == 0) out << ";Y1";
out << ";X" << (c+1) << ";K\"" << ci._name << '"' << endl;
} }
TString val; TString val;
for (TRecnotype n = 0; n < items(); n++) for (bool ok = move_first(); ok; ok = move_next())
{ {
move_to(n);
pi.addstatus(1);
if (pi.iscancelled())
break;
for (unsigned int c = 0; c < columns(); c++) for (unsigned int c = 0; c < columns(); c++)
{ {
const TRecordset_column_info& ci = column_info(c); out << 'C';
const bool is_alpha = ci._type == _alfafld || ci._type == _charfld || if (c == 0) out << ";Y" << (current_row()+2);
ci._type == _memofld || ci._type == _datefld; const TVariant& var = get(c);
if (!var.is_empty())
out << "C;Y" << (n+2) << ";X" << (c+1) << ";K"; {
if (is_alpha) out << '"'; out << ";X" << (c+1) << ";K";
get(c).as_string(val); var.as_string(val);
if (!val.blank()) if (var.type() == _alfafld || var.type() == _datefld)
{ {
val.rtrim(); val.rtrim();
val.replace('"', '\''); val.replace('"', '\'');
out << '"' << val << '"';
}
else
out << val; out << val;
} }
if (is_alpha) out << '"';
out << endl; out << endl;
} }
if (!pi.addstatus(1))
break;
} }
out << "E" << endl; out << "E" << endl;
@ -290,23 +290,25 @@ bool TRecordset::save_as_text(const char* path)
ofstream out(path); ofstream out(path);
TString val; TString val;
for (TRecnotype n = 0; n < items(); n++) for (bool ok = move_first(); ok; ok = move_next())
{ {
move_to(n);
for (unsigned int c = 0; c < columns(); c++) for (unsigned int c = 0; c < columns(); c++)
{ {
if (c > 0) if (c > 0)
out << '\t'; out << '\t';
get(c).as_string(val); const TVariant& var = get(c);
if (!val.blank()) if (!var.is_empty())
{ {
var.as_string(val);
val.rtrim(); val.rtrim();
if (val.find('\n') >= 0 || val.find('\t') >= 0)
out << unesc(val); // Evitiamo doppi separatori di campo e record
else
out << val; out << val;
} }
} }
out << endl; out << endl;
pi.addstatus(1); if (!pi.addstatus(1))
if (pi.iscancelled())
break; break;
} }
@ -333,24 +335,31 @@ bool TRecordset::save_as_campo(const char* path)
out << endl << endl << "[Data]" << endl; out << endl << endl << "[Data]" << endl;
TString val; TString val;
for (TRecnotype n = 0; n < items(); n++) for (bool ok = move_first(); ok; ok = move_next())
{ {
move_to(n);
for (unsigned int c = 0; c < columns(); c++) for (unsigned int c = 0; c < columns(); c++)
{ {
if (c > 0) if (c > 0)
out << '|'; out << '|';
get(c).as_string(val); const TVariant& var = get(c);
if (!val.blank()) if (!var.is_empty())
{
var.as_string(val);
if (var.type() == _alfafld)
{ {
val.rtrim(); val.rtrim();
val = unesc(val); val.replace('|', SAFE_PIPE_CHR); // Evitiamo doppi separatori di campo
if (val.find('\n') >= 0) // Evitiamo doppi separatori di record
out << unesc(val);
else
out << val;
}
else
out << val; out << val;
} }
} }
out << endl; out << endl;
pi.addstatus(1); if (!pi.addstatus(1))
if (pi.iscancelled())
break; break;
} }
return !pi.iscancelled(); return !pi.iscancelled();
@ -363,7 +372,7 @@ bool TRecordset::save_as(const char* path, TRecordsetExportFormat fmt, int mode)
TString ext; TString ext;
xvt_fsys_parse_pathname(path, NULL, NULL, NULL, ext.get_buffer(), NULL); xvt_fsys_parse_pathname(path, NULL, NULL, NULL, ext.get_buffer(), NULL);
ext.lower(); ext.lower();
if (ext.starts_with("htm")) if (ext == "htm" || ext == "html" || ext == "xml")
fmt = fmt_html; else fmt = fmt_html; else
if (ext == "xls" || ext == "slk") if (ext == "xls" || ext == "slk")
fmt = fmt_silk; fmt = fmt_silk;
@ -428,9 +437,9 @@ const TVariant& TRecordset::get(const char* column_name) const
int s = str.find(subfield); int s = str.find(subfield);
if (s == 0 || (s > 0 && str[s-1] < ' ')) if (s == 0 || (s > 0 && str[s-1] < ' '))
{ {
static TVariant var;
s += subfield.len(); s += subfield.len();
const int e = str.find('\n', s); const int e = str.find('\n', s);
TVariant& var = get_tmp_var();
var.set(str.sub(s, e)); var.set(str.sub(s, e));
return var; return var;
} }
@ -485,7 +494,7 @@ bool is_var_separator(char c)
{ {
if (isspace(c)) if (isspace(c))
return true; return true;
return strchr("<=>(,", c) != NULL; return strchr("<=>+-*/(,.", c) != NULL;
} }
// Cerca le variabili nel testo SQL: // Cerca le variabili nel testo SQL:
@ -1982,7 +1991,7 @@ const TRecordset_column_info& TISAM_recordset::column_info(size_t i) const
TCursor* TISAM_recordset::cursor() const TCursor* TISAM_recordset::cursor() const
{ {
if (_cursor == NULL && !_use.blank()) if (_cursor == NULL && _use.full())
{ {
TString use; parsed_text(use); TString use; parsed_text(use);
TPerformance_profiler prof("ISAM query"); TPerformance_profiler prof("ISAM query");
@ -2051,16 +2060,7 @@ bool TISAM_recordset::move_to(TRecnotype pos)
void TISAM_recordset::reset() void TISAM_recordset::reset()
{ {
_column.destroy(); _column.destroy();
if (_relation != NULL) requery();
{
delete _relation;
_relation = NULL;
}
if (_cursor != NULL)
{
delete _cursor;
_cursor = NULL;
}
} }
void TISAM_recordset::requery() void TISAM_recordset::requery()
@ -2070,6 +2070,11 @@ void TISAM_recordset::requery()
delete _cursor; delete _cursor;
_cursor = NULL; _cursor = NULL;
} }
if (_relation != NULL)
{
delete _relation;
_relation = NULL;
}
} }
void TISAM_recordset::set(const char* use) void TISAM_recordset::set(const char* use)
@ -2087,7 +2092,7 @@ TISAM_recordset::TISAM_recordset(const char* use)
TISAM_recordset::~TISAM_recordset() TISAM_recordset::~TISAM_recordset()
{ {
reset(); requery();
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -142,7 +142,7 @@ protected:
public: public:
bool valid_cursor() { return _cursor != NULL; } bool valid_cursor() { return _cursor != NULL; }
TCursor* cursor() const; virtual TCursor* cursor() const;
void set(const char* use); void set(const char* use);
virtual void requery(); virtual void requery();
virtual TRecnotype items() const; virtual TRecnotype items() const;

View File

@ -23,18 +23,15 @@ TRelation_application::~TRelation_application()
TCursor& TRelation_application::get_filtered_cursor() const TCursor& TRelation_application::get_filtered_cursor() const
{ {
TEdit_field& f = get_search_field(); const TEdit_field& f = get_search_field();
TCursor* cur = f.browse()->cursor(); return *f.browse()->cursor();
return *cur;
} }
void TRelation_application::setkey() void TRelation_application::setkey()
{ {
if (has_filtered_cursor()) if (has_filtered_cursor())
{
get_filtered_cursor().setkey(); get_filtered_cursor().setkey();
return; // ????? else
}
file().setkey(1); file().setkey(1);
} }
@ -85,46 +82,46 @@ void TRelation_application::set_limits(
{ {
if (has_filtered_cursor()) if (has_filtered_cursor())
{ {
TEdit_field& f = get_search_field(); const TEdit_field& f = get_search_field();
TBrowse* b = f.browse(); if (f.browse() != NULL)
TCursor* cur = b != NULL ? b->cursor() : NULL; f.browse()->do_input(true);
if (cur)
{
cur->setkey();
b->do_input(TRUE);
if (cur->items() == 0)
_first = _last = -1;
else
{
if (what & 0x1)
{
*cur = 0;
_first = cur->file().recno();
}
if (what & 0x2)
{
*cur = cur->items() - 1;
_last = cur->file().recno();
}
}
return;
}
}
file().setkey(1); TCursor& cur = get_filtered_cursor();
cur.setkey();
if (cur.items() > 0)
{
if (what & 0x1) if (what & 0x1)
{ {
if (!file().empty() && file().first() == NOERR) cur = 0;
_first = file().recno(); _first = cur.file().recno();
else
_first = -1;
} }
if (what & 0x2) if (what & 0x2)
{ {
if (!file().empty() && file().last() == NOERR) cur = cur.items() - 1;
_last = file().recno(); _last = cur.file().recno();
}
}
else else
_last = -1; _first = _last = -1;
}
else
{
setkey();
if (!file().empty())
{
if (what & 0x1)
{
if (file().first() == NOERR)
_first = file().recno();
}
if (what & 0x2)
{
if (file().last() == NOERR)
_last = file().recno();
}
}
else
_first = _last = -1;
} }
} }
@ -436,10 +433,10 @@ void TRelation_application::query_mode(
void TRelation_application::insert_mode() void TRelation_application::insert_mode()
{ {
bool try_auto = TRUE; bool try_auto = true;
if (_mask->query_mode()) if (_mask->query_mode())
try_auto = test_key(1, FALSE) == FALSE; try_auto = !test_key(1, FALSE);
if (try_auto && !autonum(_mask, FALSE)) if (try_auto && !autonum(_mask, FALSE))
{ {
@ -1110,6 +1107,8 @@ bool TRelation_application::save(bool check_dirty)
int TRelation_application::read(TMask& m) int TRelation_application::read(TMask& m)
{ {
const TRelation &r = *get_relation(); const TRelation &r = *get_relation();
/* Metodo VECCHIO!
const int max = m.fields(); const int max = m.fields();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
@ -1120,6 +1119,16 @@ int TRelation_application::read(TMask& m)
f.record()->read(*f.putkey(r)); f.record()->read(*f.putkey(r));
} }
} }
*/
if (m.sheets() > 0) // Metodo Salvatempo
{
FOR_EACH_MASK_SHEET(m, i, s)
{
if (s->record() && !s->external_record())
s->record()->read(*s->putkey(r));
}
}
m.autoload(r); m.autoload(r);
return NOERR; return NOERR;
} }
@ -1336,7 +1345,7 @@ void TRelation_application::main_loop()
case K_SAVE: case K_SAVE:
if (save(FALSE)) if (save(FALSE))
{ {
if ((_autoins_caller.not_empty() || is_transaction()) && _curr_trans_mode != TM_REMAIN) if ((_autoins_caller.full() || is_transaction()) && _curr_trans_mode != TM_REMAIN)
{ {
k = K_QUIT; k = K_QUIT;
} }

View File

@ -234,11 +234,11 @@ protected:
virtual void ini2sheet(TConfig& ini, TSheet_field &sheet); virtual void ini2sheet(TConfig& ini, TSheet_field &sheet);
virtual void sheet2ini(TSheet_field &sheet,TConfig& ini); virtual void sheet2ini(TSheet_field &sheet,TConfig& ini);
virtual void ini2mask(TConfig& ini, TMask& m, bool query); virtual void ini2mask(TConfig& ini, TMask& m, bool query);
virtual void mask2ini(const TMask& m, TConfig& ini);
virtual bool mask2mail(const TMask& m); virtual bool mask2mail(const TMask& m);
// @access Public Member // @access Public Member
public: public:
virtual void mask2ini(const TMask& m, TConfig& ini);
// @cmember Ritorna la relazione da modificare // @cmember Ritorna la relazione da modificare
virtual TRelation* get_relation() const pure; virtual TRelation* get_relation() const pure;
@ -253,7 +253,7 @@ public:
bool filtered() const bool filtered() const
{ return _fixed.not_empty(); } { return _fixed.not_empty(); }
// @cmember Cerca un record corrispondente alla chiave <p key> (0 prima chiave completa) // @cmember Cerca un record corrispondente alla chiave <p key> (0 prima chiave completa)
bool find(word key = 0); virtual bool find(word key = 0);
// @cmember Costruisce il membro <md TRelation_application::_fixed> // @cmember Costruisce il membro <md TRelation_application::_fixed>
void set_link(TMask & m, const char * keyexpr); void set_link(TMask & m, const char * keyexpr);
// @cmember Ritorna TRUE se e' stato chiamato col messaggio di link // @cmember Ritorna TRUE se e' stato chiamato col messaggio di link

View File

@ -2056,25 +2056,17 @@ int name2log(
int log = 0; int log = 0;
if (name) if (name)
while (*name == ' ') name++; {
while (isspace(*name))
name++;
if (name && *name) if (*name)
{ {
if (isdigit(*name) || *name == '-') log = table2logic(TFixed_string(name));
{
log = atoi(name);
if (strchr(name, '@')) log = -log;
}
else
{
const int len = strlen(name);
if (len == 3 || len == 4)
log = TTable::name2log(name);
}
CHECKS(log != 0, "Non e' un file ne' una tabella: ", name); CHECKS(log != 0, "Non e' un file ne' una tabella: ", name);
} }
}
return log; return log;
} }
@ -2411,9 +2403,7 @@ void TRelation_description::read_rel()
const char* tn = tt.get(0); // Codice del file o tabella const char* tn = tt.get(0); // Codice del file o tabella
int which_file = atoi(tn); // Non spostare questa riga (tn puo' cambiare!) const int which_file = name2log(tn); // Numero logico del file
if (which_file == 0)
which_file = TTable::name2log(tn); // Numero logico del file
if (tn[0] == '%' || tn[0] == '$') if (tn[0] == '%' || tn[0] == '$')
descfname << (tn+1); descfname << (tn+1);

View File

@ -670,8 +670,8 @@ void TReport_section::save(TXmlItem& root) const
item.AddChild("condition") << condition(); item.AddChild("condition") << condition();
if (grouped_by().not_empty()) if (grouped_by().not_empty())
item.AddChild("groupby") << grouped_by(); item.AddChild("groupby") << grouped_by();
if (_recordset != NULL) if (recordset() != NULL)
item.AddChild("sql") << _recordset->query_text(); item.AddChild("sql") << recordset()->query_text();
if (has_font()) if (has_font())
_font->save(item); _font->save(item);
@ -1256,7 +1256,7 @@ void TReport_field::set(const TVariant& var)
bool TReport_field::load_field() bool TReport_field::load_field()
{ {
const bool ok = !_field.blank(); const bool ok = _field.full();
if (ok) if (ok)
{ {
const TFieldtypes ft = var_type(); const TFieldtypes ft = var_type();
@ -1914,8 +1914,8 @@ void TReport::load_printer_font()
void TReport::update_recordset_parent() void TReport::update_recordset_parent()
{ {
if (_recordset != NULL) if (recordset() != NULL)
_recordset->set_parent(NULL); recordset()->set_parent(NULL);
for (int i = find_max_level('B'); i > 0; i--) for (int i = find_max_level('B'); i > 0; i--)
section('B', i).update_recordset_parent(); section('B', i).update_recordset_parent();
} }
@ -2187,8 +2187,8 @@ bool TReport::save(const char* fname) const
} }
} }
if (_recordset != NULL) if (recordset() != NULL)
xml.AddChild("sql") << _recordset->query_text(); xml.AddChild("sql") << recordset()->query_text();
_prescript.save(xml, "prescript"); _prescript.save(xml, "prescript");
_postscript.save(xml, "postscript"); _postscript.save(xml, "postscript");
@ -2340,7 +2340,7 @@ bool TReport::get_report_field(const TString& name, TVariant& var) const
bool TReport::get_record_field(const TString& name, TVariant& var) const bool TReport::get_record_field(const TString& name, TVariant& var) const
{ {
bool found = false; bool found = false;
if (_recordset != NULL) if (recordset() != NULL)
{ {
const char* str = name; const char* str = name;
if (name.starts_with("#RECORD.")) if (name.starts_with("#RECORD."))
@ -2353,7 +2353,7 @@ bool TReport::get_record_field(const TString& name, TVariant& var) const
// Se non lo trovo, allora lo cerco nel recordset principale // Se non lo trovo, allora lo cerco nel recordset principale
if (!found) if (!found)
{ {
var = _recordset->get(str); var = recordset()->get(str);
if (!var.is_null()) if (!var.is_null())
found = true; found = true;
} }
@ -2660,14 +2660,27 @@ void TReport::do_isam_read_output(const TRectype& file, TToken_string& out)
void TReport::msg_isam_read(TVariant_stack& stack) void TReport::msg_isam_read(TVariant_stack& stack)
{ {
const TString& f_code = stack.pop().as_string(); // prende il codice del file da leggere int fkey = 1; // numero e chiave del file da leggere
TString16 f_code = stack.pop().as_string(); // prende il codice del file da leggere
const int exclam = f_code.find('!');
if (exclam > 0)
{
fkey = atoi(f_code.mid(exclam+1));
f_code.cut(exclam);
}
const int logicnum = table2logic(f_code); const int logicnum = table2logic(f_code);
if (logicnum < LF_USER) if (logicnum < LF_USER)
return; // File sconosciuto return; // File sconosciuto
TRectype keyrec(logicnum); TRectype keyrec(logicnum);
if (logicnum == LF_TAB || logicnum == LF_TABCOM) if (logicnum == LF_TAB || logicnum == LF_TABCOM)
{
if (f_code[0] == '%')
f_code.ltrim(1);
keyrec.put("COD", f_code); keyrec.put("COD", f_code);
}
TToken_string in(stack.pop().as_string(), '!'); TToken_string in(stack.pop().as_string(), '!');
TVariant var; TVariant var;
@ -2686,9 +2699,24 @@ void TReport::msg_isam_read(TVariant_stack& stack)
keyrec.put(fld, var.as_string()); // scrive il risultato dell'espressione nel campo del file keyrec.put(fld, var.as_string()); // scrive il risultato dell'espressione nel campo del file
} }
TToken_string out(stack.pop().as_string(), '!'); // Lista dei campi di output
if (fkey <= 1)
{
const TRectype& rec = cache().get(keyrec); const TRectype& rec = cache().get(keyrec);
TToken_string out(stack.pop().as_string(), '!');
do_isam_read_output(rec, out); // Se rec e' vuoto azzera gli outputs do_isam_read_output(rec, out); // Se rec e' vuoto azzera gli outputs
}
else
{
TLocalisamfile file(logicnum);
TRectype& rec = file.curr();
rec = keyrec;
file.setkey(fkey);
if (file.read() != NOERR)
rec.zero();
do_isam_read_output(rec, out); // Se rec e' vuoto azzera gli outputs
}
} }
void TReport::msg_table_read(TVariant_stack& stack) void TReport::msg_table_read(TVariant_stack& stack)

View File

@ -1,18 +1,14 @@
#ifndef __REPORT_H #ifndef __REPORT_H
#define __REPORT_H #define __REPORT_H
#ifndef __IMAGE_H
#include <image.h>
#endif
#ifndef __ISAMS_H
class TRectype;
#endif
#ifndef __WINDOW_H #ifndef __WINDOW_H
#include <window.h> #include <window.h>
#endif #endif
#ifndef __IMAGE_H
#include <image.h>
#endif
#ifndef __XML_H #ifndef __XML_H
#include <xml.h> #include <xml.h>
#endif #endif
@ -25,6 +21,10 @@ class TRectype;
#include <alex.h> #include <alex.h>
#endif #endif
#ifndef __ISAM_H
class TRectype;
#endif
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TReport_font // TReport_font
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -528,8 +528,8 @@ public:
int print_lpi() const; int print_lpi() const;
virtual bool set_recordset(const TString& sql); virtual bool set_recordset(const TString& sql);
bool set_recordset(TRecordset* sql); virtual bool set_recordset(TRecordset* sql);
TRecordset* recordset() const { return _recordset; } virtual TRecordset* recordset() const { return _recordset; }
bool evaluate_atom(const char* atom, TVariant& var); bool evaluate_atom(const char* atom, TVariant& var);
bool evaluate(const char* expr, TVariant& var, TFieldtypes force_type); bool evaluate(const char* expr, TVariant& var, TFieldtypes force_type);

View File

@ -1087,9 +1087,12 @@ void TBook::draw_image(const TRectangle& rect, const char* name)
void TBook::add_doc(const TString& name) void TBook::add_doc(const TString& name)
{ {
if (name.full())
{
TBook::open_page(); TBook::open_page();
*_out << "<doc url=\"" << name << "\" />"<< endl; *_out << "<doc url=\"" << name << "\" />"<< endl;
TBook::close_page(); TBook::close_page();
}
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -2260,6 +2263,37 @@ void TReport_book::print_subsections(int father)
} }
} }
void TReport_book::add_doc(const TString& name)
{
if (name.ends_with(".rep", true)) // Tratto a parte i report!
{
TReport* eminem = new TReport;
if (eminem->load(name))
{
TReport* rep = _report; // Salvo variabile globale
if (rep->use_mask())
{
TFilename msk = rep->filename().name();
msk.ext("msk");
if (msk.custom_path())
{
TMask m(msk);
rep->report2mask(m);
eminem->mask2report(m);
}
}
add(*eminem, true);
_report = rep; // Ripristino variabile globale
}
delete eminem;
}
else
TBook::add_doc(name);
}
bool TReport_book::add(TReport& rep, bool progind) bool TReport_book::add(TReport& rep, bool progind)
{ {
if (!init(rep)) if (!init(rep))
@ -2297,7 +2331,7 @@ bool TReport_book::add(TReport& rep, bool progind)
_rep_page = rep.last_printed_page(); // Azzera numero di pagina relativo _rep_page = rep.last_printed_page(); // Azzera numero di pagina relativo
_is_last_page = false; _is_last_page = false;
bool ok = rex->move_to(0); bool ok = rex->move_first();
open_page(); open_page();
for (; ok && !_print_aborted; ok = rex->move_next()) for (; ok && !_print_aborted; ok = rex->move_next())

View File

@ -103,6 +103,7 @@ class TReport_book : public TBook
protected: protected:
virtual bool open_page(); virtual bool open_page();
virtual bool close_page(); virtual bool close_page();
virtual void add_doc(const TString& name);
virtual void define_frame(const TRectangle& r); virtual void define_frame(const TRectangle& r);
virtual bool on_link(const TReport_link& lnk); virtual bool on_link(const TReport_link& lnk);

23
include/righef24.h Executable file
View File

@ -0,0 +1,23 @@
#ifndef __RIGHE_F24
#define __RIGHE_F24
#define F24_PROGR "PROGR"
#define F24_F24 "F24"
#define F24_TRIBUTO "TRIBUTO"
#define F24_TIPOINTEST "TIPOINTEST"
#define F24_INTEST "INTEST"
#define F24_DESCR "DESCR"
#define F24_DATASCAD "DATASCAD"
#define F24_DATAVERS "DATAVERS"
#define F24_ABI "ABI"
#define F24_CAB "CAB"
#define F24_RATEAZIONE "RATEAZIONE"
#define F24_ANNO "ANNO"
#define F24_IMPORTODEB "IMPORTODEB"
#define F24_IMPORTOCRE "IMPORTOCRE"
#define F24_SEDE "SEDE"
#define F24_MATRICOLA "MATRICOLA"
#define F24_PERIODODA "PERIODODA"
#define F24_PERIODOA "PERIODOA"
#endif

View File

@ -136,7 +136,6 @@ bool TTable_application::user_destroy()
return TRUE; return TRUE;
} }
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
// Tabelle Multirel // Tabelle Multirel
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
@ -176,6 +175,60 @@ void TMultirel_application::get_mask_name(TString& tabname) const
tabname << _tabname; tabname << _tabname;
} }
bool TMultirel_application::find(word k)
{
bool ok = TRelation_application::find(k);
if (!ok && k < 2)
{
file().setkey(1);
file().zero();
for (TEditable_field* e = get_mask()->get_key_field(1, true); e; e = get_mask()->get_key_field(1, false))
{
if (e->shown() || e->ghost()) // Ignora campi invisibili non ghost
e->autosave(*get_relation());
}
TRectype rec(file().curr());
ok = file().read(_isequal) == NOERR;
}
return ok;
}
void TMultirel_application::init_insert_mode(TMask& m)
{
for (int i = m.fields() - 1; i >= 0; i--)
{
TMask_field& c = m.fld(i);
if (c.in_group(1) && c.is_edit())
{
TEdit_field& e = (TEdit_field&)c;
e.enable();
if (e.browse() != NULL)
e.enable_check();
_second = e.get();
}
}
}
int TMultirel_application::rewrite(const TMask& m)
{
int err = TRelation_application::write(m);
if (err == NOERR)
{
TRelation & rel = *get_relation();
rel.save_status();
rel.lfile().put("SECOND", _second);
rel.remove();
rel.restore_status();
}
return err;
}
bool TMultirel_application::user_create() bool TMultirel_application::user_create()
{ {

View File

@ -68,7 +68,6 @@ public:
virtual ~TTable_application(); virtual ~TTable_application();
}; };
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
// Tabelle multirel // Tabelle multirel
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
@ -86,6 +85,8 @@ class TMultirel_application : public TRelation_application
TRelation* _rel; TRelation* _rel;
// @cmember:(INTERNAL) Nome della tabella da utilizzare // @cmember:(INTERNAL) Nome della tabella da utilizzare
TString _tabname; TString _tabname;
// @cmember:(INTERNAL) valore iniziale campo collegato
TString _second;
// @access Protected Member // @access Protected Member
protected: protected:
@ -98,19 +99,25 @@ protected:
virtual bool changing_mask(int mode); virtual bool changing_mask(int mode);
// @cmember Ritorna la relazione da modificare // @cmember Ritorna la relazione da modificare
virtual TRelation* get_relation() const; virtual TRelation* get_relation() const;
// @cmember Inizializza la maschera per il modo inserimento
virtual void init_insert_mode(TMask& m);
// @cmember Inizializza la maschera per il modo modifica
virtual void init_modify_mode(TMask& m) { init_insert_mode(m);}
// @cmember Inizializzazione dei dati dell'utente // @cmember Inizializzazione dei dati dell'utente
virtual bool user_create() ; virtual bool user_create() ;
// @cmember Distruzione dei dati dell'utente // @cmember Distruzione dei dati dell'utente
virtual bool user_destroy() ; virtual bool user_destroy() ;
// @cmember Chiama il programma di stampa // @cmember Chiama il programma di stampa
virtual void print(); virtual void print();
// @cmember Riscrive sulla relazione i valori dalla maschera <p m>
virtual int rewrite(const TMask& m);
// @access Public Member // @access Public Member
public: public:
// @cmember Ritorna il nome della tabella // @cmember Ritorna il nome della tabella
const TString& get_tabname() const const TString& get_tabname() const
{ return _tabname; } { return _tabname; }
virtual bool find(word key = 0);
// @cmember Costruttore // @cmember Costruttore
TMultirel_application(); TMultirel_application();

View File

@ -120,7 +120,7 @@ bool TVariant::as_bool() const
{ {
bool ok = false; bool ok = false;
if (_type == _alfafld) if (_type == _alfafld)
ok = strchr("1XY", as_string()[0]) != NULL; ok = strchr("1VXY", as_string()[0]) != NULL;
else else
ok = as_int() != 0; ok = as_int() != 0;
return ok; return ok;
@ -179,11 +179,16 @@ void TVariant::convert_to(TFieldtypes ft)
{ {
switch (ft) switch (ft)
{ {
case _alfafld: set(as_string()); break; case _nullfld : set_null(); break;
case _datefld: set(as_date()); break; case _datefld : set(as_date()); break;
case _longfld: set(as_int()); break; case _intfld :
case _realfld: set(as_real()); break; case _intzerofld :
default : set_null(); break; case _longzerofld:
case _wordfld :
case _longfld : set(as_int()); break;
case _boolfld : set(as_bool()); break;
case _realfld : set(as_real()); break;
default : set(as_string()); break;
} }
} }
} }
@ -210,6 +215,11 @@ bool TVariant::is_kind_of(word cid) const
return cid == CLASS_VARIANT || TSortable::is_kind_of(cid); return cid == CLASS_VARIANT || TSortable::is_kind_of(cid);
} }
void TVariant::print_on(ostream& out) const
{
out << as_string();
}
int TVariant::compare(const TSortable& s) const int TVariant::compare(const TSortable& s) const
{ {
CHECK(s.is_kind_of(CLASS_VARIANT), "Illegal Variant comparison"); CHECK(s.is_kind_of(CLASS_VARIANT), "Illegal Variant comparison");

View File

@ -14,7 +14,7 @@ void TVariable_mask::set_handler(short fld_id, CONTROL_HANDLER handler)
TMask::set_handler( fld_id, handler ); TMask::set_handler( fld_id, handler );
} }
void TVariable_mask::set(short fld_id, const char* str, bool hit ) void TVariable_mask::set(short fld_id, const char* str, byte hit)
{ {
if(present( fld_id )) if(present( fld_id ))
TMask::set( fld_id, str, hit ); TMask::set( fld_id, str, hit );

View File

@ -26,7 +26,7 @@ public:
// @cmember Esegue il check e i messaggi sul campo <p fld_id> della maschera // @cmember Esegue il check e i messaggi sul campo <p fld_id> della maschera
virtual void check_field( short fld_id ); virtual void check_field( short fld_id );
// @cmember Setta il campo con una stringa // @cmember Setta il campo con una stringa
virtual void set(short fld_id, const char* str, bool hit=FALSE); virtual void set(short fld_id, const char* str, byte hit=0x0);
// @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di stringa // @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di stringa
virtual const TString& get(short fld_id) const; virtual const TString& get(short fld_id) const;
// @cmember Definisce l'handler del campo <p fld_id> // @cmember Definisce l'handler del campo <p fld_id>

313
include/virtkeyb.cpp Executable file
View File

@ -0,0 +1,313 @@
#include <xi.h>
#include <controls.h>
#include <image.h>
#include <virtkeyb.h>
#include <utility.h>
#define DLG_BACKSPACE 400
#define DLG_CAPS 401
#define DLG_LSHIFT 402
#define DLG_RSHIFT 403
#define DLG_LARR 404
#define DLG_RARR 405
#define DLG_F2 406
#define DLG_BASE 500
bool TVirtual_keyboard::handler(TMask_field& f, KEY key)
{
if (key == K_SPACE)
{
const short id = f.dlg();
TVirtual_keyboard & m = (TVirtual_keyboard &) f.mask();
static bool vk_shift = false;
static bool vk_caps = false;
int & pos = m.pos();
TMask_field & target = m.field(101);
target.set_focus();
switch (id)
{
case DLG_BACKSPACE :
if (pos > 0)
{
TString val(m.get(101));
if (pos == val.len())
val.rtrim(1);
else
{
const TString v = val.mid(pos);
val.cut(pos - 1);
val << v;
}
pos--;
target.set(val);
}
break;
case DLG_F2 :
pos = 0;
target.reset();
break;
case DLG_CAPS :
vk_caps = !vk_caps;
break;
case DLG_RSHIFT :
case DLG_LSHIFT :
vk_shift = true;
break;
case DLG_LARR :
if (pos > 0)
pos--;
break;
case DLG_RARR:
if (pos < target.get().len())
pos++;
break;
default :
if (id >= DLG_BASE + ' ' && pos < target.size())
{
char k = id - DLG_BASE;
if (vk_caps || vk_shift)
k = toupper(k);
vk_shift = false;
TString val(target.get());
val.insert(format("%c", k), pos++);
target.set(val);
}
break;
}
target.set_pos(pos);
}
return true;
}
void TVirtual_keyboard::create_keyboard_row(int y, const char * keyboard_row)
{
const TString80 row(keyboard_row);
const int len = row.len();
RCT rw;
short id;
int x;
TString16 prompt;
xvt_vobj_get_client_rect(win(), &rw);
const int width = xvt_rect_get_width(&rw);
x = 0;
for (int i = 0; i < len; i++)
{
unsigned char k = row[i];
switch (k)
{
case '\b' :
id = DLG_BACKSPACE;
prompt = "<<";
break;
case '\n' :
id = DLG_OK;
prompt = "Invio";
break;
case '\01' :
id = DLG_CAPS;
prompt = "Mai";
break;
case '\02' :
id = DLG_RSHIFT;
prompt = "Shift";
break;
case '\03' :
id = DLG_LSHIFT;
prompt = "Shift";
break;
case '\04' :
id = DLG_LARR;
prompt = "<-";
break;
case '\05' :
id = DLG_RARR;
prompt = "->";
break;
case '\06' :
id = DLG_F2;
prompt = "Azzera";
break;
case '\27' :
id = DLG_CANCEL;
prompt = "Esc";
break;
default :
if (k >= ' ')
{
id = DLG_BASE + k;
prompt = " "; prompt[0] = k;
}
break;
}
const int w = prompt.len() > 2 ? 2 : 1;
prompt.insert("@g");
TButton_field & b = add_button(id, 0, "", x, y, w, 2, "");
TFilename bmp(prompt);
if (TImage::build_filename(bmp))
b.set_bmp(bmp);
else
b.set_prompt(prompt);
set_handler(id, handler);
RCT r;
r.left = x * (width / buttons_per_row() - 4);
r.right = r.left + w * width / buttons_per_row() ;
r.top = (ROWY - 2) * y;
r.bottom = r.top + ROWY * 2;
b.set_rect(r);
x += w;
}
}
KEY TVirtual_keyboard::run()
{
if (id2pos(500 + '0') < 0)
init();
set(101, fld().get());
_pos = fld().get().len();
field(101).set_pos(_pos);
KEY k = TMask::run();
if (k == K_ENTER)
{
TMask & mask = fld().mask();
fld().set(get(101));
fld().set_focus();
mask.send_key(K_TAB, 0);
mask.send_key(K_F12, 0);
}
else
_fld.set_focus();
return k;
}
void TVirtual_keyboard::init()
{
TString flags;
if (fld().password())
flags << '*';
if (fld().roman())
flags << 'M';
if (fld().right_justified())
flags << 'R';
if (fld().uppercase())
flags << 'U';
byte trim = fld().trim();
if (trim == 0)
flags << '_';
else
if (trim == 1)
flags << '@';
else
if (trim == 2)
flags << '#';
TEdit_field & e = add_string(101, 0, "", 1, 0, fld().size(), flags);
e.set_read_only(true);
e.allow_pipe(fld().pipe_allowed());
create_keyboard_row(1, "1234567890'ì\b\27");
create_keyboard_row(3, "qwertyuiopè+\n\06");
create_keyboard_row(5, "\01asdfghjklòàù\04\05");
create_keyboard_row(7,"\02<zxcvbnm,.- \03");
}
TVirtual_keyboard::TVirtual_keyboard(TMask_field & fld, int cols, int rows)
: TMask(fld.prompt(), 1, cols, rows), _fld(fld)
{
int size = fld.size();
RCT f, m, k;
fld.get_rect(f);
xvt_vobj_get_client_rect(fld.parent(), &m);
xvt_vobj_get_outer_rect(win(), &k);
int height = xvt_rect_get_height(&k);
int width = xvt_rect_get_width(&k);
int ypos = f.bottom + 3;
int xpos = f.left ;
if (ypos + height > m.bottom)
ypos = f.top - 10 - height - xvt_vobj_get_attr(win(), ATTR_TITLE_HEIGHT); // attuaòmente wxWidget ignora i titoli
if (xpos + width > m.right)
xpos = f.right - width;
if (xpos < 0)
xpos = 20;
k.top = ypos;
k.bottom = ypos + height;
k.left = xpos;
k.right = xpos + width;
xvt_vobj_move(win(), &k);
}
void TVirtual_numpad::init()
{
TString flags;
if (fld().password())
flags << '*';
if (fld().roman())
flags << 'M';
if (fld().right_justified())
flags << 'R';
if (fld().uppercase())
flags << 'U';
byte trim = fld().trim();
if (trim == 0)
flags << '_';
else
if (trim == 1)
flags << '@';
else
if (trim == 2)
flags << '#';
if (_currency )
add_currency(101, 0, "", 1, 0, fld().size(), flags);
else
add_number(101, 0, "", 1, 0, fld().size(), flags, ((TReal_field& )fld()).decimals());
field(101).set_read_only(true);
field(101).allow_pipe(fld().pipe_allowed());
create_keyboard_row(1, "789\b");
create_keyboard_row(3, "456-\06");
create_keyboard_row(5, "123\04\05");
create_keyboard_row(7, "0,\n\27");
}
TVirtual_numpad::TVirtual_numpad(TMask_field & fld, bool currency, int cols, int rows)
: TVirtual_keyboard(fld, cols, rows), _currency(currency)
{
}

62
include/virtkeyb.h Executable file
View File

@ -0,0 +1,62 @@
#ifndef __VIRTKEYB_H
#define __VIRTKEYB_H
#ifndef __WINDOW_H
#include <window.h>
#endif
#ifndef __MASK_H
#include <mask.h>
#endif
// @doc EXTERNAL
// @doc EXTERNAL
// @class TVirtual_keyboard | Classe per la gestione della tastiera virtuale
//
// @base public | TMask
class TVirtual_keyboard : public TMask
{
TMask_field & _fld; // campo legato alla tastiera
int _pos;
// @author:(INTERNAL) Guido
// @access Protected Member
protected:
void create_keyboard_row(int y, const char * keyboard_row);
virtual void init();
virtual int buttons_per_row() const { return 16;}
int & pos() { return _pos;}
TMask_field & fld() {return _fld;}
static bool handler(TMask_field& f, KEY key);
// @access Public Member
public:
// @cmember Run della testatiera
virtual KEY run();
// @cmember Costruttore
TVirtual_keyboard(TMask_field & fld, int cols = 90, int rows = 8);
// @cmember Distruttore
virtual ~TVirtual_keyboard() {}
};
class TVirtual_numpad : public TVirtual_keyboard
{
// @author:(INTERNAL) Guido
bool _currency;
// @access Protected Member
protected:
virtual void init();
virtual int buttons_per_row() const { return 6;}
// @access Public Member
public:
// @cmember Costruttore
TVirtual_numpad(TMask_field & fld, bool currency = false, int cols = 35, int rows = 8);
// @cmember Distruttore
virtual ~TVirtual_numpad() {}
};
#endif // __VIRTKEYB_H

View File

@ -232,7 +232,7 @@ void TWindow_manager::destroy()
bool TWindow_manager::can_close() const bool TWindow_manager::can_close() const
{ {
bool ok = TRUE; bool ok = true;
if (_current >= 0) if (_current >= 0)
ok = cur_win()->can_be_closed(); ok = cur_win()->can_be_closed();
return ok; return ok;

View File

@ -1,6 +1,12 @@
PF0001 PF0001
Stampa etichette Fiorito Stampa etichette Fiorito
PD0666
Esportazione clifo e partite a SAP per MEDICASA
PD0777
Importazione stipendi in prima nota per OMASA
PD1579 PD1579
Importazione clienti CoFiDi Importazione clienti CoFiDi

View File

@ -71,8 +71,8 @@
<prescript description="H4 PRESCRIPT">MESSAGE RESET,F4.105</prescript> <prescript description="H4 PRESCRIPT">MESSAGE RESET,F4.105</prescript>
<field x="7" type="Stringa" width="5" id="101" pattern="1"> <field x="7" type="Stringa" width="5" id="101" pattern="1">
<source>PROVINCIA</source> <source>PROVINCIA</source>
<postscript description="H4.101 POSTSCRIPT">#THIS @ <prescript description="H4.101 PRESCRIPT">#THIS @
"F4.101" !</postscript> "F4.101" !</prescript>
</field> </field>
</section> </section>
<section type="Body" /> <section type="Body" />

44
ps/pd0350_progart.msk Executable file
View File

@ -0,0 +1,44 @@
PA "Stampa progressivo articoli" -1 -1 64 10
NU 251 5
BE
PR 1 1 "Ditta "
FL "FRD"
US 9 KE 1
CH REQUIRED
IN CODDITTA 251
DI "Codice" CODDITTA
DI "Ragione sociale @50" RAGSOC
OU 251 CODDITTA
OU 252 RAGSOC
EN
ST 252 50
BE
PR 15 1 ""
FL "D"
EN
DA 256
BE
PR 1 3 "Dalla data "
FI DADATA
GR 1
CH RE
EN
DA 257
BE
PR 40 3 "Alla data "
FI ADATA
GR 2
CH RE
FL "A"
EN
BU 24 10 2
BE
PR -12 -1 "~Stampa"
ME EXIT,13
EN
BU 9 10 2
BE
PR -22 -1 ""
EN
EN
ENDMASK

83
ps/pd0350_progart.rep Executable file
View File

@ -0,0 +1,83 @@
<report name="pd0350_progart" lpi="6">
<description>Progressivo articoli</description>
<font face="Courier New" size="10" />
<section type="Head">
<font face="Courier New" bold="1" size="10" />
<field x="1" type="Stringa" width="50" pattern="1">
<font italic="1" face="Courier New" bold="1" size="9" />
<source>#SYSTEM.RAGSOC</source>
</field>
<field x="80" type="Data" width="10" pattern="1">
<source>#SYSTEM.DATE</source>
</field>
<field x="165" type="Numero" align="right" width="3" pattern="1">
<source>#REPORT.PAGE</source>
</field>
<field x="1" y="1.5" type="Testo" width="32.5" pattern="1" text="Periodo Osservazione: Dalla data" />
<field x="34" y="1.5" type="Data" width="10" pattern="1">
<source>#DADATA</source>
</field>
<field x="50" y="1.5" type="Testo" width="9.5" pattern="1" text="Alla data" />
<field x="60" y="1.5" type="Data" width="10" pattern="1">
<source>#ADATA</source>
</field>
<field border="1" x="1" y="3" type="Linea" width="93" height="0" pattern="1" />
<field x="1" y="3.25" type="Testo" width="15" pattern="1" text="Cod. Articolo" />
<field x="22" y="3.25" type="Testo" width="15" pattern="1" text="Descrizione" />
<field x="75" y="3.25" type="Testo" width="8" pattern="1" text="Qta acq." />
<field x="86" y="3.25" type="Testo" width="8" pattern="1" text="Qta ven." />
<field border="1" x="1" y="4.75" type="Linea" width="93" height="0" pattern="1" />
</section>
<section type="Head" level="1">
<field y="0.75" type="Testo" align="center" width="94" height="2" pattern="1" text="PROGRESSIVO ARTICOLI">
<font face="Courier New" bold="1" size="16" />
</field>
</section>
<section type="Head" level="2">
<groupby>CODART</groupby>
<prescript description="H2 PRESCRIPT">MESSAGE RESET,F2.104
MESSAGE RESET,F2.105</prescript>
<field x="1" type="Stringa" hidden="1" width="20" id="101" pattern="1">
<source>CODART</source>
<postscript description="H2.101 POSTSCRIPT">#THIS @
"F2.101" !</postscript>
</field>
<field x="22" type="Stringa" hidden="1" width="50" id="102" pattern="1">
<source>ANAMAG.DESCR</source>
<postscript description="H2.102 POSTSCRIPT">#THIS @
"F2.102" !</postscript>
</field>
</section>
<section type="Body" />
<section type="Body" level="1">
<field x="1" type="Numero" hidden="1" align="right" width="10" id="103" pattern="1">
<source>QUANT</source>
<postscript description="B1.103 POSTSCRIPT">#THIS @
"MOVMAG.CODCAUS" @
"02" = IF
"F2.104"
ELSE
"F2.105"
THEN
+!</postscript>
</field>
</section>
<section type="Foot">
<field x="86.5" type="Stringa" width="8.5" pattern="1" text="Pag.">
<source>#PAGE</source>
</field>
</section>
<section type="Foot" level="1" />
<section type="Foot" level="2">
<field x="1" type="Stringa" width="20" id="101" pattern="1" />
<field x="22" type="Stringa" width="50" id="102" pattern="1" />
<field x="73" type="Numero" align="right" width="10" id="104" pattern="1" />
<field x="84" type="Numero" align="right" width="10" id="105" pattern="1" />
</section>
<sql>USE RMOVMAG KEY 2
SELECT
(NUM(ANSI(110.DATAREG)&#3E;=ANSI(#DADATA)))&#26;&#26;(NUM(ANSI(110.DATAREG)&#3C;=ANSI(#ADATA)))&#26;&#26;(110.CODCAUS&#3C;="02")
JOIN MOVMAG INTO NUMREG=NUMREG
JOIN ANAMAG INTO CODART=CODART</sql>
</report>

21
ps/pd0666.cpp Executable file
View File

@ -0,0 +1,21 @@
#include <xvt.h>
#include "pd0666.h"
int main(int argc,char** argv)
{
const int s = (argc > 1) ? argv[1][1] - '0' : 0;
switch (s)
{
case 0 :
default: pd0666100(argc,argv); // Esportazione clifo e partite a SAP di Medicasa
break;
}
exit(0);
return 0;
}

3
ps/pd0666.h Executable file
View File

@ -0,0 +1,3 @@
int pd0666100(int argc, char* argv[]);

319
ps/pd0666100.cpp Executable file
View File

@ -0,0 +1,319 @@
#include "pd0666.h"
#include "pd0666100a.h"
#include <applicat.h>
#include <automask.h>
#include <progind.h>
#include <recarray.h>
#include <textset.h>
#include "../cg/cglib01.h"
#include <clifo.h>
#include <comuni.h>
///////////////////////////////////////////////////////////
// TEsporta_SAP_mask
///////////////////////////////////////////////////////////
class TEsporta_SAP_mask : public TAutomask
{
public:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
TEsporta_SAP_mask();
};
bool TEsporta_SAP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
/* switch (o.dlg())
{
default:
break;
}*/
return true;
}
TEsporta_SAP_mask::TEsporta_SAP_mask() : TAutomask("pd0666100a")
{
//file dei clienti..
TFilename file;
file.tempdir();
file.add("clienti.xls");
set(F_CLIFILE, file);
//..dei fornitori..
file.tempdir();
file.add("fornitori.xls");
set(F_FORNFILE, file);
//..e delle partite
file.tempdir();
file.add("partite.xls");
set(F_PARTFILE, file);
}
class TEsporta_SAP_clienti_recordset : public TAS400_recordset
{
public:
TEsporta_SAP_clienti_recordset();
};
TEsporta_SAP_clienti_recordset::TEsporta_SAP_clienti_recordset()
: TAS400_recordset("AS400(512)")
{
create_field("KTOKD", -1, 4, _alfafld); //zicc o zicu
create_field("NAME1", -1, 30, _alfafld); //ragsoc1
create_field("NAME2", -1, 20, _alfafld); //ragsoc2
create_field("SORTL", -1, 1, _alfafld); //campo non richiesto?
create_field("STRAS", -1, 45, _alfafld); //via+numero
create_field("ORT01", -1, 35, _alfafld); //localita'
create_field("PSTLZ", -1, 5, _alfafld); //cap
create_field("LAND1", -1, 3, _alfafld); //codice paese
create_field("REGIO", -1, 2, _alfafld); //occhio al casino in fase di caricamento!
create_field("SPRAS", -1, 1, _alfafld); //codlin
create_field("TELX1", -1, 40, _alfafld); //somma prefisso+telefono telex
create_field("TELF1", -1, 40, _alfafld); //somma prefisso+telefono ptel1+tel1
create_field("TELFX", -1, 40, _alfafld); //somma prefisso+telefono fax
create_field("TELF2", -1, 40, _alfafld); //somma prefisso+telefono ptel2+tel2
create_field("LZONE", -1, 10, _alfafld); //non l'abbiamo
create_field("VBUND", -1, 1, _alfafld); //non l'abbiamo
create_field("STCD1", -1, 16, _alfafld); //non l'abbiamo;cofi
create_field("STCD2", -1, 16, _alfafld); //non l'abbiamo
create_field("BRSCH", -1, 2, _alfafld); //non l'abbiamo
create_field("STCEG", -1, 14, _alfafld); //statopaiv+p.iva
create_field("STKZN", -1, 1, _alfafld); //tipopers
create_field("BUSAB", -1, 2, _alfafld); //non l'abbiamo
create_field("XAUSZ", -1, 1, _alfafld); //non l'abbiamo
create_field("AKONT", -1, 8, _alfafld); //conto da tabella!
create_field("FDGRV", -1, 5, _alfafld); //non l'abbiamo
create_field("ZTERM", -1, 4, _alfafld); //codpag?
create_field("ZAMIM", -1, 1, _alfafld); //non l'abbiamo
create_field("ZWELS", -1, 4, _alfafld); //codpag ancora?
create_field("VZSKZ", -1, 2, _alfafld); //non l'abbiamo
create_field("EIKTO", -1, 6, _alfafld); //nostro codcf
create_field("XZVER", -1, 1, _alfafld); //non l'abbiamo
create_field("TOGRU", -1, 4, _alfafld); //non l'abbiamo
create_field("ALTKN", -1, 7, _alfafld); //non l'abbiamo
create_field("MAHNA", -1, 4, _alfafld); //non l'abbiamo
}
///////////////////////////////////////////////////////////
// TEsporta_SAP
///////////////////////////////////////////////////////////
class TEsporta_SAP_app : public TSkeleton_application
{
TAssoc_array _codpag;
protected:
virtual bool check_autorization() const {return false;}
virtual const char * extra_modules() const {return "cg";}
virtual void main_loop();
bool is_cofi(const TString& cofi) const;
public:
void esporta_clienti(const TString& path) const;
void esporta_fornitori(const TString& path) const;
void esporta_partite(const TString& path) const;
};
bool TEsporta_SAP_app::is_cofi(const TString& cofi) const
{
if (cofi.len() != 16)
return false;
const char* const fmt = "AAAAAANNANNANNNA";
int i = 0;
for (i = 15; i >= 0; i--)
{
if (fmt[i] == 'A')
{
if (cofi[i] < 'A' || cofi[i] > 'Z')
break;
}
else
{
if (cofi[i] < '0' || cofi[i] > '9')
break;
}
}
return i < 0;
}
void TEsporta_SAP_app::esporta_clienti(const TString& path) const
{
TString query;
query << "USE CLIFO";
query << "\nFROM TIPOCF='C'";
query << "\nTO TIPOCF='C'";
TISAM_recordset clienti_campo(query);
TEsporta_SAP_clienti_recordset clienti_sap;
const int cazzoni = clienti_campo.items();
TProgind pi(cazzoni, "Trasferimento clienti...", true, true);
TString workstring;
for (bool ok = clienti_campo.move_first(); ok; ok = clienti_campo.move_next())
{
if (!pi.addstatus(1))
break;
//creazione di un nuovo record di tipo clienti..
clienti_sap.new_rec();
//..e successivo riempimento
const long conto = clienti_campo.get(CLI_CONTO).as_int(); //ktokd
if (conto == 8 || conto == 9)
clienti_sap.set("KTOKD", TVariant("ZICC"));
else
clienti_sap.set("KTOKD", TVariant("ZICU"));
workstring = clienti_campo.get(CLI_RAGSOC).as_string(); //name1 e name2
clienti_sap.set("NAME1", TVariant(workstring.left(30)));
clienti_sap.set("NAME2", TVariant(workstring.mid(30)));
workstring = clienti_campo.get(CLI_INDCF).as_string(); //stras
workstring << " " << clienti_campo.get(CLI_CIVCF).as_string();
clienti_sap.set("STRAS", TVariant(workstring));
//pocci su comune localita' provincia
if (clienti_campo.get(CLI_COMCF).is_empty())
{
workstring = cap2comune(clienti_campo.get(CLI_CAPCF).as_string(),
clienti_campo.get(CLI_LOCCF).as_string());
workstring.insert(" |");
}
else
{
workstring = clienti_campo.get(CLI_STATOCF).as_string();
workstring << "|" << clienti_campo.get(CLI_COMCF).as_string();
}
const TRectype& com_rec = cache().get(LF_COMUNI, workstring);
const TString& dencom = com_rec.get(COM_DENCOM);
workstring = clienti_campo.get(CLI_LOCCF).as_string(); //ort01
if (dencom.full())
{
if (workstring.blank())
workstring = dencom;
else
{
workstring.upper();
if (xvt_str_fuzzy_compare(workstring, dencom) < 0.75)
workstring << ", " << dencom;
}
}
clienti_sap.set("ORT01", TVariant(workstring));
workstring = clienti_campo.get(CLI_CAPCF).as_string(); //pstlz
clienti_sap.set("PSTLZ", TVariant(workstring));
workstring = clienti_campo.get(CLI_STATOCF).as_string(); //land1
clienti_sap.set("LAND1", TVariant(workstring));
workstring = com_rec.get(COM_PROVCOM); //regio
clienti_sap.set("REGIO", TVariant(workstring));
workstring = clienti_campo.get(CLI_CODLIN).as_string(); //spras
clienti_sap.set("SPRAS", TVariant(workstring));
workstring = clienti_campo.get(CLI_PTELEX).as_string(); //telx1
workstring << clienti_campo.get(CLI_TELEX).as_string();
clienti_sap.set("TELX1", TVariant(workstring));
workstring = clienti_campo.get(CLI_PTEL).as_string(); //telf1
workstring << clienti_campo.get(CLI_TEL).as_string();
clienti_sap.set("TELF1", TVariant(workstring));
workstring = clienti_campo.get(CLI_PFAX).as_string(); //telfx
workstring << clienti_campo.get(CLI_FAX).as_string();
clienti_sap.set("TELFX", TVariant(workstring));
workstring = clienti_campo.get(CLI_PTEL2).as_string(); //telf2
workstring << clienti_campo.get(CLI_TEL2).as_string();
clienti_sap.set("TELF2", TVariant(workstring));
workstring = clienti_campo.get(CLI_COFI).as_string(); //stcd1
clienti_sap.set("STCD1", TVariant(workstring));
if (is_cofi(workstring)) //stkzn
clienti_sap.set("STKZN", TVariant("X"));
workstring = clienti_campo.get(CLI_STATOPAIV).as_string(); //stceg
workstring << clienti_campo.get(CLI_PAIV).as_string();
clienti_sap.set("STCEG", TVariant(workstring));
if (conto == 8 || conto == 9) //akont
clienti_sap.set("AKONT", TVariant("8/9"));
else
clienti_sap.set("AKONT", TVariant("7"));
workstring = clienti_campo.get(CLI_CODPAG).as_string(); //zterm
TString* codpag = (TString*)_codpag.objptr(workstring);
if (codpag == NULL)
workstring = "R000";
else
workstring = *codpag;
clienti_sap.set("ZTERM", TVariant(workstring));
clienti_sap.set("ZWELS", TVariant("D")); //zwels
workstring = clienti_campo.get(CLI_CODCF).as_string(); //eikto
clienti_sap.set("EIKTO", TVariant(workstring));
}
//scrivitore in formato xls
clienti_sap.save_as(path, fmt_silk);
#ifdef DBG
xvt_sys_goto_url(path, "open");
#endif
}
void TEsporta_SAP_app::esporta_fornitori(const TString& path) const
{
}
void TEsporta_SAP_app::esporta_partite(const TString& path) const
{
}
void TEsporta_SAP_app::main_loop()
{
//crea tabella trascodifica
_codpag.add("BB", new TString("R000"));
_codpag.add("B09", new TString("R002"));
_codpag.add("B01", new TString("R003"));
_codpag.add("BB09", new TString("R004"));
_codpag.add("B05", new TString("R004"));
_codpag.add("B07", new TString("R005"));
_codpag.add("B03", new TString("R007"));
_codpag.add("B04", new TString("R007"));
_codpag.add("B11", new TString("R007"));
_codpag.add("BB30", new TString("R007"));
_codpag.add("B08", new TString("R009"));
_codpag.add("BB60", new TString("R009"));
_codpag.add("B10", new TString("R010"));
_codpag.add("BB90", new TString("R010"));
TEsporta_SAP_mask m;
while (m.run() == K_ENTER)
{
if (m.get_bool(F_CLIENTI))
esporta_clienti(m.get(F_CLIFILE));
if (m.get_bool(F_FORNITORI))
esporta_fornitori(m.get(F_FORNFILE));
if (m.get_bool(F_PARTITE))
esporta_partite(m.get(F_PARTFILE));
}
}
int pd0666100(int argc, char* argv[])
{
TEsporta_SAP_app app;
app.run(argc, argv, TR("Esportazione a SAP"));
return 0;
}

6
ps/pd0666100a.h Executable file
View File

@ -0,0 +1,6 @@
#define F_CLIENTI 101
#define F_CLIFILE 102
#define F_FORNITORI 103
#define F_FORNFILE 104
#define F_PARTITE 105
#define F_PARTFILE 106

68
ps/pd0666100a.uml Executable file
View File

@ -0,0 +1,68 @@
#include "pd0666100a.h"
PAGE "Trasferimento a SAP per Medicasa" -1 -1 72 12
GROUPBOX DLG_NULL 70 4
BEGIN
PROMPT 1 1 "@bEsportazione clenti / fornitori"
END
BOOLEAN F_CLIENTI
BEGIN
PROMPT 2 2 "Clienti"
MESSAGE FALSE DISABLE,F_CLIFILE
MESSAGE TRUE ENABLE,F_CLIFILE
END
STRING F_CLIFILE 128 50
BEGIN
PROMPT 14 2 "File "
CHECKTYPE REQUIRED
END
BOOLEAN F_FORNITORI
BEGIN
PROMPT 2 3 "Fornitori"
MESSAGE FALSE DISABLE,F_FORNFILE
MESSAGE TRUE ENABLE,F_FORNFILE
END
STRING F_FORNFILE 128 50
BEGIN
PROMPT 14 3 "File "
CHECKTYPE REQUIRED
END
GROUPBOX DLG_NULL 70 4
BEGIN
PROMPT 1 5 "@bEsportazione partite"
END
BOOLEAN F_PARTITE
BEGIN
PROMPT 2 6 "Partite"
MESSAGE FALSE DISABLE,F_PARTFILE
MESSAGE TRUE ENABLE,F_PARTFILE
END
STRING F_PARTFILE 128 50
BEGIN
PROMPT 14 6 "File "
CHECKTYPE REQUIRED
END
BUTTON DLG_ELABORA 10 2
BEGIN
PROMPT -12 -1 ""
PICTURE BMP_ELABORA
MESSAGE EXIT,K_ENTER
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

4
ps/pd0666conf.ini Executable file
View File

@ -0,0 +1,4 @@
[MAIN]
PATH = C:\temp\
FILE =
LASTDATA =

21
ps/pd0777.cpp Executable file
View File

@ -0,0 +1,21 @@
#include <xvt.h>
#include "pd0777.h"
int main(int argc,char** argv)
{
const int s = (argc > 1) ? argv[1][1] - '0' : 0;
switch (s)
{
case 0 :
default: pd0777100(argc,argv); // Importa stipendi in prima nota (OMASA)
break;
}
exit(0);
return 0;
}

3
ps/pd0777.h Executable file
View File

@ -0,0 +1,3 @@
int pd0777100(int argc, char* argv[]);

448
ps/pd0777100.cpp Executable file
View File

@ -0,0 +1,448 @@
// OMASA
#include <applicat.h>
#include <automask.h>
#include <config.h>
#include <execp.h>
#include <filetext.h>
#include <progind.h>
#include <recarray.h>
#include <utility.h>
#include "pd0777.h"
#include "pd0777100a.h"
#include "pd0777100b.h"
#include "pd0777100C.h"
#include "../cg/cglib01.h"
#include <causali.h>
#include <mov.h>
#include <pconti.h>
#include <rmov.h>
#define MAX_CG_ROWS 98
// tabella per la conversione dei numeri negativi (schede perforate????)
static unsigned char _tabella[10] = {'p','q','r','s','t','u','v','w','x','y'};
//////////////////////////
// TAutomask
//////////////////////////
class TOmasa_mask : public TAutomask
{
protected:
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TOmasa_mask();
virtual ~TOmasa_mask(){};
};
TOmasa_mask::TOmasa_mask() :TAutomask ("pd0777100a")
{
}
bool TOmasa_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{
return true;
}
/////////////////////////
// TFile_text
/////////////////////////
class TOmasa_file: public TFile_text
{
protected:
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
public:
TOmasa_file(const TString& file_name);
virtual ~TOmasa_file() { }
};
TOmasa_file::TOmasa_file(const TString& file_name)
: TFile_text(file_name, "pd0777100a.ini")
{
}
void TOmasa_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str)
{
const TString code(s.get(0));
TString valore = str;
if (code == "_UPPERCASE")
{
valore.upper();
}
else NFCHECK("Macro non definita: %s", (const char *)code);
str = valore;
}
// TSkeleton_application
class TOmasa : public TSkeleton_application
{
TOmasa_mask* _msk;
TOmasa_file* _trasfile;
TConfig* _configfile;
TRelation* _rel;
TCursor* _cur;
TProgind* _prog;
TEsercizi_contabili* _esc;
long _numreg;
virtual bool check_autorization() const {return false;}
virtual const char * extra_modules() const {return "cg";}
public:
virtual bool create();
virtual bool destroy();
virtual void main_loop();
virtual void ini2mask();
virtual void mask2ini();
bool transfer();
void negativo(TString& importo);
int strip_zero(TString& importo);
bool my_isdigit(unsigned char ch);
int look(unsigned char carattere);
TOmasa() {}
};
TOmasa& app() { return (TOmasa&) main_app(); }
bool TOmasa::create()
{
open_files(LF_TABCOM, LF_TAB, LF_SALDI, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA,
LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
TFilename configname = "pd0777conf.ini";
configname.custom_path();
_configfile = new TConfig(configname);
_msk = new TOmasa_mask();
_rel = new TRelation (LF_PCON);
_cur = new TCursor(_rel,"((GRUPPO!=\"\")&&(CONTO!=\"\")&&(SOTTOCONTO==\"\"))",1);
_esc = new TEsercizi_contabili;
return TSkeleton_application::create();
}
bool TOmasa::destroy()
{
delete _esc;
delete _cur;
delete _rel;
delete _msk;
delete _configfile;
return TApplication::destroy();
}
int TOmasa::strip_zero(TString& importo)
{
TString16 app;
int size = importo.len();
for (int i = 0; i < size; i++)
if (importo[i] != '0') break;
if (i > 0)
{
app = importo.mid(importo[i] == '.' ? i - 1 : i);
importo = app;
}
return (i ? i - 1 : i);
}
bool TOmasa::my_isdigit(unsigned char ch)
{
return (ch >= '0' && ch <= '9');
}
int TOmasa::look(unsigned char carattere)
{
for (int i = 0; i < 10; i++)
if (_tabella[i] == carattere)
return i;
return -1;
}
void TOmasa::negativo(TString& importo)
{
strip_zero(importo);
int size = importo.len();
if (!size) return;
unsigned char last = importo[size - 1];
if (!my_isdigit(last))
{
int new_last = look(last);
TString16 dep; dep << new_last;
if (new_last >= 0)
{
importo[size - 1] = dep[0];
importo.insert("-");
}
}
}
void TOmasa::mask2ini()
{
TSheet_field& sheet = (TSheet_field&)_msk->field(F_SHEET_CONTI);
for (int i=0;i<sheet.items();i++)
{
TToken_string& row = sheet.row(i);
TString16 contoomasa = row.get(0);
TString16 conto;
const int gr = atoi(row.get(1));
const int co = atoi(row.get(2));
const long so = atol(row.get(3));
conto.format("%d|%d|%ld", gr, co, so);
_configfile->set(contoomasa, conto, "CONTI");
}
TSheet_field& sheetcms = (TSheet_field&)_msk->field(F_SHEET_CMS);
for (i=0;i<sheetcms.items();i++)
{
TToken_string& row = sheetcms.row(i);
TString16 cmsomasa = row.get(0);
TString80 cms = row.get(1);
_configfile->set(cmsomasa, cms, "COMMESSE");
}
_configfile->set_paragraph("CONTI");
}
void TOmasa::ini2mask()
{
TString_array vl;
_configfile->list_variables(vl,TRUE, "CONTI", TRUE);
TSheet_field& sheet = (TSheet_field&)_msk->field(F_SHEET_CONTI);
sheet.destroy();
int i=0;
FOR_EACH_ARRAY_ROW(vl,r,s)
{
TToken_string& riga = sheet.row(i);
TString16 contoomasa = (*s).get();
TToken_string conto = _configfile->get(contoomasa, "CONTI");
riga.add(contoomasa);
riga.add(conto.get(0));
riga.add(conto.get(1));
riga.add(conto.get(2));
sheet.check_row(i);
i++;
}
_configfile->list_variables(vl,TRUE, "COMMESSE", TRUE);
TSheet_field& sheetcms = (TSheet_field&)_msk->field(F_SHEET_CMS);
sheetcms.destroy();
i=0;
FOR_EACH_ARRAY_ROW(vl,rc,sc)
{
TToken_string& riga = sheetcms.row(i);
TString16 cmsomasa = (*sc).get();
TString80 cms = (*sc).get();
riga.add(cmsomasa);
riga.add(cms);
sheetcms.check_row(i);
i++;
}
}
void TOmasa::main_loop()
{
KEY tasto;
_msk->set(F_PERCORSO, _configfile->get("PERCORSO", "MAIN"));
_msk->set(F_CODCAUS, _configfile->get("CODCAUS", "MOVIMENTO"));
ini2mask();
tasto = _msk->run();
if (tasto == K_ENTER)
{
mask2ini();
_numreg = 0;
if (transfer())
{
_configfile->set("PERCORSO", _msk->get(F_PERCORSO), "MAIN");
_configfile->set("CODCAUS", _msk->get(F_CODCAUS), "MOVIMENTO");
message_box(TR("Importazione stipendi completata"));
}
}
}
bool TOmasa::transfer()
{
TString_array transactions;
TFilename tempdir;
tempdir.tempdir();
TString80 listfiles = tempdir;
listfiles << "\\oo*.ini";
list_files(listfiles, transactions);
FOR_EACH_ARRAY_ROW(transactions, row, name)
remove(*name);
TConfig* movpn=NULL;
_trasfile = new TOmasa_file(_msk->get(F_PERCORSO));
_trasfile->open(_msk->get(F_PERCORSO),'r');
// creazione file temporanei per commessa e conto dare e avere
const long dimension = fsize(_msk->get(F_PERCORSO));
TProgind pi(dimension,"Importazione in corso...");
TRecord_text curr;
while (_trasfile->read(curr) == NOERR)
{
pi.setstatus(_trasfile->read_file()->tellg());
TString impstr = curr.get(F_VALOREVOCE);
impstr.insert(".",11);
negativo(impstr);
const real importo(impstr);
TString16 contodare = curr.get(F_CONTODARE);
TString16 contoavere = curr.get(F_CONTOAVERE);
if ((!real::is_null(impstr)) && (!contodare.blank() || !contoavere.blank()))
{
TString16 codcms = curr.get(F_CENTROCOSTO);
codcms.trim();
TString80 cms = _configfile->get(codcms, "COMMESSE");
if (cms.empty())
{
TMask mskcms("pd0777100c");
mskcms.set(F_CMSOMASA, codcms);
if (mskcms.run() == K_ENTER)
_configfile->set(codcms, mskcms.get(F_CODCMS), "COMMESSE");
else
return TRUE;
}
TFilename name;
name.tempdir();
name.add(format("oo%s", (const char*) codcms));
name.ext(".ini");
movpn = new TConfig(name);
movpn->set_paragraph("MAIN");
movpn->set("CODCMS",codcms);
if (!contodare.blank())
{
movpn->set_paragraph("IMPORTI");
contodare.trim();
impstr = movpn->get(contodare, "IMPORTI");
real importomem(impstr);
importomem+=importo;
movpn->set(contodare, importomem.string());
}
if (!contoavere.blank())
{
movpn->set_paragraph("IMPORTI");
contoavere.trim();
impstr = movpn->get(contoavere, "IMPORTI");
real importomem(impstr);
importomem-=importo;
movpn->set(contoavere, importomem.string());
}
delete movpn;
if (pi.iscancelled())
return TRUE;
}
}
_trasfile->close();
delete _trasfile;
// creazione .ini per la prima nota
const TDate datareg = _msk->get_date(F_DATAREG);
const int annoes = _esc->date2esc(datareg);
const TString8 codcaus = _msk->get(F_CODCAUS);
listfiles = tempdir;
listfiles << "\\oo*.ini";
list_files(listfiles, transactions);
FOR_EACH_ARRAY_ROW(transactions, row_oo, name_oo)
{
TConfig* movpn=NULL;
TConfig file_oo(*name_oo);
TString16 codcms = file_oo.get("CODCMS", "MAIN");
codcms.trim();
TFilename name;
name.tempdir();
name.add(format("ooo%s", (const char*) codcms));
name.ext(".ini");
movpn = new TConfig(name);
movpn->set_paragraph("Transaction");
movpn->set("Action","INSERT");
movpn->set("Mode","AUTO");
movpn->set_paragraph(format("%d",LF_MOV));
movpn->set("ANNOES", annoes);
movpn->set("DATACOMP", datareg);
movpn->set("DATAREG", datareg);
movpn->set("DESCR", cache().get(LF_CAUSALI, codcaus, CAU_DESCR));
movpn->set("CODCAUS", codcaus);
int numrig = 0;
TString_array vl;
file_oo.list_variables(vl,TRUE, "IMPORTI", TRUE);
FOR_EACH_ARRAY_ROW(vl,r,s)
{
TString16 contoomasa = (*s).get();
TString16 importos = (*s).get();
TToken_string conto = _configfile->get(contoomasa, "CONTI");
if (conto.empty())
{
TMask mskconto("pd0777100b");
mskconto.set(F_CONTOOMASA, contoomasa);
if (mskconto.run() == K_ENTER)
{
const int gr = mskconto.get_int(F_GRUPPO);
const int co = mskconto.get_int(F_CONTO);
const long so = mskconto.get_long(F_SOTTOCONTO);
conto.format("%d|%d|%ld", gr, co, so);
_configfile->set(contoomasa, conto, "CONTI");
}
else
return TRUE;
}
numrig++;
movpn->set_paragraph(format("%d,%d",LF_RMOV, numrig));
movpn->set("ANNOES", annoes);
movpn->set("DATAREG", datareg);
movpn->set("NUMRIG", numrig);
real importo(importos);
if (importo > 0)
movpn->set("SEZIONE", "D");
else
movpn->set("SEZIONE", "A");
importos.strip("-");
movpn->set("IMPORTO", importos);
TString16 contoindbil;
contoindbil.format("%s|%s", conto.get(0), conto.get(1));
const char indbil = cache().get(LF_PCON, contoindbil, PCN_INDBIL)[0];
if ((indbil != '1') && (indbil != '2'))
movpn->set("CODCMS", _configfile->get(codcms, "COMMESSE"));
movpn->set("GRUPPO", conto.get(0));
movpn->set("CONTO", conto.get(1));
movpn->set("SOTTOCONTO", conto.get(2));
}
delete movpn;
}
tempdir.tempdir();
TString80 applicat = "cg2.exe -0 -i";
applicat << tempdir;
applicat << "\\ooo*.ini";
TExternal_app primanota(applicat);
primanota.run();
listfiles = tempdir;
listfiles << "\\oo*.ini";
list_files(listfiles, transactions);
FOR_EACH_ARRAY_ROW(transactions, rowf, namef)
remove(*namef);
return TRUE;
}
int pd0777100 (int argc, char* argv[])
{
TOmasa main_app;
main_app.run(argc, argv, TR("Importazione stipendi"));
return TRUE;
}

40
ps/pd0777100a.h Executable file
View File

@ -0,0 +1,40 @@
// campi della maschera principale pd0777100a.uml
#define F_PERCORSO 101
#define F_DATAREG 102
#define F_CODCAUS 103
#define F_DESCR 104
#define F_SHEET_CONTI 105
#define F_SHEET_CMS 106
// campi della maschera di conversione conti
#define F_S_CONTOOMASA 101
#define F_S_GRUPPO 102
#define F_S_CONTO 103
#define F_S_SOTTOCONTO 104
#define F_S_DESCRIZIONE 105
// campi della maschera di conversione commesse
#define F_S_CMSOMASA 101
#define F_S_CODCMS 102
#define F_S_DESCRCMS 103
// campi del tracciato record
#define F_CODAZIENDA 0
#define F_CODDIP 1
#define F_VOCE 2
#define F_TIPOVOCE 3
#define F_QUOTAVOCE 4
#define F_VALOREVOCE 5
#define F_IMPORTO 6
#define F_CONTODARE 7
#define F_CONTOAVERE 8
#define F_CENTROCOSTO 9
#define F_SEDELAVORO 10
#define F_SEDEINPS 11
#define F_QUALIFICA 12
#define F_POSINAIL 13
#define F_VARIABILE 14
#define F_CONTRATTO 15
#define F_FILLER 16

188
ps/pd0777100a.uml Executable file
View File

@ -0,0 +1,188 @@
#include "pd0777100a.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 "Importazione stipendi" 0 -1 0 19
STRING F_PERCORSO 50
BEGIN
PROMPT 2 2 "File da trasferire "
CHECKTYPE REQUIRED
VALIDATE FILENAME_FUNC
FLAGS "A"
HELP "Percorso e nome file da trasferire"
WARNING "E' necessario specificare il nome del file da trasferire"
END
DATE F_DATAREG
BEGIN
PROMPT 2 3 "Data registrazione "
CHECKTYPE REQUIRED
HELP "Data di registrazione dei movimenti contabili"
WARNING "E' necessario specificare la data di registrazione"
END
STRING F_CODCAUS 4
BEGIN
PROMPT 2 4 "Causale "
FLAGS "UZ"
USE LF_CAUSALI
INPUT CODCAUS F_CODCAUS
DISPLAY "Codice" CODCAUS
DISPLAY "Descrizione@60" DESCR
OUTPUT F_CODCAUS CODCAUS
OUTPUT F_DESCR DESCR
CHECKTYPE SEARCH
END
STRING F_DESCR 50
BEGIN
PROMPT 17 4 ""
USE LF_CAUSALI KEY 2
INPUT DESCR F_DESCR
DISPLAY "Descrizione@60" DESCR
DISPLAY "Codice" CODCAUS
COPY OUTPUT F_CODCAUS
CHECKTYPE SEARCH
END
SPREADSHEET F_SHEET_CONTI 70 6
BEGIN
PROMPT 2 6 "Tabella conversione conti"
ITEM "Conto OMASA"
ITEM "Gruppo"
ITEM "Conto"
ITEM "Sottoc."
ITEM "Descrizione"
END
SPREADSHEET F_SHEET_CMS 70 6
BEGIN
PROMPT 2 14 "Tabella conversione commesse"
ITEM "Cms OMASA"
ITEM "Corrispondente"
ITEM "Descrizione"
END
ENDPAGE
ENDMASK
PAGE "Conversione conti" 0 -1 0 10
STRING F_S_CONTOOMASA 14
BEGIN
PROMPT 2 2 "Conto OMASA "
FLAGS "D"
END
NUMBER F_S_GRUPPO 3
BEGIN
PROMPT 2 4 "Conto corrispon."
USE LF_PCON KEY 1 SELECT (CONTO="")
INPUT GRUPPO F_S_GRUPPO
DISPLAY "Gruppo" GRUPPO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_S_GRUPPO GRUPPO
CHECKTYPE NORMAL
END
NUMBER F_S_CONTO 3
BEGIN
PROMPT 24 4 ""
USE LF_PCON KEY 1 SELECT (SOTTOCONTO="")
INPUT GRUPPO F_S_GRUPPO
INPUT CONTO F_S_CONTO
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_S_CONTO CONTO
OUTPUT F_S_GRUPPO GRUPPO
CHECKTYPE NORMAL
END
NUMBER F_S_SOTTOCONTO 6
BEGIN
PROMPT 30 4 ""
USE LF_PCON
INPUT GRUPPO F_S_GRUPPO
INPUT CONTO F_S_CONTO
INPUT SOTTOCONTO F_S_SOTTOCONTO
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_S_SOTTOCONTO SOTTOCONTO
OUTPUT F_S_GRUPPO GRUPPO
OUTPUT F_S_CONTO CONTO
OUTPUT F_S_DESCRIZIONE DESCR
CHECKTYPE NORMAL
END
STRING F_S_DESCRIZIONE 50
BEGIN
PROMPT 39 4 ""
USE LF_PCON KEY 2
INPUT DESCR F_S_DESCRIZIONE
DISPLAY "Descrizione@50" DESCR
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
OUTPUT F_S_SOTTOCONTO SOTTOCONTO
OUTPUT F_S_CONTO CONTO
OUTPUT F_S_GRUPPO GRUPPO
OUTPUT F_S_DESCRIZIONE DESCR
CHECKTYPE NORMAL
END
ENDPAGE
ENDMASK
PAGE "Conversione commesse" 0 -1 0 10
STRING F_S_CMSOMASA 14
BEGIN
PROMPT 2 2 "Commessa OMASA "
FLAGS "D"
END
STRING F_S_CODCMS 20
BEGIN
PROMPT 2 4 "Commessa corrispondente "
FLAGS "UZ"
USE CMS
INPUT CODTAB F_S_CODCMS
DISPLAY "Codice@20" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_S_CODCMS CODTAB
OUTPUT F_S_DESCRCMS S0
CHECKTYPE NORMAL
END
STRING F_S_DESCRCMS 50
BEGIN
PROMPT 39 4 ""
USE CMS KEY 2
INPUT S0 F_S_DESCRCMS
DISPLAY "Descrizione@50" S0
DISPLAY "Codice@20" CODTAB
COPY OUTPUT F_S_CODCMS
CHECKTYPE NORMAL
END
ENDPAGE
ENDMASK

7
ps/pd0777100b.h Executable file
View File

@ -0,0 +1,7 @@
// campi della maschera pd0777100b.uml
#define F_CONTOOMASA 101
#define F_GRUPPO 102
#define F_CONTO 103
#define F_SOTTOCONTO 104
#define F_DESCRIZIONE 105

87
ps/pd0777100b.uml Executable file
View File

@ -0,0 +1,87 @@
#include "pd0777100b.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 "Conversione conti" 0 -1 0 10
STRING F_CONTOOMASA 14
BEGIN
PROMPT 2 2 "Conto OMASA "
FLAGS "D"
END
NUMBER F_GRUPPO 3
BEGIN
PROMPT 2 4 "Conto corrispondente "
USE LF_PCON KEY 1 SELECT (CONTO="")
INPUT GRUPPO F_GRUPPO
DISPLAY "Gruppo" GRUPPO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_GRUPPO GRUPPO
CHECKTYPE NORMAL
END
NUMBER F_CONTO 3
BEGIN
PROMPT 29 4 ""
USE LF_PCON KEY 1 SELECT (SOTTOCONTO="")
INPUT GRUPPO F_GRUPPO
INPUT CONTO F_CONTO
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_CONTO CONTO
OUTPUT F_GRUPPO GRUPPO
CHECKTYPE NORMAL
END
NUMBER F_SOTTOCONTO 6
BEGIN
PROMPT 35 4 ""
USE LF_PCON
INPUT GRUPPO F_GRUPPO
INPUT CONTO F_CONTO
INPUT SOTTOCONTO F_SOTTOCONTO
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_SOTTOCONTO SOTTOCONTO
OUTPUT F_GRUPPO GRUPPO
OUTPUT F_CONTO CONTO
OUTPUT F_DESCRIZIONE DESCR
CHECKTYPE NORMAL
END
STRING F_DESCRIZIONE 50
BEGIN
PROMPT 44 4 ""
USE LF_PCON KEY 2
INPUT DESCR F_DESCRIZIONE
DISPLAY "Descrizione@50" DESCR
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
OUTPUT F_SOTTOCONTO SOTTOCONTO
OUTPUT F_CONTO CONTO
OUTPUT F_GRUPPO GRUPPO
OUTPUT F_DESCRIZIONE DESCR
CHECKTYPE NORMAL
END
ENDPAGE
ENDMASK

5
ps/pd0777100c.h Executable file
View File

@ -0,0 +1,5 @@
// campi della maschera pd0777100c.uml
#define F_CMSOMASA 101
#define F_CODCMS 102
#define F_DESCRCMS 103

52
ps/pd0777100c.uml Executable file
View File

@ -0,0 +1,52 @@
#include "pd0777100c.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 "Conversione commesse" 0 -1 0 10
STRING F_CMSOMASA 14
BEGIN
PROMPT 2 2 "Commessa OMASA "
FLAGS "D"
END
STRING F_CODCMS 20
BEGIN
PROMPT 2 4 "Commessa corrispondente "
FLAGS "UZ"
USE CMS
INPUT CODTAB F_CODCMS
DISPLAY "Codice@20" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_CODCMS CODTAB
OUTPUT F_DESCRCMS S0
CHECKTYPE NORMAL
END
STRING F_DESCRCMS 50
BEGIN
PROMPT 2 5 "Descrizione "
USE CMS KEY 2
INPUT S0 F_DESCRCMS
DISPLAY "Descrizione@50" S0
DISPLAY "Codice@20" CODTAB
COPY OUTPUT F_CODCMS
CHECKTYPE NORMAL
END
ENDPAGE
ENDMASK

99
ps/pd0777conf.ini Executable file
View File

@ -0,0 +1,99 @@
[CONTI]
105010 = 1|5|105010
420020 = 4|20|420020
421000 = 4|21|421000
421100 = 4|21|421100
422010 = 4|22|422010
422020 = 4|22|422020
422090 = 4|22|422090
423010 = 4|23|423010
423030 = 4|23|423030
423040 = 4|23|423040
423050 = 4|23|423050
423060 = 4|23|423060
423070 = 4|23|423070
423090 = 4|23|423090
423100 = 4|23|423100
424100 = 4|24|424100
424110 = 4|24|424110
424120 = 4|24|424120
424130 = 4|24|424130
424150 = 4|24|424150
426000 = 4|24|426000
430500 = 4|30|430500
442060 = 4|42|442060
442070 = 4|42|442070
470000 = 4|70|470000
471010 = 4|71|471010
499000 = 4|99|499000
601100 = 6|2|601100
601110 = 6|2|601110
601120 = 6|2|601120
601150 = 6|2|601150
601330 = 6|2|601330
601340 = 6|2|601340
601350 = 6|2|601350
601375 = 6|2|601375
601385 = 6|2|601385
602740 = 6|3|602740
603430 = 6|3|603430
608030 = 6|8|608030
608040 = 6|8|608040
805000 = 8|5|805000
[MAIN]
PERCORSO = c:\MEDISTIPENDI\medicasa102006
[MOVIMENTO]
CODCAUS = STI
[COMMESSE]
1SUA = RO
1SW = TR
1SYA = TE
1SZ = MI
1SZA = VA
1SZB = UD
1SZC = AS
1SZD = VE
1SZE = CTA
1SZF = CZO
1SZI = NA
1SZM = SA
1SZO = PD
1SZU = PA
2SUA = RO
2SW = TR
2SYA = TE
2SZ = MI
2SZA = VA
2SZB = UD
2SZC = AS
2SZD = VE
2SZE = CTA
2SZF = CZO
2SZI = NA
2SZL = ME
2SZM = SA
2SZN = PE
2SZU = PA
3SLD = SE
3SUA = RO
3SY = SE
3SZ = MI
3SZE = CTA
4SUA = RO
4SW = TR
4SY = SE
4SYA = TE
4SZ = MI
4SZA = VA
4SZB = UD
4SZC = AS
4SZD = VE
4SZE = CTA
4SZF = CZO
4SZI = NA
4SZM = SA
4SZO = PD

View File

@ -59,7 +59,7 @@ class TServus : public TSkeleton_application
long _nrecords; long _nrecords;
int _cont11, _cont12, _cont13; int _cont11, _cont12, _cont13;
TRiga_documento* _riga_doc_curr; TRiga_documento* _riga_doc_curr;
real _tot_prezzinetti, _tot_tempi, _tot_manodopera, _tot_vari ; real _tot_mate, _tot_temp, _tot_mano, _tot_vari ;
virtual const char * extra_modules() const {return "ve";} virtual const char * extra_modules() const {return "ve";}
@ -68,7 +68,7 @@ protected:
virtual bool destroy(void); virtual bool destroy(void);
virtual void main_loop() ; virtual void main_loop() ;
void azzera_totali() ; void azzera_totali() ;
void aggiorna_totali(const real& prezzonetto, const real& tempi, const real& manodopera, const real& vari); void aggiorna_totali(const real& materiale, const real& tempi, const real& manodopera, const real& vari);
void elabora_documenti(); void elabora_documenti();
static int calcola_tipo(const TRiga_documento& r); static int calcola_tipo(const TRiga_documento& r);
@ -79,6 +79,10 @@ public:
const int nriga11() { return _cont11;}; const int nriga11() { return _cont11;};
const int nriga12() { return _cont12;}; const int nriga12() { return _cont12;};
const int nriga13() { return _cont13;}; const int nriga13() { return _cont13;};
const real& tot_temp() { return _tot_temp;};
const real& tot_mano() { return _tot_mano;};
const real& tot_vari() { return _tot_vari;};
const real& tot_mate() { return _tot_mate;};
const TRiga_documento& riga_doc_curr() { return *_riga_doc_curr;}; const TRiga_documento& riga_doc_curr() { return *_riga_doc_curr;};
TConfig configfile() {return *_configfile;}; TConfig configfile() {return *_configfile;};
TServus() {} ; TServus() {} ;
@ -126,14 +130,20 @@ void TServus_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TS
TString in(s.get()); TString in(s.get());
if (in == "IMPORTO") if (in == "IMPORTO")
{ {
real importo = app().riga_doc_curr().importo(TRUE, TRUE); real importo = app().riga_doc_curr().importo(TRUE, FALSE);
valore = importo.string(); valore = importo.string();
valore.strip("."); valore.strip(".");
} }
else if (in == "PREZZO") else if (in == "PREZZO")
{ {
real importo = app().riga_doc_curr().prezzo(TRUE, TRUE); real importo = app().riga_doc_curr().prezzo(TRUE, FALSE);
valore = importo.string(); valore = importo.string(0,2);
valore.strip(".");
}
else if (in == "QTA")
{
real qta = app().riga_doc_curr().quantita();
valore = qta.string(0,2);
valore.strip("."); valore.strip(".");
} }
} }
@ -200,6 +210,23 @@ void TServus_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TS
else if (in == "13") else if (in == "13")
valore.format("%ld", app().nriga13()); valore.format("%ld", app().nriga13());
} }
else if (code == "_TOTALE")
{
real totale;
TString in(s.get());
if (in == "TEMP")
totale = app().tot_temp();
else if (in == "MATE")
totale = app().tot_mate();
else if (in == "MANO")
totale = app().tot_mano();
else if (in == "VARI")
totale = app().tot_vari();
else if (in == "SOMM")
totale = app().tot_mano()+app().tot_mate();
valore = totale.string(0,2);
valore.strip(".");
}
else NFCHECK("Macro non definita: %s", (const char *)code); else NFCHECK("Macro non definita: %s", (const char *)code);
str = valore; str = valore;
@ -227,18 +254,18 @@ bool TServus::destroy()
void TServus::azzera_totali() void TServus::azzera_totali()
{ {
_tot_prezzinetti = ZERO; _tot_mate = ZERO;
_tot_tempi = ZERO; _tot_temp = ZERO;
_tot_manodopera = ZERO; _tot_mano = ZERO;
_tot_vari = ZERO; _tot_vari = ZERO;
} }
void TServus::aggiorna_totali(const real& prezzonetto, const real& tempi, const real& manodopera, const real& vari) void TServus::aggiorna_totali(const real& materiale, const real& tempi, const real& manodopera, const real& vari)
{ {
_tot_prezzinetti = _tot_prezzinetti+prezzonetto; _tot_mate = _tot_mate+materiale;
_tot_tempi = _tot_tempi+tempi; _tot_temp = _tot_temp+tempi;
_tot_manodopera = _tot_manodopera+manodopera; _tot_mano = _tot_mano+manodopera;
_tot_vari = _tot_vari+vari; _tot_vari = _tot_vari+vari;
} }
@ -349,7 +376,6 @@ void TServus::elabora_documenti()
_trasfile->write(rec); _trasfile->write(rec);
TDocumento documento = doc_rel.curr(); TDocumento documento = doc_rel.curr();
documento.body(LF_RIGHEDOC).sort(righe_sort); documento.body(LF_RIGHEDOC).sort(righe_sort);
_cont11 = _cont12 = _cont13 = 0; _cont11 = _cont12 = _cont13 = 0;
for (int i=1;i<=documento.rows();i++) for (int i=1;i<=documento.rows();i++)
{ {
@ -359,19 +385,37 @@ void TServus::elabora_documenti()
if (tipo_record >= 11 && tipo_record <= 13) if (tipo_record >= 11 && tipo_record <= 13)
{ {
doc_rel.curr(LF_RIGHEDOC) = rec_rdoc; doc_rel.curr(LF_RIGHEDOC) = rec_rdoc;
switch (tipo_record) switch (tipo_record)
{ {
case 11: case 11:
{
rec.set_type("11"); rec.set_type("11");
_cont11++; _cont11++;
//real ore = rec_rdoc.get_real(RDOC_QTA);
//real importo = rec_rdoc.get_real(RDOC_PREZZO);
real importo = rec_rdoc.prezzo(TRUE, FALSE);
real ore = rec_rdoc.quantita();
aggiorna_totali(ZERO, ore, importo, ZERO);
}
break; break;
case 12: case 12:
{
rec.set_type("12"); rec.set_type("12");
_cont12++; _cont12++;
//real importo = rec_rdoc.get_real(RDOC_PREZZO);
real importo = rec_rdoc.prezzo(TRUE, FALSE);
aggiorna_totali(importo, ZERO, ZERO, ZERO);
}
break; break;
case 13: case 13:
{
rec.set_type("13"); rec.set_type("13");
_cont13++; _cont13++;
//real importo = rec_rdoc.get_real(RDOC_PREZZO);
real importo = rec_rdoc.prezzo(TRUE, FALSE);
aggiorna_totali(ZERO, ZERO, ZERO, importo);
}
break; break;
default: default:
break; break;

View File

@ -45,8 +45,7 @@ ALIGN = R
DATA = S DATA = S
DECIMAL = 0 DECIMAL = 0
FILLER = '0' FILLER = '0'
LENGTH = 0 LENGTH = 8
PICTURE =
[HEADER OP] [HEADER OP]
NAME(0)=IDENTIFICATIVO TESTA NAME(0)=IDENTIFICATIVO TESTA
@ -131,6 +130,7 @@ NAME(7) = TIPO VEICOLO
TYPE(7) = STRINGA TYPE(7) = STRINGA
LENGTH(7) = 12 LENGTH(7) = 12
POSITION(7) = 57 POSITION(7) = 57
FIELD(7) = 33->TIPO
NAME(8) = ACQUISTO NAME(8) = ACQUISTO
TYPE(8) = STRINGA TYPE(8) = STRINGA
@ -153,6 +153,7 @@ NAME(11) = SECONDO TIPO VEICOLO
TYPE(11) = STRINGA TYPE(11) = STRINGA
LENGTH(11) = 2 LENGTH(11) = 2
POSITION(11) = 77 POSITION(11) = 77
FIELD(11) = 33->LIBCOL
NAME(12) = RICHIESTA INOLTRATA DA NAME(12) = RICHIESTA INOLTRATA DA
TYPE(12) = STRINGA TYPE(12) = STRINGA
@ -238,11 +239,11 @@ LENGTH(4) = 13
POSITION(4) = 15 POSITION(4) = 15
FIELD(4) = 33->TELAIO[4,16] FIELD(4) = 33->TELAIO[4,16]
NAME(26) = SUFFISSO PZ NAME(26) = SECONDA PARTE TELAIO
TYPE(26) = STRINGA TYPE(26) = STRINGA
LENGTH(26) = 2 LENGTH(26) = 2
POSITION(26) = 28 POSITION(26) = 28
MESSAGE(26) = _FISSO,!PZ FIELD(26) = 33->TELAIO[17,19]
NAME(5) = GIORNO IMMATRICOLAZIONE NAME(5) = GIORNO IMMATRICOLAZIONE
TYPE(5) = NUMERO TYPE(5) = NUMERO
@ -404,9 +405,10 @@ FIELD(20) = 34->CODART
NAME(5) = ORE LAVORO NAME(5) = ORE LAVORO
TYPE(5) = STRINGA TYPE(5) = STRINGA
LENGTH(5) = 5 LENGTH(5) = 4
POSITION(5) = 30 POSITION(5) = 27
FIELD(5) = 34->QTA FIELD(5) = 34->QTA
MESSAGE(5) = _DARIGA,QTA
NAME(6) = TESTO LAVORO NAME(6) = TESTO LAVORO
TYPE(6) = STRINGA TYPE(6) = STRINGA
@ -452,11 +454,13 @@ NAME(13) = INDICATORE CORRENTEZZA
TYPE(13) = STRINGA TYPE(13) = STRINGA
LENGTH(13) = 1 LENGTH(13) = 1
POSITION(13) = 88 POSITION(13) = 88
FIELD(13) = 34->CODAGG1[1,1]
NAME(14) = RICONOSCIMENTO PAGAMENTO NAME(14) = RICONOSCIMENTO PAGAMENTO
TYPE(14) = STRINGA TYPE(14) = STRINGA
LENGTH(14) = 1 LENGTH(14) = 1
POSITION(14) = 89 POSITION(14) = 89
MESSAGE(14) = _FISSO,!1
NAME(15) = IDENTIFICATORE NAME(15) = IDENTIFICATORE
TYPE(15) = STRINGA TYPE(15) = STRINGA
@ -472,7 +476,6 @@ NAME(17) = IMPORTO ORA LAVORO
TYPE(17) = IMPORTO TYPE(17) = IMPORTO
LENGTH(17) = 6 LENGTH(17) = 6
POSITION(17) = 93 POSITION(17) = 93
//FIELD(17) = 34->PREZZO
MESSAGE(17) = _DARIGA,PREZZO MESSAGE(17) = _DARIGA,PREZZO
NAME(18) = PREZZO NAME(18) = PREZZO
@ -543,14 +546,14 @@ NAME(9) = PREZZO VENDITA
TYPE(9) = IMPORTO TYPE(9) = IMPORTO
LENGTH(9) = 8 LENGTH(9) = 8
POSITION(9) = 45 POSITION(9) = 45
FIELD(9) = 34->PREZZO //FIELD(9) = 34->PREZZO
MESSAGE(9) = _IMPORTO MESSAGE(9) = _DARIGA,PREZZO
NAME(10) = IMPORTO AL NETTO NAME(10) = IMPORTO AL NETTO
TYPE(10) = IMPORTO TYPE(10) = STRINGA
LENGTH(10) = 1 LENGTH(10) = 1
POSITION(10) = 53 POSITION(10) = 53
MESSAGE(10) = _IMPORTO
NAME(11) = FILLER NAME(11) = FILLER
TYPE(11) = STRINGA TYPE(11) = STRINGA
@ -589,12 +592,13 @@ NAME(16) = INDICATORE CORRENTEZZA
TYPE(16) = STRINGA TYPE(16) = STRINGA
LENGTH(16) = 1 LENGTH(16) = 1
POSITION(16) = 88 POSITION(16) = 88
MESSAGE(16) = _FISSO,!V FIELD(16) = 34->CODAGG1[1,1]
NAME(17) = RICONOSCIMENTO ASSEGNAZIONI PARTICOLARI NAME(17) = RICONOSCIMENTO ASSEGNAZIONI PARTICOLARI
TYPE(17) = STRINGA TYPE(17) = STRINGA
LENGTH(17) = 1 LENGTH(17) = 1
POSITION(17) = 89 POSITION(17) = 89
MESSAGE(17) = _FISSO,!1
NAME(18) = RICONOSCIMENTO POSIZIONI PARTICOLARI NAME(18) = RICONOSCIMENTO POSIZIONI PARTICOLARI
TYPE(18) = STRINGA TYPE(18) = STRINGA
@ -645,8 +649,8 @@ NAME(5) = SPESE FATTURA ESTERNA
TYPE(5) = IMPORTO TYPE(5) = IMPORTO
LENGTH(5) = 8 LENGTH(5) = 8
POSITION(5) = 18 POSITION(5) = 18
FIELD(5) = 34->PREZZO //FIELD(5) = 34->PREZZO
MESSAGE(5) = _IMPORTO MESSAGE(5) = _DARIGA,PREZZO
NAME(6) = VARIE NAME(6) = VARIE
TYPE(6) = STRINGA TYPE(6) = STRINGA
@ -675,7 +679,7 @@ NAME(10) = INDICATORE CORRENTEZZA
TYPE(10) = STRINGA TYPE(10) = STRINGA
LENGTH(10) = 1 LENGTH(10) = 1
POSITION(10) = 88 POSITION(10) = 88
MESSAGE(10) = _FISSO,!V FIELD(10) = 34->CODAGG1[1,1]
NAME(11) = RICONOSCIMENTO ASSEGNAZIONI PARTICOLARI NAME(11) = RICONOSCIMENTO ASSEGNAZIONI PARTICOLARI
TYPE(11) = STRINGA TYPE(11) = STRINGA
@ -726,6 +730,7 @@ NAME(4) = SOMMA MATERIALE
TYPE(4) = IMPORTO TYPE(4) = IMPORTO
LENGTH(4) = 8 LENGTH(4) = 8
POSITION(4) = 15 POSITION(4) = 15
MESSAGE(4) = _TOTALE,MATE
NAME(5) = SOMMA PERSONALE NAME(5) = SOMMA PERSONALE
TYPE(5) = NUMERO TYPE(5) = NUMERO
@ -736,21 +741,25 @@ NAME(6) = SOMMA TEMPI
TYPE(6) = NUMERO TYPE(6) = NUMERO
LENGTH(6) = 4 LENGTH(6) = 4
POSITION(6) = 28 POSITION(6) = 28
MESSAGE(6) = _TOTALE,TEMP
NAME(7) = SOMMA MANODOPERA NAME(7) = SOMMA MANODOPERA
TYPE(7) = NUMERO TYPE(7) = NUMERO
LENGTH(7) = 8 LENGTH(7) = 8
POSITION(7) = 32 POSITION(7) = 32
MESSAGE(7) = _TOTALE,MANO
NAME(8) = SOMMA VARI NAME(8) = SOMMA VARI
TYPE(8) = NUMERO TYPE(8) = NUMERO
LENGTH(8) = 8 LENGTH(8) = 8
POSITION(8) = 40 POSITION(8) = 40
MESSAGE(8) = _TOTALE,VARI
NAME(9) = SOMMA MATERIALE+MANODOPERA NAME(9) = SOMMA MATERIALE+MANODOPERA
TYPE(9) = NUMERO TYPE(9) = NUMERO
LENGTH(9) = 8 LENGTH(9) = 8
POSITION(9) = 48 POSITION(9) = 48
MESSAGE(9) = _TOTALE,SOMM
NAME(10) = ALLEGATI NAME(10) = ALLEGATI
TYPE(10) = STRINGA TYPE(10) = STRINGA

View File

@ -1,11 +1,3 @@
#include <applicat.h>
#include <config.h>
#include <currency.h>
#include <form.h>
#include <printer.h>
#include <progind.h>
#include "../cg/cgsaldac.h"
#include "sc2.h" #include "sc2.h"
#include "sc2101.h" #include "sc2101.h"
#include "sc2102.h" #include "sc2102.h"
@ -13,12 +5,43 @@
#include "sc2100a.h" #include "sc2100a.h"
#include "sc21pec.h" #include "sc21pec.h"
#include "../cg/cgsaldac.h"
#include "../pr/agenti.h"
#include <applicat.h>
#include <form.h>
#include <printer.h>
#include <progind.h>
#include <textset.h>
#include <cfven.h> #include <cfven.h>
#include <clifo.h>
#include <causali.h> #include <causali.h>
#include <mov.h> #include <mov.h>
#include "../pr/agenti.h" class TEC_recordset : public TAS400_recordset
{
public:
TEC_recordset();
};
TEC_recordset::TEC_recordset() : TAS400_recordset("AS400(255,0,0)")
{
create_field("Cliente", 0, 6, _longfld);
create_field("RagioneSociale", -1, 50);
create_field("Valuta", -1, 3);
create_field("Causale", -1, 3);
create_field("Descrizione", -1, 60);
create_field("DataDoc", -1, 10, _datefld);
create_field("NumDoc" , -1, 7);
create_field("ProtIVA", -1, 6, _intfld);
create_field("DataPag", -1, 10, _datefld);
create_field("Dare", -1, 15, _realfld);
create_field("Avere", -1, 15, _realfld);
create_field("Scaduto", -1, 15, _realfld);
create_field("Esposto", -1, 15, _realfld);
create_field("SBF", -1, 1);
create_field("TotDoc", -1, 15, _realfld);
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TEC_form // TEC_form
@ -29,6 +52,7 @@ class TEC_form : public TForm
friend class TEC_row; friend class TEC_row;
static TEC_form* _form; static TEC_form* _form;
TEC_recordset* _recordset;
enum { MAXTOT = 16 }; enum { MAXTOT = 16 };
@ -55,7 +79,7 @@ protected:
void print_total(int riga, const THash_object& o); void print_total(int riga, const THash_object& o);
void stampa_testata(TPrinter& p); void stampa_testata(TPrinter& p);
void stampa_pedata(TPrinter& p); void stampa_pedata();
void stampa_riporti(TPrinter& p); void stampa_riporti(TPrinter& p);
static void ec_header_handler(TPrinter& p); static void ec_header_handler(TPrinter& p);
@ -81,18 +105,26 @@ public:
void set_agente(const TString& codag); void set_agente(const TString& codag);
TEC_form(const TEC_mask& m, bool gesval); bool printing() const { return _recordset == NULL; }
bool exporting() const { return _recordset != NULL; }
void export_total();
TEC_recordset& recordset() const { CHECK(exporting(),"Not exporting"); return *_recordset; }
TEC_form(const TEC_mask& m, bool gesval, bool excel);
virtual ~TEC_form(); virtual ~TEC_form();
}; };
TEC_form* TEC_form::_form = NULL; TEC_form* TEC_form::_form = NULL;
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TEC_row // TEC_row
// Rappresenta una singola riga di stampa // Rappresenta una singola riga di stampa
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
static char __ltipocf;
static long __lcodcf;
class TEC_row : public TSortable class TEC_row : public TSortable
{ {
TDate _data; // Data scadenza o pagamento TDate _data; // Data scadenza o pagamento
@ -102,6 +134,9 @@ class TEC_row : public TSortable
TString _causale; // Codice causale TString _causale; // Codice causale
TString _descrizione; // Sua descrizione TString _descrizione; // Sua descrizione
char _tipocf;
long _codcf;
TDate _data_doc; // Data del documento TDate _data_doc; // Data del documento
TString _num_doc; // Numero documento TString _num_doc; // Numero documento
long _num_prot; // Protocollo IVA long _num_prot; // Protocollo IVA
@ -146,6 +181,7 @@ public:
bool in_valuta() const { return _valuta.in_valuta(); } bool in_valuta() const { return _valuta.in_valuta(); }
void print_on(TPrint_section& body); void print_on(TPrint_section& body);
void export_to(TEC_recordset& set);
TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata); TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata);
TEC_row(const char* desc, const TImporto& imp, const TValuta& val); TEC_row(const char* desc, const TImporto& imp, const TValuta& val);
@ -153,7 +189,7 @@ public:
}; };
TEC_row::TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata) TEC_row::TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata)
: _salvo_buon_fine(FALSE), _bloccata(FALSE) : _salvo_buon_fine(false), _bloccata(false)
{ {
_riga = row.get_int(PART_NRIGA); _riga = row.get_int(PART_NRIGA);
_rata = rata; _rata = rata;
@ -172,15 +208,19 @@ TEC_row::TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& im
const bool valuta = form().in_valuta() && _valuta.in_valuta(); const bool valuta = form().in_valuta() && _valuta.in_valuta();
const char* const field = valuta ? PART_IMPTOTVAL : PART_IMPTOTDOC; const char* const field = valuta ? PART_IMPTOTVAL : PART_IMPTOTDOC;
_totale = row.get_real(field); _totale = row.get_real(field);
__ltipocf = _tipocf = row.get_char(PART_TIPOCF);
__lcodcf = _codcf = row.get_long(PART_SOTTOCONTO);
} }
TEC_row::TEC_row(const char* desc, const TImporto& imp, const TValuta& val) TEC_row::TEC_row(const char* desc, const TImporto& imp, const TValuta& val)
: _riga(9999), _rata(9999), _num_doc(0), : _riga(9999), _rata(9999), _num_doc(0),
_num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE), _bloccata(FALSE) _num_prot(0), _num_reg(0), _salvo_buon_fine(false), _bloccata(false)
{ {
_descrizione = desc; _descrizione = desc;
_importo = imp; _importo.normalize(); _importo = imp; _importo.normalize();
_valuta = val; _valuta = val;
_tipocf = __ltipocf;
_codcf = __lcodcf;
} }
// Le righe dell'estratto conto sono ordinate per data, riga partita, numero rata o // Le righe dell'estratto conto sono ordinate per data, riga partita, numero rata o
@ -254,7 +294,7 @@ void TEC_row::print_on(TPrint_section& body)
numdoc.set(_num_doc); numdoc.set(_num_doc);
TForm_item& numprot = body.find_field(PEC_PROTIVA); TForm_item& numprot = body.find_field(PEC_PROTIVA);
TString16 protiva; protiva << _num_prot; TString8 protiva; protiva << _num_prot;
numprot.set(protiva); numprot.set(protiva);
TForm_item& datapag = body.find_field(PEC_DATAPAG); TForm_item& datapag = body.find_field(PEC_DATAPAG);
@ -285,8 +325,8 @@ void TEC_row::print_on(TPrint_section& body)
TForm_item& totdoc = body.find_field(PEC_TOTDOC); TForm_item& totdoc = body.find_field(PEC_TOTDOC);
set_imp(totdoc, _totale, cod_valuta); set_imp(totdoc, _totale, cod_valuta);
TForm_item& lire = body.find_field(PEC_IMPEURO); TForm_item& euro = body.find_field(PEC_IMPEURO);
set_imp(lire, _importo_euro, ""); // In generale va espresso nella valuta della ditta set_imp(euro, _importo_euro, ""); // In generale va espresso nella valuta della ditta
TForm_item& cambio = body.find_field(PEC_CAMBIO); TForm_item& cambio = body.find_field(PEC_CAMBIO);
cambio.set(_valuta.cambio().string()); cambio.set(_valuta.cambio().string());
@ -306,6 +346,28 @@ void TEC_row::print_on(TPrint_section& body)
descr.set_prompt(old_prompt); descr.set_prompt(old_prompt);
} }
void TEC_row::export_to(TEC_recordset& r)
{
r.new_rec();
r.set("Cliente", TVariant(_codcf));
TString key; key.format("%c|%ld", _tipocf, _codcf);
const TString & ragsoc = cache().get(LF_CLIFO, key, CLI_RAGSOC);
r.set("RagioneSociale", TVariant(ragsoc));
r.set("Valuta", TVariant(_valuta.codice()));
r.set("Causale", TVariant(_causale));
r.set("Descrizione", TVariant(_descrizione));
r.set("DataDoc", TVariant(_data_doc));
r.set("NumDoc", TVariant(_num_doc));
r.set("ProtIVA", TVariant(_num_prot));
r.set("DataPag", TVariant(_data));
r.set(_importo.sezione() == 'D' ? "Dare" : "Avere", _importo.valore());
r.set("Scaduto", TVariant(_scaduto));
r.set("Esposto", TVariant(_esposto));
r.set("SBF", TVariant(_salvo_buon_fine ? "*" : " "));
r.set("TotDoc", TVariant(_totale));
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TEC_array // TEC_array
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -508,7 +570,7 @@ void TEC_array::add_row(const TRiga_partite& row)
} }
if (in_valuta) if (in_valuta)
{ {
TImporto il = rata.importo(FALSE); TImporto il = rata.importo(false);
il.normalize(sezione); il.normalize(sezione);
rec.importo_euro(il.valore()); rec.importo_euro(il.valore());
} }
@ -531,7 +593,7 @@ void TEC_array::add_row(const TRiga_partite& row)
const TDate& dls = form().data_limite_scaduto(); const TDate& dls = form().data_limite_scaduto();
const TDate& dir = form().data_inizio_rischio(); const TDate& dir = form().data_inizio_rischio();
bool sbf = FALSE; bool sbf = false;
TImporto esposto(row.esposto(in_valuta, dls, dir, sbf)); TImporto esposto(row.esposto(in_valuta, dls, dir, sbf));
bool esp = !esposto.is_zero(); bool esp = !esposto.is_zero();
@ -551,13 +613,13 @@ void TEC_array::add_row(const TRiga_partite& row)
rec.descrizione(form().describe(PEC_ABBUONI)); rec.descrizione(form().describe(PEC_ABBUONI));
if (in_valuta) if (in_valuta)
{ {
TImporto il(row.importo(FALSE, 0x2)); TImporto il(row.importo(false, 0x2));
il.normalize(sezione); il.normalize(sezione);
rec.importo_euro(il.valore()); rec.importo_euro(il.valore());
} }
} }
TImporto diffcam(row.importo(FALSE, 0x4)); TImporto diffcam(row.importo(false, 0x4));
if (!diffcam.is_zero() && !in_valuta) if (!diffcam.is_zero() && !in_valuta)
{ {
TEC_row& rec = new_row(row, data_pag, TImporto('D', ZERO), RIGA_DIFFCAM); TEC_row& rec = new_row(row, data_pag, TImporto('D', ZERO), RIGA_DIFFCAM);
@ -565,7 +627,7 @@ void TEC_array::add_row(const TRiga_partite& row)
rec.importo(diffcam); rec.importo(diffcam);
} }
TImporto ritenute(row.importo(FALSE, 0x8)); TImporto ritenute(row.importo(false, 0x8));
if (!ritenute.is_zero()) if (!ritenute.is_zero())
{ {
TEC_row& rec = new_row(row, data_pag, TImporto('D', ZERO), RIGA_RITENUTE); TEC_row& rec = new_row(row, data_pag, TImporto('D', ZERO), RIGA_RITENUTE);
@ -915,7 +977,7 @@ void TEC_form::print_total(int riga, const THash_object& o)
printer().setfooterline(riga + r, foot.row(r)); printer().setfooterline(riga + r, foot.row(r));
} }
void TEC_form::stampa_pedata(TPrinter& pr) void TEC_form::stampa_pedata()
{ {
THash_object* tot[MAXTOT]; THash_object* tot[MAXTOT];
word num_rip = ordina_totali_per_valuta(tot); word num_rip = ordina_totali_per_valuta(tot);
@ -927,9 +989,30 @@ void TEC_form::stampa_pedata(TPrinter& pr)
print_total(j*_total_rows+1, *tot[j]); print_total(j*_total_rows+1, *tot[j]);
} }
void TEC_form::export_total()
{
THash_object* tot[MAXTOT];
word num_rip = ordina_totali_per_valuta(tot);
for (word j = 0; j < num_rip; j++)
{
_recordset->new_rec();
const THash_object& o = *tot[j];
const TTotal& t = (const TTotal&)o.obj();
TString descr; descr << "*** " << TR("Totale") << ' ' << o.key();
_recordset->set("Descrizione", TVariant(descr));
_recordset->set(t.importo().sezione() == 'D' ? "Dare" : "Avere", t.importo().valore());
_recordset->set("Scaduto", t.scaduto());
_recordset->set("Esposto", t.esposto());
// _recordset->new_rec();
}
}
void TEC_form::ultima_pagina() void TEC_form::ultima_pagina()
{ {
set_last_page(TRUE); set_last_page(true);
} }
void TEC_form::ec_header_handler(TPrinter& pr) void TEC_form::ec_header_handler(TPrinter& pr)
@ -944,28 +1027,29 @@ void TEC_form::ec_footer_handler(TPrinter& pr)
if (_form->page(pr) > 0) // Normal page if (_form->page(pr) > 0) // Normal page
_form->stampa_riporti(pr); _form->stampa_riporti(pr);
else // Last page else // Last page
_form->stampa_pedata(pr); _form->stampa_pedata();
} }
void TEC_form::azzera_totali() void TEC_form::azzera_totali()
{ {
totali().destroy(); // Azzera tutti i riporti totali().destroy(); // Azzera tutti i riporti
_num_rip = 0; // Azzera il numero di righe di riporto _num_rip = 0; // Azzera il numero di righe di riporto
set_last_page(FALSE); // Azzera il flag di ultima pagina di stampa set_last_page(false); // Azzera il flag di ultima pagina di stampa
if (printing())
{
TPrint_section& foot = section('F'); TPrint_section& foot = section('F');
printer().footerlen(foot.height()); printer().footerlen(foot.height());
printer().setcurrentpage(1); printer().setcurrentpage(1);
}
} }
bool TEC_form::print_game(const TPartita& game) bool TEC_form::print_game(const TPartita& game)
{ {
bool ok = FALSE; bool ok = false;
TEC_array righe(game, this); TEC_array righe(game, this);
TPrinter& pr = printer();
TPrintrow prow;
TPrint_section& body = section('B'); TPrint_section& body = section('B');
@ -979,8 +1063,9 @@ bool TEC_form::print_game(const TPartita& game)
int r; int r;
for (r = 0; r < righe.items(); r++) for (r = 0; r < righe.items(); r++)
{ {
TEC_row& riga = righe.row(r); if (printing())
{
TPrinter& pr = printer();
if (pr.rows_left() <= (body.height()+1)) // salto pagina if (pr.rows_left() <= (body.height()+1)) // salto pagina
{ {
pr.formfeed(); pr.formfeed();
@ -991,7 +1076,9 @@ bool TEC_form::print_game(const TPartita& game)
pr.print(*fl); pr.print(*fl);
} }
} }
}
TEC_row& riga = righe.row(r);
const int ri = riga.riga(); const int ri = riga.riga();
const int ra = riga.rata(); const int ra = riga.rata();
if (ri == ultima_riga && ra == ultima_rata+1) if (ri == ultima_riga && ra == ultima_rata+1)
@ -999,10 +1086,17 @@ bool TEC_form::print_game(const TPartita& game)
ultima_riga = ri; ultima_riga = ri;
ultima_rata = ra; ultima_rata = ra;
if (printing())
{
riga.print_on(body); riga.print_on(body);
pr.print(body.row(0)); printer().print(body.row(0));
}
else
{
riga.export_to(*_recordset);
}
TString16 codval; TString4 codval;
if (in_valuta()) if (in_valuta())
codval = riga.valuta().codice(); codval = riga.valuta().codice();
@ -1013,7 +1107,7 @@ bool TEC_form::print_game(const TPartita& game)
scaduto += riga.scaduto(); scaduto += riga.scaduto();
esposto += riga.esposto(); esposto += riga.esposto();
implire += riga.importo_euro(); implire += riga.importo_euro();
ok = TRUE; ok = true;
} }
if (ok && stampa_saldo()) if (ok && stampa_saldo())
@ -1032,8 +1126,14 @@ bool TEC_form::print_game(const TPartita& game)
sld.scaduto(scaduto); sld.scaduto(scaduto);
sld.esposto(esposto); sld.esposto(esposto);
sld.importo_euro(implire); sld.importo_euro(implire);
if (printing())
{
sld.print_on(body); sld.print_on(body);
pr.print(body.row(0)); printer().print(body.row(0));
}
else
sld.export_to(*_recordset);
} }
return ok; return ok;
} }
@ -1073,23 +1173,34 @@ void TEC_form::init_header(const TMask& m)
void TEC_form::set_agente(const TString& codag) void TEC_form::set_agente(const TString& codag)
{ {
const bool good = codag.full();
TPrint_section& head = section('H'); TPrint_section& head = section('H');
TForm_item& agente = head.find_field(PEC_AGENTE); TForm_item& agente = head.find_field(PEC_AGENTE);
const bool good = !codag.blank();
agente.show(good); agente.show(good);
if (good) if (good)
{ {
TString ag; TString ag;
ag << codag << ' '; ag << codag << ' ';
ag << cache().get(LF_AGENTI, codag, AGE_RAGSOC); ag << cache().get(LF_AGENTI, codag, AGE_RAGSOC);
if (printing())
{
agente.set(ag); agente.set(ag);
} }
else
{
_recordset->new_rec();
_recordset->set("Descrizione", TVariant(ag));
_recordset->new_rec();
}
}
} }
TEC_form::TEC_form(const TEC_mask& m, bool gesval) TEC_form::TEC_form(const TEC_mask& m, bool gesval, bool excel)
: TForm(BASE_EC_PROFILE, m.get_prof_name()), : TForm(BASE_EC_PROFILE, m.get_prof_name()), _recordset(NULL),
_in_valuta(FALSE), _stampa_saldo(TRUE), _num_rip(0), _total_rows(0) _in_valuta(false), _stampa_saldo(true), _num_rip(0), _total_rows(0)
{ {
_form = this; _form = this;
@ -1104,6 +1215,14 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
_giorni_rischio = m.get_int(F_GIORISCH); _giorni_rischio = m.get_int(F_GIORISCH);
_dir = _dls; _dir -= _giorni_rischio; _dir = _dls; _dir -= _giorni_rischio;
TForm_item& flags = find_field('H', last_page, PEC_FLAGS);
TToken_string f(flags.prompt());
_in_valuta = gesval && f.get_char(0) == 'X'; // Il profilo e' in valuta se c'e' il flag di valuta
_fincatura = f.get_int(1);
if (!excel)
{
TPrinter& pr = printer(); TPrinter& pr = printer();
pr.setheaderhandler(ec_header_handler); pr.setheaderhandler(ec_header_handler);
@ -1114,20 +1233,15 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
const TPrint_section& foot = section('F'); const TPrint_section& foot = section('F');
pr.footerlen(foot.height()); pr.footerlen(foot.height());
TForm_item& flags = find_field('H', last_page, PEC_FLAGS);
TToken_string f(flags.prompt());
_in_valuta = gesval && f.get_char(0) == 'X'; // Il profilo e' in valuta se c'e' il flag di valuta
_fincatura = f.get_int(1);
if (_fincatura > 0) if (_fincatura > 0)
{ {
const int first = head.height()-2; const int first = head.height()-2;
const int last = pr.formlen(); const int last = pr.formlen();
const int horiz[] = { first+2, last-foot.height()+1, 0 }; const int horiz[] = { first+2, last-foot.height()+1, 0 };
set_fink_mode(_fincatura == 1 ? FALSE : TRUE); set_fink_mode(_fincatura == 1 ? false : true);
genera_fincatura(odd_page, first, last, horiz); genera_fincatura(odd_page, first, last, horiz);
} }
TForm_item& uns = section('F').find_field(PEC_UNASSIGNED); TForm_item& uns = section('F').find_field(PEC_UNASSIGNED);
TForm_item& tuns = section('F').find_field(PEC_TUNASSIGNED); TForm_item& tuns = section('F').find_field(PEC_TUNASSIGNED);
if (uns.shown()) uns.hide(); if (uns.shown()) uns.hide();
@ -1156,13 +1270,23 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
const word max = (foot.height() - 2) / _total_rows; const word max = (foot.height() - 2) / _total_rows;
if (_maxtot <= 0 || _maxtot > max) if (_maxtot <= 0 || _maxtot > max)
_maxtot = max; _maxtot = max;
}
else
_recordset = new TEC_recordset;
} }
TEC_form::~TEC_form() TEC_form::~TEC_form()
{ {
if (printing())
{
TPrinter& pr = printer(); TPrinter& pr = printer();
pr.setheaderhandler(NULL); pr.setheaderhandler(NULL);
pr.setfooterhandler(NULL); pr.setfooterhandler(NULL);
}
else
{
delete _recordset;
}
_form = NULL; _form = NULL;
} }
@ -1205,9 +1329,9 @@ bool TEC_Game_list::has_clifo(long codcf)
{ {
signat = key; signat = key;
if (signat.get_long(1) == codcf) if (signat.get_long(1) == codcf)
return TRUE; return true;
} }
return FALSE; return false;
} }
bool TEC_Game_list::has_game(const TRectype& rec) bool TEC_Game_list::has_game(const TRectype& rec)
@ -1280,10 +1404,15 @@ bool TStampaEC_application::print_selected()
const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti
long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata
const bool printing = form().printing();
printer().open();
const long items = c.items(); const long items = c.items();
TProgind* pi = NULL;
if (printing)
printer().open();
else
pi = new TProgind(items, TR("Calcolo estratto conto"), true, true);
for (long i = 0; i < items; i++) for (long i = 0; i < items; i++)
{ {
if (print_all || s.checked(i)) if (print_all || s.checked(i))
@ -1293,10 +1422,24 @@ bool TStampaEC_application::print_selected()
if (ret < 0) if (ret < 0)
analfabeti++; analfabeti++;
} }
if (printing)
{
if (printer().frozen()) if (printer().frozen())
break; break;
} }
else
{
if (!pi->addstatus(1))
break;
}
}
if (printing)
{
printer().close(); printer().close();
if (_tiponumec > ' ' && who == 'C')
save_numec();
if (analfabeti > 0) if (analfabeti > 0)
{ {
@ -1305,11 +1448,11 @@ bool TStampaEC_application::print_selected()
"il codice lingua non corrispondeva al profilo di stampa"), "il codice lingua non corrispondeva al profilo di stampa"),
analfabeti, anag); analfabeti, anag);
} }
}
else
delete pi;
if (_tiponumec > ' ' && who == 'C') return true;
save_numec();
return TRUE;
} }
void TStampaEC_application::find_agents_scads(TAssoc_array& agents) void TStampaEC_application::find_agents_scads(TAssoc_array& agents)
@ -1340,11 +1483,10 @@ void TStampaEC_application::find_agents_scads(TAssoc_array& agents)
const long items = cur.items(); const long items = cur.items();
cur.freeze(); cur.freeze();
TProgind pi(items, TR("Ricerca scadenze aperte per agente..."), TRUE, TRUE); TProgind pi(items, TR("Ricerca scadenze aperte per agente..."), true, true);
for (cur = 0L; cur.pos() < items; ++cur) for (cur = 0L; cur.pos() < items; ++cur)
{ {
pi.addstatus(1); if (!pi.addstatus(1))
if (pi.iscancelled())
break; break;
const char* codag = pagsca.get(PAGSCA_CODAG); const char* codag = pagsca.get(PAGSCA_CODAG);
@ -1378,33 +1520,32 @@ void TStampaEC_application::find_agents_unassigned_pags(TAssoc_array& agents)
TRelation rel(LF_PAGSCA); TRelation rel(LF_PAGSCA);
TRectype& curr = rel.curr(); TRectype& curr = rel.curr();
curr.put(PAGSCA_TIPOC, mask().get(SC_CLIFO)); curr.put(PAGSCA_TIPOC, mask().get(SC_CLIFO)); // Imposta C o F
TRectype recfr(curr), recto(curr); TRectype recfr(curr), recto(curr);
if (fromcli > 0) if (fromcli > 0)
recfr.put(PAGSCA_SOTTOCONTO, fromcli); recfr.put(PAGSCA_SOTTOCONTO, fromcli); // Imposta cliente iniziale
if (tocli >= fromcli) if (tocli >= fromcli)
recto.put(PAGSCA_SOTTOCONTO, tocli); recto.put(PAGSCA_SOTTOCONTO, tocli); // Imposta cliente finale
TString filter; TString filter;
filter << '(' << PAGSCA_NRATA <<"==9999)"; filter << '(' << PAGSCA_NRATA <<"==9999)";
if (fromage.not_empty()) if (fromage.full())
filter << "&&(" << PAGSCA_CODAG << ">=" << fromage << ')'; filter << "&&(" << PAGSCA_CODAG << ">='" << fromage << "')";
else else
filter << "&&(" << PAGSCA_CODAG << ">0)"; filter << "&&(" << PAGSCA_CODAG << "!='')";
if (toage.not_empty()) if (toage.full())
filter << "&&(" << PAGSCA_CODAG << "<=" << toage << ')'; filter << "&&(" << PAGSCA_CODAG << "<='" << toage << "')";
TCursor cur(&rel, filter, 1, &recfr, &recto); TCursor cur(&rel, filter, 1, &recfr, &recto);
const long items = cur.items(); const long items = cur.items();
if (items > 0) if (items > 0)
{ {
cur.freeze(); cur.freeze();
TProgind pi(items, TR("Ricerca pagamenti non assegnati per agente..."), TRUE, TRUE); TProgind pi(items, TR("Ricerca pagamenti non assegnati per agente..."), true, true);
for (cur = 0L; cur.pos() < items; ++cur) for (cur = 0L; cur.pos() < items; ++cur)
{ {
pi.addstatus(1); if (!pi.addstatus(1))
if (pi.iscancelled())
break; break;
const char* codag = curr.get(PAGSCA_CODAG); const char* codag = curr.get(PAGSCA_CODAG);
TEC_Game_list* games = (TEC_Game_list*)agents.objptr(codag); TEC_Game_list* games = (TEC_Game_list*)agents.objptr(codag);
@ -1441,19 +1582,26 @@ bool TStampaEC_application::print_agents()
filter.put(CLI_TIPOCF, who); filter.put(CLI_TIPOCF, who);
fc.setregion(filter, filter); fc.setregion(filter, filter);
const bool printing = form().printing();
const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti
long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata
TAssoc_array agents; TAssoc_array agents;
const long totag = find_agents_games(agents); const long totag = find_agents_games(agents);
if (totag > 0) if (totag <= 0)
{ return false;
printer().open();
TRelation rel(LF_AGENTI); TRelation rel(LF_AGENTI);
TCursor cur(&rel); TCursor cur(&rel);
const long items = cur.items(); const long items = cur.items();
cur.freeze(); cur.freeze();
TProgind* pi = NULL;
if (printing)
printer().open();
else
pi = new TProgind(items, "Calcolo estratto conto", true, true);
for (cur = 0L; cur.pos() < items; ++cur) for (cur = 0L; cur.pos() < items; ++cur)
{ {
const TString& codag = cur.curr().get(AGE_CODAGE); const TString& codag = cur.curr().get(AGE_CODAGE);
@ -1475,14 +1623,26 @@ bool TStampaEC_application::print_agents()
analfabeti++; analfabeti++;
} }
} }
if (printing)
{
if (printer().frozen()) if (printer().frozen())
break; break;
} }
else
{
if (!pi->addstatus(1))
break;
}
} }
} }
printer().close();
} }
if (printing)
{
printer().close();
if (_tiponumec > ' ' && who == 'C')
save_numec();
if (analfabeti > 0) if (analfabeti > 0)
{ {
const char* anag = who == 'C' ? TR("clienti") : TR("fornitori"); const char* anag = who == 'C' ? TR("clienti") : TR("fornitori");
@ -1490,21 +1650,23 @@ bool TStampaEC_application::print_agents()
"il codice lingua non corrispondeva al profilo di stampa"), "il codice lingua non corrispondeva al profilo di stampa"),
analfabeti, anag); analfabeti, anag);
} }
}
else
delete pi;
if (_tiponumec > ' ' && who == 'C')
save_numec();
return TRUE; return true;
} }
void TStampaEC_application::save_numec() void TStampaEC_application::save_numec()
{ {
if (_lastnumcf.items() > 0) // Ho numerato qualche estratto conto? // Ho numerato qualche estratto conto?
if (_lastnumcf.items() > 0 && form().printing())
{ {
if (yesno_box(TR("Si desidera aggiornare il numero di estratto conto stampato definitivamente?"))) if (yesno_box(TR("Si desidera aggiornare il numero di estratto conto stampato definitivamente?")))
{ {
TProgind pi(_lastnumcf.items(), TR("Aggiornamento numero estratto conto..."), FALSE, TRUE); TProgind pi(_lastnumcf.items(), TR("Aggiornamento numero estratto conto..."), false, true);
const char tipocf = mask().get_who(); // Dovrebbe essere sempre 'C' const char tipocf = mask().get_who(); // Dovrebbe essere sempre 'C'
TLocalisamfile cfven(LF_CFVEN); TLocalisamfile cfven(LF_CFVEN);
FOR_EACH_ASSOC_STRING(_lastnumcf, obj, key, str) FOR_EACH_ASSOC_STRING(_lastnumcf, obj, key, str)
@ -1547,11 +1709,13 @@ void TStampaEC_application::save_numec()
void TStampaEC_application::update_numec(const TRectype& clf, int sign) void TStampaEC_application::update_numec(const TRectype& clf, int sign)
{ {
if (_tiponumec > ' ' && clf.get_char(CLI_TIPOCF) == 'C') const char tipocf = clf.get_char(CLI_TIPOCF);
if (_tiponumec > ' ' && tipocf == 'C' && form().printing())
{ {
TForm_item& nec = form().find_field('H', odd_page, PEC_NUMPROG); TForm_item& nec = form().find_field('H', odd_page, PEC_NUMPROG);
if (nec.shown()) if (nec.shown())
{ {
const TString8 codcf = clf.get(CLI_CODCF);
TString16 num; TString16 num;
switch(_tiponumec) switch(_tiponumec)
{ {
@ -1559,12 +1723,8 @@ void TStampaEC_application::update_numec(const TRectype& clf, int sign)
if (sign > 0) if (sign > 0)
{ {
TString16 key; TString16 key;
key.format("%c|%s", tipocf, (const char*)codcf);
key.format("%s|%s", (const char *) clf.get(CLI_TIPOCF), const TRectype& cfven = cache().get(LF_CFVEN, key);
(const char *) clf.get(CLI_CODCF));
const TRectype & cfven = cache().get(LF_CFVEN, key);
num << (cfven.get_long("NUMESC")+1); num << (cfven.get_long("NUMESC")+1);
} }
break; break;
@ -1580,13 +1740,13 @@ void TStampaEC_application::update_numec(const TRectype& clf, int sign)
default: default:
break; break;
} }
if (num.not_empty()) if (num.full())
{ {
nec.set(num); nec.set(num);
_lastnumcf.add(clf.get(CLI_CODCF), num); _lastnumcf.add(codcf, num);
} }
else else
_lastnumcf.remove(clf.get(CLI_CODCF)); _lastnumcf.remove(codcf);
} }
} }
} }
@ -1598,19 +1758,21 @@ int TStampaEC_application::print_ec(TEC_Game_list* games)
TWait_cursor hourglass; TWait_cursor hourglass;
TEC_form& f = form(); TEC_form& f = form();
const bool printing = f.printing();
const TRectype& clf = f.cursor()->curr(); const TRectype& clf = f.cursor()->curr();
const TString16 lincf(clf.get(CLI_CODLIN));
bool ok = TRUE;
if (printing)
{
// make controllations per lingua profilo/CF // make controllations per lingua profilo/CF
if ((f.lingua() == _lingua_ditta && !lincf.empty()) || const TString& lincf = clf.get(CLI_CODLIN);
bool ok = true;
if ((f.lingua() == _lingua_ditta && lincf.full()) ||
f.lingua() != _lingua_ditta) f.lingua() != _lingua_ditta)
ok = lincf == f.lingua(); ok = lincf == f.lingua();
if (!ok) // Cliente analfabeta if (!ok) // Cliente analfabeta
return -1; return -1;
}
f.azzera_totali(); // Azzera totali di fine pagina f.azzera_totali(); // Azzera totali di fine pagina
@ -1629,10 +1791,12 @@ int TStampaEC_application::print_ec(TEC_Game_list* games)
TString status; TString status;
bool one_printed = FALSE; // Non ho stampato ancora nulla int printed = 0; // Non ho stampato ancora nulla
if (printing)
update_numec(clf, +1); // Incrementa contatore update_numec(clf, +1); // Incrementa contatore
TString16 last_game; TString8 last_game;
int last_year = 0; int last_year = 0;
for (cur = 0; cur.pos() < items; ++cur) for (cur = 0; cur.pos() < items; ++cur)
@ -1669,7 +1833,7 @@ int TStampaEC_application::print_ec(TEC_Game_list* games)
const TRiga_partite& riga = game.riga(r); const TRiga_partite& riga = game.riga(r);
if (riga.is_fattura()) if (riga.is_fattura())
{ {
const TDate dd(riga.get(PART_DATADOC)); const TDate dd = riga.get(PART_DATADOC);
if (dd >= data_chiuse) if (dd >= data_chiuse)
break; break;
} }
@ -1679,31 +1843,43 @@ int TStampaEC_application::print_ec(TEC_Game_list* games)
continue; continue;
} }
if (one_printed) if (printing)
{
if (printed)
{ {
TPrintrow empty; // Salta una riga vuota TPrintrow empty; // Salta una riga vuota
printer().print(empty); // (Non farlo alla fine di ogni partita!) printer().print(empty); // (Non farlo alla fine di ogni partita!)
} }
const bool printed = form().print_game(game);
if (printed)
one_printed = TRUE;
if (printer().frozen()) if (printer().frozen())
break; break;
} }
if (one_printed) if (f.print_game(game))
printed++;
}
if (printing)
{
if (printed > 0)
{ {
f.ultima_pagina(); f.ultima_pagina();
printer().formfeed(); printer().formfeed();
} }
else else
update_numec(clf, -1); update_numec(clf, -1);
}
else
{
if (printed > 0)
{
f.export_total();
// f.recordset().new_rec();
}
}
xvtil_statbar_set(NULL); xvtil_statbar_set(NULL);
return one_printed ? 1 : 0; return printed;
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -1745,33 +1921,44 @@ void TStampaEC_application::main_loop()
TEC_mask& m = mask(); TEC_mask& m = mask();
m.set(F_STAMPSALDO, "X"); m.set(F_STAMPSALDO, "X");
while (TRUE) while (true)
{ {
m.show(F_ULTIMOEC, _tiponumec == 'G'); m.show(F_ULTIMOEC, _tiponumec == 'G');
m.set(F_ULTIMOEC, _lastnumec); m.set(F_ULTIMOEC, _lastnumec);
if (m.run() != K_QUIT) const KEY k = m.run();
{ if (k == K_QUIT)
_form = new TEC_form(m, _gesval); break;
const bool excel = k != K_ENTER;
_form = new TEC_form(m, _gesval, excel);
_form->stampa_saldo(m.get_bool(F_STAMPSALDO));
if (!excel)
{
TForm_item& nec = _form->find_field('H', odd_page, PEC_NUMPROG); TForm_item& nec = _form->find_field('H', odd_page, PEC_NUMPROG);
if (nec.enabled() && nec.shown()) if (nec.enabled() && nec.shown())
{ {
nec.show(_tiponumec > ' ' && m.get_who() == 'C'); nec.show(_tiponumec > ' ' && m.get_who() == 'C');
_lastnumec = m.get_long(F_ULTIMOEC); _lastnumec = m.get_long(F_ULTIMOEC);
} }
}
_form->stampa_saldo(m.get_bool(F_STAMPSALDO));
if (m.get_bool(F_GROUPAGENT)) if (m.get_bool(F_GROUPAGENT))
print_agents(); print_agents();
else else
print_selected(); print_selected();
if (excel)
{
TFilename slk; slk.tempdir(); slk.add("ec.slk");
_form->recordset().save_as(slk, fmt_silk);
xvt_sys_goto_url(slk, "open");
}
delete _form; delete _form;
_form = NULL; _form = NULL;
}
else
break;
} }
} }

View File

@ -5,13 +5,20 @@ TOOLBAR "Toobar" 0 -3 0 3
BUTTON DLG_PRINT 10 2 BUTTON DLG_PRINT 10 2
BEGIN BEGIN
PROMPT -12 -11 "" PROMPT -13 -11 ""
MESSAGE EXIT,K_ENTER MESSAGE EXIT,K_ENTER
END END
BUTTON DLG_EDIT 10 2
BEGIN
PROMPT -23 -11 ""
PICTURE BMP_EDIT
MESSAGE EXIT,69
END
BUTTON DLG_QUIT 10 2 BUTTON DLG_QUIT 10 2
BEGIN BEGIN
PROMPT -22 -11 "" PROMPT -33 -11 ""
END END
ENDPAGE ENDPAGE

Some files were not shown because too many files have changed in this diff Show More