Change create attendee to invite

This commit is contained in:
Yoann Lecuyer 2016-05-29 12:03:18 -05:00
parent fc2ee7244c
commit 5ce0711da3
10 changed files with 65 additions and 60 deletions

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ installed
/.project
/.buildpath
/composer.phar
_ide_helper.php
_ide_helper.php
*.swp

View File

@ -75,13 +75,13 @@ class EventAttendeesController extends MyBaseController
}
/**
* Show the 'Create Attendee' modal
* Show the 'Invite Attendee' modal
*
* @param Request $request
* @param $event_id
* @return string|View
*/
public function showCreateAttendee(Request $request, $event_id)
public function showInviteAttendee(Request $request, $event_id)
{
$event = Event::scope()->find($event_id);
@ -90,28 +90,27 @@ class EventAttendeesController extends MyBaseController
* @todo This is a bit hackish
*/
if ($event->tickets->count() === 0) {
return '<script>showMessage("You need to create a ticket before you can add an attendee.");</script>';
return '<script>showMessage("You need to create a ticket before you can invite an attendee.");</script>';
}
return view('ManageEvent.Modals.CreateAttendee', [
return view('ManageEvent.Modals.InviteAttendee', [
'event' => $event,
'tickets' => $event->tickets()->lists('title', 'id'),
]);
}
/**
* Create an attendee
* Invite an attendee
*
* @param Request $request
* @param $event_id
* @return mixed
*/
public function postCreateAttendee(Request $request, $event_id)
public function postInviteAttendee(Request $request, $event_id)
{
$rules = [
'first_name' => 'required',
'ticket_id' => 'required|exists:tickets,id,account_id,' . \Auth::user()->account_id,
'ticket_price' => 'numeric|required',
'email' => 'email|required',
];
@ -130,7 +129,7 @@ class EventAttendeesController extends MyBaseController
}
$ticket_id = $request->get('ticket_id');
$ticket_price = $request->get('ticket_price');
$ticket_price = 0;
$attendee_first_name = $request->get('first_name');
$attendee_last_name = $request->get('last_name');
$attendee_email = $request->get('email');
@ -195,10 +194,10 @@ class EventAttendeesController extends MyBaseController
$this->dispatch(new GenerateTicket($order->order_reference."-".$attendee->reference_index));
if ($email_attendee == '1') {
TicketMailer::sendAttendeeTicket($attendee);
TicketMailer::sendAttendeeInvite($attendee);
}
session()->flash('message', 'Attendee Successfully Created');
session()->flash('message', 'Attendee Successfully Invited');
DB::commit();
@ -216,7 +215,7 @@ class EventAttendeesController extends MyBaseController
return response()->json([
'status' => 'error',
'error' => 'An error occurred while creating this attendee. Please try again.'
'error' => 'An error occurred while inviting this attendee. Please try again.'
]);
}
@ -259,7 +258,6 @@ class EventAttendeesController extends MyBaseController
{
$rules = [
'ticket_id' => 'required|exists:tickets,id,account_id,' . \Auth::user()->account_id,
'ticket_price' => 'numeric',
'attendees_list' => 'required|mimes:csv,txt|max:5000|',
];
@ -277,10 +275,7 @@ class EventAttendeesController extends MyBaseController
}
$ticket_id = $request->get('ticket_id');
$ticket_price = $request->get('ticket_price');
if ($request->get('ticket_price') == null) {
$ticket_price = 0;
}
$ticket_price = 0;
$email_attendee = $request->get('email_ticket');
$num_added = 0;
if ($request->file('attendees_list')) {
@ -311,6 +306,7 @@ class EventAttendeesController extends MyBaseController
$order->account_id = Auth::user()->account_id;
$order->event_id = $event_id;
$order->save();
/**
* Update qty sold
*/
@ -352,13 +348,13 @@ class EventAttendeesController extends MyBaseController
$this->dispatch(new GenerateTicket($attendee->getReferenceAttribute()));
if ($email_attendee == '1') {
TicketMailer::sendAttendeeTicket($attendee);
TicketMailer::sendAttendeeInvite($attendee);
}
}
};
}
session()->flash('message', $num_added . ' Attendees Successfully Created');
session()->flash('message', $num_added . ' Attendees Successfully Invited');
return response()->json([
'status' => 'success',

View File

@ -413,14 +413,14 @@ Route::group(['middleware' => ['auth', 'first.run']], function () {
'uses' => 'EventAttendeesController@postResendTicketToAttendee',
]);
Route::get('{event_id}/attendees/create', [
'as' => 'showCreateAttendee',
'uses' => 'EventAttendeesController@showCreateAttendee',
Route::get('{event_id}/attendees/invite', [
'as' => 'showInviteAttendee',
'uses' => 'EventAttendeesController@showInviteAttendee',
]);
Route::post('{event_id}/attendees/create', [
'as' => 'postCreateAttendee',
'uses' => 'EventAttendeesController@postCreateAttendee',
Route::post('{event_id}/attendees/invite', [
'as' => 'postInviteAttendee',
'uses' => 'EventAttendeesController@postInviteAttendee',
]);
Route::get('{event_id}/attendees/import', [

View File

@ -48,4 +48,24 @@ class TicketMailer
}
public static function sendAttendeeInvite($attendee) {
Log::info("Sending invite to: ".$attendee->email);
$data = [
'attendee' => $attendee,
];
Mail::queue('Mailers.TicketMailer.SendAttendeeInvite', $data, function($message) use ($attendee) {
$message->to($attendee->email);
$message->subject('Your ticket for the event '.$attendee->order->event->title);
$file_name = $attendee->getReferenceAttribute();
$file_path = public_path(config('attendize.event_pdf_tickets_path')).'/'.$file_name.'.pdf';
$message->attach($file_path);
});
}
}

View File

@ -0,0 +1,11 @@
@extends('Emails.Layouts.Master')
@section('message_content')
Hello {{$attendee->first_name}},<br><br>
You have been invited to the event <b>{{$attendee->order->event->title}}</b>.<br/>
Your ticket for the event is attached to this email.
<br><br>
Regards
@stop

View File

@ -5,7 +5,6 @@ Hello {{$attendee->first_name}},<br><br>
Your ticket for the event <b>{{$attendee->order->event->title}}</b> is attached to this email.
<br><br>
Thank you
@stop

View File

@ -29,11 +29,11 @@ Attendees
<div class="col-md-9">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group btn-group-responsive">
<button data-modal-id="CreateTicket" href="javascript:void(0);" data-href="{{route('showCreateAttendee', ['event_id'=>$event->id])}}" class="loadModal btn btn-success" type="button"><i class="ico-ticket"></i> Add Attendee</button>
<button data-modal-id="InviteAttendee" href="javascript:void(0);" data-href="{{route('showInviteAttendee', ['event_id'=>$event->id])}}" class="loadModal btn btn-success" type="button"><i class="ico-user-plus"></i> Invite Attendee</button>
</div>
<div class="btn-group btn-group-responsive">
<button data-modal-id="CreateTicket" href="javascript:void(0);" data-href="{{route('showImportAttendee', ['event_id'=>$event->id])}}" class="loadModal btn btn-success" type="button"><i class="ico-user-plus"></i> Import Attendees</button>
<button data-modal-id="ImportAttendees" href="javascript:void(0);" data-href="{{route('showImportAttendee', ['event_id'=>$event->id])}}" class="loadModal btn btn-success" type="button"><i class="ico-file"></i> Invite Attendees</button>
</div>
<div class="btn-group btn-group-responsive">

View File

@ -6,7 +6,7 @@
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">
<i class="ico-user-plus"></i>
Import Attendees</h3>
Invite Attendees</h3>
</div>
<div class="modal-body">
<div class="row">
@ -18,17 +18,6 @@
{!! Form::select('ticket_id', $tickets, null, ['class' => 'form-control']) !!}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{!! Form::label('ticket_price', 'Ticket Price', array('class'=>'control-label')) !!}
{!! Form::text('ticket_price', Input::old('price'),
array(
'class'=>'form-control',
'placeholder'=>'E.g: 25.99'
)) !!}
</div>
</div>
</div>
<!-- Import -->
<div class="row">
@ -45,7 +34,7 @@
<div class="form-group">
<div class="checkbox custom-checkbox">
<input type="checkbox" name="email_ticket" id="email_ticket" value="1" />
<label for="email_ticket">&nbsp;&nbsp;Send confirmation & ticket to attendee.</label>
<label for="email_ticket">&nbsp;&nbsp;Send invitation & ticket to attendees.</label>
</div>
</div>
</div>

View File

@ -1,12 +1,12 @@
<div role="dialog" class="modal fade " style="display: none;">
{!! Form::open(array('url' => route('postCreateAttendee', array('event_id' => $event->id)), 'class' => 'ajax')) !!}
{!! Form::open(array('url' => route('postInviteAttendee', array('event_id' => $event->id)), 'class' => 'ajax')) !!}
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header text-center">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">
<i class="ico-user"></i>
Create Attendee</h3>
Invite Attendee</h3>
</div>
<div class="modal-body">
<div class="row">
@ -18,17 +18,6 @@
{!! Form::select('ticket_id', $tickets, null, ['class' => 'form-control']) !!}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{!! Form::label('ticket_price', 'Ticket Price', array('class'=>'control-label required')) !!}
{!! Form::text('ticket_price', Input::old('price'),
array(
'class'=>'form-control',
'placeholder'=>'E.g: 25.99'
)) !!}
</div>
</div>
</div>
<div class="row">
@ -67,7 +56,7 @@
<div class="form-group">
<div class="checkbox custom-checkbox">
<input type="checkbox" name="email_ticket" id="email_ticket" value="1" />
<label for="email_ticket">&nbsp;&nbsp;Send confirmation & ticket to attendee.</label>
<label for="email_ticket">&nbsp;&nbsp;Send invitation & ticket to attendee.</label>
</div>
</div>
</div>
@ -75,7 +64,7 @@
</div> <!-- /end modal body-->
<div class="modal-footer">
{!! Form::button('Cancel', ['class'=>"btn modal-close btn-danger",'data-dismiss'=>'modal']) !!}
{!! Form::submit('Create Attendee', ['class'=>"btn btn-success"]) !!}
{!! Form::submit('Invite Attendee', ['class'=>"btn btn-success"]) !!}
</div>
</div><!-- /end modal content-->
{!! Form::close() !!}

View File

@ -10,13 +10,13 @@
@stop
@section('blankslate-text')
Attendees will appear here once they successfully registered for your event, or, you can manually add attendees yourself.
Attendees will appear here once they successfully registered for your event, or, you can manually invite attendees yourself.
@stop
@section('blankslate-body')
<button data-invoke="modal" data-modal-id='CreateTicket' data-href="{{route('showCreateAttendee', array('event_id'=>$event->id))}}" href='javascript:void(0);' class=' btn btn-success mt5 btn-lg' type="button" >
<i class="ico-ticket"></i>
Create Attendee
<button data-invoke="modal" data-modal-id='InviteAttendee' data-href="{{route('showInviteAttendee', array('event_id'=>$event->id))}}" href='javascript:void(0);' class=' btn btn-success mt5 btn-lg' type="button" >
<i class="ico-user-plus"></i>
Invite Attendee
</button>
@stop