git-svn-id: svn://10.65.10.50/branches/R_10_00@23107 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
36d2a2b01a
commit
89918b05cd
194
lv/lv2700.cpp
194
lv/lv2700.cpp
@ -12,21 +12,20 @@
|
||||
class TRiepBolle_recordset: public TCSV_recordset
|
||||
{
|
||||
int _loop;
|
||||
unsigned int _max_column;
|
||||
unsigned int _max_column, _lst_column;
|
||||
TArray _max_cli_col;
|
||||
|
||||
|
||||
public:
|
||||
void first_loop() { _loop = 0;}
|
||||
void prev_loop() { --_loop;}
|
||||
void next_loop() { ++_loop;}
|
||||
void set_loop(int l) { _loop = l;}
|
||||
unsigned int loops() { return (_max_column - 4 )/ 66 + 1; }
|
||||
unsigned int loops() const { return (_max_column - 4 )/_lst_column + 1; }
|
||||
unsigned int get_curr_max_column() const ;
|
||||
void set_max_column(unsigned int column);
|
||||
virtual const TVariant& get(unsigned int column) const;
|
||||
|
||||
TRiepBolle_recordset(): TCSV_recordset("CSV(\"\t\")"), _loop(0), _max_column(0) {}
|
||||
TRiepBolle_recordset(unsigned int last_col): TCSV_recordset("CSV(\"\t\")"), _loop(0), _max_column(0), _lst_column(last_col) {}
|
||||
};
|
||||
|
||||
void TRiepBolle_recordset::set_max_column(unsigned int column)
|
||||
@ -56,9 +55,9 @@ const TVariant& TRiepBolle_recordset::get(unsigned int column) const
|
||||
static TVariant __s("");
|
||||
if (column < 4)
|
||||
return TCSV_recordset::get( column);
|
||||
if (column + _loop * 66 >= get_curr_max_column())
|
||||
if (column + _loop * _lst_column >= get_curr_max_column())
|
||||
return __s;
|
||||
return TCSV_recordset::get(column + _loop * 66);
|
||||
return TCSV_recordset::get(column + _loop * _lst_column);
|
||||
}
|
||||
|
||||
class TRiepBolle_mask: public TAutomask
|
||||
@ -96,8 +95,7 @@ protected:
|
||||
virtual bool set_usr_val(const TString& name, const TVariant& var);
|
||||
|
||||
public:
|
||||
TRiepBolle_report() {}
|
||||
virtual ~TRiepBolle_report() {}
|
||||
TRiepBolle_report();
|
||||
};
|
||||
|
||||
bool TRiepBolle_report::get_usr_val(const TString& name, TVariant& var) const
|
||||
@ -120,33 +118,36 @@ bool TRiepBolle_report::get_usr_val(const TString& name, TVariant& var) const
|
||||
|
||||
bool TRiepBolle_report::set_usr_val(const TString& name, const TVariant& var)
|
||||
{
|
||||
if(name == "#TOT")
|
||||
{
|
||||
if (name == "#TOT")
|
||||
{
|
||||
TRecordset* recset = recordset();
|
||||
|
||||
if (recset != NULL)
|
||||
{
|
||||
TVariant * v = (TVariant *) _tot.objptr(recset->current_row());
|
||||
{
|
||||
TVariant* v = (TVariant*)_tot.objptr(recset->current_row());
|
||||
|
||||
if (v == NULL)
|
||||
{
|
||||
{
|
||||
v = new TVariant(ZERO);
|
||||
_tot.add(v, recset->current_row());
|
||||
}
|
||||
*v = var;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return TDocument_report::set_usr_val(name, var);
|
||||
}
|
||||
|
||||
TRiepBolle_report::TRiepBolle_report()
|
||||
{
|
||||
}
|
||||
|
||||
class TRiepBolle_app: public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
void elabora(const TMask& mask) const;
|
||||
public:
|
||||
virtual void main_loop();
|
||||
};
|
||||
|
||||
void TRiepBolle_app::elabora(const TMask& mask)const
|
||||
@ -203,99 +204,118 @@ void TRiepBolle_app::elabora(const TMask& mask)const
|
||||
TRiepBolle_report rep;
|
||||
if (!rep.load("lv2700a"))
|
||||
return;
|
||||
TRiepBolle_recordset* riep_set = new TRiepBolle_recordset();
|
||||
|
||||
const TReport_section& body = rep.section('B', 1);
|
||||
TString4 last_fld;
|
||||
for (int f = body.items()-1; f > 0; f--)
|
||||
{
|
||||
const TReport_field& fld = body.field(f);
|
||||
const TString& src = fld.field();
|
||||
if (src.len() == 2 && src > last_fld)
|
||||
last_fld = src;
|
||||
}
|
||||
int last_col = (last_fld[0]-'A'+1)*26 + (last_fld[1]-'A'+1) - 4;
|
||||
if (last_col < 66) last_col = 66;
|
||||
|
||||
TRiepBolle_recordset* riep_set = new TRiepBolle_recordset(last_col);
|
||||
((TReport &)rep).set_recordset(riep_set);
|
||||
|
||||
TProgress_monitor pi_art(docsi, TR("Estrazione articoli"));
|
||||
int count = 1;
|
||||
|
||||
for(bool ok = docs.move_first(); ok && pi_art.add_status(); ok = docs.move_next())
|
||||
if (docsi > 0)
|
||||
{
|
||||
const TDocumento d(docs.cursor()->curr());
|
||||
const TDate data = d.get_date(DOC_DATADOC);
|
||||
const TString8 numero = d.get(DOC_NDOC);
|
||||
const int nrows = d.physical_rows();
|
||||
const int id = nbolle.add(numero);
|
||||
TString8 ggmm; ggmm.format("%02d-%02d", data.day(), data.month());
|
||||
TProgress_monitor pi_art(docsi, TR("Estrazione articoli"));
|
||||
int count = 1;
|
||||
|
||||
datebolle.add(ggmm, id);
|
||||
|
||||
for (int r = 1; r <= nrows; r++)
|
||||
for(bool ok = docs.move_first(); ok && pi_art.add_status(); ok = docs.move_next())
|
||||
{
|
||||
const TRiga_documento & row = d[r];
|
||||
const TString articolo = row.get(RDOC_CODARTMAG);
|
||||
//se la causale è di reso devo leggere il ritirato e non il consegnato
|
||||
TCausale_lavanderie & cau = cached_causale_lavanderie(row.get(RDOC_CODAGG1));
|
||||
real qta;
|
||||
const TDocumento d(docs.cursor()->curr());
|
||||
const TDate data = d.get_date(DOC_DATADOC);
|
||||
const TString8 numero = d.get(DOC_NDOC);
|
||||
const int nrows = d.physical_rows();
|
||||
const int id = nbolle.add(numero);
|
||||
TString8 ggmm; ggmm.format("%02d-%02d", data.day(), data.month());
|
||||
|
||||
if (print_resi && cau.is_reso())
|
||||
qta = row.get_real(RDOC_QTAGG1);
|
||||
else
|
||||
datebolle.add(ggmm, id);
|
||||
|
||||
for (int r = 1; r <= nrows; r++)
|
||||
{
|
||||
TCausale_magazzino & caumag = cached_causale_magazzino(cau.get("S2"));
|
||||
if (!print_da_fatt || caumag.get("S2").mid(36, 2) == "+1")
|
||||
qta = row.get_real(RDOC_QTA);
|
||||
}
|
||||
if (qta != ZERO)
|
||||
{
|
||||
TArray * riep_row = (TArray *) riepilogo.objptr(articolo);
|
||||
const TRiga_documento & row = d[r];
|
||||
const TString articolo = row.get(RDOC_CODARTMAG);
|
||||
//se la causale è di reso devo leggere il ritirato e non il consegnato
|
||||
TCausale_lavanderie & cau = cached_causale_lavanderie(row.get(RDOC_CODAGG1));
|
||||
real qta;
|
||||
|
||||
if(riep_row == NULL)
|
||||
riepilogo.add(articolo, riep_row = new TArray);
|
||||
real * q = (real *) riep_row->objptr(id);
|
||||
if (print_resi && cau.is_reso())
|
||||
qta = row.get_real(RDOC_QTAGG1);
|
||||
else
|
||||
{
|
||||
TCausale_magazzino & caumag = cached_causale_magazzino(cau.get("S2"));
|
||||
if (!print_da_fatt || caumag.get("S2").mid(36, 2) == "+1")
|
||||
qta = row.get_real(RDOC_QTA);
|
||||
}
|
||||
if (qta != ZERO)
|
||||
{
|
||||
TArray * riep_row = (TArray *) riepilogo.objptr(articolo);
|
||||
|
||||
if (q == NULL)
|
||||
riep_row->add(q = new real, id);
|
||||
if(riep_row == NULL)
|
||||
riepilogo.add(articolo, riep_row = new TArray);
|
||||
real * q = (real *) riep_row->objptr(id);
|
||||
|
||||
*q += qta;
|
||||
if (q == NULL)
|
||||
riep_row->add(q = new real, id);
|
||||
|
||||
*q += qta;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TProgress_monitor pi(riepilogo.items(), TR("Costruzione report"));
|
||||
int maxpos = 0L;
|
||||
const int cols = nbolle.items();
|
||||
TString_array keys;
|
||||
|
||||
riepilogo.get_keys(keys);
|
||||
keys.sort();
|
||||
riep_set->first_loop();
|
||||
FOR_EACH_ARRAY_ROW(keys, r, key)//scandisce clienti e tiene buoni solo quelli valorizzati
|
||||
if (!riepilogo.empty())
|
||||
{
|
||||
TArray * row = (TArray *) riepilogo.objptr(*key);
|
||||
int col = 0;
|
||||
TProgress_monitor pi(riepilogo.items(), TR("Costruzione report"));
|
||||
int maxpos = 0L;
|
||||
const int cols = nbolle.items();
|
||||
TString_array keys;
|
||||
|
||||
riep_set->new_rec();
|
||||
riep_set->set(col++, codcli); //CAMPO DI ROTTURA
|
||||
riep_set->set(col++, codcli);
|
||||
riep_set->set(col++, *key);
|
||||
riep_set->set(col++, cached_article(*key).get(ANAMAG_DESCR));
|
||||
FOR_EACH_ARRAY_ITEM(nbolle, c, obj)
|
||||
riepilogo.get_keys(keys);
|
||||
keys.sort();
|
||||
riep_set->first_loop();
|
||||
FOR_EACH_ARRAY_ROW(keys, r, key)//scandisce clienti e tiene buoni solo quelli valorizzati
|
||||
{
|
||||
riep_set->set(col++, datebolle.row(c));
|
||||
riep_set->set(col++, nbolle.row(c));
|
||||
const real * qta = (real *) row->objptr(c);
|
||||
TArray * row = (TArray *) riepilogo.objptr(*key);
|
||||
int col = 0;
|
||||
|
||||
riep_set->set(col++, qta == NULL ? EMPTY_STRING : qta->stringa(10, 0));
|
||||
riep_set->set_max_column(col);
|
||||
riep_set->new_rec();
|
||||
riep_set->set(col++, codcli); //CAMPO DI ROTTURA
|
||||
riep_set->set(col++, codcli);
|
||||
riep_set->set(col++, *key);
|
||||
riep_set->set(col++, cached_article(*key).get(ANAMAG_DESCR));
|
||||
FOR_EACH_ARRAY_ITEM(nbolle, c, obj)
|
||||
{
|
||||
riep_set->set(col++, datebolle.row(c));
|
||||
riep_set->set(col++, nbolle.row(c));
|
||||
const real * qta = (real *) row->objptr(c);
|
||||
|
||||
riep_set->set(col++, qta == NULL ? EMPTY_STRING : qta->stringa(10, 0));
|
||||
riep_set->set_max_column(col);
|
||||
}
|
||||
}
|
||||
#ifdef DBG
|
||||
//Crea file che contiene il recordset per debug
|
||||
riep_set->save_as("c:/temp/riepilogoBolla.txt");
|
||||
#endif
|
||||
#ifdef DBG
|
||||
//Crea file che contiene il recordset per debug
|
||||
riep_set->save_as("c:/temp/riepilogoBolla.txt");
|
||||
#endif
|
||||
|
||||
//carica tutte le variabili del report.
|
||||
if (riep_set->items() > 0L)
|
||||
{
|
||||
const int loops = riep_set->loops();
|
||||
rep.mask2report(mask);
|
||||
riep_set->first_loop();
|
||||
for (int i = 0 ; i < loops; i++, riep_set->next_loop())
|
||||
b.add(rep);
|
||||
//carica tutte le variabili del report.
|
||||
if (riep_set->items() > 0L)
|
||||
{
|
||||
const int loops = riep_set->loops();
|
||||
rep.mask2report(mask);
|
||||
riep_set->first_loop();
|
||||
for (int i = 0 ; i < loops; i++, riep_set->next_loop())
|
||||
b.add(rep);
|
||||
}
|
||||
if (!pi.add_status())
|
||||
break;
|
||||
}
|
||||
if (!pi.add_status())
|
||||
break;
|
||||
}
|
||||
if (b.pages() > 0)
|
||||
b.print_or_preview(); // Stampa effettivamente
|
||||
|
Loading…
x
Reference in New Issue
Block a user