|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire;
|
|
namespace App\Http\Livewire;
|
|
|
|
|
+
|
|
|
use Livewire\Component;
|
|
use Livewire\Component;
|
|
|
use DateInterval;
|
|
use DateInterval;
|
|
|
use DatePeriod;
|
|
use DatePeriod;
|
|
@@ -52,16 +53,14 @@ class Record extends Component
|
|
|
Log::info($this->suppliers);
|
|
Log::info($this->suppliers);
|
|
|
$this->members = \App\Models\Member::select(['id', 'first_name', 'last_name', 'fiscal_code'])->orderBy('last_name')->orderBy('first_name')->get();
|
|
$this->members = \App\Models\Member::select(['id', 'first_name', 'last_name', 'fiscal_code'])->orderBy('last_name')->orderBy('first_name')->get();
|
|
|
|
|
|
|
|
- $this->payments = \App\Models\PaymentMethod::select('id', 'name','type')->where('enabled', true)->where('money', false)->get();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $this->payments = \App\Models\PaymentMethod::select('id', 'name', 'type')->where('enabled', true)->where('money', false)->get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getCausals($records, $indentation)
|
|
public function getCausals($records, $indentation)
|
|
|
{
|
|
{
|
|
|
- foreach($records as $record)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($records as $record) {
|
|
|
$this->causals[] = array('id' => $record->id, 'name' => $record->getTree(), 'text' => $record->getTree(), 'level' => $indentation);
|
|
$this->causals[] = array('id' => $record->id, 'name' => $record->getTree(), 'text' => $record->getTree(), 'level' => $indentation);
|
|
|
- if(count($record->childs))
|
|
|
|
|
|
|
+ if (count($record->childs))
|
|
|
$this->getCausals($record->childs, $indentation + 1);
|
|
$this->getCausals($record->childs, $indentation + 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -138,68 +137,56 @@ class Record extends Component
|
|
|
}
|
|
}
|
|
|
*/
|
|
*/
|
|
|
$datas = \App\Models\Record::with('member', 'supplier', 'payment_method')
|
|
$datas = \App\Models\Record::with('member', 'supplier', 'payment_method')
|
|
|
- ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
|
|
|
|
|
- //->where('records_rows.when', 'like', '%' . date("m-Y") . '%')
|
|
|
|
|
- ->whereBetween('date', [$this->fromDate, $this->toDate])
|
|
|
|
|
- ->where(function ($query) {
|
|
|
|
|
- $query->where('type', 'OUT')
|
|
|
|
|
- ->orWhere(function ($query) {
|
|
|
|
|
- $query->where('records.corrispettivo_fiscale', true)
|
|
|
|
|
- ->orWhere('records.commercial', false);
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
- /*->where(function ($query) {
|
|
|
|
|
|
|
+ ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
|
|
|
|
|
+ //->where('records_rows.when', 'like', '%' . date("m-Y") . '%')
|
|
|
|
|
+ ->whereBetween('date', [$this->fromDate, $this->toDate])
|
|
|
|
|
+ ->where(function ($query) {
|
|
|
|
|
+ $query->where('type', 'OUT')
|
|
|
|
|
+ ->orWhere(function ($query) {
|
|
|
|
|
+ $query->where('records.corrispettivo_fiscale', true)
|
|
|
|
|
+ ->orWhere('records.commercial', false);
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ /*->where(function ($query) {
|
|
|
$query->where('deleted', false)->orWhere('deleted', null);
|
|
$query->where('deleted', false)->orWhere('deleted', null);
|
|
|
})*/
|
|
})*/
|
|
|
- ->whereNotIn('member_id', $exclude_from_records);
|
|
|
|
|
- if ($this->filterCausals != null && sizeof($this->filterCausals) > 0)
|
|
|
|
|
- {
|
|
|
|
|
- $causals = array();
|
|
|
|
|
- foreach($this->filterCausals as $z)
|
|
|
|
|
- {
|
|
|
|
|
- $causals[] = $z;
|
|
|
|
|
- $childs = \App\Models\Causal::where('parent_id', $z)->get();
|
|
|
|
|
- foreach($childs as $c)
|
|
|
|
|
- {
|
|
|
|
|
- $causals[] = $c->id;
|
|
|
|
|
- $childsX = \App\Models\Causal::where('parent_id', $c->id)->get();
|
|
|
|
|
- foreach($childsX as $cX)
|
|
|
|
|
- {
|
|
|
|
|
- $causals[] = $cX->id;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $datas->whereIn('causal_id', $causals);
|
|
|
|
|
|
|
+ ->whereNotIn('member_id', $exclude_from_records);
|
|
|
|
|
+ if ($this->filterCausals != null && sizeof($this->filterCausals) > 0) {
|
|
|
|
|
+ $causals = array();
|
|
|
|
|
+ foreach ($this->filterCausals as $z) {
|
|
|
|
|
+ $causals[] = $z;
|
|
|
|
|
+ $childs = \App\Models\Causal::where('parent_id', $z)->get();
|
|
|
|
|
+ foreach ($childs as $c) {
|
|
|
|
|
+ $causals[] = $c->id;
|
|
|
|
|
+ $childsX = \App\Models\Causal::where('parent_id', $c->id)->get();
|
|
|
|
|
+ foreach ($childsX as $cX) {
|
|
|
|
|
+ $causals[] = $cX->id;
|
|
|
}
|
|
}
|
|
|
- if ($this->filterMember != null && $this->filterMember > 0)
|
|
|
|
|
- {
|
|
|
|
|
- $datas->where('member_id', $this->filterMember);
|
|
|
|
|
- }
|
|
|
|
|
- if ($this->filterSupplier != null && $this->filterSupplier > 0)
|
|
|
|
|
- {
|
|
|
|
|
- $datas->where('supplier_id', $this->filterSupplier);
|
|
|
|
|
- }
|
|
|
|
|
- $datas = $datas->orderBy('date', 'ASC')->orderBy('records.created_at', 'ASC')
|
|
|
|
|
- ->get();
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $datas->whereIn('causal_id', $causals);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($this->filterMember != null && $this->filterMember > 0) {
|
|
|
|
|
+ $datas->where('member_id', $this->filterMember);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($this->filterSupplier != null && $this->filterSupplier > 0) {
|
|
|
|
|
+ $datas->where('supplier_id', $this->filterSupplier);
|
|
|
|
|
+ }
|
|
|
|
|
+ $datas = $datas->orderBy('date', 'ASC')->orderBy('records.created_at', 'ASC')
|
|
|
|
|
+ ->get();
|
|
|
|
|
|
|
|
- foreach($datas as $idx => $data)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($datas as $idx => $data) {
|
|
|
|
|
|
|
|
$causalCheck = \App\Models\Causal::findOrFail($data->causal_id);
|
|
$causalCheck = \App\Models\Causal::findOrFail($data->causal_id);
|
|
|
|
|
|
|
|
$paymentCheck = $data->payment_method->money;
|
|
$paymentCheck = $data->payment_method->money;
|
|
|
|
|
|
|
|
- if (!$paymentCheck && ($causalCheck->no_first == null || !$causalCheck->no_first))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (!$paymentCheck && ($causalCheck->no_first == null || !$causalCheck->no_first)) {
|
|
|
|
|
|
|
|
- if (!$data->deleted)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (!$data->deleted) {
|
|
|
$amount = $data->amount;
|
|
$amount = $data->amount;
|
|
|
$amount += getVatValue($amount, $data->vat_id);
|
|
$amount += getVatValue($amount, $data->vat_id);
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
$amount = $data->amount;
|
|
$amount = $data->amount;
|
|
|
}
|
|
}
|
|
|
/*$when = sizeof(json_decode($data->when));
|
|
/*$when = sizeof(json_decode($data->when));
|
|
@@ -218,21 +205,16 @@ class Record extends Component
|
|
|
//$causal = $prefix . $data->date . "§" . $causalCheck->getTree();
|
|
//$causal = $prefix . $data->date . "§" . $causalCheck->getTree();
|
|
|
$causal = $prefix . $data->date . "§" . $causalCheck->getTree() . "§" . ($data->type == "IN" ? ($data->member ? ($data->member->last_name . " " . $data->member->first_name) : "") : $data->supplier->name ?? "") . "§" . $data->note . "§" . ($data->deleted ? 'DELETED' : '');
|
|
$causal = $prefix . $data->date . "§" . $causalCheck->getTree() . "§" . ($data->type == "IN" ? ($data->member ? ($data->member->last_name . " " . $data->member->first_name) : "") : $data->supplier->name ?? "") . "§" . $data->note . "§" . ($data->deleted ? 'DELETED' : '');
|
|
|
|
|
|
|
|
- if (isset($this->records[$causal]))
|
|
|
|
|
- {
|
|
|
|
|
- if (isset($this->records[$causal][$data->payment_method->name]))
|
|
|
|
|
- {
|
|
|
|
|
- if ($data->commercial)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (isset($this->records[$causal])) {
|
|
|
|
|
+ if (isset($this->records[$causal][$data->payment_method->name])) {
|
|
|
|
|
+ if ($data->commercial) {
|
|
|
if ($data->deleted && $this->records[$causal][$data->payment_method->name][$data->type])
|
|
if ($data->deleted && $this->records[$causal][$data->payment_method->name][$data->type])
|
|
|
$amount += $this->records[$causal][$data->payment_method->name][$data->type];
|
|
$amount += $this->records[$causal][$data->payment_method->name][$data->type];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!isset($this->totals[$data->payment_method->name]))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (!isset($this->totals[$data->payment_method->name])) {
|
|
|
$this->totals[$data->payment_method->name]["IN"] = 0;
|
|
$this->totals[$data->payment_method->name]["IN"] = 0;
|
|
|
$this->totals[$data->payment_method->name]["OUT"] = 0;
|
|
$this->totals[$data->payment_method->name]["OUT"] = 0;
|
|
|
}
|
|
}
|
|
@@ -243,8 +225,6 @@ class Record extends Component
|
|
|
$this->totals[$data->payment_method->name][$data->type] += $amount; // $data->amount;//$this->records[$causal][$data->payment_method->name][$data->type];
|
|
$this->totals[$data->payment_method->name][$data->type] += $amount; // $data->amount;//$this->records[$causal][$data->payment_method->name][$data->type];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return view('livewire.records');
|
|
return view('livewire.records');
|
|
@@ -258,8 +238,7 @@ class Record extends Component
|
|
|
|
|
|
|
|
$interval = DateInterval::createFromDateString('1 day');
|
|
$interval = DateInterval::createFromDateString('1 day');
|
|
|
$date_range = new DatePeriod($begin, $interval, $end);
|
|
$date_range = new DatePeriod($begin, $interval, $end);
|
|
|
- foreach ($date_range as $date)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($date_range as $date) {
|
|
|
$labels[] = $date->format('d/M');
|
|
$labels[] = $date->format('d/M');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -275,15 +254,11 @@ class Record extends Component
|
|
|
$interval = DateInterval::createFromDateString('1 day');
|
|
$interval = DateInterval::createFromDateString('1 day');
|
|
|
$date_range = new DatePeriod($begin, $interval, $end);
|
|
$date_range = new DatePeriod($begin, $interval, $end);
|
|
|
|
|
|
|
|
- foreach ($date_range as $date)
|
|
|
|
|
- {
|
|
|
|
|
- if ($type == 'IN')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($date_range as $date) {
|
|
|
|
|
+ if ($type == 'IN') {
|
|
|
$found = false;
|
|
$found = false;
|
|
|
- foreach($this->in as $in)
|
|
|
|
|
- {
|
|
|
|
|
- if (date("Y-m-d", strtotime($in->date)) == $date->format('Y-m-d'))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($this->in as $in) {
|
|
|
|
|
+ if (date("Y-m-d", strtotime($in->date)) == $date->format('Y-m-d')) {
|
|
|
$data[] = number_format($in->total, 0, "", "");
|
|
$data[] = number_format($in->total, 0, "", "");
|
|
|
$found = true;
|
|
$found = true;
|
|
|
}
|
|
}
|
|
@@ -291,13 +266,10 @@ class Record extends Component
|
|
|
if (!$found)
|
|
if (!$found)
|
|
|
$data[] = 0;
|
|
$data[] = 0;
|
|
|
}
|
|
}
|
|
|
- if ($type == 'OUT')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($type == 'OUT') {
|
|
|
$found = false;
|
|
$found = false;
|
|
|
- foreach($this->out as $out)
|
|
|
|
|
- {
|
|
|
|
|
- if (date("Y-m-d", strtotime($out->date)) == $date->format('Y-m-d'))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($this->out as $out) {
|
|
|
|
|
+ if (date("Y-m-d", strtotime($out->date)) == $date->format('Y-m-d')) {
|
|
|
$data[] = number_format($out->total, 0, "", "");
|
|
$data[] = number_format($out->total, 0, "", "");
|
|
|
$found = true;
|
|
$found = true;
|
|
|
}
|
|
}
|
|
@@ -312,7 +284,7 @@ class Record extends Component
|
|
|
|
|
|
|
|
public function export()
|
|
public function export()
|
|
|
{
|
|
{
|
|
|
- $letters = array('E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
|
|
|
|
|
|
|
+ $letters = array('F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA');
|
|
|
|
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
$spreadsheet = new Spreadsheet();
|
|
|
$activeWorksheet = $spreadsheet->getActiveSheet();
|
|
$activeWorksheet = $spreadsheet->getActiveSheet();
|
|
@@ -322,9 +294,10 @@ class Record extends Component
|
|
|
$activeWorksheet->setCellValue('B1', "Causale");
|
|
$activeWorksheet->setCellValue('B1', "Causale");
|
|
|
$activeWorksheet->setCellValue('C1', "Dettaglio");
|
|
$activeWorksheet->setCellValue('C1', "Dettaglio");
|
|
|
$activeWorksheet->setCellValue('D1', "Nominativo");
|
|
$activeWorksheet->setCellValue('D1', "Nominativo");
|
|
|
|
|
+ $activeWorksheet->setCellValue('E1', "Stato");
|
|
|
|
|
+
|
|
|
$idx = 0;
|
|
$idx = 0;
|
|
|
- foreach($this->payments as $p)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($this->payments as $p) {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -342,9 +315,10 @@ class Record extends Component
|
|
|
$activeWorksheet->setCellValue('B2', "");
|
|
$activeWorksheet->setCellValue('B2', "");
|
|
|
$activeWorksheet->setCellValue('C2', "");
|
|
$activeWorksheet->setCellValue('C2', "");
|
|
|
$activeWorksheet->setCellValue('D2', "");
|
|
$activeWorksheet->setCellValue('D2', "");
|
|
|
- foreach($this->payments as $p)
|
|
|
|
|
- {
|
|
|
|
|
- if($p->type == 'ALL'){
|
|
|
|
|
|
|
+ $activeWorksheet->setCellValue('E2', "");
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($this->payments as $p) {
|
|
|
|
|
+ if ($p->type == 'ALL') {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -353,8 +327,7 @@ class Record extends Component
|
|
|
$idx++;
|
|
$idx++;
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . '2', "Uscite");
|
|
$activeWorksheet->setCellValue($letters[$idx] . '2', "Uscite");
|
|
|
$idx++;
|
|
$idx++;
|
|
|
- }
|
|
|
|
|
- elseif($p->type == 'IN'){
|
|
|
|
|
|
|
+ } elseif ($p->type == 'IN') {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -363,8 +336,7 @@ class Record extends Component
|
|
|
$idx++;
|
|
$idx++;
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . '2', "");
|
|
$activeWorksheet->setCellValue($letters[$idx] . '2', "");
|
|
|
$idx++;
|
|
$idx++;
|
|
|
- }
|
|
|
|
|
- elseif($p->type == 'OUT'){
|
|
|
|
|
|
|
+ } elseif ($p->type == 'OUT') {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -376,53 +348,55 @@ class Record extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $activeWorksheet->getStyle('A1:P1')->getFont()->setBold(true);
|
|
|
|
|
- $activeWorksheet->getStyle('A2:P2')->getFont()->setBold(true);
|
|
|
|
|
|
|
+ $activeWorksheet->getStyle('A1:Q1')->getFont()->setBold(true);
|
|
|
|
|
+ $activeWorksheet->getStyle('A2:Q2')->getFont()->setBold(true);
|
|
|
// $activeWorksheet->getStyle('A1:N1')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('00ff00');
|
|
// $activeWorksheet->getStyle('A1:N1')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('00ff00');
|
|
|
|
|
|
|
|
$count = 3;
|
|
$count = 3;
|
|
|
|
|
|
|
|
$totals = [];
|
|
$totals = [];
|
|
|
|
|
|
|
|
- foreach($this->records as $causal => $record)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($this->records as $causal => $record) {
|
|
|
|
|
|
|
|
$check = strpos($causal, "$") ? explode("$", $causal)[1] : $causal;
|
|
$check = strpos($causal, "$") ? explode("$", $causal)[1] : $causal;
|
|
|
- list($d, $c, $j, $k) = explode("§", $check);
|
|
|
|
|
|
|
|
|
|
- $activeWorksheet->setCellValue('A' . $count, date("d/m/Y", strtotime($d)));
|
|
|
|
|
|
|
+ $parts = explode("§", $check);
|
|
|
|
|
+ $d = $parts[0] ?? '';
|
|
|
|
|
+ $c = $parts[1] ?? '';
|
|
|
|
|
+ $j = $parts[2] ?? '';
|
|
|
|
|
+ $k = $parts[3] ?? '';
|
|
|
|
|
+ $deleted = $parts[4] ?? '';
|
|
|
|
|
+ $numeroLinea = $parts[5] ?? '';
|
|
|
|
|
+
|
|
|
|
|
+ $activeWorksheet->setCellValue('A' . $count, !empty($d) ? date("d/m/Y", strtotime($d)) : '');
|
|
|
$activeWorksheet->setCellValue('B' . $count, $c);
|
|
$activeWorksheet->setCellValue('B' . $count, $c);
|
|
|
$activeWorksheet->setCellValue('C' . $count, $k);
|
|
$activeWorksheet->setCellValue('C' . $count, $k);
|
|
|
$activeWorksheet->setCellValue('D' . $count, $j);
|
|
$activeWorksheet->setCellValue('D' . $count, $j);
|
|
|
|
|
|
|
|
|
|
+ $stato = ($deleted === 'DELETED') ? 'ANNULLATA' : '';
|
|
|
|
|
+ $activeWorksheet->setCellValue('E' . $count, $stato);
|
|
|
|
|
+
|
|
|
|
|
+ if ($stato === 'ANNULLATA') {
|
|
|
|
|
+ $activeWorksheet->getStyle('E' . $count)->getFont()->getColor()->setARGB('FFFF0000');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$idx = 0;
|
|
$idx = 0;
|
|
|
- foreach($this->payments as $p)
|
|
|
|
|
- {
|
|
|
|
|
- if(isset($record[$p->name]))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($this->payments as $p) {
|
|
|
|
|
+ if (isset($record[$p->name])) {
|
|
|
|
|
|
|
|
- if(isset($record[$p->name]["IN"]))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (isset($record[$p->name]["IN"])) {
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($record[$p->name]["IN"]));
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($record[$p->name]["IN"]));
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
|
}
|
|
}
|
|
|
$idx++;
|
|
$idx++;
|
|
|
- if(isset($record[$p->name]["OUT"]))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (isset($record[$p->name]["OUT"])) {
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($record[$p->name]["OUT"]));
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($record[$p->name]["OUT"]));
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
|
}
|
|
}
|
|
|
$idx++;
|
|
$idx++;
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -435,7 +409,6 @@ class Record extends Component
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$count += 1;
|
|
$count += 1;
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$count += 1;
|
|
$count += 1;
|
|
@@ -446,32 +419,28 @@ class Record extends Component
|
|
|
$activeWorksheet->setCellValue('B' . $count, '');
|
|
$activeWorksheet->setCellValue('B' . $count, '');
|
|
|
$activeWorksheet->setCellValue('C' . $count, '');
|
|
$activeWorksheet->setCellValue('C' . $count, '');
|
|
|
$activeWorksheet->setCellValue('D' . $count, '');
|
|
$activeWorksheet->setCellValue('D' . $count, '');
|
|
|
- foreach($this->payments as $p)
|
|
|
|
|
- {
|
|
|
|
|
- if(isset($this->totals[$p->name]))
|
|
|
|
|
- {
|
|
|
|
|
- if($p->type == 'ALL'){
|
|
|
|
|
|
|
+ $activeWorksheet->setCellValue('E' . $count, '');
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($this->payments as $p) {
|
|
|
|
|
+ if (isset($this->totals[$p->name])) {
|
|
|
|
|
+ if ($p->type == 'ALL') {
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["IN"]));
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["IN"]));
|
|
|
$idx++;
|
|
$idx++;
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["OUT"]));
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["OUT"]));
|
|
|
$idx++;
|
|
$idx++;
|
|
|
- }
|
|
|
|
|
- elseif($p->type == 'IN'){
|
|
|
|
|
|
|
+ } elseif ($p->type == 'IN') {
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["IN"]));
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["IN"]));
|
|
|
$idx++;
|
|
$idx++;
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
|
$idx++;
|
|
$idx++;
|
|
|
- }
|
|
|
|
|
- elseif($p->type == 'OUT'){
|
|
|
|
|
|
|
+ } elseif ($p->type == 'OUT') {
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
|
$idx++;
|
|
$idx++;
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["OUT"]));
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["OUT"]));
|
|
|
$idx++;
|
|
$idx++;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- if($p->type == 'ALL'){
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if ($p->type == 'ALL') {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -480,8 +449,7 @@ class Record extends Component
|
|
|
$idx++;
|
|
$idx++;
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "0");
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "0");
|
|
|
$idx++;
|
|
$idx++;
|
|
|
- }
|
|
|
|
|
- elseif($p->type == 'IN'){
|
|
|
|
|
|
|
+ } elseif ($p->type == 'IN') {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -490,8 +458,7 @@ class Record extends Component
|
|
|
$idx++;
|
|
$idx++;
|
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
$activeWorksheet->setCellValue($letters[$idx] . $count, "");
|
|
|
$idx++;
|
|
$idx++;
|
|
|
- }
|
|
|
|
|
- elseif($p->type == 'OUT'){
|
|
|
|
|
|
|
+ } elseif ($p->type == 'OUT') {
|
|
|
if ($idx >= count($letters)) {
|
|
if ($idx >= count($letters)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -504,20 +471,19 @@ class Record extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $activeWorksheet->getStyle('A' . $count . ':P' . $count)->getFont()->setBold(true);
|
|
|
|
|
|
|
+ $activeWorksheet->getStyle('A' . $count . ':Q' . $count)->getFont()->setBold(true);
|
|
|
|
|
|
|
|
$activeWorksheet->getColumnDimension('A')->setWidth(20);
|
|
$activeWorksheet->getColumnDimension('A')->setWidth(20);
|
|
|
$activeWorksheet->getColumnDimension('B')->setWidth(40);
|
|
$activeWorksheet->getColumnDimension('B')->setWidth(40);
|
|
|
$activeWorksheet->getColumnDimension('C')->setWidth(40);
|
|
$activeWorksheet->getColumnDimension('C')->setWidth(40);
|
|
|
$activeWorksheet->getColumnDimension('D')->setWidth(40);
|
|
$activeWorksheet->getColumnDimension('D')->setWidth(40);
|
|
|
- foreach($letters as $l)
|
|
|
|
|
|
|
+ $activeWorksheet->getColumnDimension('E')->setWidth(20);
|
|
|
|
|
+ foreach ($letters as $l)
|
|
|
$activeWorksheet->getColumnDimension($l)->setWidth(20);
|
|
$activeWorksheet->getColumnDimension($l)->setWidth(20);
|
|
|
|
|
|
|
|
$writer = new Xlsx($spreadsheet);
|
|
$writer = new Xlsx($spreadsheet);
|
|
|
$writer->save($path = storage_path('prima_nota_' . date("YmdHis") . '.xlsx'));
|
|
$writer->save($path = storage_path('prima_nota_' . date("YmdHis") . '.xlsx'));
|
|
|
|
|
|
|
|
return response()->download($path)->deleteFileAfterSend();
|
|
return response()->download($path)->deleteFileAfterSend();
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|