| 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/views/admin/tables/ |
Upload File : |
<?php
defined('BASEPATH') or exit('No direct script access allowed');
$baseCurrency = get_base_currency();
$aColumns = [
'' . db_prefix() . 'proposals.id as id',
'subject',
'total',
'date',
'open_till',
'(SELECT GROUP_CONCAT(name SEPARATOR ",") FROM ' . db_prefix() . 'taggables JOIN ' . db_prefix() . 'tags ON ' . db_prefix() . 'taggables.tag_id = ' . db_prefix() . 'tags.id WHERE rel_id = ' . db_prefix() . 'proposals.id and rel_type="proposal" ORDER by tag_order ASC) as tags',
'datecreated',
'status',
];
$sIndexColumn = 'id';
$sTable = db_prefix() . 'proposals';
$join = [];
$custom_fields = get_table_custom_fields('proposal');
foreach ($custom_fields as $key => $field) {
$selectAs = (is_cf_date($field) ? 'date_picker_cvalue_' . $key : 'cvalue_' . $key);
array_push($customFieldsColumns, $selectAs);
array_push($aColumns, 'ctable_' . $key . '.value as ' . $selectAs);
array_push($join, 'LEFT JOIN ' . db_prefix() . 'customfieldsvalues as ctable_' . $key . ' ON ' . db_prefix() . 'proposals.id = ctable_' . $key . '.relid AND ctable_' . $key . '.fieldto="' . $field['fieldto'] . '" AND ctable_' . $key . '.fieldid=' . $field['id']);
}
$where = 'AND rel_id = ' . $rel_id . ' AND rel_type = "' . $rel_type . '"';
if ($rel_type == 'customer') {
$this->ci->db->where('userid', $rel_id);
$customer = $this->ci->db->get(db_prefix() . 'clients')->row();
if ($customer) {
if (!is_null($customer->leadid)) {
$where .= ' OR rel_type="lead" AND rel_id=' . $customer->leadid;
}
}
}
$where = [$where];
if (staff_cant('view', 'proposals')) {
array_push($where, 'AND ' . get_proposals_sql_where_staff(get_staff_user_id()));
}
$aColumns = hooks()->apply_filters('proposals_relation_table_sql_columns', $aColumns);
// Fix for big queries. Some hosting have max_join_limit
if (count($custom_fields) > 4) {
@$this->ci->db->query('SET SQL_BIG_SELECTS=1');
}
$result = data_tables_init($aColumns, $sIndexColumn, $sTable, $join, $where, [
'currency',
'invoice_id',
'hash',
]);
$output = $result['output'];
$rResult = $result['rResult'];
foreach ($rResult as $aRow) {
$row = [];
$numberOutput = '<a href="' . admin_url('proposals/list_proposals/' . $aRow['id']) . '">' . e(format_proposal_number($aRow['id'])) . '</a>';
$numberOutput .= '<div class="row-options">';
$numberOutput .= '<a href="' . site_url('proposal/' . $aRow['id'] . '/' . $aRow['hash']) . '" target="_blank">' . _l('view') . '</a>';
if (staff_can('edit', 'proposals')) {
$numberOutput .= ' | <a href="' . admin_url('proposals/proposal/' . $aRow['id']) . '">' . _l('edit') . '</a>';
}
$numberOutput .= '</div>';
$row[] = $numberOutput;
$row[] = '<a href="' . admin_url('proposals/list_proposals/' . $aRow['id']) . '">' . e($aRow['subject']) . '</a>';
$amount = e(app_format_money($aRow['total'], ($aRow['currency'] != 0 ? get_currency($aRow['currency']) : $baseCurrency)));
if ($aRow['invoice_id']) {
$amount .= '<br /> <span class="hide"> - </span><span class="text-success">' . _l('estimate_invoiced') . '</span>';
}
$row[] = $amount;
$row[] = e(_d($aRow['date']));
$row[] = e(_d($aRow['open_till']));
$row[] = render_tags($aRow['tags']);
$row[] = e(_d($aRow['datecreated']));
$row[] = format_proposal_status($aRow['status']);
// Custom fields add values
foreach ($customFieldsColumns as $customFieldColumn) {
$row[] = (strpos($customFieldColumn, 'date_picker_') !== false ? _d($aRow[$customFieldColumn]) : $aRow[$customFieldColumn]);
}
$output['aaData'][] = $row;
}