'Invoice', 'quote' => 'Quote', 'recurring' => 'Recurring Invoice'][$paper_type]; $paper_footer = $paper_type === 'quote' ? ($GLOBALS['config_quote_footer'] ?? '') : ($GLOBALS['config_invoice_footer'] ?? ''); // A stamp across a document that is done with $paper_stamp = ''; if ($paper_type === 'invoice' && $paper_status === 'Paid') { $paper_stamp = ['Paid', 'success']; } elseif ($paper_type === 'invoice' && $paper_status === 'Cancelled') { $paper_stamp = ['Cancelled', 'danger']; } elseif ($paper_type === 'quote' && in_array($paper_status, ['Accepted', 'Invoiced'], true)) { $paper_stamp = ['Accepted', 'success']; } elseif ($paper_type === 'quote' && $paper_status === 'Declined') { $paper_stamp = ['Declined', 'danger']; } $paper_dates = []; if ($paper_type === 'invoice') { $paper_dates = ['Invoice date' => $paper_row['invoice_date'], 'Due' => $paper_row['invoice_due']]; } elseif ($paper_type === 'quote') { $paper_dates = ['Quote date' => $paper_row['quote_date'], 'Valid until' => $paper_row['quote_expire']]; } else { $paper_dates = ['Billed' => recurringInvoiceFrequencies()[$paper_row['recurring_invoice_frequency']] ?? ucfirst((string) $paper_row['recurring_invoice_frequency']), 'Next invoice' => $paper_row['recurring_invoice_next_date']]; } // A recurring invoice's seat lines - what each counts now, and whether the line is off $paper_seats = $paper_type === 'recurring' ? recurringSeatLines($paper_id, intval($paper_row['client_id'])) : []; $paper_seat_sources = recurringSeatSources(); // A quote with lines billed each month, quarter or year shows them apart from // what is billed once - the lines under a heading each, and a total each $paper_groups = $paper_type === 'quote' && !empty($paper_totals['recurring']) ? $paper_totals['groups'] : null; $paper_line_groups = $paper_groups ?: ['' => ['frequency' => '', 'label' => '', 'items' => $paper_items]]; // Where the lines can be changed, what can be changed where it sits is wrapped // as a field: which one, its value as it is typed, and what a click on it // does. And the parts of the paper that follow the lines are marked, to be // drawn again after a change. $paper_field = function ($field, $value, $what, $html, $class = '') use ($paper_edit) { return $paper_edit ? '' . $html . '' : $html; }; $paper_live = function ($part) use ($paper_edit) { return $paper_edit ? ' data-billing-live="' . $part . '"' : ''; }; $paper_post = function ($params) use ($paper_type, $paper_id, $paper) { return 'post.php?' . http_build_query(array_merge($params, ['type' => $paper_type, 'doc_id' => $paper_id, 'csrf_token' => $paper['csrf'] ?? ''])); }; $paper_company_lines = array_merge(array_filter([ formatAddress($paper_company['company_address'] ?? '', $paper_company['company_city'] ?? '', $paper_company['company_state'] ?? '', $paper_company['company_zip'] ?? '', $paper_company['company_country'] ?? '', "\n"), implode(' · ', array_filter([$paper_company['company_email'] ?? '', $paper_company['phone_display'] ?? ''])), $paper_company['company_website'] ?? '', !empty($GLOBALS['config_invoice_show_tax_id']) && !empty($paper_company['company_tax_id']) ? 'Tax ID: ' . $paper_company['company_tax_id'] : '', ]), billingTaxRegistrationLines($paper_totals)); $paper_bill_lines = array_filter([ formatAddress($paper_bill_to['location_address'] ?? '', $paper_bill_to['location_city'] ?? '', $paper_bill_to['location_state'] ?? '', $paper_bill_to['location_zip'] ?? '', $paper_bill_to['location_country'] ?? '', "\n"), $paper_bill_to['contact_name'] ?? '', implode(' · ', array_filter([$paper_bill_to['contact_email'] ?? '', $paper_bill_to['contact_phone'] ?? ''])), !empty($paper_bill_to['client_tax_id_number']) ? 'Tax ID: ' . $paper_bill_to['client_tax_id_number'] : '', // Exempt - said only when nothing here is taxed, so an older taxed invoice doesn't contradict itself !empty($paper_bill_to['tax_exempt_text']) && $paper_totals['tax'] == 0 ? $paper_bill_to['tax_exempt_text'] : '', ]); ?>
| Item | Qty | Price | Tax | Amount | ||
|---|---|---|---|---|---|---|
| = escapeHtml($paper_line_group['label']) ?> | ||||||
|
= $paper_field('name', $item['item_name'], 'name', escapeHtml($item['item_name']), 'd-block') ?>
= $paper_field('description', $item['item_description'], 'description', nl2br(escapeHtml($item['item_description'])), 'd-block') ?>
= $paper_field('description', '', 'description', 'Add a description', 'd-block') ?>
'seat', 'icon' => 'fa-users']; ?>
Per = $seat_source['unit'] ?> · = escapeHtml($seat['seat_label']) ?>= floatval($seat['item_seat_minimum']) > 0 ? ' · at least ' . billingQuantity($seat['item_seat_minimum']) : '' ?>
= escapeHtml($seat['seat_gone']) ?> - it stays at = billingQuantity($item['item_quantity']) ?>
Now = billingQuantity($seat['seat_quantity']) ?>
|
= isset($paper_seats[$item_id]) ? $item_quantity : $paper_field('qty', $item_quantity, 'quantity', $item_quantity) ?> | = $paper_field('price', number_format(floatval($item['item_price']), 2, '.', ''), 'price', $paper_money($item['item_price'])) ?> | = $paper_field('tax_id', intval($item['item_tax_id']), 'tax', $item_tax_html) ?> | = $paper_money($item['item_total']) ?> |
|
|
| Nothing on it yet. | ||||||
|
Say what it's for - lines from your catalog, labor at the client's rate.
|
||||||
| = escapeHtml($paper_group['label']) ?> | |
|---|---|
| Subtotal | = $paper_money($paper_group['subtotal']) ?> |
| Discount | -= $paper_money($paper_group['discount']) ?> |
| = escapeHtml($tax_label) ?> | = $paper_money($tax_amount) ?> |
| = $paper_frequency === '' ? 'Total up front' : 'Total ' . strtolower(escapeHtml($paper_group['label'])) ?> | = $paper_money($paper_group['total']) ?> |
| Subtotal | = $paper_money($paper_totals['subtotal']) ?> |
|---|---|
| Discount | -= $paper_money($paper_totals['discount']) ?> |
| = escapeHtml($tax_label) ?> | = $paper_money($tax_amount) ?> |
| Credit | -= $paper_money($paper_totals['credit']) ?> |
| Total | = $paper_money($paper_totals['total']) ?> |
| Paid | -= $paper_money($paper['paid']) ?> |
| Balance due | = $paper_money($paper['balance']) ?> |