5de9cc7284
Files correlati :cg5.exe Ricompilazione Demo : [ ] Commento :cambiato il modo di gestire la maschera configurazione parametri ditta di contabilita';utilizzata la nuova get_mask_name in confapp.cpp git-svn-id: svn://10.65.10.50/trunk@10999 c028cbd2-c16b-5b4b-a496-9718f37d4682
240 lines
6.1 KiB
C++
Executable File
240 lines
6.1 KiB
C++
Executable File
#include <confapp.h>
|
|
#include <isam.h>
|
|
#include <modaut.h>
|
|
#include <prefix.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
|
|
#include <attiv.h>
|
|
|
|
#include "cg5100a.h"
|
|
|
|
class TParametri_ditta : public TConfig_application
|
|
{
|
|
TArray _atts;
|
|
|
|
void swap_file(int logicnum, bool tocom);
|
|
void load_file(int logicnum);
|
|
void check_registers(int year);
|
|
|
|
public:
|
|
virtual bool check_autorization() const {return FALSE;}
|
|
virtual const char* get_mask_name() const {return "cg5100a";}
|
|
virtual bool preprocess_config (TMask& mask, TConfig& config);
|
|
virtual bool postprocess_config (TMask& mask, TConfig& config);
|
|
virtual bool postprocess_config_changed(const char* par, const char* var,
|
|
const char* oldv, const char* newv);
|
|
|
|
virtual bool user_create();
|
|
TParametri_ditta() : TConfig_application(CONFIG_DITTA) {}
|
|
virtual ~TParametri_ditta() {}
|
|
};
|
|
|
|
bool TParametri_ditta::user_create()
|
|
{
|
|
TRelation att(LF_ATTIV);
|
|
TRectype & r = att.curr();
|
|
|
|
r.put(ATT_CODDITTA, get_firm());
|
|
|
|
TCursor cur(&att, "", 1, &r, &r);
|
|
const TRecnotype items = cur.items();
|
|
|
|
cur.freeze();
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
// istanzia array _atts on le attivita' della ditta corrente
|
|
_atts.add(r.get(ATT_CODATT));
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void TParametri_ditta::check_registers(int year)
|
|
{
|
|
// controlla che per ogni data attivita' esistano almeno un registro
|
|
// acquisti, vendite e giornale; warning appropriato in caso negativo
|
|
const byte R_ACQ = 0x01;
|
|
const byte R_VEN = 0x02;
|
|
const byte R_ALL = R_ACQ | R_VEN;
|
|
TRelation relreg("REG");
|
|
TRectype & reg = relreg.curr();
|
|
bool is_giornale = FALSE;
|
|
|
|
for (int i = 0; i < _atts.items(); i++)
|
|
{
|
|
byte flags = 0x00;
|
|
const TString& att = (TString&)_atts[i];
|
|
TString filter;
|
|
|
|
reg.put("CODTAB", year);
|
|
filter.format("(S8==\"\")||(S8==\"%s\")", (const char *) att);
|
|
|
|
TCursor cur(&relreg, filter, 1, ®, ®);
|
|
const TRecnotype items = cur.items();
|
|
|
|
cur.freeze();
|
|
for (cur = 0L; (flags != R_ALL || !is_giornale) && (cur.pos() < items); ++cur)
|
|
{
|
|
if (reg.get_int("I0") == 5)
|
|
is_giornale = TRUE;
|
|
else
|
|
{
|
|
switch (reg.get_int("I0"))
|
|
{
|
|
case 1: // vendite
|
|
flags |= R_VEN; break;
|
|
case 2: // acquisti
|
|
flags |= R_ACQ; break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (flags < R_ALL)
|
|
{
|
|
TString wrn(TR("I seguenti registri non esistono per l'attivita' "));
|
|
wrn << att << "(" << year << "):";
|
|
if ((flags & R_VEN) == 0x00) wrn << TR("\n\tregistro vendite");
|
|
if ((flags & R_ACQ) == 0x00) wrn << TR("\n\tregistro acquisti");
|
|
warning_box(wrn);
|
|
}
|
|
}
|
|
|
|
// libro giornale non si controlla per attivita'
|
|
if(!is_giornale)
|
|
warning_box(FR("Non esiste probabilmente nessun "
|
|
"libro giornale per l'anno %d"), year);
|
|
}
|
|
|
|
|
|
|
|
void TParametri_ditta::swap_file(int logicnum, bool tocom)
|
|
{
|
|
TDir dir;
|
|
TFilename file;
|
|
|
|
dir.get(logicnum, _lock, _nordir, _sysdirop);
|
|
file = dir.name();
|
|
file[0] = tocom ? '%' : '$';
|
|
dir.set(file, dir.eod(), dir.flags(), dir.des(), dir.expr());
|
|
dir.put(logicnum, _nordir, _sysdirop);
|
|
dir.get(logicnum, _lock, (tocom ? _comdir :_nordir), _sysdirop);
|
|
if (tocom)
|
|
{
|
|
file = dir.name();
|
|
file[0] = '%';
|
|
dir.set(file, dir.eod(), dir.flags(), dir.des(), dir.expr());
|
|
dir.put(logicnum, _comdir, _sysdirop);
|
|
}
|
|
else
|
|
dir.get(logicnum, _unlock, (tocom ? _comdir :_nordir), _sysdirop);
|
|
|
|
file = dir.filename();
|
|
if (dir.eox() == 0L || !file.exist())
|
|
{
|
|
set_autoload_new_files(FALSE);
|
|
TSystemisamfile s(logicnum);
|
|
s.build(10L);
|
|
set_autoload_new_files(TRUE);
|
|
}
|
|
}
|
|
|
|
void TParametri_ditta::load_file(int logicnum)
|
|
{
|
|
TDir dir;
|
|
dir.get(logicnum);
|
|
|
|
TSystemisamfile f(logicnum);
|
|
|
|
if (dir.eox() == 0L)
|
|
f.build(10L);
|
|
|
|
TFilename lf;
|
|
lf.format("%sstd/lf%04d.txt", firm2dir(-1), logicnum);
|
|
if (lf.exist())
|
|
f.load(lf, '|', '\0', '\n', TRUE, TRUE);
|
|
}
|
|
|
|
|
|
bool TParametri_ditta::preprocess_config (TMask& mask, TConfig& config)
|
|
{
|
|
if (has_module(CGAUT, CHK_DONGLE))
|
|
{
|
|
TLocalisamfile mov(LF_MOV);
|
|
const bool movempty = mov.empty();
|
|
mask.enable(CHK_ANCFCM, movempty);
|
|
mask.enable(CHK_PCTCCM, movempty);
|
|
if (mask.get(FLD_ANLIIV).empty())
|
|
mask.set(FLD_ANLIIV, TDate(TODAY).year());
|
|
|
|
// check auth for Saldaconto
|
|
if (!has_module(SCAUT, CHK_DONGLE))
|
|
// disable saldaconting
|
|
mask.disable(-GROUP_SALDACONTO);
|
|
}
|
|
else
|
|
mask.disable(-GROUP_CONTABILITA);
|
|
return TRUE;
|
|
}
|
|
|
|
bool TParametri_ditta::postprocess_config(TMask& mask, TConfig& config)
|
|
{
|
|
check_registers(mask.get_int(FLD_ANLIIV));
|
|
mask.field(FLD_ANLIIV).set_dirty(mask.get_int(FLD_ANLIIV) != config.get_int("AnLiIv"));
|
|
// MI3262
|
|
// La gestione liquidazione differita e' stata spostata sui parametri liquidazione
|
|
// ovvero cg5300.cpp
|
|
return TRUE;
|
|
}
|
|
|
|
bool TParametri_ditta::postprocess_config_changed(const char* par, const char* var,
|
|
const char* oldv, const char* newv)
|
|
{
|
|
const bool changed = strcmp(oldv, newv) != 0;
|
|
|
|
if (!changed)
|
|
return TRUE;
|
|
const TFixed_string v(var);
|
|
if (v == "AnCfCm")
|
|
{
|
|
if (yesno_box(TR("Confermare il cambiamento dell'anagrafica clienti/fornitori")))
|
|
{
|
|
swap_file(LF_CLIFO, *newv == 'X');
|
|
swap_file(LF_INDSP, *newv == 'X');
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
else if (v == "PcTcCm")
|
|
{
|
|
if (yesno_box(TR("Confermare il cambiamento del piano conti/causali")))
|
|
{
|
|
swap_file(LF_PCON, *newv == 'X');
|
|
swap_file(LF_CAUSALI, *newv == 'X');
|
|
swap_file(LF_RCAUSALI, *newv == 'X');
|
|
prefix().reopen();
|
|
if (*newv == 'X')
|
|
{
|
|
TDir d;
|
|
d.get(LF_PCON, _nolock, _comdir);
|
|
if (d.eod() == 0 && yesno_box(TR("Si desidera caricare gli archivi standard ?")))
|
|
{
|
|
load_file(LF_PCON);
|
|
load_file(LF_CAUSALI);
|
|
load_file(LF_RCAUSALI);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
int cg5100 (int argc, char* argv[])
|
|
{
|
|
TParametri_ditta appc;
|
|
appc.run(argc, argv, TR("Parametri Ditta"));
|
|
return 0;
|
|
}
|