Iniziata gestione footer ultima pagina EC

git-svn-id: svn://10.65.10.50/trunk@2283 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-12-13 15:14:22 +00:00
parent a9c34fd78c
commit c064e2eba5
3 changed files with 100 additions and 29 deletions

View File

@ -26,6 +26,8 @@
class TEC_form : public TForm
{
static TEC_form* _form;
enum { MAXTOT = 16 };
TCursor* _cursore;
TTotalizer _totali;
@ -38,7 +40,10 @@ class TEC_form : public TForm
word _num_rip; // Numero di righe usate per i riporti
protected:
word ordina_totali_per_valuta(THash_object* tot[MAXTOT]);
void stampa_testata(TPrinter& p);
void stampa_pedata(TPrinter& p);
void stampa_riporti(TPrinter& p);
static void ec_header_handler(TPrinter& p);
@ -55,9 +60,10 @@ public:
const TString& lingua() const { return _lingua; }
bool in_valuta() const { return _in_valuta; }
const TString& describe(short id, char sez = 'B') const;
const TString& describe(short id, char sez = 'B', pagetype pt = odd_page) const;
void azzera_totali();
void ultima_pagina();
bool print_game(const TPartita& game);
TEC_form(const TEC_mask& m, bool gesval);
@ -548,7 +554,11 @@ void TEC_form::stampa_testata(TPrinter& pr)
{
// Leggi lo special e stampalo
TForm_item& fi = body.field(f);
head_row.put(fi.key(), offset_x() + fi.x());
if (fi.shown())
{
const int x = offset_x() + fi.x() - 1; // Le TPrintrow partono da 0, bestia!
head_row.put(fi.key(), x);
}
}
for (word j = 0; j <= r; j++)
@ -566,23 +576,25 @@ static int tot_compare(const void* o1, const void* o2)
return stricmp(h1->key(), h2->key());
}
void TEC_form::stampa_riporti(TPrinter& pr)
word TEC_form::ordina_totali_per_valuta(THash_object* tot[MAXTOT])
{
const word MAXTOT = 16;
THash_object* tot[MAXTOT];
// I totali sono in un assoc array disordinato per cui li copio in un array e li ordino
// alfabeticamente in base al loro codice valuta
TTotalizer& arr = totali();
arr.restart();
_num_rip = 0;
word num_rip = 0;
for (THash_object* obj = arr.get_hashobj();
_num_rip < MAXTOT && obj != NULL;
num_rip < MAXTOT && obj != NULL;
obj = arr.get_hashobj())
tot[_num_rip++] = obj;
qsort(tot, _num_rip, sizeof(THash_object*), tot_compare);
tot[num_rip++] = obj;
qsort(tot, num_rip, sizeof(THash_object*), tot_compare);
return num_rip;
}
void TEC_form::stampa_riporti(TPrinter& pr)
{
THash_object* tot[MAXTOT];
_num_rip = ordina_totali_per_valuta(tot);
const word maxtot = section('F').height();
if (_num_rip > maxtot)
@ -609,6 +621,51 @@ void TEC_form::stampa_riporti(TPrinter& pr)
}
}
void TEC_form::stampa_pedata(TPrinter& pr)
{
THash_object* tot[MAXTOT];
word num_rip = ordina_totali_per_valuta(tot);
const word footer_used = 3;
const word maxtot = section('F', 0).height() / footer_used;
if (num_rip > maxtot)
num_rip = maxtot;
const TString& desc_totale = describe(301, 'F', last_page);
TString desc(80);
TPrint_section& body = section('B');
for (word j = 0; j < num_rip; j++)
{
const TString& key = tot[j]->key();
TTotal& t = (TTotal&)(tot[j]->obj());
desc = desc_totale;
if (key.not_empty())
desc << ' ' << key;
TEC_row rip(desc, t.importo().normalize());
rip.scaduto(t.scaduto());
rip.esposto(t.esposto());
rip.importo_lire(t.importo_lire());
rip.print_on(body);
for (word fl = 0; fl < footer_used; fl++)
pr.setfooterline(footer_used*j+fl, body.row(fl));
}
}
void TEC_form::ultima_pagina()
{
TPrint_section& foot = section('F', 0);
const word h = foot.height();
TPrinter& p = printer();
if (h > p.rows_left())
p.formfeed();
p.footerlen(h);
set_last_page(TRUE);
}
void TEC_form::ec_header_handler(TPrinter& pr)
{
pr.resetheader();
@ -620,12 +677,18 @@ void TEC_form::ec_footer_handler(TPrinter& pr)
pr.resetfooter();
if (_form->page(pr) > 0) // Normal page
_form->stampa_riporti(pr);
else // Last page
_form->stampa_pedata(pr);
}
void TEC_form::azzera_totali()
{
totali().destroy();
_num_rip = 0;
totali().destroy(); // Azzera tutti i riporti
_num_rip = 0; // Azzera il numero di righe di riporto
set_last_page(FALSE); // Azzera il flag di ultima pagina di stampa
TPrint_section& foot = section('F');
printer().footerlen(foot.height());
}
bool TEC_form::print_game(const TPartita& game)
@ -700,9 +763,9 @@ bool TEC_form::print_game(const TPartita& game)
return ok;
}
const TString& TEC_form::describe(short id, char sez) const
const TString& TEC_form::describe(short id, char sez, pagetype pt) const
{
const TForm_item& fi = find_field(sez, odd_page, id);
const TForm_item& fi = find_field(sez, pt, id);
return fi.prompt();
}
@ -730,7 +793,7 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
pr.setheaderhandler(ec_header_handler);
TPrint_section& head = section('H');
pr.headerlen(section('H').height());
pr.headerlen(head.height());
TForm_item& luogo_invio = head.find_field(PEC_LUOGOIN);
luogo_invio.set(m.get(F_LUOGOSEND));
@ -739,7 +802,7 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
data_invio.set(m.get(F_DATASEND));
TForm_item& testo_memo = head.find_field(PEC_MEMO);
testo_memo.set("Per favore pagatemi che sono alla frutta!");
testo_memo.set("Per favore pagatemi che sono alla fame!");
pr.setfooterhandler(ec_footer_handler);
const TPrint_section& foot = section('F');
@ -811,12 +874,20 @@ bool TStampaEC_application::print_selected()
printer().open();
bool one_printed = FALSE;
const long items = c.items();
for (long i = 0; i < items; i++) if (print_all || s.checked(i))
{
if (one_printed)
printer().formfeed();
fc = i; // Muove il cursore alla posizione corrente
const bool ok = print_ec();
if (!ok) analfabeti++;
if (ok)
one_printed = TRUE;
else
analfabeti++;
}
printer().formfeed();
printer().close();
@ -865,8 +936,9 @@ bool TStampaEC_application::print_ec()
if (game.chiusa())
{
const TDate& dir = form().data_inizio_rischio();
const TImporto saldo = game.calcola_saldo_al(TRUE, dir);
const TDate& dir = f.data_inizio_rischio();
const TDate& dlo = f.data_limite_operazione();
const TImporto saldo = game.calcola_saldo_al(f.in_valuta(), dlo, dir);
if (saldo.is_zero())
{
int r = 0;
@ -895,8 +967,8 @@ bool TStampaEC_application::print_ec()
partite.put(PART_NRIGA, 9999);
}
if (one_printed)
form().set_last_page(TRUE);
if (one_printed)
f.ultima_pagina();
return TRUE;
}

