2008-09-10 09:22:52 +00:00
|
|
|
#include <automask.h>
|
2009-01-23 17:03:44 +00:00
|
|
|
#include <defmask.h>
|
2008-09-10 09:22:52 +00:00
|
|
|
#include <execp.h>
|
2008-12-10 11:57:25 +00:00
|
|
|
#include <progind.h>
|
2008-08-21 15:41:07 +00:00
|
|
|
#include <relapp.h>
|
|
|
|
|
|
|
|
#include "lv0400.h"
|
2008-10-28 20:07:09 +00:00
|
|
|
#include "lvlib.h"
|
2009-01-23 17:03:44 +00:00
|
|
|
|
2008-10-28 20:07:09 +00:00
|
|
|
#include "../cg/cglib01.h"
|
2008-09-04 13:44:10 +00:00
|
|
|
#include "../mg/anamag.h"
|
2008-09-11 10:34:37 +00:00
|
|
|
#include "../mg/mglib.h"
|
2009-01-27 16:54:54 +00:00
|
|
|
#include "../mg/clifogiac.h"
|
2008-08-21 15:41:07 +00:00
|
|
|
|
2009-01-23 17:03:44 +00:00
|
|
|
long lv_new_contract(long cliente, int indsped)
|
|
|
|
{
|
|
|
|
TConfig ini(CONFIG_DITTA, "lv");
|
|
|
|
const bool unicont=ini.get_bool("UniCont");
|
|
|
|
|
|
|
|
long codcont=0;
|
|
|
|
if (unicont)
|
|
|
|
{
|
|
|
|
TISAM_recordset recset ("USE LVCONDV");
|
|
|
|
for (bool ok=recset.move_first(); ok; ok=recset.move_next())
|
|
|
|
{
|
|
|
|
const long codice=recset.get("CODCONT").as_int();
|
|
|
|
if (codice>codcont)
|
|
|
|
codcont=codice;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TString query;
|
|
|
|
query<<"USE LVCONDV \n"
|
|
|
|
<<"FROM CODCF=#CLIENTE\n"
|
|
|
|
<<"TO CODCF=#CLIENTE\n";
|
|
|
|
TISAM_recordset recset (query);
|
|
|
|
recset.set_var("#CLIENTE",cliente);
|
|
|
|
if (recset.move_last())
|
|
|
|
codcont=recset.get("CODCONT").as_int();
|
|
|
|
|
|
|
|
}
|
|
|
|
codcont++;
|
|
|
|
return codcont;
|
|
|
|
}
|
|
|
|
|
2008-09-10 09:22:52 +00:00
|
|
|
|
|
|
|
class TContratti_msk: public TAutomask
|
|
|
|
{
|
2009-01-23 17:03:44 +00:00
|
|
|
long _post_contr;
|
2009-02-03 16:34:50 +00:00
|
|
|
TString80 _artrig;
|
2009-01-23 17:03:44 +00:00
|
|
|
|
2008-09-10 09:22:52 +00:00
|
|
|
protected:
|
|
|
|
bool on_art_select();
|
|
|
|
virtual bool on_field_event(TOperable_field& o,TField_event e,long jolly);
|
2009-01-23 17:03:44 +00:00
|
|
|
virtual void on_idle();
|
|
|
|
|
2008-09-10 09:22:52 +00:00
|
|
|
public:
|
|
|
|
TContratti_msk();
|
|
|
|
};
|
|
|
|
|
|
|
|
bool TContratti_msk::on_art_select()
|
|
|
|
{
|
2008-10-28 20:07:09 +00:00
|
|
|
TSheet_field& ss = sfield(F_RIGHE);
|
|
|
|
TMask& rowmask = ss.sheet_mask();
|
2008-09-10 09:22:52 +00:00
|
|
|
TToken_string & row = ss.row(ss.selected());
|
|
|
|
const TString80 codart(row.get(ss.cid2index(S_CODART)));
|
2008-10-28 20:07:09 +00:00
|
|
|
const long codcf = get_long(F_CODCF);
|
|
|
|
const int indsped = get_int(F_INDSPED);
|
|
|
|
TArticolo_lavanderie & artrec = cached_article_laundry(codart, 'C', codcf, indsped);
|
2009-01-16 23:18:15 +00:00
|
|
|
TDate datasc(TODAY);
|
2008-10-28 20:07:09 +00:00
|
|
|
const int annoes = esercizi().date2esc(datasc);
|
2009-01-16 23:18:15 +00:00
|
|
|
|
|
|
|
int index = artrec.find_clifomag(annoes);
|
2008-10-28 20:07:09 +00:00
|
|
|
|
|
|
|
if (index > 0)
|
|
|
|
{
|
|
|
|
const TString4 umcont(row.get(ss.cid2index(S_UM)));
|
|
|
|
const real dotin = artrec.convert_to_um(artrec.clifomag(annoes)[index].get_real("DOTIN"),umcont);
|
|
|
|
rowmask.set(S_DOTIN, dotin);
|
|
|
|
row.add(dotin.stringa(), ss.cid2index(S_DOTIN));
|
|
|
|
const real dotod = artrec.convert_to_um(artrec.clifomag(annoes)[index].get_real("DOTOD"),umcont);
|
|
|
|
rowmask.set(S_DOTOD, dotod);
|
|
|
|
row.add(dotod.stringa(), ss.cid2index(S_DOTOD));
|
|
|
|
const real dottmp = artrec.convert_to_um(artrec.clifomag(annoes)[index].get_real("DOTTM"),umcont);
|
|
|
|
rowmask.set(S_DOTTMP, dottmp);
|
|
|
|
row.add(dottmp.stringa(), ss.cid2index(S_DOTTMP));
|
|
|
|
const real consyear = artrec.convert_to_um(artrec.clifomag(annoes)[index].get_real("CONSANNO"),umcont);
|
|
|
|
rowmask.set(S_CONSANNO, consyear);
|
|
|
|
row.add(consyear.stringa(), ss.cid2index(S_CONSANNO));
|
|
|
|
const real consmonth = artrec.convert_to_um(artrec.clifomag(annoes)[index].get_real("CONSMESE"),umcont);
|
|
|
|
rowmask.set(S_CONSMESE, consmonth);
|
|
|
|
row.add(consmonth.stringa(), ss.cid2index(S_CONSMESE));
|
|
|
|
}
|
2008-09-11 10:34:37 +00:00
|
|
|
|
2008-12-17 11:52:10 +00:00
|
|
|
const bool varclcons = artrec.get_int(ANAMAG_PPCONF)>0;
|
2008-09-10 09:22:52 +00:00
|
|
|
|
|
|
|
ss.enable_cell(ss.selected(),ss.cid2index(S_CALCCONS));
|
|
|
|
|
2008-10-20 08:18:31 +00:00
|
|
|
rowmask.set(S_CALCCONS,"0");
|
2008-09-10 09:22:52 +00:00
|
|
|
row.add("0",ss.cid2index(S_CALCCONS));
|
2009-01-20 09:42:36 +00:00
|
|
|
|
2009-02-03 16:34:50 +00:00
|
|
|
for (short id=F_CODART; id<=F_CODART+35; id++)
|
2009-01-20 09:42:36 +00:00
|
|
|
{
|
|
|
|
const int pos=id2pos(id);
|
|
|
|
if (pos>0)
|
|
|
|
fld(pos).set(row.get(ss.cid2index(id-400)));
|
|
|
|
}
|
2009-02-03 16:34:50 +00:00
|
|
|
|
2008-09-10 09:22:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-23 17:03:44 +00:00
|
|
|
void TContratti_msk::on_idle()
|
|
|
|
{
|
|
|
|
if (_post_contr > 0)
|
|
|
|
{
|
|
|
|
set(F_CODCONT, _post_contr);
|
|
|
|
_post_contr = 0;
|
|
|
|
efield(F_CODCONT).set_focus();
|
|
|
|
}
|
|
|
|
TAutomask::on_idle();
|
|
|
|
}
|
2008-09-10 09:22:52 +00:00
|
|
|
|
2009-01-23 17:03:44 +00:00
|
|
|
bool TContratti_msk::on_field_event(TOperable_field& o,TField_event e,long jolly)
|
2008-09-10 09:22:52 +00:00
|
|
|
{
|
|
|
|
switch(o.dlg())
|
|
|
|
{
|
2008-12-12 08:29:38 +00:00
|
|
|
case F_CODCF:
|
2009-01-23 17:03:44 +00:00
|
|
|
if (query_mode())
|
|
|
|
{
|
|
|
|
if (e == fe_modify && !o.empty() && efield(F_CODCONT).empty())
|
|
|
|
{
|
|
|
|
const long codcf = atol(o.get());
|
|
|
|
const int indsped = get_int(F_INDSPED);
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
_post_contr = lv_find_contract(codcf, indsped, oggi);
|
|
|
|
}
|
2008-12-12 08:29:38 +00:00
|
|
|
}
|
2009-01-23 17:03:44 +00:00
|
|
|
break;
|
2008-09-10 09:22:52 +00:00
|
|
|
case DLG_PLANNING:
|
2008-09-15 14:26:31 +00:00
|
|
|
if (e==fe_button && edit_mode())
|
2008-09-10 09:22:52 +00:00
|
|
|
{
|
|
|
|
TRelation_application& app=(TRelation_application&) main_app();
|
|
|
|
app.get_relation()->read(_isequal,_unlock);
|
|
|
|
TString str;
|
|
|
|
str << "lv0 -4 " << get(F_CODCF) << " " << get(F_CODCONT);
|
|
|
|
TExternal_app planning(str);
|
|
|
|
planning.run();
|
|
|
|
app.get_relation()->read(_isequal,_lock);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S_CODART:
|
2008-10-21 15:51:13 +00:00
|
|
|
if (!o.empty())
|
2008-09-10 09:22:52 +00:00
|
|
|
{
|
2008-10-21 15:51:13 +00:00
|
|
|
if (e==fe_modify)
|
2009-02-03 16:34:50 +00:00
|
|
|
{
|
|
|
|
const TString& codart=o.get();
|
|
|
|
TSheet_field& ss=sfield(F_RIGHE);
|
|
|
|
TMask& m = o.mask(); // maschera di riga!
|
|
|
|
|
|
|
|
if (_artrig.full() && codart!=_artrig)
|
|
|
|
{
|
|
|
|
if (!yesno_box("Si desidera veramente modificare l'articolo %s",(const char*) _artrig))
|
|
|
|
{
|
|
|
|
m.set(S_CODART,_artrig);
|
|
|
|
TToken_string& row=ss.row(ss.selected());
|
|
|
|
row.add(_artrig, 0);
|
|
|
|
ss.force_update(ss.selected());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_artrig = codart;
|
|
|
|
}
|
|
|
|
TArticolo art(codart);
|
2008-10-21 15:51:13 +00:00
|
|
|
if (art.um().rows() > 0)
|
|
|
|
{
|
|
|
|
const TString& um = art.um()[1].get(UMART_UM);
|
|
|
|
m.set(S_UM,um);
|
|
|
|
TToken_string& row=ss.row(ss.selected());
|
|
|
|
row.add(o.get(),ss.cid2index(S_CODART));
|
|
|
|
row.add(um,S_UM);
|
|
|
|
on_art_select();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (e==fe_init)
|
|
|
|
on_art_select();
|
2008-09-10 09:22:52 +00:00
|
|
|
}
|
2008-10-21 15:51:13 +00:00
|
|
|
break;
|
2009-01-20 09:42:36 +00:00
|
|
|
case F_RIGHE:
|
|
|
|
if (e==se_enter)
|
|
|
|
{
|
|
|
|
TSheet_field& ss=(TSheet_field&)o;
|
|
|
|
TToken_string& row=ss.row(ss.selected());
|
|
|
|
for (short id=F_IMPFISART; id<=F_IMPFISART+30; id++)
|
|
|
|
{
|
|
|
|
const int pos=id2pos(id);
|
|
|
|
if (pos>0)
|
|
|
|
fld(pos).set(row.get(ss.cid2index(id-400)));
|
|
|
|
}
|
2009-02-03 16:34:50 +00:00
|
|
|
_artrig=row.get(0);
|
2009-01-20 09:42:36 +00:00
|
|
|
}
|
2009-01-27 16:54:54 +00:00
|
|
|
if (e==se_query_del)
|
|
|
|
{
|
|
|
|
TSheet_field& ss=(TSheet_field&)o;
|
|
|
|
TToken_string& row=ss.row(ss.selected());
|
|
|
|
const TString codart=row.get(ss.cid2index(S_CODART));
|
|
|
|
if (!yesno_box("Si desidera veramente cancellare l'articolo %s",(const char*) codart))
|
|
|
|
return false;
|
|
|
|
}
|
2009-01-20 09:42:36 +00:00
|
|
|
break;
|
2009-01-23 17:03:44 +00:00
|
|
|
case DLG_NEWREC:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
if (edit_mode())
|
|
|
|
{
|
|
|
|
send_key(K_ESC, 0);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (query_mode())
|
|
|
|
{
|
|
|
|
const long codcf = get_long(F_CODCF);
|
|
|
|
if (codcf > 0)
|
|
|
|
{
|
|
|
|
const int indsped = get_int(F_INDSPED);
|
|
|
|
const long codcont = lv_new_contract(codcf, indsped);
|
|
|
|
if (codcont > 0)
|
|
|
|
set(F_CODCONT, codcont);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-01-20 09:42:36 +00:00
|
|
|
default:
|
|
|
|
if (e==fe_modify && o.dlg()>500 && o.dlg() != F_CAUSLAVDESCRIG)
|
|
|
|
{
|
|
|
|
TSheet_field& ss = sfield(F_RIGHE);
|
|
|
|
const short rowid = o.dlg()-400;
|
|
|
|
const int index= ss.cid2index(rowid);
|
|
|
|
const int sel=ss.selected();
|
|
|
|
ss.row(sel).add(o.get(),index);
|
|
|
|
ss.force_update(sel);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2008-09-10 09:22:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-23 17:03:44 +00:00
|
|
|
TContratti_msk::TContratti_msk():TAutomask("lv0400a"), _post_contr(0)
|
2008-09-10 09:22:52 +00:00
|
|
|
{
|
2009-01-27 16:54:54 +00:00
|
|
|
TConfig* configlv = new TConfig(CONFIG_DITTA,"lv");
|
|
|
|
char indir = configlv->get_char("Useindsp");
|
|
|
|
if (indir!='X')
|
|
|
|
field(F_INDSPED).hide();
|
2008-09-10 09:22:52 +00:00
|
|
|
}
|
|
|
|
|
2008-08-21 15:41:07 +00:00
|
|
|
class TContratti_app: public TRelation_application
|
|
|
|
{
|
2009-01-27 16:54:54 +00:00
|
|
|
TContratti_msk * _msk;
|
2008-08-21 15:41:07 +00:00
|
|
|
TRelation* _rel;
|
|
|
|
|
2008-08-27 15:21:44 +00:00
|
|
|
private:
|
|
|
|
void save_rows(const TMask& m);
|
|
|
|
void build_query(const TMask& m,TString& query) const;
|
|
|
|
int find_art(TSheet_field& s,const TString& art) const;
|
|
|
|
|
2008-08-21 15:41:07 +00:00
|
|
|
protected:
|
2008-09-02 10:38:36 +00:00
|
|
|
virtual TMask* get_mask (int mode) {return _msk; }
|
2008-08-21 15:41:07 +00:00
|
|
|
virtual TRelation* get_relation() const {return _rel;}
|
|
|
|
|
|
|
|
virtual bool user_create();
|
|
|
|
virtual bool user_destroy();
|
|
|
|
virtual void on_config_change();
|
|
|
|
virtual bool get_next_key(TToken_string& key);
|
2008-08-27 15:21:44 +00:00
|
|
|
virtual int read(TMask& m);
|
|
|
|
virtual int write(const TMask& m);
|
|
|
|
virtual int rewrite(const TMask& m);
|
2008-12-10 11:57:25 +00:00
|
|
|
virtual bool protected_record(TRectype & rec);
|
2008-08-27 15:21:44 +00:00
|
|
|
virtual bool remove();
|
2008-12-09 12:43:15 +00:00
|
|
|
virtual void init_query_mode(TMask& m);
|
2008-10-21 15:51:13 +00:00
|
|
|
virtual void init_insert_mode(TMask& m);
|
2009-01-27 16:54:54 +00:00
|
|
|
virtual void init_modify_mode(TMask& m);
|
2008-12-10 12:03:36 +00:00
|
|
|
bool elimina_planning(const long& codcont, const long& codcf) const;
|
2008-12-10 11:57:25 +00:00
|
|
|
bool kill_planning (TISAM_recordset& selrighe) const;
|
2008-08-21 15:41:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool TContratti_app:: user_create()
|
|
|
|
{
|
|
|
|
_rel=new TRelation (LF_LVCONDV);
|
2008-09-10 09:22:52 +00:00
|
|
|
_msk= new TContratti_msk;
|
2008-12-09 12:43:15 +00:00
|
|
|
|
2009-01-16 23:18:15 +00:00
|
|
|
TDate datasc(TODAY);
|
|
|
|
if (esercizi().date2esc(datasc) == 0)
|
|
|
|
return message_box("Attenzione non esiste l'esercizio corrispondente al %s", datasc.string());
|
|
|
|
|
2008-12-09 12:43:15 +00:00
|
|
|
TSheet_field& ss=_msk->sfield(F_RIGHE);
|
|
|
|
|
|
|
|
ss.set_auto_append();
|
2008-12-12 15:54:15 +00:00
|
|
|
ss.set_append(false);
|
2008-12-09 12:43:15 +00:00
|
|
|
|
|
|
|
return true;
|
2008-08-21 15:41:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TContratti_app:: user_destroy()
|
|
|
|
{
|
2008-09-02 10:38:36 +00:00
|
|
|
delete _msk;
|
2008-08-21 15:41:07 +00:00
|
|
|
delete _rel;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TContratti_app:: on_config_change()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TContratti_app:: get_next_key(TToken_string& key)
|
|
|
|
{
|
2008-09-02 10:38:36 +00:00
|
|
|
const long cliente=_msk->get_long(F_CODCF);
|
2008-08-21 15:41:07 +00:00
|
|
|
if (cliente<=0) return false;
|
|
|
|
key.add(F_CODCF);
|
|
|
|
key.add(cliente);
|
|
|
|
key.add(F_CODCONT);
|
|
|
|
|
2009-01-23 17:03:44 +00:00
|
|
|
long codcont= lv_new_contract(cliente, _msk->get_int(F_INDSPED));
|
2008-08-21 15:41:07 +00:00
|
|
|
key.add(codcont);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-02 10:38:36 +00:00
|
|
|
|
|
|
|
|
2008-08-27 15:21:44 +00:00
|
|
|
void TContratti_app:: build_query(const TMask& m,TString& query) const
|
|
|
|
{
|
|
|
|
query="";
|
2008-08-27 15:34:52 +00:00
|
|
|
query << "USE LVRCONDV\n"
|
2008-08-27 15:21:44 +00:00
|
|
|
<< "FROM CODCF="<<m.get(F_CODCF)<<" CODCONT="<<m.get(F_CODCONT)<<"\n"
|
|
|
|
<< "TO CODCF="<<m.get(F_CODCF)<<" CODCONT="<<m.get(F_CODCONT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int TContratti_app:: read(TMask& m)
|
|
|
|
{
|
|
|
|
int err=TRelation_application::read(m);
|
|
|
|
if(err==NOERR)
|
|
|
|
{
|
|
|
|
TString query;
|
|
|
|
build_query(m,query);
|
|
|
|
TISAM_recordset righeset(query);
|
|
|
|
const TRectype& rec=righeset.cursor()->curr();
|
|
|
|
|
|
|
|
TSheet_field& righe=m.sfield(F_RIGHE);
|
|
|
|
TMask& msk=righe.sheet_mask();
|
|
|
|
righe.destroy();
|
|
|
|
|
|
|
|
for (bool ok=righeset.move_first(); ok; ok=righeset.move_next())
|
|
|
|
{
|
|
|
|
TToken_string& row=righe.row(-1);
|
|
|
|
FOR_EACH_MASK_FIELD(msk,i,f)
|
|
|
|
{
|
|
|
|
const TFieldref*fr=f->field();
|
|
|
|
if (fr!= NULL)
|
|
|
|
row.add(fr->read(rec),righe.cid2index(f->dlg()));
|
|
|
|
}
|
|
|
|
righe.check_row(righe.items()-1,3);
|
|
|
|
}
|
|
|
|
righe.force_update();
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TContratti_app::find_art(TSheet_field& s,const TString& art) const
|
|
|
|
{
|
|
|
|
int r=-1;
|
|
|
|
for (r=s.items()-1;r>=0;r--)
|
|
|
|
{
|
|
|
|
const char* codart= s.row(r).get(0);
|
|
|
|
if (art==codart)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
|
|
|
|
}
|
|
|
|
void TContratti_app::save_rows(const TMask& m)
|
|
|
|
{
|
|
|
|
TString query;
|
|
|
|
TSheet_field& righe=m.sfield(F_RIGHE);
|
|
|
|
build_query(m,query);
|
|
|
|
TISAM_recordset righeset(query);
|
|
|
|
TLocalisamfile& file=righeset.cursor()->file();
|
|
|
|
for (bool ok=righeset.move_first(); ok; ok=righeset.move_next())
|
|
|
|
{
|
|
|
|
const TString& art=righeset.get("CODART").as_string();
|
|
|
|
if (find_art(righe,art)<0)
|
|
|
|
file.remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
TMask& msk=righe.sheet_mask();
|
2009-01-27 16:54:54 +00:00
|
|
|
|
|
|
|
const int colart=righe.cid2index(S_CODART);
|
|
|
|
const int coldotin=righe.cid2index(S_DOTIN);
|
|
|
|
const int coldotod=righe.cid2index(S_DOTOD);
|
|
|
|
const int coldottmp=righe.cid2index(S_DOTTMP);
|
|
|
|
|
|
|
|
TLocalisamfile magcli(LF_CLIFOGIAC);
|
|
|
|
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
const int year=oggi.year();
|
|
|
|
const long clifo=m.get_long(F_CODCF);
|
|
|
|
const int indsp=m.get_int(F_INDSPED);
|
|
|
|
|
2008-08-27 15:21:44 +00:00
|
|
|
FOR_EACH_SHEET_ROW(righe,r,row)
|
|
|
|
{
|
|
|
|
file.zero();
|
2009-01-27 16:54:54 +00:00
|
|
|
file.put("CODCF",clifo);
|
2008-08-27 15:21:44 +00:00
|
|
|
file.put("CODCONT",m.get(F_CODCONT));
|
|
|
|
FOR_EACH_MASK_FIELD(msk,i,f)
|
|
|
|
{
|
|
|
|
const TFieldref*fr=f->field();
|
|
|
|
if (fr!= NULL)
|
|
|
|
{
|
|
|
|
const int pos=righe.cid2index(f->dlg());
|
|
|
|
fr->write(row->get(pos),file.curr());
|
|
|
|
}
|
|
|
|
}
|
2009-01-27 16:54:54 +00:00
|
|
|
const TString80 codart=file.get("CODART");
|
|
|
|
if (codart.full())
|
|
|
|
{
|
2008-10-21 15:51:13 +00:00
|
|
|
file.rewrite_write();
|
2009-01-27 16:54:54 +00:00
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
magcli.zero();
|
|
|
|
if (oggi.month() == 12)
|
|
|
|
{
|
|
|
|
magcli.put(CLIFOGIAC_ANNOES, year+1);
|
|
|
|
magcli.put(CLIFOGIAC_TIPOCF, 'C');
|
|
|
|
magcli.put(CLIFOGIAC_CODCF, clifo);
|
|
|
|
magcli.put(CLIFOGIAC_INDSPED, indsp);
|
|
|
|
magcli.put(CLIFOGIAC_CODART, codart);
|
|
|
|
found = magcli.read()==NOERR;
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
magcli.zero();
|
|
|
|
magcli.put(CLIFOGIAC_ANNOES, year);
|
|
|
|
magcli.put(CLIFOGIAC_TIPOCF, 'C');
|
|
|
|
magcli.put(CLIFOGIAC_CODCF, clifo);
|
|
|
|
magcli.put(CLIFOGIAC_INDSPED, indsp);
|
|
|
|
magcli.put(CLIFOGIAC_CODART, codart);
|
|
|
|
}
|
|
|
|
magcli.put(CLIFOGIAC_DOTIN,row->get(coldotin));
|
|
|
|
magcli.put(CLIFOGIAC_DOTOD,row->get(coldotod));
|
|
|
|
magcli.put(CLIFOGIAC_DOTTM,row->get(coldottmp));
|
|
|
|
magcli.rewrite_write();
|
|
|
|
break;
|
|
|
|
}
|
2008-08-27 15:21:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-12-09 12:43:15 +00:00
|
|
|
void TContratti_app::init_query_mode(TMask& m)
|
|
|
|
{
|
2009-01-23 17:03:44 +00:00
|
|
|
m.field(F_RAGSOC).enable(m.field(F_CODCF).enabled());
|
2009-01-27 16:54:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TContratti_app::init_modify_mode(TMask& m)
|
|
|
|
{
|
|
|
|
TSheet_field& righe=m.sfield(F_RIGHE);
|
|
|
|
|
|
|
|
const int colart=righe.cid2index(S_CODART);
|
|
|
|
const int coldes=righe.cid2index(S_DESCR);
|
|
|
|
const int colum=righe.cid2index(S_UM);
|
|
|
|
const int coldotin=righe.cid2index(S_DOTIN);
|
|
|
|
const int coldotod=righe.cid2index(S_DOTOD);
|
|
|
|
const int coldottmp=righe.cid2index(S_DOTTMP);
|
|
|
|
|
|
|
|
TLocalisamfile magcli(LF_CLIFOGIAC);
|
|
|
|
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
const int year=oggi.year();
|
|
|
|
const long clifo=m.get_long(F_CODCF);
|
|
|
|
const int indsp=m.get_int(F_INDSPED);
|
|
|
|
|
|
|
|
FOR_EACH_SHEET_ROW(righe,r,row)
|
|
|
|
{
|
|
|
|
const TString80 codart=row->get(colart);
|
2009-02-03 16:34:50 +00:00
|
|
|
// righe.disable_cell(r,colart);
|
|
|
|
// righe.disable_cell(r,coldes);
|
|
|
|
// righe.disable_cell(r,colum);
|
2009-01-23 17:03:44 +00:00
|
|
|
|
2009-01-27 16:54:54 +00:00
|
|
|
for (int y = year + oggi.month() == 12; y >= year; y--)
|
|
|
|
{
|
|
|
|
magcli.put(CLIFOGIAC_ANNOES, y);
|
|
|
|
magcli.put(CLIFOGIAC_TIPOCF, 'C');
|
|
|
|
magcli.put(CLIFOGIAC_CODCF, clifo);
|
|
|
|
magcli.put(CLIFOGIAC_INDSPED, indsp);
|
|
|
|
magcli.put(CLIFOGIAC_CODART, codart);
|
|
|
|
if (magcli.read()==NOERR)
|
|
|
|
{
|
|
|
|
row->add(magcli.get("DOTIN"),coldotin);
|
|
|
|
row->add(magcli.get("DOTOD"),coldotod);
|
|
|
|
row->add(magcli.get("DOTTM"),coldottmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-12-09 12:43:15 +00:00
|
|
|
}
|
|
|
|
|
2009-01-27 16:54:54 +00:00
|
|
|
|
2008-10-21 15:51:13 +00:00
|
|
|
void TContratti_app::init_insert_mode(TMask& m)
|
|
|
|
{
|
2009-01-27 16:54:54 +00:00
|
|
|
|
2009-01-23 17:03:44 +00:00
|
|
|
const long codcf = m.get_long(F_CODCF);
|
|
|
|
const long indsp = m.get_int(F_INDSPED);
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
const long old_contr = lv_find_contract(codcf, indsp, oggi);
|
|
|
|
const long cur_contr = m.get_long(F_CODCONT);
|
|
|
|
if (old_contr > 0 && old_contr < cur_contr)
|
|
|
|
m.set(F_PROPOSTA, "X");
|
2008-10-21 15:51:13 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:21:44 +00:00
|
|
|
int TContratti_app::write(const TMask& m)
|
|
|
|
{
|
|
|
|
int err=TRelation_application::write(m);
|
2008-12-12 11:56:19 +00:00
|
|
|
if(err==NOERR)
|
|
|
|
{
|
|
|
|
save_rows(m);
|
|
|
|
warning_box(TR("Ricordarsi di inserire i passaggi per planning"));
|
|
|
|
}
|
|
|
|
|
2008-08-27 15:21:44 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
int TContratti_app::rewrite(const TMask& m)
|
|
|
|
{
|
|
|
|
int err=TRelation_application::rewrite(m);
|
|
|
|
if(err==NOERR) save_rows(m);
|
|
|
|
return err;
|
|
|
|
}
|
2008-12-10 11:57:25 +00:00
|
|
|
|
|
|
|
bool TContratti_app::protected_record(TRectype & rec)
|
|
|
|
{
|
|
|
|
TLaundry_contract cont(rec);
|
|
|
|
return !cont.can_be_deleted();
|
|
|
|
}
|
|
|
|
|
2008-12-10 12:03:36 +00:00
|
|
|
bool TContratti_app::elimina_planning(const long& codcont, const long& codcf) const
|
2008-12-10 11:57:25 +00:00
|
|
|
{
|
|
|
|
//creo il recordset
|
2008-12-10 12:03:36 +00:00
|
|
|
TISAM_recordset selrighe("USE LVRCONSPLAN KEY 3\nFROM CODCF=#CODCF CODCONT=#CODCONT \nTO CODCF=#CODCF CODCONT=#CODCONT");
|
2008-12-10 11:57:25 +00:00
|
|
|
|
|
|
|
//setto le variabili
|
|
|
|
selrighe.set_var("#CODCF",codcf);
|
|
|
|
selrighe.set_var("#CODCONT",codcont);
|
|
|
|
|
|
|
|
//richiamo la funzione che effettivamente fa la cancellazione delle righe interessate
|
|
|
|
kill_planning(selrighe);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TContratti_app::kill_planning (TISAM_recordset& selrighe) const
|
|
|
|
{
|
|
|
|
const TRecnotype righe = selrighe.items();
|
|
|
|
if (righe > 0)
|
|
|
|
{
|
|
|
|
TProgind pi(righe, TR("Eliminazione planning in corso..."), true, true);
|
|
|
|
TLocalisamfile& rplan = selrighe.cursor()->file();
|
|
|
|
for (bool ok = selrighe.move_last(); ok; ok = selrighe.move_prev())
|
|
|
|
{
|
|
|
|
if (!pi.addstatus(1))
|
|
|
|
break;
|
|
|
|
rplan.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-27 15:21:44 +00:00
|
|
|
bool TContratti_app::remove()
|
|
|
|
{
|
|
|
|
bool ok=TRelation_application::remove();
|
|
|
|
if(ok)
|
|
|
|
{
|
|
|
|
TString query;
|
2008-09-02 10:38:36 +00:00
|
|
|
build_query(*_msk,query);
|
2008-08-27 15:21:44 +00:00
|
|
|
TISAM_recordset righeset(query);
|
|
|
|
TLocalisamfile& file=righeset.cursor()->file();
|
2008-12-10 11:57:25 +00:00
|
|
|
|
2008-08-27 15:21:44 +00:00
|
|
|
for (bool ok=righeset.move_first(); ok; ok=righeset.move_next())
|
|
|
|
{
|
|
|
|
file.remove();
|
|
|
|
}
|
|
|
|
|
2008-12-10 12:03:36 +00:00
|
|
|
elimina_planning(_msk->get_long(F_CODCONT),_msk->get_long(F_CODCF));
|
2008-08-27 15:21:44 +00:00
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2008-08-21 15:41:07 +00:00
|
|
|
int lv0400(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TContratti_app app;
|
|
|
|
app.run (argc,argv,TR("Gestione contratti"));
|
|
|
|
return 0;
|
|
|
|
}
|