diff --git a/mr/mr2200.cpp b/mr/mr2200.cpp index cad0734aa..ffdd95446 100755 --- a/mr/mr2200.cpp +++ b/mr/mr2200.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "../ve/veconf.h" @@ -432,6 +433,13 @@ int TPlanning_mask::test_status(const TRectype& doc, int s) const return -1; } +bool TPlanning_mask::test_special(const TString & num) const +{ + const TRectype & rec = cache().get("%NUM", num); + + return rec.get_bool("B8"); +} + bool TPlanning_mask::has_confirmed_status(const TRectype &doc, TToken_string &riga) const { const char statodoc = doc.get_char(DOC_STATO); @@ -675,17 +683,19 @@ bool TPlanning_mask::carica_documenti() if (skip) { const long p = riga.get_long(RDOC_PRIORITY); - line = _constraints.find(cli, art, liv, imp, ignore_lin ? "" : lin, mag, magc, da_rdoc_key, false); - if ( line != NULL) + TMSP_constraint* linec = _constraints.find(cli, art, liv, imp, ignore_lin ? "" : lin, mag, magc, da_rdoc_key, false); + + if (linec != NULL) { - - if (p > line->priority()) - line->priority(p); - else - continue; + if (p > linec->priority()) + { + linec->priority(p); + line = _articles.find(cli, art, liv, imp, lin, mag, magc, da_rdoc_key, true); + if (line->description().blank()) + line->set_description(riga.get(RDOC_DESCR)); + } } - else - continue; + continue; } line = _articles.find(cli, art, liv, imp, lin, mag, magc, da_rdoc_key, true); } @@ -753,8 +763,8 @@ bool TPlanning_mask::carica_documenti() } } } - if (p > line->priority()) - line->priority(p); + if (p > line->priority()) + line->priority(p); } if (!skip) @@ -914,16 +924,22 @@ int TPlanning_mask::find_constr_row(TMSP_constraint& cons) } // aggiunge le tre linee TToken_string& row = sf.row(-1); + TString8 codnum = cons.da_rdoc_key().left(4); + codnum.trim(); + const bool special = test_special(codnum); + + highlight_row(sf.items() - 1, special); cons.fill_sheet_row(row, *this, TR("** Ordini ")); cons.set_on_sheet(); sf.disable_cell(sf.items()-1, -1); //linea della giacenza prog TToken_string& rowgiac = sf.row(-1); copy_sheet_row(rowgiac,row, TR("** Giacenza teorica")); + highlight_row(sf.items() - 1, special); sf.disable_cell(sf.items()-1, -1); //linea articolo (vuota) TMSP_line line(cons); - line.fill_sheet_row(sf.row(-1), *this, ""); + highlight_row(sf.items() - 1, special); r = sf.items()-3+2; // vacca if (cons.codclifor()) @@ -1008,6 +1024,7 @@ void TPlanning_mask::fill_sheet() TMSP_constraint* last_constraint = NULL; TWait_cursor hourglass; + bool special = false; // ************* // parte 1: introduce gli articoli ed i loro vincoli associati const long totart = _articles.sort(); @@ -1015,6 +1032,10 @@ void TPlanning_mask::fill_sheet() { TMSP_line& line = _articles[i]; TMSP_constraint* curr_constraint = find_constraint(line,true); + TString8 codnum = curr_constraint->da_rdoc_key().left(4); + + codnum.trim(); + const bool special = test_special(codnum); int new_row = -1; for (int nrow = sf.items() - 1; nrow >=0; nrow--) @@ -1036,10 +1057,12 @@ void TPlanning_mask::fill_sheet() TToken_string& consrow = sf.row(-1); curr_constraint->fill_sheet_row(consrow, *this, TR("** Ordini ")); + highlight_row(sf.items()-1, special); sf.disable_cell(sf.items()-1, -1); // aggiunge la linea della giacenza prog TToken_string& rowgiac = sf.row(-1); copy_sheet_row(rowgiac,consrow, TR("** Giacenza teorica")); + highlight_row(sf.items()-1, special); sf.disable_cell(sf.items()-1, -1); // last_constraint = curr_constraint; curr_constraint->set_on_sheet(); @@ -1048,6 +1071,7 @@ void TPlanning_mask::fill_sheet() sf.insert(new_row); TToken_string& row = sf.row(new_row); line.fill_sheet_row(row, *this, ""); + highlight_row(new_row, special); disable_codes(new_row); if (curr_constraint->codclifor()) sf.disable_cell(new_row,sf.cid2index(F_CLIENTE)); @@ -1061,19 +1085,27 @@ void TPlanning_mask::fill_sheet() if (!cons.is_on_sheet()) { // aggiunge le tre linee + TString8 codnum = cons.da_rdoc_key().left(4); + + codnum.trim(); + const bool special = test_special(codnum); TToken_string& consrow = sf.row(-1); cons.fill_sheet_row(consrow, *this, TR("** Ordini ")); cons.set_on_sheet(); + highlight_row(sf.items()-1, special); sf.disable_cell(sf.items()-1, -1); //linea della giacenza prog TToken_string& rowgiac = sf.row(-1); copy_sheet_row(rowgiac,consrow, TR("** Giacenza teorica")); + highlight_row(sf.items()-1, special); sf.disable_cell(sf.items()-1, -1); //linea articolo (vuota) TMSP_line line(cons); line.fill_sheet_row(sf.row(-1), *this, ""); if (consrow.get_long(sf.cid2index(F_CLIENTE))) sf.disable_cell(sf.items()-1,sf.cid2index(F_CLIENTE)); + + highlight_row(sf.items()-1, special); } } TArticolo_giacenza art; @@ -1143,11 +1175,29 @@ bool TPlanning_mask::remove_propose(bool verbose) return true; } -void TPlanning_mask::highlight(int row, int col, bool on) +void TPlanning_mask::highlight_row(int row, bool on) { - COLOR back = on ? _sel_color.get_back_color(_npr_pos) : NORMAL_BACK_COLOR; - COLOR fore = on ? _sel_color.get_fore_color(_npr_pos) : NORMAL_COLOR; + COLOR back = on ? _sel_color.get_back_color(_con_pos) : NORMAL_BACK_COLOR; + COLOR fore = on ? _sel_color.get_fore_color(_con_pos) : NORMAL_COLOR; + sfield(F_ARTICOLI).set_back_and_fore_color(back, fore, row); +} + +void TPlanning_mask::highlight(int row, int col, bool on, bool special) +{ + COLOR back; + COLOR fore; + + if (special) + { + back = on ? _sel_color.get_back_color(_npr_pos) : _sel_color.get_back_color(_con_pos); + fore = on ? _sel_color.get_fore_color(_npr_pos) : _sel_color.get_fore_color(_con_pos); + } + else + { + back = on ? _sel_color.get_back_color(_npr_pos) : NORMAL_BACK_COLOR; + fore = on ? _sel_color.get_fore_color(_npr_pos) : NORMAL_COLOR; + } sfield(F_ARTICOLI).set_back_and_fore_color(back, fore, row, col); } @@ -1228,7 +1278,12 @@ void TPlanning_mask::add_or_sub_propose(char sign, bool scheduled) } TToken_string& artrow = sf.row(art_row); const int lastbuck = _proposed_articles[new_row].last_bucket(); - + TString8 codnum = constraint->da_rdoc_key().left(4); + + codnum.trim(); + const bool special = test_special(codnum); + + highlight_row(art_row, special); for (int nbucket=0; nbucket<=lastbuck ; nbucket++) { int b = bucket( _proposed_articles[new_row].time(nbucket).date() ); @@ -1249,7 +1304,7 @@ void TPlanning_mask::add_or_sub_propose(char sign, bool scheduled) art_per_buck = ZERO; } } - highlight(art_row, F_BUCKET1 + b*2, prop != ZERO && art_per_buck != ZERO); + highlight(art_row, F_BUCKET1 + b*2, prop != ZERO && art_per_buck != ZERO, special); artrow.add(art_per_buck.string(), F_BUCKET1 + b*2 - FIRST_FIELD); real price; if (!art_per_buck.is_zero()) @@ -2674,7 +2729,7 @@ void TPlanning_mask::copy_sheet_row(TToken_string & newrow, const TToken_string newrow.get(F_DESCART - FIRST_FIELD, str); const int pos = str.find('¦'); - TString80 val(desc); + TString val(desc); if (pos >= 0) val << '¦' << str.mid(pos + 1); @@ -2841,11 +2896,10 @@ int TPlanning_mask::salva_cella(int r, int b, TPlan_docs &doc_rows, TToken_strin riga.put(RDOC_IMPIANTO, line.codimp()); riga.put(RDOC_UMQTA, row.get(sf.cid2index(F_UM))); riga.put(RDOC_DATACONS, datacons); - TString descr(row.get(sf.cid2index(F_DESCART))); - const int pos = descr.find('¦'); + TString descr(line.description()); - if (pos >= 0) - descr = descr.left(pos); + if (descr.blank()) + descr = cache().get(LF_ANAMAG, line.articolo(), ANAMAG_DESCR); riga.put(RDOC_DESCR, descr); TMSP_constraint *c = find_constraint(line); @@ -3363,7 +3417,8 @@ bool TPlanning_mask::on_field_event(TOperable_field& o, TField_event e, long jol m.get(F_TIPOCF_SHEET), m.get_long(F_CLIENTE), m.get(F_ARTICOLO), qta , price); fprice.set(price.string()); - highlight(s.selected(), o.dlg(), qta != ZERO); + if (qta != ZERO) + highlight(s.selected(), o.dlg(), true, false); } break; case DLG_CANCEL: @@ -3971,6 +4026,7 @@ void TPlanning_mask::init() load_profile(); _npr_pos =_sel_color.add_color_def("PROP", TR("Nuove proposte"), COLOR_YELLOW, COLOR_BLACK); + _con_pos =_sel_color.add_color_def("CONST", TR("Vincoli speciali"), blend_colors(COLOR_WHITE, COLOR_YELLOW, 0.60), COLOR_BLACK); TCalendar_field & cf = (TCalendar_field &) field(F_CALENDAR); @@ -4474,6 +4530,19 @@ int TCRPCheck_mask::fill_mask(const bool show_fields) // Applicazione principale /////////////////////////////////////////////////////////// +bool TPlanning_app::menu(MENU_TAG mt) +{ + bool ok = TRUE; + if (mt == MENU_ITEM(1)) + { + TSelect_color_mask & s = _m->sel(); + s.run(); + } + else + ok = TSkeleton_application::menu(mt); + return ok; +} + void TPlanning_app ::openfiles() { open_files(LF_TABCOM, LF_TAB, LF_DOC, LF_RIGHEDOC, LF_CLIFO, LF_CFVEN, LF_OCCAS, LF_INDSP, LF_CONDV, diff --git a/mr/mr2200.h b/mr/mr2200.h index 61f712356..3a80b6c90 100755 --- a/mr/mr2200.h +++ b/mr/mr2200.h @@ -41,6 +41,7 @@ class TPlanning_mask : public TCalendar_mask TSelect_color_mask _sel_color; int _npr_pos; + int _con_pos; protected: enum Categoria_doc {_Doc_vincoli=1, _Doc_planning=2}; @@ -58,7 +59,8 @@ protected: bool general_review(bool check_machine, bool check_human, bool useextralines, bool useextrahours,bool lotsizing, bool no_outcapacity, int anticipomin,int anticipomax, TMSP_mode mode, TMSP_logic logic, const char *msg ); int insert_propose(bool verbose=FALSE) ; bool remove_propose(bool verbose=FALSE) ; - void highlight(int row, int col, bool on) ; + void highlight_row(int row, bool on); + void highlight(int row, int col, bool on, bool special) ; void add_or_sub_propose(char sign, bool scheduled=FALSE); void propose(int row = -1); @@ -129,6 +131,7 @@ public: bool test_tipodoc_num( const TSheet_field &sheet_num , const TSheet_field &sheet_type) ; int test_status(const TRectype& doc, int tipo) const; + bool test_special(const TString & tipodoc) const; bool has_confirmed_status(const TRectype& doc, TToken_string &riga) const; bool has_confirmed_status(const TRectype &doc) const; bool has_confirmed_status(const char * codnum, const char *tipodoc, char stato) const; @@ -162,6 +165,8 @@ protected: virtual TPlanning_mask& mask() {return *_m;} virtual void main_loop(); virtual bool firm_change_enabled() const { return FALSE; } + virtual bool TPlanning_app::menu(MENU_TAG mt); + public: TPlanning_app() : _m(NULL) {} }; diff --git a/mr/mr2200a.uml b/mr/mr2200a.uml index 1690fd97b..122c12f67 100755 --- a/mr/mr2200a.uml +++ b/mr/mr2200a.uml @@ -1558,7 +1558,7 @@ BEGIN FLAGS "U" END -STRING F_DESCART 70 50 +STRING F_DESCART 150 50 BEGIN PROMPT 1 2 "Descrizione " FLAGS "DG" diff --git a/mr/mr2201.cpp b/mr/mr2201.cpp index 0bb1c3d84..124f7f680 100755 --- a/mr/mr2201.cpp +++ b/mr/mr2201.cpp @@ -858,18 +858,58 @@ void TMSP_constraint::fill_sheet_row(TToken_string& row, const TMask & m, const const TString80 da_rdoc_key(da_rdoc_key()); if (da_rdoc_key.full()) + { + TDocumento d('D', atoi(da_rdoc_key.smid(4,4)), da_rdoc_key.sleft(4).trim(), atoi(da_rdoc_key.smid(9,7))); + TDate cons(d.get_date("DATAORIG")); + + if (!cons.ok()) + cons = d.get_date(DOC_DATACONS); + + if (cons.ok()) + val << ' ' << cons.string() << ' '; val << '¦' << da_rdoc_key; + } if ((descr == NULL || *descr == '\0') && __userflds != NULL && __userflds->full()) { TString userdesc; TString16 fldname; + TString16 codnum; + TString fldval; const TRectype & anamag = cache().get(LF_ANAMAG, articolo()); + TToken_string fld("", '#'); - for (int n = __userflds->get_int(0); n > 0; n = __userflds->get_int()) + for (fld = __userflds->get(0); fld.full(); fld = __userflds->get()) { - fldname.format("USER%d", n); - const TString & fldval = anamag.get(fldname); + + fldname = fld.get(0); + codnum = fld.get(); + + if (codnum.blank()) + fldval = anamag.get(fldname); + else + { + fldval.cut(0); + TRelation rel(LF_RIGHEDOC); + TRectype& curr = rel.curr(); + + curr.put(RDOC_DAPROVV, 'D'); + curr.put(RDOC_DAANNO, da_rdoc_key.smid(4,4)); + curr.put(RDOC_DACODNUM, da_rdoc_key.sleft(4)); + curr.put(RDOC_DANDOC, da_rdoc_key.smid(9,7)); + curr.put(RDOC_DAIDRIGA, da_rdoc_key.smid(16)); + + TRectype filter_fr(curr), filter_to(curr); + TCursor cur(&rel, "", 4, &filter_fr, &filter_to); + const int items = cur.items(); + + for (cur = 0L; cur.pos() < items; ++cur) + if (cur.curr().get(RDOC_CODNUM) == codnum) + { + fldval = cur.curr().get(fldname); + break; + } + } if (fldval.full()) { @@ -1264,7 +1304,8 @@ TMSP_constraint* TMSP_constraints::find(long cliente, TMSP_constraint* TMSP_constraints::find(const TToken_string& row, bool create) { - TString80 str,giaclev; + TString80 giaclev; + TString str; _key.cut(0); for (int i = 0; i <= 11; i++) @@ -1398,7 +1439,8 @@ TMSP_line* TMSP_lines::find(const TToken_string& row, bool create) } } - TString80 str,giaclev; + TString str; + TString80 giaclev; _key.cut(0); for (int i = 0; i <= 13; i++)