2001-12-17 22:59:39 +00:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
// Stampa documenti
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <applicat.h>
|
|
|
|
#include <config.h>
|
|
|
|
#include <defmask.h>
|
|
|
|
#include <form.h>
|
|
|
|
#include <printer.h>
|
|
|
|
#include <progind.h>
|
|
|
|
#include <sheet.h>
|
2001-12-18 15:15:54 +00:00
|
|
|
#include <lffiles.h>
|
|
|
|
#include <utility.h>
|
2001-12-17 22:59:39 +00:00
|
|
|
|
|
|
|
#include <doc.h>
|
|
|
|
#include <rdoc.h>
|
2001-12-18 15:15:54 +00:00
|
|
|
#include "../ve/velib.h"
|
2001-12-17 22:59:39 +00:00
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
#include "si0200a.h"
|
2001-12-17 22:59:39 +00:00
|
|
|
|
|
|
|
class TDocisamfile : public TLocalisamfile
|
|
|
|
{
|
2001-12-18 15:15:54 +00:00
|
|
|
TDocumento _doc;
|
2001-12-17 22:59:39 +00:00
|
|
|
|
|
|
|
public:
|
2001-12-18 15:15:54 +00:00
|
|
|
virtual TRectype& curr() const { return (TRectype&) _doc; }
|
2001-12-17 22:59:39 +00:00
|
|
|
virtual int readat(TRecnotype nrec, word lockop = _nolock);
|
2001-12-18 15:15:54 +00:00
|
|
|
TDocisamfile() : TLocalisamfile(LF_DOC) {}
|
2001-12-17 22:59:39 +00:00
|
|
|
virtual ~TDocisamfile() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
int TDocisamfile::readat(TRecnotype nrec, word lockop)
|
|
|
|
{
|
|
|
|
int err = TBaseisamfile::readat(nrec, _nolock);
|
|
|
|
if (err == NOERR)
|
2001-12-18 15:15:54 +00:00
|
|
|
err = _doc.read(TBaseisamfile::curr());
|
2001-12-17 22:59:39 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
class TListe_form : public TForm
|
2001-12-17 22:59:39 +00:00
|
|
|
{
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
// @access Protected Member
|
2001-12-17 22:59:39 +00:00
|
|
|
protected:
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
public:
|
|
|
|
virtual bool validate(TForm_item& fld, TToken_string& val);
|
|
|
|
TListe_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") : TForm(form, code, editlevel, desc) {}
|
|
|
|
virtual ~TListe_form() {}
|
2001-12-17 22:59:39 +00:00
|
|
|
};
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
bool TListe_form::validate(TForm_item& fld, TToken_string& val)
|
|
|
|
{
|
|
|
|
return TForm::validate(fld, val);
|
2001-12-17 22:59:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
class TListe_application: public TSkeleton_application
|
|
|
|
{
|
|
|
|
TMask * _select_mask;
|
|
|
|
TListe_form * _form;
|
|
|
|
TFilename _formname;
|
|
|
|
|
2001-12-17 22:59:39 +00:00
|
|
|
protected:
|
|
|
|
virtual bool create();
|
|
|
|
virtual bool destroy();
|
2001-12-18 15:15:54 +00:00
|
|
|
char tipo_lista() const { return _formname[6]; }
|
|
|
|
void set_limits();
|
2001-12-17 22:59:39 +00:00
|
|
|
virtual void main_loop();
|
2001-12-19 20:51:39 +00:00
|
|
|
virtual const char * extra_modules() const { return "BA"; }
|
2001-12-17 22:59:39 +00:00
|
|
|
|
|
|
|
public:
|
2001-12-18 15:15:54 +00:00
|
|
|
TListe_application() : _select_mask(NULL), _form(NULL) {};
|
|
|
|
virtual ~TListe_application() {};
|
2001-12-17 22:59:39 +00:00
|
|
|
};
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
inline TListe_application& app() { return (TListe_application&) main_app(); }
|
2001-12-17 22:59:39 +00:00
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
bool TListe_application::create()
|
|
|
|
{
|
|
|
|
if (argc() < 3)
|
|
|
|
return error_box("manca il nome del form di stampa");
|
2001-12-17 22:59:39 +00:00
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART,
|
|
|
|
LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON,
|
|
|
|
LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0);
|
|
|
|
_formname == argv(2);
|
|
|
|
_select_mask = new TMask("ve0200a");
|
|
|
|
_form = new TListe_form(_formname);
|
|
|
|
|
|
|
|
return TSkeleton_application::create();
|
2001-12-17 22:59:39 +00:00
|
|
|
}
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
void TListe_application::set_limits()
|
|
|
|
{
|
|
|
|
TCursor * c = _form->cursor();
|
|
|
|
TRelation * r = c->relation();
|
|
|
|
TString16 tipo(_select_mask->get(F_TIPOCF));
|
|
|
|
TString16 cli_fr(_select_mask->get(F_CODFR));
|
|
|
|
TString16 cli_to(_select_mask->get(F_CODTO));
|
|
|
|
TRectype from(LF_CLIFO);
|
|
|
|
from.put("TIPOCF", tipo);
|
|
|
|
TRectype to(from);
|
|
|
|
|
|
|
|
if (cli_fr.empty() && cli_to.empty())
|
|
|
|
{
|
|
|
|
TString16 rag_fr(_select_mask->get(F_RAGSOCFR));
|
|
|
|
if (rag_fr.not_empty())
|
|
|
|
from.put("RAGSOC", rag_fr);
|
|
|
|
TString16 rag_to(_select_mask->get(F_RAGSOCTO));
|
|
|
|
if (rag_to.not_empty())
|
|
|
|
to.put("RAGSOC", rag_to);
|
|
|
|
r->lfile().setkey(2);
|
|
|
|
|
2001-12-17 22:59:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-12-18 15:15:54 +00:00
|
|
|
TString16 cli_fr(_select_mask->get(F_CODFR));
|
|
|
|
if (cli_fr.not_empty())
|
|
|
|
from.put("CODCF", cli_fr);
|
|
|
|
TString16 rag_to(_select_mask->get(F_CODTO));
|
|
|
|
if (rag_to.not_empty())
|
|
|
|
to.put("CODCF", cli_to);
|
|
|
|
r->lfile().setkey(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
c->setregion(from, to);
|
|
|
|
TString filter;
|
|
|
|
|
|
|
|
filter << format("((33->ANNO == %d)", _select_mask->get_int(F_ANNO));
|
|
|
|
filter << format("&& (33->PROVV == %c)", _select_mask->get(F_PROVV)[0]);
|
|
|
|
TSheet_field & s = _select_mask->sfield(F_SHEETNUMS);
|
|
|
|
const int rows = s.items();
|
|
|
|
|
|
|
|
for (int i = 0; i < rows; i++)
|
|
|
|
{
|
|
|
|
TString numfilter("&& (");
|
|
|
|
TToken_string r = s.row(i);
|
|
|
|
|
|
|
|
numfilter << format("33->CODNUM == %s", (const char *)r.get(0));
|
|
|
|
|
|
|
|
for (int j = 0; j < 6; j++)
|
|
|
|
{
|
|
|
|
const int stato = r.get_int();
|
|
|
|
|
|
|
|
if (stato > 0)
|
|
|
|
numfilter << format("&& (33->STATO == %d)", stato);
|
|
|
|
}
|
|
|
|
if (numfilter.not_empty())
|
|
|
|
filter << numfilter;
|
|
|
|
}
|
|
|
|
TDate data_fr(_select_mask->get(F_DA_DATADOC));
|
|
|
|
if (data_fr.ok())
|
|
|
|
filter << format("&& (33->DATADOC >= %s)", (const char *) data_fr.string(ANSI));
|
|
|
|
TDate data_to(_select_mask->get(F_A_DATADOC));
|
|
|
|
if (data_to.ok())
|
|
|
|
filter << format("&& (33->DATADOC >= %s)", (const char *) data_to.string(ANSI));
|
|
|
|
TDate art_fr(_select_mask->get(F_DA_DATADOC));
|
|
|
|
if (art_fr.ok())
|
|
|
|
filter << format("&& (34->CODARTMAG >= %s)", (const char *) art_fr);
|
|
|
|
TDate art_to(_select_mask->get(F_A_DATADOC));
|
|
|
|
if (art_to.ok())
|
|
|
|
filter << format("&& (34->CODARTMAG >= %s)", (const char *) art_to);
|
|
|
|
filter << ")";
|
|
|
|
|
|
|
|
c->setfilter(filter, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TListe_application::destroy()
|
|
|
|
{
|
|
|
|
delete _select_mask;
|
|
|
|
delete _form;
|
2001-12-17 22:59:39 +00:00
|
|
|
return TApplication::destroy();
|
|
|
|
}
|
|
|
|
|
2001-12-18 15:15:54 +00:00
|
|
|
void TListe_application::main_loop()
|
2001-12-17 22:59:39 +00:00
|
|
|
{
|
2001-12-18 15:15:54 +00:00
|
|
|
while (_select_mask->run())
|
|
|
|
{
|
|
|
|
set_limits();
|
|
|
|
_form->print();
|
2001-12-17 22:59:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do all the work!
|
|
|
|
int si0200(int argc, char* argv[])
|
|
|
|
{
|
2001-12-18 15:15:54 +00:00
|
|
|
TListe_application a;
|
2001-12-17 22:59:39 +00:00
|
|
|
a.run(argc, argv, "Lista documenti");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|