Patch level : 10.0 286

Files correlati     : pe0.exe
Ricompilazione Demo : [ ]
Commento            :

Preventivi/incarichi (Dinamica)


git-svn-id: svn://10.65.10.50/trunk@18736 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2009-04-20 00:06:09 +00:00
parent 4578193f88
commit 4911414595
6 changed files with 116 additions and 75 deletions

View File

@ -34,7 +34,7 @@ protected:
static bool ss_notify(TSheet_field& ss, int r, KEY key);
virtual void on_idle();
virtual void highlight_row(int row, bool dirty = true, bool update = true);
virtual void highlight_row(int row, COLOR back = COLOR_INVALID, COLOR fore = COLOR_INVALID, bool dirty = true, bool update = true);
public:
virtual void user_set_handler( short fieldid, int index);
@ -89,16 +89,16 @@ bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
TGestione_preventivo_msk& dmsk = (TGestione_preventivo_msk&) ss.mask();
TSheet_field & sh = dmsk.sfield(F_SHEET);
TDocumento& doc = dmsk.doc();
TRiga_documento& row = doc[r + 1];
switch (key)
{
case K_ENTER: // modifica
{
TRiga_documento& row = doc[r + 1];
TMask & m = sh.sheet_row_mask(r);
const int level = row.get_int(RDOC_LEVEL);
const bool prodfin = level == 0;
const bool price_enabled = (r + 1 == doc.physical_rows()) || (level < doc[r + 2].get_int(RDOC_LEVEL));
const bool price_enabled = (r + 1 == doc.physical_rows()) || (level >= doc[r + 2].get_int(RDOC_LEVEL));
short id;
m.enable(FR_PREZZO, price_enabled);
@ -109,51 +109,81 @@ bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
m.enable(id, prodfin);
}
break;
case K_INS: // Inserimento
case K_CTRL + K_INS: // Inserimento
{
const int new_sheet_r = doc.physical_rows() == 0 ? 0 : r + 1;
const int new_r = new_sheet_r + 1;
const int doc_row = r + 1;
int level = 0;
doc.insert_row(new_r, dmsk.get( F_LBTIPORIGA ));
TRiga_documento & new_row = doc[new_r];
TRiga_documento & row = doc[doc_row];
if (r > 0 && row.is_merce())
{
const int father_sheet_row = r - 1;
TRiga_documento& father_row = doc[father_sheet_row + 1];
const int rows = doc.physical_rows();
level = row.get_int(RDOC_LEVEL);
if (dmsk.get_bool(F_DETTAGLIO))
{
level = father_row.get_int(RDOC_LEVEL);
if (dmsk.get_bool(F_DETTAGLIO) || (doc_row < rows && level < doc[doc_row + 1].get_int(RDOC_LEVEL)))
level++;
dmsk.reset(F_DETTAGLIO);
}
if (level > 0)
{
new_row.put(RDOC_CODCOSTO, row.get(RDOC_CODCOSTO));
new_row.put(RDOC_CODCMS, row.get(RDOC_CODCMS));
new_row.put(RDOC_FASCMS, row.get(RDOC_FASCMS));
row.put(RDOC_CODCOSTO, father_row.get(RDOC_CODCOSTO));
row.put(RDOC_CODCMS, father_row.get(RDOC_CODCMS));
row.put(RDOC_FASCMS, father_row.get(RDOC_FASCMS));
short id;
sh.disable_cell(r, sh.cid2index(FR_PREZZO));
sh.disable_cell(r, sh.cid2index(FR_JOLLY2));
row.zero(RDOC_PREZZO);
row.zero(RDOC_K);
row.autoload(sh);
sh.disable_cell(father_sheet_row, sh.cid2index(FR_PREZZO));
sh.disable_cell(father_sheet_row, sh.cid2index(FR_JOLLY2));
father_row.zero(RDOC_PREZZO);
father_row.zero(RDOC_K);
father_row.autoload(sh);
sh.force_update(father_sheet_row);
for (id = F_CDC1; id < F_CDC12; id++)
sh.disable_cell(new_sheet_r, sh.cid2index(id));
sh.disable_cell(r, sh.cid2index(id));
}
}
new_row.put(RDOC_LEVEL, level);
row.put(RDOC_LEVEL, level);
TString tree;
if (level > 0)
tree.fill(' ');
tree << '+';
tree.rpad(10, '-');
if (level < 10)
{
if (level > 0)
tree.fill(' ', level);
tree << '+';
tree.rpad(10, '-');
}
row.put(RDOC_TREE, tree);
row.autoload(sh);
dmsk.reset(F_DETTAGLIO);
}
break;
case K_DEL: // Cancellazione
{
const int doc_row = r + 1;
const int rows = doc.physical_rows();
if (doc_row < rows)
{
TRiga_documento & row = doc[doc_row];
const int level = row.get_int(RDOC_LEVEL);
int i;
int last_row = doc_row;
for (i = doc_row + 1; i <= rows; i++)
if (level < doc[i].get_int(RDOC_LEVEL))
last_row = i;
else
break;
for (i = last_row; i > doc_row; i--)
{
doc.destroy_row(i, true);
sh.destroy(i - 1);
}
sh.force_update();
}
}
break;
default:
break;
}
@ -161,23 +191,19 @@ bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
}
void TGestione_preventivo_msk::highlight_row(int row, bool dirty, bool update)
void TGestione_preventivo_msk::highlight_row(int row, COLOR back, COLOR fore, bool dirty, bool update)
{
TRiga_documento& rigadoc = doc()[row + 1];
TSheet_field& sf = sfield(F_SHEET);
COLOR back1 = NORMAL_BACK_COLOR, back2 = FOCUS_BACK_COLOR;
COLOR back1 = NORMAL_BACK_COLOR, back2 = COLOR_BLUE;
const TColor_rule * c = (TColor_rule *) color_rules().objptr(_rule);
if (c != NULL)
{
COLOR fore;
c->colors(back2, fore);
}
const COLOR back = blend_colors(back1, back2, ((double) rigadoc.get_int(RDOC_LEVEL)) / 10.0);
back = blend_colors(back1, back2, 1.0 - (((double) rigadoc.get_int(RDOC_LEVEL)) / 10.0));
sf.set_back_and_fore_color(back, COLOR_INVALID, row);
TDocumento_mask::highlight_row(row, dirty, update);
sf.set_back_and_fore_color(back, fore, row);
TDocumento_mask::highlight_row(row, back, fore, dirty, update);
}
TVariable_mask * TGestione_preventivo_msk::riga_mask(int numriga)
@ -188,9 +214,11 @@ TVariable_mask * TGestione_preventivo_msk::riga_mask(int numriga)
if (is_new && m != NULL)
{
const TRiga_documento& riga = doc()[numriga + 1];
TEdit_field & tree = m->add_string(FR_JOLLY1, 0, "", 30, 50, 10, "D");
TEdit_field & k = m->add_string(FR_JOLLY2, 0, "K ", 2, 20, 25);
TEdit_field & tree = m->add_string(FR_JOLLY1, 0, "Albero ", 2, 20, 10, "D_");
TEdit_field & k = m->add_string(FR_JOLLY2, 0, "K ", 25, 20, 25);
m->set_handler(FR_CODART, pe_codart_handler);
m->set_handler(FR_UMQTA, pe_umart_handler);
tree.set_field(RDOC_TREE);
k.set_field(RDOC_K);
}
@ -212,14 +240,13 @@ void TGestione_preventivo_msk::doc2mask(bool reload_clifo, bool force_load, bool
const TRiga_documento & row = d[i + 1];
const int level = row.get_int(RDOC_LEVEL);
const bool prodfin = level == 0;
const bool price_enabled = (i + 1 == d.physical_rows()) || (level < d[i + 2].get_int(RDOC_LEVEL));
const bool price_enabled = (i + 1 == d.physical_rows()) || (level >= d[i + 2].get_int(RDOC_LEVEL));
s.enable_cell(i, s.cid2index(FR_PREZZO), price_enabled);
s.enable_cell(i, s.cid2index(FR_JOLLY2), price_enabled);
for (short id = F_CDC1; id < F_CDC12; id++)
s.enable_cell(i, s.cid2index(id), prodfin);
}
//aggiorna i colori delle righe e forza l'update dello sheet
highlight();
}
@ -237,18 +264,6 @@ bool TGestione_preventivo_msk::pe_data_handler(TMask_field& f, KEY k)
// HANDLER DI RIGA //
///////////////////////
//PE_RITIRATO_HANDLER: handler sul campo ritirato, che copia nel campo consegnato
//lo stesso valore eventualmente arrotondato e aggiorna il campo "dotazione odierna" (sempre)
//e il campo "dotazione temporanea" (se la causale è giusta)
bool TGestione_preventivo_msk::pe_ritirato_handler(TMask_field& f, KEY k)
{
if (f.to_check(k))
{
TMask& msk = f.mask();
}
return true;
}
bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
{
bool ok = codart_handler( f, k );
@ -323,6 +338,7 @@ bool TGestione_preventivo_msk::pe_umart_handler(TMask_field& f, KEY k)
qta *= qta_prec;
shrow.add(qta.string(), sh->cid2index(FR_UMQTA));
sh->force_update(r);
row.put(RDOC_QTA, qta);
f.focusdirty();
}
}
@ -332,14 +348,14 @@ bool TGestione_preventivo_msk::pe_umart_handler(TMask_field& f, KEY k)
const int r = sh->selected();
TRiga_documento & row = doc[r + 1];
const real old_qta = row.get_real(RDOC_QTA);
const real qta(f.get());
const real qta = row_mask.get_real(FR_QTA);
const int level = row.get_int(RDOC_LEVEL);
if (old_qta != qta)
{
const int rows = doc.physical_rows();
for (int i = r + 2; level < doc[i].get_int(RDOC_LEVEL) && i <= rows; i++)
for (int i = r + 2; i <= rows && level < doc[i].get_int(RDOC_LEVEL); i++)
{
TToken_string & shrow = sh->row(i - 1);
real row_qta(shrow.get(sh->cid2index(FR_UMQTA)));
@ -349,6 +365,7 @@ bool TGestione_preventivo_msk::pe_umart_handler(TMask_field& f, KEY k)
shrow.add(row_qta.string(), sh->cid2index(FR_UMQTA));
doc[i].put(RDOC_QTA, row_qta);
}
row.put(RDOC_QTA, qta);
sh->force_update();
}
}
@ -361,8 +378,8 @@ void TGestione_preventivo_msk::user_set_row_handler(TMask& rm, short field, int
{
switch(index)
{
case 5101: rm.set_handler(field, pe_ritirato_handler); break;
case 5102: rm.set_handler(field, pe_codart_handler); break;
case 5101: rm.set_handler(field, pe_codart_handler); break;
case 5102: rm.set_handler(field, pe_umart_handler); break;
default : TDocumento_mask::user_set_row_handler(rm, field, index); break;
}
}
@ -380,9 +397,8 @@ void TGestione_preventivo_msk::user_set_handler( short fieldid, int index)
TGestione_preventivo_msk::TGestione_preventivo_msk(const char* tipodoc) : TDocumento_mask(tipodoc)
{
TConfig* configpe = new TConfig(CONFIG_DITTA, "pe");
sfield(F_SHEET).set_auto_append();
sfield(F_SHEET).set_notify( ss_notify );
_rule = color_rules().add(new TColor_rule("Livello", "", _numexpr, FOCUS_BACK_COLOR, FOCUS_COLOR));
_rule = color_rules().add(new TColor_rule("Livello", "", _numexpr, COLOR_BLUE, FOCUS_COLOR));
}
//////////////////////////////////////////
@ -410,11 +426,12 @@ TMask* TGestione_preventivo_app::get_mask( int mode )
m->user_set_handler( row->get_int( 0 ), row->get_int( 1 ) );
}
TSheet_field & sh = m->sfield(F_SHEET);
const int y = sh.y_pos() - 1;
TEdit_field & k = m->add_string(F_K, sh.page(), "K ", 2, y, 10, "D");
const int y = m->sh_y() - 1;
TEdit_field & k = m->add_string(F_K, sh.page(), "K ", 2, y, 25);
k.set_field(DOC_K);
m->add_boolean(F_DETTAGLIO, sh.page(), "Dettaglia ", 30, y);
m->add_boolean(F_DETTAGLIO, sh.page(), "Dettaglia ", 60, y);
sh.enable_column(sh.cid2index(FR_JOLLY1), false);
}
}
return TMotore_application::get_mask(mode);
@ -425,9 +442,18 @@ int TGestione_preventivo_app::write( const TMask& m )
{
TDocumento& doc = ((TDocumento_mask&) m).doc();
const TString k = doc.get(DOC_K);
int max_level = 0;
const int rows = doc.physical_rows();
for (int i = 1 ; i <= doc.physical_rows(); i++)
if (doc[i].get(RDOC_K).blank())
for (int r = 1; r <= rows; r++)
{
const int level = doc[r].get_int(RDOC_LEVEL);
if (max_level < level)
max_level = level;
}
for (int i = 1 ; i <= rows; i++)
if (doc[i].get_int(RDOC_LEVEL) == max_level && doc[i].get(RDOC_K).blank())
doc[i].put(RDOC_K, k);
return TMotore_application::write(m);
}
@ -437,9 +463,18 @@ int TGestione_preventivo_app::rewrite( const TMask& m )
{
TDocumento& doc = ((TDocumento_mask&) m).doc();
const TString k = doc.get(DOC_K);
int max_level = 0;
const int rows = doc.physical_rows();
for (int i = 1 ; i <= doc.physical_rows(); i++)
if (doc[i].get(RDOC_K).blank())
for (int r = 1; r <= rows; r++)
{
const int level = doc[r].get_int(RDOC_LEVEL);
if (max_level < level)
max_level = level;
}
for (int i = 1 ; i <= rows; i++)
if (doc[i].get_int(RDOC_LEVEL) == max_level && doc[i].get(RDOC_K).blank())
doc[i].put(RDOC_K, k);
return TMotore_application::rewrite(m);
}

