mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Enable sending message from within the app
This commit is contained in:
parent
a5ead8407d
commit
3f8efb986d
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Response;
|
||||
use Request;
|
||||
use Redirect;
|
||||
use Auth;
|
||||
use View;
|
||||
use Input;
|
||||
use Mail;
|
||||
use Session;
|
||||
use App\Models\Account;
|
||||
use App\Libraries\Utils;
|
||||
@ -134,4 +136,24 @@ class HomeController extends BaseController
|
||||
{
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function contactUs()
|
||||
{
|
||||
Mail::raw(request()->message, function ($message) {
|
||||
$subject = 'Customer Message';
|
||||
if ( ! Utils::isNinja()) {
|
||||
$subject .= ': v' . NINJA_VERSION;
|
||||
}
|
||||
$message->to(CONTACT_EMAIL)
|
||||
->from(CONTACT_EMAIL, Auth::user()->present()->fullName)
|
||||
->replyTo(Auth::user()->email, Auth::user()->present()->fullName)
|
||||
->subject($subject);
|
||||
});
|
||||
|
||||
return redirect(Request::server('HTTP_REFERER'))
|
||||
->with('message', trans('texts.contact_us_response'));
|
||||
}
|
||||
}
|
||||
|
@ -131,6 +131,7 @@ Route::group(['middleware' => 'auth:user'], function() {
|
||||
Route::get('account/get_search_data', ['as' => 'get_search_data', 'uses' => 'AccountController@getSearchData']);
|
||||
Route::get('check_invoice_number/{invoice_id?}', 'InvoiceController@checkInvoiceNumber');
|
||||
Route::post('save_sidebar_state', 'UserController@saveSidebarState');
|
||||
Route::post('contact_us', 'HomeController@contactUs');
|
||||
|
||||
Route::get('settings/user_details', 'AccountController@showUserDetails');
|
||||
Route::post('settings/user_details', 'AccountController@saveUserDetails');
|
||||
|
@ -7,12 +7,20 @@ use App\Events\UserSettingsChanged;
|
||||
use App\Events\UserSignedUp;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use PresentableTrait;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $presenter = 'App\Ninja\Presenters\UserPresenter';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
14
app/Ninja/Presenters/UserPresenter.php
Normal file
14
app/Ninja/Presenters/UserPresenter.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php namespace App\Ninja\Presenters;
|
||||
|
||||
class UserPresenter extends EntityPresenter
|
||||
{
|
||||
public function email()
|
||||
{
|
||||
return htmlentities(sprintf('%s <%s>', $this->fullName(), $this->entity->email));
|
||||
}
|
||||
|
||||
public function fullName()
|
||||
{
|
||||
return $this->entity->first_name . ' ' . $this->entity->last_name;
|
||||
}
|
||||
}
|
@ -2274,6 +2274,7 @@ $LANG = array(
|
||||
'marked_sent_invoices' => 'Successfully marked invoices sent',
|
||||
'invoice_name' => 'Invoice',
|
||||
'product_will_create' => 'product will be created',
|
||||
'contact_us_response' => 'Your message has been sent',
|
||||
|
||||
);
|
||||
|
||||
|
@ -517,7 +517,7 @@
|
||||
@include('partials.navigation_option', ['option' => 'settings'])
|
||||
<li style="width:100%">
|
||||
<div class="nav-footer">
|
||||
<a href="{{ url(NINJA_CONTACT_URL) }}" target="_blank" title="{{ trans('texts.contact_us') }}">
|
||||
<a href="javascript:showContactUs()" target="_blank" title="{{ trans('texts.contact_us') }}">
|
||||
<i class="fa fa-envelope"></i>
|
||||
</a>
|
||||
<a href="{{ url(NINJA_FORUM_URL) }}" target="_blank" title="{{ trans('texts.support_forum') }}">
|
||||
@ -597,6 +597,7 @@
|
||||
<!-- /#page-content-wrapper -->
|
||||
</div>
|
||||
|
||||
@include('partials.contact_us')
|
||||
|
||||
@if (!Auth::check() || !Auth::user()->registered)
|
||||
<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-labelledby="signUpModalLabel" aria-hidden="true">
|
||||
|
48
resources/views/partials/contact_us.blade.php
Normal file
48
resources/views/partials/contact_us.blade.php
Normal file
@ -0,0 +1,48 @@
|
||||
{!! Former::vertical_open('/contact_us')->rules([
|
||||
'from' => 'required',
|
||||
'message' => 'required',
|
||||
]) !!}
|
||||
|
||||
<div class="modal fade" id="contactUsModal" tabindex="-1" role="dialog" aria-labelledby="contactUsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">{{ trans('texts.contact_us') }}</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="panel-body">
|
||||
|
||||
{!! Former::plaintext('from')
|
||||
->value(Auth::user()->present()->email) !!}
|
||||
|
||||
{!! Former::textarea('message')
|
||||
->rows(10) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
|
||||
<button type="submit" class="btn btn-success" onclick="submitContactUs()">{{ trans('texts.submit') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! Former::close() !!}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function showContactUs() {
|
||||
$('#contactUsModal').modal('show');
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$('#contactUsModal').on('shown.bs.modal', function() {
|
||||
$("#message").focus();
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user