Quote generation and page counting working
This commit is contained in:
parent
3bfaa5b0fd
commit
846fd36c9f
|
|
@ -105,14 +105,37 @@ if (isset($result['filename'])) {
|
|||
$Document->saveField('pdf_filename', $result['filename']);
|
||||
$Document->saveField('pdf_created_at', date('Y-m-d H:i:s'));
|
||||
|
||||
// Get user ID safely (match invoice logic)
|
||||
// Get user ID safely (match invoice logic) with Basic Auth fallback
|
||||
$userId = null;
|
||||
$sessionUser = null;
|
||||
if (isset($this->Session)) {
|
||||
$userId = $this->Session->read('Auth.User.id');
|
||||
$sessionUser = $this->Session->read('Auth.User');
|
||||
$userId = isset($sessionUser['id']) ? $sessionUser['id'] : null;
|
||||
}
|
||||
if (!$userId && isset($_SESSION['Auth']['User']['id'])) {
|
||||
$userId = $_SESSION['Auth']['User']['id'];
|
||||
}
|
||||
// Fallback: try Basic Auth username/email -> User lookup
|
||||
if (!$userId && !empty($_SERVER['PHP_AUTH_USER'])) {
|
||||
$User = ClassRegistry::init('User');
|
||||
$foundUser = $User->find('first', array(
|
||||
'conditions' => array(
|
||||
'OR' => array(
|
||||
'User.email' => $_SERVER['PHP_AUTH_USER'],
|
||||
'User.username' => $_SERVER['PHP_AUTH_USER'],
|
||||
),
|
||||
),
|
||||
'fields' => array('User.id'),
|
||||
'recursive' => -1,
|
||||
'order' => 'User.id ASC'
|
||||
));
|
||||
if ($foundUser && isset($foundUser['User']['id'])) {
|
||||
$userId = $foundUser['User']['id'];
|
||||
}
|
||||
}
|
||||
// Logging to help identify which path is used (remove after confirmed)
|
||||
error_log('pdf_quote.ctp: user detection - sessionUser=' . json_encode($sessionUser) . ', PHP_AUTH_USER=' . (isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''));
|
||||
|
||||
if ($userId) {
|
||||
$Document->saveField('pdf_created_by_user_id', $userId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue