| ';
if (!empty($company_logo) && file_exists("../uploads/settings/$company_logo")) {
$html .= ' |
Account Statement As of ' . date("Y-m-d") . ' |
| ' . $company_name . ' | ' . $client_name . ' |
| ' . nl2br(formatAddress($company_address, $company_city, $company_state, $company_zip, $company_country) . "\n$company_phone\n$company_website") . ' |
| Invoice | Scope | Date | Due | Amount | Paid | Balance |
| ' . $invoice_prefix . $invoice_number . ' | ' . $invoice_scope . ' | ' . $invoice_date . ' | ' . $invoice_due . ' | ' . numfmt_format_currency($currency_format, $invoice_amount, $session_company_currency) . ' | ' . numfmt_format_currency($currency_format, $amount_paid, $session_company_currency) . ' | ' . numfmt_format_currency($currency_format, $invoice_balance, $session_company_currency) . ' |
| Total Balance Due | ' . numfmt_format_currency($currency_format, $statement_total, $session_company_currency) . ' | |||||
Uploaded file: $file_name
$document_description
"; $document_content_raw = "$document_name $file_name $document_description"; mysqli_query($mysqli, "INSERT INTO documents SET document_name = '$document_name', document_description = '$document_description', document_content = '$document_content', document_content_raw = '$document_content_raw', document_client_visible = 1, document_client_id = $session_client_id, document_created_by = $session_contact_id"); $document_id = mysqli_insert_id($mysqli); // Create file entry mysqli_query($mysqli, "INSERT INTO files SET file_reference_name = '$file_reference_name', file_name = '$file_name', file_description = 'Attached to document: $document_name', file_ext = '$file_extension', file_mime_type = '$file_mime_type', file_size = $file_size, file_created_by = $session_contact_id, file_client_id = $session_client_id"); $file_id = mysqli_insert_id($mysqli); // Link file to document mysqli_query($mysqli, "INSERT INTO document_files SET document_id = $document_id, file_id = $file_id"); logAudit("Document", "Upload", "Client contact $session_contact_name uploaded document $document_name with file $file_name", $session_client_id, $document_id); flashAlert("Document $document_name uploaded successfully"); } else { flashAlert('Error uploading file. Please try again.', 'error'); } } else { flashAlert('Invalid file type. Please upload PDF, Word documents, or text files only.', 'error'); } } else { flashAlert('Please select a file to upload.', 'error'); } redirect('documents.php'); }