aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelgrouplandmoney.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelgrouplandmoney.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelgrouplandmoney.cpp')
-rw-r--r--linden/indra/newview/llpanelgrouplandmoney.cpp1406
1 files changed, 1406 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelgrouplandmoney.cpp b/linden/indra/newview/llpanelgrouplandmoney.cpp
new file mode 100644
index 0000000..e7dcb9f
--- /dev/null
+++ b/linden/indra/newview/llpanelgrouplandmoney.cpp
@@ -0,0 +1,1406 @@
1/**
2 * @file llpanelgrouplandmoney.cpp
3 * @brief Panel for group land and money.
4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llpanelgrouplandmoney.h"
31
32#include "lluiconstants.h"
33#include "roles_constants.h"
34
35#include "llparcel.h"
36#include "llqueryflags.h"
37
38#include "llagent.h"
39#include "lliconctrl.h"
40#include "lllineeditor.h"
41#include "llscrolllistctrl.h"
42#include "lltextbox.h"
43#include "lltabcontainer.h"
44#include "lltransactiontypes.h"
45#include "llvieweruictrlfactory.h"
46
47#include "llstatusbar.h"
48#include "llfloaterworldmap.h"
49#include "llviewermessage.h"
50
51const char LOADING_STRING[] = "Computing...";
52
53class LLPanelGroupLandMoney::impl
54{
55public:
56 impl(const LLUUID& group_id); //constructor
57 virtual ~impl();
58
59 void requestGroupLandInfo();
60
61 int getStoredContribution();
62 void setYourContributionTextField(int contrib);
63 void setYourMaxContributionTextBox(int max);
64
65 virtual void onMapButton();
66 virtual bool applyContribution();
67 virtual void processGroupLand(LLMessageSystem* msg);
68
69 static void mapCallback(void* data);
70 static void contributionCommitCallback(LLUICtrl* ctrl, void* userdata);
71 static void contributionKeystrokeCallback(LLLineEditor* caller, void* userdata);
72
73//member variables
74public:
75 LLTextBox *mTotalContributedLandp;
76 LLTextBox *mTotalLandInUsep;
77 LLTextBox *mLandAvailablep;
78 LLTextBox* mGroupOverLimitTextp;
79 LLIconCtrl* mGroupOverLimitIconp;
80 LLTextBox* mYourContributionMaxTextp;
81
82 LLLineEditor* mYourContributionEditorp;
83
84 LLButton* mMapButtonp;
85
86 LLGroupMoneyTabEventHandler* mMoneyDetailsTabEHp;
87 LLGroupMoneyTabEventHandler* mMoneyPlanningTabEHp;
88 LLGroupMoneyTabEventHandler* mMoneySalesTabEHp;
89
90 LLScrollListCtrl* mGroupParcelsp;
91
92 LLUUID mGroupID;
93 LLUUID mTransID;
94
95 bool mBeenActivated;
96 bool mNeedsSendGroupLandRequest;
97 bool mNeedsApply;
98
99 std::string mCantViewParcelsText;
100 std::string mCantViewAccountsText;
101};
102
103//*******************************************
104//** LLPanelGroupLandMoney::impl Functions **
105//*******************************************
106LLPanelGroupLandMoney::impl::impl(const LLUUID& group_id)
107{
108 mGroupID = group_id;
109 mTransID = LLUUID::null;
110
111 mBeenActivated = false;
112 mNeedsSendGroupLandRequest = true;
113 mNeedsApply = false;
114
115 mTotalLandInUsep = NULL;
116 mTotalContributedLandp = NULL;
117 mLandAvailablep = NULL;
118 mYourContributionEditorp = NULL;
119 mMapButtonp = NULL;
120 mGroupParcelsp = NULL;
121 mYourContributionMaxTextp = NULL;
122 mGroupOverLimitTextp = NULL;
123 mGroupOverLimitIconp = NULL;
124
125 mMoneySalesTabEHp = NULL;
126 mMoneyPlanningTabEHp = NULL;
127 mMoneyDetailsTabEHp = NULL;
128}
129
130LLPanelGroupLandMoney::impl::~impl()
131{
132 if ( mMoneySalesTabEHp ) delete mMoneySalesTabEHp;
133 if ( mMoneyDetailsTabEHp ) delete mMoneyDetailsTabEHp;
134 if ( mMoneyPlanningTabEHp ) delete mMoneyPlanningTabEHp;
135}
136
137void LLPanelGroupLandMoney::impl::requestGroupLandInfo()
138{
139 U32 query_flags = DFQ_GROUP_OWNED;
140
141 mTransID.generate();
142 mGroupParcelsp->deleteAllItems();
143
144 send_places_query(mGroupID, mTransID, "", query_flags, LLParcel::C_ANY, "");
145}
146
147void LLPanelGroupLandMoney::impl::onMapButton()
148{
149 LLScrollListItem* itemp;
150 itemp = mGroupParcelsp->getFirstSelected();
151 if (!itemp) return;
152
153 const LLScrollListCell* cellp;
154 // name
155 // location
156 // area
157 cellp = itemp->getColumn(3); // hidden
158
159 F32 global_x = 0.f;
160 F32 global_y = 0.f;
161 sscanf(cellp->getText().c_str(), "%f %f", &global_x, &global_y);
162
163 // Hack: Use the agent's z-height
164 F64 global_z = gAgent.getPositionGlobal().mdV[VZ];
165
166 LLVector3d pos_global(global_x, global_y, global_z);
167 gFloaterWorldMap->trackLocation(pos_global);
168
169 LLFloaterWorldMap::show(NULL, TRUE);
170}
171
172bool LLPanelGroupLandMoney::impl::applyContribution()
173{
174 // calculate max donation, which is sum of available and current.
175 S32 your_contribution = 0;
176 S32 sqm_avail;
177
178 your_contribution = getStoredContribution();
179 sqm_avail = your_contribution;
180
181 if(gStatusBar)
182 {
183 sqm_avail += gStatusBar->getSquareMetersLeft();
184 }
185
186 // get new contribution and compare to available
187 S32 new_contribution = atoi(mYourContributionEditorp->getText().c_str());
188
189 if( new_contribution != your_contribution &&
190 new_contribution >= 0 &&
191 new_contribution <= sqm_avail )
192 {
193 // update group info and server
194 if(!gAgent.setGroupContribution(mGroupID, new_contribution))
195 {
196 // should never happen...
197 llwarns << "Unable to set contribution." << llendl;
198 return false;
199 }
200 }
201 else
202 {
203 //TODO: throw up some error message here and return? right now we just
204 //fail silently and force the previous value -jwolk
205 new_contribution = your_contribution;
206 }
207
208 //set your contribution
209 setYourContributionTextField(new_contribution);
210
211 return true;
212}
213
214// Retrieves the land contribution for this agent that is currently
215// stored in the database, NOT what is currently entered in the text field
216int LLPanelGroupLandMoney::impl::getStoredContribution()
217{
218 LLGroupData group_data;
219
220 group_data.mContribution = 0;
221 gAgent.getGroupData(mGroupID, group_data);
222
223 return group_data.mContribution;
224}
225
226// Fills in the text field with the contribution, contrib
227void LLPanelGroupLandMoney::impl::setYourContributionTextField(int contrib)
228{
229 char buffer[MAX_STRING];
230 buffer[0] = '\0';
231 sprintf(buffer, "%d", contrib);
232
233 if ( mYourContributionEditorp )
234 {
235 mYourContributionEditorp->setText(buffer);
236 mYourContributionEditorp->draw();
237 }
238}
239
240void LLPanelGroupLandMoney::impl::setYourMaxContributionTextBox(int max)
241{
242 char buffer[MAX_STRING];
243 buffer[0] = '\0';
244
245 sprintf(buffer, "(%d max)", max);
246 if ( mYourContributionMaxTextp )
247 {
248 mYourContributionMaxTextp->setText(buffer);
249 }
250}
251
252//static
253void LLPanelGroupLandMoney::impl::mapCallback(void* data)
254{
255 LLPanelGroupLandMoney::impl* selfp = (LLPanelGroupLandMoney::impl*) data;
256
257 if ( selfp ) selfp->onMapButton();
258}
259
260void LLPanelGroupLandMoney::impl::contributionCommitCallback(LLUICtrl* ctrl,
261 void* userdata)
262{
263 LLPanelGroupLandMoney* tabp = (LLPanelGroupLandMoney*) userdata;
264 LLLineEditor* editorp = (LLLineEditor*) ctrl;
265
266 if ( tabp && editorp )
267 {
268 impl* self = tabp->mImplementationp;
269 int your_contribution = 0;
270 int new_contribution = 0;
271
272 new_contribution= atoi(editorp->getText().c_str());
273 your_contribution = self->getStoredContribution();
274
275 //reset their junk data to be "good" data to us
276 self->setYourContributionTextField(new_contribution);
277
278 //check to see if they're contribution text has changed
279 self->mNeedsApply = new_contribution != your_contribution;
280 tabp->notifyObservers();
281 }
282}
283
284void LLPanelGroupLandMoney::impl::contributionKeystrokeCallback(LLLineEditor* caller,
285 void* userdata)
286{
287 impl::contributionCommitCallback(caller, userdata);
288}
289
290//static
291void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg)
292{
293 S32 count = msg->getNumberOfBlocks("QueryData");
294 if(count > 0)
295 {
296 S32 first_block = 0;
297
298 LLUUID owner_id;
299 LLUUID trans_id;
300
301 msg->getUUID("QueryData", "OwnerID", owner_id, 0);
302 msg->getUUID("TransactionData", "TransactionID", trans_id);
303
304 if(owner_id.isNull())
305 {
306 // special block which has total contribution
307 ++first_block;
308 S32 total_contribution;
309 msg->getS32("QueryData", "ActualArea", total_contribution, 0);
310 char buffer[MAX_STRING];
311 sprintf(buffer, "%d sq. meters", total_contribution);
312 mTotalContributedLandp->setText(buffer);
313 S32 committed;
314 msg->getS32("QueryData", "BillableArea", committed, 0);
315 sprintf(buffer, "%d sq. meters", committed);
316 mTotalLandInUsep->setText(buffer);
317 S32 available = total_contribution - committed;
318 sprintf(buffer, "%d sq. meters", available);
319 mLandAvailablep->setText(buffer);
320 buffer[0] = '\0';
321 if ( mGroupOverLimitTextp && mGroupOverLimitIconp )
322 {
323 mGroupOverLimitIconp->setVisible(available < 0);
324 mGroupOverLimitTextp->setVisible(available < 0);
325 }
326 }
327
328 if ( trans_id != mTransID ) return;
329 // This power was removed to make group roles simpler
330 //if ( !gAgent.hasPowerInGroup(mGroupID, GP_LAND_VIEW_OWNED) ) return;
331 if (!gAgent.isInGroup(mGroupID)) return;
332
333 //we updated more than just the available area special block
334 if ( count > 1)
335 {
336 mMapButtonp->setEnabled(TRUE);
337 }
338
339 char name[MAX_STRING];
340 char desc[MAX_STRING];
341 S32 actual_area;
342 S32 billable_area;
343 U8 flags;
344 F32 global_x;
345 F32 global_y;
346 char sim_name[MAX_STRING];
347 for(S32 i = first_block; i < count; ++i)
348 {
349 msg->getUUID("QueryData", "OwnerID", owner_id, i);
350 msg->getString("QueryData", "Name", MAX_STRING, name, i);
351 msg->getString("QueryData", "Desc", MAX_STRING, desc, i);
352 msg->getS32("QueryData", "ActualArea", actual_area, i);
353 msg->getS32("QueryData", "BillableArea", billable_area, i);
354 msg->getU8("QueryData", "Flags", flags, i);
355 msg->getF32("QueryData", "GlobalX", global_x, i);
356 msg->getF32("QueryData", "GlobalY", global_y, i);
357 msg->getString("QueryData", "SimName", MAX_STRING, sim_name, i);
358
359 S32 region_x = llround(global_x) % REGION_WIDTH_UNITS;
360 S32 region_y = llround(global_y) % REGION_WIDTH_UNITS;
361 char location[MAX_STRING];
362 sprintf(location, "%s (%d, %d)", sim_name, region_x, region_y);
363 char area[MAX_STRING];
364 if(billable_area == actual_area)
365 {
366 sprintf(area, "%d", billable_area);
367 }
368 else
369 {
370 sprintf(area, "%d / %d", billable_area, actual_area);
371 }
372 char hidden[MAX_STRING];
373 sprintf(hidden, "%f %f", global_x, global_y);
374
375 LLSD row;
376
377 row["columns"][0]["column"] = "name";
378 row["columns"][0]["value"] = name;
379 row["columns"][0]["font"] = "SANSSERIFSMALL";
380
381 row["columns"][1]["column"] = "location";
382 row["columns"][1]["value"] = location;
383 row["columns"][1]["font"] = "SANSSERIFSMALL";
384
385 row["columns"][2]["column"] = "area";
386 row["columns"][2]["value"] = area;
387 row["columns"][2]["font"] = "SANSSERIFSMALL";
388
389 row["columns"][3]["column"] = "hidden";
390 row["columns"][3]["value"] = hidden;
391
392 mGroupParcelsp->addElement(row, ADD_SORTED);
393 }
394 }
395}
396
397//*************************************
398//** LLPanelGroupLandMoney Functions **
399//*************************************
400
401//static
402void* LLPanelGroupLandMoney::createTab(void* data)
403{
404 LLUUID* group_id = static_cast<LLUUID*>(data);
405 return new LLPanelGroupLandMoney("panel group land money", *group_id);
406}
407
408//static
409LLMap<LLUUID, LLPanelGroupLandMoney*> LLPanelGroupLandMoney::sGroupIDs;
410
411LLPanelGroupLandMoney::LLPanelGroupLandMoney(const std::string& name,
412 const LLUUID& group_id) :
413 LLPanelGroupTab(name, group_id)
414{
415 mImplementationp = new impl(group_id);
416
417 //problem what if someone has both the group floater open and the finder
418 //open to the same group? Some maps that map group ids to panels
419 //will then only be working for the last panel for a given group id :(
420 LLPanelGroupLandMoney::sGroupIDs.addData(group_id, this);
421}
422
423LLPanelGroupLandMoney::~LLPanelGroupLandMoney()
424{
425 delete mImplementationp;
426 LLPanelGroupLandMoney::sGroupIDs.removeData(mGroupID);
427}
428
429void LLPanelGroupLandMoney::activate()
430{
431 if ( !mImplementationp->mBeenActivated )
432 {
433 //select the first tab
434 LLTabContainerCommon* tabp = (LLTabContainerCommon*) getChildByName("group_money_tab_container");
435
436 if ( tabp )
437 {
438 tabp->selectFirstTab();
439 mImplementationp->mBeenActivated = true;
440 }
441
442 //fill in the max contribution
443
444 //This calculation is unfortunately based on
445 //the status bar's concept of how much land the user has
446 //which can change dynamically if the user buys new land, gives
447 //more land to a group, etc.
448 //A race condition can occur if we want to update the UI's
449 //concept of the user's max contribution before the status
450 //bar has been updated from a change in the user's group contribution.
451
452 //Since the max contribution should not change solely on changing
453 //a user's group contribution, (it would only change through
454 //purchasing of new land) this code is placed here
455 //and only updated once to prevent the race condition
456 //at the price of having stale data.
457 //We need to have the status bar have observers
458 //or find better way of distributing up to date land data. - jwolk
459 S32 max_avail = mImplementationp->getStoredContribution();
460 if(gStatusBar)
461 {
462 max_avail += gStatusBar->getSquareMetersLeft();
463 }
464 mImplementationp->setYourMaxContributionTextBox(max_avail);
465 }
466
467 update(GC_ALL);
468}
469
470void LLPanelGroupLandMoney::update(LLGroupChange gc)
471{
472 if (gc != GC_ALL) return; //Don't update if it's the wrong panel!
473
474 LLTabContainerCommon* tabp = (LLTabContainerCommon*) getChildByName("group_money_tab_container");
475
476 if ( tabp )
477 {
478 LLPanel* panelp;
479 LLGroupMoneyTabEventHandler* eh;
480
481 panelp = tabp->getCurrentPanel();
482
483 //now pull the event handler associated with that money tab
484 if ( panelp )
485 {
486 eh = get_if_there(LLGroupMoneyTabEventHandler::sTabsToHandlers,
487 panelp,
488 (LLGroupMoneyTabEventHandler*)NULL);
489 if ( eh ) eh->onClickTab();
490 }
491 }
492
493 mImplementationp->requestGroupLandInfo();
494 mImplementationp->setYourContributionTextField(mImplementationp->getStoredContribution());
495}
496
497bool LLPanelGroupLandMoney::needsApply(LLString& mesg)
498{
499 return mImplementationp->mNeedsApply;
500}
501
502bool LLPanelGroupLandMoney::apply(LLString& mesg)
503{
504 if (!mImplementationp->applyContribution() )
505 {
506 mesg.assign("Unable to set your land contribution.");
507 return false;
508 }
509
510 mImplementationp->mNeedsApply = false;
511 notifyObservers();
512
513 return true;
514}
515
516void LLPanelGroupLandMoney::cancel()
517{
518 //set the contribution back to the "stored value"
519 mImplementationp->setYourContributionTextField(mImplementationp->getStoredContribution());
520
521 mImplementationp->mNeedsApply = false;
522 notifyObservers();
523}
524
525
526BOOL LLPanelGroupLandMoney::postBuild()
527{
528 /* This power was removed to make group roles simpler
529 bool has_parcel_view = gAgent.hasPowerInGroup(mGroupID,
530 GP_LAND_VIEW_OWNED);
531 bool has_accounting_view = gAgent.hasPowerInGroup(mGroupID,
532 GP_ACCOUNTING_VIEW);
533 */
534
535 bool can_view = gAgent.isInGroup(mGroupID);
536
537 mImplementationp->mTotalLandInUsep =
538 (LLTextBox*) getChildByName("total_land_in_use_value");
539 mImplementationp->mTotalContributedLandp =
540 (LLTextBox*) getChildByName("total_contributed_land_value");
541 mImplementationp->mLandAvailablep =
542 (LLTextBox*) getChildByName("land_available_value");
543 mImplementationp->mGroupOverLimitIconp =
544 (LLIconCtrl*) getChildByName("group_over_limit_icon");
545 mImplementationp->mGroupOverLimitTextp =
546 (LLTextBox*) getChildByName("group_over_limit_text");
547 mImplementationp->mYourContributionMaxTextp =
548 (LLTextBox*) getChildByName("your_contribution_max_value");
549
550 mImplementationp->mYourContributionEditorp
551 = (LLLineEditor*) getChildByName("your_contribution_line_editor");
552 if ( mImplementationp->mYourContributionEditorp )
553 {
554 LLLineEditor* editor = mImplementationp->mYourContributionEditorp;
555
556 editor->setCommitCallback(mImplementationp->contributionCommitCallback);
557 editor->setKeystrokeCallback(mImplementationp->contributionKeystrokeCallback);
558 editor->setCallbackUserData(this);
559 }
560
561 mImplementationp->mMapButtonp = (LLButton*) getChildByName("map_button");
562
563 mImplementationp->mGroupParcelsp =
564 (LLScrollListCtrl*) getChildByName("group_parcel_list");
565
566 LLTextBox *no_permsp =
567 (LLTextBox*) getChildByName("cant_view_group_land_text");
568 if ( no_permsp )
569 {
570 mImplementationp->mCantViewParcelsText = no_permsp->getText();
571 removeChild(no_permsp);
572 }
573
574 no_permsp = (LLTextBox*) getChildByName("cant_view_group_accounting_text");
575 if ( no_permsp )
576 {
577 mImplementationp->mCantViewAccountsText = no_permsp->getText();
578 removeChild(no_permsp);
579 }
580
581
582 if ( mImplementationp->mMapButtonp )
583 {
584 mImplementationp->mMapButtonp->setClickedCallback(LLPanelGroupLandMoney::impl::mapCallback, mImplementationp);
585 }
586
587 if ( mImplementationp->mGroupOverLimitTextp )
588 {
589 mImplementationp->mGroupOverLimitTextp->setVisible(FALSE);
590 }
591
592 if ( mImplementationp->mGroupOverLimitIconp )
593 {
594 mImplementationp->mGroupOverLimitIconp->setVisible(FALSE);
595 }
596
597 if ( mImplementationp->mMapButtonp )
598 {
599 mImplementationp->mMapButtonp->setEnabled(FALSE);
600 }
601
602 if ( !can_view )
603 {
604 if ( mImplementationp->mGroupParcelsp )
605 {
606 mImplementationp->mGroupParcelsp->addSimpleItem(
607 mImplementationp->mCantViewParcelsText);
608 mImplementationp->mGroupParcelsp->setEnabled(FALSE);
609 }
610 }
611
612
613
614 LLButton* earlierp, *laterp;
615 LLTextEditor* textp;
616 LLPanel* panelp;
617
618 LLTabContainerCommon* tabcp = (LLTabContainerCommon*)
619 getChildByName("group_money_tab_container", true);
620
621 if ( !can_view )
622 {
623 if ( tabcp )
624 {
625 S32 i;
626 S32 tab_count = tabcp->getTabCount();
627
628 for (i = tab_count - 1; i >=0; --i)
629 {
630 tabcp->enableTabButton(i, false);
631 }
632 }
633 }
634
635
636 //pull out the widgets for the money details tab
637 earlierp = (LLButton*) getChildByName("earlier_details_button", true);
638 laterp = (LLButton*) getChildByName("later_details_button", true);
639 textp = (LLTextEditor*) getChildByName("group_money_details_text", true);
640 panelp = (LLPanel*) getChildByName("group_money_details_tab", true);
641
642 if ( !can_view )
643 {
644 textp->setText(mImplementationp->mCantViewAccountsText);
645 }
646 else
647 {
648 mImplementationp->mMoneyDetailsTabEHp =
649 new LLGroupMoneyDetailsTabEventHandler(earlierp,
650 laterp,
651 textp,
652 tabcp,
653 panelp,
654 mGroupID);
655 }
656
657 textp = (LLTextEditor*) getChildByName("group_money_planning_text", true);
658 panelp = (LLPanel*) getChildByName("group_money_planning_tab", true);
659
660 if ( !can_view )
661 {
662 textp->setText(mImplementationp->mCantViewAccountsText);
663 }
664 else
665 {
666 mImplementationp->mMoneyPlanningTabEHp =
667 new LLGroupMoneyPlanningTabEventHandler(textp,
668 tabcp,
669 panelp,
670 mGroupID);
671 }
672
673 //pull out the widgets for the money sales tab
674 earlierp = (LLButton*) getChildByName("earlier_sales_button", true);
675 laterp = (LLButton*) getChildByName("later_sales_button", true);
676 textp = (LLTextEditor*) getChildByName("group_money_sales_text", true);
677 panelp = (LLPanel*) getChildByName("group_money_sales_tab", true);
678
679 if ( !can_view )
680 {
681 textp->setText(mImplementationp->mCantViewAccountsText);
682 }
683 else
684 {
685 mImplementationp->mMoneySalesTabEHp =
686 new LLGroupMoneySalesTabEventHandler(earlierp,
687 laterp,
688 textp,
689 tabcp,
690 panelp,
691 mGroupID);
692 }
693
694 return LLPanelGroupTab::postBuild();
695}
696
697BOOL LLPanelGroupLandMoney::isVisibleByAgent(LLAgent* agentp)
698{
699 return mAllowEdit && agentp->isInGroup(mGroupID);
700}
701
702void LLPanelGroupLandMoney::processPlacesReply(LLMessageSystem* msg, void**)
703{
704 LLUUID group_id;
705 msg->getUUID("AgentData", "QueryID", group_id);
706
707 LLPanelGroupLandMoney* selfp = sGroupIDs.getIfThere(group_id);
708 if(!selfp)
709 {
710 llinfos << "Group Panel Land Money " << group_id << " no longer in existence."
711 << llendl;
712 return;
713 }
714
715 selfp->mImplementationp->processGroupLand(msg);
716}
717
718//*************************************************
719//** LLGroupMoneyTabEventHandler::impl Functions **
720//*************************************************
721
722class LLGroupMoneyTabEventHandler::impl
723{
724public:
725 impl(LLButton* earlier_buttonp,
726 LLButton* later_buttonp,
727 LLTextEditor* text_editorp,
728 LLPanel* panelp,
729 const LLUUID& group_id,
730 S32 interval_length_days,
731 S32 max_interval_days);
732 ~impl();
733
734 bool getCanClickLater();
735 bool getCanClickEarlier();
736
737 void updateButtons();
738
739//member variables
740public:
741 LLUUID mGroupID;
742 LLUUID mPanelID;
743
744 LLPanel* mPanelp;
745
746 int mIntervalLength;
747 int mMaxInterval;
748 int mCurrentInterval;
749
750 LLTextEditor* mTextEditorp;
751 LLButton* mEarlierButtonp;
752 LLButton* mLaterButtonp;
753};
754
755LLGroupMoneyTabEventHandler::impl::impl(LLButton* earlier_buttonp,
756 LLButton* later_buttonp,
757 LLTextEditor* text_editorp,
758 LLPanel* panelp,
759 const LLUUID& group_id,
760 S32 interval_length_days,
761 S32 max_interval_days)
762{
763 mGroupID = group_id;
764 mPanelID.generate();
765
766 mIntervalLength = interval_length_days;
767 mMaxInterval = max_interval_days;
768 mCurrentInterval = 0;
769
770 mTextEditorp = text_editorp;
771 mEarlierButtonp = earlier_buttonp;
772 mLaterButtonp = later_buttonp;
773 mPanelp = panelp;
774}
775
776LLGroupMoneyTabEventHandler::impl::~impl()
777{
778}
779
780bool LLGroupMoneyTabEventHandler::impl::getCanClickEarlier()
781{
782 return (mCurrentInterval < mMaxInterval);
783}
784
785bool LLGroupMoneyTabEventHandler::impl::getCanClickLater()
786{
787 return ( mCurrentInterval > 0 );
788}
789
790void LLGroupMoneyTabEventHandler::impl::updateButtons()
791{
792 if ( mEarlierButtonp )
793 {
794 mEarlierButtonp->setEnabled(getCanClickEarlier());
795 }
796 if ( mLaterButtonp )
797 {
798 mLaterButtonp->setEnabled(getCanClickLater());
799 }
800}
801
802//*******************************************
803//** LLGroupMoneyTabEventHandler Functions **
804//*******************************************
805LLMap<LLUUID, LLGroupMoneyTabEventHandler*> LLGroupMoneyTabEventHandler::sInstanceIDs;
806std::map<LLPanel*, LLGroupMoneyTabEventHandler*> LLGroupMoneyTabEventHandler::sTabsToHandlers;
807
808LLGroupMoneyTabEventHandler::LLGroupMoneyTabEventHandler(LLButton* earlier_buttonp,
809 LLButton* later_buttonp,
810 LLTextEditor* text_editorp,
811 LLTabContainerCommon* tab_containerp,
812 LLPanel* panelp,
813 const LLUUID& group_id,
814 S32 interval_length_days,
815 S32 max_interval_days)
816{
817 mImplementationp = new impl(earlier_buttonp,
818 later_buttonp,
819 text_editorp,
820 panelp,
821 group_id,
822 interval_length_days,
823 max_interval_days);
824
825 if ( earlier_buttonp )
826 {
827 earlier_buttonp->setClickedCallback(LLGroupMoneyTabEventHandler::clickEarlierCallback,
828 this);
829 }
830
831 if ( later_buttonp )
832 {
833 later_buttonp->setClickedCallback(LLGroupMoneyTabEventHandler::clickLaterCallback,
834 this);
835 }
836
837 mImplementationp->updateButtons();
838
839 if ( tab_containerp && panelp )
840 {
841 tab_containerp->setTabChangeCallback(panelp,
842 LLGroupMoneyTabEventHandler::clickTabCallback);
843 tab_containerp->setTabUserData(panelp, this);
844 }
845
846 sInstanceIDs.addData(mImplementationp->mPanelID, this);
847 sTabsToHandlers[panelp] = this;
848}
849
850LLGroupMoneyTabEventHandler::~LLGroupMoneyTabEventHandler()
851{
852 sInstanceIDs.removeData(mImplementationp->mPanelID);
853 sTabsToHandlers.erase(mImplementationp->mPanelp);
854
855 delete mImplementationp;
856}
857
858
859void LLGroupMoneyTabEventHandler::onClickTab()
860{
861 requestData(gMessageSystem);
862}
863
864void LLGroupMoneyTabEventHandler::requestData(LLMessageSystem* msg)
865{
866 //do nothing
867}
868
869void LLGroupMoneyTabEventHandler::processReply(LLMessageSystem* msg, void** data)
870{
871 //do nothing
872}
873
874void LLGroupMoneyTabEventHandler::onClickEarlier()
875{
876 if ( mImplementationp->mTextEditorp)
877 {
878 mImplementationp->mTextEditorp->setText(LOADING_STRING);
879 }
880 mImplementationp->mCurrentInterval++;
881
882 mImplementationp->updateButtons();
883
884 requestData(gMessageSystem);
885}
886
887void LLGroupMoneyTabEventHandler::onClickLater()
888{
889 if ( mImplementationp->mTextEditorp )
890 {
891 mImplementationp->mTextEditorp->setText(LOADING_STRING);
892 }
893 mImplementationp->mCurrentInterval--;
894
895 mImplementationp->updateButtons();
896
897 requestData(gMessageSystem);
898}
899
900//static
901void LLGroupMoneyTabEventHandler::clickEarlierCallback(void* data)
902{
903 LLGroupMoneyTabEventHandler* selfp = (LLGroupMoneyTabEventHandler*) data;
904
905 if ( selfp ) selfp->onClickEarlier();
906}
907
908//static
909void LLGroupMoneyTabEventHandler::clickLaterCallback(void* data)
910{
911 LLGroupMoneyTabEventHandler* selfp = (LLGroupMoneyTabEventHandler*) data;
912 if ( selfp ) selfp->onClickLater();
913}
914
915//static
916void LLGroupMoneyTabEventHandler::clickTabCallback(void* data, bool from_click)
917{
918 LLGroupMoneyTabEventHandler* selfp = (LLGroupMoneyTabEventHandler*) data;
919 if ( selfp ) selfp->onClickTab();
920}
921
922//**************************************************
923//** LLGroupMoneyDetailsTabEventHandler Functions **
924//**************************************************
925
926LLGroupMoneyDetailsTabEventHandler::LLGroupMoneyDetailsTabEventHandler(LLButton* earlier_buttonp,
927 LLButton* later_buttonp,
928 LLTextEditor* text_editorp,
929 LLTabContainerCommon* tab_containerp,
930 LLPanel* panelp,
931 const LLUUID& group_id)
932 : LLGroupMoneyTabEventHandler(earlier_buttonp,
933 later_buttonp,
934 text_editorp,
935 tab_containerp,
936 panelp,
937 group_id,
938 SUMMARY_INTERVAL,
939 SUMMARY_MAX)
940{
941}
942
943LLGroupMoneyDetailsTabEventHandler::~LLGroupMoneyDetailsTabEventHandler()
944{
945}
946
947void LLGroupMoneyDetailsTabEventHandler::requestData(LLMessageSystem* msg)
948{
949 msg->newMessageFast(_PREHASH_GroupAccountDetailsRequest);
950 msg->nextBlockFast(_PREHASH_AgentData);
951 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
952 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
953 msg->addUUIDFast(_PREHASH_GroupID, mImplementationp->mGroupID );
954 msg->nextBlockFast(_PREHASH_MoneyData);
955 msg->addUUIDFast(_PREHASH_RequestID, mImplementationp->mPanelID );
956 msg->addS32Fast(_PREHASH_IntervalDays, mImplementationp->mIntervalLength );
957 msg->addS32Fast(_PREHASH_CurrentInterval, mImplementationp->mCurrentInterval);
958
959 gAgent.sendReliableMessage();
960
961 if ( mImplementationp->mTextEditorp )
962 {
963 mImplementationp->mTextEditorp->setText(LOADING_STRING);
964 }
965
966 LLGroupMoneyTabEventHandler::requestData(msg);
967}
968
969void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg,
970 void** data)
971{
972 LLUUID group_id;
973 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
974 if (mImplementationp->mGroupID != group_id)
975 {
976 llwarns << "Group Account details not for this group!" << llendl;
977 return;
978 }
979
980 char line[MAX_STRING];
981 LLString text;
982
983 char start_date[MAX_STRING];
984 S32 interval_days;
985 S32 current_interval;
986
987 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
988 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
989 msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
990
991 if ( interval_days != mImplementationp->mIntervalLength ||
992 current_interval != mImplementationp->mCurrentInterval )
993 {
994 llinfos << "Out of date details packet " << interval_days << " "
995 << current_interval << llendl;
996 return;
997 }
998
999 sprintf(line, "%s\n\n", start_date);
1000 text.append(line);
1001
1002 S32 total_amount = 0;
1003 S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData);
1004 for(S32 i = 0; i < transactions; i++)
1005 {
1006 S32 amount = 0;
1007 char desc[MAX_STRING];
1008
1009 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Description, MAX_STRING, desc, i );
1010 msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i);
1011
1012 if (amount != 0)
1013 {
1014 sprintf(line, "%-24s %6d\n", desc, amount );
1015 text.append(line);
1016 }
1017 else
1018 {
1019 // skip it
1020 }
1021
1022 total_amount += amount;
1023 }
1024
1025 text.append(1, '\n');
1026
1027 sprintf(line, "%-24s %6d\n", "Total", total_amount );
1028 text.append(line);
1029
1030 if ( mImplementationp->mTextEditorp )
1031 {
1032 mImplementationp->mTextEditorp->setText(text);
1033 }
1034}
1035
1036//static
1037void LLGroupMoneyDetailsTabEventHandler::processGroupAccountDetailsReply(LLMessageSystem* msg,
1038 void** data)
1039{
1040 LLUUID agent_id;
1041 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
1042 if (gAgent.getID() != agent_id)
1043 {
1044 llwarns << "Got group money history reply for another agent!"
1045 << " Probably a userserver bug!" << llendl;
1046 return;
1047 }
1048
1049 LLUUID request_id;
1050 msg->getUUIDFast(_PREHASH_MoneyData, _PREHASH_RequestID, request_id );
1051 LLGroupMoneyTabEventHandler* selfp = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
1052 if (!selfp)
1053 {
1054 llwarns << "GroupAccountDetails recieved for non-existent group panel." << llendl;
1055 return;
1056 }
1057
1058 selfp->processReply(msg, data);
1059}
1060
1061//************************************************
1062//** LLGroupMoneySalesTabEventHandler Functions **
1063//************************************************
1064
1065LLGroupMoneySalesTabEventHandler::LLGroupMoneySalesTabEventHandler(LLButton* earlier_buttonp,
1066 LLButton* later_buttonp,
1067 LLTextEditor* text_editorp,
1068 LLTabContainerCommon* tab_containerp,
1069 LLPanel* panelp,
1070 const LLUUID& group_id)
1071 : LLGroupMoneyTabEventHandler(earlier_buttonp,
1072 later_buttonp,
1073 text_editorp,
1074 tab_containerp,
1075 panelp,
1076 group_id,
1077 SUMMARY_INTERVAL,
1078 SUMMARY_MAX)
1079{
1080}
1081
1082LLGroupMoneySalesTabEventHandler::~LLGroupMoneySalesTabEventHandler()
1083{
1084}
1085
1086void LLGroupMoneySalesTabEventHandler::requestData(LLMessageSystem* msg)
1087{
1088 msg->newMessageFast(_PREHASH_GroupAccountTransactionsRequest);
1089 msg->nextBlockFast(_PREHASH_AgentData);
1090 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
1091 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
1092 msg->addUUIDFast(_PREHASH_GroupID, mImplementationp->mGroupID );
1093 msg->nextBlockFast(_PREHASH_MoneyData);
1094 msg->addUUIDFast(_PREHASH_RequestID, mImplementationp->mPanelID );
1095 msg->addS32Fast(_PREHASH_IntervalDays, mImplementationp->mIntervalLength );
1096 msg->addS32Fast(_PREHASH_CurrentInterval, mImplementationp->mCurrentInterval);
1097
1098 gAgent.sendReliableMessage();
1099
1100 if ( mImplementationp->mTextEditorp )
1101 {
1102 mImplementationp->mTextEditorp->setText(LOADING_STRING);
1103 }
1104
1105 LLGroupMoneyTabEventHandler::requestData(msg);
1106}
1107
1108void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg,
1109 void** data)
1110{
1111 LLUUID group_id;
1112 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
1113 if (mImplementationp->mGroupID != group_id)
1114 {
1115 llwarns << "Group Account Transactions not for this group!" << llendl;
1116 return;
1117 }
1118
1119 char line[MAX_STRING];
1120 std::string text = mImplementationp->mTextEditorp->getText();
1121
1122 char start_date[MAX_STRING];
1123 S32 interval_days;
1124 S32 current_interval;
1125
1126 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
1127 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
1128 msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
1129
1130 if (interval_days != mImplementationp->mIntervalLength ||
1131 current_interval != mImplementationp->mCurrentInterval)
1132 {
1133 llinfos << "Out of date details packet " << interval_days << " "
1134 << current_interval << llendl;
1135 return;
1136 }
1137
1138 // If this is the first packet, clear the text, don't append.
1139 // Start with the date.
1140 if (text == LOADING_STRING)
1141 {
1142 text.clear();
1143
1144 sprintf(line, "%s\n\n", start_date);
1145 text.append(line);
1146 }
1147
1148 S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData);
1149 if (transactions == 0)
1150 {
1151 text.append("(none)");
1152 }
1153 else
1154 {
1155 for(S32 i = 0; i < transactions; i++)
1156 {
1157 const S32 SHORT_STRING = 64;
1158 char time[SHORT_STRING];
1159 S32 type = 0;
1160 S32 amount = 0;
1161 char user[SHORT_STRING];
1162 char item[SHORT_STRING];
1163
1164 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Time, SHORT_STRING, time, i);
1165 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_User, SHORT_STRING, user, i );
1166 msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Type, type, i);
1167 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Item, SHORT_STRING, item, i );
1168 msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i);
1169
1170 if (amount != 0)
1171 {
1172 char* verb;
1173
1174 switch(type)
1175 {
1176 case TRANS_OBJECT_SALE:
1177 verb = "bought";
1178 break;
1179 case TRANS_GIFT:
1180 verb = "paid you";
1181 break;
1182 case TRANS_PAY_OBJECT:
1183 verb = "paid into";
1184 break;
1185 case TRANS_LAND_PASS_SALE:
1186 verb = "bought pass to";
1187 break;
1188 case TRANS_EVENT_FEE:
1189 verb = "paid fee for event";
1190 break;
1191 case TRANS_EVENT_PRIZE:
1192 verb = "paid prize for event";
1193 break;
1194 default:
1195 verb = "";
1196 break;
1197 }
1198
1199 sprintf(line, "%s %6d - %s %s %s\n", time, amount, user, verb, item);
1200 text.append(line);
1201 }
1202 }
1203 }
1204
1205 if ( mImplementationp->mTextEditorp)
1206 {
1207 mImplementationp->mTextEditorp->setText(text);
1208 }
1209}
1210
1211//static
1212void LLGroupMoneySalesTabEventHandler::processGroupAccountTransactionsReply(LLMessageSystem* msg,
1213 void** data)
1214{
1215 LLUUID agent_id;
1216 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
1217 if (gAgent.getID() != agent_id)
1218 {
1219 llwarns << "Got group money history reply for another agent!"
1220 << " Probably a userserver bug!" << llendl;
1221 return;
1222 }
1223
1224 LLUUID request_id;
1225 msg->getUUIDFast(_PREHASH_MoneyData, _PREHASH_RequestID, request_id );
1226
1227 LLGroupMoneyTabEventHandler* self;
1228
1229 self = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
1230 if (!self)
1231 {
1232 llwarns << "GroupAccountTransactions recieved for non-existent group panel." << llendl;
1233 return;
1234 }
1235
1236 self->processReply(msg, data);
1237}
1238
1239//***************************************************
1240//** LLGroupMoneyPlanningTabEventHandler Functions **
1241//***************************************************
1242
1243LLGroupMoneyPlanningTabEventHandler::LLGroupMoneyPlanningTabEventHandler(LLTextEditor* text_editorp,
1244 LLTabContainerCommon* tab_containerp,
1245 LLPanel* panelp,
1246 const LLUUID& group_id)
1247 : LLGroupMoneyTabEventHandler(NULL,
1248 NULL,
1249 text_editorp,
1250 tab_containerp,
1251 panelp,
1252 group_id,
1253 SUMMARY_INTERVAL,
1254 SUMMARY_MAX)
1255{
1256}
1257
1258LLGroupMoneyPlanningTabEventHandler::~LLGroupMoneyPlanningTabEventHandler()
1259{
1260}
1261
1262void LLGroupMoneyPlanningTabEventHandler::requestData(LLMessageSystem* msg)
1263{
1264 msg->newMessageFast(_PREHASH_GroupAccountSummaryRequest);
1265 msg->nextBlockFast(_PREHASH_AgentData);
1266 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
1267 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
1268 msg->addUUIDFast(_PREHASH_GroupID, mImplementationp->mGroupID );
1269 msg->nextBlockFast(_PREHASH_MoneyData);
1270 msg->addUUIDFast(_PREHASH_RequestID, mImplementationp->mPanelID );
1271 msg->addS32Fast(_PREHASH_IntervalDays, mImplementationp->mIntervalLength);
1272 msg->addS32Fast(_PREHASH_CurrentInterval, 0); //planning has 0 interval
1273
1274 gAgent.sendReliableMessage();
1275
1276 if ( mImplementationp->mTextEditorp )
1277 {
1278 mImplementationp->mTextEditorp->setText(LOADING_STRING);
1279 }
1280
1281 LLGroupMoneyTabEventHandler::requestData(msg);
1282}
1283
1284void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg,
1285 void** data)
1286{
1287 LLUUID group_id;
1288 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
1289 if (mImplementationp->mGroupID != group_id)
1290 {
1291 llwarns << "Group Account Summary received not for this group!" << llendl;
1292 return;
1293 }
1294
1295 char line[MAX_STRING];
1296 LLString text;
1297
1298 char start_date[MAX_STRING];
1299 char last_stipend_date[MAX_STRING];
1300 char next_stipend_date[MAX_STRING];
1301 S32 interval_days;
1302 S32 current_interval;
1303 S32 balance;
1304 S32 total_credits;
1305 S32 total_debits;
1306 S32 cur_object_tax;
1307 S32 cur_light_tax;
1308 S32 cur_land_tax;
1309 S32 cur_group_tax;
1310 S32 cur_parcel_dir_fee;
1311 S32 cur_total_tax;
1312 S32 proj_object_tax;
1313 S32 proj_light_tax;
1314 S32 proj_land_tax;
1315 S32 proj_group_tax;
1316 S32 proj_parcel_dir_fee;
1317 S32 proj_total_tax;
1318 S32 non_exempt_members;
1319
1320 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
1321 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
1322 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_Balance, balance );
1323 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_TotalCredits, total_credits );
1324 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_TotalDebits, total_debits );
1325 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ObjectTaxCurrent, cur_object_tax );
1326 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LightTaxCurrent, cur_light_tax );
1327 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LandTaxCurrent, cur_land_tax );
1328 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_GroupTaxCurrent, cur_group_tax );
1329 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ParcelDirFeeCurrent, cur_parcel_dir_fee );
1330 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ObjectTaxEstimate, proj_object_tax );
1331 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LightTaxEstimate, proj_light_tax );
1332 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LandTaxEstimate, proj_land_tax );
1333 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_GroupTaxEstimate, proj_group_tax );
1334 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ParcelDirFeeEstimate, proj_parcel_dir_fee );
1335 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_NonExemptMembers, non_exempt_members );
1336
1337 msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
1338 msg->getStringFast(_PREHASH_MoneyData, _PREHASH_LastTaxDate, MAX_STRING, last_stipend_date);
1339 msg->getStringFast(_PREHASH_MoneyData, _PREHASH_TaxDate, MAX_STRING, next_stipend_date);
1340
1341 cur_total_tax = cur_object_tax + cur_light_tax + cur_land_tax + cur_group_tax + cur_parcel_dir_fee;
1342 proj_total_tax = proj_object_tax + proj_light_tax + proj_land_tax + proj_group_tax + proj_parcel_dir_fee;
1343
1344 if (interval_days != mImplementationp->mIntervalLength ||
1345 current_interval != mImplementationp->mCurrentInterval)
1346 {
1347 llinfos << "Out of date summary packet " << interval_days << " "
1348 << current_interval << llendl;
1349 return;
1350 }
1351
1352 sprintf(line, "Summary for this week, beginning on %s\n", start_date);
1353 text.append(line);
1354
1355 if (current_interval == 0)
1356 {
1357 sprintf(line, "The next stipend day is %s\n\n", next_stipend_date);
1358 text.append(line);
1359 sprintf(line, "%-24sL$%6d\n", "Balance", balance );
1360 text.append(line);
1361
1362 text.append(1, '\n');
1363 }
1364
1365 sprintf(line, " Group Individual Share\n");
1366 text.append(line);
1367 sprintf(line, "%-24s %6d %6d \n", "Credits", total_credits, (S32)floor((F32)total_credits/(F32)non_exempt_members));
1368 text.append(line);
1369 sprintf(line, "%-24s %6d %6d \n", "Debits", total_debits, (S32)floor((F32)total_debits/(F32)non_exempt_members));
1370 text.append(line);
1371 sprintf(line, "%-24s %6d %6d \n", "Total", total_credits + total_debits, (S32)floor((F32)(total_credits + total_debits)/(F32)non_exempt_members));
1372 text.append(line);
1373
1374 if ( mImplementationp->mTextEditorp )
1375 {
1376 mImplementationp->mTextEditorp->setText(text);
1377 }
1378}
1379
1380//static
1381void LLGroupMoneyPlanningTabEventHandler::processGroupAccountSummaryReply(LLMessageSystem* msg,
1382 void** data)
1383{
1384 LLUUID agent_id;
1385 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
1386 if (gAgent.getID() != agent_id)
1387 {
1388 llwarns << "Got group money history reply for another agent!"
1389 << " Probably a userserver bug!" << llendl;
1390 return;
1391 }
1392
1393 LLUUID request_id;
1394 msg->getUUIDFast(_PREHASH_MoneyData, _PREHASH_RequestID, request_id );
1395
1396 LLGroupMoneyTabEventHandler* self;
1397
1398 self = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
1399 if (!self)
1400 {
1401 llwarns << "GroupAccountSummary recieved for non-existent group money planning tab." << llendl;
1402 return;
1403 }
1404
1405 self->processReply(msg, data);
1406}