2010-07-24 09:20:04 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
2010-09-01 15:15:12 +00:00
|
|
|
|
#include <colors.h>
|
2010-07-24 09:20:04 +00:00
|
|
|
|
#include <defmask.h>
|
2011-01-19 11:48:29 +00:00
|
|
|
|
#include <modaut.h>
|
2010-07-24 09:20:04 +00:00
|
|
|
|
#include <recset.h>
|
|
|
|
|
#include <sheet.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include <doc.h>
|
|
|
|
|
|
|
|
|
|
#include "ci2.h"
|
|
|
|
|
#include "cilib.h"
|
|
|
|
|
#include "ci2200a.h"
|
2010-09-21 14:36:08 +00:00
|
|
|
|
#include "rilore.h"
|
2010-09-22 01:06:45 +00:00
|
|
|
|
#include "../ca/calib01.h"
|
2011-01-19 11:48:29 +00:00
|
|
|
|
#include "../ca/commesse.h"
|
|
|
|
|
#include "../ca/cfcms.h"
|
2010-07-24 09:20:04 +00:00
|
|
|
|
#include "../ve/velib.h"
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
//// CLASSE TRilevamento_cons_msk ////
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//Classe TRilevamento_cons_msk
|
|
|
|
|
class TRilevamento_cons_msk : public TAutomask
|
|
|
|
|
{
|
2010-09-02 15:23:23 +00:00
|
|
|
|
int _qtaore;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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;
|
2010-09-02 15:23:23 +00:00
|
|
|
|
TDate _datasel;
|
2010-11-16 00:17:10 +00:00
|
|
|
|
int _anno;
|
|
|
|
|
int _mese;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
int _giorno;
|
2010-11-16 00:17:10 +00:00
|
|
|
|
int _first_ex;
|
|
|
|
|
int _n_ex;
|
|
|
|
|
int _es_array[32];
|
|
|
|
|
TEsercizi_contabili _es;
|
2011-01-19 11:48:29 +00:00
|
|
|
|
TString _numcn;
|
|
|
|
|
TString _tipocn;
|
2011-01-31 02:47:08 +00:00
|
|
|
|
TToken_string _last_key;
|
2011-01-31 22:19:56 +00:00
|
|
|
|
TAssoc_array _oredisp;
|
|
|
|
|
TAssoc_array _oreprev;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
|
2010-07-24 09:20:04 +00:00
|
|
|
|
protected:
|
|
|
|
|
const real proponi_costo(TToken_string& riga);
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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);
|
2010-07-24 09:20:04 +00:00
|
|
|
|
void carica_default();
|
2010-11-16 00:17:10 +00:00
|
|
|
|
void update_day();
|
2011-01-31 02:47:08 +00:00
|
|
|
|
void update_disp();
|
2011-01-31 22:19:56 +00:00
|
|
|
|
void update_prev();
|
2010-07-24 09:20:04 +00:00
|
|
|
|
void riempi_sheet();
|
2010-11-16 00:17:10 +00:00
|
|
|
|
void riempi_calendario(const TString & query);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
void update_column(short sid, const bool full, int len = -1);
|
2010-11-16 16:17:20 +00:00
|
|
|
|
void riempi_risoatt(char tipo = 'C');
|
2011-01-31 02:47:08 +00:00
|
|
|
|
void nuova_riga();
|
|
|
|
|
void azzera_riga(TSheet_field& sheet);
|
|
|
|
|
void azzera_tutto(TSheet_field& sheet);
|
2010-07-24 09:20:04 +00:00
|
|
|
|
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;
|
2010-09-02 15:23:23 +00:00
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
const TString8 codlist = riga.get(sheet.cid2index(S_CODLIST));
|
2010-07-24 09:20:04 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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();
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
if(err == NOERR)
|
2010-07-24 09:20:04 +00:00
|
|
|
|
costo = roa.get_real("R1");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TString query;
|
2011-01-31 02:47:08 +00:00
|
|
|
|
query << "USE &ROA SELECT MID(CODTAB,30,2)==\"" << tpora << "\"\n"
|
|
|
|
|
<< "FROM CODTAB=\"" << chiave.left(21) << "\"\n"
|
|
|
|
|
<< "TO CODTAB=\"" << chiave << "\"\n";
|
2010-07-24 09:20:04 +00:00
|
|
|
|
TISAM_recordset rec(query);
|
|
|
|
|
|
|
|
|
|
if(rec.move_last())
|
|
|
|
|
costo = rec.cursor()->curr().get_real("R1");
|
2010-09-02 15:23:23 +00:00
|
|
|
|
}
|
2010-07-24 09:20:04 +00:00
|
|
|
|
return costo;
|
|
|
|
|
}
|
2011-01-31 02:47:08 +00:00
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
|
|
|
|
void TRilevamento_cons_msk::carica_default()
|
|
|
|
|
{
|
2010-09-01 15:15:12 +00:00
|
|
|
|
//leggo dalla maschera i campi chiave di ricerca
|
2010-07-24 09:20:04 +00:00
|
|
|
|
const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
|
|
|
|
const TString4 tpora = get(F_TPORA);
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString80 codcosto;
|
|
|
|
|
TString80 codcms;
|
|
|
|
|
TString16 codfase;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
TString16 codice;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString query;
|
|
|
|
|
TString select;
|
2010-09-21 14:36:08 +00:00
|
|
|
|
|
2010-11-16 16:17:20 +00:00
|
|
|
|
update_day();
|
2010-09-21 14:36:08 +00:00
|
|
|
|
switch(get(F_RISOATT)[0])
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
2010-09-22 01:06:45 +00:00
|
|
|
|
case 'R': codice = get(F_CODRIS); break;
|
|
|
|
|
case 'A': codice = get(F_CODATT); break;
|
|
|
|
|
default: break;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
2010-09-22 01:06:45 +00:00
|
|
|
|
get_anal_fields(codcosto, codcms, codfase);
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
2010-11-16 00:17:10 +00:00
|
|
|
|
query << "USE " << LF_RILORE << " KEY 2\n" ;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
|
|
|
|
|
TString fromto = RILORE_TIPO "=\"D\" ";
|
2010-09-22 01:06:45 +00:00
|
|
|
|
|
2010-11-16 00:17:10 +00:00
|
|
|
|
if (_anno > 0)
|
2010-09-21 14:36:08 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
fromto << " " << RILORE_ANNO << "=" << _anno << " ";
|
|
|
|
|
if (_mese > 0)
|
|
|
|
|
fromto << RILORE_MESE << "=" << _mese << " ";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
}
|
2010-11-16 16:17:20 +00:00
|
|
|
|
riempi_risoatt('D');
|
2010-09-01 15:15:12 +00:00
|
|
|
|
}
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
2010-09-01 15:15:12 +00:00
|
|
|
|
//RIEMPI_CALENDARIO: coloro le celle dello sheet calendario secondo le festivit<69> e i giorni occupati
|
2010-11-16 00:17:10 +00:00
|
|
|
|
void TRilevamento_cons_msk::riempi_calendario(const TString & query)
|
2010-09-01 15:15:12 +00:00
|
|
|
|
{
|
2010-11-16 16:17:20 +00:00
|
|
|
|
TSheet_field& calendario = sfield(F_CALENDARIO);
|
2010-12-05 10:28:20 +00:00
|
|
|
|
const TString4 dett = get(F_INTERVALLO);
|
2010-11-16 16:17:20 +00:00
|
|
|
|
|
|
|
|
|
update_day();
|
2010-12-05 10:28:20 +00:00
|
|
|
|
calendario.destroy(-1, false);
|
|
|
|
|
if (dett == "A")
|
2010-09-22 01:06:45 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
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);
|
2010-12-05 10:28:20 +00:00
|
|
|
|
COLOR back = NORMAL_BACK_COLOR;
|
|
|
|
|
COLOR fore = NORMAL_COLOR;
|
2010-09-02 15:23:23 +00:00
|
|
|
|
|
2010-11-16 00:17:10 +00:00
|
|
|
|
if (full_years[_es_array[i]])
|
|
|
|
|
{
|
2010-12-05 10:28:20 +00:00
|
|
|
|
back = COLOR_DKBLUE; // coloro di blu le date con registrazioni
|
|
|
|
|
fore = COLOR_WHITE; // coloro di blu le date con registrazioni
|
2010-11-16 00:17:10 +00:00
|
|
|
|
}
|
2010-12-05 10:28:20 +00:00
|
|
|
|
calendario.set_back_and_fore_color(back, fore, i - 1, 0);
|
2010-11-16 00:17:10 +00:00
|
|
|
|
row.add(_es_array[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-12-05 10:28:20 +00:00
|
|
|
|
if (dett == "M")
|
2010-09-22 01:06:45 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 16:17:20 +00:00
|
|
|
|
for (int i = 1; i <= 12; i++)
|
2010-11-16 00:17:10 +00:00
|
|
|
|
{
|
2010-11-16 16:17:20 +00:00
|
|
|
|
TToken_string & row = calendario.row(i - 1);
|
2010-12-05 10:28:20 +00:00
|
|
|
|
COLOR back = NORMAL_BACK_COLOR;
|
|
|
|
|
COLOR fore = NORMAL_COLOR;
|
|
|
|
|
|
2010-11-16 00:17:10 +00:00
|
|
|
|
if (full_months[i])
|
|
|
|
|
{
|
2010-12-05 10:28:20 +00:00
|
|
|
|
back = COLOR_DKBLUE; // coloro di blu le date con registrazioni
|
|
|
|
|
fore = COLOR_WHITE; // coloro di blu le date con registrazioni
|
2010-11-16 00:17:10 +00:00
|
|
|
|
}
|
2010-12-05 10:28:20 +00:00
|
|
|
|
calendario.set_back_and_fore_color(back, fore, i - 1, 0);
|
2010-11-16 16:17:20 +00:00
|
|
|
|
row.add(itom(i));
|
2010-11-16 00:17:10 +00:00
|
|
|
|
}
|
2010-09-22 01:06:45 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2010-12-05 10:28:20 +00:00
|
|
|
|
if (dett == "G")
|
2010-11-16 00:17:10 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 16:17:20 +00:00
|
|
|
|
for(int i = 1; i <= end_month; i++)
|
2010-11-16 00:17:10 +00:00
|
|
|
|
{
|
2010-11-16 16:17:20 +00:00
|
|
|
|
TToken_string & row = calendario.row(i - 1);
|
|
|
|
|
COLOR back = NORMAL_BACK_COLOR;
|
|
|
|
|
COLOR fore = NORMAL_COLOR;
|
2010-11-16 00:17:10 +00:00
|
|
|
|
|
|
|
|
|
if (fulldays[i])
|
|
|
|
|
{
|
2010-11-16 16:17:20 +00:00
|
|
|
|
back = COLOR_DKBLUE; // coloro di blu le date con registrazioni
|
|
|
|
|
fore = COLOR_WHITE; // coloro di blu le date con registrazioni
|
2010-11-16 00:17:10 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (TDate(i, _mese, _anno).is_holiday())
|
2010-11-16 16:17:20 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
2010-11-16 00:17:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-22 01:06:45 +00:00
|
|
|
|
calendario.force_update();
|
2010-09-01 15:15:12 +00:00
|
|
|
|
}
|
2011-01-31 22:19:56 +00:00
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
void TRilevamento_cons_msk::update_column(short sid, bool full, int len)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = sfield(F_SHEET);
|
|
|
|
|
TMask_field& f = sf.sheet_mask().field(sid);
|
|
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
|
{
|
|
|
|
|
const TString prompt = f.prompt();
|
|
|
|
|
|
|
|
|
|
len = prompt.len();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int column = sf.cid2index(sid);
|
|
|
|
|
|
|
|
|
|
sf.enable_column(column, !full);
|
|
|
|
|
sf.set_column_width(column, !full ? (max(3 + f.size(), len + 1) * CHARX) : 0);
|
|
|
|
|
}
|
2010-09-01 15:15:12 +00:00
|
|
|
|
|
2010-11-16 16:17:20 +00:00
|
|
|
|
void TRilevamento_cons_msk::riempi_risoatt(char tipo)
|
2010-09-01 15:15:12 +00:00
|
|
|
|
{
|
2010-07-24 09:20:04 +00:00
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
2011-01-31 12:38:58 +00:00
|
|
|
|
TMask & sm = sheet.sheet_mask();
|
2010-09-22 07:30:40 +00:00
|
|
|
|
if (sheet.items() > 0 && sheet.dirty() && yesno_box("Vuoi salvare le modifiche"))
|
|
|
|
|
registra();
|
2010-07-24 09:20:04 +00:00
|
|
|
|
sheet.destroy();
|
|
|
|
|
|
2010-11-16 16:17:20 +00:00
|
|
|
|
update_day();
|
|
|
|
|
//leggo dalla maschera i campi chiave di ricerca
|
2010-09-22 01:06:45 +00:00
|
|
|
|
const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
2010-09-01 15:15:12 +00:00
|
|
|
|
const TString4 tpora = get(F_TPORA);
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString80 codcosto;
|
|
|
|
|
TString80 codcms;
|
|
|
|
|
TString16 codfase;
|
|
|
|
|
TString16 codice;
|
|
|
|
|
TString query;
|
|
|
|
|
TString select;
|
2010-09-02 15:23:23 +00:00
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
switch(risoatt[0])
|
2010-09-22 01:06:45 +00:00
|
|
|
|
{
|
|
|
|
|
case 'R': codice = get(F_CODRIS); break;
|
|
|
|
|
case 'A': codice = get(F_CODATT); break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
2011-01-31 02:47:08 +00:00
|
|
|
|
update_disp();
|
2010-09-22 01:06:45 +00:00
|
|
|
|
get_anal_fields(codcosto, codcms, codfase);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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(), 4);
|
2011-01-31 12:38:58 +00:00
|
|
|
|
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());
|
|
|
|
|
}
|
2010-09-01 15:15:12 +00:00
|
|
|
|
//preparo la query
|
2010-09-22 01:06:45 +00:00
|
|
|
|
|
2010-11-16 00:17:10 +00:00
|
|
|
|
query << "USE " << LF_RILORE << " KEY 2\n" ;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
if (risoatt.full())
|
2011-01-31 02:47:08 +00:00
|
|
|
|
{
|
2010-09-22 01:06:45 +00:00
|
|
|
|
select << "(" << RILORE_TIPORA << "==\"" << risoatt << "\")";
|
2011-01-31 02:47:08 +00:00
|
|
|
|
}
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString fromto = RILORE_TIPO;
|
|
|
|
|
|
2010-11-16 16:17:20 +00:00
|
|
|
|
fromto << "=\"" << tipo << "\"";
|
2010-11-16 00:17:10 +00:00
|
|
|
|
if (_anno > 0)
|
2010-09-22 01:06:45 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
fromto << " " << RILORE_ANNO << "=" << _anno << " ";
|
|
|
|
|
if (_mese > 0)
|
2010-09-22 01:06:45 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
fromto << RILORE_MESE << "=" << _mese << " ";
|
2010-11-16 16:17:20 +00:00
|
|
|
|
if (tipo == 'C')
|
2010-11-16 00:17:10 +00:00
|
|
|
|
fromto << RILORE_GIORNO << "=" << _giorno << " ";
|
2010-09-22 01:06:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
query << "FROM " << fromto << "\n"
|
|
|
|
|
<< "TO " << fromto;
|
2010-09-01 15:15:12 +00:00
|
|
|
|
|
|
|
|
|
TISAM_recordset def(query);
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
|
|
|
|
//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());
|
2010-09-01 15:15:12 +00:00
|
|
|
|
|
2010-07-24 09:20:04 +00:00
|
|
|
|
TToken_string& riga = sheet.row(-1);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
const char tipor = rilore.get(RILORE_TIPORA)[0];
|
2010-11-16 00:17:10 +00:00
|
|
|
|
TString16 cod = rilore.get(RILORE_CODICE);
|
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
riga.add(tipor, sheet.cid2index(S_RISOATT));
|
|
|
|
|
switch(tipor)
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
case 'R': riga.add(cod, sheet.cid2index(S_CODRIS)); break;
|
|
|
|
|
case 'A': riga.add(cod, sheet.cid2index(S_CODATT)); break;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
default : break;
|
|
|
|
|
}
|
2010-11-16 00:17:10 +00:00
|
|
|
|
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));
|
2011-01-31 02:47:08 +00:00
|
|
|
|
riga.add(rilore.get(RILORE_CODLIST), sheet.cid2index(S_CODLIST));
|
2010-11-16 00:17:10 +00:00
|
|
|
|
riga.add(rilore.get(RILORE_COSTO), sheet.cid2index(S_COSTO));
|
2011-01-19 11:48:29 +00:00
|
|
|
|
riga.add(rilore.get(RILORE_CUP), sheet.cid2index(S_CUP));
|
|
|
|
|
riga.add(rilore.get(RILORE_CIG), sheet.cid2index(S_CIG));
|
2011-01-31 02:47:08 +00:00
|
|
|
|
riga.add(tipo == 'D' ? 0 : rilore.get(RILORE_ID), sheet.cid2index(S_ID));
|
2010-11-16 00:17:10 +00:00
|
|
|
|
|
2010-09-21 14:36:08 +00:00
|
|
|
|
sheet.check_row(sheet.items() - 1);
|
2011-01-31 22:19:56 +00:00
|
|
|
|
sheet.select(sheet.items() - 1);
|
|
|
|
|
update_prev();
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
2010-09-01 15:15:12 +00:00
|
|
|
|
sheet.force_update();
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
void TRilevamento_cons_msk::update_disp()
|
|
|
|
|
{
|
2011-01-31 22:19:56 +00:00
|
|
|
|
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);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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);
|
2011-01-31 22:19:56 +00:00
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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())
|
|
|
|
|
{
|
2011-01-31 22:19:56 +00:00
|
|
|
|
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);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
else
|
2011-01-31 22:19:56 +00:00
|
|
|
|
{
|
|
|
|
|
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")
|
2011-01-31 02:47:08 +00:00
|
|
|
|
{
|
2011-01-31 22:19:56 +00:00
|
|
|
|
day.addmonth();
|
|
|
|
|
--day;
|
2011-01-31 02:47:08 +00:00
|
|
|
|
}
|
2011-01-31 22:19:56 +00:00
|
|
|
|
else
|
|
|
|
|
if (intervallo == "A")
|
|
|
|
|
{
|
|
|
|
|
day.addyear();
|
|
|
|
|
--day;
|
|
|
|
|
}
|
2011-01-31 02:47:08 +00:00
|
|
|
|
|
2011-01-31 22:19:56 +00:00
|
|
|
|
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(RILORE_QTAORE);
|
|
|
|
|
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 5\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;
|
|
|
|
|
}
|
2011-01-31 02:47:08 +00:00
|
|
|
|
|
2011-01-31 22:19:56 +00:00
|
|
|
|
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_int(RILORE_QTAORE);
|
|
|
|
|
row.add(oreprev.string(), sf.cid2index(S_OREPREV));
|
|
|
|
|
sf.force_update(r);
|
|
|
|
|
_oreprev.add(chiave, oreprev);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-31 02:47:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-24 09:20:04 +00:00
|
|
|
|
//RIEMPI_SHEET: metodo che riempie lo sheet in base ai campi chiave
|
|
|
|
|
//compilati sulla maschera
|
|
|
|
|
void TRilevamento_cons_msk::riempi_sheet()
|
|
|
|
|
{
|
2010-09-01 15:15:12 +00:00
|
|
|
|
//leggo dalla maschera i campi chiave di ricerca
|
2010-07-24 09:20:04 +00:00
|
|
|
|
const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
|
|
|
|
const TString4 tpora = get(F_TPORA);
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString80 codcosto;
|
|
|
|
|
TString80 codcms;
|
|
|
|
|
TString16 codfase;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
TString16 codice;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString query;
|
|
|
|
|
TString select;
|
|
|
|
|
|
2010-11-16 16:17:20 +00:00
|
|
|
|
update_day();
|
2010-09-22 01:06:45 +00:00
|
|
|
|
switch(get(F_RISOATT)[0])
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
2010-09-22 01:06:45 +00:00
|
|
|
|
case 'R': codice = get(F_CODRIS); break;
|
|
|
|
|
case 'A': codice = get(F_CODATT); break;
|
|
|
|
|
default: break;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
get_anal_fields(codcosto, codcms, codfase);
|
2010-09-21 14:36:08 +00:00
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
//preparo la query
|
2010-11-16 00:17:10 +00:00
|
|
|
|
query << "USE " << LF_RILORE << " KEY 2\n" ;
|
2010-09-21 14:36:08 +00:00
|
|
|
|
if (risoatt.full())
|
2010-09-22 01:06:45 +00:00
|
|
|
|
select << "(" << RILORE_TIPORA << "==\"" << risoatt << "\")";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
if (codice.full())
|
|
|
|
|
{
|
|
|
|
|
if (select.full()) select << "&&";
|
|
|
|
|
select << "(" << RILORE_CODICE << "==\"" << codice << "\")";
|
|
|
|
|
}
|
|
|
|
|
if (tpora.full())
|
|
|
|
|
{
|
|
|
|
|
if (select.full()) select << "&&";
|
2010-09-22 01:06:45 +00:00
|
|
|
|
select << "(" << RILORE_TPORA << "==\"" << tpora << "\")";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
}
|
|
|
|
|
if (codcosto.full())
|
|
|
|
|
{
|
|
|
|
|
if (select.full()) select << "&&";
|
2010-09-22 01:06:45 +00:00
|
|
|
|
select << "(" << RILORE_CODCOSTO << "==\"" << codcosto << "\")";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
}
|
|
|
|
|
if (codcms.full())
|
|
|
|
|
{
|
|
|
|
|
if (select.full()) select << "&&";
|
2010-09-22 01:06:45 +00:00
|
|
|
|
select << "(" << RILORE_CODCMS << "==\"" << codcms << "\")";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
}
|
|
|
|
|
if (codfase.full())
|
|
|
|
|
{
|
|
|
|
|
if (select.full()) select << "&&";
|
2010-09-22 01:06:45 +00:00
|
|
|
|
select << "(" << RILORE_CODFASE << "==\"" << codfase << "\")";
|
2010-09-21 14:36:08 +00:00
|
|
|
|
}
|
|
|
|
|
if (select.full())
|
|
|
|
|
query << "SELECT " << select << "\n";
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString fromto = RILORE_TIPO "=\"C\"";
|
|
|
|
|
|
2010-11-16 00:17:10 +00:00
|
|
|
|
if (_anno > 0)
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
fromto << " " << RILORE_ANNO << "=" << _anno << " ";
|
|
|
|
|
if (_mese > 0)
|
|
|
|
|
fromto << RILORE_MESE << "=" << _mese << " ";
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
query << "FROM " << fromto << "\n"
|
|
|
|
|
<< "TO " << fromto;
|
2010-11-16 00:17:10 +00:00
|
|
|
|
riempi_calendario(query);
|
|
|
|
|
riempi_risoatt();
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
//NUOVA_RIGA: metodo che aggiunge una riga allo sheet
|
|
|
|
|
//tenendo conto dei campi chiave compilati in testata
|
|
|
|
|
void TRilevamento_cons_msk::nuova_riga()
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
2010-09-02 15:23:23 +00:00
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2010-09-02 15:23:23 +00:00
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
|
|
|
|
TToken_string& row = sheet.row(r);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
row.add("X", sheet.cid2index(S_DEL));
|
2010-09-02 15:23:23 +00:00
|
|
|
|
}
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//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
|
2011-01-19 11:48:29 +00:00
|
|
|
|
|
2010-07-24 09:20:04 +00:00
|
|
|
|
void TRilevamento_cons_msk::registra()
|
|
|
|
|
{
|
2011-01-19 11:48:29 +00:00
|
|
|
|
TDoc_cache ca;
|
2010-09-02 15:23:23 +00:00
|
|
|
|
TSheet_field& calendario = sfield(F_CALENDARIO);
|
2010-07-24 09:20:04 +00:00
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
2010-09-21 14:36:08 +00:00
|
|
|
|
TRilevamento_ore rilroa;
|
|
|
|
|
const int mese = get_int(F_MESE);
|
|
|
|
|
const int anno = get_int(F_ANNO);
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TString80 codcosto;
|
|
|
|
|
TString80 codcms;
|
|
|
|
|
TString16 codfase;
|
2010-11-16 00:17:10 +00:00
|
|
|
|
int err = NOERR;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
|
|
|
|
TToken_string& riga = *(TToken_string*)row;
|
2011-01-31 02:47:08 +00:00
|
|
|
|
const TString4 del = riga.get(sheet.cid2index(S_DEL));
|
2010-09-02 15:23:23 +00:00
|
|
|
|
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 int qtaore = riga.get_int(sheet.cid2index(S_QTAORE));
|
2010-11-16 00:17:10 +00:00
|
|
|
|
const long id = riga.get_long(sheet.cid2index(S_ID));
|
2011-01-31 02:47:08 +00:00
|
|
|
|
const TString8 codlist = riga.get(sheet.cid2index(S_CODLIST));
|
2010-09-21 14:36:08 +00:00
|
|
|
|
const real costo(riga.get(sheet.cid2index(S_COSTO)));
|
2011-01-19 11:48:29 +00:00
|
|
|
|
const TString16 cup(riga.get(sheet.cid2index(S_CUP)));
|
|
|
|
|
const TString16 cig(riga.get(sheet.cid2index(S_CIG)));
|
2010-07-24 09:20:04 +00:00
|
|
|
|
|
2010-09-22 01:06:45 +00:00
|
|
|
|
get_row_anal_fields(riga, codcosto, codcms, codfase);
|
2011-01-19 11:48:29 +00:00
|
|
|
|
const bool found = rilroa.read('C', id) == NOERR;
|
2011-01-31 02:47:08 +00:00
|
|
|
|
if (del == "X")
|
2011-01-19 11:48:29 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-24 09:20:04 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
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);
|
2011-01-31 02:47:08 +00:00
|
|
|
|
rilroa.put(RILORE_CODLIST, codlist);
|
2010-11-16 00:17:10 +00:00
|
|
|
|
rilroa.put(RILORE_COSTO, costo);
|
2011-01-19 11:48:29 +00:00
|
|
|
|
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_ANNO, 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_ANNO);
|
|
|
|
|
rilroa.zero(RILORE_CODNUM);
|
|
|
|
|
rilroa.zero(RILORE_NDOC);
|
|
|
|
|
rilroa.zero(RILORE_IDRIGA);
|
|
|
|
|
}
|
2010-11-16 00:17:10 +00:00
|
|
|
|
err = rilroa.rewrite_write();
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
2010-11-16 00:17:10 +00:00
|
|
|
|
if (err != NOERR)
|
|
|
|
|
break;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
2010-11-16 00:17:10 +00:00
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
2011-01-19 11:48:29 +00:00
|
|
|
|
ca.destroy();
|
2010-11-16 00:17:10 +00:00
|
|
|
|
sheet.destroy();
|
|
|
|
|
riempi_sheet();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error_box(FR("Errore %d in scrittura"), err);
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 00:17:10 +00:00
|
|
|
|
void TRilevamento_cons_msk::update_day()
|
2010-09-01 15:15:12 +00:00
|
|
|
|
{
|
2010-11-16 00:17:10 +00:00
|
|
|
|
const int row = sfield(F_CALENDARIO).selected();
|
2010-12-05 10:28:20 +00:00
|
|
|
|
const TString4 dett = get(F_INTERVALLO);
|
2010-11-16 00:17:10 +00:00
|
|
|
|
|
2010-12-05 10:28:20 +00:00
|
|
|
|
if (dett == "G")
|
2010-11-16 00:17:10 +00:00
|
|
|
|
{
|
|
|
|
|
_anno = get_int(F_ANNO);
|
|
|
|
|
_mese = get_int(F_MESE);
|
|
|
|
|
_giorno = row +1;
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-12-05 10:28:20 +00:00
|
|
|
|
if (dett == "M")
|
2010-11-16 00:17:10 +00:00
|
|
|
|
{
|
|
|
|
|
_anno = get_int(F_ANNO);
|
|
|
|
|
_mese = row + 1;
|
|
|
|
|
_giorno = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-12-05 10:28:20 +00:00
|
|
|
|
if (dett == "A")
|
2010-11-16 00:17:10 +00:00
|
|
|
|
{
|
|
|
|
|
_anno = _es_array[row];
|
|
|
|
|
_mese = 1;
|
|
|
|
|
_giorno = 1;
|
|
|
|
|
}
|
2010-09-01 15:15:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-24 09:20:04 +00:00
|
|
|
|
//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)
|
|
|
|
|
{
|
2011-01-31 12:38:58 +00:00
|
|
|
|
if ((f.dlg() == _cdc_lid ||
|
|
|
|
|
f.dlg() == _cms_lid ||
|
|
|
|
|
f.dlg() == _fase_lid) && e == fe_modify)
|
|
|
|
|
riempi_sheet();
|
2011-01-31 02:47:08 +00:00
|
|
|
|
if (f.dlg() == _scms_lid)
|
2011-01-19 11:48:29 +00:00
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2011-01-31 02:47:08 +00:00
|
|
|
|
const TRectype & commesse = cache().get(LF_COMMESSE, codcms);
|
2011-01-19 11:48:29 +00:00
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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);
|
2011-01-19 11:48:29 +00:00
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
f.mask().set(S_CUP, cfcms.get(CFCMS_CUP), 3);
|
|
|
|
|
f.mask().set(S_CIG, cfcms.get(CFCMS_CIG), 3);
|
|
|
|
|
}
|
2011-01-19 11:48:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-01 15:15:12 +00:00
|
|
|
|
switch (f.dlg())
|
2010-07-24 09:20:04 +00:00
|
|
|
|
{
|
2010-09-01 15:15:12 +00:00
|
|
|
|
case DLG_DEFAULT:
|
|
|
|
|
if(e == fe_button)
|
|
|
|
|
carica_default();
|
2010-09-02 15:23:23 +00:00
|
|
|
|
break;
|
|
|
|
|
case DLG_CERCA:
|
|
|
|
|
if(e == fe_button)
|
2010-09-01 15:15:12 +00:00
|
|
|
|
riempi_sheet();
|
2010-09-02 15:23:23 +00:00
|
|
|
|
break;
|
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
|
if(e == fe_button)
|
|
|
|
|
registra();
|
2010-09-22 01:06:45 +00:00
|
|
|
|
case F_ANNO:
|
|
|
|
|
case F_MESE:
|
|
|
|
|
case F_RISOATT:
|
|
|
|
|
case F_CODRIS:
|
|
|
|
|
case F_CODATT:
|
|
|
|
|
case F_TPORA:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
riempi_sheet();
|
2010-11-16 00:17:10 +00:00
|
|
|
|
break;
|
|
|
|
|
case F_CALENDARIO:
|
|
|
|
|
if (e == se_enter)
|
|
|
|
|
riempi_risoatt();
|
2010-09-22 01:06:45 +00:00
|
|
|
|
break;
|
2011-01-31 02:47:08 +00:00
|
|
|
|
case F_SHEET:
|
|
|
|
|
if (e == se_notify_add)
|
|
|
|
|
nuova_riga();
|
|
|
|
|
else
|
|
|
|
|
if (e == se_enter)
|
2011-01-31 22:19:56 +00:00
|
|
|
|
{
|
|
|
|
|
update_prev();
|
2011-01-31 02:47:08 +00:00
|
|
|
|
update_disp();
|
2011-01-31 22:19:56 +00:00
|
|
|
|
}
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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
|
2010-12-05 10:28:20 +00:00
|
|
|
|
{
|
2011-01-31 02:47:08 +00:00
|
|
|
|
if (dett == "M")
|
2010-12-05 10:28:20 +00:00
|
|
|
|
{
|
|
|
|
|
reset(F_MESE);
|
|
|
|
|
disable(F_MESE);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-31 02:47:08 +00:00
|
|
|
|
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;
|
2010-09-02 15:23:23 +00:00
|
|
|
|
case S_RISOATT:
|
|
|
|
|
case S_CODRIS:
|
|
|
|
|
case S_CODATT:
|
2011-01-31 02:47:08 +00:00
|
|
|
|
case S_CODLIST:
|
2010-09-02 15:23:23 +00:00
|
|
|
|
case S_TPORA:
|
|
|
|
|
if(e == fe_modify)
|
|
|
|
|
{
|
2010-09-22 01:06:45 +00:00
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
|
2011-01-31 02:47:08 +00:00
|
|
|
|
f.mask().set(S_COSTO, proponi_costo(sheet.row(sheet.selected())).string());
|
2010-09-02 15:23:23 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
default: break;
|
2010-09-01 15:15:12 +00:00
|
|
|
|
}
|
2010-07-24 09:20:04 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRilevamento_cons_msk::TRilevamento_cons_msk()
|
|
|
|
|
: TAutomask("ci2200a")
|
|
|
|
|
{
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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();
|
2010-12-05 10:28:20 +00:00
|
|
|
|
int y = 4;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-22 07:15:44 +00:00
|
|
|
|
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--)
|
2010-09-22 01:06:45 +00:00
|
|
|
|
{
|
|
|
|
|
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.enable_column(id);
|
2010-09-22 07:15:44 +00:00
|
|
|
|
set_insheet_universal_handler(F_SHEET, id);
|
|
|
|
|
set_insheet_universal_handler(F_SHEET, id + 50);
|
|
|
|
|
}
|
2010-09-22 01:06:45 +00:00
|
|
|
|
else
|
|
|
|
|
s.delete_column(id);
|
|
|
|
|
}
|
2010-07-24 09:20:04 +00:00
|
|
|
|
_qtaore = 0;
|
2010-12-05 10:28:20 +00:00
|
|
|
|
const TString4 dett = ini_get_string(CONFIG_DITTA, "ci", "DETTCONS");
|
2010-11-16 00:17:10 +00:00
|
|
|
|
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;
|
2010-12-05 10:28:20 +00:00
|
|
|
|
if (dett == "A")
|
|
|
|
|
disable(F_INTERVALLO);
|
2010-11-16 00:17:10 +00:00
|
|
|
|
else
|
2010-11-16 16:17:20 +00:00
|
|
|
|
{
|
2010-12-05 10:28:20 +00:00
|
|
|
|
if (dett == "M")
|
2010-11-16 00:17:10 +00:00
|
|
|
|
{
|
2010-12-05 10:28:20 +00:00
|
|
|
|
TList_field & f = lfield(F_INTERVALLO);
|
|
|
|
|
|
|
|
|
|
f.delete_item("G");
|
2010-11-16 00:17:10 +00:00
|
|
|
|
}
|
2010-11-16 16:17:20 +00:00
|
|
|
|
set(F_ANNO, TDate(TODAY).year());
|
|
|
|
|
}
|
2010-12-05 10:28:20 +00:00
|
|
|
|
set(F_INTERVALLO, dett);
|
2011-01-19 11:48:29 +00:00
|
|
|
|
_numcn = ini_get_string(CONFIG_DITTA, "ci", "CODNUMCN");
|
|
|
|
|
_tipocn = ini_get_string(CONFIG_DITTA, "ci", "TIPODOCCN");
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
//// 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()
|
|
|
|
|
{
|
2011-01-19 11:48:29 +00:00
|
|
|
|
open_files(LF_DOC, LF_RIGHEDOC, LF_RILORE, 0);
|
2010-07-24 09:20:04 +00:00
|
|
|
|
TRilevamento_cons_msk msk;
|
2010-09-22 01:06:45 +00:00
|
|
|
|
while (msk.run() != K_QUIT) ;
|
2010-07-24 09:20:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ci2200(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
TRilevamento_cons_app a;
|
|
|
|
|
a.run (argc, argv, TR("Rilevamento Ore Consuntivo"));
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|