mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Bug fixes
This commit is contained in:
parent
2cd7228074
commit
ec1bc6f2cf
@ -11,6 +11,8 @@ class DashboardController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$view_all = !Auth::user()->hasPermission('view_all');
|
||||
$user_id = Auth::user()->id;
|
||||
|
||||
// total_income, billed_clients, invoice_sent and active_clients
|
||||
$select = DB::raw('COUNT(DISTINCT CASE WHEN invoices.id IS NOT NULL THEN clients.id ELSE null END) billed_clients,
|
||||
@ -24,8 +26,19 @@ class DashboardController extends BaseController
|
||||
->where('clients.is_deleted', '=', false)
|
||||
->where('invoices.is_deleted', '=', false)
|
||||
->where('invoices.is_recurring', '=', false)
|
||||
->where('invoices.is_quote', '=', false)
|
||||
->groupBy('accounts.id')
|
||||
->where('invoices.is_quote', '=', false);
|
||||
|
||||
if(!$view_all){
|
||||
$metrics = $metrics->where(function($query) use($user_id){
|
||||
$query->where('invoices.user_id', '=', $user_id);
|
||||
$query->orwhere(function($query) use($user_id){
|
||||
$query->where('invoices.user_id', '=', null);
|
||||
$query->where('clients.user_id', '=', $user_id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$metrics = $metrics->groupBy('accounts.id')
|
||||
->first();
|
||||
|
||||
$select = DB::raw('SUM(clients.paid_to_date) as value, clients.currency_id as currency_id');
|
||||
@ -33,8 +46,13 @@ class DashboardController extends BaseController
|
||||
->select($select)
|
||||
->leftJoin('clients', 'accounts.id', '=', 'clients.account_id')
|
||||
->where('accounts.id', '=', Auth::user()->account_id)
|
||||
->where('clients.is_deleted', '=', false)
|
||||
->groupBy('accounts.id')
|
||||
->where('clients.is_deleted', '=', false);
|
||||
|
||||
if(!$view_all){
|
||||
$paidToDate = $paidToDate->where('clients.user_id', '=', $user_id);
|
||||
}
|
||||
|
||||
$paidToDate = $paidToDate->groupBy('accounts.id')
|
||||
->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'))
|
||||
->get();
|
||||
|
||||
@ -47,8 +65,13 @@ class DashboardController extends BaseController
|
||||
->where('clients.is_deleted', '=', false)
|
||||
->where('invoices.is_deleted', '=', false)
|
||||
->where('invoices.is_quote', '=', false)
|
||||
->where('invoices.is_recurring', '=', false)
|
||||
->groupBy('accounts.id')
|
||||
->where('invoices.is_recurring', '=', false);
|
||||
|
||||
if(!$view_all){
|
||||
$averageInvoice = $averageInvoice->where('invoices.user_id', '=', $user_id);
|
||||
}
|
||||
|
||||
$averageInvoice = $averageInvoice->groupBy('accounts.id')
|
||||
->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'))
|
||||
->get();
|
||||
|
||||
@ -65,8 +88,7 @@ class DashboardController extends BaseController
|
||||
$activities = Activity::where('activities.account_id', '=', Auth::user()->account_id)
|
||||
->where('activities.activity_type_id', '>', 0);
|
||||
|
||||
if(!Auth::user()->hasPermission('view_all')){
|
||||
$user_id = Auth::user()->id;
|
||||
if(!$view_all){
|
||||
$activities = $activities->where('activities.user_id', '=', $user_id);
|
||||
}
|
||||
|
||||
@ -89,8 +111,7 @@ class DashboardController extends BaseController
|
||||
->where('contacts.is_primary', '=', true)
|
||||
->where('invoices.due_date', '<', date('Y-m-d'));
|
||||
|
||||
if(!Auth::user()->hasPermission('view_all')){
|
||||
$user_id = Auth::user()->id;
|
||||
if(!$view_all){
|
||||
$pastDue = $pastDue->where('invoices.user_id', '=', $user_id);
|
||||
}
|
||||
|
||||
@ -114,8 +135,7 @@ class DashboardController extends BaseController
|
||||
->where('invoices.due_date', '>=', date('Y-m-d'))
|
||||
->orderBy('invoices.due_date', 'asc');
|
||||
|
||||
if(!Auth::user()->hasPermission('view_all')){
|
||||
$user_id = Auth::user()->id;
|
||||
if(!$view_all){
|
||||
$upcoming = $upcoming->where('invoices.user_id', '=', $user_id);
|
||||
}
|
||||
|
||||
@ -134,8 +154,7 @@ class DashboardController extends BaseController
|
||||
->where('contacts.deleted_at', '=', null)
|
||||
->where('contacts.is_primary', '=', true);
|
||||
|
||||
if(!Auth::user()->hasPermission('view_all')){
|
||||
$user_id = Auth::user()->id;
|
||||
if(!$view_all){
|
||||
$payments = $payments->where('payments.user_id', '=', $user_id);
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,10 @@ class InvoiceController extends BaseController
|
||||
|
||||
$lastSent = ($invoice->is_recurring && $invoice->last_sent_date) ? $invoice->recurring_invoices->last() : null;
|
||||
|
||||
if(!Auth::user()->hasPermission('view_all')){
|
||||
$clients = $clients->where('clients.user_id', '=', Auth::user()->id);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'clients' => $clients->get(),
|
||||
'entityType' => $entityType,
|
||||
@ -227,8 +231,13 @@ class InvoiceController extends BaseController
|
||||
$invoice = $account->createInvoice($entityType, $clientId);
|
||||
$invoice->public_id = 0;
|
||||
|
||||
$clients = Client::scope()->with('contacts', 'country')->orderBy('name');
|
||||
if(!Auth::user()->hasPermission('view_all')){
|
||||
$clients = $clients->where('clients.user_id', '=', Auth::user()->id);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
|
||||
'clients' => $clients->get(),
|
||||
'entityType' => $invoice->getEntityType(),
|
||||
'invoice' => $invoice,
|
||||
'method' => 'POST',
|
||||
|
@ -184,9 +184,7 @@ class TaskController extends BaseController
|
||||
{
|
||||
$action = Input::get('action');
|
||||
|
||||
$input = $request->input();
|
||||
|
||||
if(!$this->checkUpdatePermission($input, $response)){
|
||||
if(!$this->checkUpdatePermission(array('public_id'=>$publicId)/* Hacky, but works */, $response)){
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use Utils;
|
||||
use URL;
|
||||
use Auth;
|
||||
use App\Services\BaseService;
|
||||
use App\Models\Client;
|
||||
use App\Models\Payment;
|
||||
@ -34,7 +35,7 @@ class CreditService extends BaseService
|
||||
$query = $this->creditRepo->find($clientPublicId, $search);
|
||||
|
||||
if(!Utils::hasPermission('view_all')){
|
||||
$query->where('expenses.user_id', '=', Auth::user()->id);
|
||||
$query->where('credits.user_id', '=', Auth::user()->id);
|
||||
}
|
||||
|
||||
return $this->createDatatable(ENTITY_CREDIT, $query, !$clientPublicId);
|
||||
|
@ -75,7 +75,7 @@
|
||||
<div style="display:none">
|
||||
@endif
|
||||
|
||||
{!! Former::select('client')->addOption('', '')->data_bind("dropdown: client")->addClass('client-input')->addGroupClass('client_select closer-row') !!}
|
||||
{!! Former::select('client')->addOption('', '')->data_bind("dropdown: client")->addClass('client-input')->addGroupClass('client_select closer-row') !!}
|
||||
|
||||
<div class="form-group" style="margin-bottom: 8px">
|
||||
<div class="col-lg-8 col-sm-8 col-lg-offset-4 col-sm-offset-4">
|
||||
|
@ -65,6 +65,7 @@
|
||||
$('#permissions_view_all').prop('disabled', adminChecked);
|
||||
$('#permissions_create_all').prop('disabled', adminChecked);
|
||||
$('#permissions_edit_all').prop('disabled', adminChecked || !viewChecked);
|
||||
if(!viewChecked)$('#permissions_edit_all').prop('checked',false)
|
||||
}
|
||||
fixCheckboxes();
|
||||
@stop
|
Loading…
Reference in New Issue
Block a user