diff --git a/Gruntfile.js b/Gruntfile.js index 013e7395e330..5e4a88608805 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -57,7 +57,7 @@ module.exports = function(grunt) { 'public/vendor/spectrum/spectrum.js', 'public/vendor/jspdf/dist/jspdf.min.js', //'public/vendor/handsontable/dist/jquery.handsontable.full.min.js', - 'public/vendor/pdfmake/build/pdfmake.min.js', + //'public/vendor/pdfmake/build/pdfmake.min.js', //'public/vendor/pdfmake/build/vfs_fonts.js', //'public/js/vfs_fonts.js', 'public/js/lightbox.min.js', diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 1475cbb5cb09..9ff8b031cea7 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -39,6 +39,12 @@ class Handler extends ExceptionHandler { */ public function render($request, Exception $e) { - return parent::render($request, $e); + $data = [ + 'error' => get_class($e), + 'hideHeader' => true, + ]; + + return response()->view('error', $data); + //return parent::render($request, $e); } } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 605199573759..0a5504bb780b 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -22,6 +22,8 @@ class HomeController extends BaseController public function showIndex() { + Session::reflash(); + if (!Utils::isDatabaseSetup()) { return Redirect::to('/setup'); } elseif (Account::count() == 0) { diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 70fa028200ab..8cd6063ed845 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -532,21 +532,24 @@ class PaymentController extends BaseController } elseif ($account->token_billing_type_id == TOKEN_BILLING_ALWAYS || Input::get('token_billing')) { $tokenResponse = $gateway->createCard($details)->send(); $cardReference = $tokenResponse->getCardReference(); - $details['cardReference'] = $cardReference; - $token = AccountGatewayToken::where('client_id', '=', $client->id) - ->where('account_gateway_id', '=', $accountGateway->id)->first(); + if ($cardReference) { + $details['cardReference'] = $cardReference; - if (!$token) { - $token = new AccountGatewayToken(); - $token->account_id = $account->id; - $token->contact_id = $invitation->contact_id; - $token->account_gateway_id = $accountGateway->id; - $token->client_id = $client->id; + $token = AccountGatewayToken::where('client_id', '=', $client->id) + ->where('account_gateway_id', '=', $accountGateway->id)->first(); + + if (!$token) { + $token = new AccountGatewayToken(); + $token->account_id = $account->id; + $token->contact_id = $invitation->contact_id; + $token->account_gateway_id = $accountGateway->id; + $token->client_id = $client->id; + } + + $token->token = $cardReference; + $token->save(); } - - $token->token = $cardReference; - $token->save(); } } diff --git a/app/Http/Middleware/DuplicateSubmissionCheck.php b/app/Http/Middleware/DuplicateSubmissionCheck.php index 0b2726cc815a..527b462d7e84 100644 --- a/app/Http/Middleware/DuplicateSubmissionCheck.php +++ b/app/Http/Middleware/DuplicateSubmissionCheck.php @@ -12,7 +12,7 @@ class DuplicateSubmissionCheck $lastTime = session(SESSION_LAST_REQUEST_TIME); if ($lastPage == $request->path() && (microtime(true) - $lastTime <= 1.5)) { - return redirect($request->path()); + return redirect('/')->with('warning', trans('texts.duplicate_post')); } session([SESSION_LAST_REQUEST_PAGE => $request->path()]); diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 892fbba0e57d..41394b4cbd3f 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -1,5 +1,6 @@ auth->check() && Client::scope()->count() > 0) { + Session::reflash(); + return new RedirectResponse(url('/dashboard')); } diff --git a/app/Http/routes.php b/app/Http/routes.php index bcf423009e51..6c5de355f91f 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -350,7 +350,7 @@ define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN'); define('DEMO_ACCOUNT_ID', 'DEMO_ACCOUNT_ID'); define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h'); define('NINJA_GATEWAY_ID', GATEWAY_AUTHORIZE_NET); -define('NINJA_GATEWAY_CONFIG', '{"apiLoginId":"626vWcD5","transactionKey":"4bn26TgL9r4Br4qJ","testMode":"","developerMode":""}'); +define('NINJA_GATEWAY_CONFIG', ''); define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com'); define('NINJA_VERSION', '1.7.2'); diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index d6789909c4c5..e3c95a2ab339 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -146,7 +146,9 @@ class Utils public static function getErrorString($exception) { - return "{$exception->getFile()} [Line {$exception->getLine()}] => {$exception->getMessage()}"; + $class = get_class($exception); + $code = method_exists($exception, 'getStatusCode') ? $exception->getStatusCode() : $exception->getCode(); + return "***{$class}*** [{$code}] : {$exception->getFile()} [Line {$exception->getLine()}] => {$exception->getMessage()}"; } public static function logError($error, $context = 'PHP') diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 2a10335320d3..b77ea725c0fd 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -285,8 +285,8 @@ class InvoiceRepository $invoice->end_date = null; } - $invoice->terms = trim($data['terms']) ? trim($data['terms']) : ($account->invoice_terms ? $account->invoice_terms : ''); - $invoice->invoice_footer = trim($data['invoice_footer']) ? trim($data['invoice_footer']) : $account->invoice_footer; + $invoice->terms = trim($data['terms']) ? trim($data['terms']) : (!$publicId && $account->invoice_terms ? $account->invoice_terms : ''); + $invoice->invoice_footer = trim($data['invoice_footer']) ? trim($data['invoice_footer']) : (!$publicId && $account->invoice_footer ? $account->invoice_footer : ''); $invoice->public_notes = trim($data['public_notes']); $invoice->po_number = trim($data['po_number']); $invoice->invoice_design_id = $data['invoice_design_id']; diff --git a/config/cache.php b/config/cache.php index 9ddd5f331ca9..77b3682f832c 100644 --- a/config/cache.php +++ b/config/cache.php @@ -51,7 +51,8 @@ return [ 'driver' => 'memcached', 'servers' => [ [ - 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100 + 'host' => env('CACHE_HOST', '127.0.0.1'), 'port' => env('CACHE_PORT1', 11211), 'weight' => 100, + 'host' => env('CACHE_HOST', '127.0.0.1'), 'port' => env('CACHE_PORT2', 11211), 'weight' => 100 ], ], ], diff --git a/database/migrations/2015_04_12_093447_add_sv_language.php b/database/migrations/2015_04_12_093447_add_sv_language.php index 2228b6b3e94e..091282585788 100644 --- a/database/migrations/2015_04_12_093447_add_sv_language.php +++ b/database/migrations/2015_04_12_093447_add_sv_language.php @@ -14,6 +14,7 @@ class AddSvLanguage extends Migration { { DB::table('languages')->insert(['name' => 'Swedish', 'locale' => 'sv']); DB::table('languages')->insert(['name' => 'Spanish - Spain', 'locale' => 'es_ES']); + DB::table('languages')->insert(['name' => 'French - Canada', 'locale' => 'fr_CA']); } /** @@ -30,6 +31,10 @@ class AddSvLanguage extends Migration { if ($language = \App\Models\Language::whereLocale('es_ES')->first()) { $language->delete(); } + + if ($language = \App\Models\Language::whereLocale('fr_CA')->first()) { + $language->delete(); + } } } diff --git a/public/js/built.js b/public/js/built.js index 716f5ae74f77..40369ca9c69c 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -31119,18 +31119,6 @@ MIT license. for(n=[],r=[],s=0,f=t.rows[0].cells.length,c=t.clientWidth;f>s;)l=t.rows[0].cells[s],r[s]={name:l.textContent.toLowerCase().replace(/\s+/g,""),prompt:l.textContent.replace(/\r?\n/g,""),width:l.clientWidth/c*e.pdf.internal.pageSize.width},s++;for(s=1;sa;){if(s=i[a],"object"==typeof s){if(e.executeWatchFunctions(s),1===s.nodeType&&"HEADER"===s.nodeName){var w=s,g=e.pdf.margins_doc.top;e.pdf.internal.events.subscribe("addPage",function(){e.y=g,n(w,e,r),e.pdf.margins_doc.top=e.y+10,e.y+=10},!1)}if(8===s.nodeType&&"#comment"===s.nodeName)~s.textContent.indexOf("ADD_PAGE")&&(e.pdf.addPage(),e.y=e.pdf.margins_doc.top);else if(1!==s.nodeType||b[s.nodeName])if(3===s.nodeType){var y=s.nodeValue;if(s.nodeValue&&"LI"===s.parentNode.nodeName)if("OL"===s.parentNode.parentNode.nodeName)y=q++ +". "+y;else{var x=16*o["font-size"],k=2;x>20&&(k=3),h=function(t,e){this.pdf.circle(t,e,k,"FD")}}e.addText(y,o)}else"string"==typeof s&&e.addText(s,o);else{var _;if("IMG"===s.nodeName){var A=s.getAttribute("src");_=m[e.pdf.sHashCode(A)||A]}if(_){e.pdf.internal.pageSize.height-e.pdf.margins_doc.bottome.pdf.margins_doc.top&&(e.pdf.addPage(),e.y=e.pdf.margins_doc.top,e.executeWatchFunctions(s));var C=u(s),S=e.x,E=12/e.pdf.internal.scaleFactor,z=(C["margin-left"]+C["padding-left"])*E,T=(C["margin-right"]+C["padding-right"])*E,I=(C["margin-top"]+C["padding-top"])*E,B=(C["margin-bottom"]+C["padding-bottom"])*E;S+=void 0!==C["float"]&&"right"===C["float"]?e.settings.width-s.width-T:z,e.pdf.addImage(_,S,e.y+I,s.width,s.height),_=void 0,"right"===C["float"]||"left"===C["float"]?(e.watchFunctions.push(function(t,n,r,s){return e.y>=n?(e.x+=t,e.settings.width+=r,!0):s&&1===s.nodeType&&!b[s.nodeName]&&e.x+s.width>e.pdf.margins_doc.left+e.pdf.margins_doc.width?(e.x+=t,e.y=n,e.settings.width+=r,!0):!1}.bind(this,"left"===C["float"]?-s.width-z-T:0,e.y+s.height+I+B,s.width)),e.watchFunctions.push(function(t,n,r){return e.y0){s=s[0];var i=e.pdf.internal.write,o=e.y;e.pdf.internal.write=function(){},n(s,e,r);var a=Math.ceil(e.y-o)+5;e.y=o,e.pdf.internal.write=i,e.pdf.margins_doc.bottom+=a;for(var u=function(t){var i=void 0!==t?t.pageNumber:1,o=e.y;e.y=e.pdf.internal.pageSize.height-e.pdf.margins_doc.bottom,e.pdf.margins_doc.bottom-=a;for(var u=s.getElementsByTagName("span"),c=0;c-1&&(u[c].innerHTML=i),(" "+u[c].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&(u[c].innerHTML="###jsPDFVarTotalPages###");n(s,e,r),e.pdf.margins_doc.bottom+=a,e.y=o},c=s.getElementsByTagName("span"),l=0;l-1&&e.pdf.internal.events.subscribe("htmlRenderingFinished",e.pdf.putTotalPages.bind(e.pdf,"###jsPDFVarTotalPages###"),!0);e.pdf.internal.events.subscribe("addPage",u,!1),u(),b.FOOTER=1}},y=function(t,e,r,s,i,o){if(!e)return!1;"string"==typeof e||e.parentNode||(e=""+e.innerHTML),"string"==typeof e&&(e=function(t){var e,n,r,s;return r="jsPDFhtmlText"+Date.now().toString()+(1e3*Math.random()).toFixed(0),s="position: absolute !important;clip: rect(1px 1px 1px 1px); /* IE6, IE7 */clip: rect(1px, 1px, 1px, 1px);padding:0 !important;border:0 !important;height: 1px !important;width: 1px !important; top:auto;left:-100px;overflow: hidden;",n=document.createElement("div"),n.style.cssText=s,n.innerHTML='