Jump to content

Recommended Posts

Posted

Hey,

 

Can anyone point me to how I would go about getting the logged in users id so I can use it in the following:

 

 

print_r( money_format('£%i', $this->Transactions->getTotalCredit(**USER ID HERE**, "GBP")));

 

It's to display the amount of credit the logged in user has on the dashboard. Can't seem to find reference though to the users ID. 

Posted

Hey,

 

Can anyone point me to how I would go about getting the logged in users id so I can use it in the following:

 

 

print_r( money_format('£%i', $this->Transactions->getTotalCredit(**USER ID HERE**, "GBP")));

 

It's to display the amount of credit the logged in user has on the dashboard. Can't seem to find reference though to the users ID. 

 

Try this mate:

 

print_r( money_format('£%i', $this->Transactions->getTotalCredit($user_id, "GBP")));
Posted

As requested by Paul, some more information.

 

I'm trying to add this code in to structure.pdt to show each client's credit.

 

 

<?php Loader::loadModels($this, array("Transactions")); ?>

<?php if ($this->Html->ifSet($logged_in)) { ?>
   
    <div id="credit">Credit: <?php print_r( money_format('£%i', $this->Transactions->getTotalCredit(1, "GBP"))); ?></div>
<?php } ?>

 

 
I need the number 1 to be the client that is currently logged in's ID.
Posted

As requested by Paul, some more information.

 

I'm trying to add this code in to structure.pdt to show each client's credit.

 

 

<?php Loader::loadModels($this, array("Transactions")); ?>

<?php if ($this->Html->ifSet($logged_in)) { ?>
   
    <div id="credit">Credit: <?php print_r( money_format('£%i', $this->Transactions->getTotalCredit(1, "GBP"))); ?></div>
<?php } ?>

 

 
I need the number 1 to be the client that is currently logged in's ID.

 

This part happens to be the user ID:

<?php if ($this->Html->ifSet($logged_in)) { ?>

 

i.e.

$this->Transactions->getTotalCredit($logged_in, "GBP")

 

There is no explicit client information set to the structure, so if you're a staff member logged in as the client, then you would be using the wrong user ID in this case, but it should work fine for clients themselves. Alternatively, you could check to see if the staff is logged in as the client, and simply not display the credit section altogether.

 

i.e.

<?php if ($this->Html->ifSet($logged_in, false) && !$this->Html->ifSet($staff_as_client, false)) { ?>

 

As for

<div id="credit">Credit: <?php print_r( money_format('£%i', $this->Transactions->getTotalCredit(1, "GBP"))); ?></div>

Is there any particular reason you're not using the CurrencyFormat helper?

 

FYI, our future implentation of credits in the client interface will be much different than this.

Posted

Didn't even know currencyformat was there.

 

For some reason, that $logged_in is showing the incorrect client ID. I am logged in as client ID 1 (known to be correct because the correct credit amount shows when I manually use 1 in my code). I just echoed out $logged_in and it is showing the value of 4 and not 1?

 

And then if I log in as staff... it becomes 1 and then returns to 4 after logging out as the staff member. 

 

Just logged in as another test account. That showed the number 14 but the client ID should be 9 :l

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...