Merge pull request #4580 from turbo124/v5-develop

Download snappdf binary in composer post install hook
This commit is contained in:
David Bomba 2020-12-28 09:02:37 +11:00 committed by GitHub
commit 4b05fb292d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 115 additions and 19 deletions

View File

@ -125,7 +125,7 @@ class PreviewController extends BaseController
->design($design)
->build();
if (request()->query('html') == true) {
if (request()->query('html') == 'true') {
return $maker->getCompiledHTML;
}
@ -209,6 +209,10 @@ class PreviewController extends BaseController
->design($design)
->build();
if (request()->query('html') == 'true') {
return $maker->getCompiledHTML();
}
if (config('ninja.phantomjs_pdf_generation')) {
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
}

View File

@ -98,7 +98,7 @@ class CSVImport implements ShouldQueue
//sort the array by key
ksort($this->column_map);
info("import".ucfirst($this->entity_type));
nlog("import".ucfirst($this->entity_type));
$this->{"import".ucfirst($this->entity_type)}();
$data = [
@ -110,7 +110,7 @@ class CSVImport implements ShouldQueue
'settings' => $this->company->settings
];
info(print_r($data, 1));
//info(print_r($data, 1));
MailRouter::dispatch(new ImportCompleted($data), $this->company, auth()->user());
}

View File

@ -60,7 +60,7 @@ class ClientRepository extends BaseRepository
$client->fill($data);
if (!isset($client->id_number)) {
if (!isset($client->id_number) || empty($client->id_number)) {
$client->id_number = $this->getNextClientNumber($client);
}

View File

@ -102,6 +102,12 @@
}
},
"scripts": {
"post-install-cmd": [
"vendor/bin/snappdf download"
],
"post-update-cmd": [
"vendor/bin/snappdf download"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],

26
composer.lock generated
View File

@ -116,16 +116,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.171.4",
"version": "3.171.6",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "6a6b5b2e48ad18c2bfa48b7035e09d220d0e3984"
"reference": "5587d22e63ef82ef74dffca5d47f307b84137b51"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/6a6b5b2e48ad18c2bfa48b7035e09d220d0e3984",
"reference": "6a6b5b2e48ad18c2bfa48b7035e09d220d0e3984",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/5587d22e63ef82ef74dffca5d47f307b84137b51",
"reference": "5587d22e63ef82ef74dffca5d47f307b84137b51",
"shasum": ""
},
"require": {
@ -200,9 +200,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.171.4"
"source": "https://github.com/aws/aws-sdk-php/tree/3.171.6"
},
"time": "2020-12-22T19:23:05+00:00"
"time": "2020-12-23T19:12:28+00:00"
},
{
"name": "beganovich/snappdf",
@ -10619,16 +10619,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v2.17.2",
"version": "v2.17.3",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "aaee4f3d16a996fc0b570be0c69d3b80c909c507"
"reference": "bd32f5dd72cdfc7b53f54077f980e144bfa2f595"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/aaee4f3d16a996fc0b570be0c69d3b80c909c507",
"reference": "aaee4f3d16a996fc0b570be0c69d3b80c909c507",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/bd32f5dd72cdfc7b53f54077f980e144bfa2f595",
"reference": "bd32f5dd72cdfc7b53f54077f980e144bfa2f595",
"shasum": ""
},
"require": {
@ -10654,7 +10654,7 @@
"justinrainbow/json-schema": "^5.0",
"keradus/cli-executor": "^1.4",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.4.1",
"php-coveralls/php-coveralls": "^2.4.2",
"php-cs-fixer/accessible-object": "^1.0",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1",
@ -10711,7 +10711,7 @@
"description": "A tool to automatically fix PHP code style",
"support": {
"issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues",
"source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.17.2"
"source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.17.3"
},
"funding": [
{
@ -10719,7 +10719,7 @@
"type": "github"
}
],
"time": "2020-12-17T16:41:55+00:00"
"time": "2020-12-24T11:14:44+00:00"
},
{
"name": "hamcrest/hamcrest-php",

View File

@ -0,0 +1,86 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers App\Http\Controllers\PreviewController
*/
class PreviewTest extends TestCase
{
use DatabaseTransactions;
use MockAccountData;
public function setUp() :void
{
parent::setUp();
$this->makeTestData();
$this->withoutMiddleware(
ThrottleRequests::class
);
}
public function testPreviewRoute()
{
$data = $this->getData();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/preview/', $data);
$response->assertStatus(200);
}
public function testPreviewHtmlResponse()
{
$data = $this->getData();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/preview?html=true', $data);
$response->assertStatus(200);
}
private function getData()
{
$data =
[
'entity_type' => 'invoice',
'entity_id' => '',
'design' => [
'name' => '',
'design' => [
'includes' => '</style>',
'header' => '<div id="header"></div>',
'body' => '<div id="body">',
'product' => '',
'task' => '',
'footer' => '<div id="footer">$entity_footer</div>'
],
],
'is_custom' => 1,
];
return $data;
}
}