2016-02-29 15:59:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2016-09-06 20:39:27 +00:00
|
|
|
use App\Jobs\GenerateTicket;
|
2016-06-15 10:14:27 +00:00
|
|
|
use App\Jobs\SendAttendeeInvite;
|
|
|
|
|
use App\Jobs\SendAttendeeTicket;
|
|
|
|
|
use App\Jobs\SendMessageToAttendees;
|
2016-03-05 00:18:10 +00:00
|
|
|
use App\Models\Attendee;
|
2016-02-29 15:59:36 +00:00
|
|
|
use App\Models\Event;
|
|
|
|
|
use App\Models\EventStats;
|
2016-03-05 00:18:10 +00:00
|
|
|
use App\Models\Message;
|
2016-02-29 15:59:36 +00:00
|
|
|
use App\Models\Order;
|
|
|
|
|
use App\Models\OrderItem;
|
2016-03-05 00:18:10 +00:00
|
|
|
use App\Models\Ticket;
|
|
|
|
|
use Auth;
|
2016-09-06 20:39:27 +00:00
|
|
|
use Config;
|
2016-03-05 00:18:10 +00:00
|
|
|
use DB;
|
|
|
|
|
use Excel;
|
2016-09-06 20:39:27 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Log;
|
2016-03-05 00:18:10 +00:00
|
|
|
use Mail;
|
2016-06-14 12:09:55 +00:00
|
|
|
use Omnipay\Omnipay;
|
2016-06-15 12:34:12 +00:00
|
|
|
use PDF;
|
2016-03-05 00:18:10 +00:00
|
|
|
use Validator;
|
|
|
|
|
|
|
|
|
|
class EventAttendeesController extends MyBaseController
|
|
|
|
|
{
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Show the attendees list
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return View
|
|
|
|
|
*/
|
|
|
|
|
public function showAttendees(Request $request, $event_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$allowed_sorts = ['first_name', 'email', 'ticket_id', 'order_reference'];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
$searchQuery = $request->get('q');
|
|
|
|
|
$sort_order = $request->get('sort_order') == 'asc' ? 'asc' : 'desc';
|
|
|
|
|
$sort_by = (in_array($request->get('sort_by'), $allowed_sorts) ? $request->get('sort_by') : 'created_at');
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
$event = Event::scope()->find($event_id);
|
|
|
|
|
|
|
|
|
|
if ($searchQuery) {
|
|
|
|
|
$attendees = $event->attendees()
|
2016-05-25 12:20:26 +00:00
|
|
|
->withoutCancelled()
|
|
|
|
|
->join('orders', 'orders.id', '=', 'attendees.order_id')
|
|
|
|
|
->where(function ($query) use ($searchQuery) {
|
|
|
|
|
$query->where('orders.order_reference', 'like', $searchQuery . '%')
|
|
|
|
|
->orWhere('attendees.first_name', 'like', $searchQuery . '%')
|
|
|
|
|
->orWhere('attendees.email', 'like', $searchQuery . '%')
|
|
|
|
|
->orWhere('attendees.last_name', 'like', $searchQuery . '%');
|
|
|
|
|
})
|
|
|
|
|
->orderBy(($sort_by == 'order_reference' ? 'orders.' : 'attendees.') . $sort_by, $sort_order)
|
|
|
|
|
->select('attendees.*', 'orders.order_reference')
|
|
|
|
|
->paginate();
|
2016-02-29 15:59:36 +00:00
|
|
|
} else {
|
|
|
|
|
$attendees = $event->attendees()
|
2016-05-25 12:20:26 +00:00
|
|
|
->join('orders', 'orders.id', '=', 'attendees.order_id')
|
|
|
|
|
->withoutCancelled()
|
|
|
|
|
->orderBy(($sort_by == 'order_reference' ? 'orders.' : 'attendees.') . $sort_by, $sort_order)
|
|
|
|
|
->select('attendees.*', 'orders.order_reference')
|
|
|
|
|
->paginate();
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = [
|
2016-12-01 22:11:34 +00:00
|
|
|
'attendees' => $attendees,
|
|
|
|
|
'event' => $event,
|
|
|
|
|
'sort_by' => $sort_by,
|
2016-02-29 15:59:36 +00:00
|
|
|
'sort_order' => $sort_order,
|
2016-12-01 22:11:34 +00:00
|
|
|
'q' => $searchQuery ? $searchQuery : '',
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return view('ManageEvent.Attendees', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
2016-05-29 17:03:18 +00:00
|
|
|
* Show the 'Invite Attendee' modal
|
2016-03-11 01:03:33 +00:00
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return string|View
|
|
|
|
|
*/
|
2016-05-29 17:03:18 +00:00
|
|
|
public function showInviteAttendee(Request $request, $event_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$event = Event::scope()->find($event_id);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If there are no tickets then we can't create an attendee
|
|
|
|
|
* @todo This is a bit hackish
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
if ($event->tickets->count() === 0) {
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
return '<script>showMessage("'.trans("Controllers.addInviteError").'");</script>';
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-29 17:03:18 +00:00
|
|
|
return view('ManageEvent.Modals.InviteAttendee', [
|
2016-12-01 22:11:34 +00:00
|
|
|
'event' => $event,
|
2016-05-25 12:20:26 +00:00
|
|
|
'tickets' => $event->tickets()->lists('title', 'id'),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2016-05-25 12:20:26 +00:00
|
|
|
|
|
|
|
|
/**
|
2016-05-29 17:03:18 +00:00
|
|
|
* Invite an attendee
|
2016-03-11 01:03:33 +00:00
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2016-05-29 17:03:18 +00:00
|
|
|
public function postInviteAttendee(Request $request, $event_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$rules = [
|
2016-09-06 20:39:27 +00:00
|
|
|
'first_name' => 'required',
|
2016-12-01 22:11:34 +00:00
|
|
|
'ticket_id' => 'required|exists:tickets,id,account_id,' . \Auth::user()->account_id,
|
|
|
|
|
'email' => 'email|required',
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$messages = [
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'ticket_id.exists' => trans("Controllers.ticket_not_exists_error"),
|
|
|
|
|
'ticket_id.required' => trans("Controllers.ticket_field_required_error"),
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
$validator = Validator::make($request->all(), $rules, $messages);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
if ($validator->fails()) {
|
2016-03-11 01:03:33 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'error',
|
2016-05-25 12:20:26 +00:00
|
|
|
'messages' => $validator->messages()->toArray(),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
$ticket_id = $request->get('ticket_id');
|
2016-05-29 17:03:18 +00:00
|
|
|
$ticket_price = 0;
|
2016-05-25 12:20:26 +00:00
|
|
|
$attendee_first_name = $request->get('first_name');
|
2016-03-11 01:03:33 +00:00
|
|
|
$attendee_last_name = $request->get('last_name');
|
|
|
|
|
$attendee_email = $request->get('email');
|
|
|
|
|
$email_attendee = $request->get('email_ticket');
|
2016-06-16 02:06:27 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Create the order
|
|
|
|
|
*/
|
|
|
|
|
$order = new Order();
|
|
|
|
|
$order->first_name = $attendee_first_name;
|
|
|
|
|
$order->last_name = $attendee_last_name;
|
|
|
|
|
$order->email = $attendee_email;
|
|
|
|
|
$order->order_status_id = config('attendize.order_complete');
|
|
|
|
|
$order->amount = $ticket_price;
|
|
|
|
|
$order->account_id = Auth::user()->account_id;
|
|
|
|
|
$order->event_id = $event_id;
|
|
|
|
|
$order->save();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Update qty sold
|
|
|
|
|
*/
|
|
|
|
|
$ticket = Ticket::scope()->find($ticket_id);
|
|
|
|
|
$ticket->increment('quantity_sold');
|
|
|
|
|
$ticket->increment('sales_volume', $ticket_price);
|
|
|
|
|
$ticket->event->increment('sales_volume', $ticket_price);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Insert order item
|
|
|
|
|
*/
|
|
|
|
|
$orderItem = new OrderItem();
|
|
|
|
|
$orderItem->title = $ticket->title;
|
|
|
|
|
$orderItem->quantity = 1;
|
|
|
|
|
$orderItem->order_id = $order->id;
|
|
|
|
|
$orderItem->unit_price = $ticket_price;
|
|
|
|
|
$orderItem->save();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Update the event stats
|
|
|
|
|
*/
|
|
|
|
|
$event_stats = new EventStats();
|
|
|
|
|
$event_stats->updateTicketsSoldCount($event_id, 1);
|
|
|
|
|
$event_stats->updateTicketRevenue($ticket_id, $ticket_price);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Create the attendee
|
|
|
|
|
*/
|
|
|
|
|
$attendee = new Attendee();
|
|
|
|
|
$attendee->first_name = $attendee_first_name;
|
|
|
|
|
$attendee->last_name = $attendee_last_name;
|
|
|
|
|
$attendee->email = $attendee_email;
|
|
|
|
|
$attendee->event_id = $event_id;
|
|
|
|
|
$attendee->order_id = $order->id;
|
|
|
|
|
$attendee->ticket_id = $ticket_id;
|
|
|
|
|
$attendee->account_id = Auth::user()->account_id;
|
2016-05-26 00:40:49 +00:00
|
|
|
$attendee->reference_index = 1;
|
2016-05-25 12:20:26 +00:00
|
|
|
$attendee->save();
|
|
|
|
|
|
2016-05-29 15:21:45 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
if ($email_attendee == '1') {
|
2016-09-06 20:39:27 +00:00
|
|
|
$this->dispatch(new SendAttendeeInvite($attendee));
|
2016-05-25 12:20:26 +00:00
|
|
|
}
|
|
|
|
|
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
session()->flash('message', trans("Controllers.attendee_successfully_invited"));
|
2016-05-25 12:20:26 +00:00
|
|
|
|
|
|
|
|
DB::commit();
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
2016-05-25 12:20:26 +00:00
|
|
|
'redirectUrl' => route('showEventAttendees', [
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
]),
|
|
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
} catch (Exception $e) {
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
Log::error($e);
|
|
|
|
|
DB::rollBack();
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'error' => trans("Controllers.attendee_exception")
|
2016-05-25 12:20:26 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2016-05-25 12:20:26 +00:00
|
|
|
|
|
|
|
|
/**
|
2016-04-20 16:52:07 +00:00
|
|
|
* Show the 'Import Attendee' modal
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return string|View
|
|
|
|
|
*/
|
|
|
|
|
public function showImportAttendee(Request $request, $event_id)
|
|
|
|
|
{
|
|
|
|
|
$event = Event::scope()->find($event_id);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If there are no tickets then we can't create an attendee
|
|
|
|
|
* @todo This is a bit hackish
|
|
|
|
|
*/
|
|
|
|
|
if ($event->tickets->count() === 0) {
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
return '<script>showMessage("'.trans("Controllers.addInviteError").'");</script>';
|
2016-04-20 16:52:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return view('ManageEvent.Modals.ImportAttendee', [
|
2016-12-01 22:11:34 +00:00
|
|
|
'event' => $event,
|
2016-05-25 12:20:26 +00:00
|
|
|
'tickets' => $event->tickets()->lists('title', 'id'),
|
2016-04-20 16:52:07 +00:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Import attendees
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function postImportAttendee(Request $request, $event_id)
|
|
|
|
|
{
|
|
|
|
|
$rules = [
|
2016-12-01 22:11:34 +00:00
|
|
|
'ticket_id' => 'required|exists:tickets,id,account_id,' . \Auth::user()->account_id,
|
2016-05-25 12:20:26 +00:00
|
|
|
'attendees_list' => 'required|mimes:csv,txt|max:5000|',
|
2016-04-20 16:52:07 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$messages = [
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'ticket_id.exists' => trans("Controllers.ticket_not_exists_error"),
|
2016-04-20 16:52:07 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$validator = Validator::make($request->all(), $rules, $messages);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'error',
|
2016-05-25 12:20:26 +00:00
|
|
|
'messages' => $validator->messages()->toArray(),
|
2016-04-20 16:52:07 +00:00
|
|
|
]);
|
2016-05-25 12:20:26 +00:00
|
|
|
|
2016-04-20 16:52:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ticket_id = $request->get('ticket_id');
|
2016-05-29 17:03:18 +00:00
|
|
|
$ticket_price = 0;
|
2016-04-20 16:52:07 +00:00
|
|
|
$email_attendee = $request->get('email_ticket');
|
2016-05-25 12:20:26 +00:00
|
|
|
$num_added = 0;
|
|
|
|
|
if ($request->file('attendees_list')) {
|
|
|
|
|
|
|
|
|
|
$the_file = Excel::load($request->file('attendees_list')->getRealPath(), function ($reader) {
|
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
|
|
// Loop through
|
|
|
|
|
foreach ($the_file as $rows) {
|
|
|
|
|
if (!empty($rows['first_name']) && !empty($rows['last_name']) && !empty($rows['email'])) {
|
|
|
|
|
$num_added++;
|
|
|
|
|
$attendee_first_name = $rows['first_name'];
|
|
|
|
|
$attendee_last_name = $rows['last_name'];
|
|
|
|
|
$attendee_email = $rows['email'];
|
|
|
|
|
|
|
|
|
|
error_log($ticket_id . ' ' . $ticket_price . ' ' . $email_attendee);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the order
|
|
|
|
|
*/
|
|
|
|
|
$order = new Order();
|
|
|
|
|
$order->first_name = $attendee_first_name;
|
|
|
|
|
$order->last_name = $attendee_last_name;
|
|
|
|
|
$order->email = $attendee_email;
|
|
|
|
|
$order->order_status_id = config('attendize.order_complete');
|
|
|
|
|
$order->amount = $ticket_price;
|
|
|
|
|
$order->account_id = Auth::user()->account_id;
|
|
|
|
|
$order->event_id = $event_id;
|
|
|
|
|
$order->save();
|
2016-05-29 17:03:18 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
/**
|
|
|
|
|
* Update qty sold
|
|
|
|
|
*/
|
|
|
|
|
$ticket = Ticket::scope()->find($ticket_id);
|
|
|
|
|
$ticket->increment('quantity_sold');
|
|
|
|
|
$ticket->increment('sales_volume', $ticket_price);
|
|
|
|
|
$ticket->event->increment('sales_volume', $ticket_price);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insert order item
|
|
|
|
|
*/
|
|
|
|
|
$orderItem = new OrderItem();
|
|
|
|
|
$orderItem->title = $ticket->title;
|
|
|
|
|
$orderItem->quantity = 1;
|
|
|
|
|
$orderItem->order_id = $order->id;
|
|
|
|
|
$orderItem->unit_price = $ticket_price;
|
|
|
|
|
$orderItem->save();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update the event stats
|
|
|
|
|
*/
|
|
|
|
|
$event_stats = new EventStats();
|
|
|
|
|
$event_stats->updateTicketsSoldCount($event_id, 1);
|
|
|
|
|
$event_stats->updateTicketRevenue($ticket_id, $ticket_price);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the attendee
|
|
|
|
|
*/
|
|
|
|
|
$attendee = new Attendee();
|
|
|
|
|
$attendee->first_name = $attendee_first_name;
|
|
|
|
|
$attendee->last_name = $attendee_last_name;
|
|
|
|
|
$attendee->email = $attendee_email;
|
|
|
|
|
$attendee->event_id = $event_id;
|
|
|
|
|
$attendee->order_id = $order->id;
|
|
|
|
|
$attendee->ticket_id = $ticket_id;
|
|
|
|
|
$attendee->account_id = Auth::user()->account_id;
|
2016-05-26 00:40:49 +00:00
|
|
|
$attendee->reference_index = 1;
|
2016-05-25 12:20:26 +00:00
|
|
|
$attendee->save();
|
|
|
|
|
|
|
|
|
|
if ($email_attendee == '1') {
|
2016-06-15 10:14:27 +00:00
|
|
|
$this->dispatch(new SendAttendeeInvite($attendee));
|
2016-05-25 12:20:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-04-20 16:52:07 +00:00
|
|
|
}
|
2016-05-25 12:20:26 +00:00
|
|
|
|
2016-05-29 17:03:18 +00:00
|
|
|
session()->flash('message', $num_added . ' Attendees Successfully Invited');
|
2016-04-20 16:52:07 +00:00
|
|
|
|
|
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
|
|
|
|
'id' => $attendee->id,
|
2016-04-20 16:52:07 +00:00
|
|
|
'redirectUrl' => route('showEventAttendees', [
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
]),
|
|
|
|
|
]);
|
|
|
|
|
}
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Show the printable attendee list
|
|
|
|
|
*
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return View
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function showPrintAttendees($event_id)
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$data['event'] = Event::scope()->find($event_id);
|
|
|
|
|
$data['attendees'] = $data['event']->attendees()->withoutCancelled()->orderBy('first_name')->get();
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return view('ManageEvent.PrintAttendees', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Show the 'Message Attendee' modal
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return View
|
|
|
|
|
*/
|
|
|
|
|
public function showMessageAttendee(Request $request, $attendee_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
'attendee' => $attendee,
|
2016-12-01 22:11:34 +00:00
|
|
|
'event' => $attendee->event,
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return view('ManageEvent.Modals.MessageAttendee', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Send a message to an attendee
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function postMessageAttendee(Request $request, $attendee_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$rules = [
|
|
|
|
|
'subject' => 'required',
|
2016-03-05 00:18:10 +00:00
|
|
|
'message' => 'required',
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
$validator = Validator::make($request->all(), $rules);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
if ($validator->fails()) {
|
2016-03-11 01:03:33 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'error',
|
2016-05-25 12:20:26 +00:00
|
|
|
'messages' => $validator->messages()->toArray(),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
|
|
|
|
$data = [
|
2016-12-01 22:11:34 +00:00
|
|
|
'attendee' => $attendee,
|
2016-03-11 01:03:33 +00:00
|
|
|
'message_content' => $request->get('message'),
|
2016-12-01 22:11:34 +00:00
|
|
|
'subject' => $request->get('subject'),
|
|
|
|
|
'event' => $attendee->event,
|
|
|
|
|
'email_logo' => $attendee->event->organiser->full_logo_path,
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-06-15 10:14:27 +00:00
|
|
|
//@todo move this to the SendAttendeeMessage Job
|
2016-11-15 13:26:37 +00:00
|
|
|
Mail::send('Emails.messageReceived', $data, function ($message) use ($attendee, $data) {
|
2016-02-29 15:59:36 +00:00
|
|
|
$message->to($attendee->email, $attendee->full_name)
|
2016-05-25 12:20:26 +00:00
|
|
|
->from(config('attendize.outgoing_email_noreply'), $attendee->event->organiser->name)
|
|
|
|
|
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
|
|
|
|
->subject($data['subject']);
|
2016-02-29 15:59:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Could bcc in the above? */
|
2016-03-11 15:51:39 +00:00
|
|
|
if ($request->get('send_copy') == '1') {
|
2016-11-15 13:26:37 +00:00
|
|
|
Mail::send('Emails.messageReceived', $data, function ($message) use ($attendee, $data) {
|
2016-02-29 15:59:36 +00:00
|
|
|
$message->to($attendee->event->organiser->email, $attendee->event->organiser->name)
|
2016-05-25 12:20:26 +00:00
|
|
|
->from(config('attendize.outgoing_email_noreply'), $attendee->event->organiser->name)
|
|
|
|
|
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
->subject($data['subject'] . trans("Email.organiser_copy"));
|
2016-02-29 15:59:36 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'message' => trans("Controllers.message_successfully_sent"),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Shows the 'Message Attendees' modal
|
|
|
|
|
*
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return View
|
|
|
|
|
*/
|
2016-03-11 15:51:39 +00:00
|
|
|
public function showMessageAttendees(Request $request, $event_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$data = [
|
2016-12-01 22:11:34 +00:00
|
|
|
'event' => Event::scope()->find($event_id),
|
2016-05-25 12:20:26 +00:00
|
|
|
'tickets' => Event::scope()->find($event_id)->tickets()->lists('title', 'id')->toArray(),
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return view('ManageEvent.Modals.MessageAttendees', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Send a message to attendees
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function postMessageAttendees(Request $request, $event_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$rules = [
|
2016-12-01 22:11:34 +00:00
|
|
|
'subject' => 'required',
|
|
|
|
|
'message' => 'required',
|
2016-03-05 00:18:10 +00:00
|
|
|
'recipients' => 'required',
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
$validator = Validator::make($request->all(), $rules);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
if ($validator->fails()) {
|
2016-06-16 02:12:44 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'error',
|
2016-05-25 12:20:26 +00:00
|
|
|
'messages' => $validator->messages()->toArray(),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$message = Message::createNew();
|
2016-03-11 01:03:33 +00:00
|
|
|
$message->message = $request->get('message');
|
|
|
|
|
$message->subject = $request->get('subject');
|
2016-06-15 10:14:27 +00:00
|
|
|
$message->recipients = ($request->get('recipients') == 'all') ? 'all' : $request->get('recipients');
|
2016-02-29 15:59:36 +00:00
|
|
|
$message->event_id = $event_id;
|
|
|
|
|
$message->save();
|
|
|
|
|
|
2016-06-15 10:14:27 +00:00
|
|
|
/*
|
|
|
|
|
* Queue the emails
|
|
|
|
|
*/
|
|
|
|
|
$this->dispatch(new SendMessageToAttendees($message));
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
2016-03-11 04:25:15 +00:00
|
|
|
'message' => 'Message Successfully Sent',
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-29 15:21:45 +00:00
|
|
|
/**
|
|
|
|
|
* Downloads the ticket of an attendee as PDF
|
|
|
|
|
*
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
*/
|
|
|
|
|
public function showExportTicket($event_id, $attendee_id)
|
|
|
|
|
{
|
|
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
|
|
|
|
Config::set('queue.default', 'sync');
|
|
|
|
|
Log::info("*********");
|
|
|
|
|
Log::info($attendee_id);
|
|
|
|
|
Log::info($attendee);
|
|
|
|
|
|
|
|
|
|
|
2016-09-06 20:39:27 +00:00
|
|
|
$this->dispatch(new GenerateTicket($attendee->order->order_reference . "-" . $attendee->reference_index));
|
2016-05-29 15:21:45 +00:00
|
|
|
|
2016-09-06 20:39:27 +00:00
|
|
|
$pdf_file_name = $attendee->order->order_reference . '-' . $attendee->reference_index;
|
|
|
|
|
$pdf_file_path = public_path(config('attendize.event_pdf_tickets_path')) . '/' . $pdf_file_name;
|
|
|
|
|
$pdf_file = $pdf_file_path . '.pdf';
|
2016-05-29 15:21:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->download($pdf_file);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Downloads an export of attendees
|
|
|
|
|
*
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @param string $export_as (xlsx, xls, csv, html)
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function showExportAttendees($event_id, $export_as = 'xls')
|
|
|
|
|
{
|
2016-04-05 10:31:30 +00:00
|
|
|
|
2016-05-25 12:20:26 +00:00
|
|
|
Excel::create('attendees-as-of-' . date('d-m-Y-g.i.a'), function ($excel) use ($event_id) {
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
$excel->setTitle('Attendees List');
|
|
|
|
|
|
|
|
|
|
// Chain the setters
|
2016-03-04 23:27:13 +00:00
|
|
|
$excel->setCreator(config('attendize.app_name'))
|
2016-05-25 12:20:26 +00:00
|
|
|
->setCompany(config('attendize.app_name'));
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
$excel->sheet('attendees_sheet_1', function ($sheet) use ($event_id) {
|
2016-05-25 12:20:26 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
DB::connection()->setFetchMode(\PDO::FETCH_ASSOC);
|
|
|
|
|
$data = DB::table('attendees')
|
|
|
|
|
->where('attendees.event_id', '=', $event_id)
|
|
|
|
|
->where('attendees.is_cancelled', '=', 0)
|
2016-05-25 12:20:26 +00:00
|
|
|
->where('attendees.account_id', '=', Auth::user()->account_id)
|
|
|
|
|
->join('events', 'events.id', '=', 'attendees.event_id')
|
|
|
|
|
->join('orders', 'orders.id', '=', 'attendees.order_id')
|
|
|
|
|
->join('tickets', 'tickets.id', '=', 'attendees.ticket_id')
|
|
|
|
|
->select([
|
|
|
|
|
'attendees.first_name',
|
|
|
|
|
'attendees.last_name',
|
|
|
|
|
'attendees.email',
|
|
|
|
|
'orders.order_reference',
|
|
|
|
|
'tickets.title',
|
|
|
|
|
'orders.created_at',
|
|
|
|
|
DB::raw("(CASE WHEN attendees.has_arrived THEN 'YES' ELSE 'NO' END) AS has_arrived"),
|
|
|
|
|
'attendees.arrival_time',
|
|
|
|
|
])->get();
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
$sheet->fromArray($data);
|
2016-03-05 00:18:10 +00:00
|
|
|
$sheet->row(1, [
|
2016-05-25 12:20:26 +00:00
|
|
|
'First Name',
|
|
|
|
|
'Last Name',
|
|
|
|
|
'Email',
|
|
|
|
|
'Order Reference',
|
|
|
|
|
'Ticket Type',
|
|
|
|
|
'Purchase Date',
|
|
|
|
|
'Has Arrived',
|
|
|
|
|
'Arrival Time',
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
// Set gray background on first row
|
2016-03-05 00:18:10 +00:00
|
|
|
$sheet->row(1, function ($row) {
|
2016-02-29 15:59:36 +00:00
|
|
|
$row->setBackground('#f5f5f5');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})->export($export_as);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Show the 'Edit Attendee' modal
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return View
|
|
|
|
|
*/
|
|
|
|
|
public function showEditAttendee(Request $request, $event_id, $attendee_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
'attendee' => $attendee,
|
2016-12-01 22:11:34 +00:00
|
|
|
'event' => $attendee->event,
|
|
|
|
|
'tickets' => $attendee->event->tickets->lists('title', 'id'),
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return view('ManageEvent.Modals.EditAttendee', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Updates an attendee
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function postEditAttendee(Request $request, $event_id, $attendee_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$rules = [
|
|
|
|
|
'first_name' => 'required',
|
2016-12-01 22:11:34 +00:00
|
|
|
'ticket_id' => 'required|exists:tickets,id,account_id,' . Auth::user()->account_id,
|
|
|
|
|
'email' => 'required|email',
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$messages = [
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'ticket_id.exists' => trans("Controllers.ticket_not_exists_error"),
|
|
|
|
|
'ticket_id.required' => trans("Controllers.ticket_field_required_error"),
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
$validator = Validator::make($request->all(), $rules, $messages);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
if ($validator->fails()) {
|
2016-03-11 01:03:33 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'error',
|
2016-05-25 12:20:26 +00:00
|
|
|
'messages' => $validator->messages()->toArray(),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
2016-03-11 01:03:33 +00:00
|
|
|
$attendee->update($request->all());
|
2016-02-29 15:59:36 +00:00
|
|
|
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
session()->flash('message',trans("Controllers.successfully_updated_attendee"));
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
|
|
|
|
'id' => $attendee->id,
|
2016-03-11 04:25:15 +00:00
|
|
|
'redirectUrl' => '',
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Shows the 'Cancel Attendee' modal
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return View
|
|
|
|
|
*/
|
|
|
|
|
public function showCancelAttendee(Request $request, $event_id, $attendee_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
'attendee' => $attendee,
|
2016-12-01 22:11:34 +00:00
|
|
|
'event' => $attendee->event,
|
|
|
|
|
'tickets' => $attendee->event->tickets->lists('title', 'id'),
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return view('ManageEvent.Modals.CancelAttendee', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
/**
|
|
|
|
|
* Cancels an attendee
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function postCancelAttendee(Request $request, $event_id, $attendee_id)
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
2016-11-26 21:38:54 +00:00
|
|
|
$error_message = false; //Prevent "variable doesn't exist" error message
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-07 17:37:16 +00:00
|
|
|
if ($attendee->is_cancelled) {
|
2016-06-16 02:12:44 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'message' => trans("Controllers.attendee_already_cancelled"),
|
2016-03-06 17:59:19 +00:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
$attendee->ticket->decrement('quantity_sold');
|
2016-11-28 12:19:14 +00:00
|
|
|
$attendee->ticket->decrement('sales_volume', $attendee->ticket->price);
|
|
|
|
|
$attendee->ticket->event->decrement('sales_volume', $attendee->ticket->price);
|
2016-02-29 15:59:36 +00:00
|
|
|
$attendee->is_cancelled = 1;
|
|
|
|
|
$attendee->save();
|
|
|
|
|
|
2016-11-28 12:19:14 +00:00
|
|
|
$eventStats = EventStats::where('event_id', $attendee->event_id)->where('date', $attendee->created_at->format('Y-m-d'))->first();
|
|
|
|
|
if($eventStats){
|
|
|
|
|
$eventStats->decrement('tickets_sold', 1);
|
|
|
|
|
$eventStats->decrement('sales_volume', $attendee->ticket->price);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
$data = [
|
2016-12-01 22:11:34 +00:00
|
|
|
'attendee' => $attendee,
|
2016-03-06 17:59:19 +00:00
|
|
|
'email_logo' => $attendee->event->organiser->full_logo_path,
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
if ($request->get('notify_attendee') == '1') {
|
2016-03-05 00:18:10 +00:00
|
|
|
Mail::send('Emails.notifyCancelledAttendee', $data, function ($message) use ($attendee) {
|
2016-02-29 15:59:36 +00:00
|
|
|
$message->to($attendee->email, $attendee->full_name)
|
2016-05-25 12:20:26 +00:00
|
|
|
->from(config('attendize.outgoing_email_noreply'), $attendee->event->organiser->name)
|
|
|
|
|
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
->subject(trans("Email.your_ticket_cancelled"));
|
2016-02-29 15:59:36 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-06 20:39:27 +00:00
|
|
|
if ($request->get('refund_attendee') == '1') {
|
2016-06-14 12:09:55 +00:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// This does not account for an increased/decreased ticket price
|
|
|
|
|
// after the original purchase.
|
|
|
|
|
$refund_amount = $attendee->ticket->price;
|
|
|
|
|
$data['refund_amount'] = $refund_amount;
|
|
|
|
|
|
|
|
|
|
$gateway = Omnipay::create($attendee->order->payment_gateway->name);
|
|
|
|
|
|
|
|
|
|
// Only works for stripe
|
|
|
|
|
$gateway->initialize($attendee->order->account->getGateway($attendee->order->payment_gateway->id)->config);
|
|
|
|
|
|
|
|
|
|
$request = $gateway->refund([
|
|
|
|
|
'transactionReference' => $attendee->order->transaction_id,
|
2016-12-01 22:11:34 +00:00
|
|
|
'amount' => $refund_amount,
|
2016-06-14 12:09:55 +00:00
|
|
|
'refundApplicationFee' => false,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $request->send();
|
|
|
|
|
|
|
|
|
|
if ($response->isSuccessful()) {
|
|
|
|
|
|
|
|
|
|
// Update the attendee and their order
|
|
|
|
|
$attendee->is_refunded = 1;
|
|
|
|
|
$attendee->order->is_partially_refunded = 1;
|
|
|
|
|
$attendee->order->amount_refunded += $refund_amount;
|
|
|
|
|
|
|
|
|
|
$attendee->order->save();
|
|
|
|
|
$attendee->save();
|
|
|
|
|
|
|
|
|
|
// Let the user know that they have received a refund.
|
|
|
|
|
Mail::send('Emails.notifyRefundedAttendee', $data, function ($message) use ($attendee) {
|
|
|
|
|
$message->to($attendee->email, $attendee->full_name)
|
|
|
|
|
->from(config('attendize.outgoing_email_noreply'), $attendee->event->organiser->name)
|
|
|
|
|
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
->subject(trans("Email.refund_from_name", ["name"=>$attendee->event->organiser->name]));
|
2016-06-14 12:09:55 +00:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$error_message = $response->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
\Log::error($e);
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
$error_message = trans("Controllers.refund_exception");
|
2016-06-14 12:09:55 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($error_message) {
|
|
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'error',
|
2016-06-14 12:09:55 +00:00
|
|
|
'message' => $error_message,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
session()->flash('message', trans("Controllers.successfully_cancelled_attendee"));
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-11 01:03:33 +00:00
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
|
|
|
|
'id' => $attendee->id,
|
2016-03-11 04:25:15 +00:00
|
|
|
'redirectUrl' => '',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the 'Message Attendee' modal
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return View
|
|
|
|
|
*/
|
|
|
|
|
public function showResendTicketToAttendee(Request $request, $attendee_id)
|
|
|
|
|
{
|
|
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
'attendee' => $attendee,
|
2016-12-01 22:11:34 +00:00
|
|
|
'event' => $attendee->event,
|
2016-03-11 04:25:15 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return view('ManageEvent.Modals.ResendTicketToAttendee', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Send a message to an attendee
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function postResendTicketToAttendee(Request $request, $attendee_id)
|
|
|
|
|
{
|
|
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
2016-06-15 10:14:27 +00:00
|
|
|
$this->dispatch(new SendAttendeeTicket($attendee));
|
2016-03-11 04:25:15 +00:00
|
|
|
|
|
|
|
|
return response()->json([
|
2016-12-01 22:11:34 +00:00
|
|
|
'status' => 'success',
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'message' => trans("Controllers.ticket_successfully_resent"),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2016-06-15 12:34:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show an attendee ticket
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $attendee_id
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function showAttendeeTicket(Request $request, $attendee_id)
|
|
|
|
|
{
|
|
|
|
|
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
|
|
|
|
|
|
|
|
|
$data = [
|
2016-12-01 22:11:34 +00:00
|
|
|
'order' => $attendee->order,
|
|
|
|
|
'event' => $attendee->event,
|
|
|
|
|
'tickets' => $attendee->ticket,
|
2016-06-15 12:34:12 +00:00
|
|
|
'attendees' => [$attendee],
|
2016-12-01 22:11:34 +00:00
|
|
|
'css' => file_get_contents(public_path('assets/stylesheet/ticket.css')),
|
|
|
|
|
'image' => base64_encode(file_get_contents(public_path($attendee->event->organiser->full_logo_path))),
|
2016-06-15 12:34:12 +00:00
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ($request->get('download') == '1') {
|
2016-12-01 22:11:34 +00:00
|
|
|
return PDF::html('Public.ViewEvent.Partials.PDFTicket', $data, 'Tickets');
|
2016-06-15 12:34:12 +00:00
|
|
|
}
|
2016-12-01 22:11:34 +00:00
|
|
|
return view('Public.ViewEvent.Partials.PDFTicket', $data);
|
2016-06-15 12:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|