Patch level : 2.2
Files correlati : ca3 Ricompilazione Demo : [ ] Commento : Stampa bilanci anali...tici git-svn-id: svn://10.65.10.50/trunk@13210 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c5b0b3d510
commit
845b53fc60
130
ca/ca3300.cpp
130
ca/ca3300.cpp
@ -2,13 +2,15 @@
|
||||
#include <execp.h>
|
||||
#include <reprint.h>
|
||||
|
||||
#include "pconana.h"
|
||||
#include "rmovana.h"
|
||||
|
||||
#include "ca3.h"
|
||||
#include "ca3300a.h"
|
||||
#include "calib01.h"
|
||||
#include "calib02.h"
|
||||
|
||||
#include "ca3300.h"
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// MASCHERA
|
||||
////////////////////////////////////////////////////////
|
||||
@ -20,7 +22,7 @@ protected:
|
||||
bool test_compatible_report();
|
||||
|
||||
void create_sheet();
|
||||
int create_sheet_sheet(int lf, int& y, short& dlg, bool required);
|
||||
int create_sheet_fields(int lf, int& y, short& dlg, bool required);
|
||||
public:
|
||||
TPrint_bilancio_ca_mask();
|
||||
virtual ~TPrint_bilancio_ca_mask() {}
|
||||
@ -30,10 +32,12 @@ const TString& TPrint_bilancio_ca_mask::get_compatible_library() const
|
||||
{
|
||||
TString& lib = get_tmp_string();
|
||||
lib = "ca3300";
|
||||
const char stp = get(F_STAMPAMPROV)[0];
|
||||
const char bil = get(F_BILANCIO)[0];
|
||||
lib << (stp == 'R' ? 'r' : 'n'); // Raffronto o No?
|
||||
lib << (bil == 'V' ? 'v' : 'c'); // Verifica o sezioni Contrapposte
|
||||
const char stp = get(F_STAMPAMPROV)[0]; // Raffronto o No?
|
||||
const char bil = get(F_BILANCIO)[0]; // Verifica o sezioni Contrapposte
|
||||
if (bil == 'V')
|
||||
lib << (stp == 'R' ? 'a' : 'b'); // Verifica
|
||||
else
|
||||
lib << (stp == 'R' ? 'c' : 'd'); // Sezioni contrapposte
|
||||
return lib;
|
||||
}
|
||||
|
||||
@ -94,8 +98,7 @@ bool TPrint_bilancio_ca_mask::on_field_event(TOperable_field& o, TField_event e,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int TPrint_bilancio_ca_mask::create_sheet_sheet(int lf, int& y, short& dlg, bool required)
|
||||
int TPrint_bilancio_ca_mask::create_sheet_fields(int lf, int& y, short& dlg, bool required)
|
||||
{
|
||||
TSheet_field& sf = sfield(F_RIGHE);
|
||||
TMask& sm = sf.sheet_mask();
|
||||
@ -160,27 +163,27 @@ void TPrint_bilancio_ca_mask::create_sheet()
|
||||
if (level == "CDC") // Crea centro di costo
|
||||
{
|
||||
if (fasinfo.parent() == LF_CDC)
|
||||
create_sheet_sheet(LF_FASI, y, dlg, fsc_req);
|
||||
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
||||
else
|
||||
{
|
||||
const bool cdc_req = ini.get_bool("CdcRequired");
|
||||
create_sheet_sheet(LF_CDC, y, dlg, cdc_req);
|
||||
create_sheet_fields(LF_CDC, y, dlg, cdc_req);
|
||||
}
|
||||
} else
|
||||
if (level == "CMS") // Crea commessa
|
||||
{
|
||||
if (fasinfo.parent() == LF_COMMESSE)
|
||||
create_sheet_sheet(LF_FASI, y, dlg, fsc_req);
|
||||
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
||||
else
|
||||
{
|
||||
const bool cms_req = ini.get_bool("CmsRequired");
|
||||
create_sheet_sheet(LF_COMMESSE, y, dlg, cms_req);
|
||||
create_sheet_fields(LF_COMMESSE, y, dlg, cms_req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fasinfo.levels() > 0 && fasinfo.parent() <= 0)
|
||||
create_sheet_sheet(LF_FASI, y, dlg, fsc_req);
|
||||
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
||||
|
||||
for (short id = S_CDC12+100; id >= S_CDC1+100; id--)
|
||||
{
|
||||
@ -201,22 +204,22 @@ void TPrint_bilancio_ca_mask::create_sheet()
|
||||
|
||||
|
||||
TPrint_bilancio_ca_mask::TPrint_bilancio_ca_mask()
|
||||
:TAutomask("ca3300a")
|
||||
:TAutomask("ca3300")
|
||||
{
|
||||
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, 1, logicnum, 2, 1, F_CDC1_INI, F_DES1_INI, 0x0, "#DACONTO");
|
||||
ca_create_fields(*this, 1, logicnum, 2, 7, F_CDC1_FIN, F_DES1_FIN, 0x0, "#ACONTO");
|
||||
const int nfields = ca_create_fields(*this, 1, logicnum, 2, 1, F_PDC1_INI, F_DES1_INI, 0x0, PCONANA_CODCONTO);
|
||||
ca_create_fields(*this, 1, logicnum, 2, 7, F_PDC1_FIN, F_DES1_FIN, 0x0, PCONANA_CODCONTO);
|
||||
|
||||
for (int i = 0; i < nfields; i++)
|
||||
{
|
||||
TMask_field& daconto = field(F_CDC1_INI + i);
|
||||
TMask_field& daconto = field(F_PDC1_INI + i);
|
||||
daconto.set_group(1);
|
||||
daconto.check_type(CHECK_NORMAL);
|
||||
TMask_field& aconto = field(F_CDC1_FIN + i);
|
||||
TMask_field& aconto = field(F_PDC1_FIN + i);
|
||||
aconto.set_group(2);
|
||||
aconto.check_type(CHECK_NORMAL);
|
||||
}
|
||||
@ -225,15 +228,90 @@ TPrint_bilancio_ca_mask::TPrint_bilancio_ca_mask()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Reports
|
||||
// Recordset
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
class TPiano_conti_recordset : public TISAM_recordset
|
||||
{
|
||||
TString _da_conto, _a_conto;
|
||||
TString _codcms, _codfas, _codcosto;
|
||||
|
||||
protected:
|
||||
bool valid_record(const TRelation& rel);
|
||||
virtual void set_custom_filter(TCursor& cursor) const;
|
||||
|
||||
public:
|
||||
void set_filter(const TMask& m, int r);
|
||||
TPiano_conti_recordset(const char* sql);
|
||||
};
|
||||
|
||||
void TPiano_conti_recordset::set_custom_filter(TCursor& cursor) const
|
||||
{
|
||||
TRectype darec = cursor.curr();
|
||||
TRectype arec = darec;
|
||||
|
||||
darec.zero(); darec.put(PCONANA_CODCONTO, _da_conto);
|
||||
arec.zero(); arec.put(PCONANA_CODCONTO, _a_conto);
|
||||
cursor.setregion(darec, arec);
|
||||
}
|
||||
|
||||
void TPiano_conti_recordset::set_filter(const TMask& m, int r)
|
||||
{
|
||||
for (int i = 0; m.id2pos(F_PDC1_INI+i) > 0; i++)
|
||||
{
|
||||
_da_conto << m.get(F_PDC1_INI+i);
|
||||
_a_conto << m.get(F_PDC1_FIN+i);
|
||||
}
|
||||
|
||||
if (r >= 0)
|
||||
{
|
||||
TSheet_field& sf = m.sfield(F_RIGHE);
|
||||
TMask& sm = sf.sheet_mask();
|
||||
sf.update_mask(r);
|
||||
TRelation rel(LF_RMOVANA);
|
||||
sm.autosave(rel);
|
||||
const TRectype& rec = rel.curr();
|
||||
_codcosto = rec.get(RMOVANA_CODCCOSTO);
|
||||
_codcms = rec.get(RMOVANA_CODCMS);
|
||||
_codfas = rec.get(RMOVANA_CODFASE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TPiano_conti_recordset::TPiano_conti_recordset(const char* sql) : TISAM_recordset(sql)
|
||||
{ }
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Report
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
class TReport_bilancio_ca : public TAnal_report
|
||||
{
|
||||
protected:
|
||||
virtual bool set_recordset(const TString& sql);
|
||||
|
||||
public:
|
||||
TReport_bilancio_ca(const char* name) { load(name); }
|
||||
void set_recordset(const TMask& msk, int row);
|
||||
TReport_bilancio_ca(const char* name);
|
||||
};
|
||||
|
||||
bool TReport_bilancio_ca::set_recordset(const TString& sql)
|
||||
{
|
||||
TPiano_conti_recordset* rset = new TPiano_conti_recordset(sql);
|
||||
return TReport::set_recordset(rset);
|
||||
}
|
||||
|
||||
void TReport_bilancio_ca::set_recordset(const TMask& msk, int row)
|
||||
{
|
||||
TPiano_conti_recordset* rset = (TPiano_conti_recordset*)recordset();
|
||||
rset->set_filter(msk, row);
|
||||
}
|
||||
|
||||
TReport_bilancio_ca::TReport_bilancio_ca(const char* name)
|
||||
{
|
||||
load(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// APPLICAZIONE
|
||||
////////////////////////////////////////////////////////
|
||||
@ -250,7 +328,17 @@ void TPrint_bilancio_ca::main_loop()
|
||||
{
|
||||
TReport_book book;
|
||||
TReport_bilancio_ca rep(mask.get(F_REPORT));
|
||||
book.add(rep);
|
||||
|
||||
TSheet_field& sf = mask.sfield(F_RIGHE);
|
||||
if (sf.empty())
|
||||
sf.row(-1); // Aggiungo riga vuota
|
||||
const int rows = sf.items();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
rep.set_recordset(mask, i);
|
||||
book.add(rep);
|
||||
}
|
||||
|
||||
book.print_or_preview();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __CA3300A_H
|
||||
#define __CA3300A_H
|
||||
#ifndef __CA3300_H
|
||||
#define __CA3300_H
|
||||
|
||||
//pag. stampa bilancio
|
||||
#define F_CODDITTA 301
|
||||
@ -16,14 +16,14 @@
|
||||
#define F_STAMPAMPROV 314
|
||||
|
||||
//campi generati dal pdc
|
||||
#define F_CDC1_INI 316
|
||||
#define F_CDC12_INI 331
|
||||
#define F_CDC1_FIN 336
|
||||
#define F_CDC12_FIN 351
|
||||
#define F_PDC1_INI 316
|
||||
#define F_PDC4_INI 319
|
||||
#define F_PDC1_FIN 336
|
||||
#define F_PDC4_FIN 339
|
||||
#define F_DES1_INI 356
|
||||
#define F_DES12_INI 371
|
||||
#define F_DES4_INI 359
|
||||
#define F_DES1_FIN 376
|
||||
#define F_DES12_FIN 391
|
||||
#define F_DES4_FIN 379
|
||||
|
||||
#define F_SELECT 394
|
||||
#define F_REPORT 395
|
@ -1,4 +1,4 @@
|
||||
#include "ca3300a.h"
|
||||
#include "ca3300.h"
|
||||
|
||||
TOOLBAR "" 0 -3 0 3
|
||||
|
@ -3,6 +3,42 @@
|
||||
#include "calib01.h"
|
||||
#include "calib02.h"
|
||||
|
||||
bool TAnal_report::get_usr_val(const TString& name, TVariant& var) const
|
||||
{
|
||||
// CODCONTO:1, CODCMS:3, FASCMS:2, ecc...
|
||||
const int namelen = name.len();
|
||||
if (namelen >= 6 && name[namelen-2] == ':')
|
||||
{
|
||||
int logicnum = 0;
|
||||
if (name.starts_with("CODCONTO:"))
|
||||
logicnum = LF_PCONANA; else
|
||||
if (name.starts_with("CODCMS:"))
|
||||
logicnum = LF_COMMESSE; else
|
||||
if (name.starts_with("CODCOSTO:"))
|
||||
logicnum = LF_CDC; else
|
||||
if (name.starts_with("FASCMS:"))
|
||||
logicnum = LF_FASI;
|
||||
if (logicnum > 0)
|
||||
{
|
||||
const TMultilevel_code_info& mci = ca_multilevel_code_info(logicnum);
|
||||
const int level = name[namelen-1]-'1';
|
||||
if (level < mci.levels())
|
||||
{
|
||||
TString16 fldname = name; fldname.cut(namelen-2);
|
||||
TFieldref field = mci.fieldref(level);
|
||||
field.set_name(fldname);
|
||||
field.set_from(0);
|
||||
fldname.cut(0) << field; // Trasformo il TFieldref in stringa!
|
||||
get_record_field(fldname, var);
|
||||
}
|
||||
else
|
||||
var.set_null();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return TReport::get_usr_val(name, var);
|
||||
}
|
||||
|
||||
size_t TAnal_report::get_usr_words(TString_array& words) const
|
||||
{
|
||||
TReport::get_usr_words(words);
|
||||
@ -25,23 +61,6 @@ size_t TAnal_report::get_usr_words(TString_array& words) const
|
||||
return words.items();
|
||||
}
|
||||
|
||||
bool TAnal_report::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
|
||||
{
|
||||
if (opcode < _first_msg)
|
||||
return TReport::execute_usr_word(opcode, stack);
|
||||
opcode -= _first_msg;
|
||||
switch (opcode)
|
||||
{
|
||||
case 0 : msg_format_costo(stack); break;
|
||||
case 1 : msg_format_commessa(stack); break;
|
||||
case 2 : msg_format_fase(stack); break;
|
||||
case 3 : msg_format_conto(stack); break;
|
||||
case 4 : msg_format_commessa_costo(stack); break;
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TAnal_report::msg_format(int logicnum, TVariant_stack& stack)
|
||||
{
|
||||
const TString& str_in = curr_field()->get().as_string();
|
||||
@ -89,3 +108,21 @@ void TAnal_report::msg_format_commessa_costo(TVariant_stack& stack)
|
||||
|
||||
msg_format(main_info.parent(), stack);
|
||||
}
|
||||
|
||||
bool TAnal_report::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
|
||||
{
|
||||
if (opcode < _first_msg)
|
||||
return TReport::execute_usr_word(opcode, stack);
|
||||
opcode -= _first_msg;
|
||||
switch (opcode)
|
||||
{
|
||||
case 0 : msg_format_costo(stack); break;
|
||||
case 1 : msg_format_commessa(stack); break;
|
||||
case 2 : msg_format_fase(stack); break;
|
||||
case 3 : msg_format_conto(stack); break;
|
||||
case 4 : msg_format_commessa_costo(stack); break;
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ class TAnal_report : public TReport
|
||||
unsigned int _first_msg;
|
||||
|
||||
protected: // protected is safer
|
||||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||||
virtual size_t get_usr_words(TString_array& words) const;
|
||||
virtual bool execute_usr_word(unsigned int opcode, TVariant_stack& stack);
|
||||
virtual bool use_mask() { return false;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user