public static function read_key($key) { $quote = self::read(['*'], TRUE, ["`key` = ?", $key]); $quote['items'] = QuoteItem::read_items($quote['id']); $annual_fee = 0; foreach ($quote['items'] as $item) { $annual_fee += $item['annual_fee']; } $quote['first_fee'] = $annual_fee; $quote['annual_fee'] = $annual_fee; if (!is_null($quote['discount'])) { $quote['first_fee'] -= $quote['discount']; } $quote['expiration'] = Util2::future_date(substr($quote['created'], 0, 10), 60); return $quote; }
<div class="content left"> <table class="data"> <thead> <th>Date</th> <th>Expires</th> <th>Company</th> <th>Contact/Email/Key</th> <th>Items</th> <th>Views</th> </thead> <tbody> <?php $quotes = Quote::read(['*'], FALSE, ['created > CURRENT_DATE - INTERVAL 2 MONTH'], 'created DESC'); foreach ($quotes as $quote) { $expiration = Util2::future_date(substr($quote['created'], 0, 10), 60); $items = QuoteItem::read_items($quote['id']); $views = QuoteView::read_views($quote['id']); $item_details = []; foreach ($items as $item) { $item_details[] = $item['quantity'] . ' ' . $item['part']; } $view_details = []; foreach ($views as $view) { $view_details[] = $view['created'] . ' ' . $view['ip']; } echo '<tr>'; echo '<td>' . htmlspecialchars($quote['created']) . '</td>'; echo '<td>' . htmlspecialchars($expiration) . '</td>'; echo '<td>' . htmlspecialchars($quote['company']) . '</td>'; echo '<td>' . htmlspecialchars($quote['technical_name']) . '<br/>'; echo htmlspecialchars($quote['technical_email']) . '<br/>';