View File

@ -6,7 +6,7 @@
#include <prefix.h>
#include "sc21pec.h"
#include "sc2403.h"
#include "sc2401.h"
#include <causali.h>
@ -448,6 +448,8 @@ TESSL_array::TESSL_array(const TPartita& game, const TESSL_form* f)
// TESSL_form: form speciale per estratti conto e solleciti
///////////////////////////////////////////////////////////
TESSL_form * TESSL_form::_form = NULL;
void TESSL_form:: header_handler(TPrinter& pr)
{
TPrint_section& head = _form->section('H');
@ -552,7 +554,8 @@ bool TESSL_form::print_game(const TPartita& game)
riga.print_on(body);
pr.print(body.row(0));
totali().add(riga.importo(), riga.scaduto(), riga.esposto(), riga.valuta().codice());
totali().add(riga.importo(), riga.scaduto(), riga.esposto(),
ZERO, riga.valuta().codice());
saldo += riga.importo();
scaduto += riga.scaduto();

View File

@ -135,15 +135,11 @@ public:
virtual ~TESSL_form();
};
TESSL_form * TESSL_form::_form = NULL;
///////////////////////////////////////////////////////////
// TESSL_array
///////////////////////////////////////////////////////////
class TESSL_array : public TArray
{
TArray _scaduto; // Array di importi scaduti