/**
  * creates shared tas
  */
 protected function _createSharedTimeaccounts()
 {
     // create 2 timeaccounts for each cc
     $taNumber = 1;
     $userGroup = Tinebase_Group::getInstance()->getGroupByName('Users');
     $developmentString = self::$_de ? 'Entwicklung' : 'Development';
     if (!$userGroup) {
         die('Could not find userGroup "Users", stopping.');
     }
     $grants = array(array('account_id' => $userGroup->getId(), 'account_type' => 'group', 'bookOwnGrant' => TRUE, 'viewAllGrant' => TRUE, 'bookAllGrant' => TRUE, 'manageBillableGrant' => TRUE, 'exportGrant' => TRUE, 'adminGrant' => TRUE));
     $contractsIndex = 0;
     foreach ($this->_costCenters as $costcenter) {
         $this->_timeAccounts[$costcenter->getId()] = new Tinebase_Record_RecordSet('Timetracker_Model_Timeaccount');
         $i = 0;
         while ($i < 2) {
             $i++;
             $ta = new Timetracker_Model_Timeaccount(array('number' => $taNumber, 'title' => Tinebase_Record_Abstract::generateUID(3), 'grants' => $grants, 'status' => 'billed', 'cleared_at' => $this->_clearedDate, 'budget' => NULL, 'description' => 'Created By Tine 2.0 DEMO DATA'));
             if ($costcenter->remark == 'Marketing' || $costcenter->remark == $developmentString) {
                 $contract = $costcenter->remark == 'Marketing' ? $this->_contractsMarketing->getByIndex(rand(0, $this->_contractsMarketing->count() - 1)) : $this->_contractsDevelopment->getByIndex(rand(0, $this->_contractsDevelopment->count() - 1));
                 $ta->budget = $costcenter->remark == 'Marketing' ? 100 : NULL;
                 $ta->relations = array(array('own_model' => 'Timetracker_Model_Timeaccount', 'own_backend' => 'SQL', 'own_id' => NULL, 'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_model' => 'Sales_Model_CostCenter', 'related_backend' => Tasks_Backend_Factory::SQL, 'related_id' => $costcenter->getId(), 'type' => 'COST_CENTER'), array('own_model' => 'Timetracker_Model_Timeaccount', 'own_backend' => 'SQL', 'own_id' => NULL, 'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_model' => 'Sales_Model_Contract', 'related_backend' => Tasks_Backend_Factory::SQL, 'related_id' => $contract->getId(), 'type' => 'TIME_ACCOUNT'));
                 $ta->title = (self::$_de ? 'Zeitkonto mit ' : 'Timeaccount for ') . $contract->getTitle();
             } else {
                 $ta->title = (self::$_de ? 'Zeitkonto mit KST ' : 'Timeaccount for CC ') . $costcenter->getTitle();
                 $ta->relations = array(array('own_model' => 'Timetracker_Model_Timeaccount', 'own_backend' => 'SQL', 'own_id' => NULL, 'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_model' => 'Sales_Model_CostCenter', 'related_backend' => Tasks_Backend_Factory::SQL, 'related_id' => $costcenter->getId(), 'type' => 'COST_CENTER'));
             }
             $this->_timeAccounts[$costcenter->getId()]->addRecord($this->_taController->create($ta));
             $taNumber++;
         }
     }
 }
 /**
  * 
  * @param array $recordData
  * @return Tinebase_Record_RecordSet
  */
 protected function _createTimeaccounts($recordData = NULL)
 {
     $this->_timeaccountRecords = new Tinebase_Record_RecordSet('Timetracker_Model_Timeaccount');
     $this->_timeaccountController = Timetracker_Controller_Timeaccount::getInstance();
     if (!$recordData) {
         // ta for customer 1 and 2 is budgeted AND to bill
         foreach ($this->_customerRecords as $customer) {
             $this->_timeaccountRecords->addRecord($this->_timeaccountController->create(new Timetracker_Model_Timeaccount(array('title' => 'TA-for-' . $customer->name, 'description' => 'blabla', 'is_open' => 1, 'status' => $customer->name == 'Customer4' ? 'billed' : 'to bill', 'budget' => $customer->name == 'Customer3' ? null : 100), TRUE)));
         }
     } else {
         foreach ($recordData as $taArray) {
             $this->_timeaccountRecords->addRecord($this->_timeaccountController->create(new Timetracker_Model_Timeaccount($taArray, TRUE)));
         }
     }
     return $this->_timeaccountRecords;
 }