[Igarden-commit] Garden/source/Reports PurchaseReport.h, 1.1.2.1, 1.1.2.2 PurchaseReport.cpp, 1.1.2
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2006-12-14 03:05:30
|
Update of /cvsroot/igarden/Garden/source/Reports In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv20403 Modified Files: Tag: Release_branch_v1 PurchaseReport.h PurchaseReport.cpp Log Message: Allow picking whether to include mulch in purchases, and only count unpurchased materials Index: PurchaseReport.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/Reports/Attic/PurchaseReport.cpp,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** PurchaseReport.cpp 17 Nov 2006 13:24:53 -0000 1.1.2.2 --- PurchaseReport.cpp 14 Dec 2006 03:05:28 -0000 1.1.2.3 *************** *** 56,59 **** --- 56,60 ---- const short kSortBy = 12; const short kFormat = 13; + const short kIncludeMulch = 14; using yaaf::XGCheckButton; *************** *** 101,104 **** --- 102,106 ---- _AllVendors = true; _showPictures = false; + _includeMulch = false; } *************** *** 121,124 **** --- 123,127 ---- long count, n, numLayers; XGUUID nilID; + XGCheckButton *check; GardenPlot *plot; Layout *layout; *************** *** 198,201 **** --- 201,207 ---- EnableFindButton(AllowPrint(), dlog); + + check = dynamic_cast<XGCheckButton*>(dlog->FindViewByID(kIncludeMulch)); + check->SetValue(_includeMulch ? 1 : 0); } *************** *** 212,215 **** --- 218,232 ---- void PurchaseReport::ControlClick(RGDialog *dialog, XGDialog *dlog, long viewID) { + XGCheckButton *check; + + switch(viewID) + { + case kIncludeMulch: + check = dynamic_cast<XGCheckButton*>(dlog->FindViewByID(kIncludeMulch)); + _includeMulch = !check->GetValue(); + check->SetValue(_includeMulch); + EnableFindButton(AllowPrint(), dlog); + break; + } } *************** *** 273,282 **** } ! XGCommandButton *printBtn = dynamic_cast<XGCommandButton*>(dlog->FindViewByID(10001)); ! MyAssert(printBtn != NULL); ! if(AllowPrint()) ! printBtn->EnableView(); ! else ! printBtn->DisableView(); } --- 290,294 ---- } ! EnableFindButton(AllowPrint(), dlog); } *************** *** 321,328 **** { bool found = false; UInt32 n, numRows; Material *mat; MaterialRef *ref; - InstanceData *instance; XGUUID plotID; --- 333,340 ---- { bool found = false; + bool matchSupplier; UInt32 n, numRows; Material *mat; MaterialRef *ref; XGUUID plotID; *************** *** 336,368 **** if(mat != NULL) { ! if(_AllPlots) ! found = true; ! else { ! instance = ref->LatestInstanceData(kInstanceSupplierIDs); ! if(instance != NULL) { - uint32 supplier, supplierCount; - XGUUID testID; - supplierCount = instance->GetNumSuppliers(); ! for(supplier = 0; supplier < supplierCount && !found; supplier++) { ! instance->GetIndexedSupplier(supplier, testID); ! if(testID == _vendorID) ! found = true; } ! if(!found) { ! ref->GetPlotID(plotID); ! if(_plotID == plotID) ! found = true; } } - else - found = true; } } } } --- 348,415 ---- if(mat != NULL) { ! sint32 numPurchased, numUnpurchased; ! InstanceData *instance; ! ! instance = ref->GetInstanceAttributes(false); ! if(instance != NULL) { ! uint32 supplier, supplierCount; ! XGUUID testID; ! ! matchSupplier = false; ! if(!instance->GetInt32(kNumPurchased, &numPurchased)) ! numPurchased = 0; ! numUnpurchased = ref->GetNumItems() - numPurchased; ! if(numUnpurchased > 0) { supplierCount = instance->GetNumSuppliers(); ! if(_AllVendors || supplierCount == 0) ! matchSupplier = true; ! else { ! for(supplier = 0; supplier < supplierCount && !found; supplier++) ! { ! instance->GetIndexedSupplier(supplier, testID); ! if(testID == _vendorID) ! matchSupplier = true; ! } } ! } ! } ! else ! { ! numUnpurchased = ref->GetNumItems(); ! matchSupplier = true; ! } ! ! if(matchSupplier) ! { ! ref->GetPlotID(plotID); ! if(_plotID == plotID || _AllPlots) ! found = true; ! } ! } ! } ! if(_includeMulch && !found) ! { ! Path *path; ! ! path = _list[n]->GetPathIfPresent(); ! if(path != NULL) ! { ! mat = path->GetBackdrop(); ! if(mat != 0) ! { ! if(mat->GetMaterialType() == kMaterialTypeMulch) ! { ! if(path->IsPathFillPossible()) { ! found = true; } } } } } + } *************** *** 397,402 **** XGUUID testPlotID; PathElement *elem; ! bool show; ! format = _templates[_currentItem]; cellSize = InchesToPixels(8, 1); --- 444,449 ---- XGUUID testPlotID; PathElement *elem; ! bool show, matchPlot, matchSupplier; ! format = _templates[_currentItem]; cellSize = InchesToPixels(8, 1); *************** *** 420,423 **** --- 467,473 ---- if(mat != NULL) { + matchSupplier = false; + matchPlot = false; + name = mat->GetDisplayName(kUsePreferencesSetting); *************** *** 443,447 **** supplierSet.AddString(companyName); } ! show = true; } else --- 493,497 ---- supplierSet.AddString(companyName); } ! matchSupplier = true; } else *************** *** 461,465 **** str = supplier->GetCompanyName(); supplierSet.AddString(str); ! show = true; break; } --- 511,515 ---- str = supplier->GetCompanyName(); supplierSet.AddString(str); ! matchSupplier = true; break; } *************** *** 467,471 **** --- 517,524 ---- } } + else + matchSupplier = true; + ref->GetPlotID(plotID); numPlots = layout->NumPlots(); *************** *** 478,535 **** { plot->GetName(plotName); break; } } ! if(show) { ! siftedList_t::iterator cur; ! SiftedData data(name, supplierSet, plotName, ref->GetNumItems()); ! cur = siftedList.find(data); ! if(cur == siftedList.end()) { ! siftedList[data] = data; ! // printf("Setting value for '%s' to %ld\n", namePtr, data.count); } else { - (*cur).second._count += ref->GetNumItems(); - (*cur).second.AddSuppliers(supplierSet); - (*cur).second.AddPlot(plotName); - // printf("Changing value for '%s' to %ld\n", namePtr, (*cur).second.count); - } - } - } - } - - path = elem->GetPathIfPresent(); - if(path != NULL) - { - mat = path->GetBackdrop(); - if(mat != 0) - { - if(mat->GetMaterialType() == kMaterialTypeMulch) - { - if(path->IsPathFillPossible()) - { - measureUnits_t units = (measureUnits_t)_doc->GetPrefsDB()->GetInt32Pref(kUnitsPref); - double cubicMM, volume; - StringSet mulchSuppliers; - - cubicMM = path->ComputeArea() * path->GetBackdropDepth(); - // mulch sold as cubic yard in US, cubic metre in metric. - if(units == kEnglishUnits) - { - volume = cubicMM / 764554857.984; - } - else - { - volume = cubicMM / 1000000000; - } - siftedList_t::iterator cur; ! name = mat->GetDisplayName(kUsePreferencesSetting); ! SiftedData data(name, mulchSuppliers, plotName, volume, units); cur = siftedList.find(data); --- 531,560 ---- { plot->GetName(plotName); + matchPlot = true; break; } } + if(_AllPlots) + matchPlot = true; ! if(matchPlot && matchSupplier) { ! sint32 numPurchased, numUnpurchased; ! InstanceData *instance; ! instance = ref->GetInstanceAttributes(false); ! if(instance != NULL) { ! if(!instance->GetInt32(kNumPurchased, &numPurchased)) ! numPurchased = 0; } else + numPurchased = 0; + + numUnpurchased = ref->GetNumItems() - numPurchased; + if(numUnpurchased > 0) { siftedList_t::iterator cur; ! SiftedData data(name, supplierSet, plotName, numUnpurchased); cur = siftedList.find(data); *************** *** 541,549 **** else { ! (*cur).second._volume += volume; (*cur).second.AddPlot(plotName); // printf("Changing value for '%s' to %ld\n", namePtr, (*cur).second.count); } ! } } --- 566,624 ---- else { ! (*cur).second._count += numUnpurchased; ! (*cur).second.AddSuppliers(supplierSet); (*cur).second.AddPlot(plotName); // printf("Changing value for '%s' to %ld\n", namePtr, (*cur).second.count); } ! } ! } ! } ! } ! ! if(_includeMulch) ! { ! path = elem->GetPathIfPresent(); ! if(path != NULL) ! { ! mat = path->GetBackdrop(); ! if(mat != 0) ! { ! if(mat->GetMaterialType() == kMaterialTypeMulch) ! { ! if(path->IsPathFillPossible()) ! { ! measureUnits_t units = (measureUnits_t)_doc->GetPrefsDB()->GetInt32Pref(kUnitsPref); ! double cubicMM, volume; ! StringSet mulchSuppliers; ! ! cubicMM = path->ComputeArea() * path->GetBackdropDepth(); ! // mulch sold as cubic yard in US, cubic metre in metric. ! if(units == kEnglishUnits) ! { ! volume = cubicMM / 764554857.984; ! } ! else ! { ! volume = cubicMM / 1000000000; ! } ! ! siftedList_t::iterator cur; ! name = mat->GetDisplayName(kUsePreferencesSetting); ! SiftedData data(name, mulchSuppliers, plotName, volume, units); ! ! cur = siftedList.find(data); ! if(cur == siftedList.end()) ! { ! siftedList[data] = data; ! // printf("Setting value for '%s' to %ld\n", namePtr, data.count); ! } ! else ! { ! (*cur).second._volume += volume; ! (*cur).second.AddPlot(plotName); ! // printf("Changing value for '%s' to %ld\n", namePtr, (*cur).second.count); ! } ! ! } } } Index: PurchaseReport.h =================================================================== RCS file: /cvsroot/igarden/Garden/source/Reports/Attic/PurchaseReport.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PurchaseReport.h 15 Nov 2006 03:56:32 -0000 1.1.2.1 --- PurchaseReport.h 14 Dec 2006 03:05:28 -0000 1.1.2.2 *************** *** 74,77 **** --- 74,78 ---- XGUUID _vendorID; bool _showPictures; + bool _includeMulch; long _currentItem; XGSDynArray<ShopTemplate_t> _templates; |