parent
582ca8299d
commit
263cf93a1e
41 changed files with 812 additions and 288 deletions
130
app/Http/Controllers/PaymentPointsController.php
Normal file
130
app/Http/Controllers/PaymentPointsController.php
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserInvoice;
|
||||
use App\Services\HTMLHelper;
|
||||
|
||||
class PaymentPointsController extends Controller
|
||||
{
|
||||
|
||||
private $startYear;
|
||||
private $endYear;
|
||||
private $rangeYears;
|
||||
private $activeYear;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::$months,
|
||||
'filter_years' => HTMLHelper::getYearRange(),
|
||||
];
|
||||
return view('admin.payment.invoice', $data);
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
|
||||
if(!session('invoice_filter_month')){
|
||||
session(['invoice_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('invoice_filter_year')){
|
||||
session(['invoice_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('invoice_filter_name')){
|
||||
session(['invoice_filter_name' => Request::get('invoice_filter_name')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_month')){
|
||||
session(['invoice_filter_month' => Request::get('invoice_filter_month')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_year')){
|
||||
session(['invoice_filter_year' => Request::get('invoice_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if(Request::get('invoice_filter_name')){
|
||||
$query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
}
|
||||
|
||||
//->orderBy('created_at', 'DESC');
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
$join->on("flex_hour_items.flex_hour_id","=","flex_hours.id");
|
||||
$join->where("flex_hour_items.date","=", FlexHourItemBot::$date);
|
||||
})*/
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$query = $this->initSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order->auth_user_id){
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
}
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
||||
})
|
||||
->addColumn('total_shipping', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping()." €</span>";
|
||||
})
|
||||
->addColumn('created_at', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->created_at->format("d.m.Y");
|
||||
})
|
||||
/*
|
||||
->addColumn('shipping_order', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
foreach($UserInvoice->shopping_order_items as $shopping_order_item){
|
||||
$ret .= $shopping_order_item->product->name."<br>";
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
*/
|
||||
->addColumn('txaction', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order){
|
||||
return Payment::getShoppingOrderBadge($UserInvoice->shopping_order);
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('status', function (UserInvoice $UserInvoice) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserInvoice->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserInvoice->getStatusColor().'">'.$UserInvoice->getStatusType().'</span>
|
||||
</a>';
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
|
||||
return $ret;
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('invoice_number', 'invoice_number $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue