middleware('auth');
$this->startYear = 2021;
$this->endYear = date('Y');
$this->rangeYears = range($this->startYear, $this->endYear);
$this->activeYear = $this->endYear;
}
public function index()
{
$this->setActiveYears();
$date1 = Carbon::parse('01.01.'.$this->activeYear." 00:00:00")->format('Y-m-d H:i:s');
$date2 = Carbon::parse('31.12.'.$this->activeYear." 23:59:59")->toDateString();
$data = [
'years' => $this->rangeYears,
'active_year' => $this->activeYear,
];
return view('admin.payment.invoice.index', $data);
}
private function setActiveYears(){
if(Request::get('filter_sales_year')){
$this->activeYear = Request::get('filter_sales_year');
}
}
public function datatable(){
$this->setActiveYears();
$date1 = Carbon::parse('01.01.'.$this->activeYear." 00:00:00")->format('Y-m-d H:i:s');
$date2 = Carbon::parse('31.12.'.$this->activeYear." 23:59:59")->toDateString();
$query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')
->where('shopping_orders.auth_user_id', '!=', NULL) //::with('shopping_user', )->select('shopping_orders.*')
->where('mode', '=', 'live')
//->where('paid', '=', 1)
->whereBetween('created_at', [$date1, $date2]);
//->orderBy('created_at', 'DESC');
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
return '';
})
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getFormattedTotalShipping()." €";
})
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->created_at->format("d.m.Y");
})
->addColumn('shipping_order', function (ShoppingOrder $ShoppingOrder) {
$ret = "";
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
$ret .= $shopping_order_item->product->name."
";
}
return $ret;
})
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
$ret = "";
if(Invoice::isInvoice($ShoppingOrder)){
$ret .= ' ';
$ret .= '';
}else{
$ret = "-";
}
return $ret;
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'shipping_order', 'txaction', 'invoice'])
->make(true);
}
}