diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 2cd63747f874..348e5bbc75a0 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -703,18 +703,27 @@ class AccountController extends \BaseController $user->phone = trim(Input::get('phone')); $user->save(); } - + /* Logo image file */ if ($file = Input::file('logo')) { $path = Input::file('logo')->getRealPath(); File::delete('logo/'.$account->account_key.'.jpg'); - $image = Image::make($path)->resize(200, 120, true, false); - Image::canvas($image->width, $image->height, '#FFFFFF')->insert($image)->save($account->getLogoPath()); + $image = Image::make($path); + $mimeType = $file->getMimeType(); + + if ($image->width == 200 && $mimeType == 'image/jpeg') { + $file->move('logo/', $account->account_key . '.jpg'); + } else { + $image->resize(200, 120, true, false); + Image::canvas($image->width, $image->height, '#FFFFFF')->insert($image)->save($account->getLogoPath()); + } + + //$image = Image::make($path)->resize(200, 120, true, false); + //Image::canvas($image->width, $image->height, '#FFFFFF')->insert($image)->save($account->getLogoPath()); } Event::fire('user.refresh'); - Session::flash('message', trans('texts.updated_settings')); return Redirect::to('company/details'); diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php index 125e3bd72948..ba8797bb1d00 100755 --- a/app/controllers/ActivityController.php +++ b/app/controllers/ActivityController.php @@ -11,7 +11,6 @@ class ActivityController extends \BaseController ->select('activities.id', 'activities.message', 'activities.created_at', 'clients.currency_id', 'activities.balance', 'activities.adjustment'); return Datatable::query($query) - //->addColumn('blank', function($model) { return ''; }) ->addColumn('id', function ($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); }) ->addColumn('message', function ($model) { return Utils::decodeActivity($model->message); }) ->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id); }) diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index d0a889079b80..929f10e1a390 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -494,4 +494,49 @@ class InvoiceController extends \BaseController return self::edit($publicId, true); } + + public function invoiceHistory($publicId) + { + $invoice = Invoice::withTrashed()->scope($publicId)->firstOrFail(); + $invoice->load('user', 'invoice_items', 'account.country', 'client.contacts', 'client.country'); + $invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date); + $invoice->due_date = Utils::fromSqlDate($invoice->due_date); + $invoice->is_pro = Auth::user()->isPro(); + $invoice->is_quote = intval($invoice->is_quote); + + $activityTypeId = $invoice->is_quote ? ACTIVITY_TYPE_UPDATE_QUOTE : ACTIVITY_TYPE_UPDATE_INVOICE; + $activities = Activity::scope(false, $invoice->account_id)->with(['user' => function($query) { + $query->select(['id', 'first_name', 'last_name']); + }])->where('activity_type_id', '=', $activityTypeId)->orderBy('id', 'desc')->get(['id', 'created_at', 'user_id', 'json_backup']); + + $versionsJson = []; + $versionsSelect = []; + $lastId = false; + + foreach ($activities as $activity) { + $backup = json_decode($activity->json_backup); + $backup->invoice_date = Utils::fromSqlDate($backup->invoice_date); + $backup->due_date = Utils::fromSqlDate($backup->due_date); + $backup->is_pro = Auth::user()->isPro(); + $backup->is_quote = isset($backup->is_quote) && intval($backup->is_quote); + $backup->account = $invoice->account->toArray(); + + $versionsJson[$activity->id] = $backup; + + $key = Utils::timestampToDateTimeString(strtotime($activity->created_at)) . ' - ' . $activity->user->getDisplayName(); + $versionsSelect[$lastId ? $lastId : 0] = $key; + $lastId = $activity->id; + } + + $versionsSelect[$lastId] = Utils::timestampToDateTimeString(strtotime($invoice->created_at)) . ' - ' . $invoice->user->getDisplayName(); + + $data = [ + 'invoice' => $invoice, + 'versionsJson' => json_encode($versionsJson), + 'versionsSelect' => $versionsSelect, + 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), + ]; + + return View::make('invoices.history', $data); + } } diff --git a/app/lang/da/texts.php b/app/lang/da/texts.php index a178594d9bbb..536b9292b8b7 100644 --- a/app/lang/da/texts.php +++ b/app/lang/da/texts.php @@ -493,5 +493,11 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', + ); diff --git a/app/lang/de/texts.php b/app/lang/de/texts.php index 32b01db0002e..cd3abbd98530 100644 --- a/app/lang/de/texts.php +++ b/app/lang/de/texts.php @@ -483,6 +483,11 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', ); diff --git a/app/lang/en/texts.php b/app/lang/en/texts.php index 1be03bccc3ad..115725a4e15a 100644 --- a/app/lang/en/texts.php +++ b/app/lang/en/texts.php @@ -490,5 +490,11 @@ return array( 'reason_for_canceling' => 'Help us improve our site by telling us why you\'re leaving.', 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', - + + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', + ); diff --git a/app/lang/es/texts.php b/app/lang/es/texts.php index c325342adb4b..ea0f84d14630 100644 --- a/app/lang/es/texts.php +++ b/app/lang/es/texts.php @@ -463,5 +463,11 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', + ); \ No newline at end of file diff --git a/app/lang/fr/texts.php b/app/lang/fr/texts.php index fe8fbe490bb6..884eee1fffbd 100644 --- a/app/lang/fr/texts.php +++ b/app/lang/fr/texts.php @@ -484,5 +484,11 @@ return array( 'discount_percent' => 'Pourcent', 'discount_amount' => 'Montant', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', + ); \ No newline at end of file diff --git a/app/lang/it/texts.php b/app/lang/it/texts.php index f0f0e900909c..a1332c3ad927 100644 --- a/app/lang/it/texts.php +++ b/app/lang/it/texts.php @@ -486,6 +486,11 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', ); diff --git a/app/lang/lt/texts.php b/app/lang/lt/texts.php index c3d3cbf1a8b6..d67d743a495a 100644 --- a/app/lang/lt/texts.php +++ b/app/lang/lt/texts.php @@ -494,6 +494,11 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', ); diff --git a/app/lang/nb_NO/texts.php b/app/lang/nb_NO/texts.php index 06e5c1d28c4c..e93105b736d8 100644 --- a/app/lang/nb_NO/texts.php +++ b/app/lang/nb_NO/texts.php @@ -492,6 +492,12 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', + ); \ No newline at end of file diff --git a/app/lang/nl/texts.php b/app/lang/nl/texts.php index c3a2d6873de9..3243fd07dfd9 100644 --- a/app/lang/nl/texts.php +++ b/app/lang/nl/texts.php @@ -487,6 +487,12 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', + ); \ No newline at end of file diff --git a/app/lang/pt_BR/texts.php b/app/lang/pt_BR/texts.php index 3b8db1cbd54a..83751837ccb3 100644 --- a/app/lang/pt_BR/texts.php +++ b/app/lang/pt_BR/texts.php @@ -474,6 +474,11 @@ return array( 'discount_percent' => 'Percent', 'discount_amount' => 'Amount', + 'invoice_history' => 'Invoice History', + 'quote_history' => 'Quote History', + 'current_version' => 'Current version', + 'select_versiony' => 'Select version', + 'view_history' => 'View History', diff --git a/app/models/Activity.php b/app/models/Activity.php index e84d542911be..1eca289b0163 100755 --- a/app/models/Activity.php +++ b/app/models/Activity.php @@ -1,40 +1,5 @@ belongsTo('Account'); } + public function user() + { + return $this->belongsTo('User'); + } + private static function getBlank($entity = false) { $activity = new Activity(); diff --git a/app/ninja/repositories/InvoiceRepository.php b/app/ninja/repositories/InvoiceRepository.php index f4b7337a262a..5e4c1e723d16 100755 --- a/app/ninja/repositories/InvoiceRepository.php +++ b/app/ninja/repositories/InvoiceRepository.php @@ -144,6 +144,7 @@ class InvoiceRepository if (!$model->deleted_at || $model->deleted_at == '0000-00-00') { $str .= '
  • public_id.'/edit').'">'.trans("texts.edit_{$entityType}").'
  • public_id.'/clone').'">'.trans("texts.clone_{$entityType}").'
  • +
  • public_id}") . '">' . trans("texts.view_history") . '
  • '; if ($model->invoice_status_id < INVOICE_STATUS_SENT) { @@ -244,7 +245,7 @@ class InvoiceRepository $invoice->po_number = trim($data['po_number']); $invoice->invoice_design_id = $data['invoice_design_id']; - if (isset($data['tax_name']) && isset($data['tax_rate']) && Utils::parseFloat($data['tax_rate']) > 0) { + if (isset($data['tax_name']) && isset($data['tax_rate']) && $data['tax_name']) { $invoice->tax_rate = Utils::parseFloat($data['tax_rate']); $invoice->tax_name = trim($data['tax_name']); } else { @@ -345,7 +346,7 @@ class InvoiceRepository $invoiceItem->qty = Utils::parseFloat($item->qty); $invoiceItem->tax_rate = 0; - if (isset($item->tax_rate) && Utils::parseFloat($item->tax_rate) > 0) { + if (isset($item->tax_rate) && isset($item->tax_name) && $item->tax_name) { $invoiceItem->tax_rate = Utils::parseFloat($item->tax_rate); $invoiceItem->tax_name = trim($item->tax_name); } diff --git a/app/ninja/repositories/TaxRateRepository.php b/app/ninja/repositories/TaxRateRepository.php index e7888064d028..9fe1c854411e 100755 --- a/app/ninja/repositories/TaxRateRepository.php +++ b/app/ninja/repositories/TaxRateRepository.php @@ -14,7 +14,7 @@ class TaxRateRepository continue; } - if (!isset($record->name) || !Utils::parseFloat($record->rate) || !trim($record->name)) { + if (!isset($record->name) || !trim($record->name)) { continue; } diff --git a/app/routes.php b/app/routes.php index 7e65bddb7bba..7ba7bd29aa7b 100755 --- a/app/routes.php +++ b/app/routes.php @@ -113,6 +113,9 @@ Route::group(array('before' => 'auth'), function() { Route::get('recurring_invoices', 'InvoiceController@recurringIndex'); Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable')); + Route::get('invoices/invoice_history/{invoice_id}', 'InvoiceController@invoiceHistory'); + Route::get('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory'); + Route::resource('invoices', 'InvoiceController'); Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable')); Route::get('invoices/create/{client_id?}', 'InvoiceController@create'); @@ -192,6 +195,40 @@ define('ACCOUNT_CHART_BUILDER', 'chart_builder'); define('ACCOUNT_USER_MANAGEMENT', 'user_management'); define('ACCOUNT_DATA_VISUALIZATIONS', 'data_visualizations'); +define("ACTIVITY_TYPE_CREATE_CLIENT", 1); +define("ACTIVITY_TYPE_ARCHIVE_CLIENT", 2); +define("ACTIVITY_TYPE_DELETE_CLIENT", 3); + +define("ACTIVITY_TYPE_CREATE_INVOICE", 4); +define("ACTIVITY_TYPE_UPDATE_INVOICE", 5); +define("ACTIVITY_TYPE_EMAIL_INVOICE", 6); +define("ACTIVITY_TYPE_VIEW_INVOICE", 7); +define("ACTIVITY_TYPE_ARCHIVE_INVOICE", 8); +define("ACTIVITY_TYPE_DELETE_INVOICE", 9); + +define("ACTIVITY_TYPE_CREATE_PAYMENT", 10); +define("ACTIVITY_TYPE_UPDATE_PAYMENT", 11); +define("ACTIVITY_TYPE_ARCHIVE_PAYMENT", 12); +define("ACTIVITY_TYPE_DELETE_PAYMENT", 13); + +define("ACTIVITY_TYPE_CREATE_CREDIT", 14); +define("ACTIVITY_TYPE_UPDATE_CREDIT", 15); +define("ACTIVITY_TYPE_ARCHIVE_CREDIT", 16); +define("ACTIVITY_TYPE_DELETE_CREDIT", 17); + +define("ACTIVITY_TYPE_CREATE_QUOTE", 18); +define("ACTIVITY_TYPE_UPDATE_QUOTE", 19); +define("ACTIVITY_TYPE_EMAIL_QUOTE", 20); +define("ACTIVITY_TYPE_VIEW_QUOTE", 21); +define("ACTIVITY_TYPE_ARCHIVE_QUOTE", 22); +define("ACTIVITY_TYPE_DELETE_QUOTE", 23); + +define("ACTIVITY_TYPE_RESTORE_QUOTE", 24); +define("ACTIVITY_TYPE_RESTORE_INVOICE", 25); +define("ACTIVITY_TYPE_RESTORE_CLIENT", 26); +define("ACTIVITY_TYPE_RESTORE_PAYMENT", 27); +define("ACTIVITY_TYPE_RESTORE_CREDIT", 28); + define('DEFAULT_INVOICE_NUMBER', '0001'); define('RECENTLY_VIEWED_LIMIT', 8); define('LOGGED_ERROR_LIMIT', 100); @@ -260,7 +297,7 @@ define('NINJA_GATEWAY_ID', GATEWAY_AUTHORIZE_NET); define('NINJA_GATEWAY_CONFIG', '{"apiLoginId":"626vWcD5","transactionKey":"4bn26TgL9r4Br4qJ","testMode":"","developerMode":""}'); define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com'); -define('NINJA_VERSION', '1.6.0'); +define('NINJA_VERSION', '1.6.1'); define('NINJA_DATE', '2000-01-01'); define('NINJA_FROM_EMAIL', 'maildelivery@invoiceninja.com'); define('RELEASES_URL', 'https://github.com/hillelcoren/invoice-ninja/releases/'); diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index cfe34346ce53..6f53ad068202 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -288,6 +288,7 @@