Inheritance: extends Prado\Collections\TList
 function testAllReturnsCollectionOfAccounts()
 {
     $http_response = dummyObject(['status' => '200', 'body' => '{"data":[{"id":1,"name":"Name","slug":"slug","timezone":"UTC"}]}']);
     $request = $this->getMockBuilder('\\Test\\Request')->getMock();
     $request->method('get')->with($this->equalTo('accounts'))->willReturn(new \GatherContent\Response($http_response));
     $subject = new AccountCollection($request);
     $accounts = $subject->all();
     $this->assertCount(1, $accounts);
     $account = $accounts[0];
     $this->assertInstanceOf('\\GatherContent\\Model\\Account', $account);
     $this->assertSame(1, $account->id);
     $this->assertEquals('Name', $account->name);
     $this->assertEquals('slug', $account->slug);
     $this->assertEquals('UTC', $account->timezone);
 }
Exemple #2
0
<?php
include('../config.php');
include('../functions.php');
include('../classes/accountcollection.class.php');
include('../classes/currencycollection.class.php');
include('../classes/clientcollection.class.php');

loginAdmin();
if(!loggedAdmin())
  header('location: index.php');

  if(isset($_POST['add']))
    $result = AccountCollection::addAccount();
  else
    AccountCollection::loadAccount();

  include("$templates/menu.php");

  $currencies = CurrencyCollection::getCurrencies();
  $clients = ClientCollection::getClients();

  include("$templates/account_edit.php");

  include("$templates/footer.php");
?>
  static public function addAccount() 
  {
    $result = AccountCollection::verifyFields();

    if(count($result))
      return ($result);
//  if all right, save data.

$_POST['id_account'] = $_POST['id_account'] ? $_POST['id_account'] : AccountCollection::generateAccountId();

$query = "INSERT INTO `account` (
`id` ,
`id_account` ,
`id_client` ,
`name` ,
`amount` ,
`id_currency` ,
`credit` ,
`debit` ,
`vdate1` ,
`vdate2` ,
`created_at` 
)
VALUES (
NULL , '".$_POST['id_account']."', '".$_POST['client']."', '".$_POST['aname']."', 
'".$_POST['amount']."', '".$_POST['currency']."', '".$_POST['credit']."', '".$_POST['debit']."', 
'".$_POST['valuec']."', '".$_POST['valued']."', CURRENT_TIMESTAMP );";

//die($query);

mysql_query($query);
header($_POST['id_account']? 'location: account_updated.php':'location: account_created.php');
  }
Exemple #4
0
<?php
include('../config.php');
include('../functions.php');
include('../classes/accountcollection.class.php');

loginAdmin();
if(!loggedAdmin())
  header('location: index.php');

  include("$templates/menu.php");

  $total = count(AccountCollection::getHistory())-1; 
  $instance = AccountCollection::getHistoryInstance(); 
  
  include("$templates/account_history.php");

  include("$templates/footer.php");
?>
Exemple #5
0
 public function loadFromArray(array $data = array())
 {
     foreach ($data as $key => $value) {
         if ($key === 'accounts') {
             $accounts = new AccountCollection();
             foreach ($value as $accountData) {
                 $class = 'Model\\WealthbotRebalancer\\Account';
                 $account = new $class();
                 $account->loadFromArray($accountData);
                 $accounts->add($account, $account->getId());
             }
             $this->setAccounts($accounts);
         } elseif ($key === 'ria') {
             $class = 'Model\\WealthbotRebalancer\\Ria';
             $ria = new $class();
             $ria->loadFromArray($value);
             $this->setRia($ria);
         } elseif ($key === 'portfolio') {
             $class = 'Model\\WealthbotRebalancer\\Portfolio';
             $portfolio = new $class();
             $portfolio->loadFromArray($value);
             $this->setPortfolio($portfolio);
         } elseif ($key === 'job') {
             $class = 'Model\\WealthbotRebalancer\\Job';
             $job = new $class();
             $job->loadFromArray($value);
             $this->setJob($job);
         } else {
             $this->{$key} = $value;
         }
     }
 }
Exemple #6
0
<?php
include('../config.php');
include('../functions.php');
include('../classes/accountcollection.class.php');
include('../classes/currencycollection.class.php');
include('../classes/clientcollection.class.php');

loginAdmin();
if(!loggedAdmin())
  header('location: index.php');

  if(exist($_POST['add']))
    $result = AccountCollection::addAccount();

  include("$templates/menu.php");

  $currencies = CurrencyCollection::getCurrencies();
  $clients = ClientCollection::getClients();

  include("$templates/account_add.php");

  include("$templates/footer.php");
?>
Exemple #7
0
 public function getAccounts()
 {
   if (is_null(self::$accounts)) self::$accounts = AccountCollection::retrieveByClient($this->getId());
   return self::$accounts;
 }