137 lines
No EOL
5.3 KiB
PHP
137 lines
No EOL
5.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\User;
|
|
use Carbon;
|
|
use Request;
|
|
use App\User;
|
|
use App\Services\Credit;
|
|
use App\Models\UserCredit;
|
|
use App\Models\UserPayCredit;
|
|
use App\Models\UserCreditItem;
|
|
use App\Http\Controllers\Controller;
|
|
use Auth;
|
|
|
|
class PaymentController extends Controller
|
|
{
|
|
|
|
private $startYear;
|
|
private $endYear;
|
|
private $rangeYears;
|
|
private $activeYear;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
/* $this->startYear = 2021;
|
|
$this->endYear = date('Y');
|
|
$this->rangeYears = range($this->startYear, $this->endYear);
|
|
$this->activeYear = $this->endYear;*/
|
|
}
|
|
|
|
public function credit()
|
|
{
|
|
$user = \Auth::user();
|
|
$data = [
|
|
'user' => $user,
|
|
];
|
|
return view('user.payment.credit', $data);
|
|
}
|
|
|
|
|
|
public function credit_datatable(){
|
|
|
|
$user = \Auth::user();
|
|
$query = UserCredit::with('user', 'user.account')->select('user_credits.*')->where('user_id', $user->id);
|
|
|
|
return \DataTables::eloquent($query)
|
|
|
|
->addColumn('view', function (UserCredit $UserCredit) {
|
|
$ret = "";
|
|
if(Credit::isCredit($UserCredit)){
|
|
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
|
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a><br>';
|
|
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'html']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
|
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
|
|
|
}else{
|
|
$ret = "-";
|
|
}
|
|
return $ret;
|
|
})
|
|
->addColumn('total', function (UserCredit $UserCredit) {
|
|
return $UserCredit->getFormattedTotal()." €";
|
|
})
|
|
->addColumn('credits', function (UserCredit $UserCredit) {
|
|
$ret = "";
|
|
if($UserCredit->user_credit_items){
|
|
foreach($UserCredit->user_credit_items as $user_credit_item){
|
|
$ret .= nl2br($user_credit_item->getTransMessage())." / ".$user_credit_item->created_at->format('d.m.Y')."<br>";
|
|
|
|
}
|
|
}
|
|
return $ret;
|
|
})
|
|
->addColumn('status', function (UserCredit $UserCredit) {
|
|
return '<span class="badge badge-pill badge-'.$UserCredit->getStatusColor().'">'.$UserCredit->getStatusType().' <span class="ion ion-md-cash"></span></span>';
|
|
})
|
|
->orderColumn('id', 'id $1')
|
|
->orderColumn('status', 'status $1')
|
|
->orderColumn('total', 'total $1')
|
|
->rawColumns(['total', 'credits', 'status', 'view'])
|
|
->make(true);
|
|
}
|
|
|
|
public function credit_item_datatable(){
|
|
|
|
$user = \Auth::user();
|
|
$query = UserCreditItem::select('user_credit_items.*')->where('user_id', $user->id);
|
|
|
|
return \DataTables::eloquent($query)
|
|
|
|
->addColumn('message', function (UserCreditItem $user_credit_item) {
|
|
return nl2br($user_credit_item->getTransMessage());
|
|
})
|
|
->addColumn('credit', function (UserCreditItem $user_credit_item) {
|
|
return formatNumber($user_credit_item->credit)." €";
|
|
})
|
|
->addColumn('created_at', function (UserCreditItem $user_credit_item) {
|
|
return formatDate($user_credit_item->created_at);
|
|
})
|
|
->addColumn('status', function (UserCreditItem $user_credit_item) {
|
|
return '<span class="badge badge-pill badge-'.$user_credit_item->getStatusColor().'">'.$user_credit_item->getStatusType().'</span> ';
|
|
})
|
|
->addColumn('paid', function (UserCreditItem $user_credit_item) {
|
|
return ($user_credit_item->paid && $user_credit_item->user_credit) ?
|
|
'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$user_credit_item->user_credit->full_number.'</span>'
|
|
: '<span class="badge badge-pill badge-warning"><i class="fa fa-times"></i></span>';
|
|
})
|
|
|
|
->orderColumn('message', 'message $1')
|
|
->orderColumn('credit', 'credit $1')
|
|
->orderColumn('created_at', 'created_at $1')
|
|
->orderColumn('status', 'status $1')
|
|
->rawColumns(['message', 'status', 'paid'])
|
|
->make(true);
|
|
}
|
|
|
|
|
|
/*private function setActiveYears(){
|
|
if(Request::get('filter_year')){
|
|
$this->activeYear = Request::get('filter_year');
|
|
}
|
|
}
|
|
|
|
public function revenue()
|
|
{
|
|
$this->setActiveYears();
|
|
|
|
$user = \Auth::user();
|
|
$data = [
|
|
'user' => $user,
|
|
'years' => $this->rangeYears,
|
|
'active_year' => $this->activeYear,
|
|
'months' => range(1, 12),
|
|
];
|
|
return view('user.payment.revenue', $data);
|
|
}*/
|
|
} |