llpanelgrouplandmoney.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:46k
源码类别:

游戏引擎

开发平台:

C++ Builder

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