View File

@ -20,13 +20,13 @@ CANCELLA=
STAMPA=
RAGGRUPPA=
USER=
LINES_BEFORESHEET=1
SHEET_LINE=9
// Indica se il documento è indirizzato ad un cliente o ad un fornitore
TIPOCF=C
//modulo di riferimento
MODULE=ve
MODULE=pe
Title(1)=Cliente
Title(2)=Pagamenti
Title(3)=Ind.Spedizione

View File

@ -1219,7 +1219,9 @@ void TMask_generator::genera_sheet(int line, bool show_list, bool genera_disp)
_m->end( );
// Generazione dello sheet : vedi il profilo
line += profilo().get_int("LINES_BEFORESHEET", 0);
const int sh_y = profilo().get_int("SHEET_LINE");
if (sh_y > 0)
line = sh_y;
TScanner sheet_in( "ve0300b.dat" );
_m->_out << "SPREADSHEET " << F_SHEET << "\n";
_m->begin( );

View File

@ -891,6 +891,7 @@ class TDocumento_mask : public TVariable_mask // velib06
short _cms_end_sh;
TString _codcms, _codcms_sh;
TArray _color_rules;
int _sh_y;
protected:
virtual void next_page(int p);
@ -909,6 +910,7 @@ public:
void update_progs(bool stop_run = false);
virtual bool on_key(KEY key);
virtual bool stop_run(KEY key);
int sh_y() const { return _sh_y; }
void set_field_handler(short fieldid, CONTROL_HANDLER handler);
bool call_handler( TMask_field& f, KEY key);
@ -916,7 +918,7 @@ public:
static bool universal_handler( TMask_field& f, KEY key);
static bool occas_handler( TMask_field& f, KEY key );
static bool occas_code_handler( TMask_field& f, KEY key );
static bool occas_cfpi_handler( TMask_field& f, KEY key );
static bool occas_cfpi_handler( TMask_field& f, KEY key );
static bool clifo_handler( TMask_field& f, KEY key );
static bool print_handler( TMask_field& f, KEY key );
static bool elabora_handler( TMask_field& f, KEY key );
@ -964,7 +966,7 @@ public:
static bool ragsoc_search_handler( TMask_field& f, KEY key );
static bool datadocrif_handler(TMask_field& f, KEY key);
virtual void highlight_row(int row, bool dirty = true, bool update = true);
virtual void highlight_row(int row, COLOR back = COLOR_INVALID, COLOR fore = COLOR_INVALID, bool dirty = true, bool update = true);
void highlight();
bool is_calculated_page(int p) const { return _calculated_pages[p]; }

