Complete market overview card editing
This commit is contained in:
1 parent
94d336f090
commit
6a12a43114
4 files changed
+62
-4
No files matched your search
@@ -188,6 +188,38 @@ function get_contact_options(PDO $pdo): array
|
||||
);
|
||||
}
|
||||
|
||||
function update_contact_details(PDO $pdo, int $contactId, array $input): array
|
||||
{
|
||||
if ($contactId <= 0) {
|
||||
throw new InvalidArgumentException('contact_person_id muss positiv sein.');
|
||||
}
|
||||
|
||||
$sets = [];
|
||||
$params = [':id' => $contactId];
|
||||
foreach (['email', 'phone'] as $field) {
|
||||
if (array_key_exists($field, $input)) {
|
||||
$sets[] = $field . ' = :' . $field;
|
||||
$value = trim((string) ($input[$field] ?? ''));
|
||||
$params[':' . $field] = $value !== '' ? $value : null;
|
||||
}
|
||||
}
|
||||
if ($sets === []) {
|
||||
throw new InvalidArgumentException('Keine änderbaren Kontaktdaten übergeben.');
|
||||
}
|
||||
|
||||
$sets[] = 'updated_at = NOW()';
|
||||
$stmt = $pdo->prepare(
|
||||
'UPDATE contact SET ' . implode(', ', $sets) . ' WHERE id = :id
|
||||
RETURNING id, party_id, first_name, last_name, email, phone, position_title'
|
||||
);
|
||||
$stmt->execute($params);
|
||||
$contact = $stmt->fetch();
|
||||
if (!is_array($contact)) {
|
||||
throw new RuntimeException('Kontaktperson nicht gefunden.');
|
||||
}
|
||||
return $contact;
|
||||
}
|
||||
|
||||
function create_manufacturer(PDO $pdo, string $name, ?string $email = null, ?string $phone = null): array
|
||||
{
|
||||
$name = trim($name);
|
||||
|
||||
Reference in new issue
Block a user