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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user