3985 lines
109 KiB
C++
Executable File
3985 lines
109 KiB
C++
Executable File
// Stampa quadro
|
|
#include <xvt.h>
|
|
|
|
#include <applicat.h>
|
|
#include <relation.h>
|
|
#include <config.h>
|
|
#include <mask.h>
|
|
#include <form.h>
|
|
#include <printer.h>
|
|
#include <progind.h>
|
|
#include "base.h"
|
|
#include <urldefid.h>
|
|
|
|
#include <nditte.h>
|
|
#include <anagr.h>
|
|
#include "quadrod.h"
|
|
#include "quadrod1.h"
|
|
#include "quadrogd.h"
|
|
#include "quadrif.h"
|
|
#include "77stqd.h"
|
|
#include "77lib.h"
|
|
|
|
//
|
|
// Lista modifiche
|
|
//
|
|
// 3.4.96 Nella stampa per Modulaser, aggiunto all'inizio un comando per settare
|
|
// il font della stampante a 17cpi (v.riga 176)
|
|
//
|
|
|
|
|
|
// Chincaglieria che serve per posiziona()
|
|
typedef long HWND;
|
|
HIDDEN const int MAX_LEN = 300;
|
|
extern "C" {
|
|
BOOLEAN PrintLineNow( char *pData, word cbBytes, HWND hInst );
|
|
};
|
|
|
|
|
|
HIDDEN TString16 __dep16;
|
|
HIDDEN TString80 __dep80;
|
|
|
|
// Vega-Key di Modulaser
|
|
HIDDEN const char* VK_STARTDOC = "<VK>&MA795&0&1";
|
|
HIDDEN const char* VK_ENDDOC = "<VK>!0";
|
|
HIDDEN const char* VK_STARTPAGE[] = { "<VK>*9*1", "<VK>*9*2", "<VK>*9*3", "<VK>*9*4" };
|
|
typedef enum { STARTDOC, STARTDITTA, STARTPAGE, ENDDOC } ModulaserKey;
|
|
|
|
// Campi form
|
|
#define TOT_TOTALE 1
|
|
#define TOT_SNSRIT 2
|
|
#define TOT_IMPON 3
|
|
#define TOT_IMPOR 4
|
|
#define TOT_NETTO 5
|
|
#define H_COFI_DIC 13
|
|
#define H_NUM_FOGLIO 14
|
|
|
|
// Quadro D
|
|
HIDDEN const int QD_FORMLEN_PRIMA = 70; // 72 - 3 (3 e' la posizione della X di posiz.)
|
|
HIDDEN const int QD_FORMLEN = 72;
|
|
HIDDEN const int POS_DITTA = 120; // Colonna del codice ditta a pie' di modulo
|
|
HIDDEN const int QD_PAGINE = 4;
|
|
HIDDEN const int QD_RIGHE_PRIMA = 5;
|
|
HIDDEN const int QD_RIGHE_SECONDA = 7;
|
|
HIDDEN const int QD_RIGHE_TERZA = 6;
|
|
HIDDEN const int QD_RIGHE_QUARTA = 6;
|
|
HIDDEN const int HEADER_SECONDA = 7;
|
|
HIDDEN const int HEADER_TERZA = 8; // Sarebbero 9 col righello...
|
|
HIDDEN const int HEADER_QUARTA = 14; // 15 col righello...
|
|
|
|
typedef enum { PRIMA=1, SECONDA, TERZA, QUARTA } PaginaQuadro;
|
|
typedef enum { fisiche, nofisiche } TipoPagina;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Quadro D
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TDicForm : public TForm
|
|
{
|
|
private:
|
|
real _f_tot_totale, _f_tot_snsrit, _f_tot_impon, _f_tot_impor, _f_tot_netto;
|
|
real _nf_tot_totale, _nf_tot_snsrit, _nf_tot_impon, _nf_tot_impor, _nf_tot_netto;
|
|
void aggiorna_totali_C(const char tipo);
|
|
void aggiorna_totali_D(const char tipo);
|
|
void aggiorna_totali_D1(const char tipo);
|
|
void aggiorna_totali_E(const char tipo);
|
|
void aggiorna_totali_E1(const char tipo);
|
|
|
|
TCursor* _cur;
|
|
|
|
protected:
|
|
long _Items; // numero di record che hanno passato il filtro
|
|
PaginaQuadro _PaginaCorrente;
|
|
|
|
void set_curr_page(PaginaQuadro pagina) { _PaginaCorrente = pagina; }
|
|
virtual void inc_curr_page();
|
|
virtual void next_page(TPrinter& pr);
|
|
bool _modulaser; // se stampa per modulaser
|
|
bool _posiziona; // se deve fare posizionamento
|
|
TipoDitta _tipo_ditta; // tipo ditta: normale, estinto, dichiarante
|
|
int _num_foglio; // numero foglio
|
|
TString _cofi_dic; // cod.fis. dichiarante
|
|
bool _can_print_tot_fis, _can_print_tot_nofis;
|
|
bool _finite_fis, _finite_nofis, _LastDitta, _EndPrintDitta;
|
|
bool _GiaStampatiFis, _GiaStampatiNoFis, _PaginaPosizionamento;
|
|
bool _GiaPosizionato, _GiaMessoStartDoc, _GiaMessoStartPage[QD_PAGINE]; // flag per modulaser
|
|
int _CtrNoFisStampati, _CtrFisStampati; // contatori p.f. e p.g. stampate
|
|
long _codditta; // ditta in stampa
|
|
int _RigaCorr; // contatore riga corrente
|
|
TString16 _quadro; // codice quadro in stampa
|
|
|
|
virtual TCursor* cursor() const { return _cur; }
|
|
virtual TRelation* relation() const { return _cur->relation(); }
|
|
|
|
void stampa_testata(TPrinter& pr);
|
|
virtual void stampa_totali(TPrinter& pr);
|
|
virtual void aggiorna_totali(const char tipo);
|
|
virtual void set_body(TPrinter& pr, const char tipo);
|
|
void StampaPagina(PaginaQuadro PaginaCorrente, const bool StampaTotali, const long Fis, const long NoFis);
|
|
void posiziona();
|
|
void fill_page(TPrinter& pr, const int righe);
|
|
void jump_to_line(TPrinter& pr, const int riga);
|
|
void put_modulaser(TPrintrow& row, ModulaserKey key, int page=0);
|
|
void ClearFlagModulaser();
|
|
bool PaginaPosizionamento() const;
|
|
virtual bool InitPrint(const long codditta);
|
|
|
|
public:
|
|
|
|
virtual long filtra(const long codditta);
|
|
|
|
TProgind* _prog; // progind usata in print()
|
|
|
|
long codditta() const { return _codditta; }
|
|
void set_codditta(const long ditta) { _codditta = ditta; }
|
|
void set_posiziona(const bool posiz) { _posiziona = posiz; _GiaPosizionato = FALSE; }
|
|
void can_print_tot_fis(const bool canpr) { _can_print_tot_fis = canpr; }
|
|
void can_print_tot_nofis(const bool canpr) { _can_print_tot_nofis = canpr; }
|
|
void set_last_ditta(const bool last) { _LastDitta = last; }
|
|
bool last_ditta() const { return _LastDitta; }
|
|
bool EndJob() const { return _LastDitta && _EndPrintDitta; }
|
|
bool ultima_fis();
|
|
bool ultima_nofis();
|
|
TString& cofi_dic() { return _cofi_dic; }
|
|
void set_cofi_dic(const char* cofi) { _cofi_dic = cofi; }
|
|
TipoDitta tipo_ditta() const { return _tipo_ditta; }
|
|
void set_tipo_ditta(TipoDitta tipo) { _tipo_ditta = tipo; }
|
|
bool modulaser() const { return _modulaser; }
|
|
void set_modulaser(const bool modul) { _modulaser = modul; }
|
|
void set_num_foglio(const int foglio) { _num_foglio = foglio; }
|
|
int num_foglio() const { return _num_foglio; }
|
|
virtual void azzera_totali();
|
|
PaginaQuadro curr_page() const { return _PaginaCorrente; }
|
|
TCursor& cur();
|
|
|
|
void set_progind(TProgind* prog) { _prog = prog; }
|
|
TProgind* progind() { return _prog; }
|
|
bool usa_progind() const { return _prog != NULL; }
|
|
|
|
virtual void set_cursor(TCursor* cur);
|
|
virtual void close_print();
|
|
virtual bool print(const long codditta, const long NumFis, const long NumNoFis);
|
|
|
|
const TString& quadro() const { return _quadro; }
|
|
|
|
TDicForm(const char* form, const char* quadro);
|
|
virtual ~TDicForm() {}
|
|
};
|
|
|
|
TCursor& TDicForm::cur()
|
|
{
|
|
return *_cur;
|
|
}
|
|
|
|
void TDicForm::set_cursor(TCursor* cur)
|
|
{
|
|
_cur = cur;
|
|
}
|
|
|
|
TDicForm::TDicForm(const char* form, const char* quadro)
|
|
: TForm(form), _quadro(quadro), _prog(NULL)
|
|
{
|
|
_can_print_tot_fis = _can_print_tot_nofis = FALSE;
|
|
_GiaStampatiFis = _GiaStampatiNoFis = _GiaMessoStartDoc = FALSE;
|
|
_GiaPosizionato = _posiziona = _modulaser = FALSE;
|
|
_LastDitta = _EndPrintDitta = _PaginaPosizionamento = FALSE;
|
|
ClearFlagModulaser();
|
|
}
|
|
|
|
long TDicForm::filtra(const long codditta)
|
|
{
|
|
TString filtr(24);
|
|
filtr.format("CODDITTA=%ld", codditta);
|
|
|
|
_cur->setfilter(filtr, TRUE);
|
|
const long items = _cur->items();
|
|
|
|
return items;
|
|
}
|
|
|
|
|
|
bool TDicForm::InitPrint(const long codditta)
|
|
{
|
|
_codditta = codditta;
|
|
_RigaCorr = 0;
|
|
|
|
TPrinter& pr = printer();
|
|
pr.set_offset(offset_y(), offset_x());
|
|
pr.set_char_size(fontsize()); // Set font name and size
|
|
pr.set_fontname(fontname()); // according to current form
|
|
|
|
if (_posiziona && !_GiaPosizionato && pr.printtype() == winprinter)
|
|
{
|
|
posiziona();
|
|
#ifdef DBG
|
|
if (!yesno_box("Proseguire con la stampa ?"))
|
|
return FALSE;
|
|
#endif
|
|
}
|
|
|
|
const bool was_open = pr.isopen();
|
|
|
|
set_last_page(FALSE);
|
|
set_background(1, TRUE);
|
|
set_curr_page(PRIMA);
|
|
|
|
if (!was_open && !pr.open())
|
|
return FALSE;
|
|
do_events();
|
|
|
|
_Items = filtra(codditta);
|
|
|
|
if (_Items == 0L) // Se non ci sono record non stampa
|
|
return FALSE;
|
|
|
|
if (_prog)
|
|
{
|
|
delete _prog;
|
|
_prog = NULL;
|
|
}
|
|
if (pr.printtype() != screenvis)
|
|
{
|
|
TString msg(60);
|
|
msg.format("Elaborazione in corso ditta %ld", codditta);
|
|
_prog = new TProgind(_Items, msg, FALSE,TRUE);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TDicForm::close_print()
|
|
{
|
|
if (_prog)
|
|
{
|
|
delete _prog;
|
|
_prog = NULL;
|
|
}
|
|
}
|
|
|
|
bool TDicForm::print(const long codditta, const long NumFis, const long NumNoFis)
|
|
{
|
|
bool StabilitaInesistenzaNoFis = FALSE;
|
|
bool StabilitaInesistenzaFis = FALSE;
|
|
long CtrFis = NumFis;
|
|
long CtrNoFis = NumNoFis;
|
|
long PtrFis = -1L, PtrNoFis=-1L;
|
|
TPrinter& pr = printer();
|
|
|
|
_CtrFisStampati = _CtrNoFisStampati = 0;
|
|
_finite_fis = _finite_nofis = FALSE;
|
|
_GiaStampatiFis = _GiaStampatiNoFis = FALSE;
|
|
_EndPrintDitta = FALSE; // Vero se stampato l'ultimo record
|
|
bool LastRecord = FALSE; // Vero se letto l'ultimo record
|
|
|
|
_PaginaCorrente = PRIMA;
|
|
|
|
if (!InitPrint(codditta))
|
|
return FALSE;
|
|
|
|
TCursor* cur = cursor();
|
|
|
|
while (!_EndPrintDitta)
|
|
{
|
|
for (int pagina=1; pagina <= QD_PAGINE; pagina++, next_page(pr))
|
|
{
|
|
pr.formlen(QD_FORMLEN);
|
|
|
|
if (_PaginaCorrente == PRIMA)
|
|
{
|
|
if (_modulaser) ClearFlagModulaser();
|
|
|
|
for (int righe=0; righe < QD_RIGHE_PRIMA; righe++)
|
|
{
|
|
// Stampa intestazione, solo sul primo foglio.
|
|
if (!righe)
|
|
{
|
|
(*cur) = PtrFis >= 0L ? PtrFis : 0L;
|
|
stampa_testata(pr);
|
|
}
|
|
|
|
if (_finite_fis || StabilitaInesistenzaFis)
|
|
break;
|
|
|
|
// La prima volta si deve posizionare sul primo record di p.f.
|
|
if (PtrFis<0L && !StabilitaInesistenzaFis)
|
|
{
|
|
bool Trovato = FALSE;
|
|
|
|
while (!Trovato)
|
|
{
|
|
const long ditta = cur->curr().get_long(QUD_CODDITTA);
|
|
if (ditta != codditta)
|
|
break;
|
|
const char tipo = cur->curr().get(QUD_TIPOA)[0];
|
|
if (tipo != 'G')
|
|
{
|
|
PtrFis = cur->pos();
|
|
Trovato = TRUE;
|
|
break;
|
|
}
|
|
else
|
|
++(*cur);
|
|
}
|
|
StabilitaInesistenzaFis = !Trovato;
|
|
}
|
|
|
|
if (StabilitaInesistenzaFis)
|
|
break;
|
|
|
|
(*cur) = PtrFis;
|
|
const char tipo = cur->curr().get(QUD_TIPOA)[0];
|
|
|
|
if (tipo != 'F')
|
|
break;
|
|
else
|
|
{
|
|
CtrFis--;
|
|
if (CtrFis == 0L) _finite_fis = TRUE;
|
|
set_body(pr, 'F');
|
|
// La stampa e' finita se ho STAMPATO l'ultimo record
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
_EndPrintDitta = LastRecord;
|
|
if (!LastRecord)
|
|
{
|
|
++(*cur);
|
|
PtrFis = cur->pos();
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
}
|
|
}
|
|
} // for righe..
|
|
PtrFis = cur->pos();
|
|
}
|
|
|
|
if (_PaginaCorrente == SECONDA)
|
|
{
|
|
// Reset del flag di pagina con posiz.
|
|
if (_posiziona && _PaginaPosizionamento) _PaginaPosizionamento = FALSE;
|
|
for (int righe=0; righe < QD_RIGHE_SECONDA; righe++)
|
|
{
|
|
if (!righe)
|
|
fill_page(pr, HEADER_SECONDA);
|
|
|
|
if (_finite_fis || StabilitaInesistenzaFis)
|
|
break;
|
|
|
|
(*cur) = PtrFis;
|
|
const char tipo = cur->curr().get(QUD_TIPOA)[0];
|
|
|
|
if (tipo != 'F')
|
|
break;
|
|
else
|
|
{
|
|
CtrFis--;
|
|
if (CtrFis == 0L) _finite_fis = TRUE;
|
|
set_body(pr, 'F');
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
_EndPrintDitta = LastRecord;
|
|
if (!LastRecord)
|
|
{
|
|
++(*cur);
|
|
PtrFis = cur->pos();
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
}
|
|
}
|
|
}
|
|
PtrFis = cur->pos();
|
|
}
|
|
|
|
if (_PaginaCorrente == TERZA)
|
|
{
|
|
for (int righe=0; righe < QD_RIGHE_TERZA; righe++)
|
|
{
|
|
if (!righe)
|
|
{
|
|
fill_page(pr, HEADER_TERZA);
|
|
_CtrFisStampati = 0; // conta quelli che stampo sulla terza
|
|
}
|
|
|
|
if (_finite_fis || StabilitaInesistenzaFis)
|
|
break;
|
|
|
|
(*cur) = PtrFis;
|
|
const char tipo = cur->curr().get(QUD_TIPOA)[0];
|
|
|
|
if (tipo != 'F')
|
|
break;
|
|
else
|
|
{
|
|
CtrFis--;
|
|
if (CtrFis == 0L) _finite_fis = TRUE;
|
|
set_body(pr, 'F');
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
_EndPrintDitta = LastRecord;
|
|
_CtrFisStampati++;
|
|
if (!LastRecord)
|
|
{
|
|
++(*cur);
|
|
PtrFis = cur->pos();
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
}
|
|
}
|
|
}
|
|
PtrFis = cur->pos();
|
|
}
|
|
|
|
if (_PaginaCorrente == QUARTA)
|
|
{
|
|
for (int righe=0; righe < QD_RIGHE_QUARTA; righe++)
|
|
{
|
|
if (!righe)
|
|
_CtrNoFisStampati = 0;
|
|
|
|
// All'inizio salta le righe in alto
|
|
if (!righe)
|
|
fill_page(pr, HEADER_QUARTA);
|
|
|
|
if (_finite_nofis || StabilitaInesistenzaNoFis)
|
|
break;
|
|
|
|
// La prima volta si deve posizionare sul primo record di p.g.
|
|
if (PtrNoFis<0L && !StabilitaInesistenzaNoFis)
|
|
{
|
|
bool Trovato = FALSE;
|
|
bool eof = FALSE;
|
|
(*cur) = PtrFis-1 > 0L ? PtrFis-1 : 0L; // parti dall'inizio
|
|
while (!Trovato && !eof)
|
|
{
|
|
eof = cur->pos() >= _Items-1;
|
|
const long ditta = cur->curr().get_long(QUD_CODDITTA);
|
|
if (ditta != codditta)
|
|
break;
|
|
const char tipo = cur->curr().get(QUD_TIPOA)[0];
|
|
if (tipo != 'F')
|
|
{
|
|
PtrNoFis = cur->pos();
|
|
Trovato = TRUE;
|
|
break;
|
|
}
|
|
else
|
|
++(*cur);
|
|
}
|
|
StabilitaInesistenzaNoFis = !Trovato;
|
|
}
|
|
|
|
if (StabilitaInesistenzaNoFis)
|
|
break;
|
|
|
|
(*cur) = PtrNoFis;
|
|
const char tipo = cur->curr().get(QUD_TIPOA)[0];
|
|
|
|
if (tipo != 'G')
|
|
break;
|
|
else
|
|
{
|
|
CtrNoFis--;
|
|
if (CtrNoFis == 0L) _finite_nofis = TRUE;
|
|
set_body(pr, 'G');
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
_EndPrintDitta = LastRecord;
|
|
_CtrNoFisStampati++;
|
|
if (!LastRecord)
|
|
{
|
|
++(*cur);
|
|
PtrNoFis = cur->pos();
|
|
LastRecord = cur->pos() >= _Items-1;
|
|
}
|
|
}
|
|
}
|
|
PtrNoFis = cur->pos();
|
|
}
|
|
} // for pagina..
|
|
} // while !_EndPrintDitta
|
|
close_print();
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void TDicForm::ClearFlagModulaser()
|
|
{
|
|
for (int i=0; i<=QD_PAGINE; i++)
|
|
_GiaMessoStartPage[i] = FALSE;
|
|
}
|
|
|
|
bool TDicForm::ultima_fis()
|
|
{
|
|
return _can_print_tot_fis && _finite_fis && !_GiaStampatiFis;
|
|
}
|
|
|
|
bool TDicForm::ultima_nofis()
|
|
{
|
|
return _can_print_tot_nofis && _finite_nofis && !_GiaStampatiNoFis;
|
|
}
|
|
|
|
void TDicForm::inc_curr_page()
|
|
{
|
|
if (_PaginaCorrente == PRIMA)
|
|
_PaginaCorrente = SECONDA;
|
|
else
|
|
if (_PaginaCorrente == SECONDA)
|
|
_PaginaCorrente = TERZA;
|
|
else
|
|
if (_PaginaCorrente == TERZA)
|
|
_PaginaCorrente = QUARTA;
|
|
else
|
|
if (_PaginaCorrente == QUARTA)
|
|
_PaginaCorrente = PRIMA;
|
|
}
|
|
|
|
void TDicForm::put_modulaser(TPrintrow& row, ModulaserKey Cmd, int page)
|
|
{
|
|
TString riga(80);
|
|
|
|
switch (Cmd)
|
|
{
|
|
case STARTDOC:
|
|
if (!_GiaMessoStartDoc)
|
|
{
|
|
// riga = VK_STARTDOC;
|
|
riga = "\xf"; // Printer escape: font 17cpi
|
|
riga << VK_STARTDOC;
|
|
_GiaMessoStartDoc = TRUE;
|
|
}
|
|
break;
|
|
case STARTDITTA:
|
|
{
|
|
TString cofi(16);
|
|
const char* tmp = _cur->file(-116).get(ANA_COFI);
|
|
cofi.format("%-16s", tmp);
|
|
TString ragsoc(50);
|
|
ragsoc = _cur->file(LF_NDITTE).get(NDT_RAGSOC);
|
|
riga = "<VK>$";
|
|
riga << cofi;
|
|
riga << "$0$";
|
|
riga << ragsoc;
|
|
}
|
|
break;
|
|
case STARTPAGE:
|
|
riga = "<VK>*9*";
|
|
riga << page;
|
|
_GiaMessoStartPage[page] = TRUE;
|
|
break;
|
|
case ENDDOC:
|
|
riga = VK_ENDDOC;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
riga.rtrim();
|
|
riga << '\r';
|
|
row.put(riga);
|
|
}
|
|
|
|
|
|
bool TDicForm::PaginaPosizionamento() const
|
|
{
|
|
return _PaginaPosizionamento && curr_page() == PRIMA;
|
|
}
|
|
|
|
// Stampa "righe" righe vuote. Se righe e' -1 fa un formfeed mettendo
|
|
// il codice ditta sull'ultima riga
|
|
void TDicForm::fill_page(TPrinter& pr, const int righe)
|
|
{
|
|
TPrintrow row;
|
|
PaginaQuadro pagina = curr_page();
|
|
|
|
// form feed
|
|
if (righe < 0)
|
|
{
|
|
// const bool PrimaPagina = curr_page() == PRIMA;
|
|
const int stop = PaginaPosizionamento() ? QD_FORMLEN_PRIMA : QD_FORMLEN;
|
|
for (int i = _RigaCorr; i < stop; i++)
|
|
{
|
|
if (i == 0)
|
|
if (_modulaser)
|
|
{
|
|
if (!_GiaMessoStartPage[pagina])
|
|
put_modulaser(row, STARTPAGE, pagina);
|
|
}
|
|
// Sull'ultima riga metto il codice ditta
|
|
if (i == stop - 2)
|
|
{
|
|
if (_modulaser && EndJob() && curr_page() == QUARTA)
|
|
put_modulaser(row, ENDDOC);
|
|
|
|
TString16 ditta; ditta << _codditta;
|
|
row.put(ditta, POS_DITTA);
|
|
pr.print(row);
|
|
row.reset();
|
|
}
|
|
else
|
|
pr.print(row);
|
|
}
|
|
_RigaCorr = 0;
|
|
return;
|
|
}
|
|
else // righe > 0
|
|
{
|
|
for (int i=0; i < righe; i++)
|
|
{
|
|
if (i == 0 && _modulaser && !_GiaMessoStartPage[pagina])
|
|
put_modulaser(row, STARTPAGE, pagina);
|
|
else
|
|
row.reset();
|
|
pr.print(row);
|
|
_RigaCorr++;
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDicForm::jump_to_line(TPrinter& pr, const int lin)
|
|
{
|
|
if (_RigaCorr > lin)
|
|
fill_page(pr, -1);
|
|
fill_page(pr, lin - _RigaCorr);
|
|
}
|
|
|
|
void TDicForm::stampa_totali(TPrinter& pr)
|
|
{
|
|
PaginaQuadro PagCorr = curr_page();
|
|
TPrint_section& foot = section('B', even_page);
|
|
const char* pic = "############";
|
|
bool stampa = FALSE;
|
|
|
|
TForm_item& ttotale = foot.find_field(TOT_TOTALE);
|
|
TForm_item& tsnsrit = foot.find_field(TOT_SNSRIT);
|
|
TForm_item& timpon = foot.find_field(TOT_IMPON);
|
|
TForm_item& timpor = foot.find_field(TOT_IMPOR);
|
|
TForm_item& tnetto = foot.find_field(TOT_NETTO);
|
|
|
|
const bool stampa_tot_fis = ultima_fis();
|
|
const bool stampa_tot_nofis = ultima_nofis();
|
|
|
|
if (stampa_tot_fis)
|
|
if (PagCorr == TERZA) // Scrive totali p.fisiche
|
|
{
|
|
stampa=TRUE;
|
|
TString ftot(_f_tot_totale.string(pic));
|
|
TString fsnsrit(_f_tot_snsrit.string(pic));
|
|
TString fimpon(_f_tot_impon.string(pic));
|
|
TString fimpor(_f_tot_impor.string(pic));
|
|
TString fnetto(_f_tot_netto.string(pic));
|
|
// Toglie le migliaia
|
|
ftot.cut(ftot.len() - 3);
|
|
fsnsrit.cut(fsnsrit.len()-3);
|
|
fimpon.cut(fimpon.len()-3);
|
|
fimpor.cut(fimpor.len()-3);
|
|
fnetto.cut(fnetto.len()-3);
|
|
if (ftot.empty()) ftot = "0";
|
|
if (fsnsrit.empty()) fsnsrit = "0";
|
|
if (fimpon.empty()) fimpon = "0";
|
|
if (fimpor.empty()) fimpor = "0";
|
|
if (fnetto.empty()) fnetto = "0";
|
|
// Setta i campi
|
|
ttotale.set(ftot);
|
|
tsnsrit.set(fsnsrit);
|
|
timpon.set(fimpon);
|
|
timpor.set(fimpor);
|
|
tnetto.set(fnetto);
|
|
_GiaStampatiFis = TRUE;
|
|
const int NUMPER_TERZA = 6;
|
|
const int NUM_RIGHE = 8;
|
|
const int gap = ((NUMPER_TERZA - _CtrFisStampati) * NUM_RIGHE)+1;
|
|
if (gap>0)
|
|
fill_page(pr,gap);
|
|
}
|
|
|
|
if (stampa_tot_nofis)
|
|
if (PagCorr == QUARTA) // Scrive totali p.non fisiche
|
|
{
|
|
stampa=TRUE;
|
|
TString ftot(_nf_tot_totale.string(pic));
|
|
TString fsnsrit(_nf_tot_snsrit.string(pic));
|
|
TString fimpon(_nf_tot_impon.string(pic));
|
|
TString fimpor(_nf_tot_impor.string(pic));
|
|
TString fnetto(_nf_tot_netto.string(pic));
|
|
// Toglie le migliaia
|
|
ftot.cut(ftot.len() - 3);
|
|
fsnsrit.cut(fsnsrit.len()-3);
|
|
fimpon.cut(fimpon.len()-3);
|
|
fimpor.cut(fimpor.len()-3);
|
|
fnetto.cut(fnetto.len()-3);
|
|
if (ftot.empty()) ftot = "0";
|
|
if (fsnsrit.empty()) fsnsrit = "0";
|
|
if (fimpon.empty()) fimpon = "0";
|
|
if (fimpor.empty()) fimpor = "0";
|
|
if (fnetto.empty()) fnetto = "0";
|
|
// Setta i campi
|
|
ttotale.set(ftot);
|
|
tsnsrit.set(fsnsrit);
|
|
timpon.set(fimpon);
|
|
timpor.set(fimpor);
|
|
tnetto.set(fnetto);
|
|
_GiaStampatiNoFis = TRUE;
|
|
const int NUMPER_QUARTA = 6;
|
|
const int NUM_RIGHE = 8;
|
|
const int gap = ((NUMPER_QUARTA - _CtrNoFisStampati) * NUM_RIGHE)+1;
|
|
|
|
if (gap > 0)
|
|
fill_page(pr,gap);
|
|
}
|
|
if (stampa)
|
|
{
|
|
foot.update();
|
|
for (word j = 0; j < foot.height(); j++)
|
|
{
|
|
pr.print(foot.row(j));
|
|
_RigaCorr++;
|
|
}
|
|
foot.reset(); // non stampare piu' questi totali!
|
|
}
|
|
}
|
|
|
|
void TDicForm::stampa_testata(TPrinter& pr)
|
|
{
|
|
TPrint_section& head = section('H', first_page);
|
|
const word r = head.height()-1;
|
|
TPrintrow& head_row = head.row(r-1);
|
|
|
|
// Setta il numero di pagina e poi lo incrementa
|
|
TForm_item& nf = head.find_field(H_NUM_FOGLIO);
|
|
TString fstr(10); fstr << _num_foglio;
|
|
nf.set(fstr);
|
|
_num_foglio++;
|
|
|
|
// Setta il cod.fis. del dichiarante se necessario
|
|
if (tipo_ditta() == estinto)
|
|
{
|
|
TForm_item& cfd = head.find_field(H_COFI_DIC);
|
|
cfd.set(_cofi_dic);
|
|
}
|
|
// Righe da saltare nelle prime pag. dei moduli successivi al primo (che' son
|
|
// senza le righe del posizionamento...)
|
|
int HEADER_PRIMA_NOPOS = 3;
|
|
head.update();
|
|
for (word j = 0; j <= r; j++)
|
|
{
|
|
if (j==0)
|
|
{
|
|
if (_modulaser)
|
|
{
|
|
TPrintrow& r = head.row(j);
|
|
if (!_GiaMessoStartDoc)
|
|
put_modulaser(r, STARTDOC);
|
|
put_modulaser(r, STARTDITTA);
|
|
put_modulaser(r, STARTPAGE, 1);
|
|
pr.print(r);
|
|
_RigaCorr++;
|
|
r.reset();
|
|
HEADER_PRIMA_NOPOS--;
|
|
}
|
|
if (!PaginaPosizionamento())
|
|
fill_page(pr, HEADER_PRIMA_NOPOS);
|
|
}
|
|
else
|
|
{
|
|
pr.print(head.row(j));
|
|
_RigaCorr++;
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDicForm::next_page(TPrinter& pr)
|
|
{
|
|
PaginaQuadro PagCorr = curr_page();
|
|
if (PagCorr >= TERZA)
|
|
stampa_totali(pr);
|
|
fill_page(pr, -1); // formfeed "adattato"
|
|
inc_curr_page();
|
|
}
|
|
|
|
void TDicForm::azzera_totali()
|
|
{
|
|
_f_tot_netto = _f_tot_totale = _f_tot_impor = _f_tot_impon = _f_tot_snsrit = ZERO;
|
|
_nf_tot_netto = _nf_tot_totale = _nf_tot_impor = _nf_tot_impon = _nf_tot_snsrit = ZERO;
|
|
}
|
|
|
|
void TDicForm::aggiorna_totali_E(const char tipo)
|
|
{
|
|
}
|
|
|
|
void TDicForm::aggiorna_totali_E1(const char tipo)
|
|
{
|
|
}
|
|
|
|
void TDicForm::aggiorna_totali_D(const char tipo)
|
|
{
|
|
real totale, netto, impon, nsrit, impor;
|
|
TCursor* cur = cursor();
|
|
TRectype& crr = cur->curr();
|
|
|
|
totale = crr.get_real(QUD_TOTALE);
|
|
netto = crr.get_real(QUD_NETTO);
|
|
impon = crr.get_real(QUD_IMPONIBILE);
|
|
impor = crr.get_real(QUD_IMPORTO);
|
|
nsrit = crr.get_real(QUD_SOMME);
|
|
|
|
if (tipo == 'F')
|
|
{
|
|
_f_tot_totale += totale;
|
|
_f_tot_netto += netto;
|
|
_f_tot_impon += impon;
|
|
_f_tot_snsrit += nsrit;
|
|
_f_tot_impor += impor;
|
|
}
|
|
else
|
|
{
|
|
_nf_tot_totale += totale;
|
|
_nf_tot_netto += netto;
|
|
_nf_tot_impon += impon;
|
|
_nf_tot_snsrit += nsrit;
|
|
_nf_tot_impor += impor;
|
|
}
|
|
}
|
|
|
|
void TDicForm::aggiorna_totali_D1(const char tipo)
|
|
{
|
|
real totale, netto, impon, QuotaProv, SpeseAnt, impor;
|
|
TCursor* cur = cursor();
|
|
TRectype& crr = cur->curr();
|
|
|
|
totale = crr.get_real(QD1_TOTALE);
|
|
netto = crr.get_real(QD1_NETTO);
|
|
impon = crr.get_real(QD1_IMPONIBILE);
|
|
impor = crr.get_real(QD1_IMPORTO);
|
|
QuotaProv = crr.get_real(QD1_QUOTAPRO);
|
|
SpeseAnt = crr.get_real(QD1_SPESEANT);
|
|
|
|
if (tipo == 'F')
|
|
{
|
|
_f_tot_totale += totale;
|
|
_f_tot_netto += netto;
|
|
_f_tot_impon += impon;
|
|
_f_tot_snsrit += QuotaProv;
|
|
_f_tot_impor += impor;
|
|
}
|
|
else
|
|
{
|
|
_nf_tot_totale += totale;
|
|
_nf_tot_netto += netto;
|
|
_nf_tot_impon += impon;
|
|
_nf_tot_snsrit += QuotaProv;
|
|
_nf_tot_impor += impor;
|
|
}
|
|
}
|
|
|
|
void TDicForm::aggiorna_totali_C(const char tipo)
|
|
{
|
|
real totale, netto, impon, nsrit, impor;
|
|
TCursor* cur = cursor();
|
|
TRectype& crr = cur->curr();
|
|
|
|
totale = crr.get_real(QUD_TOTALE);
|
|
netto = crr.get_real(QUD_NETTO);
|
|
impon = crr.get_real(QUD_IMPONIBILE);
|
|
impor = crr.get_real(QUD_IMPORTO);
|
|
nsrit = crr.get_real(QUD_SOMME);
|
|
|
|
if (tipo == 'F')
|
|
{
|
|
_f_tot_totale += totale;
|
|
_f_tot_netto += netto;
|
|
_f_tot_impon += impon;
|
|
_f_tot_snsrit += nsrit;
|
|
_f_tot_impor += impor;
|
|
}
|
|
else
|
|
{
|
|
_nf_tot_totale += totale;
|
|
_nf_tot_netto += netto;
|
|
_nf_tot_impon += impon;
|
|
_nf_tot_snsrit += nsrit;
|
|
_nf_tot_impor += impor;
|
|
}
|
|
}
|
|
|
|
|
|
void TDicForm::aggiorna_totali(const char tipo)
|
|
{
|
|
if (_quadro == "C")
|
|
aggiorna_totali_C(tipo);
|
|
|
|
if (_quadro == "D")
|
|
aggiorna_totali_D(tipo);
|
|
|
|
if (_quadro == "D1")
|
|
aggiorna_totali_D1(tipo);
|
|
|
|
if (_quadro == "E")
|
|
aggiorna_totali_E(tipo);
|
|
|
|
if (_quadro == "E1")
|
|
aggiorna_totali_E1(tipo);
|
|
}
|
|
|
|
void TDicForm::set_body(TPrinter& pr, const char tipo)
|
|
{
|
|
TPrint_section& body = section('B', odd_page);
|
|
body.reset();
|
|
body.update();
|
|
aggiorna_totali(tipo);
|
|
const int body_righe = body.height();
|
|
for (int i=0; i < body_righe; i++)
|
|
{
|
|
pr.print(body.row(i));
|
|
_RigaCorr++;
|
|
}
|
|
if (usa_progind())
|
|
progind()->addstatus(1);
|
|
}
|
|
|
|
|
|
void TDicForm::posiziona()
|
|
{
|
|
_GiaPosizionato = TRUE;
|
|
_PaginaPosizionamento = TRUE;
|
|
|
|
arrange_form();
|
|
/****************************
|
|
char str_pos[MAX_LEN];
|
|
int i;
|
|
const int xip = ipx();
|
|
const int yip = ipy();
|
|
const int xfp = fpx(); //131;
|
|
|
|
for (i=0; i < MAX_LEN; i++) str_pos[i] = ' ';
|
|
str_pos[0] = '\r';
|
|
str_pos[0] = '\r';
|
|
str_pos[xip] = str_pos[xfp] = char_to_pos();
|
|
str_pos[xfp+1] = '\r';
|
|
str_pos[xfp+1] = '\0';
|
|
|
|
bool parti = yesno_box("Conferma stampa riga di posizionamento ?");
|
|
if (!parti) return;
|
|
|
|
_GiaPosizionato = TRUE;
|
|
_PaginaPosizionamento = TRUE;
|
|
|
|
do
|
|
{
|
|
if (!PrintLineNow(str_pos, xfp+1, hInst))
|
|
message_box("PrintLineNow fallita!");
|
|
}
|
|
while (!yesno_box("Posizione corretta ?"));
|
|
**************/
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Quadro G
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
HIDDEN const int QG_FORMLEN = 72;
|
|
HIDDEN const int QG_PAGINE = 2;
|
|
HIDDEN const int HEADER_SECONDA_G = 7;
|
|
|
|
class TQuadroG : public TDicForm
|
|
{
|
|
private:
|
|
long _items_g, _items_gd;
|
|
void stampa_prospetti1_2(TPrinter& pr);
|
|
void stampa_prospetti3_4(TPrinter& pr);
|
|
|
|
protected:
|
|
virtual void inc_curr_page();
|
|
virtual void next_page(TPrinter& pr);
|
|
virtual void stampa_totali(TPrinter& pr) {}
|
|
virtual void aggiorna_totali(const char tipo) {}
|
|
virtual void set_body(TPrinter& pr, const char tipo) {}
|
|
|
|
public:
|
|
virtual bool print(const long codditta, const long NumFis, const long NumNoFis);
|
|
void set_items_gd(const long itg, const long itgd) { _items_g = itg; _items_gd = itgd; }
|
|
|
|
TQuadroG(const char* form, const char* quadro) : TDicForm(form, quadro),
|
|
_items_g(0L), _items_gd(0L) {}
|
|
virtual ~TQuadroG() {}
|
|
};
|
|
|
|
|
|
void TQuadroG::inc_curr_page()
|
|
{
|
|
if (_PaginaCorrente == PRIMA)
|
|
_PaginaCorrente = SECONDA;
|
|
else
|
|
if (_PaginaCorrente == SECONDA)
|
|
_PaginaCorrente = PRIMA;
|
|
}
|
|
|
|
|
|
void TQuadroG::next_page(TPrinter& pr)
|
|
{
|
|
PaginaQuadro PagCorr = curr_page();
|
|
fill_page(pr, -1);
|
|
inc_curr_page();
|
|
}
|
|
|
|
|
|
void TQuadroG::stampa_prospetti1_2(TPrinter& pr)
|
|
{
|
|
TPrint_section& head = section('H', 1);
|
|
const word rr = head.height()-1;
|
|
TPrintrow& head_row = head.row(rr-1);
|
|
|
|
// Setta il numero di pagina e poi lo incrementa
|
|
TForm_item& nf = head.find_field(H_NUM_FOGLIO);
|
|
TString fstr(10); fstr << _num_foglio;
|
|
nf.set(fstr);
|
|
_num_foglio++;
|
|
|
|
// Setta il cod.fis. del dichiarante se necessario
|
|
if (tipo_ditta() == estinto)
|
|
{
|
|
TForm_item& cfd = head.find_field(H_COFI_DIC);
|
|
cfd.set(_cofi_dic);
|
|
}
|
|
|
|
TCursor* cur = cursor();
|
|
|
|
// Prospetto n. 2
|
|
TRectype& r = cur->curr();
|
|
TToken_string p22(r.get("P22"));
|
|
TToken_string p23(r.get("P23"));
|
|
TToken_string p24(r.get("P24"));
|
|
TToken_string p25(r.get("P25"));
|
|
TToken_string p26(r.get("P26"));
|
|
|
|
const int START_P2 = 56;
|
|
const int RIGHE_P2 = 5;
|
|
const int COL_P2 = 5;
|
|
int cols = 0;
|
|
for (int i = 0; i < RIGHE_P2; i++)
|
|
{
|
|
const int fc2 = START_P2 + cols;
|
|
TForm_item& c2 = head.find_field(fc2);
|
|
c2.set(p22.get(i));
|
|
|
|
const int fc3 = fc2 + 1;
|
|
TForm_item& c3 = head.find_field(fc3);
|
|
c3.set(p23.get(i));
|
|
|
|
const int fc4 = fc3 + 1;
|
|
TForm_item& c4 = head.find_field(fc4);
|
|
c4.set(p24.get(i));
|
|
|
|
const int fc5 = fc4 + 1;
|
|
TForm_item& c5 = head.find_field(fc5);
|
|
c5.set(p25.get(i));
|
|
|
|
const int fc6 = fc5 + 1;
|
|
TForm_item& c6 = head.find_field(fc6);
|
|
c6.set(p26.get(i));
|
|
|
|
cols += COL_P2;
|
|
}
|
|
|
|
// Righe da saltare nelle prime pag. dei moduli successivi al primo (che' son
|
|
// senza le righe del posizionamento...)
|
|
int HEADER_PRIMA_NOPOS = 3;
|
|
head.update();
|
|
for (word j = 0; j <= rr; j++)
|
|
{
|
|
if (j==0)
|
|
{
|
|
if (_modulaser)
|
|
{
|
|
TPrintrow& r = head.row(j);
|
|
if (!_GiaMessoStartDoc)
|
|
put_modulaser(r, STARTDOC);
|
|
put_modulaser(r, STARTDITTA);
|
|
put_modulaser(r, STARTPAGE, 1);
|
|
pr.print(r);
|
|
_RigaCorr++;
|
|
r.reset();
|
|
HEADER_PRIMA_NOPOS--;
|
|
}
|
|
if (!PaginaPosizionamento())
|
|
fill_page(pr, HEADER_PRIMA_NOPOS);
|
|
}
|
|
else
|
|
{
|
|
pr.print(head.row(j));
|
|
_RigaCorr++;
|
|
}
|
|
}
|
|
}
|
|
|
|
void TQuadroG::stampa_prospetti3_4(TPrinter& pr)
|
|
{
|
|
TPrint_section& sez = section('B');
|
|
const word rr = sez.height()-1;
|
|
sez.reset();
|
|
TPrintrow& head_row = sez.row(rr-1);
|
|
|
|
// Prospetto n. 3
|
|
TCursor* cur = cursor();
|
|
TRectype& r = cur->curr();
|
|
TToken_string p33a(r.get("P33A"));
|
|
TToken_string p33b(r.get("P33B"));
|
|
TToken_string p35a(r.get("P35A"));
|
|
TToken_string p35b(r.get("P35B"));
|
|
TToken_string p36a(r.get("P36A"));
|
|
TToken_string p36b(r.get("P36B"));
|
|
|
|
// colonna 2 e 7
|
|
for (int i=1; i<=5; i++)
|
|
{
|
|
TForm_item& c2 = sez.find_field(i);
|
|
TForm_item& c7 = sez.find_field(i+65);
|
|
int src=0; // determina quale posizione va letta dalla token-string per il campo corrente
|
|
switch (i)
|
|
{
|
|
case 1:
|
|
src = 0;
|
|
break;
|
|
case 2:
|
|
src = 7;
|
|
break;
|
|
case 3:
|
|
src = 10;
|
|
break;
|
|
case 4:
|
|
src = 12;
|
|
break;
|
|
case 5:
|
|
src = 14;
|
|
break;
|
|
}
|
|
|
|
c2.set(p33a.get(src));
|
|
c7.set(p36b.get(src));
|
|
}
|
|
|
|
const int RIGHE_P3 = 20;
|
|
|
|
// Colonna 3
|
|
const int START_P3_COL3 = 6;
|
|
int c3=0;
|
|
for (i = 0; i < RIGHE_P3; i++)
|
|
{
|
|
c3 = START_P3_COL3 + i;
|
|
TForm_item& c5a = sez.find_field(c3);
|
|
c5a.set(p33b.get(i));
|
|
}
|
|
|
|
// Colonna 5
|
|
const int START_P3_COL5 = c3 + 1;
|
|
int c5=0;
|
|
for (i = 0; i < RIGHE_P3; i++)
|
|
{
|
|
c5 = START_P3_COL5 + i;
|
|
TForm_item& c6a = sez.find_field(c5);
|
|
c6a.set(p35b.get(i));
|
|
}
|
|
|
|
// Colonna 6
|
|
const int START_P3_COL6 = c5 + 1;
|
|
int c6=0;
|
|
for (i = 0; i < RIGHE_P3; i++)
|
|
{
|
|
c6 = START_P3_COL6 + i;
|
|
TForm_item& c6a = sez.find_field(c6);
|
|
c6a.set(p36a.get(i));
|
|
}
|
|
|
|
sez.update();
|
|
const int sez_righe = sez.height();
|
|
for (i=0; i < sez_righe; i++)
|
|
{
|
|
pr.print(sez.row(i));
|
|
_RigaCorr++;
|
|
}
|
|
if (usa_progind())
|
|
progind()->addstatus(1);
|
|
}
|
|
|
|
|
|
bool TQuadroG::print(const long codditta, const long NumFis, const long NumNoFis)
|
|
{
|
|
TCursor* cur = cursor();
|
|
|
|
bool StabilitaInesistenzaNoFis = FALSE;
|
|
bool StabilitaInesistenzaFis = FALSE;
|
|
long CtrFis = NumFis;
|
|
long CtrNoFis = NumNoFis;
|
|
long PtrFis = -1L, PtrNoFis=-1L;
|
|
TPrinter& pr = printer();
|
|
|
|
_CtrFisStampati = _CtrNoFisStampati = 0;
|
|
_finite_fis = _finite_nofis = FALSE;
|
|
_GiaStampatiFis = _GiaStampatiNoFis = FALSE;
|
|
_EndPrintDitta = FALSE; // Vero se stampato l'ultimo record
|
|
bool LastRecord = FALSE; // Vero se letto l'ultimo record
|
|
|
|
_PaginaCorrente = PRIMA;
|
|
|
|
if (!InitPrint(codditta))
|
|
return FALSE;
|
|
|
|
for (int pagina=1; pagina <= QG_PAGINE; pagina++, next_page(pr))
|
|
{
|
|
pr.formlen(QG_FORMLEN);
|
|
|
|
if (_PaginaCorrente == PRIMA)
|
|
{
|
|
if (_modulaser) ClearFlagModulaser();
|
|
|
|
(*cur) = PtrFis >= 0L ? PtrFis : 0L;
|
|
stampa_prospetti1_2(pr);
|
|
}
|
|
|
|
if (_PaginaCorrente == SECONDA)
|
|
{
|
|
// Reset del flag di pagina con posiz.
|
|
if (_posiziona && _PaginaPosizionamento) _PaginaPosizionamento = FALSE;
|
|
|
|
fill_page(pr, HEADER_SECONDA_G);
|
|
stampa_prospetti3_4(pr);
|
|
}
|
|
} // for pagina..
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Distinta G
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
HIDDEN const int QGD_FORMLEN = 72;
|
|
HIDDEN const int QGD_PAGINE = 2;
|
|
HIDDEN const int HEADER_SECONDA_GD = 7;
|
|
HIDDEN const int QGD_RIGHE_PRIMA = 8;
|
|
|
|
class TDistintaG : public TQuadroG
|
|
{
|
|
private:
|
|
real _f_tot_utspet, _f_tot_utpag, _f_tot_rope, _f_tot_ropespet;
|
|
real _nf_tot_utspet, _nf_tot_utpag, _nf_tot_rope, _nf_tot_ropespet;
|
|
void aggiorna_totali(const char tipo);
|
|
void stampa_totali(TPrinter& pr);
|
|
void stampa_testata(TPrinter& pr);
|
|
virtual void next_page(TPrinter& pr);
|
|
virtual void set_body(TPrinter& pr, const char tipo);
|
|
|
|
public:
|
|
virtual bool print(const long codditta, const long NumFis, const long NumNoFis);
|
|
|
|
TDistintaG(const char* form, const char* quadro) : TQuadroG(form,quadro) {}
|
|
virtual ~TDistintaG() {}
|
|
};
|
|
|
|
void TDistintaG::next_page(TPrinter& pr)
|
|
{
|
|
PaginaQuadro PagCorr = curr_page();
|
|
// if (PagCorr == SECONDA)
|
|
stampa_totali(pr);
|
|
fill_page(pr, -1); // formfeed "adattato"
|
|
inc_curr_page();
|
|
}
|
|
|
|
void TDistintaG::aggiorna_totali(const char tipo)
|
|
{
|
|
real utspet, utpag, rope, ropespet;
|
|
TCursor* cur = cursor();
|
|
TRectype& crr = cur->curr();
|
|
|
|
utspet = crr.get_real(QGD_UTSPETT);
|
|
utpag = crr.get_real(QGD_UTPAG);
|
|
rope = crr.get_real(QGD_ROPE);
|
|
ropespet = crr.get_real(QGD_ROPESPET);
|
|
|
|
if (tipo == 'F')
|
|
{
|
|
_f_tot_utspet += utspet;
|
|
_f_tot_utpag += utpag;
|
|
_f_tot_rope += rope;
|
|
_f_tot_ropespet += ropespet;
|
|
}
|
|
else
|
|
{
|
|
_nf_tot_utspet += utspet;
|
|
_nf_tot_utpag += utpag;
|
|
_nf_tot_rope += rope;
|
|
_nf_tot_ropespet += ropespet;
|
|
}
|
|
}
|
|
|
|
|
|
void TDistintaG::stampa_totali(TPrinter& pr)
|
|
{
|
|
PaginaQuadro PagCorr = curr_page();
|
|
TPrint_section& foot = section('B', even_page);
|
|
const word righe = foot.height();
|
|
const char* pic = "############";
|
|
bool stampa = FALSE;
|
|
|
|
TForm_item& ttotale = foot.find_field(TOT_TOTALE);
|
|
TForm_item& tsnsrit = foot.find_field(TOT_SNSRIT);
|
|
TForm_item& timpon = foot.find_field(TOT_IMPON);
|
|
TForm_item& timpor = foot.find_field(TOT_IMPOR);
|
|
|
|
const bool stampa_tot_fis = ultima_fis();
|
|
const bool stampa_tot_nofis = ultima_nofis();
|
|
|
|
if (stampa_tot_fis)
|
|
if (PagCorr == PRIMA) // Scrive totali p.fisiche
|
|
{
|
|
stampa=TRUE;
|
|
TString ftot(_f_tot_utspet.string(pic));
|
|
TString fsnsrit(_f_tot_utpag.string(pic));
|
|
TString fimpon(_f_tot_rope.string(pic));
|
|
TString fimpor(_f_tot_ropespet.string(pic));
|
|
|
|
// Toglie le migliaia
|
|
ftot.cut(ftot.len() - 3);
|
|
fsnsrit.cut(fsnsrit.len()-3);
|
|
fimpon.cut(fimpon.len()-3);
|
|
fimpor.cut(fimpor.len()-3);
|
|
if (ftot.empty()) ftot = "0";
|
|
if (fsnsrit.empty()) fsnsrit = "0";
|
|
if (fimpon.empty()) fimpon = "0";
|
|
if (fimpor.empty()) fimpor = "0";
|
|
|
|
// Setta i campi
|
|
ttotale.set(ftot);
|
|
tsnsrit.set(fsnsrit);
|
|
timpon.set(fimpon);
|
|
timpor.set(fimpor);
|
|
|
|
_GiaStampatiFis = TRUE;
|
|
const int NUMPER_TERZA = 6;
|
|
const int NUM_RIGHE = 8;
|
|
const int gap = ((NUMPER_TERZA - _CtrFisStampati) * NUM_RIGHE)+1;
|
|
if (gap>0)
|
|
fill_page(pr,gap);
|
|
}
|
|
|
|
if (stampa_tot_nofis)
|
|
if (PagCorr == SECONDA) // Scrive totali p.non fisiche
|
|
{
|
|
stampa=TRUE;
|
|
TString ftot (_nf_tot_utspet.string(pic));
|
|
TString fsnsrit(_nf_tot_utpag.string(pic));
|
|
TString fimpon (_nf_tot_rope.string(pic));
|
|
TString fimpor (_nf_tot_ropespet.string(pic));
|
|
|
|
// Toglie le migliaia
|
|
ftot.cut(ftot.len() - 3);
|
|
fsnsrit.cut(fsnsrit.len()-3);
|
|
fimpon.cut(fimpon.len()-3);
|
|
fimpor.cut(fimpor.len()-3);
|
|
|
|
if (ftot.empty()) ftot = "0";
|
|
if (fsnsrit.empty()) fsnsrit = "0";
|
|
if (fimpon.empty()) fimpon = "0";
|
|
if (fimpor.empty()) fimpor = "0";
|
|
|
|
// Setta i campi
|
|
ttotale.set(ftot);
|
|
tsnsrit.set(fsnsrit);
|
|
timpon.set(fimpon);
|
|
timpor.set(fimpor);
|
|
|
|
_GiaStampatiNoFis = TRUE;
|
|
const int NUMPER_QUARTA = 6;
|
|
const int NUM_RIGHE = 8;
|
|
const int gap = ((NUMPER_QUARTA - _CtrNoFisStampati) * NUM_RIGHE)+1;
|
|
|
|
if (gap > 0)
|
|
fill_page(pr,gap);
|
|
}
|
|
if (stampa)
|
|
{
|
|
foot.update();
|
|
for (word j = 0; j < righe; j++)
|
|
{
|
|
pr.print(foot.row(j));
|
|
_RigaCorr++;
|
|
}
|
|
foot.reset(); // non stampare piu' questi totali!
|
|
}
|
|
}
|
|
|
|
void TDistintaG::stampa_testata(TPrinter& pr)
|
|
{
|
|
TPrint_section& head = section('H', 1);
|
|
const word r = head.height()-1;
|
|
TPrintrow& head_row = head.row(r-1);
|
|
|
|
// Setta il numero di pagina e poi lo incrementa
|
|
TForm_item& nf = head.find_field(H_NUM_FOGLIO);
|
|
TString fstr(10); fstr << _num_foglio;
|
|
nf.set(fstr);
|
|
_num_foglio++;
|
|
}
|
|
|
|
void TDistintaG::set_body(TPrinter& pr, const char tipo)
|
|
{
|
|
TPrint_section& body = section('B', odd_page);
|
|
body.reset();
|
|
body.update();
|
|
aggiorna_totali(tipo);
|
|
const int body_righe = body.height();
|
|
for (int i=0; i < body_righe; i++)
|
|
{
|
|
pr.print(body.row(i));
|
|
_RigaCorr++;
|
|
}
|
|
if (usa_progind())
|
|
progind()->addstatus(1);
|
|
}
|
|
|
|
|
|
bool TDistintaG::print(const long codditta, const long NumFis, const long NumNoFis)
|
|
{
|
|
TCursor* cur = cursor();
|
|
|
|
bool StabilitaInesistenzaNoFis = FALSE;
|
|
bool StabilitaInesistenzaFis = FALSE;
|
|
long CtrFis = NumFis;
|
|
long CtrNoFis = NumNoFis;
|
|
long PtrFis = -1L, PtrNoFis=-1L;
|
|
TPrinter& pr = printer();
|
|
|
|
_CtrFisStampati = _CtrNoFisStampati = 0;
|
|
_finite_fis = _finite_nofis = FALSE;
|
|
_GiaStampatiFis = _GiaStampatiNoFis = FALSE;
|
|
_EndPrintDitta = FALSE; // Vero se stampato l'ultimo record
|
|
bool LastRecord = FALSE; // Vero se letto l'ultimo record
|
|
_PaginaCorrente = PRIMA;
|
|
|
|
_codditta = codditta;
|
|
_RigaCorr = 0;
|
|
|
|
const long items = filtra(codditta);
|
|
|
|
while (!_EndPrintDitta)
|
|
{
|
|
for (int pagina=1; pagina <= QGD_PAGINE; pagina++, next_page(pr))
|
|
{
|
|
pr.formlen(QGD_FORMLEN);
|
|
|
|
if (_PaginaCorrente == PRIMA)
|
|
{
|
|
if (_modulaser) ClearFlagModulaser();
|
|
|
|
for (int righe=0; righe < QGD_RIGHE_PRIMA; righe++)
|
|
{
|
|
// Stampa intestazione, solo sul primo foglio.
|
|
if (!righe)
|
|
{
|
|
(*cur) = PtrFis >= 0L ? PtrFis : 0L;
|
|
stampa_testata(pr);
|
|
}
|
|
|
|
if (_finite_fis || StabilitaInesistenzaFis)
|
|
break;
|
|
|
|
// La prima volta si deve posizionare sul primo record di p.f.
|
|
if (PtrFis<0L && !StabilitaInesistenzaFis)
|
|
{
|
|
bool Trovato = FALSE;
|
|
|
|
while (!Trovato)
|
|
{
|
|
const long ditta = cur->curr().get_long(QGD_CODDITTA);
|
|
if (ditta != codditta)
|
|
break;
|
|
const char tipo = cur->curr().get(QGD_TIPOA)[0];
|
|
if (tipo != 'G')
|
|
{
|
|
PtrFis = cur->pos();
|
|
Trovato = TRUE;
|
|
break;
|
|
}
|
|
else
|
|
++(*cur);
|
|
}
|
|
StabilitaInesistenzaFis = !Trovato;
|
|
}
|
|
|
|
if (StabilitaInesistenzaFis)
|
|
break;
|
|
|
|
(*cur) = PtrFis;
|
|
const char tipo = cur->curr().get(QGD_TIPOA)[0];
|
|
|
|
if (tipo != 'F')
|
|
break;
|
|
else
|
|
{
|
|
CtrFis--;
|
|
if (CtrFis == 0L) _finite_fis = TRUE;
|
|
set_body(pr, 'F');
|
|
// La stampa e' finita se ho STAMPATO l'ultimo record
|
|
LastRecord = cur->pos() >= items-1;
|
|
_EndPrintDitta = LastRecord;
|
|
if (!LastRecord)
|
|
{
|
|
++(*cur);
|
|
PtrFis = cur->pos();
|
|
LastRecord = cur->pos() >= items-1;
|
|
}
|
|
}
|
|
} // for righe..
|
|
PtrFis = cur->pos();
|
|
}
|
|
|
|
if (_PaginaCorrente == SECONDA)
|
|
{
|
|
// Reset del flag di pagina con posiz.
|
|
if (_posiziona && _PaginaPosizionamento) _PaginaPosizionamento = FALSE;
|
|
for (int righe=0; righe < QD_RIGHE_SECONDA; righe++)
|
|
{
|
|
if (!righe)
|
|
_CtrNoFisStampati = 0;
|
|
|
|
// All'inizio salta le righe in alto
|
|
if (!righe)
|
|
fill_page(pr, HEADER_SECONDA_GD);
|
|
|
|
if (_finite_nofis || StabilitaInesistenzaNoFis)
|
|
break;
|
|
|
|
// La prima volta si deve posizionare sul primo record di p.g.
|
|
if (PtrNoFis<0L && !StabilitaInesistenzaNoFis)
|
|
{
|
|
bool Trovato = FALSE;
|
|
bool eof = FALSE;
|
|
(*cur) = PtrFis-1 > 0L ? PtrFis-1 : 0L; // parti dall'inizio
|
|
while (!Trovato && !eof)
|
|
{
|
|
eof = cur->pos() >= items-1;
|
|
const long ditta = cur->curr().get_long(QGD_CODDITTA);
|
|
if (ditta != codditta)
|
|
break;
|
|
const char tipo = cur->curr().get(QGD_TIPOA)[0];
|
|
if (tipo != 'F')
|
|
{
|
|
PtrNoFis = cur->pos();
|
|
Trovato = TRUE;
|
|
break;
|
|
}
|
|
else
|
|
++(*cur);
|
|
}
|
|
StabilitaInesistenzaNoFis = !Trovato;
|
|
}
|
|
|
|
if (StabilitaInesistenzaNoFis)
|
|
break;
|
|
|
|
(*cur) = PtrNoFis;
|
|
const char tipo = cur->curr().get(QGD_TIPOA)[0];
|
|
|
|
if (tipo != 'G')
|
|
break;
|
|
else
|
|
{
|
|
CtrNoFis--;
|
|
if (CtrNoFis == 0L) _finite_nofis = TRUE;
|
|
set_body(pr, 'G');
|
|
LastRecord = cur->pos() >= items-1;
|
|
_EndPrintDitta = LastRecord;
|
|
_CtrNoFisStampati++;
|
|
if (!LastRecord)
|
|
{
|
|
++(*cur);
|
|
PtrNoFis = cur->pos();
|
|
LastRecord = cur->pos() >= items-1;
|
|
}
|
|
}
|
|
}
|
|
PtrNoFis = cur->pos();
|
|
}
|
|
} // for pagina..
|
|
} // while !EndPrintDitta
|
|
|
|
if (usa_progind())
|
|
{
|
|
delete _prog;
|
|
_prog = NULL;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// TStDicArray
|
|
//
|
|
// Array delle ditte da stampare. Contiene una riga per ogni ditta che si vuole stampare
|
|
// Il formato della riga e':
|
|
// codditta|estinti|numfis|numnofis|ultimafis|ultimanofis
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TStDicArray : public TObject
|
|
{
|
|
private:
|
|
TString_array _store;
|
|
|
|
public:
|
|
TToken_string& operator[](int i) const;
|
|
int curr_index() const { return _store.last(); }
|
|
void set(const int index, const TipoDitta tipo=normale, const int num_fis=0, const int num_nofis=0,
|
|
bool ultima_con_fis=FALSE, bool ultima_con_nofis=FALSE, const char* cofidic=NULL);
|
|
void set_tipo(const int index, const TipoDitta tipo);
|
|
void set_ultima_con_fis(const int index, const bool ultima_fis);
|
|
void set_ultima_con_nofis(const int index, const bool ultima_nofis);
|
|
void set_flag_tipi(const int index, const bool ultima_fis, const bool ultima_nofis);
|
|
void set_ctr_tipi(const int index, const int num_fis, const int num_nofis);
|
|
void add(const long codditta, const TipoDitta tipo=normale, const int num_fis=0, const int num_nofis=0,
|
|
bool ultima_con_fis=FALSE, bool ultima_con_nofis=FALSE, const char* cofidic=NULL);
|
|
int items() const { return _store.items(); }
|
|
void destroy() { _store.destroy(); }
|
|
};
|
|
|
|
|
|
TToken_string& TStDicArray::operator[](int i) const
|
|
{
|
|
return ((TString_array&)_store).row(i);
|
|
}
|
|
|
|
void TStDicArray::set_ultima_con_fis(const int index, const bool ultima_fis)
|
|
{
|
|
TToken_string riga((TString&)_store[index]);
|
|
riga.add(ultima_fis, 4);
|
|
_store.add(riga,index);
|
|
}
|
|
|
|
void TStDicArray::set_ultima_con_nofis(const int index, const bool ultima_nofis)
|
|
{
|
|
TToken_string riga((TString&)_store[index]);
|
|
riga.add(ultima_nofis, 5);
|
|
_store.add(riga,index);
|
|
}
|
|
|
|
void TStDicArray::set_flag_tipi(const int index, const bool ultima_fis, const bool ultima_nofis)
|
|
{
|
|
TToken_string riga((TString&)_store[index]);
|
|
riga.add(ultima_fis,4);
|
|
riga.add(ultima_nofis,5);
|
|
_store[index] = riga;
|
|
}
|
|
|
|
void TStDicArray::set_ctr_tipi(const int index, const int num_fis, const int num_nofis)
|
|
{
|
|
TToken_string riga((TString&)_store[index]);
|
|
riga.add(num_fis,2);
|
|
riga.add(num_nofis,3);
|
|
_store[index] = riga;
|
|
}
|
|
|
|
void TStDicArray::set(const int index, const TipoDitta tipo, const int num_fis, const int num_nofis,
|
|
bool ultima_con_fis, bool ultima_con_nofis, const char* cofi_dic)
|
|
{
|
|
TToken_string riga((TString&)_store[index]);
|
|
riga.add(tipo,1);
|
|
riga.add(num_fis,2);
|
|
riga.add(num_nofis,3);
|
|
riga.add(ultima_con_fis,4);
|
|
riga.add(ultima_con_nofis,5);
|
|
TString codfis(20); codfis = cofi_dic ? cofi_dic : "";
|
|
riga.add((const char*)codfis,6);
|
|
_store[index] = riga;
|
|
}
|
|
|
|
void TStDicArray::add(const long codditta, const TipoDitta tipo, const int num_fis, const int num_nofis,
|
|
bool ultima_con_fis, bool ultima_con_nofis, const char* cfdic)
|
|
{
|
|
TString key(40);
|
|
// Il formato della riga e': codditta|estinti|numfis|numnofis|ultimafis|ultimanofis
|
|
key.format("%ld|%d|%d|%d|%d|%d|%s", codditta, tipo, num_fis, num_nofis, ultima_con_fis, ultima_con_nofis, cfdic ? cfdic : "");
|
|
_store.add(key);
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// STAMPA QUADRO
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TStampaQuadro : public TApplication
|
|
{
|
|
TMask* _m; // Maschera di stampa
|
|
|
|
TConfig* _cnf; // Configurazione
|
|
TString16 _section; // Paragrafo del config
|
|
long _codditta;
|
|
int _anno_dic;
|
|
|
|
TString _quadro;
|
|
char _livello; // "S" studio, "D" singola ditta
|
|
TString _title;
|
|
|
|
TStDicArray _ditte;
|
|
|
|
protected: // TApplication
|
|
virtual bool menu(MENU_TAG);
|
|
virtual void on_config_change();
|
|
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
|
|
protected:
|
|
virtual bool user_create() pure;
|
|
virtual bool user_destroy() pure;
|
|
|
|
virtual TDicForm* get_form() const pure;
|
|
virtual TCursor* get_cursor() const pure;
|
|
|
|
virtual const char* mask_name() const;
|
|
virtual const char* form_name() const;
|
|
|
|
virtual bool conta_tipi_per() const { return TRUE; }
|
|
void fill_estinti(const long CodDic);
|
|
const TStDicArray& ditte() const { return _ditte; }
|
|
|
|
virtual bool print_quadro(const int OffsetDitta, const bool modulaser);
|
|
virtual void print(const bool modulaser);
|
|
|
|
bool singola_ditta() const { return _livello == 'D'; }
|
|
const TString& quadro() const { return _quadro; }
|
|
|
|
TStampaQuadro(const char* quad, char liv);
|
|
|
|
public:
|
|
const TString& taitol() const { return _title; }
|
|
|
|
virtual ~TStampaQuadro() { }
|
|
};
|
|
|
|
TStampaQuadro::TStampaQuadro(const char* quad, char liv)
|
|
: _quadro(quad), _livello(liv)
|
|
{
|
|
_title = "Stampa Quadro "; _title << _quadro;
|
|
}
|
|
|
|
// La maschera e' uguale per tutti i quadri
|
|
const char* TStampaQuadro::mask_name() const
|
|
{
|
|
return "77STQD";
|
|
}
|
|
|
|
const char* TStampaQuadro::form_name() const
|
|
{
|
|
__dep16 = "77Q";
|
|
__dep16 << _quadro;
|
|
return __dep16;
|
|
}
|
|
|
|
bool TStampaQuadro::create()
|
|
{
|
|
TApplication::create();
|
|
|
|
_section = name();
|
|
_section.cut(2);
|
|
_cnf = new TConfig(CONFIG_USER, _section);
|
|
|
|
_m = new TMask(mask_name());
|
|
_m->set_caption(taitol());
|
|
|
|
if (singola_ditta())
|
|
{
|
|
_codditta = get_firm_770();
|
|
_m->set(F_CODDITTA, _codditta);
|
|
}
|
|
else
|
|
{
|
|
_m->hide(F_RAGDITTA);
|
|
_m->set(F_TEXT, "Ditte selezionate");
|
|
_m->show(F_TEXT);
|
|
}
|
|
|
|
user_create();
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaQuadro::destroy()
|
|
{
|
|
user_destroy();
|
|
|
|
delete _m;
|
|
delete _cnf;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
void TStampaQuadro::on_config_change()
|
|
{
|
|
TConfig conf(singola_ditta() ? CONFIG_STUDIO : CONFIG_USER);
|
|
_anno_dic = (int)conf.get_long(ANNO_SEL, _section);
|
|
}
|
|
|
|
bool TStampaQuadro::menu(MENU_TAG)
|
|
{
|
|
KEY k;
|
|
_m->set(F_ANNO, _anno_dic);
|
|
while ((k = _m->run()) == K_ENTER)
|
|
{
|
|
const bool modulaser = _m->get_bool(F_MODULASER);
|
|
print(modulaser);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void TStampaQuadro::fill_estinti(const long CodDic)
|
|
{
|
|
int NumFisiche=0, NumNoFisiche=0;
|
|
TString CodFiDic(20);
|
|
|
|
// Salva il cod.fis. del dichiarante
|
|
CodFiDic = cod_fis(CodDic);
|
|
|
|
if (conta_tipi_per())
|
|
{
|
|
conta_tipiper(CodDic, _quadro, &NumFisiche, &NumNoFisiche);
|
|
_ditte.add(CodDic, dichiarante, NumFisiche, NumNoFisiche);
|
|
}
|
|
else
|
|
_ditte.add(CodDic, dichiarante);
|
|
|
|
const int index_dich = _ditte.curr_index();
|
|
bool gia_trovata_ultima_fis = FALSE;
|
|
bool gia_trovata_ultima_nofis = FALSE;
|
|
int index = index_dich;
|
|
|
|
// Leggo gli estinti
|
|
TLocalisamfile base(LF_BASE);
|
|
base.setkey(2);
|
|
base.zero();
|
|
base.put(BSE_CODDIC, (long)CodDic);
|
|
TRectype dep(base.curr());
|
|
|
|
for (base.read(); !base.eof(); base.next())
|
|
{
|
|
if (base.curr() > dep)
|
|
break;
|
|
|
|
// Scarta il record del quadro I "globale" del dichiarante
|
|
const char tipoqua = base.get(BSE_TIPOQUA)[0];
|
|
if (tipoqua == COD_QUA_I_DIC)
|
|
continue;
|
|
|
|
const long DittaEstinta = base.get_long(BSE_CODDITTA);
|
|
|
|
if (conta_tipi_per())
|
|
{
|
|
conta_tipiper(DittaEstinta, _quadro, &NumFisiche, &NumNoFisiche);
|
|
_ditte.add(DittaEstinta, estinto, NumFisiche, NumNoFisiche, FALSE, FALSE, CodFiDic);
|
|
}
|
|
else
|
|
_ditte.add(DittaEstinta, estinto, 0L, 0L, FALSE, FALSE, CodFiDic);
|
|
|
|
if (conta_tipi_per())
|
|
{
|
|
// Determina se con questa ditta finiscono le persone f. o g.
|
|
if (NumFisiche == 0 && !gia_trovata_ultima_fis)
|
|
{
|
|
_ditte.set_ultima_con_fis(index, TRUE);
|
|
gia_trovata_ultima_fis = TRUE;
|
|
}
|
|
|
|
if (NumNoFisiche == 0 && !gia_trovata_ultima_nofis)
|
|
{
|
|
_ditte.set_ultima_con_nofis(index, TRUE);
|
|
gia_trovata_ultima_nofis = TRUE;
|
|
}
|
|
}
|
|
index++;
|
|
}
|
|
|
|
if (conta_tipi_per())
|
|
{
|
|
// Finiti gli estinti. L'ultima ditta deve avere i totali se non gia' trovati
|
|
if (!gia_trovata_ultima_fis)
|
|
_ditte.set_ultima_con_fis(index, TRUE);
|
|
|
|
if (!gia_trovata_ultima_nofis)
|
|
_ditte.set_ultima_con_nofis(index, TRUE);
|
|
}
|
|
}
|
|
|
|
// _ditte e' fatto di righe siffatte:
|
|
// codditta, flag 2 dichiarante, 1 normale, 0 estinto, num_fis, num_nofis, ultima_con_fis, ultima_con_nofis
|
|
|
|
bool TStampaQuadro::print_quadro(const int OffsetDitta, const bool modulaser)
|
|
{
|
|
TDicForm* ff = get_form();
|
|
int start=0, last=0;
|
|
// Setta formlen prima di printer.open per avere la lunghezza giusta nel caso di
|
|
// stampa a video
|
|
printer().formlen(QD_FORMLEN);
|
|
bool ok = printer().open();
|
|
|
|
ff->set_cursor(get_cursor());
|
|
ff->azzera_totali();
|
|
ff->set_modulaser(modulaser);
|
|
|
|
// Dice se deve eseguire il posizionamento del foglio.
|
|
// Se stampa piu' ditte va eseguito solo sulla prima
|
|
// Occhio a non spostarlo nel ciclo.
|
|
ff->set_posiziona(TRUE);
|
|
|
|
if (OffsetDitta >= 0)
|
|
{
|
|
start = OffsetDitta;
|
|
last = OffsetDitta;
|
|
}
|
|
else
|
|
last = _ditte.items() - 1;
|
|
|
|
for (int i = start; i <= last; i++)
|
|
{
|
|
TString CoFiDic(20);
|
|
TToken_string riga(ditte()[i]);
|
|
const long codditta = atol(riga.get(0));
|
|
const TipoDitta tipo = (TipoDitta)riga.get_int(1);
|
|
const long fis = riga.get_long(2);
|
|
const long nofis = riga.get_long(3);
|
|
const bool LastFis = (bool)riga.get_int(4);
|
|
const bool LastNoFis = (bool)riga.get_int(5);
|
|
|
|
// I gruppi dich-estinti hanno totali comuni
|
|
// Si presume che nell'array vengano messi nell'ordine dich-estinti
|
|
if (tipo == normale || tipo == dichiarante)
|
|
ff->azzera_totali();
|
|
|
|
if (tipo == estinto)
|
|
CoFiDic = riga.get(6);
|
|
|
|
if (conta_tipi_per())
|
|
{
|
|
// Se e' un dichiarante i totali vanno sull'estinto in cui finiscono o le F o le G
|
|
const bool StampaTotaliFis = tipo == normale ||
|
|
(tipo == estinto && LastFis);
|
|
|
|
const bool StampaTotaliNoFis = tipo == normale ||
|
|
(tipo == estinto && LastNoFis);
|
|
|
|
// Dice al form se e' questa ditta e' l'ultima con f. o g.
|
|
ff->can_print_tot_fis(StampaTotaliFis);
|
|
ff->can_print_tot_nofis(StampaTotaliNoFis);
|
|
}
|
|
|
|
// Dice al form che tipo di ditta si stampa
|
|
ff->set_tipo_ditta(tipo);
|
|
|
|
// Numera i fogli a partire da 1 per ogni ditta normale e da 1 e di seguito negli estinti
|
|
// per i sogg. dichiaranti
|
|
if (tipo == normale || tipo == dichiarante)
|
|
ff->set_num_foglio(1);
|
|
|
|
// Se la ditta e' estinta dice al form il cod.fis. del dichiarante
|
|
if (tipo == estinto)
|
|
ff->set_cofi_dic(CoFiDic);
|
|
|
|
// Dice al form che e' l'ultima ditta
|
|
if (i == last)
|
|
ff->set_last_ditta(TRUE);
|
|
|
|
ff->print(codditta, fis, nofis);
|
|
}
|
|
|
|
printer().close();
|
|
return ok;
|
|
}
|
|
|
|
void TStampaQuadro::print(const bool modulaser)
|
|
{
|
|
int NumFisiche=0, NumNoFisiche=0;
|
|
|
|
_ditte.destroy(); // Pulisce l'array delle ditte
|
|
|
|
if (singola_ditta())
|
|
{
|
|
if (sogg_estinto(_codditta))
|
|
{
|
|
warning_box("La ditta %ld e' un soggetto estinto", _codditta);
|
|
return;
|
|
}
|
|
|
|
// Se e' un dichiarante va a prendere tutti i suoi estinti.
|
|
bool dich = sogg_dic(_codditta);
|
|
if (dich)
|
|
fill_estinti(_codditta);
|
|
else
|
|
{
|
|
if (conta_tipi_per())
|
|
{
|
|
conta_tipiper(_codditta, _quadro, &NumFisiche, &NumNoFisiche);
|
|
_ditte.add(_codditta, normale, NumFisiche, NumNoFisiche);
|
|
}
|
|
else
|
|
_ditte.add(_codditta, normale);
|
|
}
|
|
}
|
|
else // stampa ditte selezionate
|
|
{
|
|
// Costruisco un'array delle ditte da stampare.
|
|
// Tolgo i sogg. estinti, e dopo un dichiarante metto tutti i suoi estinti.
|
|
long codditta_prec = get_firm_770();
|
|
long codditta = 0L;
|
|
int i=0;
|
|
while ((codditta = _cnf->get_long(DITTE_SEL, _section, i++)) != 0L)
|
|
{
|
|
if (sogg_estinto(codditta))
|
|
continue;
|
|
|
|
// Se e' un dichiarante va a prendere tutti i suoi estinti.
|
|
bool dich = sogg_dic(codditta);
|
|
if (dich)
|
|
fill_estinti(codditta);
|
|
else
|
|
{
|
|
if (conta_tipi_per())
|
|
{
|
|
conta_tipiper(codditta, _quadro, &NumFisiche, &NumNoFisiche);
|
|
_ditte.add(codditta, normale, NumFisiche, NumNoFisiche);
|
|
}
|
|
else
|
|
_ditte.add(codditta, normale);
|
|
}
|
|
}
|
|
set_firm_770(codditta_prec);
|
|
}
|
|
|
|
print_quadro(-1, modulaser);
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// STAMPA QUADRO D
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
class TStampaQuadroD : public TStampaQuadro
|
|
{
|
|
TDicForm* _form;
|
|
TRelation* _rel;
|
|
TCursor* _cur;
|
|
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
|
|
virtual TDicForm* get_form() const { return _form; }
|
|
virtual TCursor* get_cursor() const { return _cur; }
|
|
|
|
public:
|
|
TStampaQuadroD(const char* quadro, char livel);
|
|
virtual ~TStampaQuadroD() { }
|
|
};
|
|
|
|
TStampaQuadroD::TStampaQuadroD(const char* quadro, char liv)
|
|
: TStampaQuadro(quadro, liv)
|
|
{
|
|
}
|
|
|
|
bool TStampaQuadroD::user_create()
|
|
{
|
|
if (quadro() == "C")
|
|
{
|
|
_rel = new TRelation(LF_QUAC);
|
|
_rel->add("%CA7", "CODTAB=CODCAUS", 1, LF_QUAC, 14);
|
|
_rel->add(LF_NDITTE, "CODDITTA=CODDITTA");
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_QUAC, 216);
|
|
_rel->add("%STA", "CODTAB=STATORES", 1, -216, 24);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, -216, 218);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, -218, 313);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, -216, 413);
|
|
_cur = new TSorted_cursor(_rel, "CODDITTA|TIPOA|216@->RAGSOC|CODANAGR|CODCAUS|PERC");
|
|
}
|
|
|
|
if (quadro() == "D")
|
|
{
|
|
_rel = new TRelation(LF_QUAD);
|
|
_rel->add("%CA7", "CODTAB=CODCAUS", 1, LF_QUAD, 14);
|
|
_rel->add(LF_NDITTE, "CODDITTA=CODDITTA");
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_QUAD, 216);
|
|
_rel->add("%STA", "CODTAB=STATORES", 1, -216, 24);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, -216, 218);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, -218, 313);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, -216, 413);
|
|
_cur = new TSorted_cursor(_rel, "CODDITTA|TIPOA|216@->RAGSOC|CODANAGR|CODCAUS|PERC");
|
|
}
|
|
|
|
if (quadro() == "D1")
|
|
{
|
|
_rel = new TRelation(LF_QUAD1);
|
|
_rel->add("%CA7", "CODTAB=CODCAUS", 1, LF_QUAD1, 14);
|
|
_rel->add(LF_NDITTE, "CODDITTA=CODDITTA");
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_QUAD1, 216);
|
|
_rel->add("%STA", "CODTAB=STATORES", 1, -216, 24);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, -216, 218);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, -218, 313);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, -216, 413);
|
|
_cur = new TSorted_cursor(_rel, "CODDITTA|TIPOA|216@->RAGSOC|CODANAGR|CODCAUS|PERC");
|
|
}
|
|
|
|
if (quadro() == "E")
|
|
{
|
|
_rel = new TRelation(LF_QUAE);
|
|
_rel->add("%CA7", "CODTAB=CODCAUS", 1, LF_QUAE, 14);
|
|
_rel->add(LF_NDITTE, "CODDITTA=CODDITTA");
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_QUAE, 216);
|
|
_rel->add("%STA", "CODTAB=STATORES", 1, -216, 24);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, -216, 218);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, -218, 313);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, -216, 413);
|
|
_cur = new TSorted_cursor(_rel, "CODDITTA|TIPOA|216@->RAGSOC|CODANAGR|CODCAUS|PERC");
|
|
}
|
|
|
|
if (quadro() == "E1")
|
|
{
|
|
_rel = new TRelation(LF_QUAE1);
|
|
_rel->add("%CA7", "CODTAB=CODCAUS", 1, LF_QUAE1, 14);
|
|
_rel->add(LF_NDITTE, "CODDITTA=CODDITTA");
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_QUAE1, 216);
|
|
_rel->add("%STA", "CODTAB=STATORES", 1, -216, 24);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, -216, 218);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, -218, 313);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, -216, 413);
|
|
_cur = new TSorted_cursor(_rel, "CODDITTA|TIPOA|216@->RAGSOC|CODANAGR|CODCAUS|PERC");
|
|
}
|
|
|
|
_form = new TDicForm(form_name(), quadro());
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaQuadroD::user_destroy()
|
|
{
|
|
delete _form;
|
|
delete _cur;
|
|
delete _rel;
|
|
return TRUE;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// STAMPA QUADRO G
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
class TStampaQuadroG : public TStampaQuadro
|
|
{
|
|
private:
|
|
TQuadroG* _form_g;
|
|
TDistintaG* _form_gd;
|
|
TRelation* _rel_g, * _rel_gd;
|
|
TCursor* _cur_g, * _cur_gd;
|
|
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
|
|
virtual TDicForm* get_form() const { return _form_g; }
|
|
virtual TCursor* get_cursor() const { return _cur_g; }
|
|
|
|
virtual bool print_quadro(const int OffsetDitta, const bool modulaser);
|
|
|
|
public:
|
|
TStampaQuadroG(char livel) : TStampaQuadro("G", livel) { }
|
|
};
|
|
|
|
bool TStampaQuadroG::user_create()
|
|
{
|
|
_rel_g = new TRelation(LF_QUAG);
|
|
_rel_g->add(LF_NDITTE, "CODDITTA=CODDITTA");
|
|
_rel_g->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel_g->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel_g->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel_g->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_cur_g = new TCursor(_rel_g);
|
|
|
|
_rel_gd = new TRelation(LF_QUAGD);
|
|
_rel_gd->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_QUAGD, 216);
|
|
_rel_gd->add("%STA", "CODTAB=STATORES", 1, -216, 24);
|
|
_rel_gd->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, -216, 218);
|
|
_rel_gd->add(LF_COMUNI, "COM=COMNASC", 1, -218, 313);
|
|
_rel_gd->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, -216, 413);
|
|
_cur_gd = new TSorted_cursor(_rel_gd, "CODDITTA|TIPOA|216@->RAGSOC|CODANAGR");
|
|
|
|
_form_g = new TQuadroG("77QG", quadro());
|
|
_form_gd = new TDistintaG("77QGD", quadro());
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaQuadroG::user_destroy()
|
|
{
|
|
delete _form_gd;
|
|
delete _form_g;
|
|
|
|
delete _rel_gd;
|
|
delete _cur_gd;
|
|
|
|
delete _rel_g;
|
|
delete _cur_g;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// _ditte e' fatto di righe siffatte:
|
|
// codditta, flag 2 dichiarante, 1 normale, 0 estinto, num_fis, num_nofis, ultima_con_fis, ultima_con_nofis
|
|
bool TStampaQuadroG::print_quadro(const int OffsetDitta, const bool modulaser)
|
|
{
|
|
int start=0, last=0;
|
|
long items_g, items_gd;
|
|
|
|
items_g = items_gd = 0L;
|
|
// Setta formlen prima di printer.open per avere la lunghezza giusta nel caso di
|
|
// stampa a video
|
|
printer().formlen(QG_FORMLEN);
|
|
bool ok = printer().open();
|
|
|
|
_form_g->set_cursor(_cur_g);
|
|
_form_gd->set_cursor(_cur_gd);
|
|
|
|
_form_g->set_modulaser(modulaser);
|
|
_form_gd->set_modulaser(modulaser);
|
|
|
|
_form_gd->azzera_totali();
|
|
|
|
// Dice se deve eseguire il posizionamento del foglio.
|
|
// Se stampa piu' ditte va eseguito solo sulla prima
|
|
// Occhio a non spostarlo nel ciclo.
|
|
_form_g->set_posiziona(TRUE);
|
|
|
|
if (OffsetDitta >= 0)
|
|
{
|
|
start = OffsetDitta;
|
|
last = OffsetDitta;
|
|
}
|
|
else
|
|
last = ditte().items() - 1;
|
|
|
|
for (int i = start; i <= last; i++)
|
|
{
|
|
TString CoFiDic(20);
|
|
TToken_string riga(ditte()[i]);
|
|
const long codditta = atol(riga.get(0));
|
|
const TipoDitta tipo = (TipoDitta)riga.get_int(1);
|
|
const long fis = riga.get_long(2);
|
|
const long nofis = riga.get_long(3);
|
|
const bool LastFis = (bool)riga.get_int(4);
|
|
const bool LastNoFis = (bool)riga.get_int(5);
|
|
|
|
// I gruppi dich-estinti hanno totali comuni
|
|
// Si presume che nell'array vengano messi nell'ordine dich-estinti
|
|
if (tipo == normale || tipo == dichiarante)
|
|
_form_g->azzera_totali();
|
|
|
|
if (tipo == estinto)
|
|
CoFiDic = riga.get(6);
|
|
|
|
// Se e' un dichiarante i totali vanno sull'estinto in cui finiscono o le F o le G
|
|
const bool StampaTotaliFis = tipo == normale ||
|
|
(tipo == estinto && LastFis);
|
|
|
|
const bool StampaTotaliNoFis = tipo == normale ||
|
|
(tipo == estinto && LastNoFis);
|
|
|
|
// Dice al form se e' questa ditta e' l'ultima con f. o g.
|
|
_form_gd->can_print_tot_fis(StampaTotaliFis);
|
|
_form_gd->can_print_tot_nofis(StampaTotaliNoFis);
|
|
|
|
// Dice al form che tipo di ditta si stampa
|
|
_form_g->set_tipo_ditta(tipo);
|
|
|
|
// Numera i fogli a partire da 1 per ogni ditta normale e da 1 e di seguito negli estinti
|
|
// per i sogg. dichiaranti
|
|
if (tipo == normale || tipo == dichiarante)
|
|
_form_g->set_num_foglio(1);
|
|
|
|
// Se la ditta e' estinta dice al form il cod.fis. del dichiarante
|
|
if (tipo == estinto)
|
|
_form_g->set_cofi_dic(CoFiDic);
|
|
|
|
// Dice al form che e' l'ultima ditta
|
|
if (i == last)
|
|
_form_gd->set_last_ditta(TRUE);
|
|
|
|
items_g = _form_g->filtra(codditta);
|
|
items_gd = _form_gd->filtra(codditta);
|
|
|
|
// Dice al form quanto e' lunga la progress-bar
|
|
_form_g->set_items_gd(items_g, items_gd);
|
|
|
|
_form_g->print(codditta, fis, nofis);
|
|
// La progind deve essere la stessa tra G e distinta...
|
|
|
|
_form_gd->set_progind(_form_g->progind()); // Passa la progind al form gd ...
|
|
_form_g->set_progind(NULL); // ... e la toglie dal form g
|
|
|
|
_form_gd->print(codditta, fis, nofis);
|
|
}
|
|
|
|
printer().close();
|
|
return ok;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Quadro G-1
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
HIDDEN const int QG1_FORMLEN = 72;
|
|
HIDDEN const int QG1_PAGINE = 1;
|
|
|
|
class TQuadroG1 : public TDicForm
|
|
{
|
|
private:
|
|
long _items;
|
|
void stampa_prospetto(TPrinter& pr);
|
|
|
|
public:
|
|
virtual bool print(const long codditta, const long NumFis=0L, const long NumNoFis=0L);
|
|
//virtual bool print(const long codditta);
|
|
|
|
TQuadroG1(const char* form, const char* quadro) : TDicForm(form, quadro) {}
|
|
virtual ~TQuadroG1() {}
|
|
};
|
|
|
|
bool TQuadroG1::print(const long codditta, const long NumFis, const long NumNoFis)
|
|
{
|
|
TCursor* cur = cursor();
|
|
TPrinter& pr = printer();
|
|
|
|
if (!InitPrint(codditta))
|
|
return FALSE;
|
|
|
|
pr.formlen(QG1_FORMLEN);
|
|
|
|
if (_modulaser) ClearFlagModulaser();
|
|
|
|
(*cur) = 0L;
|
|
stampa_prospetto(pr);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TQuadroG1::stampa_prospetto(TPrinter& pr)
|
|
{
|
|
TPrint_section& head = section('H', 1);
|
|
const word rr = head.height()-1;
|
|
TPrintrow& head_row = head.row(rr-1);
|
|
|
|
// Setta il cod.fis. del dichiarante se necessario
|
|
if (tipo_ditta() == estinto)
|
|
{
|
|
TForm_item& cfd = head.find_field(H_COFI_DIC);
|
|
cfd.set(_cofi_dic);
|
|
}
|
|
|
|
TCursor* cur = cursor();
|
|
// Prospetto
|
|
TRectype& r = cur->curr();
|
|
TToken_string p12(r.get("P12"));
|
|
TToken_string p13(r.get("P13"));
|
|
TToken_string p14(r.get("P14"));
|
|
TToken_string p15(r.get("P15"));
|
|
TToken_string p16(r.get("P16"));
|
|
TToken_string p17(r.get("P17"));
|
|
|
|
const int START_PROSP = 56;
|
|
const int RIGHE_COL356 = 12;
|
|
const int RIGHE_COL27 = 5;
|
|
const int COL_PROSP = 5;
|
|
|
|
// Colonne 2 e 7
|
|
for (int i = 0; i < RIGHE_COL27; i++)
|
|
{
|
|
const int fc2 = START_PROSP + i;
|
|
TForm_item& c2 = head.find_field(fc2);
|
|
c2.set(p12.get(i));
|
|
|
|
const int fc7 = fc2 + RIGHE_COL27 + 1;
|
|
TForm_item& c7 = head.find_field(fc7);
|
|
c7.set(p17.get(i));
|
|
}
|
|
|
|
const int START_COL3 = 68;
|
|
// Colonne 3 5 e 6
|
|
for (i = 0; i < RIGHE_COL356; i++)
|
|
{
|
|
const int fc3 = START_COL3 + i;
|
|
TForm_item& c3 = head.find_field(fc3);
|
|
c3.set(p13.get(i));
|
|
|
|
const int fc5 = fc3 + RIGHE_COL356 + 1;
|
|
TForm_item& c5 = head.find_field(fc5);
|
|
c5.set(p15.get(i));
|
|
|
|
const int fc6 = fc5 + RIGHE_COL356 + 1;
|
|
TForm_item& c6 = head.find_field(fc6);
|
|
c6.set(p16.get(i));
|
|
}
|
|
|
|
// Righe da saltare nelle prime pag. dei moduli successivi al primo (che' son
|
|
// senza le righe del posizionamento...)
|
|
int HEADER_PRIMA_NOPOS = 3;
|
|
head.update();
|
|
for (word j = 0; j <= rr; j++)
|
|
{
|
|
if (j==0)
|
|
{
|
|
if (_modulaser)
|
|
{
|
|
TPrintrow& r = head.row(j);
|
|
if (!_GiaMessoStartDoc)
|
|
put_modulaser(r, STARTDOC);
|
|
put_modulaser(r, STARTDITTA);
|
|
put_modulaser(r, STARTPAGE, 1);
|
|
pr.print(r);
|
|
_RigaCorr++;
|
|
r.reset();
|
|
HEADER_PRIMA_NOPOS--;
|
|
}
|
|
if (!PaginaPosizionamento())
|
|
fill_page(pr, HEADER_PRIMA_NOPOS);
|
|
}
|
|
else
|
|
{
|
|
pr.print(head.row(j));
|
|
_RigaCorr++;
|
|
}
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// STAMPA QUADRO G-1
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
class TStampaQuadroG1 : public TStampaQuadroD
|
|
{
|
|
private:
|
|
TQuadroG1* _form;
|
|
TRelation* _rel;
|
|
TCursor* _cur;
|
|
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
|
|
virtual TDicForm* get_form() const { return _form; }
|
|
virtual TCursor* get_cursor() const { return _cur; }
|
|
virtual bool conta_tipi_per() const { return FALSE; }
|
|
|
|
public:
|
|
TStampaQuadroG1(char livel) : TStampaQuadroD("G1", livel) {}
|
|
};
|
|
|
|
bool TStampaQuadroG1::user_create()
|
|
{
|
|
_form = new TQuadroG1("77QG1", quadro());
|
|
|
|
_rel = new TRelation(LF_QUAG1);
|
|
_rel->add(LF_NDITTE, "CODDITTA=CODDITTA");
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_cur = new TCursor(_rel);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaQuadroG1::user_destroy()
|
|
{
|
|
delete _cur;
|
|
delete _rel;
|
|
delete _form;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/*
|
|
// _ditte e' fatto di righe siffatte:
|
|
// codditta, flag 2 dichiarante, 1 normale, 0 estinto, num_fis, num_nofis, ultima_con_fis, ultima_con_nofis
|
|
bool TStampaQuadroG1::print_quadro(TString& quadro, const int OffsetDitta)
|
|
{
|
|
int start=0, last=0;
|
|
|
|
// Setta formlen prima di printer.open per avere la lunghezza giusta nel caso di
|
|
// stampa a video
|
|
printer().formlen(QG_FORMLEN);
|
|
bool ok = printer().open();
|
|
bool modulaser = _m->get_bool(F_MODULASER);
|
|
|
|
_form->set_cursor(_rel, _cur);
|
|
|
|
_form->set_modulaser(modulaser);
|
|
|
|
// Dice se deve eseguire il posizionamento del foglio.
|
|
// Se stampa piu' ditte va eseguito solo sulla prima
|
|
// Occhio a non spostarlo nel ciclo.
|
|
_form->set_posiziona(TRUE);
|
|
|
|
if (OffsetDitta >= 0)
|
|
{
|
|
start = OffsetDitta;
|
|
last = OffsetDitta;
|
|
}
|
|
else
|
|
last = _ditte.items() - 1;
|
|
|
|
for (int i = start; i <= last; i++)
|
|
{
|
|
TString CoFiDic(20);
|
|
TToken_string riga(_ditte[i]);
|
|
riga.separator('|');
|
|
const long codditta = atol(riga.get(0));
|
|
const TipoDitta tipo = (TipoDitta)riga.get_int(1);
|
|
|
|
// I gruppi dich-estinti hanno totali comuni
|
|
// Si presume che nell'array vengano messi nell'ordine dich-estinti
|
|
if (tipo == normale || tipo == dichiarante)
|
|
_form->azzera_totali();
|
|
|
|
if (tipo == estinto)
|
|
CoFiDic = riga.get(6);
|
|
|
|
// Dice al form che tipo di ditta si stampa
|
|
_form->set_tipo_ditta(tipo);
|
|
|
|
// Numera i fogli a partire da 1 per ogni ditta normale e da 1 e di seguito negli estinti
|
|
// per i sogg. dichiaranti
|
|
if (tipo == normale || tipo == dichiarante)
|
|
_form->set_num_foglio(1);
|
|
|
|
// Se la ditta e' estinta dice al form il cod.fis. del dichiarante
|
|
if (tipo == estinto)
|
|
_form->set_cofi_dic(CoFiDic);
|
|
|
|
// Dice al form che e' l'ultima ditta
|
|
if (i == last)
|
|
_form->set_last_ditta(TRUE);
|
|
|
|
_form->print(codditta);
|
|
}
|
|
printer().close();
|
|
return ok;
|
|
}
|
|
*/
|
|
/*
|
|
void TStampaQuadroG1::fill_estinti(const long CodDic)
|
|
{
|
|
int NumFisiche=0, NumNoFisiche=0;
|
|
TString CodFiDic(20);
|
|
|
|
// Salva il cod.fis. del dichiarante
|
|
CodFiDic = cod_fis(CodDic);
|
|
|
|
_ditte.add(CodDic, dichiarante);
|
|
const int index_dich = _ditte.curr_index();
|
|
int index = index_dich;
|
|
|
|
// Leggo gli estinti
|
|
TLocalisamfile base(LF_BASE);
|
|
base.setkey(2);
|
|
base.zero();
|
|
base.put(BSE_CODDIC, (long)CodDic);
|
|
TRectype dep(base.curr());
|
|
|
|
for (base.read(); !base.eof(); base.next())
|
|
{
|
|
if (base.curr() > dep)
|
|
break;
|
|
|
|
// Scarta il record del quadro I "globale" del dichiarante
|
|
const char tipoqua = base.get(BSE_TIPOQUA)[0];
|
|
if (tipoqua == COD_QUA_I_DIC)
|
|
continue;
|
|
|
|
const long DittaEstinta = base.get_long(BSE_CODDITTA);
|
|
|
|
_ditte.add(DittaEstinta, estinto, 0L, 0L, FALSE, FALSE, CodFiDic);
|
|
|
|
index++;
|
|
}
|
|
}
|
|
*/
|
|
/*
|
|
void TStampaQuadroG1::print()
|
|
{
|
|
int NumFisiche=0, NumNoFisiche=0;
|
|
|
|
_ditte.destroy(); // Pulisce l'array delle ditte
|
|
|
|
if (_singola_ditta)
|
|
{
|
|
if (sogg_estinto(_codditta))
|
|
{
|
|
warning_box("La ditta %ld e' un soggetto estinto", _codditta);
|
|
return;
|
|
}
|
|
|
|
// Se e' un dichiarante va a prendere tutti i suoi estinti.
|
|
bool dich = sogg_dic(_codditta);
|
|
if (dich)
|
|
fill_estinti(_codditta);
|
|
else
|
|
_ditte.add(_codditta, normale);
|
|
}
|
|
else // stampa ditte selezionate
|
|
{
|
|
// Costruisco un'array delle ditte da stampare.
|
|
// Tolgo i sogg. estinti, e dopo un dichiarante metto tutti i suoi estinti.
|
|
long codditta_prec = get_firm_770();
|
|
long codditta = 0L;
|
|
int i=0;
|
|
while ((codditta = _cnf->get_long(DITTE_SEL, _section, i++)) != 0L)
|
|
{
|
|
if (sogg_estinto(codditta))
|
|
continue;
|
|
|
|
// Se e' un dichiarante va a prendere tutti i suoi estinti.
|
|
bool dich = sogg_dic(codditta);
|
|
if (dich)
|
|
fill_estinti(codditta);
|
|
else
|
|
_ditte.add(codditta, normale);
|
|
|
|
}
|
|
set_firm_770(codditta_prec);
|
|
}
|
|
print_quadro(_quadro, -1);
|
|
}
|
|
*/
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Quadro F
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
HIDDEN const int QF_FORMLEN = 72;
|
|
HIDDEN const int QF_PAGINE = 2;
|
|
HIDDEN const int HEADER_SECONDA_F = 7;
|
|
|
|
class TQuadroF : public TDicForm
|
|
{
|
|
private:
|
|
real pa3t, pa4t, pa5t, pa6t, pa7t; // totali prosp. A
|
|
real pb3t, pb4t, pc3t, pc4t, pd3t, pd4t; // totali prosp, B, C e D
|
|
int _ptrA, _ptrB, _ptrC, _ptrD; // puntatori alle righe dei prospetti
|
|
long _items;
|
|
int stampa_prospetto_A(TPrinter& pr);
|
|
int stampa_prospetto_B(TPrinter& pr);
|
|
int stampa_prospetto_C(TPrinter& pr);
|
|
int stampa_prospetto_D(TPrinter& pr);
|
|
TRecord_array* _prosp_a, *_prosp_b, *_prosp_c, *_prosp_d;
|
|
void azzera_contatori();
|
|
void aggiorna_totali(char tipoprosp, TRectype& r);
|
|
void stampa_totali(char tipoprosp, TPrinter& pr);
|
|
|
|
public:
|
|
virtual bool print(const long codditta, const long numfis=0L, const long numnofis=0L);
|
|
virtual void inc_curr_page();
|
|
virtual void next_page(TPrinter& pr);
|
|
|
|
TQuadroF(const char* form, const char* quadro) : TDicForm(form, quadro) {}
|
|
virtual ~TQuadroF() {}
|
|
};
|
|
|
|
void TQuadroF::azzera_contatori()
|
|
{
|
|
pa3t = pa4t = pa5t = pa6t = pa7t = ZERO;
|
|
pb3t=pb4t=pc3t=pc4t=pd3t=pd4t = ZERO; // totali prosp, B, C e D
|
|
_ptrA = _ptrB = _ptrC = _ptrD = 1;
|
|
}
|
|
|
|
|
|
void TQuadroF::stampa_totali(char tipoprosp, TPrinter& pr)
|
|
{
|
|
const int PA3_TOT = 104;
|
|
const int PB3_TOT = 54;
|
|
TPrint_section& sez = tipoprosp == 'A' ? section('H', 1) : section('B', 1);
|
|
const int rr = sez.height()-1;
|
|
int i = PA3_TOT, riga_tot=0;
|
|
|
|
switch (tipoprosp)
|
|
{
|
|
case 'A':
|
|
{
|
|
riga_tot = 46;
|
|
TForm_item& c = sez.find_field(i++);
|
|
TString c3(pa3t.string());
|
|
c.set(c3);
|
|
c = sez.find_field(i++);
|
|
TString c4(pa4t.string());
|
|
c.set(c4);
|
|
c = sez.find_field(i++);
|
|
TString c5(pa5t.string());
|
|
c.set(c5);
|
|
c = sez.find_field(i++);
|
|
TString c6(pa6t.string());
|
|
c.set(c6);
|
|
c = sez.find_field(i++);
|
|
TString c7(pa7t.string());
|
|
c.set(c7);
|
|
break;
|
|
}
|
|
case 'B':
|
|
{
|
|
i = PB3_TOT;
|
|
riga_tot = 14;
|
|
TForm_item& c = sez.find_field(i++);
|
|
TString c3(pb3t.string());
|
|
c.set(c3);
|
|
c = sez.find_field(i);
|
|
TString c4(pb4t.string());
|
|
c.set(c4);
|
|
break;
|
|
}
|
|
case 'C':
|
|
{
|
|
i = PB3_TOT+2;
|
|
riga_tot = 20;
|
|
TForm_item& c = sez.find_field(i++);
|
|
TString c3(pc3t.string());
|
|
c.set(c3);
|
|
c = sez.find_field(i);
|
|
TString c4(pc4t.string());
|
|
c.set(c4);
|
|
break;
|
|
}
|
|
case 'D':
|
|
{
|
|
i = PB3_TOT+4;
|
|
riga_tot = 26;
|
|
TForm_item& c = sez.find_field(i++);
|
|
TString d3(pd3t.string());
|
|
c.set(d3);
|
|
c = sez.find_field(i);
|
|
TString d4(pd4t.string());
|
|
c.set(d4);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
sez.update();
|
|
pr.print(sez.row(riga_tot));
|
|
_RigaCorr++;
|
|
|
|
if (usa_progind())
|
|
progind()->addstatus(1);
|
|
}
|
|
|
|
void TQuadroF::aggiorna_totali(char tipoprosp, TRectype& r)
|
|
{
|
|
real sogg,rope,acc,ecc,sal;
|
|
|
|
switch (tipoprosp)
|
|
{
|
|
case 'A':
|
|
sogg = r.get_real(QUF_SOGRIT);
|
|
rope = r.get_real(QUF_ROPE);
|
|
acc = r.get_real(QUF_ACCONTI);
|
|
ecc = r.get_real(QUF_VERSECC);
|
|
sal = r.get_real(QUF_VERSALDO);
|
|
pa3t += sogg;
|
|
pa4t += rope;
|
|
pa5t += acc;
|
|
pa6t += ecc;
|
|
pa7t += sal;
|
|
break;
|
|
case 'B':
|
|
sogg = r.get_real(QUF_SOGRIT);
|
|
rope = r.get_real(QUF_ROPE);
|
|
pb3t += sogg;
|
|
pb4t += rope;
|
|
break;
|
|
case 'C':
|
|
sogg = r.get_real(QUF_SOGRIT);
|
|
rope = r.get_real(QUF_ROPE);
|
|
pc3t += sogg;
|
|
pc4t += rope;
|
|
break;
|
|
case 'D':
|
|
sogg = r.get_real(QUF_SOGRIT);
|
|
rope = r.get_real(QUF_ROPE);
|
|
pd3t += sogg;
|
|
pd4t += rope;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void TQuadroF::next_page(TPrinter& pr)
|
|
{
|
|
PaginaQuadro PagCorr = curr_page();
|
|
// if (PagCorr = SECONDA) stampa_totali(pr);
|
|
fill_page(pr, -1); // formfeed "adattato"
|
|
inc_curr_page();
|
|
}
|
|
|
|
void TQuadroF::inc_curr_page()
|
|
{
|
|
if (_PaginaCorrente == PRIMA)
|
|
_PaginaCorrente = SECONDA;
|
|
else
|
|
if (_PaginaCorrente == SECONDA)
|
|
_PaginaCorrente = PRIMA;
|
|
}
|
|
|
|
|
|
bool TQuadroF::print(const long codditta, const long numfis, const long numnofis)
|
|
{
|
|
bool EndPrint=FALSE, End_A=FALSE, End_B=FALSE, End_C=FALSE, End_D=FALSE;
|
|
int residui_A=0, residui_B=0, residui_C=0, residui_D=0;
|
|
TCursor* cur = cursor();
|
|
TPrinter& pr = printer();
|
|
|
|
if (!InitPrint(codditta))
|
|
return FALSE;
|
|
|
|
azzera_contatori();
|
|
|
|
TLocalisamfile& rf = cur->file(LF_RIGHEF);
|
|
TRectype dep(rf.curr());
|
|
dep.zero();
|
|
dep.put("CODDITTA", _codditta);
|
|
dep.put("TIPOPRO", "A");
|
|
_prosp_a = new TRecord_array(dep, "NPROG");
|
|
dep.put("TIPOPRO", "B");
|
|
_prosp_b = new TRecord_array(dep, "NPROG");
|
|
dep.put("TIPOPRO", "C");
|
|
_prosp_c = new TRecord_array(dep, "NPROG");
|
|
dep.put("TIPOPRO", "D");
|
|
_prosp_d = new TRecord_array(dep, "NPROG");
|
|
|
|
pr.formlen(QG1_FORMLEN);
|
|
|
|
while (!EndPrint)
|
|
{
|
|
for (int pagina=1; pagina <= QF_PAGINE; pagina++, next_page(pr))
|
|
{
|
|
if (_PaginaCorrente == PRIMA)
|
|
{
|
|
if (_modulaser) ClearFlagModulaser();
|
|
|
|
if (End_A)
|
|
break;
|
|
|
|
(*cur) = 0L;
|
|
|
|
residui_A = stampa_prospetto_A(pr);
|
|
|
|
End_A = (residui_A == 0);
|
|
if (End_A) stampa_totali('A', pr);
|
|
EndPrint = End_A && End_B && End_C && End_D;
|
|
}
|
|
|
|
if (_PaginaCorrente == SECONDA)
|
|
{
|
|
// Reset del flag di pagina con posiz.
|
|
if (_posiziona && _PaginaPosizionamento) _PaginaPosizionamento = FALSE;
|
|
|
|
if (End_B && End_C && End_D)
|
|
break;
|
|
|
|
fill_page(pr, HEADER_SECONDA_F);
|
|
|
|
residui_B = stampa_prospetto_B(pr);
|
|
End_B = (residui_B == 0);
|
|
if (End_B) stampa_totali('B', pr);
|
|
|
|
residui_C = stampa_prospetto_C(pr);
|
|
End_C = (residui_C == 0);
|
|
if (End_C) stampa_totali('C', pr);
|
|
|
|
residui_D = stampa_prospetto_D(pr);
|
|
End_D = (residui_D == 0);
|
|
if (End_D) stampa_totali('D', pr);
|
|
|
|
EndPrint = End_A && End_B && End_C && End_D;
|
|
}
|
|
} // for pagina..
|
|
} // EndPrint()
|
|
close_print();
|
|
return TRUE;
|
|
}
|
|
|
|
const int F_DESC_CAUS = 50;
|
|
const int RIGHE_PROSP = 3;
|
|
|
|
int TQuadroF::stampa_prospetto_C(TPrinter& pr)
|
|
{
|
|
TPrint_section& sez = section('B', 1);
|
|
const int rr = sez.height()-1;
|
|
|
|
const int START_C = 16;
|
|
const int last_c = _prosp_c->last_row();
|
|
for (int i=0; i < RIGHE_PROSP; _ptrC++, i++)
|
|
{
|
|
if (_ptrC > last_c)
|
|
break;
|
|
|
|
TRectype& r = _prosp_c->row(_ptrC, TRUE);
|
|
aggiorna_totali('C', r);
|
|
TString16 codcau(r.get(QUF_CODCAUS));
|
|
TString descr_cau(get_desc_cau(codcau));
|
|
TString16 aliq (r.get(QUF_ALIQUOTA));
|
|
TString sogg (r.get(QUF_SOGRIT));
|
|
TString rope (r.get(QUF_ROPE));
|
|
|
|
const int fc0 = START_C + _ptrC - 1;
|
|
TString16 nord; nord << _ptrC;
|
|
TForm_item& c0 = sez.find_field(fc0);
|
|
c0.set(nord);
|
|
|
|
const int fc1 = fc0 + RIGHE_PROSP;
|
|
TForm_item& c1 = sez.find_field(fc1);
|
|
c1.set(descr_cau);
|
|
|
|
const int fc2 = fc1 + RIGHE_PROSP;
|
|
TForm_item& c2 = sez.find_field(fc2);
|
|
c2.set(aliq);
|
|
|
|
const int fc3 = fc2 + RIGHE_PROSP;
|
|
TForm_item& c3 = sez.find_field(fc3);
|
|
c3.set(sogg);
|
|
|
|
const int fc4 = fc3 + RIGHE_PROSP;
|
|
TForm_item& c4 = sez.find_field(fc4);
|
|
c4.set(rope);
|
|
}
|
|
const int res_C = last_c - _ptrC;
|
|
return res_C < 0 ? 0 : res_C;
|
|
}
|
|
|
|
int TQuadroF::stampa_prospetto_D(TPrinter& pr)
|
|
{
|
|
TPrint_section& sez = section('B', 1);
|
|
const int rr = sez.height()-1;
|
|
|
|
const int START_D = 31;
|
|
const int last_d = _prosp_d->last_row();
|
|
for (int i=0; i < RIGHE_PROSP; _ptrD++, i++)
|
|
{
|
|
if (_ptrD > last_d)
|
|
break;
|
|
|
|
TRectype& r = _prosp_d->row(_ptrD, TRUE);
|
|
aggiorna_totali('D', r);
|
|
TString16 codcau(r.get(QUF_CODCAUS));
|
|
TString descr_cau(get_desc_cau(codcau));
|
|
TString16 aliq (r.get(QUF_ALIQUOTA));
|
|
TString sogg (r.get(QUF_SOGRIT));
|
|
TString rope (r.get(QUF_ROPE));
|
|
|
|
const int fc0 = START_D + _ptrD - 1;
|
|
TString16 nord; nord << _ptrD;
|
|
TForm_item& c0 = sez.find_field(fc0);
|
|
c0.set(nord);
|
|
|
|
const int fc1 = fc0 + RIGHE_PROSP;
|
|
TForm_item& c1 = sez.find_field(fc1);
|
|
c1.set(descr_cau);
|
|
|
|
const int fc2 = fc1 + RIGHE_PROSP;
|
|
TForm_item& c2 = sez.find_field(fc2);
|
|
c2.set(aliq);
|
|
|
|
const int fc3 = fc2 + RIGHE_PROSP;
|
|
TForm_item& c3 = sez.find_field(fc3);
|
|
c3.set(sogg);
|
|
|
|
const int fc4 = fc3 + RIGHE_PROSP;
|
|
TForm_item& c4 = sez.find_field(fc4);
|
|
c4.set(rope);
|
|
}
|
|
|
|
sez.update();
|
|
for (i=0; i < rr; i++)
|
|
{
|
|
pr.print(sez.row(i));
|
|
_RigaCorr++;
|
|
}
|
|
|
|
if (usa_progind())
|
|
progind()->addstatus(1);
|
|
|
|
const int res_D = last_d - _ptrD;
|
|
return res_D < 0 ? 0 : res_D;
|
|
}
|
|
|
|
int TQuadroF::stampa_prospetto_B(TPrinter& pr)
|
|
{
|
|
TPrint_section& sez = section('B', 1);
|
|
const int rr = sez.height()-1;
|
|
|
|
const int START_B = 1;
|
|
|
|
const int last_b = _prosp_b->last_row();
|
|
for (int i=0; i < RIGHE_PROSP; _ptrB++, i++)
|
|
{
|
|
if (_ptrB > last_b)
|
|
break;
|
|
|
|
TRectype& r = _prosp_b->row(_ptrB, TRUE);
|
|
aggiorna_totali('B', r);
|
|
TString dep(50);
|
|
dep = r.get(QUF_CODCAUS);
|
|
TString descr_cau(get_desc_cau(dep));
|
|
TString16 aliq (r.get(QUF_ALIQUOTA));
|
|
TString sogg (r.get(QUF_SOGRIT));
|
|
TString rope (r.get(QUF_ROPE));
|
|
|
|
const int fc0 = START_B + _ptrB - 1;
|
|
TString16 nord; nord << _ptrB;
|
|
TForm_item& c0 = sez.find_field(fc0);
|
|
c0.set(nord);
|
|
|
|
const int fc1 = fc0 + RIGHE_PROSP;
|
|
TForm_item& c1 = sez.find_field(fc1);
|
|
c1.set(descr_cau);
|
|
|
|
const int fc2 = fc1 + RIGHE_PROSP;
|
|
TForm_item& c2 = sez.find_field(fc2);
|
|
c2.set(aliq);
|
|
|
|
const int fc3 = fc2 + RIGHE_PROSP;
|
|
TForm_item& c3 = sez.find_field(fc3);
|
|
c3.set(sogg);
|
|
|
|
const int fc4 = fc3 + RIGHE_PROSP;
|
|
TForm_item& c4 = sez.find_field(fc4);
|
|
c4.set(rope);
|
|
}
|
|
|
|
// TBI setta totali e descr.causale F
|
|
TString16 fcau(cursor()->curr(LF_QUAF).get(QUF_FCAUS));
|
|
TString descr_cau(get_desc_cau(fcau));
|
|
TForm_item& fd = sez.find_field(F_DESC_CAUS);
|
|
fd.set(descr_cau);
|
|
|
|
const int res_B = last_b - _ptrB;
|
|
return res_B < 0 ? 0 : res_B;
|
|
}
|
|
|
|
int TQuadroF::stampa_prospetto_A(TPrinter& pr)
|
|
{
|
|
TPrint_section& head = section('H', 1);
|
|
const word rr = head.height()-1;
|
|
TPrintrow& head_row = head.row(rr-1);
|
|
|
|
// Setta il cod.fis. del dichiarante se necessario
|
|
if (tipo_ditta() == estinto)
|
|
{
|
|
TForm_item& cfd = head.find_field(H_COFI_DIC);
|
|
cfd.set(_cofi_dic);
|
|
}
|
|
|
|
TCursor* cur = cursor();
|
|
|
|
const int START_PROSP = 56;
|
|
const int RIGHE_PROSP = 6;
|
|
const int COL_PROSP = 8;
|
|
const int last_a = _prosp_a->last_row();
|
|
|
|
for (int i=0; i < RIGHE_PROSP ; _ptrA++, i++)
|
|
{
|
|
if (_ptrA > last_a)
|
|
break;
|
|
TRectype& r = _prosp_a->row(_ptrA, TRUE);
|
|
aggiorna_totali('A', r);
|
|
TString16 codcau(r.get(QUF_CODCAUS));
|
|
TString descr_cau(get_desc_cau(codcau));
|
|
TString16 aliq (r.get(QUF_ALIQUOTA));
|
|
TString sogg (r.get(QUF_SOGRIT));
|
|
TString rope (r.get(QUF_ROPE));
|
|
TString acc(r.get(QUF_ACCONTI));
|
|
TString ecc(r.get(QUF_VERSECC));
|
|
TString sal(r.get(QUF_VERSALDO));
|
|
|
|
const int fc0 = START_PROSP + _ptrA - 1;
|
|
TString16 nord; nord << _ptrA;
|
|
TForm_item& c0 = head.find_field(fc0);
|
|
c0.set(nord);
|
|
|
|
const int fc1 = fc0 + RIGHE_PROSP;
|
|
TForm_item& c1 = head.find_field(fc1);
|
|
c1.set(descr_cau);
|
|
|
|
const int fc2 = fc1 + RIGHE_PROSP;
|
|
TForm_item& c2 = head.find_field(fc2);
|
|
c2.set(aliq);
|
|
|
|
const int fc3 = fc2 + RIGHE_PROSP;
|
|
TForm_item& c3 = head.find_field(fc3);
|
|
c3.set(sogg);
|
|
|
|
const int fc4 = fc3 + RIGHE_PROSP;
|
|
TForm_item& c4 = head.find_field(fc4);
|
|
c4.set(rope);
|
|
|
|
const int fc5 = fc4 + RIGHE_PROSP;
|
|
TForm_item& c5 = head.find_field(fc5);
|
|
c5.set(acc);
|
|
|
|
const int fc6 = fc5 + RIGHE_PROSP;
|
|
TForm_item& c6 = head.find_field(fc6);
|
|
c6.set(ecc);
|
|
|
|
const int fc7 = fc6 + RIGHE_PROSP;
|
|
TForm_item& c7 = head.find_field(fc7);
|
|
c7.set(sal);
|
|
}
|
|
|
|
// Righe da saltare nelle prime pag. dei moduli successivi al primo (che' son
|
|
// senza le righe del posizionamento...)
|
|
int HEADER_PRIMA_NOPOS = 3;
|
|
head.update();
|
|
for (word j = 0; j <= rr; j++)
|
|
{
|
|
if (j==0)
|
|
{
|
|
if (_modulaser)
|
|
{
|
|
TPrintrow& r = head.row(j);
|
|
if (!_GiaMessoStartDoc)
|
|
put_modulaser(r, STARTDOC);
|
|
put_modulaser(r, STARTDITTA);
|
|
put_modulaser(r, STARTPAGE, 1);
|
|
pr.print(r);
|
|
_RigaCorr++;
|
|
r.reset();
|
|
HEADER_PRIMA_NOPOS--;
|
|
}
|
|
if (!PaginaPosizionamento())
|
|
fill_page(pr, HEADER_PRIMA_NOPOS);
|
|
}
|
|
else
|
|
{
|
|
pr.print(head.row(j));
|
|
_RigaCorr++;
|
|
}
|
|
}
|
|
const int res = last_a - _ptrA;
|
|
return res < 0 ? 0 : res;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// STAMPA QUADRO F
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TStampaQuadroF : public TStampaQuadro
|
|
{
|
|
private:
|
|
TQuadroF* _form;
|
|
TRelation* _rel;
|
|
TCursor* _cur;
|
|
|
|
protected:
|
|
virtual bool conta_tipi_per() const { return FALSE; }
|
|
virtual TDicForm* get_form() const { return _form; }
|
|
|
|
virtual TCursor* get_cursor() const { return _cur; }
|
|
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
|
|
public:
|
|
TStampaQuadroF(char livel) : TStampaQuadro("F", livel) { }
|
|
};
|
|
|
|
bool TStampaQuadroF::user_create()
|
|
{
|
|
_form = new TQuadroF("77QF", quadro());
|
|
|
|
_rel = new TRelation(LF_QUAF);
|
|
_rel->add(LF_RIGHEF, "CODDITTA=CODDITTA");
|
|
_rel->add(LF_NDITTE, "CODDITTA=CODDITTA", 1, LF_QUAF);
|
|
_rel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR", 1, LF_NDITTE, 116);
|
|
_rel->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, LF_ANAG, 118);
|
|
_rel->add(LF_COMUNI, "COM=COMNASC", 1, LF_ANAGFIS, 113);
|
|
_rel->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG, 213);
|
|
_cur = new TCursor(_rel);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaQuadroF::user_destroy()
|
|
{
|
|
delete _cur;
|
|
delete _rel;
|
|
delete _form;
|
|
return TRUE;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Quadro H
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
HIDDEN const int QH_FORMLEN = 72;
|
|
HIDDEN const int QH_PAGINE = 2;
|
|
HIDDEN const int HEADER_SECONDA_H = 7;
|
|
|
|
class TQuadroH : public TDicForm
|
|
{
|
|
private:
|
|
real _rC2t, _rC3t; // totali colonna 2 e 3
|
|
long _items;
|
|
void azzera_contatori();
|
|
// void aggiorna_totali(char tipoprosp, TRectype& r);
|
|
// void stampa_totali(char tipoprosp, TPrinter& pr);
|
|
|
|
public:
|
|
virtual bool print(const long codditta, const long numfis=0L, const long numnofis=0L);
|
|
virtual void inc_curr_page();
|
|
virtual void next_page(TPrinter& pr);
|
|
|
|
TQuadroH(const char* form, const char* quadro) : TDicForm(form, quadro) {}
|
|
virtual ~TQuadroH() {}
|
|
};
|
|
|
|
|
|
void TQuadroH::azzera_contatori()
|
|
{
|
|
_rC2t = _rC3t = ZERO;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Quadro 770/A
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TDipendente : public TSortable
|
|
{
|
|
TRecnotype _pos;
|
|
|
|
long _codice_ditta;
|
|
TString _ragsoc;
|
|
long _codice_dipendente;
|
|
long _codice_deceduto;
|
|
TDate _fine_rapporto;
|
|
bool _lavoro_precedente;
|
|
char _causa;
|
|
char _rettifica_conguaglio;
|
|
int _numero_progressivo;
|
|
|
|
public:
|
|
virtual int compare(const TSortable& s) const;
|
|
|
|
TRecnotype pos() const { return _pos; }
|
|
long codice_deceduto() const { return _codice_deceduto; }
|
|
void reset_deceduto() { _codice_deceduto = -_codice_deceduto; }
|
|
long codice() const { return _codice_dipendente; }
|
|
|
|
TDipendente(const TCursor& cur);
|
|
virtual ~TDipendente() { }
|
|
};
|
|
|
|
TDipendente::TDipendente(const TCursor& cur)
|
|
{
|
|
_pos = ((TCursor&)cur).pos();
|
|
|
|
const TRectype& rec = cur.curr();
|
|
const TRectype& dip = cur.curr(LF_DIPEND);
|
|
|
|
_codice_ditta = rec.get_long("CODDITTA");
|
|
_ragsoc = dip.get("COGNOME"); _ragsoc << ' ' << dip.get("NOME");
|
|
_codice_deceduto = dip.get_long("CODDIPDEC");
|
|
_codice_dipendente = rec.get_long("CODDIP");
|
|
_fine_rapporto = rec.get("DATAFR");
|
|
_lavoro_precedente = rec.get("CFDLPREC").not_empty();
|
|
_causa = rec.get_char("CAUSA");
|
|
_rettifica_conguaglio = rec.get_char("RETCON");
|
|
_numero_progressivo = rec.get_int("NPROG");
|
|
|
|
if (_rettifica_conguaglio == 'B' || !_fine_rapporto.ok())
|
|
_fine_rapporto = eotime;
|
|
else
|
|
if (_fine_rapporto.year() != 1995)
|
|
_pos = -1; // Non stampare anni diversi dal 1995
|
|
}
|
|
|
|
|
|
int TDipendente::compare(const TSortable& s) const
|
|
{
|
|
const TDipendente& rec = (const TDipendente&)s;
|
|
|
|
if (_codice_ditta != rec._codice_ditta)
|
|
return _codice_ditta > rec._codice_ditta ? +1 : -1;
|
|
|
|
const int diff = _ragsoc.compare(rec._ragsoc, -1, TRUE);
|
|
if (diff != 0)
|
|
return diff;
|
|
|
|
if (_codice_dipendente != rec._codice_dipendente)
|
|
return _codice_dipendente > rec._codice_dipendente ? +1 : -1;
|
|
|
|
if (_fine_rapporto != rec._fine_rapporto)
|
|
return _fine_rapporto > rec._fine_rapporto ? +1 : -1;
|
|
|
|
if (_lavoro_precedente != rec._lavoro_precedente)
|
|
return _lavoro_precedente ? +1 : -1;
|
|
|
|
if (_causa != rec._causa)
|
|
return _causa > rec._causa ? +1 : -1;
|
|
|
|
if (_rettifica_conguaglio != rec._rettifica_conguaglio)
|
|
return _rettifica_conguaglio > rec._rettifica_conguaglio ? +1 : -1;
|
|
|
|
return _numero_progressivo - rec._numero_progressivo;
|
|
}
|
|
|
|
class TDipendenti : public TObject
|
|
{
|
|
TArray _data;
|
|
|
|
protected:
|
|
const TDipendente& dip(int i) const { return (const TDipendente&)_data[i]; }
|
|
|
|
public:
|
|
const TDipendente& operator[](int i) const { return dip(i); }
|
|
|
|
int fill(TCursor& cur);
|
|
int items() const { return _data.items(); }
|
|
|
|
int find(long d) const;
|
|
|
|
TDipendenti() { }
|
|
virtual ~TDipendenti() { }
|
|
};
|
|
|
|
int TDipendenti::find(long cod) const
|
|
{
|
|
for (int i = _data.last(); i >= 0; i--)
|
|
if (dip(i).codice() == cod)
|
|
break;
|
|
return i;
|
|
}
|
|
|
|
int TDipendenti::fill(TCursor& cur)
|
|
{
|
|
for (cur = 0; cur.ok(); ++cur)
|
|
{
|
|
TDipendente* n = new TDipendente(cur);
|
|
if (n->pos() >= 0)
|
|
_data.add(n);
|
|
else
|
|
delete n;
|
|
}
|
|
const int i = _data.items();
|
|
if (i > 0)
|
|
{
|
|
_data.sort();
|
|
for (int d = i-1; d >= 0; d--)
|
|
{
|
|
const long coddec = dip(d).codice_deceduto();
|
|
if (coddec > 0) // E' un erede!
|
|
{
|
|
const int posdec = find(coddec);
|
|
if (posdec >= 0 && posdec != d-1) // Il deceduto esiste
|
|
{
|
|
TDipendente* dipen = (TDipendente*)_data.remove(d, TRUE);
|
|
dipen->reset_deceduto(); // Non e' piu' un erede
|
|
_data.insert(dipen, posdec+1); // Attaccalo dietro al deceduto
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
class TQuadroA : public TDicForm
|
|
{
|
|
enum { QA_FORMLEN = 72 };
|
|
|
|
protected:
|
|
virtual void next_page(TPrinter& pr);
|
|
virtual bool print(const long codditta, const long NumFis, const long NumNoFis);
|
|
|
|
virtual void azzera_totali();
|
|
virtual void aggiorna_totali(const char) { }
|
|
|
|
virtual int elementi_pagina(PaginaQuadro p) const;
|
|
virtual int prima_riga(PaginaQuadro p) const;
|
|
virtual int riga_totali(PaginaQuadro p) const;
|
|
|
|
void stampa_corpo(TPrinter& pr);
|
|
void stampa_totali(TPrinter& pr);
|
|
|
|
public:
|
|
TQuadroA(const char* form, const char* quadro) : TDicForm(form, quadro) {}
|
|
virtual ~TQuadroA() {}
|
|
};
|
|
|
|
void TQuadroA::azzera_totali()
|
|
{
|
|
TPrint_section& totali = section('F', last_page);
|
|
totali.reset();
|
|
}
|
|
|
|
void TQuadroA::stampa_corpo(TPrinter& pr)
|
|
{
|
|
TPrint_section& body = section('B', odd_page);
|
|
body.reset();
|
|
body.update();
|
|
|
|
const int body_righe = body.height();
|
|
for (int i = 0; i < body_righe; i++)
|
|
{
|
|
pr.print(body.row(i));
|
|
_RigaCorr++;
|
|
}
|
|
|
|
if (usa_progind())
|
|
progind()->addstatus(1);
|
|
}
|
|
|
|
|
|
void TQuadroA::stampa_totali(TPrinter& pr)
|
|
{
|
|
TPrint_section& totali = section('F', last_page);
|
|
totali.update();
|
|
for (int i = 0; i < totali.items(); i++)
|
|
{
|
|
pr.print(totali.row(i));
|
|
_RigaCorr++;
|
|
}
|
|
}
|
|
|
|
void TQuadroA::next_page(TPrinter& pr)
|
|
{
|
|
fill_page(pr, -1); // formfeed "adattato"
|
|
inc_curr_page();
|
|
}
|
|
|
|
int TQuadroA::elementi_pagina(PaginaQuadro p) const
|
|
{
|
|
const int n[4] = { 1, 3, 3, 2 };
|
|
return n[p - PRIMA];
|
|
}
|
|
|
|
int TQuadroA::prima_riga(PaginaQuadro p) const
|
|
{
|
|
return p == PRIMA ? 45 : 5;
|
|
}
|
|
|
|
int TQuadroA::riga_totali(PaginaQuadro p) const
|
|
{
|
|
const int h = ((TQuadroA*)this)->section('B', odd_page).height();
|
|
return prima_riga(p) + elementi_pagina(p) * h;
|
|
}
|
|
|
|
bool TQuadroA::print(const long codditta, const long NumFis, const long NumNoFis)
|
|
{
|
|
TCursor& cur = *cursor();
|
|
TPrinter& pr = printer();
|
|
|
|
if (!InitPrint(codditta))
|
|
return FALSE;
|
|
|
|
pr.formlen(QA_FORMLEN);
|
|
|
|
int elementi = 0; // Numero di elementi stampati in questa pagina
|
|
bool stampato_ultimo = FALSE;
|
|
bool stampati_totali = FALSE;
|
|
|
|
int pos = 0;
|
|
TDipendenti indice;
|
|
if (quadro() == "A" || quadro() == "B")
|
|
{
|
|
const int i = indice.fill(cur);
|
|
if (i > 0)
|
|
{
|
|
if (usa_progind())
|
|
progind()->addstatus(cur.items()-i); // Segna come elaborati tutti gli ignorati
|
|
|
|
cur = indice[0].pos();
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
else
|
|
cur = 0;
|
|
|
|
while (!stampati_totali)
|
|
{
|
|
bool stampero_ultimo = stampato_ultimo == FALSE;
|
|
if (stampero_ultimo)
|
|
{
|
|
if (indice.items() > 0) // Usa indice alternativo
|
|
stampero_ultimo &= pos == indice.items()-1;
|
|
else // Usa indice del cursore
|
|
stampero_ultimo &= cur.pos() == cur.items()-1;
|
|
}
|
|
|
|
switch(_PaginaCorrente)
|
|
{
|
|
case PRIMA:
|
|
if (_modulaser)
|
|
ClearFlagModulaser();
|
|
|
|
if (elementi == 0)
|
|
{
|
|
stampa_testata(pr);
|
|
jump_to_line(pr, prima_riga(PRIMA));
|
|
}
|
|
|
|
if (!stampato_ultimo)
|
|
{
|
|
stampa_corpo(pr);
|
|
stampato_ultimo = stampero_ultimo;
|
|
}
|
|
|
|
elementi++;
|
|
if (elementi >= elementi_pagina(PRIMA))
|
|
{
|
|
next_page(pr);
|
|
elementi = 0;
|
|
}
|
|
break;
|
|
case SECONDA:
|
|
case TERZA:
|
|
if (!stampato_ultimo)
|
|
{
|
|
if (elementi == 0)
|
|
jump_to_line(pr, prima_riga(_PaginaCorrente));
|
|
stampa_corpo(pr);
|
|
stampato_ultimo = stampero_ultimo;
|
|
}
|
|
elementi++;
|
|
if (elementi >= elementi_pagina(_PaginaCorrente))
|
|
{
|
|
next_page(pr);
|
|
elementi = 0;
|
|
}
|
|
break;
|
|
case QUARTA:
|
|
if (!stampato_ultimo)
|
|
{
|
|
if (elementi == 0)
|
|
jump_to_line(pr, prima_riga(QUARTA));
|
|
|
|
stampa_corpo(pr);
|
|
stampato_ultimo = stampero_ultimo;
|
|
}
|
|
|
|
elementi++;
|
|
|
|
if (elementi >= elementi_pagina(QUARTA))
|
|
{
|
|
if (stampato_ultimo)
|
|
{
|
|
jump_to_line(pr, riga_totali(QUARTA));
|
|
stampa_totali(pr);
|
|
stampati_totali = TRUE;
|
|
}
|
|
next_page(pr);
|
|
elementi = 0;
|
|
}
|
|
break;
|
|
default:
|
|
CHECK(0, "Invalid Quadro A page");
|
|
break;
|
|
}
|
|
|
|
if (!stampato_ultimo)
|
|
{
|
|
if (indice.items() > 0)
|
|
cur = indice[++pos].pos();
|
|
else
|
|
++cur;
|
|
}
|
|
}
|
|
|
|
close_print();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
class TStampaQuadroA : public TStampaQuadro
|
|
{
|
|
protected:
|
|
TQuadroA* _form;
|
|
TSorted_cursor* _cur;
|
|
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
|
|
virtual bool conta_tipi_per() const { return FALSE; }
|
|
virtual TDicForm* get_form() const { return _form; }
|
|
virtual TCursor* get_cursor() const { return _cur; }
|
|
|
|
public:
|
|
TStampaQuadroA(const char* quadro, char livel) : TStampaQuadro(quadro, livel) { }
|
|
virtual ~TStampaQuadroA() { }
|
|
};
|
|
|
|
bool TStampaQuadroA::user_create()
|
|
{
|
|
_form = new TQuadroA("77QA", quadro());
|
|
|
|
TString sortkey(80);
|
|
sortkey.format("CODDITTA|%d->COGNOME|%d->NOME|CODDIP", LF_DIPEND, LF_DIPEND);
|
|
_cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaQuadroA::user_destroy()
|
|
{
|
|
delete _cur;
|
|
delete _form;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
// Quadro A1
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TQuadroA1 : public TQuadroA
|
|
{
|
|
protected:
|
|
virtual int elementi_pagina(PaginaQuadro p) const;
|
|
virtual int prima_riga(PaginaQuadro p) const;
|
|
virtual long filtra(const long codditta);
|
|
|
|
public:
|
|
TQuadroA1(const char* form, const char* quadro) : TQuadroA(form, quadro) { }
|
|
virtual ~TQuadroA1() { }
|
|
};
|
|
|
|
int TQuadroA1::elementi_pagina(PaginaQuadro p) const
|
|
{
|
|
const int n[4] = { 3, 6, 6, 5 };
|
|
return n[p-PRIMA];
|
|
}
|
|
|
|
int TQuadroA1::prima_riga(PaginaQuadro p) const
|
|
{
|
|
return p == PRIMA ? 32 : 4;
|
|
}
|
|
|
|
long TQuadroA1::filtra(const long codditta)
|
|
{
|
|
TString filtr(32);
|
|
filtr.format("CODDITTA=%ld|ANNORIF=1995", codditta);
|
|
|
|
cursor()->setfilter(filtr, TRUE);
|
|
const long items = cursor()->items();
|
|
|
|
return items;
|
|
}
|
|
|
|
class TStampaQuadroA1 : public TStampaQuadroA
|
|
{
|
|
protected:
|
|
virtual bool user_create();
|
|
|
|
public:
|
|
TStampaQuadroA1(const char* quadro, char livel) : TStampaQuadroA(quadro, livel) { }
|
|
virtual ~TStampaQuadroA1() { }
|
|
};
|
|
|
|
bool TStampaQuadroA1::user_create()
|
|
{
|
|
_form = new TQuadroA1("77QA1", quadro());
|
|
|
|
TString sortkey(80);
|
|
sortkey.format("CODDITTA|%d->COGNOME|%d->NOME|CODDIP|MESERIF|NPROG", LF_DIPEND, LF_DIPEND);
|
|
_cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
// Quadro A2
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TQuadroA2 : public TQuadroA
|
|
{
|
|
protected:
|
|
virtual int elementi_pagina(PaginaQuadro p) const;
|
|
virtual int prima_riga(PaginaQuadro p) const;
|
|
|
|
public:
|
|
TQuadroA2(const char* form, const char* quadro) : TQuadroA(form, quadro) { }
|
|
virtual ~TQuadroA2() { }
|
|
};
|
|
|
|
int TQuadroA2::elementi_pagina(PaginaQuadro p) const
|
|
{
|
|
const int n[4] = { 3, 6, 6, 5 };
|
|
return n[p-PRIMA];
|
|
}
|
|
|
|
int TQuadroA2::prima_riga(PaginaQuadro p) const
|
|
{
|
|
return p == PRIMA ? 32 : 4;
|
|
}
|
|
|
|
class TStampaQuadroA2 : public TStampaQuadroA
|
|
{
|
|
protected:
|
|
virtual bool user_create();
|
|
|
|
public:
|
|
TStampaQuadroA2(const char* quadro, char livel) : TStampaQuadroA(quadro, livel) { }
|
|
virtual ~TStampaQuadroA2() { }
|
|
};
|
|
|
|
bool TStampaQuadroA2::user_create()
|
|
{
|
|
_form = new TQuadroA2("77QA2", quadro());
|
|
|
|
TString sortkey(80);
|
|
sortkey.format("CODDITTA|%d->COGNOME|%d->NOME|CODDIP|RETCON|NPROG", LF_DIPEND, LF_DIPEND);
|
|
_cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
// Quadro A3
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TQuadroA3 : public TQuadroA
|
|
{
|
|
int _nprog;
|
|
|
|
protected:
|
|
virtual bool print(const long codditta, const long NumFis, const long NumNoFis);
|
|
|
|
virtual int elementi_pagina(PaginaQuadro p) const;
|
|
virtual int prima_riga(PaginaQuadro p) const;
|
|
virtual long filtra(const long codditta);
|
|
|
|
public:
|
|
void set_nprog(int np) { _nprog = np; }
|
|
|
|
TQuadroA3(const char* form, const char* quadro);
|
|
virtual ~TQuadroA3() { }
|
|
};
|
|
|
|
TQuadroA3::TQuadroA3(const char* form, const char* quadro)
|
|
: TQuadroA(form, quadro), _nprog(1)
|
|
{ }
|
|
|
|
|
|
long TQuadroA3::filtra(const long codditta)
|
|
{
|
|
TString filtr(32);
|
|
filtr.format("CODDITTA=%ld|NPROG=%d", codditta, _nprog);
|
|
|
|
cursor()->setfilter(filtr, TRUE);
|
|
const long items = cursor()->items();
|
|
|
|
return items;
|
|
}
|
|
|
|
bool TQuadroA3::print(const long codditta, const long NumFis, const long NumNoFis)
|
|
{
|
|
TPrint_section& head = section('H', first_page);
|
|
TForm_item& tipo_ditta = head.field(0);
|
|
|
|
_nprog = 1;
|
|
tipo_ditta.set("1");
|
|
TQuadroA::print(codditta, NumFis, NumNoFis);
|
|
|
|
_nprog = 2;
|
|
tipo_ditta.set("2");
|
|
TQuadroA::print(codditta, NumFis, NumNoFis);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int TQuadroA3::elementi_pagina(PaginaQuadro p) const
|
|
{
|
|
const int n[4] = { 6, 10, 10, 9 };
|
|
return n[p-PRIMA];
|
|
}
|
|
|
|
int TQuadroA3::prima_riga(PaginaQuadro p) const
|
|
{
|
|
return p == PRIMA ? 32 : 4;
|
|
}
|
|
|
|
class TStampaQuadroA3 : public TStampaQuadroA
|
|
{
|
|
protected:
|
|
virtual bool user_create();
|
|
|
|
public:
|
|
TStampaQuadroA3(const char* quadro, char livel) : TStampaQuadroA(quadro, livel) { }
|
|
virtual ~TStampaQuadroA3() { }
|
|
};
|
|
|
|
bool TStampaQuadroA3::user_create()
|
|
{
|
|
_form = new TQuadroA3("77QA3", quadro());
|
|
|
|
TString sortkey(80);
|
|
sortkey.format("CODDITTA|NPROG|%d->COGNOME|%d->NOME|CODDIP", LF_DIPEND, LF_DIPEND);
|
|
_cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
// Quadro B
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TQuadroB : public TQuadroA
|
|
{
|
|
protected:
|
|
virtual int elementi_pagina(PaginaQuadro p) const;
|
|
virtual int prima_riga(PaginaQuadro p) const;
|
|
|
|
public:
|
|
TQuadroB(const char* form, const char* quadro) : TQuadroA(form, quadro) { }
|
|
virtual ~TQuadroB() { }
|
|
};
|
|
|
|
int TQuadroB::elementi_pagina(PaginaQuadro p) const
|
|
{
|
|
const int n[4] = { 3, 5, 5, 3 };
|
|
return n[p-PRIMA];
|
|
}
|
|
|
|
int TQuadroB::prima_riga(PaginaQuadro p) const
|
|
{
|
|
return p == PRIMA ? 34 : 5;
|
|
}
|
|
|
|
class TStampaQuadroB : public TStampaQuadroA
|
|
{
|
|
protected:
|
|
virtual bool user_create();
|
|
|
|
public:
|
|
TStampaQuadroB(const char* quadro, char livel) : TStampaQuadroA(quadro, livel) { }
|
|
virtual ~TStampaQuadroB() { }
|
|
};
|
|
|
|
bool TStampaQuadroB::user_create()
|
|
{
|
|
_form = new TQuadroB("77QB", quadro());
|
|
|
|
TString sortkey(80);
|
|
sortkey.format("CODDITTA|%d->COGNOME|%d->NOME|CODDIP|DATAINI|NPROG", LF_DIPEND, LF_DIPEND);
|
|
_cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// MAIN
|
|
//
|
|
// Uso:
|
|
// 772mod -4 [QUADRO] [ LIVELLO {S|D} ]
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
int stampa_quadro(int argc, char* argv[])
|
|
{
|
|
if (argc >= 4)
|
|
{
|
|
const TFixed_string quadro(argv[2]);
|
|
const char livello = *argv[3];
|
|
|
|
TStampaQuadro* app = NULL;
|
|
|
|
if ( quadro == "C" || quadro == "D" || quadro == "D1" || quadro == "E" || quadro == "E1" )
|
|
{
|
|
app = new TStampaQuadroD(quadro, livello);
|
|
}
|
|
else if (quadro[0] == 'A')
|
|
{
|
|
switch (quadro[1] - '0')
|
|
{
|
|
case 1: app = new TStampaQuadroA1(quadro, livello); break;
|
|
case 2: app = new TStampaQuadroA2(quadro, livello); break;
|
|
case 3: app = new TStampaQuadroA3(quadro, livello); break;
|
|
default: app = new TStampaQuadroA(quadro, livello); break;
|
|
}
|
|
}
|
|
else if (quadro[0] == 'B')
|
|
{
|
|
app = new TStampaQuadroB(quadro, livello);
|
|
}
|
|
else if (quadro == "F")
|
|
{
|
|
app = new TStampaQuadroF(livello);
|
|
}
|
|
else if (quadro == "G")
|
|
{
|
|
app = new TStampaQuadroG(livello);
|
|
}
|
|
else if (quadro == "G1")
|
|
{
|
|
app = new TStampaQuadroG1(livello);
|
|
}
|
|
/*
|
|
else if (quadro == "H")
|
|
{
|
|
app = new TStampaQuadroH app(quadro, livello);
|
|
}
|
|
*/
|
|
if (app != NULL)
|
|
{
|
|
app->run(argc, argv, app->taitol());
|
|
delete app;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|