Bernd Wurst commited on 2018-01-24 11:16:35
Zeige 1 geänderte Dateien mit 46 Einfügungen und 0 Löschungen.
| ... | ... |
@@ -142,8 +142,52 @@ function set_kundenkontakt($typ, $id) {
|
| 142 | 142 |
system_failure("Falscher Typ!");
|
| 143 | 143 |
} |
| 144 | 144 |
db_query("UPDATE kundendaten.kunden SET ".$field."=:contact WHERE id=:kunde", $args);
|
| 145 |
+ sync_legacy_contactdata(); |
|
| 145 | 146 |
} |
| 146 | 147 |
|
| 148 |
+ |
|
| 149 |
+function sync_legacy_contactdata() |
|
| 150 |
+{
|
|
| 151 |
+ $cid = (int) $_SESSION['customerinfo']['customerno']; |
|
| 152 |
+ $kundenkontakte = get_kundenkontakte(); |
|
| 153 |
+ $kunde = get_contact($kundenkontakte['kunde']); |
|
| 154 |
+ $args = array("firma" => $kunde['company'],
|
|
| 155 |
+ "vorname" => explode(' ', $kunde['name'], 2)[0],
|
|
| 156 |
+ "nachname" => explode(' ', $kunde['name'], 2)[1],
|
|
| 157 |
+ "adresse" => $kunde['address'], |
|
| 158 |
+ "plz" => $kunde['zip'], |
|
| 159 |
+ "ort" => $kunde['city'], |
|
| 160 |
+ "land" => $kunde['country'], |
|
| 161 |
+ "telefon" => $kunde['phone'], |
|
| 162 |
+ "mobile" => $kunde['mobile'], |
|
| 163 |
+ "telefax" => $kunde['fax'], |
|
| 164 |
+ "email" => $kunde['email'], |
|
| 165 |
+ "cid" => $cid); |
|
| 166 |
+ db_query("UPDATE kundendaten.kunden SET firma=:firma, vorname=:vorname, nachname=:nachname, adresse=:adresse,
|
|
| 167 |
+ plz=:plz, ort=:ort, land=:land, telefon=:telefon, mobile=:mobile, telefax=:telefax, email=:email |
|
| 168 |
+ WHERE id=:cid", $args); |
|
| 169 |
+ if ($kundenkontakte['extern']) {
|
|
| 170 |
+ $extern = get_contact($kundenkontakte['extern'])['email']; |
|
| 171 |
+ if ($extern) {
|
|
| 172 |
+ db_query("UPDATE kundendaten.kunden SET email_extern=? WHERE id=?", array($extern, $cid));
|
|
| 173 |
+ } |
|
| 174 |
+ |
|
| 175 |
+ } |
|
| 176 |
+ if ($kundenkontakte['rechnung']) {
|
|
| 177 |
+ $kunde = get_contact($kundenkontakte['rechnung']); |
|
| 178 |
+ $args = array("firma" => $kunde['company'],
|
|
| 179 |
+ "name" => $kunde['name'], |
|
| 180 |
+ "adresse" => $kunde['address'], |
|
| 181 |
+ "plz" => $kunde['zip'], |
|
| 182 |
+ "ort" => $kunde['city'], |
|
| 183 |
+ "email" => $kunde['email'], |
|
| 184 |
+ "cid" => $cid); |
|
| 185 |
+ db_query("UPDATE kundendaten.kunden SET re_firma=:firma, re_name=:name, re_adresse=:adresse,
|
|
| 186 |
+ re_plz=:plz, re_ort=:ort, email_rechnung=:email WHERE id=:cid", $args); |
|
| 187 |
+ } |
|
| 188 |
+} |
|
| 189 |
+ |
|
| 190 |
+ |
|
| 147 | 191 |
function get_kundenkontakte() {
|
| 148 | 192 |
$cid = (int) $_SESSION['customerinfo']['customerno']; |
| 149 | 193 |
$result = db_query("SELECT contact_kunde, contact_extern, contact_rechnung FROM kundendaten.kunden WHERE id=?", array($cid));
|
| ... | ... |
@@ -186,6 +230,8 @@ function save_contact($c) |
| 186 | 230 |
db_query("INSERT INTO kundendaten.contacts (nic_id, nic_handle, customer, company, name, address, zip, city, country, phone, mobile, fax, pgp_id, pgp_key) VALUES (:nic_id, :nic_handle, :customer, :company, :name, :address, :zip, :city, :country, :phone, :mobile, :fax, :pgp_id, :pgp_key)", $c);
|
| 187 | 231 |
$c['id'] = db_insert_id(); |
| 188 | 232 |
} |
| 233 |
+ // FIXME: Das sollte eigentlich nicht bei jedem einzelnen Speicherovrgang passieren |
|
| 234 |
+ sync_legacy_contactdata(); |
|
| 189 | 235 |
return $c['id']; |
| 190 | 236 |
} |
| 191 | 237 |
|
| 192 | 238 |