|
|
@@ -200,28 +200,78 @@ class RecordINOUT extends Component
|
|
|
|
|
|
$this->columns[] = $filter;
|
|
|
|
|
|
- $f = $filter;
|
|
|
- if ($m == 'x')
|
|
|
- $f = str_replace("x-", "", $filter);
|
|
|
+ list($m, $y) = explode("-", $filter);
|
|
|
+
|
|
|
+ // $f = $filter;
|
|
|
+ // if ($m == 'x')
|
|
|
+ // $f = str_replace("x-", "", $filter);
|
|
|
|
|
|
//$dt = $y . "-0" . $m;
|
|
|
|
|
|
- $records = \App\Models\Record::where('type', 'IN')
|
|
|
+ // $records = \App\Models\Record::where('type', 'IN')
|
|
|
+ // ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
|
|
|
+ // ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
|
|
|
+ // ->where(function ($query) {
|
|
|
+ // $query->where('deleted', false)->orWhere('deleted', null);
|
|
|
+ // })
|
|
|
+ // ->where(function ($query) {
|
|
|
+ // $query->where('financial_movement', false)->orWhere('financial_movement', null);
|
|
|
+ // })
|
|
|
+ // ->whereNotIn('member_id', $exclude_from_records)
|
|
|
+ // /*->where(function ($query) use ($f, $dt) {
|
|
|
+ // $query->where('records.date', 'like', '%' . $dt . '%')->orWhere('records_rows.when', 'like', '%' . $f . '%');
|
|
|
+ // })*/
|
|
|
+ // ->where('records_rows.when', 'like', '%"' . $f . '"%')
|
|
|
+ // ->get();
|
|
|
+ // //$records = $records->orderBy('date', 'DESC')->get();
|
|
|
+
|
|
|
+ $recordsQuery = \App\Models\Record::where('records.type', 'IN')
|
|
|
->join('records_rows', 'records.id', '=', 'records_rows.record_id')
|
|
|
->whereNotIn('records_rows.causal_id', $this->excludeCausals)
|
|
|
- ->where(function ($query) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->where('deleted', false)->orWhere('deleted', null);
|
|
|
})
|
|
|
- ->where(function ($query) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->where('financial_movement', false)->orWhere('financial_movement', null);
|
|
|
})
|
|
|
- ->whereNotIn('member_id', $exclude_from_records)
|
|
|
- /*->where(function ($query) use ($f, $dt) {
|
|
|
- $query->where('records.date', 'like', '%' . $dt . '%')->orWhere('records_rows.when', 'like', '%' . $f . '%');
|
|
|
- })*/
|
|
|
- ->where('records_rows.when', 'like', '%"' . $f . '"%')
|
|
|
- ->get();
|
|
|
- //$records = $records->orderBy('date', 'DESC')->get();
|
|
|
+ ->whereNotIn('member_id', $exclude_from_records);
|
|
|
+
|
|
|
+ if ($m === 'x') {
|
|
|
+ // Anno fiscale da settembre $y a agosto $y+1
|
|
|
+ $months = array_merge(range(9, 12), range(1, 8));
|
|
|
+ $years = [
|
|
|
+ 9 => $y, 10 => $y, 11 => $y, 12 => $y,
|
|
|
+ 1 => $y+1, 2 => $y+1, 3 => $y+1, 4 => $y+1,
|
|
|
+ 5 => $y+1, 6 => $y+1, 7 => $y+1, 8 => $y+1
|
|
|
+ ];
|
|
|
+
|
|
|
+ $recordsQuery->where(function ($q) use ($months, $years) {
|
|
|
+ foreach ($months as $month) {
|
|
|
+ $year = $years[$month];
|
|
|
+ // variante entrambi numeri stringhe
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":\"{$year}\"}')");
|
|
|
+ // variante month stringa e year int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":{$year}}')");
|
|
|
+ // variante month int e year stringa
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":\"{$year}\"}')");
|
|
|
+ // variante entrambi numeri int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":{$year}}')");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $recordsQuery->where(function ($q) use ($m, $y) {
|
|
|
+ // variante entrambi numeri stringhe
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
|
|
|
+ // variante month stringa e year int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":{$y}}')");
|
|
|
+ // variante month int e year stringa
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":\"{$y}\"}')");
|
|
|
+ // variante entrambi numeri int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":{$y}}')");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $records = $recordsQuery->get();
|
|
|
|
|
|
$ccc = 0;
|
|
|
$ids = '';
|
|
|
@@ -256,18 +306,66 @@ class RecordINOUT extends Component
|
|
|
}
|
|
|
//die;
|
|
|
|
|
|
- $records = \App\Models\Record::where('type', 'OUT')
|
|
|
+ // $records = \App\Models\Record::where('type', 'OUT')
|
|
|
+ // ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
|
|
|
+ // ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
|
|
|
+ // ->where(function ($query) {
|
|
|
+ // $query->where('deleted', false)->orWhere('deleted', null);
|
|
|
+ // })
|
|
|
+ // ->where(function ($query) {
|
|
|
+ // $query->where('financial_movement', false)->orWhere('financial_movement', null);
|
|
|
+ // })
|
|
|
+ // ->whereNotIn('member_id', $exclude_from_records)
|
|
|
+ // ->where('records_rows.when', 'like', '%"' . $f . '"%')->get();
|
|
|
+ //$records = $records->orderBy('date', 'DESC')->get();
|
|
|
+
|
|
|
+ $recordsQuery = \App\Models\Record::where('records.type', 'OUT')
|
|
|
->join('records_rows', 'records.id', '=', 'records_rows.record_id')
|
|
|
->whereNotIn('records_rows.causal_id', $this->excludeCausals)
|
|
|
- ->where(function ($query) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->where('deleted', false)->orWhere('deleted', null);
|
|
|
})
|
|
|
- ->where(function ($query) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->where('financial_movement', false)->orWhere('financial_movement', null);
|
|
|
})
|
|
|
- ->whereNotIn('member_id', $exclude_from_records)
|
|
|
- ->where('records_rows.when', 'like', '%"' . $f . '"%')->get();
|
|
|
- //$records = $records->orderBy('date', 'DESC')->get();
|
|
|
+ ->whereNotIn('member_id', $exclude_from_records);
|
|
|
+
|
|
|
+ if ($m === 'x') {
|
|
|
+ // Anno fiscale da settembre $y a agosto $y+1
|
|
|
+ $months = array_merge(range(9, 12), range(1, 8));
|
|
|
+ $years = [
|
|
|
+ 9 => $y, 10 => $y, 11 => $y, 12 => $y,
|
|
|
+ 1 => $y+1, 2 => $y+1, 3 => $y+1, 4 => $y+1,
|
|
|
+ 5 => $y+1, 6 => $y+1, 7 => $y+1, 8 => $y+1
|
|
|
+ ];
|
|
|
+
|
|
|
+ $recordsQuery->where(function ($q) use ($months, $years) {
|
|
|
+ foreach ($months as $month) {
|
|
|
+ $year = $years[$month];
|
|
|
+ // variante entrambi numeri stringhe
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":\"{$year}\"}')");
|
|
|
+ // variante month stringa e year int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":{$year}}')");
|
|
|
+ // variante month int e year stringa
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":\"{$year}\"}')");
|
|
|
+ // variante entrambi numeri int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":{$year}}')");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $recordsQuery->where(function ($q) use ($m, $y) {
|
|
|
+ // variante entrambi numeri stringhe
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
|
|
|
+ // variante month stringa e year int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":{$y}}')");
|
|
|
+ // variante month int e year stringa
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":\"{$y}\"}')");
|
|
|
+ // variante entrambi numeri int
|
|
|
+ $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":{$y}}')");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $records = $recordsQuery->get();
|
|
|
|
|
|
foreach($records as $record)
|
|
|
{
|
|
|
@@ -286,7 +384,6 @@ class RecordINOUT extends Component
|
|
|
$this->records_out[$filter][$record->causal_id] = $amount;
|
|
|
$this->updateParent("OUT", $record->causal_id, $amount, $filter);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -423,7 +520,12 @@ class RecordINOUT extends Component
|
|
|
$ret = '';
|
|
|
break;
|
|
|
}
|
|
|
- $ret .= $y;
|
|
|
+ if ($m == 'x') {
|
|
|
+ $nextY = $y+1;
|
|
|
+ $ret = "{$y}/{$nextY}";
|
|
|
+ } else {
|
|
|
+ $ret .= $y;
|
|
|
+ }
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
@@ -454,6 +556,7 @@ class RecordINOUT extends Component
|
|
|
{
|
|
|
|
|
|
$rows_in = array();
|
|
|
+ $rows_out = array();
|
|
|
|
|
|
if ($this->filterCausalsIn != null && sizeof($this->filterCausalsIn) > 0)
|
|
|
{
|
|
|
@@ -470,7 +573,22 @@ class RecordINOUT extends Component
|
|
|
$rows_in = $this->rows_in;
|
|
|
}
|
|
|
|
|
|
- $path = $this->generateExcel($this->columns, $rows_in, $this->records_in, $this->rows_out, $this->records_out,false);
|
|
|
+ if ($this->filterCausalsOut != null && sizeof($this->filterCausalsOut) > 0)
|
|
|
+ {
|
|
|
+ foreach($this->rows_out as $r)
|
|
|
+ {
|
|
|
+ if (in_array($r["id"], $this->filterCausalsOut) || in_array($r["parent_id"], $this->filterCausalsOut) || in_array($r["first_parent_id"], $this->filterCausalsOut))
|
|
|
+ {
|
|
|
+ $rows_out[] = $r;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $rows_out = $this->rows_out;
|
|
|
+ }
|
|
|
+
|
|
|
+ $path = $this->generateExcel($this->columns, $rows_in, $this->records_in, $rows_out, $this->records_out,false);
|
|
|
|
|
|
return response()->download($path)->deleteFileAfterSend();
|
|
|
|