fhiiqm/test/vertrag_list_autocomplete1.php
changeset 3 3c49783d0862
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/test/vertrag_list_autocomplete1.php	Fri Sep 02 12:52:50 2011 +0200
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 09/2011
+ *
+ * Autocomplete Vertragssuche
+ */
+
+    header('Content-type: text/html; charset="iso-8859-1',true); //wg. jquery ui autocomplete
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    $q = strtolower($_GET["term"]); // wird in jquery in 'term' uebergeben
+
+    $su = array("ä","ö","ü","ß","Ä","Ö","Ü");
+    $er = array("&auml;","&ouml;","&uuml;","&szlig;","&Auml;","&Ouml;","&Uuml;");
+//    $er = array("ae","oe","ue","ss","Ae;","Oe","Ue");
+    
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+	$dbc = new dbconnection();
+
+    $sql = "SELECT contract_ID,contract_name,t.vtyp_bezeichnung,contract_begin
+            FROM fhiiqm.Vertrag v LEFT OUTER JOIN fhiiqm.Vertrag_Typ t ON v.vtyp_ID=t.vtyp_ID 
+            WHERE contract_name LIKE '%".$q."%' COLLATE latin1_general_ci 
+            ORDER BY contract_name";
+    $result = $dbc ->queryObjectArray($sql);
+    if ($result)
+    {
+        foreach ($result as $row)
+        {
+            $cb = new DateTime($row->contract_begin);
+// 			$clist[] = "\"" . $row->contract_ID . " - " . str_replace($su,$er,$row->contract_name) . " | " . 
+//               str_replace($su,$er,$row->vtyp_bezeichnung) . " | VBeginn: " . $cb->format('d.m.Y') . "\"";
+ 			$clist[] = "\"" . $row->contract_ID . " - " . $row->contract_name . " | " . 
+             $row->vtyp_bezeichnung . " | VBeginn: " . $cb->format('d.m.Y') . "\"";
+		}
+    }
+    $dbc -> close();
+    echo "[" . implode(", ", $clist) . "]"; // Format, das jquery source erwartet
+?>
\ No newline at end of file