Logo

WebApi Client Examples

<?php use Visionline\Crm\WebApi; // Instantiate cache and clear it to see the impact of caching below $cache = new WebApi\FileCache('cache'); $cache->clear(); // Re-initialize WebApi to enable caching $webapi = new WebApi\WebApi($endpoint, $connection, array( 'cache' => $cache )); // Retrieve fieldset1 $fieldset1 = array(); foreach ($webapi->enumFields(WebApi\EntityType::Objekt, 'Allgemeine Daten') as $field) { array_push($fieldset1, $field->field); } // Retrieve fieldset2 $fieldset2 = array(); foreach ($webapi->enumFields(WebApi\EntityType::Objekt, 'Detailfelder') as $field) { array_push($fieldset2, $field->field); } // Query some properties $objekte = $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isFalse('GeloeschtObjekt')) ->order(WebApi\Order::desc('ObjektNrObjekt')) ->max(10) ->result(); // Retrieve values of fieldset1 and output elapsed time $start = microtime(true); $webapi->get(WebApi\EntityType::Objekt, $objekte, $fieldset1); echo('<p>get fieldset 1 took ' . round(microtime(true) - $start, 3) . 's</p>'); // Retrieve values of fieldset 1 from cache and output elapsed time $start = microtime(true); $webapi->get(WebApi\EntityType::Objekt, $objekte, $fieldset1); echo('<p>get fieldset 1 from cache took ' . round(microtime(true) - $start, 3) . 's</p>'); // Retrieve values of fieldset 2 and output elapsed time $start = microtime(true); $webapi->get(WebApi\EntityType::Objekt, $objekte, $fieldset2); echo('<p>get fieldset 2 took ' . round(microtime(true) - $start, 3) . 's</p>'); // Retrieve values of fieldset 1 and 2 from cache and output elapsed time $start = microtime(true); $webapi->get(WebApi\EntityType::Objekt, $objekte, array_merge($fieldset1, $fieldset2)); echo('<p>get fieldset 1 and 2 from cache took ' . round(microtime(true) - $start, 3) . 's</p>'); <?php use Visionline\Crm\WebApi; // Get a contact who has an open interest $contact = $webapi->createQuery(WebApi\EntityType::Kontakt) ->add(WebApi\Filter::eq('GesamtstatusInteresse', 'offen')) ->max(1) ->uniqueResult(); if ($contact !== null) { // Get open interests and print results $interests = $webapi->getInterests($contact, array('offen')); foreach ($interests as $interest) { echo('Kontakt ' . $contact->id . ' has open interest since ' . $interest->datumAnlage . '<br/>'); } } // Get some contacts $contactsFields = $webapi->createQuery(WebApi\EntityType::Kontakt) ->max(10) ->fields(array('SpeichernunterKontakt')); // Get interests of all contacts and print results $interests = $webapi->getInterests(array_keys($contactsFields)); foreach ($interests as $interest) { echo('Kontakt ' . $contactsFields[$interest->kontaktId]['SpeichernunterKontakt'] . ' has interest since ' . $interest->datumAnlage . ' with status ' . $interest->status . '<br/>'); } ?> <?php use Visionline\Crm\WebApi; // Query some contacts with relations to projects $kontakte = $webapi->createQuery(WebApi\EntityType::Kontakt) ->add(WebApi\Filter::isFalse('GeloeschtKontakt')) ->add(WebApi\Filter::isNotEmpty('ProjekteVonKontakt')) ->max(10) ->result(); // Retrieve data of contacts $kontakteDaten = $webapi->get(WebApi\EntityType::Kontakt, $kontakte, array('SpeichernunterKontakt')); // Query projects of contacts $projekte = $webapi->queryProjekte(WebApi\EntityType::Kontakt, $kontakte); // Retrieve data of projects $projekteDaten = $webapi->get(WebApi\EntityType::Projekt, $projekte, array('ProjektNrProjekt')); // Display gathered information echo '<ul>'; foreach ($projekte as $projekt) { echo '<li>'; echo $kontakteDaten[$projekt->relatedTo]['SpeichernunterKontakt'] . ' is ' . $projekt->role . ' of project ' . $projekteDaten[$projekt->id]['ProjektNrProjekt'] . '.'; echo '</li>'; } echo '</ul>';<?php use Visionline\Crm\WebApi; // Query some contacts with relations to real estates $kontakte = $webapi->createQuery(WebApi\EntityType::Kontakt) ->add(WebApi\Filter::isFalse('GeloeschtKontakt')) ->add(WebApi\Filter::isNotEmpty('ObjekteVonKontakt')) ->max(10) ->result(); // Retrieve data of contacts $kontakteDaten = $webapi->get(WebApi\EntityType::Kontakt, $kontakte, array('SpeichernunterKontakt')); // Query real estates of contacts $objekte = $webapi->queryObjekte(WebApi\EntityType::Kontakt, $kontakte); // Retrieve data of real estates $objekteDaten = $webapi->get(WebApi\EntityType::Objekt, $objekte, array('ObjektNrObjekt')); // Display gathered information echo '<ul>'; foreach ($objekte as $objekt) { echo '<li>'; echo $kontakteDaten[$objekt->relatedTo]['SpeichernunterKontakt'] . ' is ' . $objekt->role . ' of real estate ' . $objekteDaten[$objekt->id]['ObjektNrObjekt'] . '.'; echo '</li>'; } echo '</ul>';<?php use Visionline\Crm\WebApi; // Get contact with photo $contacts = $webapi->createQuery(WebApi\EntityType::Kontakt) ->add(WebApi\Filter::isNotNull('BildKontakt')) ->max(1) ->fields(array('PostanschriftAdresskopfKontakt')); if (count($contacts) > 0) { foreach ($contacts as $contactId => $contactFields) { // Query photo of contact $contactImageDocument = $webapi->createQuery(WebApi\EntityType::Dokument) ->add(WebApi\Filter::oneOf('BildVonKontaktenDokument', $contactId)) ->max(1) ->uniqueResult(); // Get image file $contactImage = $webapi->getFile($contactImageDocument, 200, NULL, WebApi\ResizeMode::Scale); // Output results $contactImageBase64 = base64_encode($contactImage); echo('<img src="data:image/jpeg;base64,' . $contactImageBase64 . '" width="200" alt="Photo" />'); echo('<pre><address>' . $contactFields['PostanschriftAdresskopfKontakt'] . '</address></pre>'); } } else { echo("<p>No contact with photo found.</p>"); } ?> <?php use Visionline\Crm\WebApi; use Visionline\Crm\WebApi\EntityType; use Visionline\Crm\WebApi\Expression; use Visionline\Crm\WebApi\Order; // Query a random real estate $objektResult = $webapi->createQuery(EntityType::Objekt) ->add(Expression::isFalse('GeloeschtObjekt')) ->addOrder(Order::random()) ->max(1) ->result(); // Query a random contact $kontaktResult = $webapi->createQuery(EntityType::Kontakt) ->add(Expression::isFalse('GeloeschtKontakt')) ->addOrder(Order::random()) ->max(1) ->result(); // Create the activity $id = $webapi->create(EntityType::Aktivität, array( 'Beginn' => date('c'), 'AktivitaetsartAktivitaet' => 'Allgemeine Aktivität', 'AktivitaetsTypAktivitaet' => 'Aktivität', 'BetreffAktivitaet' => 'My Test Activity', 'KontakteVonAktivitaet' => $kontaktResult[0]->id, 'ObjekteVonAktivitaet' => $objektResult[0]->id, 'StatusAktivitaet' => 'stattgefunden' ) ); <?php use Visionline\Crm\WebApi; // Define enquiry data $enquiry = new WebApi\Enquiry(); $enquiry->nachname = 'Doe'; $enquiry->vorname = 'John'; $enquiry->notiz = 'This is an example'; $enquiry->anfragequelle = 'Homepage'; $enquiry->projektNr = '123/456'; $enquiry->vermarktungsarten = array('Kauf'); $enquiry->kaufpreisVon = 100000; $enquiry->kaufpreisBis = 200000; $enquiry->objekttypen = array('Wohnung'); $enquiry->erwerbsarten = array('Eigennutzer'); $enquiry->objektarten = array('Etage', 'Maisonette', 'Erdgeschoss'); $enquiry->datum = time(); // Create the enquiry $result = $webapi->createEnquiry($enquiry); // Output warnings that occured foreach ($result->warnings as $warning) { echo("<p>Warning: " . $warning . "</p>"); } // Output the resulting enquiry echo '<pre>'; var_dump($result->enquiry); echo '</pre>';<?php use Visionline\Crm\WebApi; use Visionline\Crm\WebApi\EntityType; use Visionline\Crm\WebApi\Expression; // Create a real estate $id = $webapi->create(EntityType::Objekt, array('ObjektKontrakt' => 'Kauf', 'ObjekttitelObjekt' => 'Created via WebApi')); // Update the created real estate $webapi->update(EntityType::Objekt, $id, array('ObjekttitelObjekt' => 'Updated via WebApi')); // Query the real estate $queryResult = $webapi->createQuery(EntityType::Objekt) ->add(Expression::eq('ObjekttitelObjekt', 'Updated via WebApi')) ->fields(array('ObjekttitelObjekt', 'ObjektKontrakt')); foreach ($queryResult as $id => $fieldValues) { echo '<p>Vermarktungsart: ' . $fieldValues['ObjektKontrakt'] . '</p>'; echo '<p>Objekttitel: ' . $fieldValues['ObjekttitelObjekt'] . '</p>'; } <?php use Visionline\Crm\WebApi; // Re-initialize WebApi to enable debugging $webapi = new WebApi\WebApi($endpoint, $connection, array( 'debug' => true )); try { // Query some properties $objekte = $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isFalse('GeloeschtObjekt')) ->order(WebApi\Order::desc('ObjektNObjekt')) ->max(10) ->result(); } catch (Exception $ex) { // Output debug messages echo '<pre>'; foreach ($webapi->getDebugMessages() as $message) { echo htmlentities($message) . PHP_EOL; } echo '</pre>'; } <?php use Visionline\Crm\WebApi; // Run query $queryResult = $webapi->createQuery(WebApi\EntityType::Anfrage) ->add(WebApi\Filter::isFalse('GeloeschtAnfrage')) ->add(WebApi\Filter::oneOf('AnfrageStatus', 'offen')) ->order(WebApi\Order::asc('DatumAngelegtAnfrage')) ->max(10) ->result(); // Retrieve enquiry data $enqueries = $webapi->getEnquiries($queryResult); echo '<code class="prettyprint lang-json">'; echo json_encode($enqueries, JSON_PRETTY_PRINT); echo '</code>'; <?php use Visionline\Crm\WebApi; echo('<pre>'); // Enumerate all fields $webapi->enumFields(WebApi\EntityType::Dokument); $webapi->enumFields(WebApi\EntityType::Kontakt); $webapi->enumFields(WebApi\EntityType::Objekt); $webapi->enumFields(WebApi\EntityType::Projekt); // Enumerate fields of each available category $webapi->enumFields(WebApi\EntityType::Dokument, 'Allgemeine Daten'); $webapi->enumFields(WebApi\EntityType::Dokument, 'Eigene Felder'); $webapi->enumFields(WebApi\EntityType::Dokument, 'Weitere Felder'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Eigene Felder'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Interesse'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Spezialfelder'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Adressfelder'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Namensfelder'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Kontaktdaten'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Vertriebsfelder'); $webapi->enumFields(WebApi\EntityType::Kontakt, 'Weitere Felder'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Allgemeine Daten'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Flächen'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Vermittlung'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Preise/Kosten'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Veröffentlichung'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Versteigerung'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Detailfelder'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Weitere Felder'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Spezialfelder'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Schätzung'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Grundbuch und Energieausweis'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Eigene Felder'); $webapi->enumFields(WebApi\EntityType::Objekt, 'Website'); $webapi->enumFields(WebApi\EntityType::Projekt, 'Website'); $webapi->enumFields(WebApi\EntityType::Projekt, 'Veröffentlichung'); $webapi->enumFields(WebApi\EntityType::Projekt, 'Eigene Felder'); $webapi->enumFields(WebApi\EntityType::Projekt, 'Allgemeine Daten'); $webapi->enumFields(WebApi\EntityType::Projekt, 'Spezialfelder'); $webapi->enumFields(WebApi\EntityType::Projekt, 'Weitere Felder'); echo('</pre>'); <?php use Visionline\Crm\WebApi; if (isset($_REQUEST['id'])) { $webapi->passthruFile(intval($_REQUEST['id']), true, 300, 300, WebApi\ResizeMode::Crop); } else { // Find an image $dokument = $webapi->createQuery(WebApi\EntityType::Dokument) ->add(WebApi\Filter::eq('DateierweiterungDokument', '.jpg')) ->order(WebApi\Order::desc('DatumGeaendertDokument')) ->max(1) ->uniqueResult(); // If we haven't got a result if ($dokument == null) { echo('No image found.'); } else { // Output an img that is retrieved from this example with the id of the image $url = $_SERVER['PHP_SELF'] . '?'; foreach ($_REQUEST as $key => $value) { $url .= urlencode($key) . '=' . urlencode($value) . '&'; } $url .= "id=" . $dokument->id; echo('<img src="' . $url . '" width="300" height="300" alt="Sample image" />'); } }<?php use Visionline\Crm\WebApi; // Enumerate all fields of EntityType::Projekt $fields = array(); foreach ($webapi->enumFields(WebApi\EntityType::Projekt) as $result) { array_push($fields, $result->field); } // Run query and get field values $projects = $webapi->createQuery(WebApi\EntityType::Projekt) ->add(WebApi\Filter::isFalse('GeloeschtProjekt')) ->order(WebApi\Order::desc('DatumGeaendertProjekt')) ->max(1) ->fields($fields); if (count($projects) > 0) { $project = array_pop($projects); echo('<table>'); foreach ($project as $key => $value) { echo('<tr><td>' . $key . '</td><td>' . $value . '</td></tr>'); } echo('</table>'); }<?php use Visionline\Crm\WebApi; // Query some projects with contacts $projekte = $webapi->createQuery(WebApi\EntityType::Projekt) ->add(WebApi\Filter::isFalse('GeloeschtProjekt')) ->add(WebApi\Filter::isNotEmpty('KontakteVonProjekt')) ->max(3) ->result(); // Query contacts of projects $kontakte = $webapi->queryKontakte(WebApi\EntityType::Projekt, $projekte); // Retrieve data of contacts $kontakteDaten = $webapi->get(WebApi\EntityType::Kontakt, $kontakte, array('SpeichernunterKontakt')); // Display gathered information echo '<ul>'; foreach ($kontakte as $kontakt) { echo '<li>'; echo $kontakteDaten[$kontakt->id]['SpeichernunterKontakt'] . ' is ' . $kontakt->role . ' of project with id ' . $kontakt->relatedTo . '.'; echo '</li>'; } echo '</ul>';<?php use Visionline\Crm\WebApi; $fields = array( 'ProjektNrProjekt', 'WebsiteTitelProjekt', 'WebsiteKurzbeschreibungProjekt' ); // Run query $objekte = $webapi->createQuery(WebApi\EntityType::Projekt) ->add(WebApi\Filter::isFalse('GeloeschtProjekt')) ->add(WebApi\Filter::isEmpty('ProjekteUntergeordnetVonProjekt')) ->order(WebApi\Order::asc('ProjektNrProjekt')) ->max(10) ->fields($fields); // Output values in a table echo("<table>"); // Output headers for Id and each field echo("<tr>"); echo("<th>Id</th>"); foreach ($fields as $field) { echo("<th>$field</th>"); } echo("</tr>"); // Output value of Id and each field foreach ($objekte as $id => $objekt) { echo("<tr>"); echo("<td>$id</td>"); foreach ($objekt as $value) { echo("<td>$value</td>"); } echo("</tr>"); } echo("</table>"); <?php use Visionline\Crm\WebApi; function printEvents($events) { echo '<ul>'; foreach ($events as $event) { printf('<li>%d: %s with id %d was %s by %s (Betreuer %s, Kontakt %s), state: %s</li>', $event->id, $event->entityType, $event->entityId, strtolower($event->changeType) . 'd', $event->username, $event->betreuerId, $event->betreuerContactId, $event->state); } echo '</ul>'; } echo '<p>First 10 events in the system:</p>'; printEvents($webapi->queryEvents(null, null, 10)); echo '<p>First 5 events of today:</p>'; printEvents($webapi->queryEvents(strtotime('today midnight'), null, 5)); echo '<p>First 3 events after event with id 2:</p>'; printEvents($webapi->queryEvents(null, 2, 3)); <?php use Visionline\Crm\WebApi; // fields for which to query name values $fields = array( 'ObjektNrObjekt', 'ObjekttitelObjekt', 'WebsiteTitelObjekt', 'WebsiteKurzbeschreibungObjekt' ); // fields for which to query id values $idFields = array( 'StatusObjekt', 'ObjektartenObjekt' ); // Run query $objekte = $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isFalse('GeloeschtObjekt')) ->add(WebApi\Filter::isTrue('WebsiteVeroeffentlichenObjekt')) ->add(WebApi\Filter::oneOf('StatusObjekt', 'aktuell,reserviert')) ->add(WebApi\Filter::oneOf('ObjektartTypen', 'Wohnung')) ->order(WebApi\Order::asc('ObjektNrObjekt')) ->max(10) ->fields($fields, $idFields); // Output values in a table echo("<table>"); // Output headers for Id and each field echo("<tr>"); echo("<th>Id</th>"); foreach ($fields as $field) { echo("<th>$field</th>"); } echo("</tr>"); // Output value of Id and each field foreach ($objekte as $id => $objekt) { echo("<tr>"); echo("<td>$id</td>"); foreach ($objekt as $value) { echo("<td>$value</td>"); } echo("</tr>"); } echo("</table>");<?php use Visionline\Crm\WebApi; // The fieldset we will retrieve for each property $fields = array( 'ObjektNrObjekt', 'StatusObjekt', 'AnzahlZimmerObjekt', 'KaufpreisBruttoObjekt' ); // Query some top-level projects $projects = $webapi->createQuery(WebApi\EntityType::Projekt) ->add(WebApi\Filter::isFalse('GeloeschtProjekt')) ->add(WebApi\Filter::isEmpty('ProjekteUntergeordnetVonProjekt')) ->order(WebApi\Order::desc('DatumGeaendertProjekt')) ->max(5) ->result(); // Output values in a table echo("<table>"); foreach ($projects as $project) { // Output header for each project echo('<tr><th colspan="' . strval(count($fields)+1) . '">Projekt #' . $project->id . '</th></tr>'); // Run query to retrieve properties of projects // with advanced ordering $objekte = $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isFalse('GeloeschtObjekt')) ->add(WebApi\Filter::inHierarchy('ProjekteVonObjekt', $project->id)) ->add(WebApi\Filter::oneOf('StatusObjekt', 'aktuell,reserviert')) ->addOrder(WebApi\Order::asc('StatusObjekt')) ->addOrder(WebApi\Order::desc('AnzahlZimmerObjekt')) ->addOrder(WebApi\Order::desc('KaufpreisBruttoObjekt')) ->max(30) ->fields($fields); // Output headers for Id and each field echo("<tr>"); echo("<th>Id</th>"); foreach ($fields as $field) { echo("<th>$field</th>"); } echo("</tr>"); // Output value of Id and each field foreach ($objekte as $id => $objekt) { echo("<tr>"); echo("<td>$id</td>"); foreach ($objekt as $value) { echo("<td>$value</td>"); } echo("</tr>"); } } echo("</table>");<?php use Visionline\Crm\WebApi; // Define function that returns the child projects of a project function queryChildProjects($webapi, $parent) { return $webapi->createQuery(WebApi\EntityType::Projekt) ->add(WebApi\Filter::isFalse('GeloeschtProjekt')) ->add(WebApi\Filter::oneOf('ProjekteUntergeordnetVonProjekt', $parent->id)) ->order(WebApi\Order::asc('ProjektNrProjekt')) ->result(); } // Define function that returns the real estates of a project function queryRealEstates($webapi, $parent) { return $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isFalse('GeloeschtObjekt')) ->add(WebApi\Filter::oneOf('ProjekteVonObjekt', $parent->id)) ->order(WebApi\Order::asc('ObjektNrObjekt')) ->result(); } // Define function that recursively prints a project and its childs function printProjectRecursive($webapi, $project) { echo('<li>'); echo('<strong>Project #' . $project->id . '</strong>'); $children = queryChildProjects($webapi, $project); if (count($children) > 0) { echo('<p>Child projects:<ul>'); foreach ($children as $child) { printProjectRecursive($webapi, $child); } echo('</ul></p>'); } $realestates = queryRealEstates($webapi, $project); if (count($realestates) > 0) { echo('<p>Real estates:<ul>'); foreach ($realestates as $realestate) { echo('<li>Real estate #' . $realestate->id . '</li>'); } echo('</ul></p>'); } } // Query a top-level project $project = $webapi->createQuery(WebApi\EntityType::Projekt) ->add(WebApi\Filter::isFalse('GeloeschtProjekt')) ->add(WebApi\Filter::isEmpty('ProjekteUntergeordnetVonProjekt')) ->order(WebApi\Order::asc('ProjektNrProjekt')) ->max(1) ->uniqueResult(); if ($project != null) { // Print the project recursively printProjectRecursive($webapi, $project); }<?php use Visionline\Crm\WebApi; // Query some real estates with contacts of role 'Käufer' $objekte = $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isFalse('GeloeschtObjekt')) ->add(WebApi\Filter::oneOf('RolleKontaktVonObjekt', 'Käufer')) ->max(10) ->result(); // Query contacts of projects with role 'Käufer' $kontakte = $webapi->queryKontakte(WebApi\EntityType::Objekt, $objekte, null, array('Käufer')); // Retrieve data of contacts $kontakteDaten = $webapi->get(WebApi\EntityType::Kontakt, $kontakte, array('SpeichernunterKontakt')); // Display gathered information echo '<ul>'; foreach ($kontakte as $kontakt) { echo '<li>'; echo $kontakteDaten[$kontakt->id]['SpeichernunterKontakt'] . ' bought real estate with id ' . $kontakt->relatedTo . '.'; echo '</li>'; } echo '</ul>';<?php use Visionline\Crm\WebApi; // Query some real estates $realestates = $webapi->createQuery(WebApi\EntityType::Objekt) ->order(Webapi\Order::desc('DatumGeaendertObjekt')) ->max(10) ->result(); // Query the first image of each real estate $documents = $webapi->queryWebsiteDocuments(WebApi\EntityType::Objekt, $realestates, 1, null, array('Bild')); if (count($documents) > 0) { // Output each image foreach ($documents as $document) { echo('<p>First image of real estate with id ' . $document->relatedTo . ':'); $filename = $webapi->saveFile($document, 'documents', false, 200, 200, WebApi\ResizeMode::Crop); echo('<img src="' . $filename . '" width="200" height="200" alt="Photo" />'); echo('</p>'); } } else { echo('<p>No images found.</p>'); } <?php use Visionline\Crm\WebApi; $fields = array( 'ObjektNrObjekt', 'ObjekttitelObjekt', 'StatusObjekt', 'ObjektartenObjekt', 'WebsiteTitelObjekt', 'WebsiteKurzbeschreibungObjekt' ); // Run query $objekte = $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isFalse('GeloeschtObjekt')) ->add(WebApi\Filter::isTrue('WebsiteVeroeffentlichenObjekt')) ->add(WebApi\Filter::oneOf('StatusObjekt', 'aktuell,reserviert')) ->add(WebApi\Filter::oneOf('ObjektartTypen', 'Wohnung')) ->order(WebApi\Order::asc('ObjektNrObjekt')) ->max(10) ->fields($fields); // Output values in a table echo("<table>"); // Output headers for Id and each field echo("<tr>"); echo("<th>Id</th>"); foreach ($fields as $field) { echo("<th>$field</th>"); } echo("</tr>"); // Output value of Id and each field foreach ($objekte as $id => $objekt) { echo("<tr>"); echo("<td>$id</td>"); foreach ($objekt as $value) { echo("<td>$value</td>"); } echo("</tr>"); } echo("</table>");<?php use Visionline\Crm\WebApi; $objekt = $webapi->createQuery(WebApi\EntityType::Objekt) ->add(WebApi\Filter::isNotEmpty('ZustaendigeBetreuerObjekt')) ->order(WebApi\Order::desc('DatumGeaendertObjekt')) ->max(10) ->uniqueResult(); $getfields = array('PostanschriftAdresskopfKontakt', 'TelefongeschaeftlichKontakt'); $contactsQueryResult = $webapi->queryResponsibleContacts(WebApi\EntityType::Objekt, $objekt); $contacts = $webapi->get(WebApi\EntityType::Kontakt, $contactsQueryResult, $getfields); foreach ($contacts as $id => $fields) { echo('<pre><address>' . $fields['PostanschriftAdresskopfKontakt'] . '</address></pre>'); echo('<p>Tel: ' . $fields['TelefongeschaeftlichKontakt'] . '</p>'); } ?> <?php use Visionline\Crm\WebApi; // Get a real estate $objekt = $webapi->createQuery(WebApi\EntityType::Objekt) ->order(Webapi\Order::desc('DatumGeaendertObjekt')) ->max(1) ->uniqueResult(); // Query the website documents of the real estate $documents = $webapi->queryWebsiteDocuments(WebApi\EntityType::Objekt, $objekt); if (count($documents) > 0) { // Get website documents of property $documentFields = $webapi->get(WebApi\EntityType::Dokument, $documents, array('BezeichnungDokument', 'DateierweiterungDokument', 'DokumentartDokument')); // Output website documents foreach ($documents as $document) { $fields = $documentFields[$document->id]; echo('<p>' . $fields['BezeichnungDokument'] . ' - ' . $fields['DokumentartDokument'] . ':</p>'); if ($fields['DateierweiterungDokument'] == '.jpg' || $fields['DateierweiterungDokument'] == '.png') { $filename = $webapi->saveFile($document, 'documents', false, 200, 200, WebApi\ResizeMode::Crop); echo('<img src="' . $filename . '" width="200" alt="Photo" />'); } else if ($documentFields['DateierweiterungDokument'] == '.html') { echo($webapi->getFile($document)); } else { echo('Got document type that is beyond the scope of this example.'); } } } else { echo('No website documents found for real estate #' . $objekt->id); }<?php use Visionline\Crm\WebApi; // Find an image $dokument = $webapi->createQuery(WebApi\EntityType::Dokument) ->add(WebApi\Filter::eq('DateierweiterungDokument', '.jpg')) ->order(WebApi\Order::desc('DatumGeaendertDokument')) ->max(1) ->uniqueResult(); // If we haven't got a result if ($dokument == null) { echo('No image found.'); } else { // save the image file $filename = $webapi->saveFile($dokument, 'documents', false, 300, null, WebApi\ResizeMode::Scale); echo('<img src="' . $filename . '" width="300" alt="Sample image" />'); }<?php use Visionline\Crm\WebApi; // Find an image $dokument = $webapi->createQuery(WebApi\EntityType::Dokument) ->add(WebApi\Filter::eq('DateierweiterungDokument', '.jpg')) ->order(WebApi\Order::desc('DatumGeaendertDokument')) ->max(1) ->uniqueResult(); // If we haven't got a result if ($dokument == null) { echo('No image found.'); } else { // Get the images $imageCropped = $webapi->getFile($dokument, 300, 300, WebApi\ResizeMode::Crop); $imageScaledToWidth = $webapi->getFile($dokument, 300, NULL, WebApi\ResizeMode::Scale); $imageScaledToHeight = $webapi->getFile($dokument, NULL, 300, WebApi\ResizeMode::Scale); $imageCropped = base64_encode($imageCropped); $imageScaledToWidth = base64_encode($imageScaledToWidth); $imageScaledToHeight = base64_encode($imageScaledToHeight); ?> <img src="data:image/jpeg;base64,<?php echo($imageCropped); ?>" width="300" height="300" alt="An image received from CRM-VISIONLINE" /> <img src="data:image/jpeg;base64,<?php echo($imageScaledToWidth); ?>" width="300" alt="An image received from CRM-VISIONLINE" /> <img src="data:image/jpeg;base64,<?php echo($imageScaledToHeight); ?>" height="300" alt="An image received from CRM-VISIONLINE" /> <?php }<?php use Visionline\Crm\WebApi; // Get a contact who has an open interest $contact = $webapi->createQuery(WebApi\EntityType::Kontakt) ->add(WebApi\Filter::eq('GesamtstatusInteresse', 'offen')) ->max(1) ->uniqueResult(); if ($contact !== null) { // Get open interests and close them $interests = $webapi->getInterests($contact, array('offen')); foreach ($interests as $interest) { echo('Closing interest of contact ' . $contact->id . ' from ' . $interest->datumAnlage . '<br/>'); $interest->status = 'negativ erledigt'; $webapi->updateInterest($interest); } } ?><?php use Visionline\Crm\WebApi; // Enumerate available user defined fields $userDefinedFields = $webapi->enumFields(WebApi\EntityType::Projekt, 'Eigene Felder'); // Build array of field identifiers $fields = array(); foreach ($userDefinedFields as $userDefinedField) { array_push($fields, $userDefinedField->field); } // Run query $projekte = $webapi->createQuery(WebApi\EntityType::Projekt) ->order(WebApi\Order::desc('ProjektNrProjekt')) ->max(10) ->fields($fields); // Output values in a table echo("<table>"); // Output headers for Id and each user defined field echo("<tr>"); echo("<th>Id</th>"); foreach ($userDefinedFields as $userDefinedField) { echo("<th>" . $userDefinedField->name . "</th>"); } echo("</tr>"); // Output value of Id and each user defined field foreach ($projekte as $id => $projekt) { echo("<tr>"); echo("<td>$id</td>"); foreach ($projekt as $value) { echo("<td>$value</td>"); } echo("</tr>"); } echo("</table>");<?php use Visionline\Crm\WebApi; // Find some website contents $websiteContents = $webapi->createQuery(WebApi\EntityType::Dokument) ->add(WebApi\Filter::oneOf('DokumentartDokument', 'Inhalt für Website')) ->order(WebApi\Order::desc('DatumGeaendertDokument')) ->max(3) ->result(); if (count($websiteContents) == 0) { echo('No website contents found.'); } // Get the files foreach ($websiteContents as $index => $content) { echo('<h2>Website Content #' . ($index+1) . '</h2>'); $webapi->passthruFile($content); }