3849f63cf0
Files correlati : Ricompilazione Demo : [ ] Commento : Ripotata la versione Partners 2.0 patch 302 sul main trunk git-svn-id: svn://10.65.10.50/trunk@10387 c028cbd2-c16b-5b4b-a496-9718f37d4682
393 lines
10 KiB
C++
Executable File
393 lines
10 KiB
C++
Executable File
///////////////////////////////////////////////////////////
|
||
// Quadro 770/C
|
||
///////////////////////////////////////////////////////////
|
||
|
||
#include "77stqc.h"
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////
|
||
// Quadro C
|
||
/////////////////////////////////////////////////////////////////////////////////
|
||
|
||
bool TQuadroC::controlla_percentuale(TCursor& cur, const real& perc_p)
|
||
{
|
||
bool stampa = TRUE;
|
||
TRectype& rc = cur.curr();
|
||
long ditta_p = rc.get_long(QUC_CODDITTA);
|
||
char tipo_p = rc.get_char(QUC_TIPOA);
|
||
long codana_p = rc.get_long(QUC_CODANAGR);
|
||
char caus_p = rc.get_char(QUC_CAUSALE);
|
||
int tass_p = rc.get_int(QUC_TASSAZIONE);
|
||
TString ragsoc_p = get_ragsoc_anagr(tipo_p,codana_p);
|
||
|
||
if (perc_p == ZERO)
|
||
{
|
||
++(cur);
|
||
long ditta = rc.get_long(QUC_CODDITTA);
|
||
char tipo = rc.get_char(QUC_TIPOA);
|
||
long codana = rc.get_long(QUC_CODANAGR);
|
||
char caus = rc.get_char(QUC_CODCAUS);
|
||
int tass = rc.get_int(QUC_TASSAZIONE);
|
||
TString ragsoc = get_ragsoc_anagr(tipo,codana);
|
||
real perc = rc.get_real(QUC_PERC);
|
||
|
||
if (ditta == ditta_p && tipo == tipo_p && ragsoc == ragsoc_p &&
|
||
codana == codana_p && caus == caus_p && tass == tass_p)
|
||
{
|
||
if (perc != ZERO)
|
||
{
|
||
stampa = FALSE;
|
||
_devo_sommare = TRUE;
|
||
}
|
||
else
|
||
stampa = FALSE;
|
||
}
|
||
--(cur);
|
||
}
|
||
else
|
||
{
|
||
++(cur);
|
||
long ditta = rc.get_long(QUC_CODDITTA);
|
||
char tipo = rc.get_char(QUC_TIPOA);
|
||
long codana = rc.get_long(QUC_CODANAGR);
|
||
char caus = rc.get_char(QUC_CODCAUS);
|
||
int tass = rc.get_int(QUC_TASSAZIONE);
|
||
TString ragsoc = get_ragsoc_anagr(tipo,codana);
|
||
real perc = rc.get_real(QUC_PERC);
|
||
|
||
if (ditta == ditta_p && tipo == tipo_p && ragsoc == ragsoc_p &&
|
||
codana == codana_p && caus == caus_p && tass == tass_p && perc_p == perc)
|
||
stampa = FALSE;
|
||
else
|
||
_devo_sommare = TRUE;
|
||
|
||
--(cur);
|
||
}
|
||
|
||
return stampa;
|
||
}
|
||
|
||
void TQuadroC::leggi_importi()
|
||
{
|
||
TRectype& rec = cursor()->curr();
|
||
|
||
_ammlordo += rec.get_real(QUC_AMMLORDO);
|
||
_controbb += rec.get_real(QUC_CONTROBB);
|
||
_somnonsog += rec.get_real(QUC_SOMNONSOGG);
|
||
_imponibile += rec.get_real(QUC_IMPONIBILE);
|
||
_imposta += rec.get_real(QUC_IMPOSTA);
|
||
_detcarfam += rec.get_real(QUC_DETCARFAM);
|
||
_detlavdip += rec.get_real(QUC_DETLAVDIP);
|
||
_totdet += rec.get_real(QUC_TOTDET);
|
||
_ritenute += rec.get_real(QUC_RITENUTE);
|
||
_gglav += rec.get_int(QUC_GGLAVDIP);
|
||
}
|
||
|
||
void TQuadroC::setta_importi(TPrint_section& body)
|
||
{
|
||
TRectype& rec = cursor()->curr();
|
||
|
||
real ammlordo = rec.get_real(QUC_AMMLORDO);
|
||
real controbb = rec.get_real(QUC_CONTROBB);
|
||
real somnonsog = rec.get_real(QUC_SOMNONSOGG);
|
||
real imponibile = rec.get_real(QUC_IMPONIBILE);
|
||
real imposta = rec.get_real(QUC_IMPOSTA);
|
||
real detcarfam = rec.get_real(QUC_DETCARFAM);
|
||
real detlavdip = rec.get_real(QUC_DETLAVDIP);
|
||
real totdet = rec.get_real(QUC_TOTDET);
|
||
real ritenute = rec.get_real(QUC_RITENUTE);
|
||
int gglav = rec.get_int(QUC_GGLAVDIP);
|
||
|
||
if (_devo_sommare)
|
||
{
|
||
ammlordo += _ammlordo;
|
||
controbb += _controbb;
|
||
somnonsog += _somnonsog;
|
||
imponibile += _imponibile;
|
||
imposta += _imposta;
|
||
detcarfam += _detcarfam;
|
||
detlavdip += _detlavdip;
|
||
totdet += _totdet;
|
||
ritenute += _ritenute;
|
||
gglav += _gglav;
|
||
_devo_sommare = FALSE;
|
||
_ammlordo = ZERO;
|
||
_controbb = ZERO;
|
||
_somnonsog = ZERO;
|
||
_imponibile = ZERO;
|
||
_imposta = ZERO;
|
||
_detcarfam = ZERO;
|
||
_detlavdip = ZERO;
|
||
_totdet = ZERO;
|
||
_ritenute = ZERO;
|
||
_gglav = 0;
|
||
}
|
||
|
||
TForm_item& fammlordo = body.find_field(C_AMMLORDO);
|
||
TForm_item& fcontrobb = body.find_field(C_CONTROBB);
|
||
TForm_item& fsomnonsog = body.find_field(C_SOMNONSOG);
|
||
TForm_item& fimponibile = body.find_field(C_IMPONIBILE);
|
||
TForm_item& fimposta = body.find_field(C_IMPOSTA);
|
||
TForm_item& fdetcarfam = body.find_field(C_DETCARFAM);
|
||
TForm_item& fgglav = body.find_field(C_GGLAV);
|
||
TForm_item& fdetlavdip = body.find_field(C_DETLAVDIP);
|
||
TForm_item& ftotdet = body.find_field(C_TOTDET);
|
||
TForm_item& fritenute = body.find_field(C_RITENUTE);
|
||
|
||
TString sammlordo (ammlordo.string());
|
||
TString scontrobb (controbb.string());
|
||
TString ssomnonsog (somnonsog.string());
|
||
TString simponibile (imponibile.string());
|
||
TString simposta (imposta.string());
|
||
TString sdetcarfam (detcarfam.string());
|
||
TString sgglav;
|
||
TString sdetlavdip (detlavdip.string());
|
||
TString stotdet (totdet.string());
|
||
TString sritenute (ritenute.string());
|
||
sgglav.format("%d",gglav);
|
||
// Setta i campi
|
||
fammlordo.set(sammlordo);
|
||
fcontrobb.set(scontrobb);
|
||
fsomnonsog.set(ssomnonsog);
|
||
fimponibile.set(simponibile);
|
||
fimposta.set(simposta);
|
||
fdetcarfam.set(sdetcarfam);
|
||
fgglav.set(sgglav);
|
||
fdetlavdip.set(sdetlavdip);
|
||
ftotdet.set(stotdet);
|
||
fritenute.set(sritenute);
|
||
}
|
||
|
||
void TQuadroC::stampa_corpo(TPrinter& pr)
|
||
{
|
||
TPrint_section& body = section('B', odd_page);
|
||
const int body_righe = body.height();
|
||
body.reset();
|
||
setta_importi(body);
|
||
body.update();
|
||
for (int i=0; i < body_righe; i++)
|
||
{
|
||
pr.print(body.row(i));
|
||
_RigaCorr++;
|
||
}
|
||
body.reset();
|
||
if (usa_progind())
|
||
progind()->addstatus(1);
|
||
}
|
||
|
||
int TQuadroC::elementi_pagina(PaginaQuadro p) const
|
||
{
|
||
const int n[4] = { 6, 7, 7, 7 };
|
||
return n[p-PRIMA];
|
||
}
|
||
|
||
int TQuadroC::dic_form_len() const
|
||
{
|
||
if (curr_page()==PRIMA && _PaginaPosizionamento)
|
||
return QC_FORMLEN-HEADER_PRIMA_NOPOS_QC;
|
||
else
|
||
return QC_FORMLEN;
|
||
}
|
||
|
||
int TQuadroC::prima_riga(PaginaQuadro p) const
|
||
{
|
||
int line = 0;
|
||
|
||
if (p==PRIMA)
|
||
{
|
||
if (_PaginaPosizionamento)
|
||
line = 1;
|
||
else
|
||
line = 1+HEADER_PRIMA_NOPOS_QC;
|
||
}
|
||
|
||
else if (p==SECONDA) line = 4;
|
||
else if (p==TERZA) line = 4;
|
||
else if (p==QUARTA) line = 4;
|
||
|
||
return line;
|
||
}
|
||
|
||
bool TQuadroC::print(const long codditta, const long NumFis, const long NumNoFis)
|
||
{
|
||
TCursor& cur = *cursor();
|
||
TPrinter& pr = printer();
|
||
_num_foglio=0;
|
||
bool stampa = TRUE;
|
||
|
||
_gglav = 0;
|
||
if (!InitPrint(codditta))
|
||
return FALSE;
|
||
|
||
int elementi = 0; // Numero di elementi stampati in questa pagina
|
||
int ele_bis = 0;
|
||
bool stampato_ultimo = FALSE;
|
||
bool stampati_totali = FALSE;
|
||
|
||
// se il dispositivo scelto non <20> una winprinter
|
||
// non <20> mai eseguito il posizionamento
|
||
if (pr.printtype() != winprinter)
|
||
_PaginaPosizionamento = FALSE;
|
||
|
||
int pos = 0;
|
||
TDipendenti indice;
|
||
cur = 0;
|
||
|
||
if (_modulaser)
|
||
{
|
||
TPrintrow r;
|
||
put_modulaser(r, VEGASTARTDOC);
|
||
put_modulaser(r, VEGASTARTDITTA);
|
||
put_modulaser(r, VEGASTARTPAGE, PRIMA);
|
||
pr.print(r);
|
||
_RigaCorr++;
|
||
}
|
||
|
||
while (!stampati_totali)
|
||
{
|
||
bool stampa = TRUE;
|
||
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);
|
||
}
|
||
|
||
pr.formlen(dic_form_len());
|
||
_EndPrintDitta=stampato_ultimo;
|
||
|
||
switch(_PaginaCorrente)
|
||
{
|
||
|
||
// stampa prima pagina
|
||
case PRIMA:
|
||
|
||
if (_modulaser)
|
||
ClearFlagModulaser();
|
||
|
||
if (ele_bis == 0)
|
||
{
|
||
jump_to_line(pr, prima_riga(PRIMA));
|
||
stampa_testata(pr);
|
||
}
|
||
|
||
if (!stampato_ultimo)
|
||
{
|
||
real perc_p = cur.curr().get_real(QUC_PERC);
|
||
stampa = controlla_percentuale(cur,perc_p);
|
||
if (stampa)
|
||
stampa_corpo(pr);
|
||
else
|
||
{
|
||
leggi_importi();
|
||
elementi--;
|
||
}
|
||
stampato_ultimo = stampero_ultimo;
|
||
}
|
||
|
||
elementi++;
|
||
ele_bis++;
|
||
if (elementi >= elementi_pagina(PRIMA))
|
||
{
|
||
next_page(pr);
|
||
elementi = 0;
|
||
ele_bis = 0;
|
||
}
|
||
break;
|
||
|
||
// stampa seconda o terza pagina
|
||
case SECONDA:
|
||
case TERZA:
|
||
|
||
_PaginaPosizionamento=FALSE;
|
||
|
||
if (!stampato_ultimo)
|
||
{
|
||
if (ele_bis == 0)
|
||
jump_to_line(pr, prima_riga(_PaginaCorrente));
|
||
real perc_p = cur.curr().get_real(QUC_PERC);
|
||
stampa = controlla_percentuale(cur,perc_p);
|
||
if (stampa)
|
||
stampa_corpo(pr);
|
||
else
|
||
{
|
||
leggi_importi();
|
||
elementi--;
|
||
}
|
||
stampato_ultimo = stampero_ultimo;
|
||
}
|
||
elementi++;
|
||
ele_bis++;
|
||
if (elementi >= elementi_pagina(_PaginaCorrente))
|
||
{
|
||
next_page(pr);
|
||
elementi = 0;
|
||
ele_bis = 0;
|
||
}
|
||
break;
|
||
|
||
// stampa quarta pagina
|
||
case QUARTA:
|
||
if (!stampato_ultimo)
|
||
{
|
||
if (ele_bis == 0)
|
||
jump_to_line(pr, prima_riga(QUARTA));
|
||
real perc_p = cur.curr().get_real(QUC_PERC);
|
||
stampa = controlla_percentuale(cur,perc_p);
|
||
if (stampa)
|
||
stampa_corpo(pr);
|
||
else
|
||
{
|
||
leggi_importi();
|
||
elementi--;
|
||
}
|
||
stampato_ultimo = stampero_ultimo;
|
||
}
|
||
|
||
elementi++;
|
||
ele_bis++;
|
||
|
||
if (elementi >= elementi_pagina(QUARTA))
|
||
{
|
||
// salto ad inizio sezione
|
||
jump_to_line(pr, 60);
|
||
stampa_totali(pr);
|
||
if (stampato_ultimo)
|
||
stampati_totali = TRUE;
|
||
_EndPrintDitta=stampato_ultimo;
|
||
next_page(pr);
|
||
elementi = 0;
|
||
ele_bis = 0;
|
||
}
|
||
break;
|
||
default:
|
||
CHECK(0, "Invalid Quadro C page");
|
||
break;
|
||
}
|
||
|
||
if (!stampato_ultimo)
|
||
{
|
||
if (indice.items() > 0)
|
||
cur = indice[++pos].pos();
|
||
else
|
||
++cur;
|
||
}
|
||
}
|
||
|
||
close_print();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
bool TStampaQuadroC::user_create()
|
||
{
|
||
_form = new TQuadroC("77QC", quadro());
|
||
|
||
TString sortkey(80);
|
||
sortkey.format("CODDITTA|TIPOA|216@->RAGSOC|CODANAGR|CODCAUS|PERC", LF_QUAC, LF_QUAC);
|
||
_cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
|
||
|
||
return TRUE;
|
||
}
|