⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.142
Server IP:
217.76.53.76
Server:
Linux vmi1397931.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
Server Software:
Apache
PHP Version:
8.2.27
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
softpos.com.ng
/
app
/
Http
/
Controllers
/
View File Name :
HomeController.php
getCreatedBy(); $low_stock = (int)Utility::settings()['low_product_stock_threshold']; $branches = Branch::select('id')->where('created_by', '=', $user_id)->count(); $cashregisters = CashRegister::select('cash_registers.id') ->leftjoin('branches', 'branches.id', '=', 'cash_registers.branch_id') ->where('branches.created_by', '=', $user_id) ->count(); $productObj = Product::getallproducts(); $productscount = $productObj->count(); $lowstockproducts = []; if ($productscount > 0) { foreach ($productObj->get() as $key => $product) { $productquantity = $product->getTotalProductQuantity(); if ($productquantity <= $low_stock) { $lowstockproducts[] = [ 'name' => $product->name, 'quantity' => $productquantity ]; } } } // Dashboard calendar $events = Calendar::where('created_by', '=', \Auth::user()->getCreatedBy())->get(); $now = date('m'); $current_month_event = Calendar::select('id', 'start', 'end', 'title', 'created_at', 'className')->whereRaw('MONTH(start)=' . $now)->get(); $arrEvents = []; foreach ($events as $event) { $arr['id'] = $event['id']; $arr['title'] = $event['title']; $arr['start'] = $event['start']; $arr['end'] = $event['end']; $arr['className'] = $event['className']; $arr['url'] = route('calendars.show', $event['id']); $arrEvents[] = $arr; } $arrEvents = json_encode($arrEvents); // Dashboard calendar $notifications = Notification::getAllNotifications(); $customers = Customer::select('id')->where('created_by', '=', $user_id)->count(); $vendors = Vendor::select('id')->where('created_by', '=', $user_id)->count(); $monthlySelledAmount = Sale::totalSelledAmount(true); $totalSelledAmount = Sale::totalSelledAmount(); $monthlyPurchasedAmount = Purchase::totalPurchasedAmount(true); $totalPurchasedAmount = Purchase::totalPurchasedAmount(); $purchasesArray = Purchase::getPurchaseReportChart(); $salesArray = Sale::getSalesReportChart(); $todos = Todo::where('created_by', '=', Auth::user()->id)->orderBy('id', 'DESC')->get(); $saletarget = BranchSalesTarget::getBranchTargets(true); $homes = [ 'branches', 'cashregisters', 'productscount', 'lowstockproducts', 'notifications', 'customers', 'vendors', 'monthlySelledAmount', 'totalSelledAmount', 'monthlyPurchasedAmount', 'totalPurchasedAmount', 'purchasesArray', 'salesArray', 'todos', 'saletarget', ]; $getOrderChart = $this->getOrderChart(['duration' => 'week']); $ownersCount = User::totalOwners(); $paidOwnersCount = User::countPaidOwners(); $ordersCount = Order::totalOrders(); $ordersPrice = Order::totalOrdersPrice(); $plansCount = Plan::totalPlan(); $mostPurchasedPlan = Plan::most_purchased_plan(); $sa = [ 'getOrderChart', 'ownersCount', 'ordersCount', 'ordersPrice', 'plansCount', 'paidOwnersCount', 'mostPurchasedPlan', ]; if (Auth::user()->isSuperAdmin()) { return view('sa-dashboard', compact($sa)); } //storage limit $users = User::find(\Auth::user()->creatorId()); $plan = Plan::find($users->plan_id); if($plan->storage_limit > 0) { $storage_limit = ($users->storage_limit / $plan->storage_limit) * 100; } else { $storage_limit = 0; } return view('dashboard', compact($homes, 'arrEvents','users','plan','storage_limit')); } else { if (!file_exists(storage_path() . "/installed")) { header('location:install'); die; } else { $settings = Utility::settings(); if($settings['display_landing'] == 'on' && \Schema::hasTable('landing_page_settings')) { $plans = Plan::get(); return view('landingpage::layouts.landingpage'); // return view('layouts.landing'); } else { return redirect('login'); } } } } public function getOrderChart(array $arrParam) { $arrDuration = []; if ($arrParam['duration']) { if ($arrParam['duration'] == 'week') { $previous_week = strtotime("-2 week +1 day"); for ($i = 0; $i < 14; $i++) { $arrDuration[date('Y-m-d', $previous_week)] = date('d-M', $previous_week); $previous_week = strtotime(date('Y-m-d', $previous_week) . " +1 day"); } } } $arrTask = []; foreach ($arrDuration as $date => $label) { $data = Order::select(DB::raw('count(*) as total'))->whereDate('created_at', '=', $date)->first(); $arrTask['label'][] = $label; $arrTask['data'][] = $data->total; } return $arrTask; } public function changeMode() { $usr = Auth::user(); $usr->mode = $usr->mode == 'light' ? 'dark' : 'light'; $usr->save(); return redirect()->back(); } }