/** * * @return array */ protected function _createSupplier() { $container = Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser()->getId(), 'Addressbook_Model_Contact', 'WRITE'); $containerContracts = Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser()->getId(), 'Sales_Model_Contract', 'WRITE'); $container = $container->getFirstRecord(); $contact1 = $this->_contactController->create(new Addressbook_Model_Contact(array('n_given' => 'Yiting', 'n_family' => 'Huang', 'container_id' => $container->getId()))); $contact2 = $this->_contactController->create(new Addressbook_Model_Contact(array('n_given' => 'Hans Friedrich', 'n_family' => 'Ochs', 'container_id' => $container->getId()))); $customerData = array('name' => 'Worldwide Electronics International', 'cpextern_id' => $contact1->getId(), 'cpintern_id' => $contact2->getId(), 'number' => 4294967, 'iban' => 'CN09234098324098234598', 'bic' => '0239580429570923432444', 'url' => 'http://wwei.cn', 'vatid' => '239rc9mwqe9c2q', 'credit_term' => '30', 'currency' => 'EUR', 'curreny_trans_rate' => 7.034, 'discount' => 12.5, 'adr_prefix1' => 'no prefix 1', 'adr_prefix2' => 'no prefix 2', 'adr_street' => 'Mao st. 2000', 'adr_postalcode' => '1', 'adr_locality' => 'Shanghai', 'adr_region' => 'Shanghai', 'adr_countryname' => 'China', 'adr_pobox' => '7777777'); return $this->_json->saveSupplier($customerData); }
public static function normalizeBankAccounts() { $limit = 400; \org\sopen\dev\DebugLogger::openLogFileAppend(CSopen::instance()->getConfigPath() . '/logs/sepa-integrate.log'); try { $dFilter = new Addressbook_Model_ContactFilter(array(array('field' => 'query', 'operator' => 'contains', 'value' => '')), 'AND'); /*$dFilter = new Addressbook_Model_ContactFilter(array(array( 'field' => 'contact_id', 'operator' => 'in', 'value' => array('100222', '100223') )), 'AND'); */ $contactIds = Addressbook_Controller_Contact::getInstance()->search($dFilter, null, false, true); \org\sopen\dev\DebugLogger::log('Count adress ids: ' . count($contactIds)); $count = 0; foreach ($contactIds as $contactId) { /*if($count++ > $limit){ break; }*/ $contact = Addressbook_Controller_Contact::getInstance()->get($contactId); self::doSepa($contact); //$bankAccountCollection = Billing_Controller_Debitor::getInstance()->getBankAccountCollectionForDebitor($debitor); } } catch (Exception $e) { \org\sopen\dev\DebugLogger::log('global error: ' . $e->__toString()); } }
/** * test sync of existing contacts folder */ public function testSyncOfContacts() { $container = $this->_getPersonalContainer('Addressbook'); $this->_syncFolder(); $this->_requestInitialSynckey($container); // now do the first sync $sync = $this->_sync($container); $syncDoc = $sync->getResponse(); // we make sure that there are always > 0 contacts in this container if ($syncDoc === null) { $contact = new Addressbook_Model_Contact(array('n_family' => 'lala', 'container_id' => $container->getId())); Addressbook_Controller_Contact::getInstance()->create($contact); $sync = $this->_sync($container); $syncDoc = $sync->getResponse(); } #$syncDoc->formatOutput = true; echo $syncDoc->saveXML(); $xpath = new DomXPath($syncDoc); $xpath->registerNamespace('AirSync', 'uri:AirSync'); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Class'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals('Contacts', $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:SyncKey'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals(2, $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Status'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals(Syncroton_Command_Sync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Commands'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals("uri:Contacts", $syncDoc->lookupNamespaceURI('Contacts'), $syncDoc->saveXML()); }
protected function appendDependentRecords($record) { if ($record->__get('debitor_id')) { $this->appendForeignRecordToRecord($record, 'debitor_id', 'debitor_id', 'id', new Billing_Backend_Debitor()); $debitor = $record->__get('debitor_id'); try { if (is_object($debitor)) { $contactId = $debitor->__get('contact_id'); } else { $contactId = $debitor->contact_id; } $contact = Addressbook_Controller_Contact::getInstance()->get($contactId); if (is_object($debitor)) { $debitor->__set('contact_id', $contact->toArray()); } else { $debitor->contact_id = $contact->toArray(); } } catch (Exception $e) { } $record->__set('debitor_id', $debitor); } if ($record->__get('job_id')) { $this->appendForeignRecordToRecord($record, 'job_id', 'job_id', 'id', new Billing_Backend_Job()); } if ($record->__get('price_group_id')) { $this->appendForeignRecordToRecord($record, 'price_group_id', 'price_group_id', 'id', new Billing_Backend_PriceGroup()); } if ($record->__get('payment_method_id')) { $this->appendForeignRecordToRecord($record, 'payment_method_id', 'payment_method_id', 'id', new Billing_Backend_PaymentMethod()); } }
/** * test useNotes */ public function testUseNotes() { $contact = $this->objects['initialContact']; $contact1 = clone $contact; $contact1->notes = array(new Tinebase_Record_RecordSet('Tinebase_Model_Note', array($this->objects['note']))); $contact->notes = array(new Tinebase_Record_RecordSet('Tinebase_Model_Note', array($this->objects['note']))); $newcontact1 = $this->_instance->create($contact1); $this->_instance->delete($newcontact1); $this->_instance->useNotes(false); $this->objects['contact'] = $this->_instance->create($contact); $compStr = 'Array ( [0] => Array ( [note_type_id] => 1 [note] => phpunit test note [record_backend] => Sql [id] => ) )'; $this->assertTrue($newcontact1->has('notes')); $this->assertEquals($compStr, $newcontact1->notes[0]->note); $this->setExpectedException('Tinebase_Exception_NotFound'); $this->objects['contact']->notes[0]->note = 'note'; }
protected function appendDependentRecords($record) { if ($record->__get('open_item_id')) { $this->appendForeignRecordToRecord($record, 'open_item_id', 'open_item_id', 'id', new Billing_Backend_OpenItem()); } if ($record->__get('monition_receipt_id')) { $this->appendForeignRecordToRecord($record, 'monition_receipt_id', 'monition_receipt_id', 'id', new Billing_Backend_Receipt()); } if ($record->__get('debitor_id')) { $this->appendForeignRecordToRecord($record, 'debitor_id', 'debitor_id', 'id', new Billing_Backend_Debitor()); $debitor = $record->__get('debitor_id'); try { if (is_object($debitor)) { $contactId = $debitor->__get('contact_id'); } else { $contactId = $debitor->contact_id; } $contact = Addressbook_Controller_Contact::getInstance()->get($contactId); if (is_object($debitor)) { $debitor->__set('contact_id', $contact->toArray()); } else { $debitor->contact_id = $contact->toArray(); } } catch (Exception $e) { } $record->__set('debitor_id', $debitor); } }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb()); $this->_contactController = Addressbook_Controller_Contact::getInstance(); $this->_contractController = Sales_Controller_Contract::getInstance(); $this->_json = new Sales_Frontend_Json(); }
/** * the singleton pattern * * @return Addressbook_Controller_Contact */ public static function getInstance() { if (self::$_instance === NULL) { self::$_instance = new Addressbook_Controller_Contact(); } return self::$_instance; }
/** * resolve memberroles * * @param $records */ protected function _resolveMemberroles($records) { $listRoles = Addressbook_Controller_ListRole::getInstance()->getAll(); $contactIds = array(); foreach ($records as $record) { if (isset($record->memberroles)) { $contactIds = array_merge($contactIds, $record->memberroles->contact_id); } } if (count($contactIds) > 0) { $contacts = Addressbook_Controller_Contact::getInstance()->getMultiple($contactIds); } foreach ($records as $list) { if (isset($record->memberroles)) { foreach ($list->memberroles as $memberrole) { $contact = $contacts->getById($memberrole->contact_id); if ($contact) { $memberrole->contact_id = $contact; } $listRole = $listRoles->getById($memberrole->list_role_id); if ($listRole) { $memberrole->list_role_id = $listRole; } } } } }
/** * update to 9.1 * * @return void */ public function update_0() { // we need at least addressbook version 9,7 if (version_compare($this->getApplicationVersion('Addressbook'), '9.8') < 0) { return; } $setupUser = $this->_getSetupFromConfigOrCreateOnTheFly(); if ($setupUser) { Tinebase_Core::set(Tinebase_Core::USER, $setupUser); $filter = new Phone_Model_CallFilter(array(array('field' => 'start', 'operator' => 'after', 'value' => date('Y-m-d H:i:s', time() - 3600 * 24 * 30 * 3))), 'AND', array('ignoreAcl' => true)); $addressbookController = Addressbook_Controller_Contact::getInstance(); $phoneController = Phone_Controller_Call::getInstance(); $calls = $phoneController->search($filter); foreach ($calls as $_record) { // resolve telephone number to contacts if possible $telNumber = Addressbook_Model_Contact::normalizeTelephoneNoCountry($phoneController->resolveInternalNumber($_record->destination)); if (null === $telNumber) { continue; } $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'telephone_normalized', 'operator' => 'equals', 'value' => $telNumber))); $contacts = $addressbookController->search($filter); $relations = array(); foreach ($contacts as $contact) { $relations[] = array('related_model' => 'Addressbook_Model_Contact', 'related_id' => $contact->getId(), 'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_backend' => Tinebase_Model_Relation::DEFAULT_RECORD_BACKEND, 'type' => 'CALLER'); } if (count($relations) > 0) { $_record->relations = $relations; $phoneController->update($_record); } } } $this->setApplicationVersion('Phone', '9.1'); }
public function printDocs() { // print payments which are debit returns and have flag print inquiry $resultData = array(); $filters = array(array('field' => 'is_return_debit', 'operator' => 'equals', 'value' => '1'), array('field' => 'print_inquiry', 'operator' => 'equals', 'value' => '1'), array('field' => 'inquiry_print_date', 'operator' => 'isnull', 'value' => '')); $objFilter = new Billing_Model_PaymentFilter($filters, 'AND'); $paymentIds = Billing_Controller_Payment::getInstance()->search($objFilter, null, null, true); foreach ($paymentIds as $paymentId) { $payment = Billing_Controller_Payment::getInstance()->get($paymentId); // get base payment $basePayment = $payment->getForeignRecordBreakNull('return_debit_base_payment_id', Billing_Controller_Payment::getInstance()); if ($basePayment) { $batchJobDta = $basePayment->getForeignRecordBreakNull('batch_job_dta_id', Billing_Controller_BatchJobDta::getInstance()); if ($batchJobDta) { $bankAccount = Billing_Api_BankAccount::getFromBatchJobDta($batchJobDta); $debitor = $payment->getForeignRecord('debitor_id', Billing_Controller_Debitor::getInstance()); $contact = $debitor->getForeignRecord('contact_id', Addressbook_Controller_Contact::getInstance()); $data = array(); $dummyTextBlocks = null; $data = array_merge($data, Addressbook_Custom_Template::getContactData(array('contact' => $contact, 'user' => Tinebase_Core::get(Tinebase_Core::USER), 'userContact' => Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::get(Tinebase_Core::USER)->getId())), $dummyTextBlocks)); $data = array_merge($data, array('bank_name' => $bankAccount->getBank(), 'account_name' => $bankAccount->getName(), 'account_nr' => $bankAccount->getNumber(), 'bank_code' => $bankAccount->getBankCode())); $resultData[$contact->__get('n_fileas')] = $data; $payment->__set('inquiry_print_date', new Zend_Date()); Billing_Controller_Payment::getInstance()->update($payment); } } } $outputFileName = 'Ruecklastschrift-Nachforschung-' . strftime('%d-%m-%Y %H-%M-%S') . '.pdf'; $templateId = Tinebase_Core::getPreference('Billing')->getValue(Billing_Preference::TEMPLATE_DEBIT_RETURN_INQUIRY); ksort($resultData); Billing_Controller_PrintJobRecordData::getInstance()->export($resultData, $templateId, $outputFileName); }
protected function appendDependentRecords($record) { if ($record->__get('debitor_id')) { $this->appendForeignRecordToRecord($record, 'debitor_id', 'debitor_id', 'id', new Billing_Backend_Debitor()); $debitor = $record->__get('debitor_id'); try { if (is_object($debitor)) { $contactId = $debitor->__get('contact_id'); } else { $contactId = $debitor->contact_id; } $contact = Addressbook_Controller_Contact::getInstance()->get($contactId); if (is_object($debitor)) { $debitor->__set('contact_id', $contact->toArray()); } else { $debitor->contact_id = $contact->toArray(); } } catch (Exception $e) { } $record->__set('debitor_id', $debitor); } if ($record->__get('op_id')) { $this->appendForeignRecordToRecord($record, 'op_id', 'op_id', 'id', new Billing_Backend_OpenItem()); } if ($record->__get('account_system_id')) { $this->appendForeignRecordToRecord($record, 'account_system_id', 'account_system_id', 'id', new Billing_Backend_AccountSystem()); } if ($record->__get('account_system_id_haben')) { $this->appendForeignRecordToRecord($record, 'account_system_id_haben', 'account_system_id_haben', 'id', new Billing_Backend_AccountSystem()); } if ($record->__get('return_debit_base_payment_id')) { $this->appendForeignRecordToRecord($record, 'return_debit_base_payment_id', 'return_debit_base_payment_id', 'id', new Billing_Backend_Payment()); } }
/** * tear down tests * */ public function tearDown() { parent::tearDown(); foreach ($this->_testEmailContacts as $email) { $contactIdsToDelete = Addressbook_Controller_Contact::getInstance()->search(new Addressbook_Model_ContactFilter(array(array('field' => 'containerType', 'operator' => 'equals', 'value' => 'all'), array('field' => 'email', 'operator' => 'equals', 'value' => $email))), null, false, true); Addressbook_Controller_Contact::getInstance()->delete($contactIdsToDelete); } }
/** * resolves a record * * @param string $value * @return array|string */ protected function _resolveRecord($value) { if ($value === Addressbook_Model_Contact::CURRENTCONTACT) { $contact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId(), TRUE)->toArray(); } else { $contact = parent::_resolveRecord($value); } return $contact; }
/** * try to add an account * */ public function testAddAccount() { $account = Admin_Controller_User::getInstance()->create($this->objects['initialAccount'], 'lars', 'lars'); $this->assertTrue(!empty($account->accountId)); //$this->assertTrue($this->objects['initialAccount']->accountId != $account->accountId); $this->assertEquals($this->objects['initialAccount']->accountLoginName, $account->accountLoginName); $contact = Addressbook_Controller_Contact::getInstance()->getContactByUserId($account->accountId); $this->assertTrue(!empty($contact->creation_time)); }
/** * testGetTranslatedValue * * @see 0008600: Fix fatal error in Calendar/Model/Event.php */ public function testGetTranslatedValue() { $event = new Calendar_Model_Event(array('dtstart' => new Tinebase_DateTime('2011-11-23 14:25:00'), 'dtend' => new Tinebase_DateTime('2011-11-23 15:25:00'), 'summary' => 'test event', 'organizer' => Tinebase_Core::getUser()->contact_id)); $translation = Tinebase_Translation::getTranslation('Calendar'); $timezone = Tinebase_Core::getPreference()->getValueForUser(Tinebase_Preference::TIMEZONE, Tinebase_Core::getUser()->getId()); $fileas = Calendar_Model_Event::getTranslatedValue('organizer', $event->organizer, $translation, $timezone); $userContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId()); $this->assertEquals($userContact->n_fileas, $fileas); }
/** * test equals operator of creation time filter */ public function testCreationTimeEqualsOperator() { $contact = $this->_addContact(); $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $contact->container_id), array('field' => 'owner', 'operator' => 'equals', 'value' => Zend_Registry::get('currentAccount')->getId()))); $count1 = $this->_instance->searchCount($filter); $date = Tinebase_DateTime::now(); $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'creation_time', 'operator' => 'equals', 'value' => $date->toString('Y-m-d')), array('field' => 'container_id', 'operator' => 'equals', 'value' => $contact->container_id), array('field' => 'owner', 'operator' => 'equals', 'value' => Zend_Registry::get('currentAccount')->getId()))); $count2 = $this->_instance->searchCount($filter); $this->assertEquals($count1, $count2); }
/** * try to update a list */ public function testUpdateList() { $list = $this->testAddList(); $list->members = array($this->objects['contact2']); $list = $this->_instance->update($list); $this->assertEquals(1, count($list->members)); $contactId = $list->members[0]; $contact = Addressbook_Controller_Contact::getInstance()->get($contactId); $this->assertEquals($this->objects['contact2']->adr_one_locality, $contact->adr_one_locality); }
public function testEmptyStringValues() { $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->contact_id), array('field' => 'org_unit', 'operator' => 'equals', 'value' => ''))); $this->assertEquals(1, count(Addressbook_Controller_Contact::getInstance()->search($filter)), 'org_unit is NULL and should be included with empty string'); $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->contact_id), array('field' => 'n_fileas', 'operator' => 'equals', 'value' => ''))); $this->assertEquals(0, count(Addressbook_Controller_Contact::getInstance()->search($filter)), 'n_fileas is set and should not be included with empty string'); $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->contact_id), array('field' => 'org_unit', 'operator' => 'not', 'value' => ''))); $this->assertEquals(0, count(Addressbook_Controller_Contact::getInstance()->search($filter)), 'org_unit is NULL and should be not included with empty string with not operator'); $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->contact_id), array('field' => 'n_fileas', 'operator' => 'not', 'value' => ''))); $this->assertEquals(1, count(Addressbook_Controller_Contact::getInstance()->search($filter)), 'n_fileas is set and should be included with empty string and not operator'); }
/** * try to add an account */ public function testAddAccount() { $account = Admin_Controller_User::getInstance()->create($this->objects['initialAccount'], 'lars', 'lars'); $this->assertTrue(!empty($account->accountId)); $this->assertEquals($this->objects['initialAccount']->accountLoginName, $account->accountLoginName); $contact = Addressbook_Controller_Contact::getInstance()->getContactByUserId($account->accountId); $this->assertTrue(!empty($contact->creation_time)); $this->assertEquals(Tinebase_Core::getUser()->accountId, $account->created_by, 'created_by not matching'); $this->assertTrue($account->creation_time instanceof Tinebase_DateTime, 'creation time not set: ' . print_r($account->toArray(), true)); $this->assertEquals(Tinebase_DateTime::now()->format('Y-m-d'), $account->creation_time->format('Y-m-d')); }
/** * appends sql to given select statement * * @param Zend_Db_Select $_select * @param Tinebase_Backend_Sql_Abstract $_backend */ public function appendFilterSql($_select, $_backend) { if ($this->_value) { $filterData = array(array('field' => 'debitor_nr', 'operator' => $this->_operator, 'value' => $this->_value)); $filter = new Billing_Model_DebitorFilter($filterData, 'OR'); $contactFilter = new Addressbook_Model_ContactFilter(array(array('field' => 'query', 'operator' => $this->_operator, 'value' => $this->_value))); $contactIds = Addressbook_Controller_Contact::getInstance()->search($contactFilter, NULL, FALSE, TRUE); $filter->addFilter(new Tinebase_Model_Filter_Id('contact_id', 'in', $contactIds)); Tinebase_Backend_Sql_Filter_FilterGroup::appendFilters($_select, $filter, $_backend); } }
/** * @see 0011934: show contacts in phone call grid */ public function testContactRelation() { $phoneNumber = '0406437435'; $myContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId()); $myContact->tel_work = $phoneNumber; Addressbook_Controller_Contact::getInstance()->update($myContact); $call = new Phone_Model_Call(array('line_id' => 'phpunitlineid', 'phone_id' => 'phpunitphoneid', 'direction' => Phone_Model_Call::TYPE_INCOMING, 'source' => '26', 'destination' => $phoneNumber)); $call = Phone_Controller_Call::getInstance()->create($call); $this->assertEquals(1, count($call->relations), 'my contact should be added as relation to the call' . print_r($call->toArray(), true)); $this->assertEquals($myContact->getId(), $call->relations->getFirstRecord()->related_id); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { parent::setUp(); $this->_testContainer = $this->_getPersonalContainer('Crm'); $this->objects['lead'] = new Crm_Model_Lead(array('lead_name' => 'PHPUnit', 'leadstate_id' => 1, 'leadtype_id' => 1, 'leadsource_id' => 1, 'container_id' => $this->_testContainer->id, 'start' => new Tinebase_DateTime("2007-12-12"), 'description' => 'Lead Description', 'end' => Tinebase_DateTime::now(), 'turnover' => '200000', 'probability' => 70, 'end_scheduled' => Tinebase_DateTime::now())); $this->objects['leadWithLink'] = new Crm_Model_Lead(array('lead_name' => 'PHPUnit with contact', 'leadstate_id' => 1, 'leadtype_id' => 1, 'leadsource_id' => 1, 'container_id' => $this->_testContainer->id, 'start' => new Tinebase_DateTime("2007-12-24"), 'description' => 'Lead Description', 'end' => Tinebase_DateTime::now(), 'turnover' => '200000', 'probability' => 50, 'end_scheduled' => Tinebase_DateTime::now())); $this->objects['linkedContact'] = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'assistent' => 'Cornelius Weiß', 'bday' => '1975-01-02 03:04:05', 'email' => '*****@*****.**', 'email_home' => '*****@*****.**', 'note' => 'Bla Bla Bla', 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars', 'n_given' => 'Lars', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK')); $this->objects['linkedTask'] = new Tasks_Model_Task(array('summary' => 'task test')); Crm_Controller_Lead::getInstance()->create($this->objects['leadWithLink']); $this->objects['linkedContact'] = Addressbook_Controller_Contact::getInstance()->create($this->objects['linkedContact'], FALSE); }
/** * test converting vcard from sogo connector to Calendar_Model_Event */ public function testConvertToTine20Model() { $vcalendarStream = fopen(dirname(__FILE__) . '/../../../Import/files/lightning.ics', 'r'); $converter = Tasks_Convert_Task_VCalendar_Factory::factory(Tasks_Convert_Task_VCalendar_Factory::CLIENT_GENERIC); $event = $converter->toTine20Model($vcalendarStream); $organizer = Addressbook_Controller_Contact::getInstance()->get($event->organizer); $this->assertEquals(Calendar_Model_Event::CLASS_PRIVATE, $event->class); $this->assertEquals('Hamburg', $event->location); $this->assertEquals('*****@*****.**', $organizer->email); $this->assertGreaterThan(0, count($event->attendee->filter('user_id', $event->organizer)), 'Organizer must be attendee too'); }
public function exportArticleSellList($data, $exportType) { $export = Billing_Custom_ArticleExportData::create($data); if ($export->hasNoGrouping() || $exportType == 'CSV') { $export->setRecordSet(Billing_Controller_ArticleSold::getInstance()->search($export->getFilter(), $export->getPagination())); } elseif ($export->hasGroupingCustomer()) { // get all customers // -> maybe a huge set // check restrictions of filter regarding customer (customer_group) /* $debitorFilter = new Billing_Model_DebitorFilter(array(),'AND'); $debFilter = null; $articleFilter = $export->getFilter(); if($articleFilter->isFilterSet('debitor_id')){ $debFilter = $articleFilter->getFilter('debitor_id'); if($debFilter->isFilterSet('id')){ $debitorFilter->addFilter($debFilter->get('id')); } if($debFilter->isFilterSet('debitor_group_id')){ $debitorFilter->addFilter($debFilter->get('debitor_group_id')); } }*/ $debitorIds = Billing_Controller_ArticleSold::getInstance()->getDebitorIds($export->getFilter()); foreach ($debitorIds as $debitorId) { $debitor = Billing_Controller_Debitor::getInstance()->get($debitorId); $export->addCustomerRecordSet(Billing_Controller_ArticleSold::getInstance()->search($export->getCustomerFilter($debitor), $export->getPagination()), $debitorId); } } switch ($exportType) { case 'PDF': $outputFileName = 'Artikel-Verkaufsliste-' . strftime('%d-%m-%Y %H-%M-%S') . '.pdf'; $templateId = Tinebase_Core::getPreference('Billing')->getValue(Billing_Preference::TEMPLATE_ARTICLE_SOLD); if ($export->hasGroupingCustomer()) { $data = array(); $aResult = $export->customerRecordsToArray(true); foreach ($aResult as $debitorId => $result) { $debitor = Billing_Controller_Debitor::getInstance()->get($debitorId); $contact = $debitor->getForeignRecord('contact_id', Addressbook_Controller_Contact::getInstance()); $data[$contact->__get('n_fileas')] = array('POS_TABLE' => $result['data'], 'customer_nr' => $debitor->__get('debitor_nr'), 'customer_name' => $contact->__get('n_fileas'), 'begin_date' => \org\sopen\app\util\format\Date::format(new Zend_Date($export->getStartDate())), 'end_date' => $export->getEndDate() ? \org\sopen\app\util\format\Date::format(new Zend_Date($export->getEndDate())) : 'heute', 'sum_total_netto' => number_format($result['total_netto'], 2, ',', '.'), 'sum_total_brutto' => number_format($result['total_brutto'], 2, ',', '.')); } ksort($data); } else { $data = array(array('POS_TABLE' => $export->toArray(true), 'begin_date' => \org\sopen\app\util\format\Date::format(new Zend_Date($export->getStartDate())), 'end_date' => $export->getEndDate() ? \org\sopen\app\util\format\Date::format(new Zend_Date($export->getEndDate())) : 'heute', 'sum_total_netto' => number_format($export->getSumTotalNetto(), 2, ',', '.'), 'sum_total_brutto' => number_format($export->getSumTotalBrutto(), 2, ',', '.'))); } Billing_Controller_PrintJobRecordData::getInstance()->export($data, $templateId, $outputFileName); break; case 'CSV': $this->exportAsCsv($export, 'Artikel-Verkaufsliste-' . strftime('%d-%m-%Y %H-%M-%S') . '.csv'); break; } }
/** * tests if creating reduced demodata is possible */ public function testCreateReducedDemoData() { ob_start(); Addressbook_Setup_DemoData::getInstance()->createDemoData(array('locale' => 'de')); ob_end_clean(); $c = Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser(), 'Addressbook', FALSE); $id = $c->getId(); $id = $id[1]; $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $id))); $result = Addressbook_Controller_Contact::getInstance()->search($filter); $this->assertEquals(20, count($result)); }
/** * export contact * * @param string $filter JSON encoded string with contact ids for multi export or contact filter * @param string $options format or export definition id */ public function exportContacts($filter, $options) { $decodedFilter = Zend_Json::decode($filter); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Export filter: ' . print_r($decodedFilter, TRUE)); } if (!is_array($decodedFilter)) { $decodedFilter = array(array('field' => 'id', 'operator' => 'equals', 'value' => $decodedFilter)); } $filter = new Addressbook_Model_ContactFilter($decodedFilter); parent::_export($filter, Zend_Json::decode($options), Addressbook_Controller_Contact::getInstance()); }
/** * resolve records and prepare for export (set user timezone, ...) * * @param Tinebase_Record_RecordSet $_records */ protected function _resolveRecords(Tinebase_Record_RecordSet $_records) { Calendar_Model_Attender::resolveAttendee($_records->attendee, false, $_records); $organizers = Addressbook_Controller_Contact::getInstance()->getMultiple(array_unique($_records->organizer), TRUE); foreach ($_records as $record) { $attendee = $record->attendee->getName(); $record->attendee = implode('& ', $attendee); $organizer = $organizers->getById($record->organizer); if ($organizer) { $record->organizer = $organizer->n_fileas; } } }
/** * testNotificationToResponsible */ public function testNotificationOnDelete() { $lead = $this->_getLead(); // give sclever access to lead container $this->_setPersonaGrantsForTestContainer($lead['container_id'], 'sclever'); $lead->relations = array(new Tinebase_Model_Relation(array('type' => 'RESPONSIBLE', 'related_record' => Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId()), 'own_model' => 'Crm_Model_Lead', 'own_backend' => 'Sql', 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_model' => 'Addressbook_Model_Contact', 'related_backend' => Tasks_Backend_Factory::SQL), TRUE)); $savedLead = $this->_leadController->create($lead); self::flushMailer(); $this->_leadController->delete($savedLead->getId()); $messages = self::getMessages(); $this->assertEquals(1, count($messages)); $bodyText = $messages[0]->getBodyText()->getContent(); $this->assertContains('**PHPUnit **', $bodyText); }
/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ protected function tearDown() { // delete the db entries try { Crm_Controller_Lead::getInstance()->delete($this->objects['leadWithLink']); } catch (Exception $e) { // access denied ? } try { Addressbook_Controller_Contact::getInstance()->delete($this->objects['linkedContact']); } catch (Exception $e) { // access denied ? } }