llpanelgrouplandmoney.cpp 41 KB

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