private function getProviderQueueTickets(&$queue) { $headers = ['#', 'Client', 'Subject', 'Status', 'Updated', 'Assigned']; if ($this->canSeeBilling()) { $headers[] = 'Quoted/Billed'; } $tickets = $this->query("SELECT * from tickets WHERE queue_id='{$queue['id']}' and ticket_isclosed = false"); $rows = []; foreach ($tickets as $ticket) { $well = $ticket['ticket_standing'] ? "<div class='well'>" . nl2br($ticket['ticket_standing']) . "</div>" : null; $color = $ticket['ticket_status'] == 'Waiting for Admin' ? "blue" : null; $popover = base::popover($ticket['ticket_title'], $this->chop($ticket['ticket_body'], 150) . $well, 'right'); $row = [$ticket['id'], $this->getCompanyByID($ticket['company_id']), "<a {$popover} href='/ticket/{$ticket['id']}/'>{$ticket['ticket_title']}</a>", $ticket['ticket_status'], $this->fbTime($ticket['ticket_lastupdated']), $ticket['ticket_assigned'] ? "<a class='get' href='/selfassign/{$ticket['id']}/'> " . $this->getUserByID($ticket['ticket_assigned']) . "</a>" : "<a class='get' href='/selfassign/{$ticket['id']}/'>Unassigned</a>", $this->getQuotedBilled($ticket), $color]; if (!$this->canSeeBilling()) { array_pop($row); } if (!$color) { array_pop($row); } $rows[] = $row; } $table = table::init()->headers($headers)->rows($rows)->render(); return $table; }
public function listClients() { // At a glance - Let's view the client's basic info, If you can see billing, then show subscription // and show total amount collected. Put in a datatable so we can search. $headers = ["Client", "Address", "VIP", "Tickets"]; if ($this->canSeeBilling()) { $billing = ['Subscription', 'Total Income']; $headers = array_merge($headers, $billing); } $rows = []; $companies = $this->query("SELECT * from companies ORDER by company_since DESC"); foreach ($companies as $company) { $tcontent = null; $ticks = $this->query("SELECT id,ticket_title FROM tickets WHERE company_id='{$company['id']}' ORDER by ticket_opents DESC LIMIT 10"); foreach ($ticks as $tick) { $tcontent .= "<a href='/ticket/{$tick['id']}/'>{$tick['ticket_title']}</a><br/>"; } $ticketblock = base::popover("Ticket History", $tcontent, 'right'); $row = ["<a href='/client/{$company['id']}/'>{$company['company_name']}</a>", "{$company['company_address']}, {$company['company_city']}, {$company['company_state']}", $company['company_vip'] ? "Yes" : "No", "<a href='#' {$ticketblock}>" . $this->returnCountFromTable("tickets", "company_id='{$company['id']}'") . "</a>"]; if ($this->canSeeBilling()) { $plan = $this->query("SELECT * from plans WHERE id='{$company['company_plan']}'", true)[0]; if (!$plan) { $plandata = "No Subscription"; } else { $plandata = "{$plan['plan_name']} ({$plan['plan_amount']})"; } $ttl = 0; $transactions = $this->query("SELECT transaction_amount FROM transactions WHERE company_id='{$company['id']}'"); foreach ($transactions as $transaction) { $ttl += $transaction['transaction_amount']; } $ttl = "\$" . number_format($ttl, 2); $new = [$plandata, $ttl]; $row = array_merge($row, $new); } $rows[] = $row; } $this->exportJS(js::datatable('clientList')); $addButton = button::init()->text("Add Account")->icon('plus')->addStyle('btn-success')->url('/clients/create/')->render(); $table = table::init()->headers($headers)->rows($rows)->id('clientList')->render(); $widget = widget::init()->header("Customer List")->content($table)->isTable()->icon('user')->rightHeader($addButton)->render(); $this->export(base::row($widget)); }