1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Minor fixes

This commit is contained in:
David Bomba 2023-10-15 05:49:14 +11:00
parent b67d0b1ae4
commit 17d11710a7
5 changed files with 61 additions and 23 deletions

View File

@ -28,4 +28,15 @@ class ProcessInvoicesInBulkRequest extends FormRequest
'invoices' => ['array'],
];
}
public function prepareForValidation()
{
$input = $this->all();
if(isset($input['invoices'])){
$input['invoices'] = array_unique($input['invoices']);
}
$this->replace($input);
}
}

View File

@ -51,7 +51,7 @@ class StorePaymentRequest extends Request
$credits_total = 0;
if (isset($input['client_id']) && is_string($input['client_id'])) {
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
$input['client_id'] = $this->decodePrimaryKey($input['client_id'], true);
}
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {

View File

@ -1014,17 +1014,17 @@ html {
*/
protected function generateEntityImagesMarkup()
{
// if (!$this->client->getSetting('embed_documents') && !$this->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
// return '';
// }
if (!$this->client->getSetting('embed_documents') || !$this->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
return '';
}
$dom = new \DOMDocument('1.0', 'UTF-8');
$container = $dom->createElement('div');
$container->setAttribute('style', 'display:grid; grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr);justify-items: center;');
foreach ($this->entity->documents as $document) {
if (!$document->isImage()) {
foreach ($this->entity->documents()->where('is_public',true)->get() as $document) {
if (!$document->isImage()) {
continue;
}

View File

@ -62,8 +62,27 @@ trait MakesHash
return $hashids->encode($value);
}
public function decodePrimaryKey($value)
public function decodePrimaryKey($value, $return_string_failure = false)
{
try {
$hashids = new Hashids(config('ninja.hash_salt'), 10);
$decoded_array = $hashids->decode($value);
if(isset($decoded_array[0]) ?? false) {
return $decoded_array[0];
} elseif($return_string_failure) {
return "Invalid Primary Key";
} else {
throw new \Exception('Invalid Primary Key');
}
} catch (\Exception $e) {
return response()->json(['error'=>'Invalid primary key'], 400);
}
/*
try {
$hashids = new Hashids(config('ninja.hash_salt'), 10);
@ -77,6 +96,7 @@ trait MakesHash
} catch (\Exception $e) {
return response()->json(['error'=>'Invalid primary key'], 400);
}
*/
}
public function transformKeys($keys)

View File

@ -12,18 +12,19 @@
namespace App\Utils;
use App\Models\Country;
use App\Models\CreditInvitation;
use App\Models\InvoiceInvitation;
use App\Models\PurchaseOrderInvitation;
use App\Models\QuoteInvitation;
use App\Models\RecurringInvoiceInvitation;
use App\Utils\Traits\AppSetup;
use App\Utils\Traits\DesignCalculator;
use App\Utils\Traits\MakesDates;
use Exception;
use App\Models\Account;
use App\Models\Country;
use App\Utils\Traits\AppSetup;
use App\Models\QuoteInvitation;
use App\Models\CreditInvitation;
use App\Utils\Traits\MakesDates;
use App\Models\InvoiceInvitation;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
use App\Utils\Traits\DesignCalculator;
use App\Models\PurchaseOrderInvitation;
use App\Models\RecurringInvoiceInvitation;
/**
* Note the premise used here is that any currencies will be formatted back to the company currency and not
@ -775,31 +776,37 @@ html {
*/
protected function generateEntityImagesMarkup()
{
if ($this->company->getSetting('embed_documents') === false) {
if (!$this->vendor->getSetting('embed_documents') || !$this->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
return '';
}
$dom = new \DOMDocument('1.0', 'UTF-8');
$container = $dom->createElement('div');
$container->setAttribute('style', 'display:grid; grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr);');
foreach ($this->entity->documents as $document) {
$container->setAttribute('style', 'display:grid; grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr);justify-items: center;');
foreach ($this->entity->documents()->where('is_public',true)->get() as $document) {
if (!$document->isImage()) {
continue;
}
$image = $dom->createElement('img');
$image->setAttribute('src', $document->generateUrl());
$image->setAttribute('style', 'max-height: 100px; margin-top: 20px;');
$image->setAttribute('src', "data:image/png;base64,".base64_encode($document->getFile()));
$image->setAttribute('style', 'max-width: 50%; margin-top: 20px;');
$container->appendChild($image);
}
$dom->appendChild($container);
return $dom->saveHTML();
$html = $dom->saveHTML();
$dom = null;
return $html;
}
/**