/**
  * Get accounts children
  *
  * @param array $input
  * 	An array as follows: array(id => $id);
  *
  * @return JSON encoded string
  *  A string as follows: [{"text" : $accountKey . " " . $accountName, "state" : {"opened" : true }, "icon" : $icon, "children" : [{"text" : $childAccountKey0 . " " . $childAccountName0, "icon" : $childIcon0}, …]}]
  */
 public function getAccountChildren($input)
 {
     $Account = $this->Account->byId($input['id']);
     $AccountType = $this->AccountType->byId($Account->account_type_id);
     $accountTree = array('text' => $Account->key . ' ' . $Account->name, 'state' => array('opened' => true), 'icon' => 'fa fa-sitemap', 'children' => array());
     $this->Account->byParent($input['id'])->each(function ($Account) use(&$accountTree) {
         if ($Account->is_group) {
             array_push($accountTree['children'], array('text' => $Account->key . ' ' . $Account->name, 'icon' => 'fa fa-sitemap'));
         } else {
             array_push($accountTree['children'], array('text' => $Account->key . ' ' . $Account->name, 'icon' => 'fa fa-leaf'));
         }
     });
     // return array(array('label' => $this->Lang->get('decima-accounting::account-management.D'), 'value'=> 'D'), array('label' => $this->Lang->get('decima-accounting::account-management.A'), 'value'=> 'A'));
     // $this->AccountType->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($AccountType) use (&$accountTypes)
     // {
     // array_push($accountTypes, array('label'=> $AccountType->name, 'value'=>$AccountType->id));
     // });
     return json_encode(array('accountTree' => $accountTree, 'balanceTypeName' => $this->Lang->get('decima-accounting::account-management.' . $Account->balance_type), 'balanceTypeValue' => $Account->balance_type, 'accountTypeName' => $AccountType->name, 'accountTypeValue' => $Account->account_type_id));
 }