Author Topic: Change Balances  (Read 6372 times)

Offline inkstains

Change Balances
« on: October 12, 2007, 10:45:06 am »
just an item to change the balances of Bank and Pocket either individually or together. saves going through mysql, which can be a little daunting for some.


save as ChangeBal.php and place inside your SMFShop's items folder and install as you would an ordinary item just making sure to set stock to zero so no one can purchase it. and then just give yourself the item through admin.


ChangeBal.php

Code: [Select]
<?php
if (!defined('SMF'))
die('Hacking attempt...');

class 
item_ChangeBal extends itemTemplate {
    function 
getItemDetails() {
    
    $this->authorName 'inkstains';
$this->authorWeb 'http://www.daniel15.com/forum/index.php';
$this->authorEmail '';
    
        
$this->name "Change Balance";
        
$this->desc "Change the balances of Bank and Pocket";
        
$this->price 10;
        
$this->require_input true;
$this->can_use_item true;
    }

function getUseInput() {

global $context$scripturl$settings$txt;
return '<br />Change Money Bank: &nbsp;&nbsp;<select name="resetB" size="1" id="resetB">
        <option value="0">No</option>
<option value="1">Yes</option>
  </select>
   Change Money Bank Value: &nbsp;&nbsp;<input type="text" name="info1" value="40" /><br />
<br />Change Money Pocket: <select name="resetP" size="1" id="resetP">
        <option value="0">No</option>
<option value="1">Yes</option>
  </select>
   Change Money Pocket Value: <input type="text" name="info2" value="40" /><br />
  '
;

    }


function onUse() {
        global 
$db_prefix$ID_MEMBER$item_info;

       
if ($_POST['resetB'] && $_POST['resetP'] == 1
{
db_query("UPDATE {$db_prefix}members
  SET moneyBank = 
{$_POST['info1']}
  "
__FILE____LINE__);
  
db_query("UPDATE {$db_prefix}members
  SET money = 
{$_POST['info2']}
  "
__FILE____LINE__);
  
        return 
"Money Bank and Money Pocket has been set to {$_POST['info1']} and {$_POST['info2']} respectively";
        
        die(
"dead");
}

elseif ($_POST['resetB'] == && $_POST['resetP'] == 0
{
db_query("UPDATE {$db_prefix}members
  SET moneyBank = 
{$_POST['info1']}"__FILE____LINE__);
        return 
"Money Bank has been reset {$_POST['info1']}";
        
        die(
"dead");
}

elseif ($_POST['resetB'] == && $_POST['resetP'] == 1
{
db_query("UPDATE {$db_prefix}members
  SET money = 
{$_POST['info2']}"__FILE____LINE__);
        return 
"Money Pocket has been reset {$_POST['info2']}";
        
        die(
"dead");
}

else
{

return "Please make sure you fill in all options";

}

    }

}

?>

Offline feildmaster

Re: Change Balances
« Reply #1 on: October 20, 2007, 04:25:12 pm »
urm...

give me a better reason why i'd want that...?

*just trying to help others understand it better* sure i know it does that but... to me it seems like more work than the admin panel... Oo

Offline inkstains

Re: Change Balances
« Reply #2 on: October 21, 2007, 11:13:43 am »
umm because you can't set the actual value if you use Membergroup Functions you can only add or subtract and you would have to go through each membergroup and if you use Members' Inventory you can only set it one member at a time.

with this you can set all of the bank to a specified value or all of the pockets to a specified value or both to a specified value.

 :buck2:

Offline feildmaster

Re: Change Balances
« Reply #3 on: October 22, 2007, 12:11:41 pm »
rofl... i see...

though i dunno if i would want to do that... =)

Offline Lew_Cipher

Re: Change Balances
« Reply #4 on: November 30, 2007, 04:56:21 pm »
Thank you for this item. Excellent work!

The option to reset all the pocket & bank money should already be a standard option in the Shop's admin settings.

Offline De[v]

Re: Change Balances
« Reply #5 on: December 10, 2011, 03:48:43 pm »
Is they away to edit this so i can edit a set users balances of Bank and Pocket ?