f93632a43c
Files correlati : Ricompilazione Demo : [ ] Commento : comincia a stampare qualcosa anche per commessa cdc git-svn-id: svn://10.65.10.50/branches/R_10_00@21681 c028cbd2-c16b-5b4b-a496-9718f37d4682
1301 lines
34 KiB
C++
Executable File
1301 lines
34 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <colors.h>
|
||
#include <defmask.h>
|
||
#include <modaut.h>
|
||
#include <recset.h>
|
||
#include <sheet.h>
|
||
#include <utility.h>
|
||
|
||
#include <doc.h>
|
||
|
||
#include "ci2.h"
|
||
#include "cilib.h"
|
||
#include "ci2200a.h"
|
||
#include "rilore.h"
|
||
#include "../ca/calib01.h"
|
||
#include "../ca/commesse.h"
|
||
#include "../ca/cfcms.h"
|
||
#include "../ve/velib.h"
|
||
|
||
////////////////////////////////////////////
|
||
//// CLASSE TRilevamento_cons_msk ////
|
||
////////////////////////////////////////////
|
||
|
||
//Classe TRilevamento_cons_msk
|
||
class TRilevamento_cons_msk : public TAutomask
|
||
{
|
||
short _cdc_sid, _cdc_lid;
|
||
short _cms_sid, _cms_lid;
|
||
short _fase_sid, _fase_lid;
|
||
short _scdc_sid, _scdc_lid;
|
||
short _scms_sid, _scms_lid;
|
||
short _sfase_sid, _sfase_lid;
|
||
TDate _datasel;
|
||
int _anno;
|
||
int _mese;
|
||
int _giorno;
|
||
int _first_ex;
|
||
int _n_ex;
|
||
int _es_array[32];
|
||
TEsercizi_contabili _es;
|
||
TString _numcn;
|
||
TString _tipocn;
|
||
TToken_string _last_key;
|
||
TAssoc_array _oredisp;
|
||
TAssoc_array _oreprev;
|
||
|
||
protected:
|
||
const real proponi_costo(TToken_string& riga);
|
||
void get_anal_fields(TString & cdc, TString & cms, TString & fase);
|
||
void get_row_anal_fields(TToken_string & row, TString & cdc, TString & cms, TString & fase);
|
||
void put_row_anal_fields(TToken_string & row, const TString & cdc, const TString & cms, const TString & fase);
|
||
void carica_default();
|
||
void update_day();
|
||
void update_disp();
|
||
void update_prev();
|
||
void riempi_sheet();
|
||
void riempi_calendario(const TString & query);
|
||
void update_column(short sid, const bool full);
|
||
void riempi_risoatt(char tipo = 'C');
|
||
void nuova_riga();
|
||
void azzera_riga(TSheet_field& sheet);
|
||
void azzera_tutto(TSheet_field& sheet);
|
||
void registra();
|
||
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
||
public:
|
||
TRilevamento_cons_msk();
|
||
};
|
||
|
||
const real TRilevamento_cons_msk::proponi_costo(TToken_string& riga)
|
||
{
|
||
real costo = ZERO;
|
||
TSheet_field& sheet = sfield(F_SHEET);
|
||
const TString8 codlist = riga.get(sheet.cid2index(S_CODLIST));
|
||
const char tipo = riga.get_char(sheet.cid2index(S_RISOATT));
|
||
TString80 codice;
|
||
switch(tipo)
|
||
{
|
||
case 'R': codice = riga.get(sheet.cid2index(S_CODRIS)); break;
|
||
case 'A': codice = riga.get(sheet.cid2index(S_CODATT)); break;
|
||
default : break;
|
||
}
|
||
|
||
const TDate dal(1, _mese, _anno);
|
||
const TString4 tpora = riga.get(sheet.cid2index(S_TPORA));
|
||
const TRisoatt_key chiave(codlist, tipo, codice, dal, tpora);
|
||
TModule_table roa("&ROA");
|
||
roa.put("CODTAB", chiave);
|
||
int err = roa.read();
|
||
|
||
if(err == NOERR)
|
||
costo = roa.get_real("R1");
|
||
else
|
||
{
|
||
TString query;
|
||
query << "USE &ROA SELECT MID(CODTAB,30,2)==\"" << tpora << "\"\n"
|
||
<< "FROM CODTAB=\"" << chiave.left(21) << "\"\n"
|
||
<< "TO CODTAB=\"" << chiave << "\"\n";
|
||
TISAM_recordset rec(query);
|
||
|
||
if(rec.move_last())
|
||
costo = rec.cursor()->curr().get_real("R1");
|
||
}
|
||
return costo;
|
||
}
|
||
|
||
void TRilevamento_cons_msk::get_anal_fields(TString & cdc, TString & cms, TString & fase)
|
||
{
|
||
TString val;
|
||
|
||
cdc.cut(0);
|
||
if (_cdc_sid >= 0)
|
||
for ( short id = _cdc_sid; id <= _cdc_lid; id++)
|
||
{
|
||
val = get(id);
|
||
val.rpad(field(id).size());
|
||
cdc << val;
|
||
}
|
||
cdc.trim();
|
||
cms.cut(0);
|
||
if (_cms_sid >= 0)
|
||
for ( short id = _cms_sid; id <= _cms_lid; id++)
|
||
{
|
||
val = get(id);
|
||
val.rpad(field(id).size());
|
||
cms << val;
|
||
}
|
||
cms.trim();
|
||
fase.cut(0);
|
||
if (_fase_sid >= 0)
|
||
for ( short id = _fase_sid; id <= _fase_lid; id++)
|
||
{
|
||
val = get(id);
|
||
val.rpad(field(id).size());
|
||
fase << val;
|
||
}
|
||
fase.trim();
|
||
}
|
||
|
||
void TRilevamento_cons_msk::get_row_anal_fields(TToken_string & row, TString & cdc, TString & cms, TString & fase)
|
||
{
|
||
TSheet_field & s = sfield(F_SHEET);
|
||
TMask & m = s.sheet_mask();
|
||
TString val;
|
||
|
||
cdc.cut(0);
|
||
if (_scdc_sid >= 0)
|
||
for ( short id = _scdc_sid; id <= _scdc_lid; id++)
|
||
{
|
||
val = row.get(s.cid2index(id));
|
||
val.rpad(m.field(id).size());
|
||
cdc << val;
|
||
}
|
||
cdc.trim();
|
||
cms.cut(0);
|
||
if (_scms_sid >= 0)
|
||
for ( short id = _scms_sid; id <= _scms_lid; id++)
|
||
{
|
||
val = row.get(s.cid2index(id));
|
||
val.rpad(m.field(id).size());
|
||
cms << val;
|
||
}
|
||
cms.trim();
|
||
fase.cut(0);
|
||
if (_sfase_sid >= 0)
|
||
for ( short id = _sfase_sid; id <= _sfase_lid; id++)
|
||
{
|
||
val = row.get(s.cid2index(id));
|
||
val.rpad(m.field(id).size());
|
||
fase << val;
|
||
}
|
||
fase.trim();
|
||
}
|
||
|
||
void TRilevamento_cons_msk::put_row_anal_fields(TToken_string & row, const TString & cdc, const TString & cms, const TString & fase)
|
||
{
|
||
TSheet_field & s = sfield(F_SHEET);
|
||
TMask & m = s.sheet_mask();
|
||
int pos = 0;
|
||
|
||
if (_scdc_sid >= 0)
|
||
for (short id = _scdc_sid; id <= _scdc_lid; id++)
|
||
{
|
||
const int len = m.field(id).size();
|
||
row.add(cdc.mid(pos, len), s.cid2index(id));
|
||
pos += len;
|
||
}
|
||
pos = 0;
|
||
if (_scms_sid >= 0)
|
||
for (short id = _scms_sid; id <= _scms_lid; id++)
|
||
{
|
||
const int len = m.field(id).size();
|
||
row.add(cms.mid(pos, len), s.cid2index(id));
|
||
pos += len;
|
||
}
|
||
pos = 0;
|
||
if (_sfase_sid >= 0)
|
||
for (short id = _sfase_sid; id <= _sfase_lid; id++)
|
||
{
|
||
const int len = m.field(id).size();
|
||
row.add(fase.mid(pos, len), s.cid2index(id));
|
||
pos += len;
|
||
}
|
||
}
|
||
|
||
void TRilevamento_cons_msk::carica_default()
|
||
{
|
||
//leggo dalla maschera i campi chiave di ricerca
|
||
const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
||
const TString4 tpora = get(F_TPORA);
|
||
TString80 codcosto;
|
||
TString80 codcms;
|
||
TString16 codfase;
|
||
TString16 codice;
|
||
TString query;
|
||
TString select;
|
||
|
||
update_day();
|
||
switch(get(F_RISOATT)[0])
|
||
{
|
||
case 'R': codice = get(F_CODRIS); break;
|
||
case 'A': codice = get(F_CODATT); break;
|
||
default: break;
|
||
}
|
||
get_anal_fields(codcosto, codcms, codfase);
|
||
|
||
query << "USE " << LF_RILORE << " KEY 2\n" ;
|
||
if (risoatt.full())
|
||
select << "(" << RILORE_TIPORA << "==\"" << risoatt << "\")";
|
||
if (codice.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODICE << "==\"" << codice << "\")";
|
||
}
|
||
if (tpora.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_TPORA << "==\"" << tpora << "\")";
|
||
}
|
||
if (codcosto.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODCOSTO << "==\"" << codcosto << "\")";
|
||
}
|
||
if (codcms.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODCMS << "==\"" << codcms << "\")";
|
||
}
|
||
if (codfase.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODFASE << "==\"" << codfase << "\")";
|
||
}
|
||
if (select.full())
|
||
query << "SELECT " << select << "\n";
|
||
|
||
TString fromto = RILORE_TIPO "=\"D\" ";
|
||
|
||
if (_anno > 0)
|
||
{
|
||
fromto << " " << RILORE_ANNO << "=" << _anno << " ";
|
||
if (_mese > 0)
|
||
fromto << RILORE_MESE << "=" << _mese << " ";
|
||
}
|
||
riempi_risoatt('D');
|
||
}
|
||
|
||
//RIEMPI_CALENDARIO: coloro le celle dello sheet calendario secondo le festivit<69> e i giorni occupati
|
||
void TRilevamento_cons_msk::riempi_calendario(const TString & query)
|
||
{
|
||
TSheet_field& calendario = sfield(F_CALENDARIO);
|
||
const TString4 dett = get(F_INTERVALLO);
|
||
|
||
update_day();
|
||
calendario.destroy(-1, false);
|
||
if (dett == "A")
|
||
{
|
||
TBit_array full_years;
|
||
TISAM_recordset recset(query);
|
||
|
||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||
{
|
||
const int anno = recset.get(RILORE_ANNO).as_int();
|
||
|
||
full_years.set(anno);
|
||
}
|
||
for (int i = 0; i < _n_ex; i++)
|
||
{
|
||
TToken_string & row = calendario.row(i);
|
||
COLOR back = NORMAL_BACK_COLOR;
|
||
COLOR fore = NORMAL_COLOR;
|
||
|
||
if (full_years[_es_array[i]])
|
||
{
|
||
back = COLOR_DKBLUE; // coloro di blu le date con registrazioni
|
||
fore = COLOR_WHITE; // coloro di blu le date con registrazioni
|
||
}
|
||
calendario.set_back_and_fore_color(back, fore, i - 1, 0);
|
||
row.add(_es_array[i]);
|
||
}
|
||
}
|
||
else
|
||
if (dett == "M")
|
||
{
|
||
TBit_array full_months;
|
||
TISAM_recordset recset(query);
|
||
|
||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||
{
|
||
const int mese = recset.get(RILORE_MESE).as_int();
|
||
|
||
full_months.set(mese);
|
||
}
|
||
|
||
for (int i = 1; i <= 12; i++)
|
||
{
|
||
TToken_string & row = calendario.row(i - 1);
|
||
COLOR back = NORMAL_BACK_COLOR;
|
||
COLOR fore = NORMAL_COLOR;
|
||
|
||
if (full_months[i])
|
||
{
|
||
back = COLOR_DKBLUE; // coloro di blu le date con registrazioni
|
||
fore = COLOR_WHITE; // coloro di blu le date con registrazioni
|
||
}
|
||
calendario.set_back_and_fore_color(back, fore, i - 1, 0);
|
||
row.add(itom(i));
|
||
}
|
||
}
|
||
else
|
||
if (dett == "G")
|
||
{
|
||
TDate d(1, _mese, _anno); d.set_end_month();
|
||
const int end_month = d.day();
|
||
TBit_array fulldays;
|
||
TISAM_recordset recset(query);
|
||
|
||
//scorro il recordset, aggiungo una riga allo sheet per ogni chiave analitica che trovo e coloro di blu
|
||
//tutte le celle che corrispondono a una data interessata da qualcosa
|
||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||
{
|
||
const int day = recset.get(RILORE_GIORNO).as_int();
|
||
|
||
fulldays.set(day);
|
||
}
|
||
|
||
for(int i = 1; i <= end_month; i++)
|
||
{
|
||
TToken_string & row = calendario.row(i - 1);
|
||
COLOR back = NORMAL_BACK_COLOR;
|
||
COLOR fore = NORMAL_COLOR;
|
||
|
||
if (fulldays[i])
|
||
{
|
||
back = COLOR_DKBLUE; // coloro di blu le date con registrazioni
|
||
fore = COLOR_WHITE; // coloro di blu le date con registrazioni
|
||
}
|
||
else
|
||
if (TDate(i, _mese, _anno).is_holiday())
|
||
{
|
||
back = COLOR_DKRED; // coloro di rosso le festivit<69>
|
||
fore = COLOR_WHITE; // coloro di rosso le festivit<69>
|
||
}
|
||
calendario.set_back_and_fore_color(back, fore, i - 1, 0);
|
||
row.add(i);
|
||
}
|
||
}
|
||
calendario.force_update();
|
||
}
|
||
|
||
void TRilevamento_cons_msk::update_column(short sid, bool full)
|
||
{
|
||
TSheet_field& sf = sfield(F_SHEET);
|
||
if (full)
|
||
sf.set_column_width(sid, 0);
|
||
// sf.set_column_width(column, !full ? (max(3 + f.size(), len + 1) * CHARX) : 0);
|
||
}
|
||
|
||
void TRilevamento_cons_msk::riempi_risoatt(char tipo)
|
||
{
|
||
TSheet_field& sheet = sfield(F_SHEET);
|
||
TMask & sm = sheet.sheet_mask();
|
||
|
||
if (sheet.items() > 0 && sheet.dirty() && yesno_box("Vuoi salvare le modifiche"))
|
||
registra();
|
||
sheet.destroy();
|
||
|
||
update_day();
|
||
//leggo dalla maschera i campi chiave di ricerca
|
||
const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
||
const TString4 tpora = get(F_TPORA);
|
||
TString80 codcosto;
|
||
TString80 codcms;
|
||
TString16 codfase;
|
||
TString16 codice;
|
||
TString query;
|
||
TString select;
|
||
|
||
switch(risoatt[0])
|
||
{
|
||
case 'R': codice = get(F_CODRIS); break;
|
||
case 'A': codice = get(F_CODATT); break;
|
||
default: break;
|
||
}
|
||
update_disp();
|
||
get_anal_fields(codcosto, codcms, codfase);
|
||
sheet.set_columns_order();
|
||
update_column(S_RISOATT, risoatt.full());
|
||
update_column(S_CODRIS, codice.full());
|
||
update_column(S_DESRIS, codice.full());
|
||
update_column(S_CODATT, codice.full());
|
||
update_column(S_DESATT, codice.full());
|
||
update_column(S_TPORA, tpora.full());
|
||
if (_scdc_sid >= 0)
|
||
for ( short id = _scdc_sid; id <= _scdc_lid; id++)
|
||
{
|
||
update_column(id, codcosto.full());
|
||
sm.enable(id + 50, codcosto.blank());
|
||
}
|
||
if (_scms_sid >= 0)
|
||
for ( short id = _scms_sid; id <= _scms_lid; id++)
|
||
{
|
||
update_column(id, codcms.full());
|
||
sm.enable(id + 50, codcms.blank());
|
||
}
|
||
if (_sfase_sid >= 0)
|
||
for ( short id = _sfase_sid; id <= _sfase_lid; id++)
|
||
{
|
||
update_column(id, codfase.full());
|
||
sm.enable(id + 50, codfase.blank());
|
||
}
|
||
//preparo la query
|
||
|
||
query << "USE " << LF_RILORE << " KEY 2\n" ;
|
||
if (risoatt.full())
|
||
{
|
||
select << "(" << RILORE_TIPORA << "==\"" << risoatt << "\")";
|
||
}
|
||
if (codice.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODICE << "==\"" << codice << "\")";
|
||
}
|
||
if (tpora.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_TPORA << "==\"" << tpora << "\")";
|
||
}
|
||
if (codcosto.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODCOSTO << "==\"" << codcosto << "\")";
|
||
}
|
||
if (codcms.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODCMS << "==\"" << codcms << "\")";
|
||
}
|
||
if (codfase.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODFASE << "==\"" << codfase << "\")";
|
||
}
|
||
if (select.full())
|
||
query << "SELECT " << select << "\n";
|
||
|
||
TString fromto = RILORE_TIPO;
|
||
|
||
fromto << "=\"" << tipo << "\"";
|
||
if (_anno > 0)
|
||
{
|
||
fromto << " " << RILORE_ANNO << "=" << _anno << " ";
|
||
if (_mese > 0)
|
||
{
|
||
fromto << RILORE_MESE << "=" << _mese << " ";
|
||
if (tipo == 'C')
|
||
fromto << RILORE_GIORNO << "=" << _giorno << " ";
|
||
}
|
||
}
|
||
query << "FROM " << fromto << "\n"
|
||
<< "TO " << fromto;
|
||
|
||
TISAM_recordset def(query);
|
||
|
||
//riempio lo sheet con i dati che soddisfano il filtro preparato prima
|
||
for(bool ok = def.move_first(); ok; ok = def.move_next())
|
||
{
|
||
TRilevamento_ore rilore(def.cursor()->curr());
|
||
|
||
TToken_string& riga = sheet.row(-1);
|
||
const char tipor = rilore.get(RILORE_TIPORA)[0];
|
||
TString16 cod = rilore.get(RILORE_CODICE);
|
||
|
||
riga.add(tipor, sheet.cid2index(S_RISOATT));
|
||
switch(tipor)
|
||
{
|
||
case 'R': riga.add(cod, sheet.cid2index(S_CODRIS)); break;
|
||
case 'A': riga.add(cod, sheet.cid2index(S_CODATT)); break;
|
||
default : break;
|
||
}
|
||
riga.add(rilore.get(RILORE_TPORA), sheet.cid2index(S_TPORA));
|
||
put_row_anal_fields(riga, rilore.get(RILORE_CODCOSTO), rilore.get(RILORE_CODCMS), rilore.get(RILORE_CODFASE));
|
||
riga.add(rilore.get(RILORE_QTAORE), sheet.cid2index(S_QTAORE));
|
||
riga.add(rilore.get(RILORE_CODLIST), sheet.cid2index(S_CODLIST));
|
||
riga.add(rilore.get(RILORE_COSTO), sheet.cid2index(S_COSTO));
|
||
riga.add(rilore.get(RILORE_CUP), sheet.cid2index(S_CUP));
|
||
riga.add(rilore.get(RILORE_CIG), sheet.cid2index(S_CIG));
|
||
riga.add(tipo == 'D' ? 0 : rilore.get(RILORE_ID), sheet.cid2index(S_ID));
|
||
|
||
sheet.check_row(sheet.items() - 1);
|
||
sheet.select(sheet.items() - 1);
|
||
update_prev();
|
||
}
|
||
sheet.force_update();
|
||
}
|
||
|
||
void TRilevamento_cons_msk::update_disp()
|
||
{
|
||
TSheet_field & sf = sfield(F_SHEET);
|
||
|
||
//leggo dalla maschera i campi chiave di ricerca
|
||
TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
||
TString4 tpora = get(F_TPORA);
|
||
TString16 codice;
|
||
|
||
if (risoatt == "R")
|
||
codice = get(F_CODRIS);
|
||
else
|
||
if (risoatt == "A")
|
||
codice = get(F_CODATT);
|
||
|
||
const bool head_resource = codice.full();
|
||
|
||
if (!head_resource && sf.items() > 0)
|
||
{
|
||
const int r = sf.selected();
|
||
|
||
if (r >= 0)
|
||
{
|
||
TToken_string & row = sf.row(r);
|
||
|
||
risoatt = row.get(sf.cid2index(S_RISOATT));
|
||
tpora = row.get(sf.cid2index(S_TPORA));
|
||
if (risoatt == "R")
|
||
codice = row.get(sf.cid2index(S_CODRIS));
|
||
else
|
||
if (risoatt == "A")
|
||
codice = row.get(sf.cid2index(S_CODATT));
|
||
}
|
||
}
|
||
|
||
if (codice.full())
|
||
{
|
||
TString chiave(risoatt);
|
||
TDate day(_giorno, _mese, _anno);
|
||
|
||
chiave << codice.lpad(field(F_CODRIS).size()) << day.string(ANSI) << tpora;
|
||
real * val = (real *)_oredisp.objptr(chiave);
|
||
|
||
if (val != NULL)
|
||
set(F_OREDIS, *val);
|
||
else
|
||
{
|
||
TString query;
|
||
|
||
query << "USE &DRA SELECT MID(CODTAB,30,2)==\"" << tpora << "\"\n"
|
||
<< "FROM CODTAB=\"" << chiave << "\"\n" ;
|
||
TString tochiave = chiave.left(21);
|
||
|
||
const TString4 intervallo = get(F_INTERVALLO);
|
||
|
||
if (intervallo == "M")
|
||
{
|
||
day.addmonth();
|
||
--day;
|
||
}
|
||
else
|
||
if (intervallo == "A")
|
||
{
|
||
day.addyear();
|
||
--day;
|
||
}
|
||
|
||
tochiave << day.string(ANSI) << tpora;
|
||
|
||
query << "TO CODTAB=\"" << tochiave << "\"\n";
|
||
|
||
TISAM_recordset def(query);
|
||
real oredisp;
|
||
|
||
for(bool ok = def.move_first(); ok; ok = def.move_next())
|
||
oredisp += def.cursor()->curr().get_real("R1");
|
||
set(F_OREDIS, oredisp);
|
||
_oredisp.add(chiave, oredisp);
|
||
}
|
||
}
|
||
}
|
||
|
||
void TRilevamento_cons_msk::update_prev()
|
||
{
|
||
TSheet_field & sf = sfield(F_SHEET);
|
||
|
||
if ( sf.items() > 0)
|
||
{
|
||
const int r = sf.selected();
|
||
|
||
if (r < 0)
|
||
return;
|
||
TToken_string & row = sf.row(r);
|
||
//leggo dalla maschera i campi chiave di ricerca
|
||
TString4 risoatt = row.get(sf.cid2index(S_RISOATT));
|
||
TString16 codice;
|
||
|
||
if (risoatt == "T")
|
||
risoatt = "";
|
||
else
|
||
if (risoatt == "R")
|
||
codice = row.get(sf.cid2index(S_CODRIS));
|
||
else
|
||
if (risoatt == "A")
|
||
codice = row.get(sf.cid2index(S_CODATT));
|
||
|
||
if (codice.full())
|
||
{
|
||
TString4 tpora = row.get(sf.cid2index(S_TPORA));
|
||
TString codcosto;
|
||
TString codcms;
|
||
TString codfase;
|
||
TToken_string chiave;
|
||
|
||
get_anal_fields(codcosto, codcms, codfase);
|
||
chiave.add(_anno);
|
||
chiave.add(_mese);
|
||
chiave.add(_giorno);
|
||
chiave.add(risoatt);
|
||
chiave.add(codice);
|
||
chiave.add(tpora);
|
||
chiave.add(codcosto);
|
||
chiave.add(codcms);
|
||
chiave.add(codfase);
|
||
real * val = (real *)_oreprev.objptr(chiave);
|
||
|
||
if (val != NULL)
|
||
row.add(val->string(), sf.cid2index(S_OREPREV));
|
||
else
|
||
{
|
||
TString query;
|
||
query << "USE " << LF_RILORE << " KEY 2\n"
|
||
<< "FROM " << RILORE_TIPO "=\"P\""
|
||
<< " " << RILORE_ANNO << "=" << _anno << " "
|
||
<< RILORE_MESE << "=" << _mese << " "
|
||
<< RILORE_GIORNO << "=" << _giorno << " "
|
||
<< RILORE_TIPORA << "=" << risoatt << " "
|
||
<< RILORE_CODICE << "=" << codice << " "
|
||
<< RILORE_TPORA << "=" << tpora << " "
|
||
<< RILORE_CODCOSTO << "=" << codcosto << " "
|
||
<< RILORE_CODCMS << "=" << codcms << " "
|
||
<< RILORE_CODFASE << "=" << codfase << "\n";
|
||
|
||
TDate day(_giorno, _mese, _anno);
|
||
const TString4 intervallo = get(F_INTERVALLO);
|
||
|
||
if (intervallo == "M")
|
||
{
|
||
day.addmonth();
|
||
--day;
|
||
}
|
||
else
|
||
if (intervallo == "A")
|
||
{
|
||
day.addyear();
|
||
--day;
|
||
}
|
||
|
||
query << "TO " << RILORE_TIPO "=\"P\""
|
||
<< " " << RILORE_ANNO << "=" << day.year() << " "
|
||
<< RILORE_MESE << "=" << day.month() << " "
|
||
<< RILORE_GIORNO << "=" << day.day() << " "
|
||
<< RILORE_GIORNO << "=" << _giorno << " "
|
||
<< RILORE_TIPORA << "=" << risoatt << " "
|
||
<< RILORE_CODICE << "=" << codice << " "
|
||
<< RILORE_TPORA << "=" << tpora << " "
|
||
<< RILORE_CODCOSTO << "=" << codcosto << " "
|
||
<< RILORE_CODCMS << "=" << codcms << " "
|
||
<< RILORE_CODFASE << "=" << codfase << "\n";
|
||
|
||
TISAM_recordset def(query);
|
||
real oreprev;
|
||
|
||
for(bool ok = def.move_first(); ok; ok = def.move_next())
|
||
oreprev += def.cursor()->curr().get_real(RILORE_QTAORE);
|
||
row.add(oreprev.string(), sf.cid2index(S_OREPREV));
|
||
sf.force_update(r);
|
||
_oreprev.add(chiave, oreprev);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//RIEMPI_SHEET: metodo che riempie lo sheet in base ai campi chiave
|
||
//compilati sulla maschera
|
||
void TRilevamento_cons_msk::riempi_sheet()
|
||
{
|
||
//leggo dalla maschera i campi chiave di ricerca
|
||
const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
||
const TString4 tpora = get(F_TPORA);
|
||
TString80 codcosto;
|
||
TString80 codcms;
|
||
TString16 codfase;
|
||
TString16 codice;
|
||
TString query;
|
||
TString select;
|
||
|
||
update_day();
|
||
switch(get(F_RISOATT)[0])
|
||
{
|
||
case 'R': codice = get(F_CODRIS); break;
|
||
case 'A': codice = get(F_CODATT); break;
|
||
default: break;
|
||
}
|
||
|
||
get_anal_fields(codcosto, codcms, codfase);
|
||
|
||
//preparo la query
|
||
query << "USE " << LF_RILORE << " KEY 2\n" ;
|
||
if (risoatt.full())
|
||
select << "(" << RILORE_TIPORA << "==\"" << risoatt << "\")";
|
||
if (codice.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODICE << "==\"" << codice << "\")";
|
||
}
|
||
if (tpora.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_TPORA << "==\"" << tpora << "\")";
|
||
}
|
||
if (codcosto.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODCOSTO << "==\"" << codcosto << "\")";
|
||
}
|
||
if (codcms.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODCMS << "==\"" << codcms << "\")";
|
||
}
|
||
if (codfase.full())
|
||
{
|
||
if (select.full()) select << "&&";
|
||
select << "(" << RILORE_CODFASE << "==\"" << codfase << "\")";
|
||
}
|
||
if (select.full())
|
||
query << "SELECT " << select << "\n";
|
||
|
||
TString fromto = RILORE_TIPO "=\"C\"";
|
||
|
||
if (_anno > 0)
|
||
{
|
||
fromto << " " << RILORE_ANNO << "=" << _anno << " ";
|
||
if (_mese > 0)
|
||
fromto << RILORE_MESE << "=" << _mese << " ";
|
||
}
|
||
query << "FROM " << fromto << "\n"
|
||
<< "TO " << fromto;
|
||
riempi_calendario(query);
|
||
riempi_risoatt();
|
||
}
|
||
|
||
//NUOVA_RIGA: metodo che aggiunge una riga allo sheet
|
||
//tenendo conto dei campi chiave compilati in testata
|
||
void TRilevamento_cons_msk::nuova_riga()
|
||
{
|
||
TSheet_field& sheet = sfield(F_SHEET);
|
||
const int r = sheet.items() - 1;
|
||
TToken_string & riga = sheet.row(r);
|
||
TMask& msk = sheet.sheet_mask();
|
||
|
||
|
||
sheet.select(r);
|
||
//guardo il tipo risorsa / attrezzatura che sto ricercando
|
||
const bool tutti = get(F_RISOATT)[0] == 'T';
|
||
const TString4 tipo = tutti ? "R" : get(F_RISOATT);
|
||
TString codice;
|
||
TString tpora = get(F_TPORA);
|
||
TString codcosto;
|
||
TString codcms;
|
||
TString codfase;
|
||
|
||
riga.add(tipo, sheet.cid2index(S_RISOATT));
|
||
if (!tutti)
|
||
{
|
||
if (tipo == "R")
|
||
riga.add(get(F_CODRIS), sheet.cid2index(S_CODRIS));
|
||
else
|
||
riga.add(get(F_CODATT), sheet.cid2index(S_CODATT));
|
||
}
|
||
riga.add(tpora, sheet.cid2index(S_TPORA));
|
||
get_anal_fields(codcosto, codcms, codfase);
|
||
put_row_anal_fields(riga, codcosto, codcms, codfase);
|
||
riga.add(proponi_costo(riga).string(), sheet.cid2index(S_COSTO));
|
||
|
||
sheet.check_row(r);
|
||
sheet.force_update(r);
|
||
}
|
||
//AZZERA_RIGA: metodo che azzera il valore unitario della riga selezionata
|
||
void TRilevamento_cons_msk::azzera_riga(TSheet_field& sheet)
|
||
{
|
||
TMask& msk = sheet.sheet_mask();
|
||
msk.set(S_DEL, "X");
|
||
}
|
||
|
||
|
||
//AZZERA_TUTTO: metodo che azzera il valore unitario di tutte le righe visualizzate sullo sheet
|
||
void TRilevamento_cons_msk::azzera_tutto(TSheet_field& sheet)
|
||
{
|
||
FOR_EACH_SHEET_ROW(sheet, r, row)
|
||
{
|
||
TToken_string& row = sheet.row(r);
|
||
row.add("X", sheet.cid2index(S_DEL));
|
||
}
|
||
}
|
||
|
||
//REGISTRA: metodo che salva nella tabella di modulo le
|
||
//righe dello sheet che hanno valore > 0, ed elimina quelle che hanno
|
||
//vaoler pari a zero, e poi ricarica lo sheet
|
||
|
||
void TRilevamento_cons_msk::registra()
|
||
{
|
||
TDoc_cache ca;
|
||
TSheet_field& calendario = sfield(F_CALENDARIO);
|
||
TSheet_field& sheet = sfield(F_SHEET);
|
||
TRilevamento_ore rilroa;
|
||
const int mese = get_int(F_MESE);
|
||
const int anno = get_int(F_ANNO);
|
||
TString80 codcosto;
|
||
TString80 codcms;
|
||
TString16 codfase;
|
||
int err = NOERR;
|
||
|
||
FOR_EACH_SHEET_ROW(sheet, r, row)
|
||
{
|
||
TToken_string& riga = *(TToken_string*)row;
|
||
const TString4 del = riga.get(sheet.cid2index(S_DEL));
|
||
const char tipora = riga.get_char(sheet.cid2index(S_RISOATT));
|
||
const TString16 codice = tipora == 'R' ? riga.get(sheet.cid2index(S_CODRIS)) : riga.get(sheet.cid2index(S_CODATT));
|
||
const TString4 tpora = riga.get(sheet.cid2index(S_TPORA));
|
||
const real qtaore(riga.get(sheet.cid2index(S_QTAORE)));
|
||
const long id = riga.get_long(sheet.cid2index(S_ID));
|
||
const TString8 codlist = riga.get(sheet.cid2index(S_CODLIST));
|
||
const real costo(riga.get(sheet.cid2index(S_COSTO)));
|
||
const TString16 cup(riga.get(sheet.cid2index(S_CUP)));
|
||
const TString16 cig(riga.get(sheet.cid2index(S_CIG)));
|
||
|
||
get_row_anal_fields(riga, codcosto, codcms, codfase);
|
||
const bool found = rilroa.read('C', id) == NOERR;
|
||
if (del == "X")
|
||
{
|
||
if (found)
|
||
{
|
||
err = rilroa.remove();
|
||
if (_numcn.full() && _tipocn.full())
|
||
{
|
||
TDocumento & doc = ca.doc(rilroa);
|
||
const int docrow = doc.id2rownum(rilroa.get_long(RILORE_IDRIGA));
|
||
|
||
if (docrow > 0)
|
||
doc.destroy_row(docrow, true);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
rilroa.put(RILORE_TIPO, "C");
|
||
rilroa.put(RILORE_ID, id);
|
||
rilroa.put(RILORE_ANNO, anno);
|
||
rilroa.put(RILORE_MESE, mese);
|
||
rilroa.put(RILORE_GIORNO, _giorno);
|
||
rilroa.put(RILORE_TIPORA, tipora);
|
||
rilroa.put(RILORE_CODICE, codice);
|
||
rilroa.put(RILORE_TPORA, tpora);
|
||
rilroa.put(RILORE_CODCOSTO, codcosto);
|
||
rilroa.put(RILORE_CODCMS, codcms);
|
||
rilroa.put(RILORE_CODFASE, codfase);
|
||
rilroa.put(RILORE_QTAORE, qtaore);
|
||
rilroa.put(RILORE_CODLIST, codlist);
|
||
rilroa.put(RILORE_COSTO, costo);
|
||
rilroa.put(RILORE_CUP, cup);
|
||
rilroa.put(RILORE_CIG, cig);
|
||
|
||
if (_numcn.full() && _tipocn.full())
|
||
{
|
||
TDoc_key oldkey(rilroa);
|
||
const long ndoc = date2ndoc(TDate(_giorno, mese, anno));
|
||
|
||
if (oldkey.provv() != 'D')
|
||
{
|
||
oldkey.set_provv();
|
||
oldkey.set_anno(anno);
|
||
oldkey.set_codnum(_numcn);
|
||
oldkey.set_ndoc(ndoc);
|
||
}
|
||
|
||
TDocumento & olddoc = ca.doc(oldkey);
|
||
|
||
int docrow = olddoc.id2rownum(rilroa.get_long(RILORE_IDRIGA));
|
||
TDoc_key key(olddoc);
|
||
|
||
if (found && (key.anno() != anno || ndoc != olddoc.get_long(DOC_NDOC)))
|
||
{
|
||
if (docrow > 0)
|
||
olddoc.destroy_row(docrow, true);
|
||
docrow = -1;
|
||
key.set_ndoc(ndoc);
|
||
}
|
||
|
||
TDocumento & doc = ca.doc(key);
|
||
|
||
doc.set_tipo(_tipocn);
|
||
doc.put(DOC_DATADOC, TDate(_giorno, mese, anno));
|
||
|
||
TSpesa_prest risatt(codice, tipora);
|
||
|
||
if (docrow < 0)
|
||
{
|
||
doc.new_row(risatt.tipo_riga());
|
||
docrow = doc.physical_rows();
|
||
doc.set_row_ids();
|
||
}
|
||
TRiga_documento & rdoc = doc[docrow];
|
||
|
||
rdoc.put(RDOC_TIPORIGA, risatt.tipo_riga());
|
||
rdoc.put(RDOC_CODART, codice);
|
||
rdoc.put(RDOC_DESCR, risatt.descrizione());
|
||
rdoc.put(RDOC_CHECKED, "X");
|
||
rdoc.put(RILORE_TPORA, tpora); // campo virtuale
|
||
rdoc.put(RDOC_CODCOSTO, codcosto);
|
||
rdoc.put(RDOC_CODCMS, codcms);
|
||
rdoc.put(RDOC_FASCMS, codfase);
|
||
rdoc.put(RDOC_QTA, qtaore);
|
||
rdoc.put(RDOC_UMQTA, risatt.um());
|
||
rdoc.put(RDOC_PREZZO, costo);
|
||
rdoc.put(RDOC_PREZZOL, rdoc.iva(risatt.cod_iva()).lordo(costo, ALL_DECIMALS));
|
||
rdoc.put(RDOC_CODIVA, risatt.cod_iva());
|
||
rilroa.put(RILORE_PROVV, key.provv());
|
||
rilroa.put(RILORE_ANNOD, key.anno());
|
||
rilroa.put(RILORE_CODNUM, key.codnum());
|
||
rilroa.put(RILORE_NDOC, key.ndoc());
|
||
rilroa.put(RILORE_IDRIGA, rdoc.get_long(RDOC_IDRIGA));
|
||
}
|
||
else
|
||
{
|
||
rilroa.zero(RILORE_PROVV);
|
||
rilroa.zero(RILORE_ANNOD);
|
||
rilroa.zero(RILORE_CODNUM);
|
||
rilroa.zero(RILORE_NDOC);
|
||
rilroa.zero(RILORE_IDRIGA);
|
||
}
|
||
err = rilroa.rewrite_write();
|
||
}
|
||
if (err != NOERR)
|
||
break;
|
||
}
|
||
if (err == NOERR)
|
||
{
|
||
ca.destroy();
|
||
sheet.destroy();
|
||
riempi_sheet();
|
||
}
|
||
else
|
||
error_box(FR("Errore %d in scrittura"), err);
|
||
}
|
||
|
||
void TRilevamento_cons_msk::update_day()
|
||
{
|
||
const int row = sfield(F_CALENDARIO).selected();
|
||
const TString4 dett = get(F_INTERVALLO);
|
||
|
||
if (dett == "G")
|
||
{
|
||
_anno = get_int(F_ANNO);
|
||
_mese = get_int(F_MESE);
|
||
_giorno = row +1;
|
||
}
|
||
else
|
||
if (dett == "M")
|
||
{
|
||
_anno = get_int(F_ANNO);
|
||
_mese = row + 1;
|
||
_giorno = 1;
|
||
}
|
||
else
|
||
if (dett == "A")
|
||
{
|
||
_anno = _es_array[row];
|
||
_mese = 1;
|
||
_giorno = 1;
|
||
}
|
||
}
|
||
|
||
//ON_FIELD_EVENT: metodo che gestisce gli eventi sui vari campi della maschera
|
||
bool TRilevamento_cons_msk::on_field_event(TOperable_field& f, TField_event e, long jolly)
|
||
{
|
||
if ((f.dlg() == _cdc_lid ||
|
||
f.dlg() == _cms_lid ||
|
||
f.dlg() == _fase_lid) && e == fe_modify)
|
||
riempi_sheet();
|
||
if (f.dlg() == _scms_lid)
|
||
{
|
||
if (e == fe_init || e == fe_modify)
|
||
{
|
||
const TRectype & curr = f.mask().efield(_scms_lid).browse()->cursor()->curr();
|
||
const TString codcms = curr.get(COMMESSE_CODCMS);
|
||
|
||
f.mask().set(S_CMSH, codcms);
|
||
if (e == fe_modify)
|
||
{
|
||
const TRectype & commesse = cache().get(LF_COMMESSE, codcms);
|
||
|
||
f.mask().set(S_CODLIST, commesse.get(COMMESSE_LISRILCN), 3);
|
||
if (main_app().has_module(CUAUT))
|
||
{
|
||
TToken_string key;
|
||
|
||
key.add(codcms);
|
||
key.add("C");
|
||
key.add(1);
|
||
const TRectype & cfcms = cache().get(LF_CFCMS, key);
|
||
|
||
f.mask().set(S_CUP, cfcms.get(CFCMS_CUP), 3);
|
||
f.mask().set(S_CIG, cfcms.get(CFCMS_CIG), 3);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
switch (f.dlg())
|
||
{
|
||
case DLG_DEFAULT:
|
||
if(e == fe_button)
|
||
carica_default();
|
||
break;
|
||
case DLG_CERCA:
|
||
if(e == fe_button)
|
||
riempi_sheet();
|
||
break;
|
||
case DLG_SAVEREC:
|
||
if(e == fe_button)
|
||
registra();
|
||
case F_ANNO:
|
||
case F_MESE:
|
||
case F_RISOATT:
|
||
case F_CODRIS:
|
||
case F_CODATT:
|
||
case F_TPORA:
|
||
if (e == fe_modify)
|
||
riempi_sheet();
|
||
break;
|
||
case F_CALENDARIO:
|
||
if (e == se_enter)
|
||
riempi_risoatt();
|
||
break;
|
||
case F_SHEET:
|
||
if (e == se_notify_add)
|
||
nuova_riga();
|
||
else
|
||
if (e == se_enter)
|
||
{
|
||
update_prev();
|
||
update_disp();
|
||
}
|
||
break;
|
||
case F_INTERVALLO:
|
||
if (e == fe_modify)
|
||
{
|
||
const TString4 dett = ini_get_string(CONFIG_DITTA, "ci", "DETTCONS");
|
||
if (dett == "A")
|
||
{
|
||
reset(F_ANNO);
|
||
disable(F_ANNO);
|
||
reset(F_MESE);
|
||
disable(F_MESE);
|
||
}
|
||
else
|
||
{
|
||
if (dett == "M")
|
||
{
|
||
reset(F_MESE);
|
||
disable(F_MESE);
|
||
}
|
||
}
|
||
riempi_sheet();
|
||
}
|
||
break;
|
||
case DLG_RESET:
|
||
if(e == fe_button)
|
||
{
|
||
TSheet_field& sheet = sfield(F_SHEET);
|
||
switch(jolly)
|
||
{
|
||
case 0: azzera_tutto(sheet); break;
|
||
case 2: azzera_riga(sheet); break;
|
||
default: break;
|
||
}
|
||
sheet.force_update();
|
||
return false;
|
||
}
|
||
break;
|
||
case S_RISOATT:
|
||
case S_CODRIS:
|
||
case S_CODATT:
|
||
case S_CODLIST:
|
||
case S_TPORA:
|
||
if(e == fe_modify)
|
||
{
|
||
TSheet_field& sheet = sfield(F_SHEET);
|
||
|
||
f.mask().set(S_COSTO, proponi_costo(sheet.row(sheet.selected())).string());
|
||
}
|
||
break;
|
||
default: break;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
TRilevamento_cons_msk::TRilevamento_cons_msk()
|
||
: TAutomask("ci2200a")
|
||
{
|
||
const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI);
|
||
TConfig& ini = ca_config();
|
||
TSheet_field & s = sfield(F_SHEET);
|
||
TMask & sm = s.sheet_mask();
|
||
int y = 4;
|
||
int sy = 8;
|
||
short dlg = F_ANAL; // id del primo campo da generare
|
||
short sdlg = S_CDC1 + 100; // id del primo campo da generare
|
||
|
||
_cdc_sid = _cdc_lid = _cms_sid = _cms_lid = _fase_sid = _fase_lid = -1;
|
||
_scdc_sid = _scdc_lid = _scms_sid = _scms_lid = _sfase_sid = _sfase_lid = -1;
|
||
|
||
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)
|
||
{
|
||
int h = ca_multilevel_code_info(LF_CDC).levels();
|
||
const int h1 = ca_create_fields_compact(*this, 0, LF_FASI, 2, y, dlg, dlg + 100);
|
||
y += 2;
|
||
_cdc_sid = dlg;
|
||
_cdc_lid = dlg + h - 1;
|
||
_fase_sid = _cdc_lid + 1;
|
||
_fase_lid = dlg + h1 - 1;
|
||
dlg += h1;
|
||
const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy, sdlg, sdlg + 50);
|
||
sy += 2;
|
||
_scdc_sid = sdlg;
|
||
_scdc_lid = sdlg + h - 1;
|
||
_sfase_sid = _scdc_lid + 1;
|
||
_sfase_lid = sdlg + sh - 1;
|
||
sdlg += sh;
|
||
}
|
||
else
|
||
{
|
||
const int h = ca_create_fields_compact(*this, 0, LF_CDC, 2, y++, dlg, dlg + 100);
|
||
_cdc_sid = dlg;
|
||
_cdc_lid = dlg + h - 1;
|
||
dlg += h;
|
||
const int sh = ca_create_fields_compact(sm, 0, LF_CDC, 2, sy++, sdlg, sdlg + 50);
|
||
_scdc_sid = sdlg;
|
||
_scdc_lid = sdlg + sh - 1;
|
||
sdlg += h;
|
||
}
|
||
}
|
||
else
|
||
if (level == "CMS") // Crea commessa
|
||
{
|
||
if (fasinfo.parent() == LF_COMMESSE)
|
||
{
|
||
int h = ca_multilevel_code_info(LF_COMMESSE).levels();
|
||
const int h1 = ca_create_fields_compact(*this, 0, LF_FASI, 2, y, dlg, dlg + 100);
|
||
y += 2;
|
||
_cms_sid = dlg;
|
||
_cms_lid = dlg + h - 1;
|
||
_fase_sid = _cms_lid + 1;
|
||
_fase_lid = dlg + h1 - 1;
|
||
dlg += h1;
|
||
const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy, sdlg, sdlg + 50);
|
||
sy += 2;
|
||
_scms_sid = sdlg;
|
||
_scms_lid = sdlg + h - 1;
|
||
_sfase_sid = _scms_lid + 1;
|
||
_sfase_lid = sdlg + sh - 1;
|
||
sdlg += sh;
|
||
}
|
||
else
|
||
{
|
||
const int h = ca_create_fields_compact(*this, 0, LF_COMMESSE, 2, y++, dlg, dlg + 100);
|
||
_cms_sid = dlg;
|
||
_cms_lid = dlg + h - 1;
|
||
dlg += h;
|
||
const int sh = ca_create_fields_compact(sm, 0, LF_COMMESSE, 2, sy++, sdlg, sdlg + 50);
|
||
_scms_sid = sdlg;
|
||
_scms_lid = sdlg + sh - 1;
|
||
sdlg += sh;
|
||
}
|
||
}
|
||
}
|
||
if (fasinfo.levels() > 0 && fasinfo.parent() <= 0)
|
||
{
|
||
const int h = ca_create_fields_compact(*this, 0, LF_FASI, 2, y++, dlg, dlg + 100);
|
||
_fase_sid = dlg;
|
||
_fase_lid = dlg + h - 1;
|
||
dlg += h;
|
||
const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy++, sdlg, sdlg + 50);
|
||
_sfase_sid = sdlg;
|
||
_sfase_lid = sdlg + sh - 1;
|
||
sdlg += h;
|
||
}
|
||
|
||
for (int i = 0; i < 12; i++)
|
||
{
|
||
const short id = F_ANAL + i;
|
||
|
||
const int pos = id2pos(id);
|
||
if (pos >= 0)
|
||
{
|
||
set_universal_handler(id);
|
||
set_universal_handler(id + 100);
|
||
}
|
||
}
|
||
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 = ((TEditable_field &)f).get_warning();
|
||
s.set_column_header(id, prompt);
|
||
s.set_column_justify(id, f.is_kind_of(CLASS_REAL_FIELD));
|
||
s.set_column_width(id, (max(3+size, prompt.len()+1)) * CHARX);
|
||
s.update_column_width(id);
|
||
s.enable_column(id);
|
||
set_insheet_universal_handler(F_SHEET, id);
|
||
set_insheet_universal_handler(F_SHEET, id + 50);
|
||
}
|
||
else
|
||
s.delete_column(id);
|
||
}
|
||
const TString4 dett = ini_get_string(CONFIG_DITTA, "ci", "DETTCONS");
|
||
TSheet_field & sc = sfield(F_CALENDARIO);
|
||
|
||
_n_ex = 0;
|
||
for (int codes = _es.first(); codes != 0; codes = _es.next(codes))
|
||
_es_array[_n_ex++] = codes;
|
||
if (dett == "A")
|
||
disable(F_INTERVALLO);
|
||
else
|
||
{
|
||
if (dett == "M")
|
||
{
|
||
TList_field & f = lfield(F_INTERVALLO);
|
||
|
||
f.delete_item("G");
|
||
}
|
||
set(F_ANNO, TDate(TODAY).year());
|
||
}
|
||
set(F_INTERVALLO, dett);
|
||
_numcn = ini_get_string(CONFIG_DITTA, "ci", "CODNUMCN");
|
||
_tipocn = ini_get_string(CONFIG_DITTA, "ci", "TIPODOCCN");
|
||
}
|
||
|
||
////////////////////////////////////////////
|
||
//// CLASSE TRilevamento_cons_app ////
|
||
////////////////////////////////////////////
|
||
|
||
//classe TRilevamento_cons_app
|
||
class TRilevamento_cons_app : public TSkeleton_application
|
||
{
|
||
public:
|
||
virtual void main_loop();
|
||
};
|
||
|
||
void TRilevamento_cons_app::main_loop()
|
||
{
|
||
open_files(LF_DOC, LF_RIGHEDOC, LF_RILORE, 0);
|
||
TRilevamento_cons_msk msk;
|
||
while (msk.run() != K_QUIT) ;
|
||
}
|
||
|
||
int ci2200(int argc, char *argv[])
|
||
{
|
||
TRilevamento_cons_app a;
|
||
a.run (argc, argv, TR("Rilevamento Ore Consuntivo"));
|
||
return TRUE;
|
||
} |