Fix timestamps, delete requests, invoice dates and GR quantities
Apply the configured timezone to PHP and both DB connections, wrap unwrapped ajax payloads so delete buttons reach their engines, normalise and validate invoice due dates, reject stock quantities below the stored 4dp scale, and list stock movements across all warehouses.
This commit is contained in:
+18
-1
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
// Apply the configured application timezone before anything formats or stores a
|
||||
// date. config.php (loaded by the caller) supplies $time_zone.
|
||||
require_once __DIR__ . '/assets/utils/timezone.php';
|
||||
|
||||
// db connection
|
||||
/** overide native PDO function */
|
||||
class database extends PDO {
|
||||
@@ -97,4 +101,17 @@ $pdo1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
//..................... PDO2 .....................//
|
||||
$pdo2 = new database($db_type2.':host='.$db_server2.';dbname='.$db_database2.';charset=utf8', $db_user2, $db_pass2);
|
||||
$pdo2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$pdo2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// Pin both connections to the application timezone, so MySQL NOW() and PHP
|
||||
// date() agree no matter how the database server itself is configured. Queries
|
||||
// mix the two freely (rows written with NOW(), others with date()), and a
|
||||
// mismatch shows up as timestamps hours away from the real clock.
|
||||
foreach ([$pdo1, $pdo2] as $pdo_tz) {
|
||||
try {
|
||||
$pdo_tz->exec("SET time_zone = '" . APP_TIMEZONE_OFFSET . "'");
|
||||
} catch (PDOException $e) {
|
||||
// A server that refuses the offset keeps its own zone — no worse than
|
||||
// before this call existed, and not a reason to fail the request.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user