getOne($sqlStmt); endif; // Check ranges of hsno´s // ... To be done to be beautiful... !!! if ($f_srvp_id_inv != "" && $f_srvp_id != "" && $f_ad_street != "") : // Get ad_id of the new address // insertStmt("address", array("ad_street", $f_ad_street, "ad_zipcode", $f_ad_zipcode, "ad_city", $f_ad_city, "ad_country", $f_ad_country)); // $ad_id_new = getLastInsertID(); // Fill "f_ad_city" with signs because of function call "insertAddress" if ($f_ad_city == "") : $f_ad_city = "???"; endif; if ($f_ad_country == "") : $f_ad_country = "DE"; endif; $tmpArray = insertAddress($f_ad_street, $f_ad_zipcode, $f_ad_city, "", $f_ad_country); $ad_id_new = $tmpArray[0]; // Insert relation if ($ad_id_new != "" && $ad_id_new != "0") : insertStmt("serviceplzaddress", array("hq_id", $hq_id, "srvp_id", $f_srvp_id_inv, "ad_id", $ad_id_new, "srvpxa_hsno_from", $f_srvpxa_hsno_from, "srvpxa_hsno_to", $f_srvpxa_hsno_to, "srvpxa_mode", $f_srvpxa_mode)); else : $statusMessage = "Es wurde kein Eintrag angelegt!"; endif; $f_act = "search"; else : if ($f_srvp_id_inv == "") : $statusMessage = "Die angegebene Rechnungs-PLZ existiert nicht!"; elseif ($f_srvp_id == "") : $statusMessage = "Die angegebene PLZ ist nicht gültig!"; elseif ($f_ad_street == "") : $statusMessage = "Es ist keine Straße angegeben!"; else : $statusMessage = "Der Datensatz konnte nicht eingestellt werden! Bitte alle Felder vollständig ausfüllen!"; endif; endif; endif; // REMOVE association between zipcode and address if ($f_act == "removeZipcodeAddress") : TA("B"); // Entries to be deleted? $fieldsLength = count($f_del_assoc); if ($fieldsLength > 0 && $f_del_assoc[0] != "") : // Remove all associations according to the zipcode nested in array $f_del_zipcode_id for ($i = 0; $i < $fieldsLength; $i++) : deleteStmt("serviceplzaddress","srvpxa_id = '" . $f_del_assoc[$i] . "' AND hq_id = '" . $hq_id . "'"); endfor; $f_act = "search"; else : $statusMessage = "Bitte markieren Sie zu löschende Beziehungen durch anklicken der jeweiligen Checkbox hinter dem Eintrag!"; endif; TA("C"); TA("E"); endif; // Generate search-resultset // if ($f_act == "search" && $searchValues != "") : if ($f_act == "search") : if (strlen($f_srvp_plz) > 0 || strlen($f_ad_street) > 0 || strlen($f_ad_zipcode) > 0 || strlen($f_ad_city) > 0 || strlen($f_srvpxa_hsno_from) > 0 || strlen($f_srvpxa_hsno_to) > 0) : // Get the id of the area $f_srvp_id_inv = getFieldValueFromId("serviceplz","srvp_plz",$f_srvp_plz,"srvp_id"); // ************************************************* // * Selection of the mappings "address" => "area" * // ************************************************* $whereClause = ""; if ($f_ad_street != "") : $whereClause .= "ad.ad_street LIKE '" . $f_ad_street . "%'"; endif; if ($whereClause != "" && $f_ad_zipcode != "") : $whereClause .= " AND "; endif; if ($f_ad_zipcode != "") : $whereClause .= "ad.ad_zipcode LIKE '" . $f_ad_zipcode . "%'"; endif; if ($whereClause != "" && $f_ad_city != "") : $whereClause .= " AND "; endif; if ($f_ad_city != "") : $whereClause .= "ad.ad_city LIKE '" . $f_ad_city . "%'"; endif; if ($whereClause != "" && $f_ad_country != "") : $whereClause .= " AND "; endif; if ($f_ad_country != "") : $whereClause .= "ad.ad_country LIKE '" . $f_ad_country . "%'"; endif; // Only prefix ! if ($whereClause != "" && $f_srvp_id_inv != "") : $whereClause .= " AND "; endif; if ($f_srvp_id_inv != "") : $whereClause .= "srvp.srvp_id = '" . $f_srvp_id_inv . "'"; endif; if ($whereClause != "" && $f_srvpxa_hsno_from != "") : $whereClause .= " AND "; endif; if ($f_srvpxa_hsno_from != "") : $whereClause .= "srvpxa.srvpxa_hsno_from = '" . $f_srvpxa_hsno_from . "'"; endif; if ($whereClause != "" && $f_srvpxa_hsno_to != "") : $whereClause .= " AND "; endif; if ($f_srvpxa_hsno_to != "") : $whereClause .= "srvpxa.srvpxa_hsno_to = '" . $f_srvpxa_hsno_to . "'"; endif; if ($whereClause != "") : $whereClause .= " AND "; endif; if ($orderClause == "") : $orderClause = "ad.ad_street, srvpxa.srvpxa_hsno_to, ad.ad_zipcode"; endif; // ********************************************************************* // * Selection of the associations between invoice zipcode and address * // ********************************************************************* $sqlquery = "SELECT ad.ad_id, ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country," . " srvpxa.srvpxa_id, srvpxa.srvpxa_hsno_from, srvpxa.srvpxa_hsno_to, srvpxa.srvpxa_mode," . " srvp.srvp_id, srvp.srvp_plz" . " FROM address AS ad, serviceplz AS srvp, serviceplzaddress AS srvpxa" . " WHERE " . $whereClause . " srvpxa.hq_id = '" . $hq_id . "' AND" . " ad.ad_id = srvpxa.ad_id AND" . " srvp.srvp_id = srvpxa.srvp_id" . " ORDER BY " . $orderClause; // echo $sqlquery; $result = $db->dbQ($sqlquery); while ($row = $result->fetch_assoc()): $numOfRows++; $out .= "