| 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/services/estimates/ |
Upload File : |
<?php
namespace app\services\estimates;
use app\services\AbstractKanban;
class EstimatesPipeline extends AbstractKanban
{
protected function table(): string
{
return 'estimates';
}
public function defaultSortDirection()
{
return get_option('default_estimates_pipeline_sort_type');
}
public function defaultSortColumn()
{
return get_option('default_estimates_pipeline_sort');
}
public function limit()
{
return get_option('estimates_pipeline_limit');
}
protected function applySearchQuery($q): self
{
if (!startsWith($q, '#')) {
$fields_client = $this->ci->db->list_fields(db_prefix() . 'clients');
$fields_estimates = $this->ci->db->list_fields(db_prefix() . 'estimates');
$q = $this->ci->db->escape_like_str($q);
$where = '(';
$i = 0;
foreach ($fields_client as $f) {
$where .= db_prefix() . 'clients.' . $f . ' LIKE "%' . $q . '%" ESCAPE \'!\'';
$where .= ' OR ';
$i++;
}
$i = 0;
foreach ($fields_estimates as $f) {
$where .= db_prefix() . 'estimates.' . $f . ' LIKE "%' . $q . '%" ESCAPE \'!\'';
$where .= ' OR ';
$i++;
}
$where = substr($where, 0, -4);
$where .= ')';
$this->ci->db->where($where);
} else {
$this->ci->db->where(db_prefix() . 'estimates.id IN
(SELECT rel_id FROM ' . db_prefix() . 'taggables WHERE tag_id IN
(SELECT id FROM ' . db_prefix() . 'tags WHERE name="' . $this->ci->db->escape_str(strafter($search, '#')) . '")
AND ' . db_prefix() . 'taggables.rel_type=\'estimate\' GROUP BY rel_id HAVING COUNT(tag_id) = 1)
');
}
return $this;
}
protected function initiateQuery(): self
{
$has_permission_view = staff_can('view', 'estimates');
$noPermissionQuery = get_estimates_where_sql_for_staff(get_staff_user_id());
$this->ci->db->select(db_prefix() . 'estimates.id,status,invoiceid,' . get_sql_select_client_company() . ',total,currency,symbol,' . db_prefix() . 'currencies.name as currency_name,date,expirydate,clientid');
$this->ci->db->from('estimates');
$this->ci->db->join(db_prefix() . 'clients', db_prefix() . 'clients.userid = ' . db_prefix() . 'estimates.clientid', 'left');
$this->ci->db->join(db_prefix() . 'currencies', db_prefix() . 'estimates.currency = ' . db_prefix() . 'currencies.id');
$this->ci->db->where('status', $this->status);
if (!$has_permission_view) {
$this->ci->db->where($noPermissionQuery);
}
return $this;
}
}