diff --git a/agent/invoice.php b/agent/invoice.php index d14a9897..3719004d 100644 --- a/agent/invoice.php +++ b/agent/invoice.php @@ -288,6 +288,9 @@ if (isset($_GET['invoice_id'])) { Download PDF + + Packing Slip + Send Email diff --git a/agent/post/invoice.php b/agent/post/invoice.php index 51ef704c..667e603f 100644 --- a/agent/post/invoice.php +++ b/agent/post/invoice.php @@ -944,6 +944,153 @@ if (isset($_GET['export_invoice_pdf'])) { } +if (isset($_GET['export_invoice_packing_slip'])) { + + $invoice_id = intval($_GET['export_invoice_packing_slip']); + + $sql = mysqli_query( + $mysqli, + "SELECT * FROM invoices + LEFT JOIN clients ON invoice_client_id = client_id + LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1 + LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1 + WHERE invoice_id = $invoice_id + $access_permission_query + LIMIT 1" + ); + + $row = mysqli_fetch_assoc($sql); + $invoice_id = intval($row['invoice_id']); + $invoice_prefix = nullable_htmlentities($row['invoice_prefix']); + $invoice_number = intval($row['invoice_number']); + $invoice_date = nullable_htmlentities($row['invoice_date']); + $client_id = intval($row['client_id']); + $client_name = nullable_htmlentities($row['client_name']); + $location_address = nullable_htmlentities($row['location_address']); + $location_city = nullable_htmlentities($row['location_city']); + $location_state = nullable_htmlentities($row['location_state']); + $location_zip = nullable_htmlentities($row['location_zip']); + $location_country = nullable_htmlentities($row['location_country']); + $contact_email = nullable_htmlentities($row['contact_email']); + $contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); + $contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code)); + $contact_extension = nullable_htmlentities($row['contact_extension']); + + $sql = mysqli_query($mysqli, "SELECT * FROM companies WHERE company_id = 1"); + $row = mysqli_fetch_assoc($sql); + $company_id = intval($row['company_id']); + $company_name = nullable_htmlentities($row['company_name']); + $company_country = nullable_htmlentities($row['company_country']); + $company_address = nullable_htmlentities($row['company_address']); + $company_city = nullable_htmlentities($row['company_city']); + $company_state = nullable_htmlentities($row['company_state']); + $company_zip = nullable_htmlentities($row['company_zip']); + $company_phone_country_code = nullable_htmlentities($row['company_phone_country_code']); + $company_phone = nullable_htmlentities(formatPhoneNumber($row['company_phone'], $company_phone_country_code)); + $company_email = nullable_htmlentities($row['company_email']); + $company_website = nullable_htmlentities($row['company_website']); + $company_tax_id = nullable_htmlentities($row['company_tax_id']); + if ($config_invoice_show_tax_id && !empty($company_tax_id)) { + $company_tax_id_display = "Tax ID: $company_tax_id"; + } else { + $company_tax_id_display = ""; + } + $company_logo = nullable_htmlentities($row['company_logo']); + + require_once("../plugins/TCPDF/tcpdf.php"); + + // Start TCPDF + $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); + $pdf->SetMargins(10, 10, 10); + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + $pdf->AddPage(); + $pdf->SetFont('helvetica', '', 10); + + // Logo + Right Columns + $html = '
| ';
+ if (!empty($company_logo) && file_exists("../uploads/settings/$company_logo")) {
+ $html .= ' |
+
+ Packing Slip + ' . $invoice_prefix . $invoice_number . ' '; + $html .= ' |
+
| ' . $company_name . ' | +' . $client_name . ' | +
| ' . nl2br("$company_address\n$company_city $company_state $company_zip\n$company_country\n$company_phone\n$company_website\n$company_tax_id_display") . ' | +' . nl2br("$location_address\n$location_city $location_state $location_zip\n$location_country\n$contact_email\n$contact_phone") . ' | +
| Item | +Qty | +Picked? | +|
|---|---|---|---|
| ' . $name . ' | +' . number_format($qty, 2) . ' | +
+
|
+
|
+ Picked By: + |
+
+ Checked By: + |
+