| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/app.houseland.info/application/libraries/merge_fields/ |
Upload File : |
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Credit_note_merge_fields extends App_merge_fields
{
public function build()
{
return [
[
'name' => 'Credit Note Number',
'key' => '{credit_note_number}',
'available' => [
'credit_note',
],
],
[
'name' => 'Date',
'key' => '{credit_note_date}',
'available' => [
'credit_note',
],
],
[
'name' => 'Status',
'key' => '{credit_note_status}',
'available' => [
'credit_note',
],
],
[
'name' => 'Total',
'key' => '{credit_note_total}',
'available' => [
'credit_note',
],
],
[
'name' => 'Subtotal',
'key' => '{credit_note_subtotal}',
'available' => [
'credit_note',
],
],
[
'name' => 'Credits Used',
'key' => '{credit_note_credits_used}',
'available' => [
'credit_note',
],
],
[
'name' => 'Credits Remaining',
'key' => '{credit_note_credits_remaining}',
'available' => [
'credit_note',
],
],
];
}
/**
* Credit notes merge fields
* @param mixed $id credit note id
* @return array
*/
public function format($id)
{
$fields = [];
if (!class_exists('credit_notes_model')) {
$this->ci->load->model('credit_notes_model');
}
$credit_note = $this->ci->credit_notes_model->get($id);
if (!$credit_note) {
return $fields;
}
$fields['{credit_note_number}'] = e(format_credit_note_number($id));
$fields['{credit_note_total}'] = e(app_format_money($credit_note->total, $credit_note->currency_name));
$fields['{credit_note_subtotal}'] = e(app_format_money($credit_note->subtotal, $credit_note->currency_name));
$fields['{credit_note_credits_remaining}'] = e(app_format_money($credit_note->remaining_credits, $credit_note->currency_name));
$fields['{credit_note_credits_used}'] = e(app_format_money($credit_note->credits_used, $credit_note->currency_name));
$fields['{credit_note_date}'] = e(_d($credit_note->date));
$fields['{credit_note_status}'] = e(format_credit_note_status($credit_note->status, true));
$custom_fields = get_custom_fields('credit_note');
foreach ($custom_fields as $field) {
$fields['{' . $field['slug'] . '}'] = get_custom_field_value($id, $field['id'], 'credit_note');
}
return hooks()->apply_filters('credit_note_merge_fields', $fields, [
'id' => $id,
'credit_note' => $credit_note,
]);
}
}