mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for currency set for paymentsa
This commit is contained in:
parent
4e86fcf2ba
commit
66a19407d1
@ -2,12 +2,19 @@
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Events\Credit\CreditWasViewed;
|
||||
use App\Events\Invoice\InvoiceWasViewed;
|
||||
use App\Events\Misc\InvitationWasViewed;
|
||||
use App\Events\Quote\QuoteWasViewed;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class EntityViewController extends Controller
|
||||
@ -19,7 +26,7 @@ class EntityViewController extends Controller
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $entity_types = ['invoice', 'quote'];
|
||||
private $entity_types = ['invoice', 'quote', 'credit', 'recurring_invoice'];
|
||||
|
||||
/**
|
||||
* Show the entity outside client portal.
|
||||
@ -118,4 +125,54 @@ class EntityViewController extends Controller
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function handlePasswordSet(Request $request)
|
||||
{
|
||||
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($request->entity_type)).'Invitation';
|
||||
$key = $request->entity_type.'_id';
|
||||
|
||||
$invitation = $entity_obj::where('key', $request->invitation_key)
|
||||
->whereHas($request->entity_type, function ($query) {
|
||||
$query->where('is_deleted',0);
|
||||
})
|
||||
->with('contact.client')
|
||||
->first();
|
||||
|
||||
$contact = $invitation->contact;
|
||||
$contact->password = Hash::make($request->password);
|
||||
$contact->save();
|
||||
|
||||
$request->session()->invalidate();
|
||||
auth()->guard('contact')->loginUsingId($contact->id, true);
|
||||
|
||||
if (! $invitation->viewed_date) {
|
||||
$invitation->markViewed();
|
||||
|
||||
event(new InvitationWasViewed($invitation->{$request->entity_type}, $invitation, $invitation->{$request->entity_type}->company, Ninja::eventVars()));
|
||||
|
||||
$this->fireEntityViewedEvent($invitation, $request->entity_type);
|
||||
}
|
||||
|
||||
return redirect()->route('client.'.$request->entity_type.'.show', [$request->entity_type => $this->encodePrimaryKey($invitation->{$key})]);
|
||||
|
||||
}
|
||||
|
||||
private function fireEntityViewedEvent($invitation, $entity_string)
|
||||
{
|
||||
switch ($entity_string) {
|
||||
case 'invoice':
|
||||
event(new InvoiceWasViewed($invitation, $invitation->company, Ninja::eventVars()));
|
||||
break;
|
||||
case 'quote':
|
||||
event(new QuoteWasViewed($invitation, $invitation->company, Ninja::eventVars()));
|
||||
break;
|
||||
case 'credit':
|
||||
event(new CreditWasViewed($invitation, $invitation->company, Ninja::eventVars()));
|
||||
break;
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -102,6 +102,17 @@ class InvitationController extends Controller
|
||||
auth()->guard('contact')->loginUsingId($client_contact->id, true);
|
||||
|
||||
} elseif ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
|
||||
|
||||
//if no contact password has been set - allow user to set password - then continue to view entity
|
||||
if(empty($invitation->contact->password)){
|
||||
|
||||
return $this->render('view_entity.set_password', [
|
||||
'root' => 'themes',
|
||||
'entity_type' => $entity,
|
||||
'invitation_key' => $invitation_key
|
||||
]);
|
||||
}
|
||||
|
||||
$this->middleware('auth:contact');
|
||||
return redirect()->route('client.login');
|
||||
|
||||
|
@ -210,6 +210,7 @@ class PaymentRepository extends BaseRepository {
|
||||
$payment->exchange_currency_id = $company_currency;
|
||||
$payment->currency_id = $client_currency;
|
||||
|
||||
return $payment;
|
||||
}
|
||||
|
||||
$payment->currency_id = $company_currency;
|
||||
|
@ -4544,6 +4544,7 @@ $LANG = array(
|
||||
'activity_123' => ':user deleted recurring expense :recurring_expense',
|
||||
'activity_124' => ':user restored recurring expense :recurring_expense',
|
||||
'fpx' => "FPX",
|
||||
'to_view_entity_set_password' => 'To view the :entity you need to set password.',
|
||||
|
||||
);
|
||||
|
||||
|
@ -18,6 +18,7 @@ Route::post('client/password/reset', 'Auth\ContactResetPasswordController@reset'
|
||||
Route::get('view/{entity_type}/{invitation_key}', 'ClientPortal\EntityViewController@index')->name('client.entity_view');
|
||||
Route::get('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@password')->name('client.entity_view.password');
|
||||
Route::post('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@handlePassword');
|
||||
Route::post('set_password', 'ClientPortal\EntityViewController@handlePasswordSet')->name('client.set_password');
|
||||
|
||||
Route::get('tmp_pdf/{hash}', 'ClientPortal\TempRouteController@index')->name('tmp_pdf');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user