public function getCostCenterChildren($input)
  {
    $CostCenter = $this->CostCenter->byId($input['id']);

    $costCenterTree = array('text' => $CostCenter->key . ' ' . $CostCenter->name, 'state' => array('opened' => true), 'icon' => 'fa fa-sitemap', 'children' => array());

    $this->CostCenter->byParent($input['id'])->each(function($CostCenter) use (&$costCenterTree)
    {
      if($CostCenter->is_group)
      {
        array_push($costCenterTree['children'], array('text' => $CostCenter->key . ' ' . $CostCenter->name, 'icon' => 'fa fa-sitemap'));
      }
      else
      {
        array_push($costCenterTree['children'], array('text' => $CostCenter->key . ' ' . $CostCenter->name, 'icon' => 'fa fa-leaf'));
      }
    });

    return json_encode(array($costCenterTree));
  }
public function getCostCenterChildren($input)
  {
    $CostCenter = $this->CostCenter->byId($input['id']);

    $costCenterTree = array('text' => $CostCenter->key . ' ' . $CostCenter->name, 'state' => array('opened' => true), 'icon' => 'fa fa-sitemap', 'children' => array());

    $this->CostCenter->byParent($input['id'])->each(function($CostCenter) use (&$costCenterTree)
    {
      if($CostCenter->is_group)
      {
        array_push($costCenterTree['children'], array('text' => $CostCenter->key . ' ' . $CostCenter->name, 'icon' => 'fa fa-sitemap'));
      }
      else
      {
        array_push($costCenterTree['children'], array('text' => $CostCenter->key . ' ' . $CostCenter->name, 'icon' => 'fa fa-leaf'));
      }
    });

    return json_encode(array($costCenterTree));
  }
public function getCostCenterChildren ( $ input ) { $ CostCenter = $ this -> CostCenter -> byId ( $ input [ 'id' ] ) ; $ costCenterTree = array ( 'text' => $ CostCenter -> key . ' ' . $ CostCenter -> name , 'state' => array ( 'opened' => true ) , 'icon' => 'fa fa-sitemap' , 'children' => array ( ) ) ; $ this -> CostCenter -> byParent ( $ input [ 'id' ] ) -> each ( function ( $ CostCenter ) use ( & $ costCenterTree ) { if ( $ CostCenter -> is_group ) { array_push ( $ costCenterTree [ 'children' ] , array ( 'text' => $ CostCenter -> key . ' ' . $ CostCenter -> name , 'icon' => 'fa fa-sitemap' ) ) ; } else { array_push ( $ costCenterTree [ 'children' ] , array ( 'text' => $ CostCenter -> key . ' ' . $ CostCenter -> name , 'icon' => 'fa fa-leaf' ) ) ; } } ) ; return json_encode ( array ( $ costCenterTree ) ) ; }
Get cost centers children

@param array $input
An array as follows: array(id => $id);

@return JSON encoded string
A string as follows: [{"text" : $costCenterKey . " " . $costCenterName, "state" : {"opened" : true }, "icon" : $icon, "children" : [{"text" : $childCostCenterKey0 . " " . $childCostCenterName0, "icon" : $childIcon0}, …]}]
Get cost centers children