Add Gutschrift functionality to ManualInvoice with modal and backend support

This commit is contained in:
2025-12-02 15:46:58 +01:00
parent e2dfa4a50c
commit 5feaadb171
8 changed files with 703 additions and 1253 deletions

View File

@@ -227,4 +227,36 @@ class TTCrudBaseModel {
return new static($result->fetch_assoc());
}
public function save() {
$data = [];
$reflection = new ReflectionClass(get_called_class());
foreach ($reflection->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
$field = $property->getName();
if (property_exists($this, $field)) {
$data[$field] = $this->$field;
}
}
// If we have an ID, update; otherwise, create
if (isset($this->id) && $this->id > 0) {
return self::update($data);
} else {
$newId = self::create($data);
$this->id = $newId;
return $newId;
}
}
public function deleteInstance() {
if (!isset($this->id)) {
throw new Exception("Cannot delete model without ID");
}
return self::delete($this->id);
}
public static function search($filter = [], $limit = null, $order = ["key" => null]): array {
return self::getAll($filter, $limit, 0, $order);
}
}