/**
  * tests if the modelconfiguration gets created using the static call
  */
 public function testModelCreation()
 {
     $employeeCObj = HumanResources_Model_Employee::getConfiguration();
     $fields = $employeeCObj->getFields();
     // test modlog field
     $this->assertArrayHasKey('deleted_time', $fields);
     // test supervisor_id field
     $this->assertArrayHasKey('supervisor_id', $fields);
     $this->assertArrayHasKey('notes', $fields);
     $this->assertArrayHasKey('tags', $fields);
     $contractCObj = HumanResources_Model_Contract::getConfiguration();
     $fields = $contractCObj->getFields();
     // test supervisor_id field not existing in contact configuration object
     $this->assertArrayNotHasKey('supervisor_id', $fields);
     $this->assertArrayHasKey('employee_id', $fields);
     // test employee config again, so nothing gets overwritten
     $employeeCObj = HumanResources_Model_Employee::getConfiguration();
     $fields = $employeeCObj->getFields();
     $this->assertArrayHasKey('deleted_time', $fields);
     $this->assertArrayHasKey('supervisor_id', $fields);
     $this->assertArrayHasKey('id', $fields);
     $account = Tinebase_Core::getUser();
     $employee = new HumanResources_Model_Employee(array('account_id' => $account->getId(), 'n_family' => $account->accountLastName, 'n_given' => $account->accountFirstName));
     // test record fields
     $modelConfig = $employee::getConfiguration();
     $resolveFields = $modelConfig->recordFields;
     $this->assertArrayHasKey('account_id', $resolveFields);
     $this->assertArrayHasKey('division_id', $resolveFields);
     $this->assertArrayHasKey('created_by', $resolveFields);
     $this->assertArrayHasKey('last_modified_by', $resolveFields);
     $this->assertArrayHasKey('deleted_by', $resolveFields);
     $contact = new Addressbook_Model_Contact(array('n_family' => 'Spencer', 'n_given' => 'Bud'));
     $co = $contact::getConfiguration();
     $this->assertNull($co);
     // test the created filter model
     $filterModel = $employee::getConfiguration()->filterModel;
     $this->assertArrayHasKey('id', $filterModel);
     $this->assertArrayHasKey('query', $filterModel);
     $this->assertArrayHasKey('account_id', $filterModel);
     $this->assertArrayHasKey('supervisor_id', $filterModel);
     $this->assertArrayHasKey('options', $filterModel['supervisor_id']);
     $this->assertArrayHasKey('controller', $filterModel['supervisor_id']['options']);
     $this->assertArrayHasKey('filtergroup', $filterModel['supervisor_id']['options']);
     $this->assertArrayHasKey('division_id', $filterModel);
     $this->assertArrayHasKey('created_by', $filterModel);
     $this->assertArrayHasKey('last_modified_by', $filterModel);
     $this->assertArrayHasKey('deleted_by', $filterModel);
     $this->assertArrayNotHasKey('employee_id', $filterModel);
     $this->assertEquals('Tinebase_Model_Filter_Query', $filterModel['query']['filter']);
 }
 /**
  * update employee
  * 
  * @param Zend_Console_Getopt $opts
  * @param HumanResources_Model_Employee $employee
  * @param HumanResources_Model_Employee $currentEmployee
  * @return HumanResources_Model_Employee
  */
 protected function _updateImportedEmployee($opts, $employee, $currentEmployee)
 {
     if ($opts->v) {
         echo "Updating employee " . $employee->n_fn . ".\n";
     }
     // update only some fields
     $fieldsToUpdate = array('postalcode', 'locality', 'street', 'bday', 'employment_begin', 'employment_end', 'bank_account_number', 'bank_name', 'bank_code_number', 'health_insurance', 'number', 'contracts');
     $changed = FALSE;
     foreach ($fieldsToUpdate as $field) {
         if (!empty($employee->{$field}) && $currentEmployee->{$field} !== $employee->{$field}) {
             if ($field === 'contracts' && !empty($currentEmployee->{$field})) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($currentEmployee->toArray(), TRUE));
                 }
             } else {
                 $currentEmployee->{$field} = $employee->{$field};
             }
             $changed = TRUE;
         }
     }
     if ($opts->d || !$changed) {
         $result = $currentEmployee;
     } else {
         $json = new HumanResources_Frontend_Json();
         $result = $json->saveEmployee($currentEmployee->toArray());
         if ($currentEmployee->contracts) {
             $rs = new Tinebase_Record_RecordSet('HumanResources_Model_Contract');
             foreach ($currentEmployee->contracts as $contract) {
                 $rs->addRecord(new HumanResources_Model_Contract($contract));
             }
             $currentEmployee->contracts = $rs;
         }
         if ($currentEmployee->costcenters) {
             $ccrs = new Tinebase_Record_RecordSet('HumanResources_Model_CostCenter');
             foreach ($currentEmployee->costcenters as $costcenter) {
                 $ccrs->addRecord(new HumanResources_Model_CostCenter($costcenter));
             }
             $currentEmployee->costcenters = $ccrs;
         }
         $result = HumanResources_Controller_Employee::getInstance()->update($currentEmployee);
     }
     return $result;
 }