Adding ability to remove ninja logo

This commit is contained in:
Hillel Coren 2014-04-04 12:24:56 +03:00
parent 8fdb122224
commit 5b323e04d7
6 changed files with 79 additions and 5 deletions

1
.gitignore vendored
View File

@ -4,7 +4,6 @@
/app/config/ubuntu
/app/config/packages/anahkiasen/rocketeer/
/app/storage
/public/logo
/public/build
/public/vendor
/bootstrap/compiled.php

View File

@ -70,9 +70,73 @@ class AccountController extends \BaseController {
$account = Auth::user()->account;
$ninjaAccount = $this->getNinjaAccount();
$ninjaClient = $this->getNinjaClient($ninjaAccount);
}
private function getNinjaAccount()
{
$account = Account::whereAccountKey(NINJA_ACCOUNT_KEY)->first();
if ($account)
{
return $account;
}
else
{
$account = new Account();
$account->name = 'Invoice Ninja';
$account->work_email = 'contact@invoiceninja.com';
$account->work_phone = '(800) 763-1948';
$account->account_key = NINJA_ACCOUNT_KEY;
$account->save();
$random = str_random(RANDOM_KEY_LENGTH);
$user = new User();
$user->email = 'contact@invoiceninja.com';
$user->password = $random;
$user->password_confirmation = $random;
$user->username = $random;
$user->notify_sent = false;
$user->notify_paid = false;
$account->users()->save($user);
}
return $account;
}
private function getNinjaClient($ninjaAccount)
{
$client = Client::whereAccountId($ninjaAccount->id)->wherePublicId(Auth::user()->account_id)->first();
if ($client)
{
return $client;
}
else
{
$client = new Client;
$client->public_id = Auth::user()->account_id;
$client->user_id = $ninjaAccount->users()->first()->id;
foreach (['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country_id', 'work_phone'] as $field)
{
$client->$field = Auth::user()->account->$field;
}
$ninjaAccount->clients()->save($client);
$contact = new Contact;
$contact->user_id = $ninjaAccount->users()->first()->id;
$contact->is_primary = true;
foreach (['first_name', 'last_name', 'email', 'phone'] as $field)
{
$contact->$field = Auth::user()->$field;
}
$client->contacts()->save($contact);
}
}
public function setTrashVisible($entityType, $visible)

View File

@ -14,7 +14,7 @@ class AddProPlan extends Migration {
{
Schema::table('accounts', function($table)
{
$table->timestamp('pro_plan_paid');
$table->date('pro_plan_paid');
});
}

View File

@ -111,7 +111,18 @@ class User extends ConfideUser implements UserInterface, RemindableInterface
return false;
}
return $this->account->pro_plan_paid;
$datePaid = $this->account->pro_plan_paid;
if (!$datePaid || $datePaid == '0000-00-00')
{
return false;
}
$today = new DateTime('now');
$datePaid = DateTime::createFromFormat('Y-m-d', $datePaid);
$interval = $today->diff($datePaid);
return $interval->y == 0;
}
public function showGreyBackground()

View File

@ -1,6 +1,5 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
@ -240,6 +239,7 @@ define('DEFAULT_QUERY_CACHE', 120); // minutes
define('DEFUALT_LOCALE', 'en');
define('GATEWAY_PAYPAL_EXPRESS', 17);
define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
if (Auth::check() && !Session::has(SESSION_TIMEZONE))

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB