|
@@ -350,6 +350,9 @@ Route::group(['middleware' => 'auth'],function(){
|
|
|
->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
|
|
->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
|
|
|
->where('records.type', 'IN');
|
|
->where('records.type', 'IN');
|
|
|
|
|
|
|
|
|
|
+ $y = \App\Models\Record::select('records.*', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name')) // , \DB::raw('SUM(records.id) As total'))
|
|
|
|
|
+ ->leftJoin('members', 'records.member_id', '=', 'members.id')->leftJoin('records_rows', 'records.id', '=', 'records_rows.record_id')->where('records.type', 'IN');
|
|
|
|
|
+
|
|
|
if (isset($_GET["search"]["value"]))
|
|
if (isset($_GET["search"]["value"]))
|
|
|
{
|
|
{
|
|
|
$v = str_replace("'", "\'", stripcslashes($_GET["search"]["value"]));
|
|
$v = str_replace("'", "\'", stripcslashes($_GET["search"]["value"]));
|
|
@@ -357,6 +360,10 @@ Route::group(['middleware' => 'auth'],function(){
|
|
|
$query->where('first_name', 'like', '%' . $v . '%')
|
|
$query->where('first_name', 'like', '%' . $v . '%')
|
|
|
->orWhere('last_name', 'like', '%' . $v . '%');
|
|
->orWhere('last_name', 'like', '%' . $v . '%');
|
|
|
});
|
|
});
|
|
|
|
|
+ $y = $y->where(function ($query) use ($v) {
|
|
|
|
|
+ $query->where('first_name', 'like', '%' . $v . '%')
|
|
|
|
|
+ ->orWhere('last_name', 'like', '%' . $v . '%');
|
|
|
|
|
+ });
|
|
|
//where('first_name', 'like', '%' . $_GET["search"]["value"] . '%');
|
|
//where('first_name', 'like', '%' . $_GET["search"]["value"] . '%');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -367,19 +374,23 @@ Route::group(['middleware' => 'auth'],function(){
|
|
|
if ($_GET["filterCommercial"] == 1)
|
|
if ($_GET["filterCommercial"] == 1)
|
|
|
{
|
|
{
|
|
|
$x = $x->where('commercial', true );
|
|
$x = $x->where('commercial', true );
|
|
|
|
|
+ $y = $y->where('commercial', true );
|
|
|
}
|
|
}
|
|
|
if ($_GET["filterCommercial"] == 2)
|
|
if ($_GET["filterCommercial"] == 2)
|
|
|
{
|
|
{
|
|
|
$x = $x->where('commercial', false);
|
|
$x = $x->where('commercial', false);
|
|
|
|
|
+ $y = $y->where('commercial', false);
|
|
|
}
|
|
}
|
|
|
if ($_GET["filterMember"] > 0)
|
|
if ($_GET["filterMember"] > 0)
|
|
|
{
|
|
{
|
|
|
$x = $x->where('member_id', $_GET["filterMember"]);
|
|
$x = $x->where('member_id', $_GET["filterMember"]);
|
|
|
|
|
+ $y = $y->where('member_id', $_GET["filterMember"]);
|
|
|
}
|
|
}
|
|
|
if ($_GET["filterPaymentMethod"] != "null")
|
|
if ($_GET["filterPaymentMethod"] != "null")
|
|
|
{
|
|
{
|
|
|
$payments = explode(",", $_GET["filterPaymentMethod"]);
|
|
$payments = explode(",", $_GET["filterPaymentMethod"]);
|
|
|
$x = $x->whereIn('payment_method_id', $payments);
|
|
$x = $x->whereIn('payment_method_id', $payments);
|
|
|
|
|
+ $y = $y->whereIn('payment_method_id', $payments);
|
|
|
}
|
|
}
|
|
|
if ($_GET["filterCausals"] != "null")
|
|
if ($_GET["filterCausals"] != "null")
|
|
|
{
|
|
{
|
|
@@ -387,14 +398,17 @@ Route::group(['middleware' => 'auth'],function(){
|
|
|
//$causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
|
|
//$causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
|
|
|
$causals = \App\Models\RecordRow::whereIn('causal_id', $causals)->pluck('record_id');
|
|
$causals = \App\Models\RecordRow::whereIn('causal_id', $causals)->pluck('record_id');
|
|
|
$x = $x->whereIn('records.id', $causals);
|
|
$x = $x->whereIn('records.id', $causals);
|
|
|
|
|
+ $y = $y->whereIn('records.id', $causals);
|
|
|
}
|
|
}
|
|
|
if ($_GET["filterFrom"] != '')
|
|
if ($_GET["filterFrom"] != '')
|
|
|
{
|
|
{
|
|
|
$x = $x->where('date', '>=', $_GET["filterFrom"]);
|
|
$x = $x->where('date', '>=', $_GET["filterFrom"]);
|
|
|
|
|
+ $y = $y->where('date', '>=', $_GET["filterFrom"]);
|
|
|
}
|
|
}
|
|
|
if ($_GET["filterTo"] != '')
|
|
if ($_GET["filterTo"] != '')
|
|
|
{
|
|
{
|
|
|
$x = $x->where('date', '<=', $_GET["filterTo"]);
|
|
$x = $x->where('date', '<=', $_GET["filterTo"]);
|
|
|
|
|
+ $y = $y->where('date', '<=', $_GET["filterTo"]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//});
|
|
//});
|
|
@@ -429,24 +443,23 @@ Route::group(['middleware' => 'auth'],function(){
|
|
|
$moneysCausal = \App\Models\Causal::where('money', true)->pluck('id')->toArray();
|
|
$moneysCausal = \App\Models\Causal::where('money', true)->pluck('id')->toArray();
|
|
|
|
|
|
|
|
$total = 0;
|
|
$total = 0;
|
|
|
- /*
|
|
|
|
|
- foreach($x->get() as $r)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ foreach($y->get() as $r)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
if (!in_array($r->payment_method_id, $moneys))
|
|
if (!in_array($r->payment_method_id, $moneys))
|
|
|
{
|
|
{
|
|
|
- foreach($r->rows as $rr)
|
|
|
|
|
- {
|
|
|
|
|
- if ((!in_array($rr->member_id, $exclude_from_records) || in_array($r->causal_id, $moneysCausal)) && (!$r->deleted || $r->deleted == null) && (!in_array($rr->causal_id, $excludeCausals) || in_array($r->causal_id, $moneysCausal)) && (!$r->financial_movement || $r->financial_movement == null) && (!$r->corrispettivo_fiscale || $r->corrispettivo_fiscale == null))
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ((!in_array($r->member_id, $exclude_from_records) || in_array($r->causal_id, $moneysCausal)) && (!$r->deleted || $r->deleted == null) && (!in_array($r->causal_id, $excludeCausals) || in_array($r->causal_id, $moneysCausal)) && (!$r->financial_movement || $r->financial_movement == null) && (!$r->corrispettivo_fiscale || $r->corrispettivo_fiscale == null))
|
|
|
{
|
|
{
|
|
|
- $total += $rr->amount;
|
|
|
|
|
- if ($rr->vat_id > 0)
|
|
|
|
|
- $total += getVatValue($rr->amount, $rr->vat_id);
|
|
|
|
|
|
|
+ $total += $r->amount;
|
|
|
|
|
+ if ($r->vat_id > 0)
|
|
|
|
|
+ $total += getVatValue($r->amount, $r->vat_id);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- */
|
|
|
|
|
|
|
+
|
|
|
$count = $x->count();
|
|
$count = $x->count();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -493,7 +506,7 @@ Route::group(['middleware' => 'auth'],function(){
|
|
|
'causals' => $causals,
|
|
'causals' => $causals,
|
|
|
'payment' => $r->payment_method->name,
|
|
'payment' => $r->payment_method->name,
|
|
|
'status' => $r->deleted ? 'Annullato' : '',
|
|
'status' => $r->deleted ? 'Annullato' : '',
|
|
|
- 'action' => $r->id . "|" . formatPrice($total) . "|" . ($r->deleted ? 'x' : '')
|
|
|
|
|
|
|
+ 'action' => $r->id . "||" . ($r->deleted ? 'x' : '')
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -512,7 +525,7 @@ Route::group(['middleware' => 'auth'],function(){
|
|
|
'action' => ''
|
|
'action' => ''
|
|
|
);*/
|
|
);*/
|
|
|
|
|
|
|
|
- return json_encode(array("data" => $datas, "recordsTotal" => $count, "recordsFiltered" => $count));
|
|
|
|
|
|
|
+ return json_encode(array("data" => $datas, "recordsTotal" => $count, "recordsFiltered" => $count, "totals" => formatPrice($total)));
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|