Files correlati : cg0.exe cg0800a.msk cg0900a.msk cg0800a.rep cg0900a.rep cg4.exe cg4b00a.msk cg4c00a.msk cg4b00a.rep cg4c00a.rep cgmenu.men Bug : Commento: Progressivi IVA per attività (registrazione e competenza)
211 lines
4.1 KiB
C++
211 lines
4.1 KiB
C++
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <reprint.h>
|
||
#include <variant.h>
|
||
|
||
#include "cglib.h"
|
||
#include "cg0900a.h"
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// TRiepilogoIVAatt_mask
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TRiepilogoIVAatt_mask : public TAutomask
|
||
{
|
||
protected:
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
||
public:
|
||
TRiepilogoIVAatt_mask() : TAutomask("cg0900a") { }
|
||
};
|
||
|
||
bool TRiepilogoIVAatt_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
TRiepilogoIVAatt_mask & m = (TRiepilogoIVAatt_mask &) o.mask();
|
||
|
||
switch (o.dlg())
|
||
{
|
||
case F_DAMESE:
|
||
if (e == fe_modify || e == fe_close)
|
||
{
|
||
if (atoi(o.get()) > m.get_int(F_AMESE))
|
||
m.set(F_AMESE, o.get());
|
||
}
|
||
break;
|
||
case F_AMESE:
|
||
if (e == fe_modify || e == fe_close)
|
||
{
|
||
if (atoi(o.get()) < m.get_int(F_DAMESE))
|
||
o.set(m.get(F_DAMESE));
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// TRiepilogoIVAatt_app
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TRiepilogoIVAatt_app : public TSkeleton_application
|
||
{
|
||
protected:
|
||
void execute_print(TAutomask & m, TReport & rep, KEY k);
|
||
virtual void main_loop();
|
||
};
|
||
|
||
void TRiepilogoIVAatt_app::execute_print(TAutomask & m, TReport & rep, KEY k)
|
||
{
|
||
TReport_book b;
|
||
export_type type = _export_printer;
|
||
|
||
switch (k)
|
||
{
|
||
case K_ENTER:
|
||
case K_PRINT:
|
||
type = _export_printer;
|
||
break;
|
||
case K_EXCEL:
|
||
type = _export_excel;
|
||
rep.section('B', 1).find_field(90)->show(true);
|
||
break;
|
||
case K_EXPORT:
|
||
type = _export_generic;
|
||
break;
|
||
case K_PDF:
|
||
type = _export_pdf;
|
||
break;
|
||
case K_TEXT:
|
||
type = _export_text;
|
||
break;
|
||
break;
|
||
case K_VISUALIZE:
|
||
type = _export_visualize;
|
||
break;
|
||
default:
|
||
type = _export_user;
|
||
break;
|
||
}
|
||
|
||
TFilename name = m.get(DLG_OUTPUTD);
|
||
TString fname = m.get(DLG_OUTPUTF);
|
||
|
||
if (name.blank())
|
||
name.tempdir();
|
||
if (!dexist(name))
|
||
if (!make_dir(name))
|
||
{
|
||
error_box(FR("Non posso creare %s uso il direttorio temporaneo"), (const char *)name);
|
||
name.cut(0);
|
||
name.tempdir();
|
||
}
|
||
if (fname.blank())
|
||
{
|
||
TString t(20);
|
||
|
||
fname = "cg0800";
|
||
_strtime_s(t.get_buffer(), t.size());
|
||
t.strip(":");
|
||
fname << '_' << today.date2ansi() << '_' << t;
|
||
}
|
||
name.add(fname);
|
||
rep.set_export_sections(type);
|
||
b.add(rep, type);
|
||
|
||
switch (type)
|
||
{
|
||
case _export_printer:
|
||
b.print_or_preview();
|
||
break;
|
||
case _export_generic:
|
||
b.esporta();
|
||
break;
|
||
case _export_excel:
|
||
b.export_excel(name, false, true, false, '\t');
|
||
break;
|
||
case _export_pdf:
|
||
b.export_pdf(name, false, true);
|
||
break;
|
||
case _export_text:
|
||
b.export_text(name, 0, false, true);
|
||
break;
|
||
case _export_visualize:
|
||
b.preview();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void TRiepilogoIVAatt_app::main_loop()
|
||
{
|
||
TRiepilogoIVAatt_mask m;
|
||
KEY k;
|
||
|
||
while ((k = m.run()) != K_QUIT)
|
||
{
|
||
TRiepilogoIVA_report rep;
|
||
TFilename repname = m.get(DLG_REPORT);
|
||
TRiepilogoIVAatt_recordset * recset = new TRiepilogoIVAatt_recordset;
|
||
|
||
if (repname.blank())
|
||
repname = "cg0900a";
|
||
|
||
rep.load(repname);
|
||
if (recset != nullptr)
|
||
{
|
||
int anno = m.get_int(F_ANNO);
|
||
int damese = m.get_int(F_DAMESE);
|
||
int amese = m.get_int(F_AMESE);
|
||
|
||
recset->freeze();
|
||
recset->set_anno(anno);
|
||
|
||
if (damese == 13)
|
||
{
|
||
damese = 1;
|
||
amese = 12;
|
||
recset->set_annual(true);
|
||
}
|
||
recset->set_da_mese(damese);
|
||
recset->set_a_mese(amese);
|
||
|
||
const TDate da(1, damese, anno);
|
||
TDate a(1, amese, anno);
|
||
|
||
if (m.get_long(F_DAMESE) == 13)
|
||
a.addyear();
|
||
a.set_end_month();
|
||
recset->set_from(da);
|
||
recset->set_to(a);
|
||
|
||
const TString & codatt = m.get(F_CODATT);
|
||
|
||
recset->set_codatt(codatt);
|
||
rep.set_recordset(recset);
|
||
if (codatt.full())
|
||
{
|
||
TReport_section * f1 = rep.find_section('F', 1);
|
||
|
||
if (f1 != nullptr)
|
||
{
|
||
const int fields = f1->items();
|
||
|
||
for (int i = 0; i < fields; i++)
|
||
f1->field(i).hide();
|
||
}
|
||
}
|
||
execute_print(m, rep, k);
|
||
}
|
||
}
|
||
}
|
||
|
||
int cg0900(int argc, char* argv[])
|
||
{
|
||
TRiepilogoIVAatt_app app;
|
||
app.run(argc, argv, TR("Stampa progressivi IVA avanzata per attivit<69>"));
|
||
return 0;
|
||
}
|