0352ef0f2e
Files correlati : ci0.exe ci2.exe ci0200a.msk Ricompilazione Demo : [ ] Commento : Riportate correzioni di Bonazzi in rilevazione ore (cliente CRPA) git-svn-id: svn://10.65.10.50/branches/R_10_00@22554 c028cbd2-c16b-5b4b-a496-9718f37d4682
1562 lines
38 KiB
C++
Executable File
1562 lines
38 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <defmask.h>
|
||
#include <modaut.h>
|
||
#include <recset.h>
|
||
#include <sheet.h>
|
||
#include <urldefid.h>
|
||
#include <tree.h>
|
||
#include <treectrl.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"
|
||
|
||
//////////////////////////////////////////////
|
||
// Albero
|
||
//////////////////////////////////////////////
|
||
class TRil_tree : public TBidirectional_tree
|
||
{
|
||
typedef enum { _normal, _holiday, _full } _type;
|
||
TString_array _content;
|
||
_type _t[64];
|
||
int _curr_node;
|
||
TString4 _dett;
|
||
int _month;
|
||
TEsercizi_contabili _es;
|
||
|
||
|
||
protected:
|
||
|
||
public:
|
||
void highlight(const TString & query, int mese, int anno);
|
||
bool update_content(const TString & query, const TString & dett, int month, int year);
|
||
virtual bool goto_root();
|
||
virtual bool goto_firstson() { return false; }
|
||
virtual bool goto_rbrother();
|
||
virtual bool goto_node(const TString &id);
|
||
virtual bool could_have_son() const { return false; }
|
||
virtual bool has_son() const { return false; }
|
||
virtual bool has_rbrother() const;
|
||
virtual TObject* curr_node() const;
|
||
const int pos() const { return _curr_node;}
|
||
const TString &id() const { return *(TString *)curr_node(); }
|
||
const TString &id(int pos) const { return _content.row(pos); }
|
||
virtual void node2id(const TObject* obj, TString& id) const;
|
||
|
||
virtual bool has_root() const;
|
||
virtual bool has_father() const { return false; }
|
||
virtual bool has_lbrother() const;
|
||
virtual bool goto_father() { return false; }
|
||
virtual bool goto_lbrother();
|
||
virtual bool get_description(TString& desc) const { desc = _content.row(_curr_node); return true;}
|
||
virtual TImage* image(bool selected) const;
|
||
|
||
public:
|
||
TRil_tree() : _curr_node(0), _dett("") {}
|
||
};
|
||
|
||
|
||
bool TRil_tree::has_root() const
|
||
{
|
||
return _content.items() > 0L;
|
||
}
|
||
|
||
bool TRil_tree::goto_root()
|
||
{
|
||
bool ok = has_root();
|
||
if (ok)
|
||
_curr_node = 0L;
|
||
return ok;
|
||
}
|
||
|
||
bool TRil_tree::has_rbrother() const
|
||
{
|
||
return _curr_node < _content.items() -1;
|
||
}
|
||
|
||
bool TRil_tree::goto_rbrother()
|
||
{
|
||
bool ok = has_rbrother();
|
||
if (ok)
|
||
_curr_node++;
|
||
return ok;
|
||
}
|
||
|
||
bool TRil_tree::has_lbrother() const
|
||
{
|
||
return _curr_node > 0L;
|
||
}
|
||
|
||
bool TRil_tree::goto_lbrother()
|
||
{
|
||
bool ok = has_lbrother();
|
||
if (ok)
|
||
_curr_node--;
|
||
return ok;
|
||
}
|
||
|
||
bool TRil_tree::goto_node(const TString &id)
|
||
{
|
||
const long pos = atol(id);
|
||
const bool ok = pos >= 0 && pos < _content.items();
|
||
if (ok)
|
||
_curr_node = pos;
|
||
return ok;
|
||
}
|
||
|
||
TObject* TRil_tree::curr_node() const
|
||
{
|
||
bool ok = has_root();
|
||
if (ok)
|
||
return (TObject*)&_content[_curr_node];
|
||
return (TObject*) &EMPTY_STRING;
|
||
|
||
}
|
||
void TRil_tree::highlight(const TString & query, int mese, int anno)
|
||
{
|
||
if (_dett == "A")
|
||
{
|
||
TBit_array full_years;
|
||
TISAM_recordset recset(query);
|
||
|
||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||
{
|
||
const TDate & d = recset.get(RILORE_DADATA).as_date();
|
||
const int es = esercizi().date2esc(d);
|
||
|
||
full_years.set(es);
|
||
}
|
||
for (int i = 0; i < _content.items(); i++)
|
||
_t[i] = full_years[atoi(id(i))] ? _full : _normal;
|
||
}
|
||
else
|
||
if (_dett == "M")
|
||
{
|
||
TBit_array full_months;
|
||
TISAM_recordset recset(query);
|
||
|
||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||
{
|
||
const TDate & d = recset.get(RILORE_DADATA).as_date();
|
||
const int mese = d.month();
|
||
|
||
full_months.set(mese);
|
||
}
|
||
|
||
for (int i = 0; i <= 11; i++)
|
||
_t[i] = full_months[i + 1] ? _full : _normal; }
|
||
else
|
||
if (_dett == "G")
|
||
{
|
||
TDate day(1, mese, anno);
|
||
TDate last(day); last.set_end_month();
|
||
TBit_array full_days;
|
||
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 TDate & d = recset.get(RILORE_DADATA).as_date();
|
||
const int day = d.day();
|
||
|
||
full_days.set(day);
|
||
}
|
||
|
||
for(; day <= last; ++day)
|
||
{
|
||
const int i = day.day();
|
||
if (full_days[i])
|
||
_t[i - 1] = _full;
|
||
else
|
||
_t[i - 1] = (day.is_holiday() || day.wday() == 6) ? _holiday : _normal;
|
||
}
|
||
}
|
||
}
|
||
|
||
bool TRil_tree::update_content(const TString & query, const TString & dett, int month, int year)
|
||
{
|
||
bool updated = false;
|
||
|
||
if (dett == "G")
|
||
{
|
||
if (_dett != dett || _month != month)
|
||
{
|
||
_dett = dett;
|
||
_month = month;
|
||
_content.destroy();
|
||
TDate day(1, month, year);
|
||
TDate last(day); last.set_end_month();
|
||
|
||
for (; day <= last; ++day)
|
||
{
|
||
const int i = day.day();
|
||
_content.add(format("%d", i));
|
||
_t[i - 1] = (day.is_holiday() || day.wday() == 6) ? _holiday : _normal;
|
||
}
|
||
updated = true;
|
||
}
|
||
}
|
||
else
|
||
if (_dett != dett)
|
||
{
|
||
_dett = dett;
|
||
_month = month;
|
||
_content.destroy();
|
||
if (_dett == "M")
|
||
{
|
||
for (int month = 1; month < 13; month++)
|
||
{
|
||
_content.add(itom(month));
|
||
_t[month] = _normal;
|
||
}
|
||
}
|
||
else
|
||
if (_dett == "A")
|
||
{
|
||
int i = 0;
|
||
for (int codes = _es.first(); codes != 0; codes = _es.next(codes))
|
||
{
|
||
_content.add(format("%d", codes));
|
||
_t[i++] = _normal;
|
||
}
|
||
}
|
||
updated = true;
|
||
}
|
||
if (updated)
|
||
goto_root();
|
||
highlight(query, month, year);
|
||
return updated;
|
||
}
|
||
|
||
void TRil_tree::node2id(const TObject* obj, TString& id) const
|
||
{
|
||
FOR_EACH_ARRAY_ITEM(_content, r, o)
|
||
if (o == obj)
|
||
{
|
||
id.cut(0) << r;
|
||
break;
|
||
}
|
||
}
|
||
|
||
TImage* TRil_tree::image(bool selected) const
|
||
{
|
||
switch (_t[_curr_node])
|
||
{
|
||
case _normal:
|
||
return get_res_icon(ICO_DAY_WORK);
|
||
break;
|
||
case _holiday:
|
||
return get_res_icon(ICO_DAY_HOLY);
|
||
break;
|
||
case _full:
|
||
return get_res_icon(ICO_DAY_FULL);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return get_res_icon(10201);
|
||
}
|
||
|
||
|
||
////////////////////////////////////////////
|
||
//// 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 _curr_anno;
|
||
int _curr_mese;
|
||
int _curr_giorno;
|
||
TString _numcn;
|
||
TString _tipocn;
|
||
TToken_string _last_key;
|
||
TAssoc_array _oreprev;
|
||
|
||
protected:
|
||
const TString & proponi_costo(const TMask & mask);
|
||
const TString & 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);
|
||
const char * content_query();
|
||
void update_tree();
|
||
void update_disp();
|
||
void update_prev(int r = -1);
|
||
void update_column(short sid, const bool full);
|
||
void riempi_nuova_riga(int r);
|
||
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:
|
||
void riempi_sheet(char tipo = 'C');
|
||
|
||
TRilevamento_cons_msk();
|
||
};
|
||
|
||
const TString & TRilevamento_cons_msk::proponi_costo(const TMask& msk)
|
||
{
|
||
const TString8 codlist = msk.get(S_CODLIST);
|
||
const char tipo = msk.get(S_RISOATT)[0];
|
||
TString80 codice;
|
||
switch(tipo)
|
||
{
|
||
case 'R': codice = msk.get(S_CODRIS); break;
|
||
case 'A': codice = msk.get(S_CODATT); break;
|
||
default : break;
|
||
}
|
||
const TDate dal(1, _mese, _anno);
|
||
const TString4 tpora = msk.get(S_TPORA);
|
||
TRisoatt_key chiave(codlist, tipo, codice, dal, tpora);
|
||
const TRectype & rec = cache().get("&ROA", chiave);
|
||
|
||
if (rec.empty())
|
||
{
|
||
if (chiave.cod().full() && chiave.tpora().full())
|
||
{
|
||
TModule_table tab("ROA");
|
||
|
||
tab.put("CODTAB", chiave);
|
||
const int err = tab.read();
|
||
if (err != _isemptyfile)
|
||
{
|
||
chiave.overwrite("????????", 21, 8);
|
||
if (err != _iseof)
|
||
tab.prev();
|
||
if (tab.get("CODTAB").match(chiave))
|
||
return tab.get("R1");
|
||
}
|
||
}
|
||
}
|
||
else
|
||
return rec.get("R1");
|
||
return EMPTY_STRING;
|
||
}
|
||
|
||
const TString & TRilevamento_cons_msk::proponi_costo(TToken_string& riga)
|
||
{
|
||
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));
|
||
TRisoatt_key chiave(codlist, tipo, codice, dal, tpora);
|
||
const TRectype & rec = cache().get("&ROA", chiave);
|
||
|
||
if (rec.empty())
|
||
{
|
||
if (chiave.cod().full() && chiave.tpora().full())
|
||
{
|
||
TModule_table tab("ROA");
|
||
|
||
tab.put("CODTAB", chiave);
|
||
const int err = tab.read();
|
||
if (err != _isemptyfile)
|
||
{
|
||
chiave.overwrite("????????", 21, 8);
|
||
if (err != _iseof)
|
||
tab.prev();
|
||
if (tab.get("CODTAB").match(chiave))
|
||
return tab.get("R1");
|
||
}
|
||
}
|
||
}
|
||
else
|
||
return rec.get("R1");
|
||
return EMPTY_STRING;
|
||
}
|
||
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
//RIEMPI_CALENDARIO: coloro le celle dello sheet calendario secondo le festivit<69> e i giorni occupati
|
||
void TRilevamento_cons_msk::update_column(short sid, bool full)
|
||
{
|
||
TSheet_field& sf = sfield(F_SHEET);
|
||
if (full)
|
||
sf.set_column_width(sid, 0);
|
||
}
|
||
|
||
void TRilevamento_cons_msk::riempi_sheet(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();
|
||
|
||
//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;
|
||
}
|
||
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";
|
||
|
||
const TString & dett = get(F_INTERVALLO);
|
||
TString from;
|
||
from << RILORE_TIPO << "=\"" << tipo << "\"";
|
||
TString to(from);
|
||
TDate da(botime);
|
||
TDate a(eotime);
|
||
|
||
if (_anno > 0)
|
||
{
|
||
da.set_day(1);
|
||
da.set_month(1);
|
||
da.set_year(_anno);
|
||
a.set_year(_anno);
|
||
if (dett != "A")
|
||
{
|
||
da.set_month(_mese);
|
||
a.set_month(_mese);
|
||
if (dett != "M" && tipo == 'C')
|
||
{
|
||
da.set_day(_giorno);
|
||
a.set_day(_giorno);
|
||
}
|
||
else
|
||
a.set_end_month();
|
||
}
|
||
}
|
||
from << " " << RILORE_DADATA << "=" << da.string() << " ";
|
||
to << " " << RILORE_DADATA << "=" << a.string() << " ";
|
||
|
||
query << "FROM " << from << "\n"
|
||
<< "TO " << to;
|
||
|
||
TISAM_recordset def(query);
|
||
|
||
_curr_giorno = _giorno;
|
||
_curr_mese = _mese;
|
||
_curr_anno = _anno;
|
||
//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));
|
||
riga.add(rilore.get(RILORE_RIMBORSO), sheet.cid2index(S_RIMBORSO));
|
||
|
||
const int r = sheet.items() - 1;
|
||
|
||
sheet.check_row(r);
|
||
// sheet.update_mask(r);
|
||
update_prev(r);
|
||
// sheet.update_row(r);
|
||
}
|
||
if (sheet.items() > 0)
|
||
{
|
||
sheet.select(0);
|
||
update_disp();
|
||
update_prev();
|
||
}
|
||
sheet.force_update();
|
||
}
|
||
|
||
void TRilevamento_cons_msk::update_tree()
|
||
{
|
||
const TString & dett = get(F_INTERVALLO);
|
||
|
||
if (dett == "G")
|
||
{
|
||
_anno = get_int(F_ANNO);
|
||
_mese = get_int(F_MESE);
|
||
_giorno = 1;
|
||
}
|
||
else
|
||
if (dett == "M")
|
||
{
|
||
_anno = get_int(F_ANNO);
|
||
_mese = 1;
|
||
_giorno = 1;
|
||
}
|
||
else
|
||
if (dett == "A")
|
||
{
|
||
_anno = TDate(TODAY).year();
|
||
_mese = 1;
|
||
_giorno = 1;
|
||
}
|
||
TTree_field & cal = tfield(F_CALENDARIO);
|
||
TRil_tree * tree = (TRil_tree *) cal.tree();
|
||
|
||
tree->update_content(content_query(), get(F_INTERVALLO), _mese, _anno);
|
||
cal.force_update();
|
||
cal.tree()->goto_root();
|
||
}
|
||
|
||
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));
|
||
}
|
||
}
|
||
|
||
TDate day(_giorno, _mese, _anno);
|
||
TString chiave;
|
||
|
||
chiave.cut(0) << risoatt << codice.rpad(field(F_CODRIS).size()) << day.string(ANSI) << tpora;
|
||
real oredisp;
|
||
if (codice.full())
|
||
{
|
||
TString query;
|
||
|
||
query << "USE &DRA SELECT RIGHT(CODTAB,2)==\"" << tpora << "\"\n"
|
||
<< "FROM CODTAB=\"" << chiave << "\"\n" ;
|
||
|
||
TString tochiave(risoatt);
|
||
const TString4 intervallo = get(F_INTERVALLO);
|
||
|
||
if (intervallo == "M")
|
||
{
|
||
day.addmonth();
|
||
--day;
|
||
}
|
||
else
|
||
if (intervallo == "A")
|
||
{
|
||
day.addyear();
|
||
--day;
|
||
}
|
||
|
||
tochiave << codice << day.string(ANSI) << tpora;
|
||
query << "TO CODTAB=\"" << tochiave << "\"\n";
|
||
|
||
TISAM_recordset def(query);
|
||
|
||
for(bool ok = def.move_first(); ok; ok = def.move_next())
|
||
oredisp += def.cursor()->curr().get_real("R1");
|
||
}
|
||
set(F_OREDIS, oredisp);
|
||
|
||
real orecons;
|
||
codice.trim();
|
||
|
||
for (int r = 0; r < sf.items(); r++)
|
||
{
|
||
TToken_string & row = sf.row(r);
|
||
|
||
if (risoatt == row.get(sf.cid2index(S_RISOATT)))
|
||
if (codice == row.get(sf.cid2index(S_CODRIS)))
|
||
orecons += real(row.get(sf.cid2index(S_QTAORE)));
|
||
}
|
||
if (orecons > get_real(F_OREDIS))
|
||
field(F_ORECONS).set_prompt("$[r]Cons. ");
|
||
else
|
||
field(F_ORECONS).set_prompt("Cons. ");
|
||
set(F_ORECONS, orecons);
|
||
}
|
||
|
||
void TRilevamento_cons_msk::update_prev(int r)
|
||
{
|
||
TSheet_field & sf = sfield(F_SHEET);
|
||
|
||
if (r < 0)
|
||
r = sf.selected();
|
||
|
||
if (r >= 0 && r < sf.items())
|
||
{
|
||
TToken_string & row = sf.row(r);
|
||
//leggo dalla maschera i campi chiave di ricerca
|
||
TString4 risoatt = row.get(sf.cid2index(S_RISOATT));
|
||
TString16 codice;
|
||
TString codcosto;
|
||
TString codcms;
|
||
TString codfase;
|
||
|
||
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));
|
||
get_row_anal_fields(row, codcosto, codcms, codfase);
|
||
if (codice.full() && (codcosto.full() || codcms.full() || codfase.full()))
|
||
{
|
||
TString4 tpora = row.get(sf.cid2index(S_TPORA));
|
||
TToken_string chiave;
|
||
|
||
chiave.add(_anno);
|
||
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 3";
|
||
query << "\nFROM " << RILORE_TIPO "=\"P\" "
|
||
<< RILORE_TIPORA << "=" << risoatt << " "
|
||
<< RILORE_CODICE << "=" << codice << " "
|
||
<< RILORE_TPORA << "=" << tpora << " ";
|
||
query << RILORE_CODCOSTO << "=" << codcosto << " ";
|
||
query << RILORE_CODCMS << "=" << codcms << " ";
|
||
query << RILORE_CODFASE << "=" << codfase ;
|
||
query << "\n";
|
||
|
||
query << "TO " << RILORE_TIPO "=\"P\" "
|
||
<< RILORE_TIPORA << "=" << risoatt << " "
|
||
<< RILORE_CODICE << "=" << codice << " "
|
||
<< RILORE_TPORA << "=" << tpora << " ";
|
||
query << RILORE_CODCOSTO << "=" << codcosto << " ";
|
||
query << RILORE_CODCMS << "=" << codcms << " ";
|
||
query << RILORE_CODFASE << "=" << codfase ;
|
||
query << "\n";
|
||
|
||
const TString & dett = get(F_INTERVALLO);
|
||
|
||
TDate inizio(1, 1, _anno);
|
||
TDate fine(31, 12, _anno);
|
||
if (dett == "G")
|
||
{
|
||
inizio.set_month(_mese);
|
||
fine.set_month(_mese);
|
||
fine.set_end_month();
|
||
}
|
||
TISAM_recordset def(query);
|
||
real oreprev;
|
||
|
||
for(bool ok = def.move_first(); ok; ok = def.move_next())
|
||
{
|
||
TDate da(def.get(RILORE_DADATA).as_date());
|
||
TDate a(def.get(RILORE_ADATA).as_date());
|
||
|
||
if (a >= inizio && da <= fine)
|
||
{
|
||
real ore = def.get(RILORE_QTAORE).as_real();
|
||
|
||
if (da > inizio)
|
||
inizio = da;
|
||
if (a < fine)
|
||
fine = a;
|
||
ore = ore * (fine - inizio) / (a - da);
|
||
oreprev += ore;
|
||
}
|
||
}
|
||
row.add(oreprev.string(), sf.cid2index(S_OREPREV));
|
||
sf.force_update(r);
|
||
_oreprev.add(chiave, oreprev);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
const char * TRilevamento_cons_msk::content_query()
|
||
{
|
||
//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 select;
|
||
TString & query = get_tmp_string(256);
|
||
|
||
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";
|
||
|
||
const TString & dett = get(F_INTERVALLO);
|
||
TString from = RILORE_TIPO "=\"C\"";
|
||
TString to(from);
|
||
TDate da(botime);
|
||
TDate a(eotime);
|
||
|
||
if (dett != "A")
|
||
{
|
||
da.set_day(1);
|
||
da.set_month(1);
|
||
da.set_year(_anno);
|
||
a.set_year(_anno);
|
||
if (dett != "M")
|
||
{
|
||
da.set_month(_mese);
|
||
a.set_month(_mese);
|
||
}
|
||
a.set_end_month();
|
||
}
|
||
from << " " << RILORE_DADATA << "=" << da.string() << " ";
|
||
to << " " << RILORE_DADATA << "=" << a.string() << " ";
|
||
|
||
query << "FROM " << from << "\n"
|
||
<< "TO " << to;
|
||
return query;
|
||
}
|
||
|
||
//NUOVA_RIGA: metodo che aggiunge una riga allo sheet
|
||
//tenendo conto dei campi chiave compilati in testata
|
||
void TRilevamento_cons_msk::riempi_nuova_riga(int r)
|
||
{
|
||
TSheet_field& sheet = sfield(F_SHEET);
|
||
TToken_string & riga = sheet.row(r);
|
||
TMask& msk = sheet.sheet_mask();
|
||
|
||
|
||
//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);
|
||
sheet.select(r);
|
||
sheet.update_mask(r);
|
||
sheet.check_row(r);
|
||
riga.add(proponi_costo(riga), sheet.cid2index(S_COSTO));
|
||
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& sheet = sfield(F_SHEET);
|
||
TRilevamento_ore rilroa;
|
||
TString80 codcosto;
|
||
TString80 codcms;
|
||
TString16 codfase;
|
||
int err = NOERR;
|
||
const TString4 dett = get(F_INTERVALLO);
|
||
|
||
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));
|
||
const bool rimborso = riga.get_char(sheet.cid2index(S_RIMBORSO)) == 'X';
|
||
|
||
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);
|
||
TDate da(_curr_giorno, _curr_mese, _curr_anno);
|
||
TDate a(_curr_giorno, _curr_mese, _curr_anno);
|
||
|
||
if (dett == "A")
|
||
{
|
||
da.set_day(1);
|
||
a.set_month(1);
|
||
da.set_day(31);
|
||
a.set_month(12);
|
||
}
|
||
else
|
||
if (dett =="M")
|
||
{
|
||
da.set_day(1);
|
||
a.set_end_month();
|
||
}
|
||
|
||
if (id == 0L || dett == "G")
|
||
{
|
||
rilroa.put(RILORE_DADATA, da);
|
||
rilroa.put(RILORE_ADATA, a);
|
||
}
|
||
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);
|
||
rilroa.put(RILORE_RIMBORSO, rimborso);
|
||
|
||
if (_numcn.full() && _tipocn.full())
|
||
{
|
||
TString8 codnum = rilroa.get(RILORE_CODNUM);
|
||
TDoc_key oldkey(rilroa.get_date(RILORE_DADATA).year(), codnum, rilroa.get_long(RILORE_NDOC), rilroa.get_char(RILORE_PROVV));
|
||
|
||
const long ndoc = date2ndoc(da);
|
||
|
||
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();
|
||
((TRil_tree * )tfield(F_CALENDARIO).tree())->highlight(content_query(), _mese, _anno);
|
||
riempi_sheet();
|
||
tfield(F_CALENDARIO).force_update();
|
||
}
|
||
else
|
||
error_box(FR("Errore %d in scrittura"), err);
|
||
}
|
||
|
||
//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)
|
||
{
|
||
const short dlg = f.dlg();
|
||
|
||
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);
|
||
TMask & m = f.mask();
|
||
|
||
m.set(S_CMSH, codcms);
|
||
|
||
const TRectype & commesse = cache().get(LF_COMMESSE, codcms);
|
||
|
||
if (m.get(S_CODLIST).blank())
|
||
m.set(S_CODLIST, commesse.get(COMMESSE_LISRILCN), 3);
|
||
if (e == fe_modify)
|
||
{
|
||
if (codcms.full())
|
||
{
|
||
TDate inizio;
|
||
TDate fine;
|
||
const TDate data(_giorno, _mese, _anno);
|
||
|
||
ca_durata_commessa(commesse, inizio, fine);
|
||
if (data < inizio)
|
||
return error_box(FR("Commessa %s non iniziata"), (const char *) codcms);
|
||
if (data > fine)
|
||
return error_box(FR("Commessa %s terminata"), (const char *) codcms);
|
||
}
|
||
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);
|
||
|
||
m.set(S_CUP, cfcms.get(CFCMS_CUP), 3);
|
||
m.set(S_CIG, cfcms.get(CFCMS_CIG), 3);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
switch (f.dlg())
|
||
{
|
||
case DLG_DEFAULT:
|
||
if(e == fe_button)
|
||
riempi_sheet('D');
|
||
break;
|
||
case DLG_CERCA:
|
||
if(e == fe_button)
|
||
update_tree();
|
||
riempi_sheet();
|
||
break;
|
||
case DLG_SAVEREC:
|
||
if(e == fe_button)
|
||
registra();
|
||
case F_ANNO:
|
||
case F_MESE:
|
||
if (e == fe_modify)
|
||
update_tree();
|
||
break;
|
||
case F_CDC1:
|
||
case F_CDC2:
|
||
case F_CDC3:
|
||
case F_CDC4:
|
||
case F_CDC5:
|
||
case F_CDC6:
|
||
case F_CDC7:
|
||
case F_CDC8:
|
||
case F_CDC9:
|
||
case F_CDC10:
|
||
case F_CDC11:
|
||
case F_CDC12:
|
||
case F_RISOATT:
|
||
case F_CODRIS:
|
||
case F_CODATT:
|
||
case F_TPORA:
|
||
if (e == fe_modify)
|
||
{
|
||
update_tree();
|
||
riempi_sheet();
|
||
}
|
||
break;
|
||
case F_CALENDARIO:
|
||
if (e == fe_modify)
|
||
{
|
||
const TString & dett = get(F_INTERVALLO);
|
||
|
||
if (dett == "A")
|
||
_anno = atoi(*((TString *) ((TRil_tree *) tfield(F_CALENDARIO).tree())->curr_node()));
|
||
else
|
||
if (dett == "M")
|
||
_mese = ((TRil_tree *) tfield(F_CALENDARIO).tree())->pos() + 1;
|
||
else
|
||
_giorno = atoi(*((TString *) ((TRil_tree *) tfield(F_CALENDARIO).tree())->curr_node()));
|
||
|
||
|
||
riempi_sheet();
|
||
}
|
||
break;
|
||
case F_SHEET:
|
||
if (e == se_notify_add)
|
||
riempi_nuova_riga(jolly);
|
||
else
|
||
if (e == se_enter || e == se_leave)
|
||
{
|
||
update_prev();
|
||
update_disp();
|
||
}
|
||
break;
|
||
case F_INTERVALLO:
|
||
if (e == fe_modify)
|
||
{
|
||
const TString & dett = f.get();
|
||
|
||
if (dett == "A")
|
||
{
|
||
hide(F_ANNO);
|
||
hide(F_MESE);
|
||
}
|
||
else
|
||
if (dett == "M")
|
||
{
|
||
show(F_ANNO);
|
||
hide(F_MESE);
|
||
}
|
||
else
|
||
{
|
||
show(F_ANNO);
|
||
show(F_MESE);
|
||
}
|
||
update_tree();
|
||
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 && f.mask().get(S_COSTO).blank())
|
||
f.mask().set(S_COSTO, proponi_costo(f.mask()));
|
||
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);
|
||
}
|
||
TString4 dett = ini_get_string(CONFIG_DITTA, "ci", "DETTCONS");
|
||
if (dett.blank())
|
||
dett = "G";
|
||
|
||
if (dett == "A")
|
||
{
|
||
disable(F_INTERVALLO);
|
||
hide(F_ANNO);
|
||
hide(F_MESE);
|
||
}
|
||
else
|
||
{
|
||
if (dett == "M")
|
||
{
|
||
TList_field & f = lfield(F_INTERVALLO);
|
||
|
||
f.delete_item("G");
|
||
hide(F_MESE);
|
||
}
|
||
}
|
||
set(F_ANNO, TDate(TODAY).year());
|
||
set(F_INTERVALLO, dett);
|
||
|
||
TTree_field & tc = tfield(F_CALENDARIO);
|
||
TRil_tree * t = new TRil_tree();
|
||
|
||
tc.set_tree(t);
|
||
_giorno = 1;
|
||
_mese = get_int(F_MESE);
|
||
_anno = get_int(F_ANNO);
|
||
update_tree();
|
||
tc.force_update();
|
||
riempi_sheet();
|
||
_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;
|
||
} |