akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -0,0 +1,110 @@
<?php
namespace App\Http\Livewire\Report;
use App\Models\Common\Report;
use App\Utilities\Reports as Utility;
use Illuminate\Contracts\View\View;
use Livewire\Component;
class Pin extends Component
{
public $categories;
public $pinned = false;
public $reportId = null;
public function render(): View
{
$pins = setting('favorites.report.' . user()->id, []);
if (!empty($pins)) {
$pins = json_decode($pins, true);
foreach ($this->categories as $category) {
foreach($category['reports'] as $report) {
if (is_array($report)) {
$report = Report::find($report['id']);
}
if (! Utility::canShow($report->class)) {
continue;
}
$class = Utility::getClassInstance($report, false);
if (empty($class)) {
continue;
}
if (in_array($this->reportId, $pins)) {
$this->pinned = true;
break;
}
}
}
}
return view('livewire.report.pin');
}
public function changeStatus($report_id)
{
if ($this->pinned) {
$this->removePin($report_id);
} else {
$this->addPin($report_id);
}
}
public function addPin($report_id)
{
$pins = setting('favorites.report.' . user()->id, []);
if (!empty($pins)) {
$pins = json_decode($pins, true);
}
if (in_array($report_id, $pins)) {
return;
}
if (count($pins) >= 6) {
return;
}
$pins[] = $report_id;
$this->pinned = true;
setting(['favorites.report.' . user()->id => json_encode($pins)])->save();
$this->emit('addedPin');
}
public function removePin($report_id)
{
$pins = setting('favorites.report.' . user()->id, []);
if (!empty($pins)) {
$pins = json_decode($pins, true);
}
foreach ($pins as $key => $pinned_id) {
if ($pinned_id != $report_id) {
continue;
}
unset($pins[$key]);
$this->pinned = false;
break;
}
setting(['favorites.report.' . user()->id => json_encode($pins)])->save();
$this->emit('removedPin');
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace App\Http\Livewire\Report;
use App\Models\Common\Report;
use App\Utilities\Reports as Utility;
use Livewire\Component;
use Illuminate\Support\Str;
use Illuminate\Contracts\View\View;
class Pins extends Component
{
public $pins = [];
public $categories;
public $reports = [];
public $icons = [];
public $report_id = null;
protected $listeners = [
'addedPin' => 'render',
'removedPin' => 'render',
];
public function render(): View
{
$this->reports = collect();
$pins = setting('favorites.report.' . user()->id, []);
if (!empty($pins)) {
$pins = json_decode($pins, true);
foreach ($this->categories as $category) {
foreach($category['reports'] as $report) {
if (is_array($report)) {
$report = Report::find($report['id']);
}
if (! Utility::canShow($report->class)) {
continue;
}
$class = Utility::getClassInstance($report, false);
if (empty($class)) {
continue;
}
if (in_array($report->id, $pins)) {
$this->reports->push($report);
$this->icons[$report->id] = $class->getIcon();
}
}
}
}
return view('livewire.report.pins');
}
}