bug fixes

This commit is contained in:
Hillel Coren 2014-02-17 18:25:38 +02:00
parent a3f988fa8d
commit cb898dd9b2
6 changed files with 43 additions and 48 deletions

View File

@ -5,10 +5,10 @@ class DashboardController extends \BaseController {
public function index()
{
// total_income, billed_clients, invoice_sent and active_clients
$select = DB::raw('SUM(DISTINCT clients.paid_to_date) total_income,
COUNT(DISTINCT CASE WHEN invoices.id IS NOT NULL THEN clients.id ELSE null END) billed_clients,
$select = DB::raw('COUNT(DISTINCT CASE WHEN invoices.id IS NOT NULL THEN clients.id ELSE null END) billed_clients,
SUM(CASE WHEN invoices.invoice_status_id >= '.INVOICE_STATUS_SENT.' THEN 1 ELSE 0 END) invoices_sent,
COUNT(DISTINCT clients.id) active_clients');
COUNT(DISTINCT clients.id) active_clients,
AVG(invoices.amount) as invoice_avg');
$metrics = DB::table('accounts')
->select($select)
@ -19,27 +19,35 @@ class DashboardController extends \BaseController {
->groupBy('accounts.id')
->first();
$invoiceAvg = DB::table('invoices')
->where('invoices.account_id', '=', Auth::user()->account_id)
->where('invoices.deleted_at', '=', null)
->avg('amount');
$select = DB::raw('SUM(clients.paid_to_date) value');
$totalIncome = DB::table('accounts')
->select($select)
->leftJoin('clients', 'accounts.id', '=', 'clients.account_id')
->where('accounts.id', '=', Auth::user()->account_id)
->where('clients.deleted_at', '=', null)
->groupBy('accounts.id')
->first();
$activities = Activity::where('activities.account_id', '=', Auth::user()->account_id)
->orderBy('created_at', 'desc')->take(6)->get();
$pastDue = Invoice::scope()->where('due_date', '<', date('Y-m-d'))
$pastDue = Invoice::scope()
->where('due_date', '<', date('Y-m-d'))
->where('balance', '>', 0)
->orderBy('due_date', 'asc')->take(6)->get();
$upcoming = Invoice::scope()->where('due_date', '>', date('Y-m-d'))
$upcoming = Invoice::scope()
->where('due_date', '>', date('Y-m-d'))
->where('balance', '>', 0)
->orderBy('due_date', 'asc')->take(6)->get();
$data = [
'totalIncome' => Utils::formatMoney($metrics->total_income, Session::get(SESSION_CURRENCY)),
'totalIncome' => Utils::formatMoney($totalIncome->value, Session::get(SESSION_CURRENCY)),
'billedClients' => $metrics->billed_clients,
'invoicesSent' => $metrics->invoices_sent,
'activeClients' => $metrics->active_clients,
'invoiceAvg' => Utils::formatMoney($invoiceAvg, Session::get(SESSION_CURRENCY)),
'invoiceAvg' => Utils::formatMoney($metrics->invoice_avg, Session::get(SESSION_CURRENCY)),
'activities' => $activities,
'pastDue' => $pastDue,
'upcoming' => $upcoming

View File

@ -18,7 +18,7 @@
{{ Former::select('client')->addOption('', '')->addGroupClass('client-select') }}
{{ Former::text('amount') }}
{{ Former::text('credit_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::text('credit_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
{{-- Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) --}}
{{ Former::textarea('private_notes') }}

View File

@ -62,13 +62,17 @@
</div>
<div class="col-md-4" id="col_2">
<div data-bind="visible: !is_recurring()">
{{ Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
{{ Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
</div>
<div data-bind="visible: is_recurring" style="display: none">
{{ Former::select('frequency_id')->label('How often')->options($frequencies)->data_bind("value: frequency_id") }}
{{ Former::text('start_date')->data_bind("datePicker: start_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::text('end_date')->data_bind("datePicker: end_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::text('start_date')->data_bind("datePicker: start_date, valueUpdate: 'afterkeydown'")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
{{ Former::text('end_date')->data_bind("datePicker: end_date, valueUpdate: 'afterkeydown'")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
</div>
@if ($invoice && $invoice->recurring_invoice_id)
<div class="pull-right" style="padding-top: 6px">
@ -76,7 +80,7 @@
</div>
@else
<div data-bind="visible: invoice_status_id() < CONSTS.INVOICE_STATUS_SENT">
{{ Former::checkbox('recurring')->text('Enable | <a href="#" onclick="showLearnMore()">Learn more</a>')->data_bind("checked: is_recurring")
{{ Former::checkbox('recurring')->text('Enable &nbsp;&nbsp; <a href="#" onclick="showLearnMore()"><i class="glyphicon glyphicon-question-sign"></i> Learn more</a>')->data_bind("checked: is_recurring")
->inlineHelp($invoice && $invoice->last_sent_date ? 'Last invoice sent ' . Utils::dateToString($invoice->last_sent_date) : '') }}
</div>
@endif
@ -92,7 +96,7 @@
<div class="form-group" style="margin-bottom: 8px">
<label for="recurring" class="control-label col-lg-4 col-sm-4">Taxes</label>
<div class="col-lg-8 col-sm-8" style="padding-top: 7px">
<a href="#" data-bind="click: $root.showTaxesForm">Manage rates</a>
<a href="#" data-bind="click: $root.showTaxesForm"><i class="glyphicon glyphicon-list-alt"></i> Manage rates</a>
</div>
</div>
@ -118,7 +122,7 @@
</thead>
<tbody data-bind="sortable: { data: invoice_items, afterMove: onDragged }">
<tr data-bind="event: { mouseover: showActions, mouseout: hideActions }" class="sortable-row">
<td style="min-width:20px;" class="hide-border td-icon">
<td style="min-width:32px;" class="hide-border td-icon">
<i style="display:none" data-bind="visible: actionsVisible() &amp;&amp; $parent.invoice_items().length > 1" class="fa fa-sort"></i>
</td>
<td style="min-width:160px">
@ -137,10 +141,10 @@
<td style="display:none" style="min-width:120px; vertical-align:middle" data-bind="visible: $root.invoice_item_taxes.show">
<select class="form-control" style="width:100%" data-bind="value: tax, options: $root.tax_rates, optionsText: 'displayName'"></select>
</td>
<td style="min-width:120px;text-align: right;padding-top:9px !important">
<span data-bind="text: totals.total"></span>
<td style="min-width:120px;text-align: right;padding-top:9px !important">
<div class="line-total" data-bind="text: totals.total"></div>
</td>
<td style="min-width:20px; cursor:pointer" class="hide-border td-icon">
<td style="min-width:32px; cursor:pointer" class="hide-border td-icon">
&nbsp;<i style="display:none" data-bind="click: $parent.removeItem, visible: actionsVisible() &amp;&amp; $parent.invoice_items().length > 1" class="fa fa-minus-circle" title="Remove item"/>
</td>
</tr>

View File

@ -22,7 +22,7 @@
{{ Former::text('amount') }}
{{ Former::select('payment_type_id')->addOption('','')->label('Payment type')
->fromQuery($paymentTypes, 'name', 'id') }}
{{ Former::text('payment_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::text('payment_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
{{-- Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) --}}

View File

@ -15,7 +15,7 @@
"intervention/image": "dev-master",
"webpatser/laravel-countries": "dev-master",
"anahkiasen/rocketeer": "dev-develop",
"codeception/codeception": "dev-master",
"codeception/codeception": "dev-master"
},
"autoload": {
"classmap": [

View File

@ -172,41 +172,24 @@ table.dataTable tr.even td.sorting_3 { background-color: white; }
New/edit invoice page
************************************************/
/*
table.invoice-table tbody tr:hover {
background-color: #FFFFFF !important;
}
*/
.invoice-table td {
padding: 2px !important;
.invoice-table td.hide-border,
.invoice-table th.hide-border {
border-style: none !important;
}
.invoice-table td input,
.invoice-table td textarea {
border: none !important;
width: 100%;
.invoice-table .line-total {
padding-top: 6px;
}
.invoice-table th {
border-top: 1px solid #ddd !important;
}
.invoice-table td.hide-border,
.invoice-table th.hide-border {
border-style: none !important;
}
.invoice-table td.td-icon {
vertical-align: middle !important;
}
.invoice-table tfoot tr {
height: 30px;
}
.fa-bars {
.fa-sort {
cursor: move !important;
}