Add support for per-department custom daily targets

- Introduced `department_daily_targets` field in criteria, renderer, and API to define daily target overrides for departments.
- Enhanced daily target logic to honor per-department overrides while maintaining backward compatibility.
- Updated SMS, email, and Slack renderers for consistent enforcement of text length limits with fallback to non-mbstring functions.
- Refactored order item update logic to improve database interaction safety by using setters.
This commit is contained in:
Jeppe Bundgaard
2026-02-25 13:03:04 +01:00
parent 5cc311ae32
commit ffc5d6bc21
7 changed files with 167 additions and 16 deletions
+9 -3
View File
@@ -259,18 +259,24 @@ class order_items_o extends db
return $items;
}
/**
* @throws Exception
*/
public function updateOrderItem(int $id, int $price, string $notes, string $reference, int $quantity): void
{
global $db, $response;
$this->id = $id;
$this->select((int)$id);
$this->requireSelected();
try {
// Avoid SQL injection
$price = $db->escape_string($price);
$notes = $db->escape_string($notes);
$reference = $db->escape_string($reference);
// Update the record in the database
$sql = "UPDATE $this->table SET price = $price, notes = '$notes', reference = '$reference', quantity = $quantity WHERE id = $this->id";
$db->query($sql);
$this->price->set((int)$price);
$this->notes->set($notes);
$this->reference->set($reference);
$this->quantity->set($quantity);
// Set the values of the object properties
$this->getObjectProperties();
$this->objectChanged();