Exemple #1
0
function hourTable($hours, $o = array())
{
    $r = getRenderer();
    $table['headers'] = array('Date', 'Client', 'Description', 'Staff', 'Hours', 'Billable', 'Type', 'Edit', 'Delete');
    $table['rows'] = array();
    $total_hours = 0;
    $billable_hours = 0;
    $hours_to_skip = array();
    foreach ($hours as $h) {
        if (!empty($hours_to_skip[$h->id])) {
            continue;
        }
        $total_hours += $h->getHours();
        $billable_hours += $h->getBillableHours();
        if ($h->is_project_hour()) {
            $description = UI::link(array('controller' => 'Hour', 'action' => 'show', 'id' => $h->id, 'text' => $h->getName()));
            $edit_button = UI::button(array('controller' => 'Hour', 'action' => 'show', 'id' => $h->id));
        } else {
            $description = UI::link(array('controller' => 'SupportHour', 'action' => 'show', 'id' => $h->id, 'text' => $h->getName()));
            $edit_button = UI::button(array('controller' => 'SupportHour', 'action' => 'show', 'id' => $h->id));
        }
        $company_link = UI::link(array('text' => $h->getCompanyName(), 'controller' => 'Company', 'action' => 'show', 'id' => $h->getCompany()->id));
        $name = $h->getStaffName();
        if ($h->getPairName()) {
            $name . ' and ' . $h->getPairName();
        }
        $logged = $h->getHours();
        $billable = $h->getBillableHours();
        $type = $h->getType();
        if ($h->is_pair()) {
            $name = $h->getPairName();
            $logged = $logged * 2;
            $billable = $billable * 2;
            $hours_to_skip[$h->get('pair_hour_id')] = true;
        }
        $table['rows'][] = array($h->getData('date'), $company_link, $description, $name, $logged, $billable, $type, $edit_button, UI::button(array('controller' => 'Hour', 'action' => 'destroy', 'id' => $h->id)));
    }
    $o['title'] = 'Hours';
    $o['id'] = 'hour-table';
    $o['pager'] = true;
    $hours_table = $r->view('basicTable', $table, $o);
    $totals = '
    <div class="bs-docs-example" id="Hours">
    <div class="hours-month">
    Total Project Hours: <span class="unbillable">' . $total_hours . '</span>
    </div>
    <div class="hours-week">
    Billable Project Hours: <span class="billable">' . $billable_hours . '</span>
    </div>
    <div class="clear-both"></div></div>
    ';
    return $totals . $hours_table;
}
function bookmarkTable($bookmarks, $o = array())
{
    if (!$bookmarks) {
        return;
    }
    $r = getRenderer();
    $html = '<fieldset id="bookmarks"><legend>Bookmarks</legend><ul id="bookmark-list">';
    foreach ($bookmarks as $b) {
        $html .= "\n      <li>\n        <div class='destroy-bookmark-container'>\n          " . UI::link(array('controller' => 'Bookmark', 'action' => 'destroy', 'id' => $b->id, 'text' => '<span class="ui-icon ui-icon-trash"></span>'), array('class' => 'ui-state-default ui-corner-all')) . " \n        </div>\n        <a href='" . $b->getSource() . "'>" . $b->getDescription() . "</a>\n        <div class='clear'></div>\n      </li>";
    }
    $html .= '</ul></fieldset>';
    return $html;
}
Exemple #3
0
function paymentTable($payments, $o = array())
{
    $r = getRenderer();
    $table = array();
    $table['headers'] = array('Date', 'Invoice ID', 'Client', 'Amount', 'Type', 'Edit', 'Delete');
    $table['rows'] = array();
    $total_payments = 0;
    $r = getRenderer();
    foreach ($payments as $p) {
        $total_payments += $p->getAmount();
        $table['rows'][] = array(UI::link(array('controller' => 'Payment', 'action' => 'show', 'id' => $p->id, 'text' => $p->getData('date'))), UI::link(array('text' => $p->getInvoiceId(), 'controller' => 'Invoice', 'action' => 'show', 'id' => $p->getInvoiceId())), UI::link(array('controller' => 'Company', 'action' => 'show', 'id' => $p->getCompany()->id, 'text' => $p->getCompanyName())), '$ ' . number_format($p->getAmount(), 2), $p->getType(), $p->getPurpose(), UI::button(array('controller' => 'Payment', 'action' => 'show', 'id' => $p->id)), UI::button(array('controller' => 'Payment', 'action' => 'destroy', 'id' => $p->id)));
    }
    $payment_table = $r->view('basicTable', $table, array_merge(array('title' => 'Payments', 'pager' => true), $o));
    $total_payments = $r->view('basicMessage', 'Total payments: $ ' . number_format($total_payments, 2));
    return '<div id="payments-table">' . $total_payments . $payment_table . '</div>';
}
Exemple #4
0
 function link($controller, $parameters, $text = false, $o = array())
 {
     $parameters['controller'] = $controller;
     $parameters['text'] = $text;
     return UI::link($parameters, $o);
 }