Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file modified .bowerrc
100644 → 100755
Empty file.
Empty file modified .dockerignore
100644 → 100755
Empty file.
34 changes: 20 additions & 14 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
APP_ENV=production
APP_DEBUG=false
APP_ENV=dev
APP_DEBUG=true
APP_URL=
APP_CIPHER=AES-256-CBC
APP_KEY=
APP_TIMEZONE=

DB_TYPE=mysql
DB_TYPE=pgsql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=attendize
DB_USERNAME=attendize
DB_PASSWORD=attendize

DEFAULT_DATEPICKER_SEPERATOR="-"
DEFAULT_DATEPICKER_FORMAT="yyyy-MM-dd HH:mm"
DEFAULT_DATETIME_FORMAT="Y-m-d H:i"

# https://github.com/NitMedia/wkhtml2pdf#driver-types
WKHTML2PDF_BIN_FILE=wkhtmltopdf-amd64

MAIL_DRIVER=smtp
MAIL_PORT=25
MAIL_PORT=2525
MAIL_ENCRYPTION=
MAIL_HOST=maildev
MAIL_FROM_ADDRESS=testing@attendize.com
MAIL_FROM_NAME=testing_service
MAIL_HOST=smtp.mailtrap.io
MAIL_FROM_ADDRESS=events@equisfinancial.com
MAIL_FROM_NAME=quisfinancial
MAIL_PASSWORD=
MAIL_USERNAME=

CORP_EMAIL=testing@xyb.io
GOOGLE_ANALYTICS_ID=
GOOGLE_MAPS_GEOCODING_KEY=

TWITTER_WIDGET_ID=

LOG=errorlog

CACHE_DRIVER=array

INTERCOM_APP_ID=
INTERCOM_KEY=

BNS_URL=https://dev.equis.xyz/bns
CRM_URL=https://crm.stage.equis.xyz

ROLLBAR_TOKEN=

CACHE_DRIVER=redis
Empty file modified .gitattributes
100644 → 100755
Empty file.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
/node_modules
.env
.idea
installed
/.settings/
/.project
/.buildpath
/composer.phar
_ide_helper.php
*.swp

# Do not include backup lang files
resources/lang/*/[a-zA-Z]*20[0-9][0-9][0-1][0-9][0-3][0-9]_[0-2][0-9][0-5][0-9][0-5][0-9].php
.php_cs.cache
Empty file modified .htaccess
100644 → 100755
Empty file.
18 changes: 0 additions & 18 deletions Dockerfile-composer

This file was deleted.

6 changes: 0 additions & 6 deletions Dockerfile-nginx
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
FROM nginx:latest
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN apt-get update && apt-get install openssl
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj "/C=GB/ST=London/L=London/O=NA/CN=localhost"
RUN openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
RUN mkdir /etc/nginx/snippets
COPY self-signed.conf /etc/nginx/snippets/self-signed.conf
COPY ssl-params.conf /etc/nginx/snippets/ssl-params.conf
6 changes: 3 additions & 3 deletions Dockerfile-php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM php:7.1.20-fpm
FROM php:7.0-fpm
RUN apt-get update && apt-get install -y \
libpq-dev \
libmcrypt-dev \
libpng-dev \
libpng12-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libxrender1 \
libfontconfig \
libxext-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) pdo_mysql mysqli mcrypt gd zip
&& docker-php-ext-install -j$(nproc) pdo_pgsql pgsql mcrypt gd zip
WORKDIR /usr/share/nginx/html/attendize
4 changes: 2 additions & 2 deletions Gruntfile.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function (grunt) {
'./public/vendor/humane-js/humane.js',
'./public/vendor/RRSSB/js/rrssb.js',
'./public/vendor/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.js',
'./public/vendor/datetimepicker/dist/DateTimePicker.js',
'./public/vendor/curioussolutions-datetimepicker/dist/DateTimePicker.js',
'./public/vendor/jquery-minicolors/jquery.minicolors.min.js',
'./public/assets/javascript/app.js'
],
Expand Down Expand Up @@ -87,4 +87,4 @@ module.exports = function (grunt) {
grunt.registerTask('js', ['concat']);
grunt.registerTask('styles', ['concat']);
grunt.registerTask('minify', ['uglify']);
};
};
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified VERSION
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions _build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

composer dumpautoload
composer install

php artisan migrate
npm install
grunt

php artisan attendize:install
226 changes: 226 additions & 0 deletions app/Console/Commands/CRMMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
<?php

namespace App\Console\Commands;

use App\Models\Account;
use App\Models\Timezone;
use App\Models\User;
use App\Models\Role;
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\Event;
use App\Models\EventStats;
use App\Models\Attendee;
use DB;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use PhpSpec\Exception\Exception;

class CRMMigration extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'attendize:crm_migration';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Migrate CRM event data';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
try {
DB::connection();
} catch (\Exception $e) {
$this->error('Unable to connect to database.');
$this->error('Please fill valid database credentials into .env and rerun this command.');
return;
}

$this->comment('--------------------');
$this->comment('Attempting to migrate CRM event data');
$this->comment('--------------------');

$this->comment('Migrating users');

$account = Account::take(1)->get();
$account_id = $account[0]->id;
try {
DB::beginTransaction();
$content = file_get_contents(base_path('crm_migration/users.json'));
$users = json_decode($content, true);
$unmigrated_users = [];
foreach ($users as $data) {
$user = User::where('email', $data['email'])->first();
if (!$user) {
if ($data['isadmin'] == '1') {
$role = 'admin';
} else if ($data['isagent'] == '1') {
$role = 'agent';
} else {
array_push($unmigrated_users, $data);
continue;
}

$userRole = Role::where('name', $role)->first();
$user = new User();
$user->email = $data['email'];
$user->agentcode = $data['agentcode'];
$user->first_name = $data['firstname'];
$user->last_name = $data['lastname'];
$user->password = $data['password'];
$user->phone = $data['phone'];
$user->account_id = $account_id;
$user->save();
$user->attachRole($userRole);
}
}

if(count($unmigrated_users) > 0) {
$this->comment('There are some unmigrated users. Check this file: '
. base_path('crm_migration/unmigrated_users.json'));
file_put_contents(base_path('crm_migration/unmigrated_users.json'), json_encode($unmigrated_users));
}

$this->comment('User migration succeed.');

$this->comment('--------------------');

DB::commit();
} catch (\Exception $e) {
$this->error($e);
DB::rollBack();
return;
}

$this->comment('Migrating orders and tickets');

try {
$content = file_get_contents(base_path('crm_migration/crm_98_event.json'));
$orders = json_decode($content, true);
$event = Event::where('title', '=', '2018 National Winter Convention')->first();
if(!$event) {
$this->error('Can not find "2018 National Winter Convention" event.');
return;
}

$ticket = $event->tickets()->where('title', '=', 'GEN')->first();
if(!$ticket) {
$this->error('Can not find GEN ticket.');
return;
}

DB::beginTransaction();
$unmigrated_tickets = [];

foreach($orders as $data) {
$user = User::where('email', '=', $data['email'])->first();
if(!$user) {
array_push($unmigrated_tickets, $data);
continue;
}

$order = new Order();
$order->payment_gateway_id = 2;
$order->first_name = $user->first_name;
$order->last_name = $user->last_name;
$order->email = $data['email'];
$order->order_status_id = 1;
$order->amount = $data['paymentamount'];
$order->booking_fee = 0;
$order->organiser_booking_fee = 0;
$order->discount = 0;
$order->account_id = $account_id;
$order->event_id = $event->id;
$order->is_payment_received = 1;
$order->created_at = $data['created_at'];

$order->save();

/*
* Update the event sales volume
*/
$event->increment('sales_volume', $order->amount);

