mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for purchase order viewed activity
This commit is contained in:
parent
806af6996b
commit
a9004fa9f7
@ -108,6 +108,8 @@ class ActivityController extends BaseController
|
||||
'credit' => $activity->credit ? $activity->credit : '',
|
||||
'task' => $activity->task ? $activity->task : '',
|
||||
'vendor' => $activity->vendor ? $activity->vendor : '',
|
||||
'vendor_contact' => $activity->vendor_contact ? $activity->vendor_contact : '',
|
||||
'purchase_order' => $activity->purchase_order ? $activity->purchase_order : '',
|
||||
];
|
||||
|
||||
return array_merge($arr, $activity->toArray());
|
||||
|
@ -459,7 +459,8 @@ class BaseController extends Controller
|
||||
);
|
||||
|
||||
if ($query instanceof Builder) {
|
||||
$limit = request()->input('per_page', 20);
|
||||
//27-10-2022 - enforce unsigned integer
|
||||
$limit = $this->resolveQueryLimit();
|
||||
|
||||
$paginator = $query->paginate($limit);
|
||||
$query = $paginator->getCollection();
|
||||
@ -472,6 +473,14 @@ class BaseController extends Controller
|
||||
return $this->response($this->manager->createData($resource)->toArray());
|
||||
}
|
||||
|
||||
private function resolveQueryLimit()
|
||||
{
|
||||
if(request()->has('per_page'))
|
||||
return abs((int)request()->input('per_page', 20));
|
||||
|
||||
return 20;
|
||||
}
|
||||
|
||||
protected function miniLoadResponse($query)
|
||||
{
|
||||
$user = auth()->user();
|
||||
@ -524,7 +533,7 @@ class BaseController extends Controller
|
||||
);
|
||||
|
||||
if ($query instanceof Builder) {
|
||||
$limit = request()->input('per_page', 20);
|
||||
$limit = $this->resolveQueryLimit();
|
||||
|
||||
$paginator = $query->paginate($limit);
|
||||
$query = $paginator->getCollection();
|
||||
@ -782,7 +791,7 @@ class BaseController extends Controller
|
||||
);
|
||||
|
||||
if ($query instanceof Builder) {
|
||||
$limit = request()->input('per_page', 20);
|
||||
$limit = $this->resolveQueryLimit();
|
||||
|
||||
$paginator = $query->paginate($limit);
|
||||
$query = $paginator->getCollection();
|
||||
@ -831,7 +840,7 @@ class BaseController extends Controller
|
||||
}
|
||||
|
||||
if ($query instanceof Builder) {
|
||||
$limit = request()->input('per_page', 20);
|
||||
$limit = $this->resolveQueryLimit();
|
||||
$paginator = $query->paginate($limit);
|
||||
$query = $paginator->getCollection();
|
||||
$resource = new Collection($query, $transformer, $this->entity_type);
|
||||
|
@ -14,6 +14,7 @@ namespace App\Http\Controllers\VendorPortal;
|
||||
use App\Events\Credit\CreditWasViewed;
|
||||
use App\Events\Invoice\InvoiceWasViewed;
|
||||
use App\Events\Misc\InvitationWasViewed;
|
||||
use App\Events\PurchaseOrder\PurchaseOrderWasViewed;
|
||||
use App\Events\Quote\QuoteWasViewed;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
@ -83,7 +84,8 @@ class InvitationController extends Controller
|
||||
|
||||
$invitation->markViewed();
|
||||
event(new InvitationWasViewed($invitation->purchase_order, $invitation, $invitation->company, Ninja::eventVars()));
|
||||
|
||||
event(new PurchaseOrderWasViewed($invitation, $invitation->company, Ninja::eventVars()));
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
|
@ -17,8 +17,10 @@ use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\Admin\EntityViewedObject;
|
||||
use App\Notifications\Admin\EntityViewedNotification;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class InvitationViewedListener implements ShouldQueue
|
||||
@ -44,6 +46,11 @@ class InvitationViewedListener implements ShouldQueue
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
App::forgetInstance('translator');
|
||||
$t = app('translator');
|
||||
$t->replace(Ninja::transformTranslations($event->company->settings));
|
||||
App::setLocale($event->company->getLocale());
|
||||
|
||||
$entity_name = lcfirst(class_basename($event->entity));
|
||||
$invitation = $event->invitation;
|
||||
|
||||
|
@ -305,6 +305,16 @@ class Activity extends StaticModel
|
||||
return $this->belongsTo(Expense::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function purchase_order()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrder::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function vendor_contact()
|
||||
{
|
||||
return $this->belongsTo(VendorContact::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class)->withTrashed();
|
||||
|
@ -15,8 +15,14 @@ use App\Models\Activity;
|
||||
use App\Models\Backup;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\VendorContact;
|
||||
use App\Transformers\PurchaseOrderTransformer;
|
||||
use App\Transformers\VendorContactTransformer;
|
||||
use App\Transformers\VendorTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class ActivityTransformer extends EntityTransformer
|
||||
@ -40,6 +46,9 @@ class ActivityTransformer extends EntityTransformer
|
||||
'payment',
|
||||
'expense',
|
||||
'task',
|
||||
'purchase_order',
|
||||
'vendor',
|
||||
'vendor_contact',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -56,6 +65,7 @@ class ActivityTransformer extends EntityTransformer
|
||||
'recurring_invoice_id' => $activity->recurring_invoice_id ? (string) $this->encodePrimaryKey($activity->recurring_invoice_id) : '',
|
||||
'recurring_expense_id' => $activity->recurring_expense_id ? (string) $this->encodePrimaryKey($activity->recurring_expense_id) : '',
|
||||
'purchase_order_id' => $activity->purchase_order_id ? (string) $this->encodePrimaryKey($activity->purchase_order_id) : '',
|
||||
'vendor_id' => $activity->vendor_id ? (string) $this->encodePrimaryKey($activity->vendor_id) : '',
|
||||
'vendor_contact_id' => $activity->vendor_contact_id ? (string) $this->encodePrimaryKey($activity->vendor_contact_id) : '',
|
||||
'company_id' => $activity->company_id ? (string) $this->encodePrimaryKey($activity->company_id) : '',
|
||||
'user_id' => (string) $this->encodePrimaryKey($activity->user_id),
|
||||
@ -90,6 +100,13 @@ class ActivityTransformer extends EntityTransformer
|
||||
return $this->includeItem($activity->client, $transformer, Client::class);
|
||||
}
|
||||
|
||||
public function includeVendor(Activity $activity)
|
||||
{
|
||||
$transformer = new VendorTransformer($this->serializer);
|
||||
|
||||
return $this->includeItem($activity->vendor, $transformer, Vendor::class);
|
||||
}
|
||||
|
||||
public function includeContact(Activity $activity)
|
||||
{
|
||||
$transformer = new ClientContactTransformer($this->serializer);
|
||||
@ -97,6 +114,13 @@ class ActivityTransformer extends EntityTransformer
|
||||
return $this->includeItem($activity->contact, $transformer, ClientContact::class);
|
||||
}
|
||||
|
||||
public function includeVendorContact(Activity $activity)
|
||||
{
|
||||
$transformer = new VendorContactTransformer($this->serializer);
|
||||
|
||||
return $this->includeItem($activity->vendor_contact, $transformer, VendorContact::class);
|
||||
}
|
||||
|
||||
public function includeRecurringInvoice(Activity $activity)
|
||||
{
|
||||
$transformer = new RecurringInvoiceTransformer($this->serializer);
|
||||
@ -104,6 +128,14 @@ class ActivityTransformer extends EntityTransformer
|
||||
return $this->includeItem($activity->recurring_invoice, $transformer, RecurringInvoice::class);
|
||||
}
|
||||
|
||||
public function includePurchaseOrder(Activity $activity)
|
||||
{
|
||||
$transformer = new PurchaseOrderTransformer($this->serializer);
|
||||
|
||||
return $this->includeItem($activity->purchase_order(), $transformer, PurchaseOrder::class);
|
||||
}
|
||||
|
||||
|
||||
public function includeQuote(Activity $activity)
|
||||
{
|
||||
$transformer = new RecurringInvoiceTransformer($this->serializer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user