{if $iframe} {$_locale_string = substr($wa->locale(), 0, 2)} {$wa->appName()} — {$wa->accountName()} {* CSS *} {$wa->css()} {wa_js} {$wa_url}wa-content/js/jquery/jquery-3.6.0.min.js {$wa_url}wa-content/js/jquery-plugins/jquery.store.js {$wa_url}wa-content/js/jquery-wa/wa.js {/wa_js} {wa_js} {$wa_app_static_url}js/crm.js {$wa_app_static_url}js/invoice.js {/wa_js} {* CRM CORE *} {$wa->js()} {/if} {$_title = '[`Invoice`]'} {$invoice.contact = $contact} {$is_pending = $invoice.state_id === crmInvoiceModel::STATE_PENDING} {$is_payment_expired = $is_pending && $invoice.days_left && $invoice.days_left < 0}

[`Invoice`] [`#`]{$invoice.number|escape} [`issued on`] {$invoice.invoice_date|wa_date} {sprintf('[`for %s`]', $invoice.amount|wa_format_amount_currency:$invoice.currency_id)} {* @event backend_invoice.%plugin_id%.title_suffix *} {if !empty($backend_invoice)}{foreach $backend_invoice as $_}{ifset($_.title_suffix)}{/foreach}{/if} {$_state = crmInvoice::getState($invoice.state_id)} {if $is_pending} {if $is_payment_expired} [`Payment deadline has expired`] {else} [`Pending payment`] {/if} {else} {$_state.name|escape|default:$invoice.state_id} {/if}

{if $show_url && empty($public_url)}   [`A CRM settlement is required to publish invoices.`] [`Use Site app to add a settlement for CRM.`] {/if}
{$_disabled = false} {$_contact = $invoice.contact} {$_exists = $_contact->exists()} {* $_disabled = !$_exists *} {if $invoice.state_id == crmInvoiceModel::STATE_PROCESSING} {elseif $invoice.state_id == crmInvoiceModel::STATE_PAID} {if $is_cancel_available} {/if} {elseif $invoice.state_id == crmInvoiceModel::STATE_PENDING} {elseif $invoice.state_id == crmInvoiceModel::STATE_DRAFT && floatval($invoice.amount)} {/if} {if $is_recurrent_available} {/if} {* @event backend_invoice.%plugin_id%.action_button *} {if !empty($backend_invoice)}{foreach $backend_invoice as $_}{ifset($_.action_button)}{/foreach}{/if} {if $show_url && !empty($public_url)} {/if}
{if !empty($invoice.due_date)}
[`Expires in`]
{if $invoice.state_id == crmInvoiceModel::STATE_PENDING && !$is_payment_expired} {/if} {if $invoice.state_id == crmInvoiceModel::STATE_PAID} {/if} {if $invoice.days_left >= 0}{_w('%s day', '%s days', $invoice.days_left)} [`to`] {/if}{$invoice.due_date|wa_date} {if in_array($invoice.state_id, [crmInvoiceModel::STATE_PENDING, crmInvoiceModel::STATE_DRAFT]) && $invoice.days_left < 0} [`Expired`] {/if}
{if $invoice.days_left < 0 && !crmInvoice::isCliOk()}

{sprintf_wp( 'Cron job required to automatically handle invoices expiration.', "`$wa_app_url`settings/cron/" )}

{* include file="templates/actions/settings/SettingsCronInvoicesArchive.inc.html" inline *}
{/if} {/if}
[`Billed To`]
{$_exists = $contact->exists()} {$_userpic = $contact->getPhoto(32)} {$_contact_name = $wa->crm->contactName($contact.name)}
{if !empty($_userpic)}
{if $_exists} {else} {/if}
{/if}
{if $_exists} {$_contact_name} {if $company_contact} {$company_contact.name|escape} {/if} {else} {$_contact_name} {/if}
[`Payment recipient`]
{ifempty($invoice.company.name, $invoice.company_id)|escape}
{if !empty($invoice.comment_sanitized)}
[`Comment`]
{$invoice.comment_sanitized}
{/if}
{if $deal}
[`Deal`]
{$_funnel_color = 'lightgray'} {if !empty($funnel) && !empty($funnel.color)}{$_funnel_color = $funnel.color}{/if} {if $deal.status_id == crmDealModel::STATUS_WON} {elseif $deal.status_id == crmDealModel::STATUS_LOST} {elseif empty($funnel.icon)} {else} {/if} {$deal.name|escape} {if !empty($funnel.is_archived)} ([`archive`]) {/if}
{elseif $deal_access_denied}
[`Deal not shown due to access rights restrictions.`]
{/if} {if !empty($invoice.creator_contact)} {$_contact = $invoice.creator_contact} {$_exists = $_contact->exists()} {$_userpic = $_contact->getPhoto(32)} {$_contact_name = $wa->crm->contactName($_contact.name)}
[`Created by`]
{if !empty($_userpic)}
{if $_exists} {else} {/if}
{/if}
{if $_exists} {$_contact_name} {else} {$_contact_name} {/if}
{/if}
[`Created at`]
{$invoice.create_datetime|wa_datetime}
{if $transactions}

[`Payment transactions`]

{foreach $transactions as $_t} {$_classes = ["c-transaction"]} {if $_t.state === "DECLINED"} {$_classes[] = "is-declined"} {elseif ($_t.state) === "CAPTURED"} {$_classes[] = "is-captured"} {elseif ($_t.state) === "CANCELED"} {$_classes[] = "is-canceled"} {elseif ($_t.state) === "REFUNDED"} {$_classes[] = "is-refunded"} {elseif ($_t.state) === "AUTH"} {$_classes[] = "is-auth"} {/if} {$plugin_name = {ifempty($plugins[$_t.plugin].name, $_t.plugin)|escape}} {/foreach}
{$_t.create_datetime|wa_datetime}
{$plugin_name} 
{$_t.amount|wa_format_amount_currency:$_t.currency_id}
{$_t.view_data|escape} 
{$_t.state|escape}
{/if} {* @event backend_invoice.%plugin_id%.info_section *} {if !empty($backend_invoice)}{foreach $backend_invoice as $_}{ifset($_.info_section)}{/foreach}{/if}
{include file="../frontend/FrontendInvoice.html" is_include=true use_skeleton=true inline}
{if $iframe} {/if}