4f034aa7f5
Files correlati : Ricompilazione Demo : [ ] Commento :stampa mastrini e movimenti in stato di avanzamento git-svn-id: svn://10.65.10.50/trunk@13112 c028cbd2-c16b-5b4b-a496-9718f37d4682
232 lines
5.9 KiB
C++
Executable File
232 lines
5.9 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <execp.h>
|
||
#include <reprint.h>
|
||
|
||
#include "rmovana.h"
|
||
|
||
#include "ca3.h"
|
||
#include "ca3200a.h"
|
||
#include "calib01.h"
|
||
#include "calib02.h"
|
||
|
||
////////////////////////////////////////////////////////
|
||
// MASCHERA
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_mastrini_ca_mask : public TAutomask
|
||
{
|
||
protected:
|
||
bool on_field_event(TOperable_field& o, TField_event e, long jolly) {return true;}
|
||
void create_page2();
|
||
int create_page2_sheet(int lf, int& y, short& dlg, bool required);
|
||
public:
|
||
TPrint_mastrini_ca_mask();
|
||
virtual ~TPrint_mastrini_ca_mask() {}
|
||
};
|
||
|
||
int TPrint_mastrini_ca_mask::create_page2_sheet(int lf, int& y, short& dlg, bool required)
|
||
{
|
||
TSheet_field& sf = sfield(F_RIGHE);
|
||
TMask& sm = sf.sheet_mask();
|
||
|
||
const int h = ca_create_fields(sm, 0, lf, 1, y, dlg, dlg+50);
|
||
|
||
for (int i = 0; i < h; i++)
|
||
{
|
||
TEdit_field& fld = sm.efield(dlg+i);
|
||
int logic = lf;
|
||
if (logic == LF_FASI)
|
||
{
|
||
const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI);
|
||
if (fasinfo.parent() != 0)
|
||
{
|
||
const TMultilevel_code_info& parinfo = ca_multilevel_code_info(fasinfo.parent());
|
||
if (i < parinfo.levels())
|
||
logic = fasinfo.parent();
|
||
}
|
||
}
|
||
|
||
const char* fieldname = NULL;
|
||
switch(logic)
|
||
{
|
||
case LF_CDC : fieldname = RMOVANA_CODCCOSTO; break;
|
||
case LF_COMMESSE: fieldname = RMOVANA_CODCMS; break;
|
||
case LF_FASI : fieldname = RMOVANA_CODFASE; break;
|
||
default : fieldname = RMOVANA_CODCONTO; break;
|
||
}
|
||
TFieldref* f = (TFieldref*)fld.field();
|
||
f->set_name(fieldname);
|
||
|
||
fld.check_type(required ? CHECK_REQUIRED : CHECK_NORMAL);
|
||
|
||
TEdit_field& dfld = sm.efield(dlg+50+i);
|
||
dfld.set_field(EMPTY_STRING); // Toglie campi che fan saltare gli output!
|
||
}
|
||
|
||
y += h+1;
|
||
dlg += h;
|
||
|
||
return h;
|
||
}
|
||
|
||
void TPrint_mastrini_ca_mask::create_page2()
|
||
{
|
||
TSheet_field& sf = sfield(F_RIGHE);
|
||
TMask& sm = sf.sheet_mask();
|
||
sm.hide(-1);
|
||
|
||
const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI);
|
||
|
||
TConfig_anal ini;
|
||
const bool fsc_req = ini.get_bool("FscRequired");
|
||
|
||
int y = 1;
|
||
short dlg = S_CDC1 + 100; // id del primo campo da generare
|
||
|
||
for (int i = 0; i < 2; i++)
|
||
{
|
||
const TString& level = ini.get("Level", NULL, i+1); // Legge il livello 1 o 2
|
||
if (level == "CDC") // Crea centro di costo
|
||
{
|
||
if (fasinfo.parent() == LF_CDC)
|
||
create_page2_sheet(LF_FASI, y, dlg, fsc_req);
|
||
else
|
||
{
|
||
const bool cdc_req = ini.get_bool("CdcRequired");
|
||
create_page2_sheet(LF_CDC, y, dlg, cdc_req);
|
||
}
|
||
} else
|
||
if (level == "CMS") // Crea commessa
|
||
{
|
||
if (fasinfo.parent() == LF_COMMESSE)
|
||
create_page2_sheet(LF_FASI, y, dlg, fsc_req);
|
||
else
|
||
{
|
||
const bool cms_req = ini.get_bool("CmsRequired");
|
||
create_page2_sheet(LF_COMMESSE, y, dlg, cms_req);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (fasinfo.levels() > 0 && fasinfo.parent() <= 0)
|
||
create_page2_sheet(LF_FASI, y, dlg, fsc_req);
|
||
|
||
for (short id = S_CDC12+100; id >= S_CDC1+100; id--)
|
||
{
|
||
const int pos = sm.id2pos(id);
|
||
if (pos >= 0)
|
||
{
|
||
TMask_field& f = sm.fld(pos);
|
||
const int size = f.size();
|
||
const TString& prompt = f.prompt();
|
||
sf.set_column_header(id, prompt);
|
||
sf.set_column_justify(id, f.is_kind_of(CLASS_REAL_FIELD));
|
||
sf.set_column_width(id, (max(3+size, prompt.len()+1)) * CHARX);
|
||
}
|
||
else
|
||
sf.delete_column(id);
|
||
}
|
||
}
|
||
|
||
|
||
TPrint_mastrini_ca_mask::TPrint_mastrini_ca_mask()
|
||
:TAutomask("ca3200a")
|
||
{
|
||
TConfig_anal cfg;
|
||
const bool use_pdcc = cfg.get_bool("UsePdcc");
|
||
|
||
const int logicnum = use_pdcc ? LF_PCON : LF_PCONANA;
|
||
const int nfields = ca_create_fields(*this, 0, logicnum, 2, 5, F_CDC1_INI, F_DES1_INI, 0x0, "#DACONTO");
|
||
ca_create_fields(*this, 0, logicnum, 2, 11, F_CDC1_FIN, F_DES1_FIN, 0x0, "#ACONTO");
|
||
|
||
for (int i = 0; i < nfields; i++)
|
||
{
|
||
TMask_field& daconto = field(F_CDC1_INI + i);
|
||
daconto.set_group(1);
|
||
daconto.check_type(CHECK_NORMAL);
|
||
TMask_field& aconto = field(F_CDC1_FIN + i);
|
||
aconto.set_group(2);
|
||
aconto.check_type(CHECK_NORMAL);
|
||
}
|
||
// creazione dei campi della seconda pagina della maschera
|
||
create_page2();
|
||
}
|
||
|
||
|
||
////////////////////////////////////////////////////////
|
||
// REPORT
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_mastrini_ca_rep : public TAnal_report
|
||
{
|
||
/*protected:
|
||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||
void calcola_saldo_iniziale();*/
|
||
};
|
||
|
||
|
||
////////////////////////////////////////////////////////
|
||
// APPLICAZIONE
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_mastrini_ca : public TSkeleton_application
|
||
{
|
||
TPrint_mastrini_ca_mask * _mask;
|
||
|
||
protected:
|
||
bool create();
|
||
bool destroy();
|
||
|
||
public:
|
||
virtual void main_loop();
|
||
};
|
||
|
||
bool TPrint_mastrini_ca::create()
|
||
{
|
||
_mask = new TPrint_mastrini_ca_mask;
|
||
return TSkeleton_application::create();
|
||
}
|
||
|
||
bool TPrint_mastrini_ca::destroy()
|
||
{
|
||
delete _mask;
|
||
return TSkeleton_application::destroy();
|
||
}
|
||
|
||
void TPrint_mastrini_ca::main_loop()
|
||
{
|
||
while (_mask->run() == K_ENTER)
|
||
{
|
||
//costruzione della query x il report in base ai parametri della maschera
|
||
TSheet_field& sheet = _mask->sfield(F_RIGHE);
|
||
const int n_righe_sheet = sheet.items();
|
||
//se lo sheet <20> vuoto aggiunge una riga vuota
|
||
if (n_righe_sheet == 0)
|
||
sheet.insert();
|
||
|
||
//report e book
|
||
TReport_book book; //book dei report
|
||
TString path = _mask->get(F_REPORT);
|
||
if (path.empty())
|
||
path = "ca3200a";
|
||
TPrint_mastrini_ca_rep rep;
|
||
rep.load(path);
|
||
|
||
FOR_EACH_SHEET_ROW(sheet, r, row)
|
||
{
|
||
TString query;
|
||
query << "USE RMOVANA\nJOIN PCONANA INTO CODCONTO==CODCONTO";
|
||
rep.set_recordset(query);
|
||
|
||
rep.mask2report(*_mask);
|
||
book.add(rep);
|
||
|
||
}
|
||
|
||
book.print_or_preview(); //stampa il book dei report
|
||
}
|
||
}
|
||
|
||
int ca3200(int argc, char* argv[])
|
||
{
|
||
TPrint_mastrini_ca a;
|
||
a.run(argc, argv, TR("Stampa mastrini"));
|
||
return 0;
|
||
} |