//============================================================================== // Общие функции для формирования файлов выгрузки для интеграции с МТБЗ (ХМАО Югра) //============================================================================== AskReportMonth(&monthStr) { if (strlen(monthStr)==0) { string saveStrDate0=Str_Date_0; string saveStrDate1=Str_Date_1; sprintf(Str_Date_0, "%d.%d", Month_Cash,Year_Cash); sprintf(Str_Date_1, "%d.%d", Month_Cash,Year_Cash); if (AskPeriod(256,"Введите месяц, за который сформировать отчет")==ESC) return -1; monthStr=Str_Date_0; strcpy(Str_Date_0,saveStrDate0); strcpy(Str_Date_1,saveStrDate1); } return 0; } GetNameFileRefTimeFromCnf(cnfName, org, date, refNameForErrorMsg) { int numRefTime = GetCommonCnfInt(cnfName, "mtbz"); if (numRefTime == 0) { var err="В настройках интеграции с МТБЗ не заполнен номер для сетки соответствия " + refNameForErrorMsg; AmbaMessageBox(err, "Ошибка!", 0, 0); BreakTableReceive(); } char FileSetka[256]; FileSetka = GetNameFileRefTime(numRefTime, org, date); RTrim(FileSetka); if (strlen(FileSetka)==0) { var err="Не найдена сетка соответствия " + refNameForErrorMsg + " (в 'Сетках -> Прочие справочники'). "; err += "Не найдена таблица с номером " + static_cast_to_string(numRefTime) + " на дату " + date + " для организации с номером " + static_cast_to_string(org); AmbaMessageBox(err, "Ошибка!", 0, 0); BreakTableReceive(); } return FileSetka; } GetKOSGU(shzStr, srcExt, mStr, mvStr, orgForRefTime, dateForRefTime) { var prop = CreateObject("APropBE"); prop.SetSrc(ExtSrcToInt(srcExt[0])); return GetKOSGUProp(shzStr, prop, mStr, mvStr, orgForRefTime, dateForRefTime); } GetKOSGUProp(shzStr, prop, mStr, mvStr, orgForRefTime, dateForRefTime) { if (ScriptCheckName("User_MTBZ_GetKOSGU")) { return User_MTBZ_GetKOSGU(shzStr, prop, mStr, mvStr, orgForRefTime, dateForRefTime); } int getFromRefTime = GetCommonCnfInt("KOSGUFrom", "mtbz"); if (getFromRefTime == 0) return Get_KOSGU_KFO_FromShz(shzStr, /*getKOSGU = */ true); else { return Get_KOSGU_KFO_FromRefTime(IntSrcToExt(prop.GetSrc()), orgForRefTime, dateForRefTime, /*getKOSGU = */ true); } } GetKFO(shzStr, srcExt, mStr, mvStr, orgForRefTime, dateForRefTime) { var prop = CreateObject("APropBE"); prop.SetSrc(ExtSrcToInt(srcExt[0])); return GetKFOProp(shzStr, prop, mStr, mvStr, orgForRefTime, dateForRefTime); } GetKFOProp(shzStr, prop, mStr, mvStr, orgForRefTime, dateForRefTime) { if (ScriptCheckName("User_MTBZ_GetKFO")) { return User_MTBZ_GetKFO(shzStr, prop, mStr, mvStr, orgForRefTime, dateForRefTime); } int getFromRefTime = GetCommonCnfInt("KOSGUFrom", "mtbz"); if (getFromRefTime == 0) return Get_KOSGU_KFO_FromShz(shzStr, /*getKOSGU = */ false); else return Get_KOSGU_KFO_FromRefTime(IntSrcToExt(prop.GetSrc()), orgForRefTime, dateForRefTime, /*getKOSGU = */ false); } Get_KOSGU_KFO_FromShz(shzStr, getKOSGU) { //из ШЗ var shzObj = CreateObject("ShifrZatrat"); shzObj.ComInitial(static_cast_to_string(shzStr), 1); var cnfPartShz = GetCommonCnfStr(getKOSGU ? "ShzKOSGU" : "ShzKFO", "mtbz"); return shzObj.GetPseudPartShz(cnfPartShz); } Get_KOSGU_KFO_FromRefTime(srcExt, orgForRefTime, dateForRefTime, getKOSGU) { //из сетки соответствия string refTimeFileName = GetNameFileRefTimeFromCnf("sSRC_KOSGU", orgForRefTime, dateForRefTime, "'Источник - КОСГУ - КФО'"); char strValue[256]; GetValueClassif(refTimeFileName,CharAsString(srcExt),strValue,255,getKOSGU ? "KOSGU" : "KFO", "Src"); if (strlen(strValue) == 0) { var err="Не найден источник с кодом '" + static_cast_to_string(srcExt) + "' в сетке соответствия 'Источник - КОСГУ - КФО' (в 'Сетках -> Прочие справочники')"; AmbaMessageBox(err, "Ошибка!", 0, 0); BreakTableReceive(); } return strValue; } MtbzSrcName(srcExt, orgForRefTime, dateForRefTime) { int getFromRefTime = GetCommonCnfInt("KOSGUFrom", "mtbz"); if (getFromRefTime != 0) { string refTimeFileName = GetNameFileRefTimeFromCnf("sSRC_KOSGU", orgForRefTime, dateForRefTime, "'Источник - КОСГУ - КФО'"); char strValue[256]; GetValueClassif(refTimeFileName, srcExt, strValue, 255, "NameMTBZ", "Src"); var result = RTrimS(strValue); if (strlen(result) > 0) return result; } return GetSrcName(ExtSrcToInt(srcExt[0])); } GetDoljnStartDate(onDate, Combine) { var tmpComb=CreateObject("TmpCurCombine"); tmpComb.Init(ExtCombineToInt(Combine)); var date = R_FaceCnfFld("psDEntry","mtbz",onDate,0); var kdate = KDateFromStr(date); if (kdate.IsValid()) return kdate.GetStr(); char dateRb[32]; kch_from("data_rb",dateRb); return dateRb; } FillVidMapFromCnf(&mapObj, cnfName) { mapObj = CreateObject("MapLong"); var vidsStr = GetCommonCnfStr(cnfName,"mtbz"); var codeNuArray; int countElem = ListNUToSafeArray(vidsStr,0,codeNuArray); for (int i=0; i MAXKOD) return 0; int include = IsCodeNach(Extern_To_Intern(extCodeInteger)); if (!include) include = IsIncludeVid(extCodeInteger); if (!include || IsExcludeVid(extCodeInteger)) return 0; return 1; } GetHoursWorked(dateBegin, dateEnd, extCombine) { var tmpComb=CreateObject("TmpCurCombine"); tmpComb.Init(ExtCombineToInt(extCombine)); var kDateBegin = KDateFromStr(dateBegin); var kDateEnd = KDateFromStr(dateEnd); if (!kDateBegin.IsValid() || !kDateEnd.IsValid()) return 0; s50(Transl_Date_To_Abs(dateBegin)); double hoursWorked; skoljko(hoursWorked, to_int(kDateBegin.GetDouble()), kDateBegin.GetDay(), kDateEnd.GetDay(), rsimv, calm, cht); return hoursWorked; } GetDaysWorked(dateBegin, dateEnd, extCombine) { var tmpComb=CreateObject("TmpCurCombine"); tmpComb.Init(ExtCombineToInt(extCombine)); var kDateBegin = KDateFromStr(dateBegin); var kDateEnd = KDateFromStr(dateEnd); if (!kDateBegin.IsValid() || !kDateEnd.IsValid()) return 0; s50(Transl_Date_To_Abs(dateBegin)); return count_simv(rsimv, calm, kDateBegin.GetDay() - 1, kDateEnd.GetDay() - 1); } GetHoursNorm(dateBegin, dateEnd, extCombine) { var tmpComb=CreateObject("TmpCurCombine"); tmpComb.Init(ExtCombineToInt(extCombine)); var kDateBegin = KDateFromStr(dateBegin); var kDateEnd = KDateFromStr(dateEnd); if (!kDateBegin.IsValid() || !kDateEnd.IsValid()) return 0; s50(Transl_Date_To_Abs(dateBegin)); double hoursNorm; skoljko(hoursNorm, to_int(kDateBegin.GetDouble()), kDateBegin.GetDay(), kDateEnd.GetDay(), "2", calmras, 0); return hoursNorm; } GetDaysNorm(dateBegin, dateEnd, extCombine) { var tmpComb=CreateObject("TmpCurCombine"); tmpComb.Init(ExtCombineToInt(extCombine)); var kDateBegin = KDateFromStr(dateBegin); var kDateEnd = KDateFromStr(dateEnd); if (!kDateBegin.IsValid() || !kDateEnd.IsValid()) return 0; s50(Transl_Date_To_Abs(dateBegin)); return count_simv("2", calmras, kDateBegin.GetDay() - 1, kDateEnd.GetDay() - 1); } GetDepRefTimeValue(podr, valueFldName, orgForRefTime, dateForRefTime) { string refTimeFileName = GetNameFileRefTimeFromCnf("sUIDPODR", orgForRefTime, dateForRefTime, "'Подразделение - OID'"); char value[256]; GetValueClassif(refTimeFileName, to_string(podr), value, 255, valueFldName, "FCpodr"); return RTrimS(value); } GetDepartmentName(podrCode, orgForRefTime, dateForRefTime) { int podr = atoi(podrCode); var nameFromRefTime = GetDepRefTimeValue(podr, "podrMTBZ", orgForRefTime, dateForRefTime); return (strlen(nameFromRefTime) > 0) ? nameFromRefTime : RTrimS(OtdNameByCod(podrCode)); } GetDoljnRefTimeValue(doljnKey, keyFldName, valueFldName, orgForRefTime, dateForRefTime) { string refTimeFileName = GetNameFileRefTimeFromCnf("sUIDSHP", orgForRefTime, dateForRefTime, "'МТБЗ. Штатная единица - UID'"); char value[256]; GetValueClassif(refTimeFileName, to_string(doljnKey), value, 255, valueFldName, keyFldName); return RTrimS(value); } GetDoljnId(date, extCombine) { int combine = ExtCombineToInt(extCombine); var doljnElem = GetDoljnFromKCH(date,combine); if (doljnElem.IsEmpty()) return ""; return doljnElem.GetID(); } GetPositionName(dolgnost, orgForRefTime, dateForRefTime) { int doljnId = atoi(dolgnost); var doljnElem = GetDoljnFromSpravByID(doljnId); if(doljnElem.IsEmpty()) return ""; var nameFromRefTime = GetDoljnRefTimeValue(doljnElem.GetExtCode(), "DoljnExtCod", "doljnMTBZ", orgForRefTime, dateForRefTime); if (strlen(nameFromRefTime) > 0) return nameFromRefTime; if(doljnElem.GetFrmrCode() != 0) return RTrimS(doljnElem.GetFrmrName()); return RTrimS(doljnElem.GetName()); } GetGrafikName(grafik, orgForRefTime, dateForRefTime) { int calend = atoi(grafik); string refTimeFileName = GetNameFileRefTimeFromCnf("sNormCal", orgForRefTime, dateForRefTime, "'МТБЗ. Календарь - Название'"); char calendName[256]; GetValueClassif(refTimeFileName, to_string(calend), calendName, 255, "NCalMTBZ", "NormCal"); var name = RTrimS(calendName); if (strlen(name) == 0) return GetNameCalend(calend); return name; } CalcTypeEmployment(CTabl, fldKod, fldInc, rcr) { //todo избавиться от магических чисел // PrimaryWorkplace = 0, // InternalPartTime, // ExternalPartTime int kodRab = atoi(CTabl.Text(fldKod,rcr)); if (kodRab == 4 || kodRab == 9) return 2; int incType = atoi(CTabl.Text(fldInc,rcr)); return incType == 0 ? 0 : 1; //todo а что если ГПХ? } ZeroGuidIfEmpty(str) { if (str == "") return "00000000-0000-0000-0000-000000000000"; return str; } GetAnsiValue(CTabl, fld, rcr) { return OemToAnsi(RTrimS(CTabl.Text(fld,rcr))); } GetGUIDValue(CTabl, fld, rcr) { return ZeroGuidIfEmpty(RTrimS(CTabl.Text(fld,rcr))); } var defaultDate; ValidDateOrDefault(ikdate) { if (!IsObject(defaultDate)) defaultDate = KDateFromStr("01.01.2000"); if (ikdate.IsValid() == false) return defaultDate; return ikdate; } RenameTableMTBZCommon(__AdrMainTable,__MainTableRcr, newTableName) { if ( __AdrMainTable ) { var TblMain=CreateObject("CurPrnTbl"); TblMain.Initial(__AdrMainTable); if ( __MainTableRcr>=0 && __MainTableRcr