Gutschriften

This commit is contained in:
Kevin Adametz 2021-04-23 14:52:25 +02:00
parent 35ae3da244
commit 6ac9fcc4d2
20 changed files with 510 additions and 63 deletions

View file

@ -2,9 +2,10 @@
namespace App\Http\Controllers;
use App\Services\Invoice;
use Response;
use Storage;
use Response;
use App\Services\Credit;
use App\Services\Invoice;
class FileController extends Controller
{
@ -63,8 +64,8 @@ class FileController extends Controller
if ($disk === 'credit'){
$UserCredit = \App\Models\UserCredit::findOrFail($id);
$filename = Invoice::getCreditFilename($UserCredit);
$path = Invoice::getCreditDownloadPath($UserCredit);
$filename = Credit::getFilename($UserCredit);
$path = Credit::getDownloadPath($UserCredit);
if (!Storage::disk('public')->exists($path)) {
return Response::make('File no found.', 404);
}

View file

@ -5,11 +5,9 @@ namespace App\Http\Controllers;
use Carbon;
use Request;
use App\User;
use App\Services\Invoice;
use App\Services\Payment;
use App\Models\ShoppingOrder;
use App\Models\ShoppingOrderMargin;
use App\Services\Credit;
use App\Models\UserCredit;
use App\Models\ShoppingOrderMargin;
use App\Repositories\CreditRepository;
class PaymentCreditController extends Controller
@ -120,7 +118,7 @@ class PaymentCreditController extends Controller
})*/
->addColumn('credit', function (UserCredit $UserCredit) {
$ret = "";
if(Invoice::isCredit($UserCredit)){
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>';
}else{

View file

@ -0,0 +1,85 @@
<?php
namespace App\Http\Controllers;
use Carbon;
use Request;
use App\User;
use App\Services\Invoice;
use App\Services\Payment;
use App\Models\ShoppingOrder;
class PaymentPayCreditController extends Controller
{
private $filter_user_status;
public function __construct()
{
$this->middleware('auth');
$this->filter_user_status = 'all';
}
public function index()
{
$this->setActiveFilter();
$data = [
'filter_user_status' => $this->filter_user_status,
];
return view('admin.payment.pay_credit.index', $data);
}
private function setActiveFilter(){
if(Request::get('filter_user_status')){
$this->filter_user_status = Request::get('filter_user_status');
}
}
public function datatable(){
$this->setActiveFilter();
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)
->where('active', true);
//->orderBy('created_at', 'DESC');
return \DataTables::eloquent($query)
->addColumn('id', function (User $user) {
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('first_name', function (User $user) {
return $user->account ? $user->account->first_name : '';
})
->addColumn('last_name', function (User $user) {
return $user->account ? $user->account->last_name : '';
})
->addColumn('payment_credit', function (User $user) {
return $user->payment_credit ? $user->getFormattedPaymentCredit().' €' : '';
})
->addColumn('is_active_account', function (User $user) {
if($user->payment_account){
if($user->isActiveAccount()){
return '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span></a>';
}
return '<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i></span></a>';
}
return '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
})
->addColumn('action', function (User $user) {
$ret = '<a href="#" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
return $ret;
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('payment_credit', 'payment_credit $1')
->orderColumn('is_active_account', 'is_active_account $1')
->rawColumns(['id', 'shipping_order', 'is_active_account', 'action'])
->make(true);
}
}