b0f462dc9e
git-svn-id: svn://10.65.10.50/trunk@2213 c028cbd2-c16b-5b4b-a496-9718f37d4682
305 lines
6.8 KiB
C++
Executable File
305 lines
6.8 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <config.h>
|
|
#include <form.h>
|
|
#include <printer.h>
|
|
#include <urldefid.h>
|
|
|
|
#include "../cg/saldacon.h"
|
|
#include "sc2.h"
|
|
#include "sc2101.h"
|
|
|
|
#include <clifo.h>
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TEC_row
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TEC_row : public TSortable
|
|
{
|
|
TString _causale;
|
|
TString _desc_causale;
|
|
TDate _data_doc;
|
|
TString _num_doc;
|
|
long _num_prot;
|
|
TImporto _totale_doc;
|
|
TDate _data_scad;
|
|
TImporto _importo;
|
|
TValuta _valuta;
|
|
|
|
protected: // TSortable
|
|
virtual int compare(const TSortable& s) const;
|
|
|
|
public:
|
|
TEC_row(const TRectype& rec);
|
|
virtual ~TEC_row() {}
|
|
};
|
|
|
|
TEC_row::TEC_row(const TRectype& rec)
|
|
{
|
|
if (rec.num() == LF_SCADENZE)
|
|
{
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Totalizzatore
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TTotal : TAssoc_array
|
|
{
|
|
public:
|
|
void add(const char* val, const TImporto& imp);
|
|
|
|
TTotal();
|
|
virtual ~TTotal() { }
|
|
};
|
|
|
|
void TTotal::add(const char* val, const TImporto& imp)
|
|
{
|
|
TObject* obj = objptr(val);
|
|
if (obj)
|
|
{
|
|
TImporto& tot = (TImporto&)*obj;
|
|
tot += imp;
|
|
}
|
|
else
|
|
{
|
|
add(val, imp);
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Form speciale per estratti conto
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TEC_form : public TForm
|
|
{
|
|
static TEC_form* _form;
|
|
|
|
TCursor* _cursore;
|
|
TTotal _totali;
|
|
|
|
protected:
|
|
static TEC_form& form() { return *_form; }
|
|
static void ec_header_handler(TPrinter& p);
|
|
static void ec_footer_handler(TPrinter& p);
|
|
|
|
public:
|
|
long move_cursor(const TRectype& rec);
|
|
|
|
TEC_form(const char* codice, TCursor* cursor);
|
|
virtual ~TEC_form();
|
|
};
|
|
|
|
TEC_form* TEC_form::_form = NULL;
|
|
|
|
void TEC_form::ec_header_handler(TPrinter& pr)
|
|
{
|
|
TPrint_section& head = form().section('H', 1);
|
|
|
|
head.reset();
|
|
pr.resetheader();
|
|
|
|
head.update();
|
|
for (word j = 0; j < head.height(); j++)
|
|
pr.setheaderline(j, head.row(j));
|
|
}
|
|
|
|
|
|
void TEC_form::ec_footer_handler(TPrinter& p)
|
|
{
|
|
TRACE("Stamperei un footer");
|
|
}
|
|
|
|
long TEC_form::move_cursor(const TRectype& rec)
|
|
{
|
|
cursor()->file().curr() = rec;
|
|
const long r = cursor()->read();
|
|
return r;
|
|
}
|
|
|
|
TEC_form::TEC_form(const char* codice, TCursor* cur)
|
|
: TForm(BASE_EC_PROFILE, codice)
|
|
{
|
|
_form = this;
|
|
_cursore = cur;
|
|
|
|
TPrinter& pr = printer();
|
|
|
|
pr.setheaderhandler(ec_header_handler);
|
|
pr.headerlen(section('H', 1).height());
|
|
|
|
pr.setfooterhandler(ec_footer_handler);
|
|
pr.footerlen(section('F', 1).height());
|
|
}
|
|
|
|
TEC_form::~TEC_form()
|
|
{
|
|
TPrinter& pr = printer();
|
|
pr.setheaderhandler(NULL);
|
|
pr.setfooterhandler(NULL);
|
|
_form = NULL;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Stampa estratti conto
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TStampaEC_application : public TApplication
|
|
{
|
|
TEC_mask* _msk;
|
|
TEC_form* _form;
|
|
|
|
TString _lingua;
|
|
TString _linprof;
|
|
bool _gesval;
|
|
|
|
protected: // TApplication
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual bool menu(MENU_TAG m);
|
|
virtual void on_firm_change();
|
|
|
|
public:
|
|
static TStampaEC_application& app() { return (TStampaEC_application&)main_app(); }
|
|
|
|
public:
|
|
TEC_mask& mask() { return *_msk; }
|
|
TCursor_sheet& sheet() { return _msk->cur_sheet(); }
|
|
TEC_form& form() { return *_form; }
|
|
|
|
bool select_ec(); // starting point
|
|
bool print_selected(); // print selected items
|
|
bool print_ec(); // print one item
|
|
|
|
TStampaEC_application();
|
|
virtual ~TStampaEC_application() {}
|
|
};
|
|
|
|
bool TStampaEC_application::select_ec()
|
|
{
|
|
TEC_mask& m = mask();
|
|
while (m.run() != K_ESC)
|
|
{
|
|
_linprof = m.get_prof_lang();
|
|
_form = new TEC_form(m.get_prof_code(), sheet().cursor());
|
|
|
|
print_selected();
|
|
|
|
delete _form;
|
|
_form = NULL;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaEC_application::print_selected()
|
|
{
|
|
TCursor_sheet& s = sheet();
|
|
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
|
|
|
|
printer().open();
|
|
|
|
TCursor& c = *s.cursor();
|
|
const long items = c.items();
|
|
for (long i = 0; i < items; i++) if (print_all || s.checked(i))
|
|
{
|
|
c = i;
|
|
form().move_cursor(c.file().curr());
|
|
|
|
const bool ok = print_ec();
|
|
if (!ok) analfabeti++;
|
|
}
|
|
|
|
printer().close();
|
|
|
|
if (analfabeti > 0)
|
|
warning_box("%ld clienti/fornitori non sono stati stmapati in quanto "
|
|
"il codice lingua non corrispondeva al profilo di stampa", analfabeti);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaEC_application::print_ec()
|
|
{
|
|
TEC_form& f = form();
|
|
|
|
const TRectype& clf = f.cursor()->file().curr();
|
|
const TString lincf(clf.get(CLI_CODLIN));
|
|
|
|
bool ok = TRUE;
|
|
|
|
// make controllations per lingua profilo/CF
|
|
if ((_linprof == _lingua && !lincf.empty()) || _linprof != _lingua)
|
|
ok = lincf == _linprof;
|
|
|
|
if (!ok) // Cliente analfabeta
|
|
return FALSE;
|
|
|
|
TRectype filter(LF_PARTITE);
|
|
filter.put(PART_TIPOCF, clf.get(CLI_TIPOCF));
|
|
filter.put(PART_SOTTOCONTO, clf.get(CLI_CODCF));
|
|
|
|
TLocalisamfile& partite = f.cursor()->file(LF_PARTITE);
|
|
for (int err = partite.read();
|
|
err == NOERR && partite.curr() == filter;
|
|
err = partite.read(_isgreat))
|
|
{
|
|
TPartita game(partite.curr());
|
|
for (int r = game.last(); r > 0; r = game.pred(r))
|
|
{
|
|
}
|
|
|
|
partite.put(PART_NUMRIG, 9999);
|
|
}
|
|
|
|
printer().formfeed();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Generic TApplication methods
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool TStampaEC_application::create()
|
|
{
|
|
TApplication::create();
|
|
|
|
_msk = new TEC_mask("sc2100a");
|
|
|
|
dispatch_e_menu(MENU_ITEM(1));
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaEC_application::destroy()
|
|
{
|
|
delete _msk;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
void TStampaEC_application::on_firm_change()
|
|
{
|
|
TApplication::on_firm_change();
|
|
TConfig c(CONFIG_DITTA, "cg");
|
|
_lingua = c.get("CodLin");
|
|
_gesval = c.get_bool("GesVal");
|
|
}
|
|
|
|
bool TStampaEC_application::menu(MENU_TAG m)
|
|
{
|
|
select_ec();
|
|
return FALSE;
|
|
}
|
|
|
|
TStampaEC_application::TStampaEC_application()
|
|
: _lingua(1), _linprof(1), _msk(NULL), _form(NULL)
|
|
{}
|
|
|
|
int sc2100(int argc, char** argv)
|
|
{
|
|
TStampaEC_application app;
|
|
app.run(argc, argv, "Stampa Estratti Conto");
|
|
return 0;
|
|
}
|