fhiiqm/test/vertrag_list_autocomplete1.php
author Bettina Schwarzer <schwarzer@fhi-berlin.mpg.de>
Fri, 02 Sep 2011 12:52:50 +0200
changeset 3 3c49783d0862
permissions -rw-r--r--
jquery ui autocomplete -Test

<?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
?>