Jump to content

Recommended Posts

Posted

No, I don't think there is a getTotal method or the like yet.

I'm not sure how the admin panel is contructed, but it may very well use queries which are unavailable through the API.

If you post the response data you get from getList() here I can probably whip up a bit of PHP to calculate the total for you.

Just guessing here, but something like this psuedo-code should work:

$total=0;
foreach(json_decode($getListResponse) as $transaction) {
  $total+=$transaction['amount'];
}
echo $total; // outputs the total amount transacted
Posted
  On 9/16/2013 at 5:23 PM, mauriez said:

Ah!

 

You triggered me looking it up in the PHP source code.. and I found it!

 

http://source-docs.blesta.com/class-Transactions.html#_getTotalCredit

 

Nice ;) 

 

thanks!

I had saw this, but I'm afraid it more likely pulls any positive balance sitting in the customers account, not the total of all their transactions. I could be wrong though, the wording is vague.

Posted
  On 9/18/2013 at 9:43 AM, pepijn said:

yes, the api directly calls the models, so you can use the model directly http://docs.blesta.com/display/dev/API#API-WithintheBlestaenvironment

 

// from somewhere in your controller...
$this->uses(array("Transactions"));
 
// Now invoke it
$this->Transactions->getTotalCredit(1, "USD");

 

That just throws up this error:

 

Call to undefined method View::uses() on line 73 in/home/evaske/public_html/Clients/app/views/client/default/structure.pdt

 

I had to use Loader::loadModels($this, array("Transactions")); instead :)

Posted
  On 9/18/2013 at 11:08 AM, Evaske said:

That just throws up this error:

 

Call to undefined method View::uses() on line 73 in/home/evaske/public_html/Clients/app/views/client/default/structure.pdt

 

I had to use Loader::loadModels($this, array("Transactions")); instead :)

 

 

Yes, $this->uses() is available to controllers, which is where models should be loaded--not from views. While you can get away with it by calling the Loader directly, doing so partially negates the logical separation of business logic and presentation in the MVC design pattern. Generally speaking, when your solution goes against the design pattern you're working within, it's a good idea to rethink your approach.

 

I'm not sure why you opted to not use the API, but core files are included in our patches and updates, which will overwrite your custom changes if you are not keeping record of them and merging file content accordingly.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...