/*
* Update the event stats
*/

$event_stats = EventStats::firstOrNew([
'event_id' => $event->id,
'date' => DB::raw('CURRENT_DATE'),
]);

$event_stats->increment('tickets_sold', $data['noofseats']);
$event_stats->increment('sales_volume', $order->amount);

$event_stats->save();


/*
* Insert order items (for use in generating invoices)
*/
$orderItem = new OrderItem();
$orderItem->title = $ticket->title;
$orderItem->quantity = $data['noofseats'];
$orderItem->order_id = $order->id;
$orderItem->unit_price = $data['paymentamount'] / $data['noofseats'];
$orderItem->save();

/*
* Update ticket info
*/

$ticket->increment('quantity_sold', $data['noofseats']);

$ticket->increment('sales_volume', $data['paymentamount']);


/*
* Add the attendees
*/

$attendee_increment = 1;
foreach($data['tickets'] as $t) {
$attendee = new Attendee();
$attendee->first_name = $user->first_name;
$attendee->last_name = $user->last_name;
$attendee->email = $data['email'];
$attendee->event_id = $event->id;
$attendee->order_id = $order->id;
$attendee->ticket_id = $ticket->id;
$attendee->account_id = $account_id;
$attendee->reference_index = $attendee_increment;
$attendee->purchased_by = $user->id;
$attendee->assigned_to = $t['assigned_to'];
$attendee->save();
$attendee_increment++;
}

}

if(count($unmigrated_tickets) > 0) {
$this->comment('There are some unmigrated tickets. Check this file: '
. base_path('crm_migration/unmigrated_tickets.json'));
file_put_contents(base_path('crm_migration/unmigrated_tickets.json'), json_encode($unmigrated_tickets));
}
DB::commit();
} catch (\Exception $e) {
$this->error($e);
DB::rollBack();
return;
}

$this->comment('Success!');
}
}
3 changes: 3 additions & 0 deletions app/Console/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Account;
use App\Models\Timezone;
use App\Models\User;
use App\Models\Role;
use DB;
use Hash;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -99,6 +100,8 @@ public function handle()
$user_data['is_parent'] = 1;
$user_data['is_registered'] = 1;
$user = User::create($user_data);
$ownerRole = Role::where('name', 'owner')->first();
$user->attachRole($ownerRole);

DB::commit();
$this->info('Admin User Successfully Created');
Expand Down
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Kernel extends ConsoleKernel
protected $commands = [
Commands\Install::class,
Commands\CreateDatabase::class,
Commands\CRMMigration::class,
];

/**
Expand Down
Loading