View File

@ -298,7 +298,8 @@ TDocumento_mask::TDocumento_mask(const char* td)
else
break;
}
_sh_y = prof.get_int("SHEET_LINE", "MAIN");
// Legge i colori personalizzati dal .ini gestito dalla TSelect_color_mask
TString tmp; tmp << doc().tipo().mask_name() << "_0"; tmp.lower();
TConfig conf(CONFIG_GUI, tmp);
@ -1674,12 +1675,12 @@ bool TDocumento_mask::clifo_handler( TMask_field& f, KEY key )
return true;
}
void TDocumento_mask::highlight_row(int row, bool dirty, bool update)
void TDocumento_mask::highlight_row(int row, COLOR back, COLOR fore, bool dirty, bool update)
{
TRiga_documento& rigadoc = doc()[row + 1];
TSheet_field& sf = sfield(F_SHEET);
COLOR back = COLOR_INVALID, fore = COLOR_INVALID;
// COLOR back = COLOR_INVALID, fore = COLOR_INVALID;
FOR_EACH_ARRAY_ITEM_BACK(color_rules(), rule, o)
{

View File

@ -113,8 +113,6 @@
#define F_DESCDC12 282
//#define F_SELECT 101
#define F_USERFLD 301
//scontrini
#define DLG_CHIUDI 401
#define DLG_TURNO 402
@ -131,4 +129,7 @@
#define DLG_FUNC08 418
#define DLG_CONFERMA 420
#define F_USERFLD 450
#endif // veuml.h