getTemplate() : 'standard';
if (empty($current_template)) {
$current_template = 'standard';
}
// Always include the hidden input for the template field
?>
= 3) break;
if ($template_id !== $current_template && isset($all_templates[$template_id])) {
$main_grid_templates[$template_id] = $all_templates[$template_id];
}
}
// If we still don't have 3 templates, add any remaining templates
foreach ($all_templates as $template_id => $template) {
if (count($main_grid_templates) >= 3) break;
if (!isset($main_grid_templates[$template_id])) {
$main_grid_templates[$template_id] = $template;
}
}
// Display the main grid templates
foreach ($main_grid_templates as $template_id => $template) :
$checked = ($current_template === $template_id) ? 'checked' : '';
$selected_class = ($current_template === $template_id) ? 'selected' : '';
// Check if this template is premium (not free)
$is_premium = isset($template['is_free']) && !$template['is_free'];
// Add premium overlay classes
$premium_classes = '';
if ($is_free_version && $is_premium) {
$premium_classes = 'premium-template-blurred';
}
?>
getFields('quote-tab');
foreach ($main_fields as $field):
// Skip fields that have a section (like notes) - they're rendered separately
// Also skip the template field as it's rendered manually in the template selection section
if (!isset($field['section']) && $field['name'] !== 'quote_template') {
echo $quote_form_manager->renderField($field, $quote);
}
endforeach;
?>
getFieldsBySection('quote-tab', 'notes');
foreach ($notes_fields as $field):
echo $quote_form_manager->renderField($field, $quote);
endforeach;
?>
getItems()) :
$index = 0;
foreach ($quote->getItems() as $item) :
// Generate a unique ID for the item
$item_id = 'item_' . time() . '_' . $index . '_' . rand(1000, 9999);
// Get display title for header using dynamic field access
$title = $item->getName();
if (empty($title) && method_exists($item, 'getData')) {
$item_data = $item->getData();
if (is_array($item_data) && isset($item_data['title'])) {
$title = $item_data['title'];
}
}
$display_title = !empty($title) ? $title : sprintf(__('Item #%d', 'easy-invoice'), $index + 1);
$short_title = strlen($display_title) > 30 ? substr($display_title, 0, 30) . '...' : $display_title;
?>
getQuantity()); ?> × $getPrice()), 2)); ?>
= $getAmount(), 2)); ?>
generateExistingItemHtml($item, $index); ?>
getItemFields();
$title_placeholder = '';
foreach ($item_fields as $field) {
if ($field['name'] === 'title') {
$title_placeholder = $field['placeholder'] ?? __('Item', 'easy-invoice');
break;
}
}
// Try to get the value from POST (if form was submitted and errored)
$item_title = isset($_POST['items'][0]['title']) ? trim($_POST['items'][0]['title']) : '';
?>
generateItemTemplateHtml(); ?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getBusinessClientName() ?: ($client->getFirstName() . ' ' . $client->getLastName()));
} else {
echo '-';
}
} else {
echo '-';
}
?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getEmail() ?: '-');
} else {
echo '-';
}
} else {
echo '-';
}
?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getBusinessClientName() ?: ($client->getFirstName() . ' ' . $client->getLastName()));
} else {
echo '-';
}
} else {
echo '-';
}
?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getBusinessClientName() ?: '-');
} else {
echo '-';
}
} else {
echo '-';
}
?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getEmail() ?: '-');
} else {
echo '-';
}
} else {
echo '-';
}
?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getExtraInfo() ?: esc_html__('—', 'easy-invoice'));
} else {
echo esc_html__('—', 'easy-invoice');
}
} else {
echo esc_html__('—', 'easy-invoice');
}
?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getWebsite() ?: esc_html__('—', 'easy-invoice'));
} else {
echo esc_html__('—', 'easy-invoice');
}
} else {
echo esc_html__('—', 'easy-invoice');
}
?>
getClientId()) {
$client = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find($quote->getClientId());
if ($client) {
echo esc_html($client->getAddress() ?: esc_html__('—', 'easy-invoice'));
} else {
echo esc_html__('—', 'easy-invoice');
}
} else {
echo esc_html__('—', 'easy-invoice');
}
?>
getFieldsBySection('discounts-taxes-tab', 'discount');
$tax_fields = $quote_form_manager->getFieldsBySection('discounts-taxes-tab', 'tax');
$additional_tax_fields = $quote_form_manager->getFieldsBySection('discounts-taxes-tab', 'additional_tax');
// Combine and sort by order
$all_fields = array_merge($discount_fields, $tax_fields, $additional_tax_fields);
usort($all_fields, function($a, $b) {
return ($a['order'] ?? 0) - ($b['order'] ?? 0);
});
foreach ($all_fields as $field):
echo $quote_form_manager->renderField($field, $quote);
endforeach;
?>
getFieldsBySection('payments-tab', 'payment');
foreach ($payment_fields as $field):
echo $quote_form_manager->renderField($field, $quote);
endforeach;
?>
getFieldsBySection('payments-tab', 'currency');
foreach ($currency_fields as $field):
echo $quote_form_manager->renderField($field, $quote);
endforeach;
?>