/**
  * Get organization cost centers
  *
  * @return array
  *  An array of arrays as follows: array( array('label'=>$name0, 'value'=>$id0), array('label'=>$name1, 'value'=>$id1),…)
  */
 public function getGroupsCostCenters()
 {
     //Is Group: Further cost centers can be made under Groups, but entries can be made against non-Groups
     $costCenters = array();
     $this->CostCenter->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function ($CostCenter) use(&$costCenters) {
         if ($CostCenter->is_group) {
             array_push($costCenters, array('label' => $CostCenter->key . ' ' . $CostCenter->name, 'value' => $CostCenter->id));
         }
     });
     return $costCenters;
 }
 /**
  * Get organization cost centers
  *
  * @return array
  *  An array of arrays as follows: array ( 'organizationCostCenters' => array( array('label'=>$name0, 'value'=>$id0), array('label'=>$name1, 'value'=>$id1),…), 'defaultCostCenter' => array('id'=>$id, 'label'=>$label))
  */
 public function getCostCenters()
 {
     $costCenters = $defaultCostCenter = array();
     $count = 0;
     $this->CostCenter->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function ($CostCenter) use(&$costCenters, &$count, &$defaultCostCenter) {
         if (empty($CostCenter->is_group)) {
             $count++;
             if ($count == 1) {
                 $defaultCostCenter = array_add($defaultCostCenter, 'id', $CostCenter->id);
                 $defaultCostCenter = array_add($defaultCostCenter, 'label', $CostCenter->key . ' ' . $CostCenter->name);
             }
             array_push($costCenters, array('label' => $CostCenter->key . ' ' . $CostCenter->name, 'value' => $CostCenter->id));
         }
     });
     if ($count > 1) {
         $defaultCostCenter['id'] = $defaultCostCenter['label'] = '';
     }
     return array('organizationCostCenters' => $costCenters, 'defaultCostCenter' => $defaultCostCenter);
 }