diff --git a/app/Http/Controllers/Api/ExcelController.php b/app/Http/Controllers/Api/ExcelController.php index 5668a7f..3d8d36d 100644 --- a/app/Http/Controllers/Api/ExcelController.php +++ b/app/Http/Controllers/Api/ExcelController.php @@ -175,6 +175,9 @@ class ExcelController extends Controller $tax[$item->tax] = 0; $gross[$item->tax] = 0; } + if ($invoice->sum == 0) { + continue; + } $net[$item->tax] += $item->amount * $item->price * $payment->paid_amount / $invoice->sum; $tax[$item->tax] += $item->amount * $item->price * $item->tax * $payment->paid_amount / ($invoice->sum * 100); $gross[$item->tax] += $item->total * $payment->paid_amount / ($invoice->sum); @@ -184,9 +187,9 @@ class ExcelController extends Controller $worksheet->setCellValue('B' . $row, $invoice->customer->name); $worksheet->setCellValue('C' . $row, $invoice->address->name); $worksheet->getCell('D' . $row)->getStyle()->getNumberFormat()->setFormatCode($this->currencyMask); - $worksheet->setCellValue('D' . $row, ($invoice->sum - $invoice->tax) / ($invoice->sum / $payment->paid_amount)); + $worksheet->setCellValue('D' . $row, ($invoice->sum != 0 && $payment->paid_amount != 0) ? (($invoice->sum - $invoice->tax) / ($invoice->sum / $payment->paid_amount)) : 0); $worksheet->getCell('E' . $row)->getStyle()->getNumberFormat()->setFormatCode($this->currencyMask); - $worksheet->setCellValue('E' . $row, $invoice->tax / ($invoice->sum / $payment->paid_amount)); + $worksheet->setCellValue('E' . $row, ($invoice->sum != 0 && $payment->paid_amount != 0) ? ($invoice->tax / ($invoice->sum / $payment->paid_amount)) : 0); $worksheet->getCell('F' . $row)->getStyle()->getNumberFormat()->setFormatCode($this->currencyMask); $worksheet->setCellValue('F' . $row, $payment->paid_amount); $worksheet->setCellValue('G' . $row, Date::PHPToExcel(\DateTime::createFromFormat('!Y-m-d', $payment->payment_date))); diff --git a/app/Http/Controllers/Api/OptionController.php b/app/Http/Controllers/Api/OptionController.php index fc4e403..3846348 100644 --- a/app/Http/Controllers/Api/OptionController.php +++ b/app/Http/Controllers/Api/OptionController.php @@ -28,6 +28,11 @@ class OptionController extends Controller $option->value = $value; $option->save(); } + + $arr = explode(';base64,', $request->company_logo); + $type = substr($arr[0], strpos($arr[0], '/') + 1); + file_put_contents(base_path('/public/storage/company_logo.'. $type), base64_decode($arr[1])); + return response()->json($request->all()); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 0efd374..fed420c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\View\Composers\OptionLogo; use App\View\Composers\TaxDropdown; use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\View; @@ -34,6 +35,7 @@ class AppServiceProvider extends ServiceProvider public function boot(): void { View::composer('components.tax-dropdown', TaxDropdown::class); + View::composer('components.company-logo', OptionLogo::class); Number::useLocale(config('app.locale')); Number::useCurrency(config('app.currency')); diff --git a/app/View/Composers/OptionLogo.php b/app/View/Composers/OptionLogo.php new file mode 100644 index 0000000..c1830f7 --- /dev/null +++ b/app/View/Composers/OptionLogo.php @@ -0,0 +1,17 @@ +first(); + + $view->with(['company_logo' => $company_logo]); + } + +} diff --git a/resources/views/components/company-logo.blade.php b/resources/views/components/company-logo.blade.php new file mode 100644 index 0000000..41664a0 --- /dev/null +++ b/resources/views/components/company-logo.blade.php @@ -0,0 +1 @@ + diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php index 80801c3..add85db 100644 --- a/resources/views/layouts/navigation.blade.php +++ b/resources/views/layouts/navigation.blade.php @@ -6,15 +6,12 @@
- +