diff --git a/src/f9/f90100.h b/src/f9/f90100.h index 9ef7cc1e9..4dda0e77b 100644 --- a/src/f9/f90100.h +++ b/src/f9/f90100.h @@ -67,6 +67,7 @@ public: TApri_estr_msk(); ~TApri_estr_msk() {} }; + class TMonitor_mask : public TAutomask { // friend class TF9_app; diff --git a/src/f9/f90600.cpp b/src/f9/f90600.cpp index 8b7f977cd..4ba103855 100644 --- a/src/f9/f90600.cpp +++ b/src/f9/f90600.cpp @@ -656,15 +656,15 @@ bool TControlloIntegrazioni_mask::associa_int_acq(const long numreg, TToken_stri void TControlloIntegrazioni_mask::conferma_esclusi() const { - TSheet_field& sf = sfield(S_INCL); + const TMask& mask = *this; + TSheet_field& sf = mask.sfield(S_CONTROLLO); FOR_EACH_SHEET_ROW_LOOP(sf, row) { - const long nreg = sf.get_long_row_cell(row, FI_NUMREG); + const long nreg = sf.get_long_row_cell(row, F_CNUMREG); TRectype & movs = (TRectype&)cache().get(LF_MOV, nreg); - const TString & da_escludere = sf.get_str_row_cell(row, FI_IESCLUDI); - if (da_escludere == "S") + if (sf.get_bool_row_cell(row, F_CESCLUDI)) { TToken_string stato("", ';'); @@ -673,19 +673,33 @@ void TControlloIntegrazioni_mask::conferma_esclusi() const stato.add("X"); movs.put(MOV_ELABF9, stato); movs.rewrite(); - sf.set_row_cell(FI_IESCLUSO, true, row); + sf.set_row_cell(F_CESCLUSO, "Si", row); + + TString query; + + query << "UPDATE " F9_ERR " SET ESCLUSO = 'Si' WHERE " ERR_CODSOC " = '" << _cod_soc << "' AND IDESTR = '" << + _id_estr << "' AND NUMREG = '" << nreg << "';"; + fp_db().sq_set_exec(query); + fp_db().sq_commit(); } else { if (movs.get(MOV_ELABF9).full()) { - movs.zero(MOV_ELABF9); - sf.set_row_cell(FI_IESCLUSO, false, row); + movs.put(MOV_ELABF9, ""); + sf.set_row_cell(F_CESCLUSO, "", row); + movs.rewrite(); + TString query; + query << "UPDATE " F9_ERR " SET ESCLUSO = NULL WHERE " ERR_CODSOC " = '" << _cod_soc << "' AND IDESTR = '" << + _id_estr << "' AND NUMREG = '" << nreg << "';"; + fp_db().sq_set_exec(query); + fp_db().sq_commit(); } } } sf.force_update(); + sf.show(); } TToken_string* TControlloIntegrazioni_mask::selected_mov() @@ -1121,6 +1135,40 @@ TControlloIntegrazioni_mask::TControlloIntegrazioni_mask(const char* codsoc, con // TApri_pacchetto_msk //////////////////////////////////////////////////////// +void TApri_pacchetto_msk::conferma_esclusi() const +{ + TSheet_field& sf = sfield(S_INCL); + + FOR_EACH_SHEET_ROW_LOOP(sf, row) + { + const long nreg = sf.get_long_row_cell(row, FI_NUMREG); + TRectype & movs = (TRectype&)cache().get(LF_MOV, nreg); + const TString & da_escludere = sf.get_str_row_cell(row, FI_IESCLUDI); + + if (da_escludere == "S") + { + TToken_string stato("", ';'); + + stato.add("", 0); + stato.add(today.date2ansi()); + stato.add("X"); + movs.put(MOV_ELABF9, stato); + movs.rewrite(); + sf.set_row_cell(FI_IESCLUSO, true, row); + } + else + { + if (movs.get(MOV_ELABF9).full()) + { + movs.zero(MOV_ELABF9); + sf.set_row_cell(FI_IESCLUSO, false, row); + movs.rewrite(); + } + } + } + sf.force_update(); +} + bool TApri_pacchetto_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) @@ -1137,15 +1185,37 @@ bool TApri_pacchetto_msk::on_field_event(TOperable_field& o, TField_event e, lon break; case B_ISELESCL: if (e == fe_button) - //inselect_handler(); + { + static bool sel_esclusi = false; + if (_provv || TArchiviazioneIntegrazioni::is_stato_errore(_statoestr)) + { + sel_esclusi = !sel_esclusi; + field(B_IESCL).enable(sel_esclusi); + field(B_IALLESCL).enable(sel_esclusi); + sfield(S_INCL).enable_column(cid2index(FI_IESCLUDI), sel_esclusi); + sfield(S_INCL).force_update(); + return true; + } + warning_box("E' possibile escludere i movimenti solo per pacchetti bloccati\nin stato di errore '" D_WA_ERR " - %s'", + TArchiviazioneIntegrazioni::traduci_stato(D_WA_ERR)); + } break; case B_IESCL: if (e == fe_button) - //inescludi_handler(); + conferma_esclusi(); break; case B_IALLESCL: if (e == fe_button) - //inall_handler(); + { + TSheet_field& sf = sfield(S_INCL); + const bool active = *sf.row(0).get(cid2index(FI_IESCLUDI)) == 'S'; + + FOR_EACH_SHEET_ROW_LOOP(sf, row) + sf.set_row_cell(FI_IESCLUDI, active ? "N" : "S", row); + sf.force_update(); + return true; + } + break; default: break; } return true; diff --git a/src/f9/f90600.h b/src/f9/f90600.h index e3555a6de..5fd33e398 100644 --- a/src/f9/f90600.h +++ b/src/f9/f90600.h @@ -38,7 +38,8 @@ class TApri_pacchetto_msk : public TAutomask //bool inall_handler() const; //bool inescludi_handler() const; //bool inselect_handler() const; - //void conferma_esclusi() const; + void conferma_esclusi() const; + public: void fill_estr() const; void fill_res() const; @@ -169,6 +170,7 @@ public: TArray & esclusi() { return _esclusi; } static const char* traduci_stato(const TString& cod); + static bool is_stato_errore(const TString& stato_etr) { return stato_etr == D_GEST_ERR || stato_etr == D_WA_ERR || stato_etr == D_ERR_SOS; } void run_estr_msk() { _estr_msk->run(); }