PageRenderTime 57ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llpanelgrouplandmoney.cpp

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