mauriez Posted September 16, 2013 Report Posted September 16, 2013 Hi! I just read this: http://74.80.216.101/forums/showthread.php?t=1274 However, I have not found any documentation regarding this. Is the feature implemented in V3.0.2? Or is it still planned? thanks! Quote
Alex Posted September 16, 2013 Report Posted September 16, 2013 I believe this should do the trick: http://source-docs.blesta.com/class-Transactions.html#_getList Quote
mauriez Posted September 16, 2013 Author Report Posted September 16, 2013 Thanks.. But is there no getTotal() or getCredit() yet? I do see the total shown in the Admin panel, but maybe thats built using the same getList()? Quote
Alex Posted September 16, 2013 Report Posted September 16, 2013 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 Quote
mauriez Posted September 16, 2013 Author Report Posted September 16, 2013 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! Quote
Alex Posted September 16, 2013 Report Posted September 16, 2013 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. Quote
Evaske Posted September 17, 2013 Report Posted September 17, 2013 Is there a way to use this without connecting to the API so I can display the client credit in the dashboard? Quote
pepijn Posted September 18, 2013 Report Posted September 18, 2013 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"); Evaske 1 Quote
Evaske Posted September 18, 2013 Report Posted September 18, 2013 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 Quote
Tyson Posted September 18, 2013 Report Posted September 18, 2013 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.