navbar and dashboard
parent
52a37b0bc6
commit
cc513b65e3
|
@ -1,52 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admins;
|
||||
namespace App\Http\Controllers\Admins\Dashboard;
|
||||
|
||||
use App\Helpers\ResponseFormatter;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Kasir\Menu;
|
||||
use App\Models\MenuTerlarisView;
|
||||
use App\Models\Pengeluaran;
|
||||
use App\Models\Pesanan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class DashboardController extends Controller
|
||||
class CalculationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('pages.admin.dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
* @Date: 2024-01-26 18:59:12
|
||||
* @Desc: Display Menu Terlaris
|
||||
*/
|
||||
|
||||
public function menuTerlaris()
|
||||
{
|
||||
|
||||
$data = MenuTerlarisView::where([['kategori_produk_id', '=', 2], ['tgl_start_promo', '=', null]])->get();
|
||||
|
||||
return DataTables::of($data)
|
||||
->addIndexColumn()
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function getCalculationPendapatan()
|
||||
{
|
||||
$pendapatanBulan = $this->calculatePendapatanBulan();
|
||||
$pendapatanMinggu = $this->calculatePendapatanMinggu();
|
||||
$pendapatanHari = $this->calculatePendapatanHari();
|
||||
$pengeluaranBulan = $this->calculatePengeluaranBulan();
|
||||
$pengeluaranHari = $this->calculatePengeluaranHari();
|
||||
|
||||
return ResponseFormatter::success(['pendapatanBulan' => $pendapatanBulan, 'pendapatanHari' => $pendapatanHari, 'pengeluaranBulan' => $pengeluaranBulan, 'pengeluaranHari' => $pengeluaranHari]);
|
||||
// dd($pendapatanMinggu);
|
||||
return ResponseFormatter::success(['pendapatanBulan' => $pendapatanBulan, 'pendapatanMinggu' => $pendapatanMinggu, 'pendapatanHari' => $pendapatanHari]);
|
||||
}
|
||||
|
||||
private function calculatePendapatanBulan()
|
||||
|
@ -95,6 +67,52 @@ class DashboardController extends Controller
|
|||
];
|
||||
}
|
||||
|
||||
private function calculatePendapatanMinggu()
|
||||
{
|
||||
// tanggal minggu ini
|
||||
$first_day_of_the_current_week = Carbon::today()->startOfWeek();
|
||||
$last_day_of_the_current_week = $first_day_of_the_current_week->copy()->endOfWeek();
|
||||
// dd($last_day_of_the_current_week);
|
||||
// tanggal minggu lalu
|
||||
$first_day_of_the_previous_week = $first_day_of_the_current_week->copy()->subWeek()->startOfWeek();
|
||||
$last_day_of_the_previous_week = $first_day_of_the_current_week->copy()->subWeek()->endOfWeek();
|
||||
|
||||
// get data jumlah penjualan keseluruhan dalam satu minggu
|
||||
$penjualanSatuMinggu = Pesanan::whereBetween('tanggal_pesanan', [$first_day_of_the_current_week, $last_day_of_the_current_week])->sum('grand_total');
|
||||
$penjualanMingguLalu = Pesanan::whereBetween('tanggal_pesanan', [$first_day_of_the_previous_week, $last_day_of_the_previous_week])->sum('grand_total');
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
* @Date: 2024-01-30 15:52:41
|
||||
* @Desc: constant status
|
||||
* 1 netral
|
||||
* 2 plus
|
||||
* 3 minus
|
||||
*/
|
||||
$statusCalculation = 1;
|
||||
|
||||
// calculate percentage of sales growth in the last week and this week
|
||||
if ($penjualanMingguLalu != 0) {
|
||||
$statusCalculation = 2;
|
||||
$percentageOfSalesGrowth = ($penjualanSatuMinggu - $penjualanMingguLalu) / $penjualanMingguLalu * 100;
|
||||
// minus or not
|
||||
if ($percentageOfSalesGrowth < 0) {
|
||||
$statusCalculation = 3;
|
||||
$percentageOfSalesGrowth = $percentageOfSalesGrowth * -1;
|
||||
}
|
||||
} else {
|
||||
$statusCalculation = 1;
|
||||
$percentageOfSalesGrowth = 0;
|
||||
}
|
||||
|
||||
return [
|
||||
'penjualanSatuMinggu' => $penjualanSatuMinggu,
|
||||
'penjualanMingguLalu' => $penjualanMingguLalu,
|
||||
'statusCalculation' => $statusCalculation,
|
||||
'percentageOfSalesGrowth' => $percentageOfSalesGrowth
|
||||
];
|
||||
}
|
||||
|
||||
private function calculatePendapatanHari()
|
||||
{
|
||||
// tanggal hari ini
|
||||
|
@ -152,9 +170,9 @@ class DashboardController extends Controller
|
|||
$first_day_of_the_previous_month = $first_day_of_the_current_month->copy()->subMonth()->startOfMonth();
|
||||
$last_day_of_the_previous_month = $first_day_of_the_current_month->copy()->subMonth()->endOfMonth();
|
||||
|
||||
// get data jumlah penjualan keseluruhan dalam satu bulan
|
||||
$penjualanSatuBulan = pengeluaran::whereBetween('tanggal', [$first_day_of_the_current_month, $last_day_of_the_current_month])->sum('nominal');
|
||||
$penjualanBulanLalu = pengeluaran::whereBetween('tanggal', [$first_day_of_the_previous_month, $last_day_of_the_previous_month])->sum('nominal');
|
||||
// get data jumlah pengeluaran keseluruhan dalam satu bulan
|
||||
$pengeluaranSatuBulan = pengeluaran::whereBetween('tanggal', [$first_day_of_the_current_month, $last_day_of_the_current_month])->sum('nominal');
|
||||
$pengeluaranBulanLalu = pengeluaran::whereBetween('tanggal', [$first_day_of_the_previous_month, $last_day_of_the_previous_month])->sum('nominal');
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
|
@ -167,9 +185,9 @@ class DashboardController extends Controller
|
|||
$statusCalculation = 1;
|
||||
|
||||
// calculate percentage of sales growth in the last month and this month
|
||||
if ($penjualanBulanLalu != 0) {
|
||||
if ($pengeluaranBulanLalu != 0) {
|
||||
$statusCalculation = 2;
|
||||
$percentageOfSalesGrowth = ($penjualanSatuBulan - $penjualanBulanLalu) / $penjualanBulanLalu * 100;
|
||||
$percentageOfSalesGrowth = ($pengeluaranSatuBulan - $pengeluaranBulanLalu) / $pengeluaranBulanLalu * 100;
|
||||
// minus or not
|
||||
if ($percentageOfSalesGrowth < 0) {
|
||||
$statusCalculation = 3;
|
||||
|
@ -181,8 +199,8 @@ class DashboardController extends Controller
|
|||
}
|
||||
|
||||
return [
|
||||
'penjualanSatuBulan' => $penjualanSatuBulan,
|
||||
'penjualanBulanLalu' => $penjualanBulanLalu,
|
||||
'pengeluaranSatuBulan' => $pengeluaranSatuBulan,
|
||||
'pengeluaranBulanLalu' => $pengeluaranBulanLalu,
|
||||
'statusCalculation' => $statusCalculation,
|
||||
'percentageOfSalesGrowth' => $percentageOfSalesGrowth
|
||||
];
|
||||
|
@ -199,9 +217,9 @@ class DashboardController extends Controller
|
|||
$first_day_of_the_previous_day = $first_day_of_the_current_day->copy()->subDay()->startOfDay();
|
||||
$last_day_of_the_previous_day = $first_day_of_the_current_day->copy()->subDay()->endOfDay();
|
||||
|
||||
// get data jumlah penjualan keseluruhan dalam satu bulan
|
||||
$penjualanHariIni = Pengeluaran::whereBetween('tanggal', [$first_day_of_the_current_day, $last_day_of_the_current_day])->sum('nominal');
|
||||
$penjualanKemarin = pengeluaran::whereBetween('tanggal', [$first_day_of_the_previous_day, $last_day_of_the_previous_day])->sum('nominal');
|
||||
// get data jumlah pengeluaran keseluruhan dalam satu bulan
|
||||
$pengeluaranHariIni = Pengeluaran::whereBetween('tanggal', [$first_day_of_the_current_day, $last_day_of_the_current_day])->sum('nominal');
|
||||
$pengeluaranKemarin = pengeluaran::whereBetween('tanggal', [$first_day_of_the_previous_day, $last_day_of_the_previous_day])->sum('nominal');
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
|
@ -214,9 +232,9 @@ class DashboardController extends Controller
|
|||
$statusCalculation = 1;
|
||||
|
||||
// calculate percentage of sales growth in the last month and this month
|
||||
if ($penjualanKemarin != 0) {
|
||||
if ($pengeluaranKemarin != 0) {
|
||||
$statusCalculation = 2;
|
||||
$percentageOfSalesGrowth = ($penjualanHariIni - $penjualanKemarin) / $penjualanKemarin * 100;
|
||||
$percentageOfSalesGrowth = ($pengeluaranHariIni - $pengeluaranKemarin) / $pengeluaranKemarin * 100;
|
||||
|
||||
// minus or not
|
||||
if ($percentageOfSalesGrowth < 0) {
|
||||
|
@ -229,95 +247,10 @@ class DashboardController extends Controller
|
|||
}
|
||||
|
||||
return [
|
||||
'penjualanHariIni' => $penjualanHariIni,
|
||||
'penjualanKemarin' => $penjualanKemarin,
|
||||
'pengeluaranHariIni' => $pengeluaranHariIni,
|
||||
'pengeluaranKemarin' => $pengeluaranKemarin,
|
||||
'statusCalculation' => $statusCalculation,
|
||||
'percentageOfSalesGrowth' => $percentageOfSalesGrowth
|
||||
];
|
||||
}
|
||||
|
||||
public function getChart()
|
||||
{
|
||||
$allPenjualan = Pesanan::sum('grand_total');
|
||||
|
||||
$weekThisMonth = $this->getDataEachWeekThisMonth();
|
||||
$weekLastMonth = $this->getDataEachWeekLastMonth();
|
||||
|
||||
return ResponseFormatter::success(['allPenjualan' => $allPenjualan, 'weekThisMonth' => $weekThisMonth, 'weekLastMonth' => $weekLastMonth]);
|
||||
}
|
||||
|
||||
private function getDataEachWeekThisMonth()
|
||||
{
|
||||
//format string
|
||||
$f = 'Y-m-d';
|
||||
|
||||
//if you want to record time as well, then replace today() with now()
|
||||
//and remove startOfDay()
|
||||
$today = Carbon::today();
|
||||
$date = $today->copy()->firstOfMonth()->startOfDay();
|
||||
$eom = $today->copy()->endOfMonth()->startOfDay();
|
||||
|
||||
$dates = [];
|
||||
|
||||
for ($i = 1; $date->lte($eom); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->dayOfWeek != Carbon::SUNDAY && $date->lte($eom)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dates['Minggu ke ' . $i] = $startDate->format($f) . ' 00:00:00 |' . $date->format($f) . ' 23:59:59';
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$datapenjualan = [];
|
||||
|
||||
foreach ($dates as $key => $value) {
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', explode('|', $value))->sum('grand_total');
|
||||
|
||||
|
||||
$datapenjualan[$key] = $dataPenjualan;
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
|
||||
private function getDataEachWeekLastMonth()
|
||||
{
|
||||
//format string
|
||||
$f = 'Y-m-d';
|
||||
|
||||
//if you want to record time as well, then replace today() with now()
|
||||
//and remove startOfDay()
|
||||
$today = Carbon::today()->subMonth();
|
||||
$date = $today->copy()->firstOfMonth()->startOfDay();
|
||||
$eom = $today->copy()->endOfMonth()->startOfDay();
|
||||
|
||||
$dates = [];
|
||||
|
||||
for ($i = 1; $date->lte($eom); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->dayOfWeek != Carbon::SUNDAY && $date->lte($eom)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dates['Minggu ke ' . $i] = $startDate->format($f) . ' 00:00:00 |' . $date->format($f) . ' 23:59:59';
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$datapenjualan = [];
|
||||
foreach ($dates as $key => $value) {
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', explode('|', $value))->sum('grand_total');
|
||||
$datapenjualan[$key] = $dataPenjualan;
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admins\Dashboard;
|
||||
|
||||
use App\Helpers\ResponseFormatter;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pengeluaran;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ChartPengeluaranController extends Controller
|
||||
{
|
||||
|
||||
public function getChartPengeluaran()
|
||||
{
|
||||
$allPengeluaran = Pengeluaran::sum('nominal');
|
||||
|
||||
$weekThisMonth = $this->getDataEachWeekThisMonthPengeluaran();
|
||||
$weekLastMonth = $this->getDataEachWeekLastMonthPengeluaran();
|
||||
|
||||
return ResponseFormatter::success(['allPengeluaran' => $allPengeluaran, 'weekThisMonth' => $weekThisMonth, 'weekLastMonth' => $weekLastMonth]);
|
||||
}
|
||||
|
||||
private function getDataEachWeekThisMonthPengeluaran()
|
||||
{
|
||||
//format string
|
||||
$f = 'Y-m-d';
|
||||
|
||||
//if you want to record time as well, then replace today() with now()
|
||||
//and remove startOfDay()
|
||||
$today = Carbon::today();
|
||||
$date = $today->copy()->firstOfMonth()->startOfDay();
|
||||
$eom = $today->copy()->endOfMonth()->startOfDay();
|
||||
|
||||
$dates = [];
|
||||
|
||||
for ($i = 1; $date->lte($eom); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->dayOfWeek != Carbon::SUNDAY && $date->lte($eom)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dates['Minggu ke ' . $i] = $startDate->format($f) . ' 00:00:00 |' . $date->format($f) . ' 23:59:59';
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$datapengeluaran = [];
|
||||
|
||||
foreach ($dates as $key => $value) {
|
||||
$dataPengeluaran = Pengeluaran::whereBetween('tanggal', explode('|', $value))->sum('nominal');
|
||||
$datapengeluaran[$key] = $dataPengeluaran;
|
||||
}
|
||||
|
||||
return $datapengeluaran;
|
||||
}
|
||||
|
||||
private function getDataEachWeekLastMonthPengeluaran()
|
||||
{
|
||||
//format string
|
||||
$f = 'Y-m-d';
|
||||
|
||||
//if you want to record time as well, then replace today() with now()
|
||||
//and remove startOfDay()
|
||||
$today = Carbon::today()->subMonth();
|
||||
$date = $today->copy()->firstOfMonth()->startOfDay();
|
||||
$eom = $today->copy()->endOfMonth()->startOfDay();
|
||||
|
||||
$dates = [];
|
||||
|
||||
for ($i = 1; $date->lte($eom); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->dayOfWeek != Carbon::SUNDAY && $date->lte($eom)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dates['Minggu ke ' . $i] = $startDate->format($f) . ' 00:00:00 |' . $date->format($f) . ' 23:59:59';
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$datapengeluaran = [];
|
||||
foreach ($dates as $key => $value) {
|
||||
$dataPengeluaran = Pengeluaran::whereBetween('tanggal', explode('|', $value))->sum('nominal');
|
||||
$datapengeluaran[$key] = $dataPengeluaran;
|
||||
}
|
||||
|
||||
return $datapengeluaran;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admins\Dashboard;
|
||||
|
||||
use App\Helpers\ResponseFormatter;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pesanan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ChartPenjualanController extends Controller
|
||||
{
|
||||
|
||||
public function getChartWeek()
|
||||
{
|
||||
// get data grand_total this week from first day until last day of week from 00:00:00 until 23:59:59
|
||||
$grandTotalThisWeek = Pesanan::whereBetween('tanggal_pesanan', [Carbon::today()->startOfWeek()->format('Y-m-d') . ' 00:00:00', Carbon::today()->endOfWeek()->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
|
||||
// get data grand_total last week from first day until last day of week from 00:00:00 until 23:59:59
|
||||
$grandTotalLastWeek = Pesanan::whereBetween('tanggal_pesanan', [Carbon::today()->subWeek()->startOfWeek()->format('Y-m-d') . ' 00:00:00', Carbon::today()->subWeek()->endOfWeek()->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
* @Date: 2024-01-30 15:52:41
|
||||
* @Desc: constant status
|
||||
* 1 netral
|
||||
* 2 plus
|
||||
* 3 minus
|
||||
*/
|
||||
$statusCalculation = 1;
|
||||
|
||||
// calculate percentage of sales growth in the last week and this week
|
||||
if ($grandTotalLastWeek != 0) {
|
||||
$statusCalculation = 2;
|
||||
$percentageOfSalesGrowth = ($grandTotalThisWeek - $grandTotalLastWeek) / $grandTotalLastWeek * 100;
|
||||
// minus or not
|
||||
if ($percentageOfSalesGrowth < 0) {
|
||||
$statusCalculation = 3;
|
||||
$percentageOfSalesGrowth = $percentageOfSalesGrowth * -1;
|
||||
}
|
||||
} else {
|
||||
$statusCalculation = 1;
|
||||
$percentageOfSalesGrowth = 0;
|
||||
}
|
||||
|
||||
$thisWeek = $this->getDataEachDayThisWeek();
|
||||
// $lastWeek = $this->getDataEachDayLastWeek();
|
||||
|
||||
return ResponseFormatter::success(['thisWeek' => $thisWeek, 'grandTotalThisWeek' => $grandTotalThisWeek, 'grandTotalLastWeek' => $grandTotalLastWeek, 'percentageOfSalesGrowth' => $percentageOfSalesGrowth, 'statusCalculation' => $statusCalculation]);
|
||||
}
|
||||
|
||||
private function getDataEachDayThisWeek()
|
||||
{
|
||||
// get data grand_total per day this week from 00:00:00 until 23:59:59
|
||||
$datapenjualan = [];
|
||||
|
||||
$today = Carbon::today();
|
||||
$date = $today->copy()->startOfWeek()->startOfDay();
|
||||
$eow = $today->copy()->endOfWeek()->startOfDay();
|
||||
|
||||
for ($i = 1; $date->lte($eow); $i++) {
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', [$date->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
$datapenjualan[tanggal_indonesia($date->format('Y-m-d'))] = $dataPenjualan;
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
|
||||
private function getDataEachDayLastWeek()
|
||||
{
|
||||
// get data grand_total per day last week from 00:00:00 until 23:59:59
|
||||
$datapenjualan = [];
|
||||
|
||||
$today = Carbon::today()->subWeek();
|
||||
$date = $today->copy()->startOfWeek()->startOfDay();
|
||||
$eow = $today->copy()->endOfWeek()->startOfDay();
|
||||
|
||||
for ($i = 1; $date->lte($eow); $i++) {
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', [$date->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
$datapenjualan[tanggal_indonesia($date->format('Y-m-d'))] = $dataPenjualan;
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
|
||||
public function getChartMonth()
|
||||
{
|
||||
// get data grand_total this month from first day until last day of month from 00:00:00 until 23:59:59
|
||||
$grandTotalThisMonth = Pesanan::whereBetween('tanggal_pesanan', [Carbon::today()->startOfMonth()->format('Y-m-d') . ' 00:00:00', Carbon::today()->endOfMonth()->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
|
||||
// get data grand_total last month from first day until last day of month from 00:00:00 until 23:59:59
|
||||
$grandTotalLastMonth = Pesanan::whereBetween('tanggal_pesanan', [Carbon::today()->subMonth()->startOfMonth()->format('Y-m-d') . ' 00:00:00', Carbon::today()->subMonth()->endOfMonth()->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
* @Date: 2024-01-30 15:52:41
|
||||
* @Desc: constant status
|
||||
* 1 netral
|
||||
* 2 plus
|
||||
* 3 minus
|
||||
*/
|
||||
$statusCalculation = 1;
|
||||
|
||||
// calculate percentage of sales growth in the last week and this week
|
||||
if ($grandTotalLastMonth != 0) {
|
||||
$statusCalculation = 2;
|
||||
$percentageOfSalesGrowth = ($grandTotalThisMonth - $grandTotalLastMonth) / $grandTotalLastMonth * 100;
|
||||
// minus or not
|
||||
if ($percentageOfSalesGrowth < 0) {
|
||||
$statusCalculation = 3;
|
||||
$percentageOfSalesGrowth = $percentageOfSalesGrowth * -1;
|
||||
}
|
||||
} else {
|
||||
$statusCalculation = 1;
|
||||
$percentageOfSalesGrowth = 0;
|
||||
}
|
||||
|
||||
$weekThisMonth = $this->getDataEachWeekThisMonth();
|
||||
// $weekLastMonth = $this->getDataEachWeekLastMonth();
|
||||
|
||||
return ResponseFormatter::success(['weekThisMonth' => $weekThisMonth, 'grandTotalThisMonth' => $grandTotalThisMonth, 'grandTotalLastMonth' => $grandTotalLastMonth, 'percentageOfSalesGrowth' => $percentageOfSalesGrowth, 'statusCalculation' => $statusCalculation]);
|
||||
}
|
||||
|
||||
private function getDataEachWeekThisMonth()
|
||||
{
|
||||
// get data grand_total per week this month from 00:00:00 until 23:59:59 each day of week (Sunday)
|
||||
$datapenjualan = [];
|
||||
$today = Carbon::today();
|
||||
$date = $today->copy()->startOfMonth()->startOfDay();
|
||||
$eom = $today->copy()->endOfMonth()->startOfDay();
|
||||
|
||||
for ($i = 1; $date->lte($eom); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->dayOfWeek != Carbon::SUNDAY && $date->lte($eom)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', [$startDate->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
$datapenjualan['Minggu ke ' . $i] = $dataPenjualan;
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
|
||||
private function getDataEachWeekLastMonth()
|
||||
{
|
||||
// get data grand_total per week this month from 00:00:00 until 23:59:59 each day of week (Sunday) last month
|
||||
$datapenjualan = [];
|
||||
$today = Carbon::today()->subMonth();
|
||||
$date = $today->copy()->startOfMonth()->startOfDay();
|
||||
$eom = $today->copy()->endOfMonth()->startOfDay();
|
||||
|
||||
for ($i = 1; $date->lte($eom); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->dayOfWeek != Carbon::SUNDAY && $date->lte($eom)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', [$startDate->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
$datapenjualan['Minggu ke ' . $i] = $dataPenjualan;
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
|
||||
public function getChartYear()
|
||||
{
|
||||
// get data grand_total this year from first day until last day of year from 00:00:00 until 23:59:59
|
||||
$grandTotalThisYear = Pesanan::whereBetween('tanggal_pesanan', [Carbon::today()->startOfYear()->format('Y-m-d') . ' 00:00:00', Carbon::today()->endOfYear()->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
|
||||
// get data grand_total last year from first day until last day of year from 00:00:00 until 23:59:59
|
||||
$grandTotalLastYear = Pesanan::whereBetween('tanggal_pesanan', [Carbon::today()->subYear()->startOfYear()->format('Y-m-d') . ' 00:00:00', Carbon::today()->subYear()->endOfYear()->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
* @Date: 2024-01-30 15:52:41
|
||||
* @Desc: constant status
|
||||
* 1 netral
|
||||
* 2 plus
|
||||
* 3 minus
|
||||
*/
|
||||
$statusCalculation = 1;
|
||||
|
||||
// calculate percentage of sales growth in the last week and this week
|
||||
if ($grandTotalLastYear != 0) {
|
||||
$statusCalculation = 2;
|
||||
$percentageOfSalesGrowth = ($grandTotalThisYear - $grandTotalLastYear) / $grandTotalLastYear * 100;
|
||||
// minus or not
|
||||
if ($percentageOfSalesGrowth < 0) {
|
||||
$statusCalculation = 3;
|
||||
$percentageOfSalesGrowth = $percentageOfSalesGrowth * -1;
|
||||
}
|
||||
} else {
|
||||
$statusCalculation = 1;
|
||||
$percentageOfSalesGrowth = 0;
|
||||
}
|
||||
|
||||
$monthThisYear = $this->getDataEachMonthThisYear();
|
||||
// $monthLastYear = $this->getDataEachMonthLastYear();
|
||||
|
||||
return ResponseFormatter::success(['monthThisYear' => $monthThisYear, 'grandTotalThisYear' => $grandTotalThisYear, 'grandTotalLastYear' => $grandTotalLastYear, 'percentageOfSalesGrowth' => $percentageOfSalesGrowth, 'statusCalculation' => $statusCalculation]);
|
||||
}
|
||||
|
||||
private function getDataEachMonthThisYear()
|
||||
{
|
||||
// get data grand_total per month this year from 00:00:00 until 23:59:59 each day of month (last day of month)
|
||||
$datapenjualan = [];
|
||||
$today = Carbon::today();
|
||||
$date = $today->copy()->startOfYear()->startOfDay();
|
||||
$eoy = $today->copy()->endOfYear()->startOfDay();
|
||||
|
||||
for ($i = 1; $date->lte($eoy); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->day != $date->daysInMonth && $date->lte($eoy)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', [$startDate->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
$datapenjualan[$date->format('F')] = $dataPenjualan;
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
|
||||
private function getDataEachMonthLastYear()
|
||||
{
|
||||
// get data grand_total per month this year from 00:00:00 until 23:59:59 each day of month (last day of month) last year
|
||||
$datapenjualan = [];
|
||||
$today = Carbon::today()->subYear();
|
||||
$date = $today->copy()->startOfYear()->startOfDay();
|
||||
$eoy = $today->copy()->endOfYear()->startOfDay();
|
||||
|
||||
for ($i = 1; $date->lte($eoy); $i++) {
|
||||
|
||||
//record start date
|
||||
$startDate = $date->copy();
|
||||
|
||||
//loop to end of the week while not crossing the last date of month
|
||||
while ($date->day != $date->daysInMonth && $date->lte($eoy)) {
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
$dataPenjualan = Pesanan::whereBetween('tanggal_pesanan', [$startDate->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->sum('grand_total');
|
||||
$datapenjualan['Bulan ke ' . $i] = $dataPenjualan;
|
||||
$date->addDay();
|
||||
}
|
||||
|
||||
return $datapenjualan;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admins\Dashboard;
|
||||
|
||||
use App\Helpers\ResponseFormatter;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Kasir\Menu;
|
||||
use App\Models\KelompokKategori;
|
||||
use App\Models\MenuTerlarisView;
|
||||
use App\Models\Pengeluaran;
|
||||
use App\Models\Pesanan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('pages.admin.dashboard.dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: xelz
|
||||
* @Date: 2024-01-26 18:59:12
|
||||
* @Desc: Display Menu Terlaris
|
||||
*/
|
||||
|
||||
public function menuTerlaris()
|
||||
{
|
||||
|
||||
$data = MenuTerlarisView::where([['kategori_produk_id', '=', 2], ['tgl_start_promo', '=', null]])->get();
|
||||
|
||||
// $KelompokKategori = KelompokKategori::with('kelompokKategoriPivot.produkTerlaris')->get();
|
||||
// dd($KelompokKategori->kelompokKategoriPivot->first()->produkTerlaris);
|
||||
|
||||
return DataTables::of($data)
|
||||
->addIndexColumn()
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function minumanTerlaris()
|
||||
{
|
||||
$data = MenuTerlarisView::where([['kategori_produk_id', '=', 1], ['tgl_start_promo', '=', null]])->get();
|
||||
|
||||
// $KelompokKategori = KelompokKategori::with('kelompokKategoriPivot.produkTerlaris')->get();
|
||||
// dd($KelompokKategori->kelompokKategoriPivot->first()->produkTerlaris);
|
||||
|
||||
return DataTables::of($data)
|
||||
->addIndexColumn()
|
||||
->make(true);
|
||||
}
|
||||
}
|
|
@ -23,6 +23,12 @@ class KategoriProduk extends Model
|
|||
return $this->hasMany(Produk::class, 'kategori_produk_id');
|
||||
}
|
||||
|
||||
|
||||
public function produkTerlaris()
|
||||
{
|
||||
return $this->belongsTo(MenuTerlarisView::class, 'produk_id');
|
||||
}
|
||||
|
||||
// kelompok kategori
|
||||
public function kelompokKategori()
|
||||
{
|
||||
|
|
|
@ -27,4 +27,9 @@ class KelompokKategoriPivot extends Model
|
|||
{
|
||||
return $this->belongsTo(Produk::class, 'produk_id');
|
||||
}
|
||||
|
||||
public function produkTerlaris()
|
||||
{
|
||||
return $this->belongsTo(MenuTerlarisView::class, 'produk_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,25 @@ class MenuTerlarisView extends Model
|
|||
use HasFactory;
|
||||
|
||||
protected $table = 'menu_terlaris_view';
|
||||
|
||||
// full path to reach image from storage folder and check if image exists or not
|
||||
public function getGambarProdukAttribute($value)
|
||||
{
|
||||
$storage = storage_path('app/public/produk/' . $this->kategori_produk_id . '/' . $value);
|
||||
if (file_exists($storage)) {
|
||||
return asset('storage/produk/' . $this->kategori_produk_id . '/' . $value);
|
||||
} else {
|
||||
return asset('assets/images/menu_image.jpeg');
|
||||
}
|
||||
}
|
||||
|
||||
public function kategori_produk()
|
||||
{
|
||||
return $this->belongsTo(KategoriProduk::class, 'kategori_produk_id');
|
||||
}
|
||||
|
||||
public function kelompokKategori()
|
||||
{
|
||||
return $this->belongsToMany(KelompokKategori::class, KelompokKategoriPivot::class, 'produk_id', 'kelompok_kategori_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
Keriting</span>
|
||||
</a>
|
||||
|
||||
<button class="navbar-toggler order-1" type="button" data-toggle="collapse" data-target="#navbarCollapse"
|
||||
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse order-3" id="navbarCollapse">
|
||||
<!-- Left navbar links -->
|
||||
<ul class="navbar-nav">
|
||||
|
|
|
@ -1,365 +0,0 @@
|
|||
@extends('layouts.base')
|
||||
|
||||
@section('content-header')
|
||||
<div class="col-12">
|
||||
<div class="container" style="display: contents">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0"> Dashboard</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item active">Dashboard</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card" id="calculationPendapatan">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title">Laporan Pendapatan dan Pengeluaran</h5>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
||||
<!-- ./card-body -->
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 col-6">
|
||||
<div class="description-block border-right">
|
||||
<span class="description-percentage" id="penjualanHaripercentageOfSalesGrowth">
|
||||
</span>
|
||||
<h5 class="description-header" id="penjualanHari"></h5>
|
||||
<span class="description-text">Pendapatan Hari ini</span>
|
||||
</div>
|
||||
<!-- /.description-block -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-sm-3 col-6">
|
||||
<div class="description-block border-right">
|
||||
<span class="description-percentage" id="pengeluaranHaripercentageOfSalesGrowth">
|
||||
</span>
|
||||
<h5 class="description-header" id="pengeluaranHari"></h5>
|
||||
<span class="description-text">Pengeluaran Hari ini</span>
|
||||
</div>
|
||||
<!-- /.description-block -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-sm-3 col-6">
|
||||
<div class="description-block border-right">
|
||||
<span class="description-percentage" id="penjualanBulanpercentageOfSalesGrowth">
|
||||
</span>
|
||||
<h5 class="description-header" id="penjualanBulan"></h5>
|
||||
<span class="description-text">Pendapatan Bulan ini</span>
|
||||
</div>
|
||||
<!-- /.description-block -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-sm-3 col-6">
|
||||
<div class="description-block">
|
||||
<span class="description-percentage" id="pengeluaranBulanpercentageOfSalesGrowth">
|
||||
</span>
|
||||
<h5 class="description-header" id="pengeluaranBulan"></h5>
|
||||
<span class="description-text">Pengeluaran Bulan ini</span>
|
||||
</div>
|
||||
<!-- /.description-block -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /.card-footer -->
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<h3 class="card-title">Menu Terlaris</h3>
|
||||
<div class="card-tools">
|
||||
<a href="#" class="btn btn-tool btn-sm">
|
||||
<i class="fas fa-download"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-tool btn-sm">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body table-responsive p-0">
|
||||
<table class="table table-striped table-valign-middle" id="table-terlaris">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Menu</th>
|
||||
<th>Harga</th>
|
||||
<th>Terjual</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
<!-- /.col-md-6 -->
|
||||
<div class="col-lg-6">
|
||||
<!-- /.card -->
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h3 class="card-title">Penjualan</h3>
|
||||
<a href="javascript:void(0);">View Report</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
<p class="d-flex flex-column">
|
||||
<span class="text-bold text-lg" id="penjualanSepanjangWaktu"></span>
|
||||
<span>Penjualan Keseluruhan</span>
|
||||
</p>
|
||||
<p class="ml-auto d-flex flex-column text-right">
|
||||
<span class="text-success" id="persentaseSepanjangWaktu">
|
||||
<i class="fas fa-arrow-up"></i> 33.1%
|
||||
</span>
|
||||
<span class="text-muted">dari bulan lalu</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.d-flex -->
|
||||
|
||||
<div class="position-relative mb-4">
|
||||
<canvas id="sales-chart" height="200"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-row justify-content-end">
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-square text-primary"></i> Bulan ini
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<i class="fas fa-square text-gray"></i> Bulan Kemarin
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col-md-6 -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /.container-fluid -->
|
||||
</div>
|
||||
<!-- /.content -->
|
||||
@endsection
|
||||
|
||||
@push('styles')
|
||||
<link rel="stylesheet" href="{{ asset('assets/datatables/datatables.min.css') }} ">
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('assets/datatables/datatables.min.js') }}"></script>
|
||||
<!-- ChartJS -->
|
||||
<script src="{{ asset('assets/plugins/chart.js/Chart.min.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
'use strict'
|
||||
|
||||
var ticksStyle = {
|
||||
fontColor: '#495057',
|
||||
fontStyle: 'bold'
|
||||
}
|
||||
|
||||
var mode = 'index'
|
||||
var intersect = true
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('dashboard.getChart') }}",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(response) {
|
||||
var data = response.data;
|
||||
console.log(data);
|
||||
$('#penjualanSepanjangWaktu').append(converRp(data.allPenjualan));
|
||||
var $salesChart = $('#sales-chart')
|
||||
var salesChart = new Chart($salesChart, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: Object.keys(data.weekThisMonth),
|
||||
datasets: [{
|
||||
backgroundColor: '#007bff',
|
||||
borderColor: '#007bff',
|
||||
data: Object.values(data.weekThisMonth)
|
||||
},
|
||||
{
|
||||
backgroundColor: '#ced4da',
|
||||
borderColor: '#ced4da',
|
||||
data: Object.values(data.weekLastMonth)
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
maintainAspectRatio: false,
|
||||
tooltips: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
hover: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
// display: false,
|
||||
gridLines: {
|
||||
display: true,
|
||||
lineWidth: '4px',
|
||||
color: 'rgba(0, 0, 0, .2)',
|
||||
zeroLineColor: 'transparent'
|
||||
},
|
||||
ticks: $.extend({
|
||||
beginAtZero: true,
|
||||
// Include a dollar sign in the ticks
|
||||
callback: function(value, index,
|
||||
values) {
|
||||
return converRp(value)
|
||||
}
|
||||
}, ticksStyle)
|
||||
}],
|
||||
xAxes: [{
|
||||
display: true,
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: ticksStyle
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
error: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#table-terlaris').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
searching: false,
|
||||
"bLengthChange": false,
|
||||
"bFilter": true,
|
||||
"bInfo": false,
|
||||
ajax: "{{ route('dashboard.menuTerlaris') }}",
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'nama_produk',
|
||||
name: 'nama_produk'
|
||||
},
|
||||
{
|
||||
data: 'harga_produk',
|
||||
name: 'harga_produk',
|
||||
'render': function(data, type, full, meta) {
|
||||
// change to IDR
|
||||
return 'Rp. ' + data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
},
|
||||
className: 'text-right'
|
||||
},
|
||||
{
|
||||
data: 'jumlah_produk_terjual',
|
||||
name: 'jumlah_produk_terjual'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
$(document).ready(function() {
|
||||
getCalculationPendapatan();
|
||||
})
|
||||
|
||||
function getCalculationPendapatan() {
|
||||
$.ajax({
|
||||
url: "{{ route('dashboard.getCalculationPendapatan') }}",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(response) {
|
||||
var data = response.data;
|
||||
changeDataFromCalculate('penjualanBulan', data.pendapatanBulan
|
||||
.penjualanSatuBulan, data.pendapatanBulan.percentageOfSalesGrowth,
|
||||
data.pendapatanBulan.statusCalculation)
|
||||
changeDataFromCalculate('penjualanHari', data.pendapatanHari
|
||||
.penjualanHariIni, data.pendapatanHari.percentageOfSalesGrowth,
|
||||
data.pendapatanHari.statusCalculation)
|
||||
changeDataFromCalculate('pengeluaranBulan', data.pengeluaranBulan
|
||||
.pengeluaranSatuBulan, data.pengeluaranBulan.percentageOfSalesGrowth,
|
||||
data.pengeluaranBulan.statusCalculation)
|
||||
changeDataFromCalculate('pengeluaranHari', data.pengeluaranHari
|
||||
.pengeluaranHariIni, data.pengeluaranHari.percentageOfSalesGrowth,
|
||||
data.pengeluaranHari.statusCalculation)
|
||||
},
|
||||
error: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function changeDataFromCalculate(id, penjualanSatuBulan, percentageOfSalesGrowth, statusCalculation) {
|
||||
// change to IDR
|
||||
if (penjualanSatuBulan == null) {
|
||||
penjualanSatuBulan = 0;
|
||||
} else {
|
||||
penjualanSatuBulan;
|
||||
}
|
||||
|
||||
$('#' + id).append(converRp(penjualanSatuBulan));
|
||||
|
||||
// pembulatan 2 angka di belakang koma
|
||||
percentageOfSalesGrowth = percentageOfSalesGrowth.toFixed(2);
|
||||
switch (statusCalculation) {
|
||||
case 1:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-left"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-warning')
|
||||
break;
|
||||
case 2:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-up"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-success')
|
||||
break;
|
||||
case 3:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-down"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-danger')
|
||||
break;
|
||||
default:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-left"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-warning')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function converRp(params) {
|
||||
return ('Rp. ' + params.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.') ?? 0);
|
||||
}
|
||||
</script>
|
||||
@endpush
|
|
@ -0,0 +1,284 @@
|
|||
@extends('layouts.base')
|
||||
|
||||
@section('content-header')
|
||||
<div class="col-12">
|
||||
<div class="container" style="display: contents">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0"> Dashboard</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item active">Dashboard</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card card-info card-outline" id="calculationPendapatan">
|
||||
{{-- <div class="card-header">
|
||||
<h5 class="card-title">Laporan Pendapatan dan Pengeluaran</h5>
|
||||
</div> --}}
|
||||
<!-- /.card-header -->
|
||||
|
||||
<!-- ./card-body -->
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="description-block border-left border-right">
|
||||
<span>
|
||||
<span class="description-percentage" id="penjualanHaripercentageOfSalesGrowth">
|
||||
</span>
|
||||
<small>Dari hari kemarin</small>
|
||||
</span>
|
||||
<h5 class="description-header" id="penjualanHari"></h5>
|
||||
<span class="description-text">Penjualan Hari ini</span>
|
||||
</div>
|
||||
<!-- /.description-block -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="description-block border-right">
|
||||
<span>
|
||||
<span class="description-percentage" id="penjualanMinggupercentageOfSalesGrowth">
|
||||
</span>
|
||||
<small>Dari minggu kemarin</small>
|
||||
</span>
|
||||
<h5 class="description-header" id="penjualanMinggu"></h5>
|
||||
<span class="description-text">Penjualan Minggu ini</span>
|
||||
</div>
|
||||
<!-- /.description-block -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="description-block border-right">
|
||||
<span>
|
||||
<span class="description-percentage" id="penjualanBulanpercentageOfSalesGrowth">
|
||||
</span>
|
||||
<small>Dari bulan kemarin</small>
|
||||
</span>
|
||||
<h5 class="description-header" id="penjualanBulan"></h5>
|
||||
<span class="description-text">Penjualan Bulan ini</span>
|
||||
</div>
|
||||
<!-- /.description-block -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /.card-footer -->
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<!-- /.card -->
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h3 class="card-title">Penjualan per Minggu</h3>
|
||||
{{-- <a href="javascript:void(0);">View Report</a> --}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
<p class="d-flex flex-column">
|
||||
<span class="text-bold text-lg" id="penjualanWeek"></span>
|
||||
<span>Penjualan Keseluruhan Minggu ini</span>
|
||||
</p>
|
||||
<p class="ml-auto d-flex flex-column text-right">
|
||||
<span id="persentaseWeek">
|
||||
</span>
|
||||
<span class="text-muted">dari minggu lalu</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.d-flex -->
|
||||
|
||||
<div class="position-relative mb-4">
|
||||
<canvas id="sales-chart-week" height="200"></canvas>
|
||||
</div>
|
||||
|
||||
{{-- <div class="d-flex flex-row justify-content-end">
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-square text-primary"></i> minggu ini
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<i class="fas fa-square text-gray"></i> minggu Kemarin
|
||||
</span>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col-md-6 -->
|
||||
<div class="col-lg-6">
|
||||
<!-- /.card -->
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h3 class="card-title">Penjualan per Bulan</h3>
|
||||
{{-- <a href="javascript:void(0);">View Report</a> --}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
<p class="d-flex flex-column">
|
||||
<span class="text-bold text-lg" id="penjualanMonth"></span>
|
||||
<span>Penjualan Keseluruhan Bulan ini</span>
|
||||
</p>
|
||||
<p class="ml-auto d-flex flex-column text-right">
|
||||
<span id="persentaseMonth">
|
||||
</span>
|
||||
<span class="text-muted">dari bulan lalu</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.d-flex -->
|
||||
|
||||
<div class="position-relative mb-4">
|
||||
<canvas id="sales-chart-month" height="200"></canvas>
|
||||
</div>
|
||||
|
||||
{{-- <div class="d-flex flex-row justify-content-end">
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-square text-primary"></i> Bulan ini
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<i class="fas fa-square text-gray"></i> Bulan Kemarin
|
||||
</span>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col-md-6 -->
|
||||
<div class="col-lg-12">
|
||||
<!-- /.card -->
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h3 class="card-title">Penjualan per Tahun</h3>
|
||||
{{-- <a href="javascript:void(0);">View Report</a> --}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
<p class="d-flex flex-column">
|
||||
<span class="text-bold text-lg" id="penjualanYear"></span>
|
||||
<span>Penjualan Keseluruhan Tahun ini</span>
|
||||
</p>
|
||||
<p class="ml-auto d-flex flex-column text-right">
|
||||
<span id="persentaseYear">
|
||||
</span>
|
||||
<span class="text-muted">dari tahun lalu</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.d-flex -->
|
||||
|
||||
<div class="position-relative mb-4">
|
||||
<canvas id="sales-chart-year" height="200"></canvas>
|
||||
</div>
|
||||
|
||||
{{-- <div class="d-flex flex-row justify-content-end">
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-square text-primary"></i> Tahun ini
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<i class="fas fa-square text-gray"></i> Tahun Kemarin
|
||||
</span>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col-md-6 -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /.container-fluid -->
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<h3 class="card-title">Makanan Terlaris</h3>
|
||||
<div class="card-tools">
|
||||
<a href="#" class="btn btn-tool btn-sm">
|
||||
<i class="fas fa-download"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-tool btn-sm">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body table-responsive p-0">
|
||||
<table class="table table-striped table-valign-middle" id="table-terlaris">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Menu</th>
|
||||
<th>Harga</th>
|
||||
<th>Terjual</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
<!-- /.col-md-6 -->
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<h3 class="card-title">Minuman Terlaris</h3>
|
||||
<div class="card-tools">
|
||||
<a href="#" class="btn btn-tool btn-sm">
|
||||
<i class="fas fa-download"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-tool btn-sm">
|
||||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body table-responsive p-0">
|
||||
<table class="table table-striped table-valign-middle" id="table-minuman-terlaris">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Menu</th>
|
||||
<th>Harga</th>
|
||||
<th>Terjual</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
<!-- /.col-md-6 -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /.container-fluid -->
|
||||
</div>
|
||||
<!-- /.content -->
|
||||
@endsection
|
||||
|
||||
@push('styles')
|
||||
<link rel="stylesheet" href="{{ asset('assets/datatables/datatables.min.css') }} ">
|
||||
@endpush
|
||||
|
||||
@include('pages.admin.dashboard.js')
|
|
@ -0,0 +1,418 @@
|
|||
@push('scripts')
|
||||
<script src="{{ asset('assets/datatables/datatables.min.js') }}"></script>
|
||||
<!-- ChartJS -->
|
||||
<script src="{{ asset('assets/plugins/chart.js/Chart.min.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
'use strict'
|
||||
|
||||
var ticksStyle = {
|
||||
fontColor: '#495057',
|
||||
fontStyle: 'bold'
|
||||
}
|
||||
|
||||
var mode = 'index'
|
||||
var intersect = true
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('dashboard.getChartWeek') }}",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(response) {
|
||||
var data = response.data;
|
||||
$('#penjualanWeek').append(converRp(data.grandTotalThisWeek));
|
||||
changeDataFromCalculateChart('persentaseWeek', data
|
||||
.percentageOfSalesGrowth,
|
||||
data.statusCalculation)
|
||||
var $salesChart = $('#sales-chart-week')
|
||||
var salesChart = new Chart($salesChart, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: Object.keys(data.thisWeek),
|
||||
datasets: [{
|
||||
backgroundColor: '#007bff',
|
||||
borderColor: '#007bff',
|
||||
data: Object.values(data.thisWeek)
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
maintainAspectRatio: false,
|
||||
tooltips: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
hover: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
// display: false,
|
||||
gridLines: {
|
||||
display: true,
|
||||
lineWidth: '4px',
|
||||
color: 'rgba(0, 0, 0, .2)',
|
||||
zeroLineColor: 'transparent'
|
||||
},
|
||||
ticks: $.extend({
|
||||
beginAtZero: true,
|
||||
// Include a dollar sign in the ticks
|
||||
callback: function(value, index,
|
||||
values) {
|
||||
return converRp(value)
|
||||
}
|
||||
}, ticksStyle)
|
||||
}],
|
||||
xAxes: [{
|
||||
display: true,
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: ticksStyle
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
error: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$(function() {
|
||||
'use strict'
|
||||
|
||||
var ticksStyle = {
|
||||
fontColor: '#495057',
|
||||
fontStyle: 'bold'
|
||||
}
|
||||
|
||||
var mode = 'index'
|
||||
var intersect = true
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('dashboard.getChartMonth') }}",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(response) {
|
||||
var data = response.data;
|
||||
$('#penjualanMonth').append(converRp(data.grandTotalThisMonth));
|
||||
changeDataFromCalculateChart('persentaseMonth', data
|
||||
.percentageOfSalesGrowth,
|
||||
data.statusCalculation)
|
||||
var $salesChart = $('#sales-chart-month')
|
||||
var salesChart = new Chart($salesChart, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: Object.keys(data.weekThisMonth),
|
||||
datasets: [{
|
||||
backgroundColor: '#007bff',
|
||||
borderColor: '#007bff',
|
||||
data: Object.values(data.weekThisMonth)
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
maintainAspectRatio: false,
|
||||
tooltips: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
hover: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
// display: false,
|
||||
gridLines: {
|
||||
display: true,
|
||||
lineWidth: '4px',
|
||||
color: 'rgba(0, 0, 0, .2)',
|
||||
zeroLineColor: 'transparent'
|
||||
},
|
||||
ticks: $.extend({
|
||||
beginAtZero: true,
|
||||
// Include a dollar sign in the ticks
|
||||
callback: function(value, index,
|
||||
values) {
|
||||
return converRp(value)
|
||||
}
|
||||
}, ticksStyle)
|
||||
}],
|
||||
xAxes: [{
|
||||
display: true,
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: ticksStyle
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
error: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$(function() {
|
||||
'use strict'
|
||||
|
||||
var ticksStyle = {
|
||||
fontColor: '#495057',
|
||||
fontStyle: 'bold'
|
||||
}
|
||||
|
||||
var mode = 'index'
|
||||
var intersect = true
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('dashboard.getChartYear') }}",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(response) {
|
||||
var data = response.data;
|
||||
// console.log(data);
|
||||
$('#penjualanYear').append(converRp(data.grandTotalThisYear));
|
||||
changeDataFromCalculateChart('persentaseYear', data
|
||||
.percentageOfSalesGrowth,
|
||||
data.statusCalculation)
|
||||
var $salesChart = $('#sales-chart-year')
|
||||
var salesChart = new Chart($salesChart, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: Object.keys(data.monthThisYear),
|
||||
datasets: [{
|
||||
backgroundColor: '#007bff',
|
||||
borderColor: '#007bff',
|
||||
data: Object.values(data.monthThisYear)
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
maintainAspectRatio: false,
|
||||
tooltips: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
hover: {
|
||||
mode: mode,
|
||||
intersect: intersect
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
// display: false,
|
||||
gridLines: {
|
||||
display: true,
|
||||
lineWidth: '4px',
|
||||
color: 'rgba(0, 0, 0, .2)',
|
||||
zeroLineColor: 'transparent'
|
||||
},
|
||||
ticks: $.extend({
|
||||
beginAtZero: true,
|
||||
// Include a dollar sign in the ticks
|
||||
callback: function(value, index,
|
||||
values) {
|
||||
return converRp(value)
|
||||
}
|
||||
}, ticksStyle)
|
||||
}],
|
||||
xAxes: [{
|
||||
display: true,
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: ticksStyle
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
error: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#table-terlaris').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
searching: false,
|
||||
"bLengthChange": false,
|
||||
"bFilter": true,
|
||||
"bInfo": false,
|
||||
ajax: "{{ route('dashboard.menuTerlaris') }}",
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'nama_produk',
|
||||
name: 'nama_produk'
|
||||
},
|
||||
{
|
||||
data: 'harga_produk',
|
||||
name: 'harga_produk',
|
||||
'render': function(data, type, full, meta) {
|
||||
// change to IDR
|
||||
return 'Rp. ' + data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
},
|
||||
className: 'text-right'
|
||||
},
|
||||
{
|
||||
data: 'jumlah_produk_terjual',
|
||||
name: 'jumlah_produk_terjual'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#table-minuman-terlaris').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
searching: false,
|
||||
"bLengthChange": false,
|
||||
"bFilter": true,
|
||||
"bInfo": false,
|
||||
ajax: "{{ route('dashboard.minumanTerlaris') }}",
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'nama_produk',
|
||||
name: 'nama_produk'
|
||||
},
|
||||
{
|
||||
data: 'harga_produk',
|
||||
name: 'harga_produk',
|
||||
'render': function(data, type, full, meta) {
|
||||
// change to IDR
|
||||
return 'Rp. ' + data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
},
|
||||
className: 'text-right'
|
||||
},
|
||||
{
|
||||
data: 'jumlah_produk_terjual',
|
||||
name: 'jumlah_produk_terjual'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
$(document).ready(function() {
|
||||
getCalculationPendapatan();
|
||||
})
|
||||
|
||||
function getCalculationPendapatan() {
|
||||
$.ajax({
|
||||
url: "{{ route('dashboard.getCalculationPendapatan') }}",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(response) {
|
||||
var data = response.data;
|
||||
console.log(data);
|
||||
changeDataFromCalculate('penjualanBulan', data.pendapatanBulan
|
||||
.penjualanSatuBulan, data.pendapatanBulan.percentageOfSalesGrowth,
|
||||
data.pendapatanBulan.statusCalculation)
|
||||
changeDataFromCalculate('penjualanMinggu', data.pendapatanMinggu
|
||||
.penjualanSatuMinggu, data.pendapatanMinggu.percentageOfSalesGrowth,
|
||||
data.pendapatanMinggu.statusCalculation)
|
||||
changeDataFromCalculate('penjualanHari', data.pendapatanHari
|
||||
.penjualanHariIni, data.pendapatanHari.percentageOfSalesGrowth,
|
||||
data.pendapatanHari.statusCalculation)
|
||||
},
|
||||
error: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function changeDataFromCalculate(id, penjualanSatuBulan, percentageOfSalesGrowth, statusCalculation) {
|
||||
// change to IDR
|
||||
if (penjualanSatuBulan == null) {
|
||||
penjualanSatuBulan = 0;
|
||||
} else {
|
||||
penjualanSatuBulan;
|
||||
}
|
||||
|
||||
$('#' + id).append(converRp(penjualanSatuBulan));
|
||||
|
||||
// pembulatan 2 angka di belakang koma
|
||||
percentageOfSalesGrowth = percentageOfSalesGrowth.toFixed(2);
|
||||
switch (statusCalculation) {
|
||||
case 1:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-left"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-warning')
|
||||
break;
|
||||
case 2:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-up"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-success')
|
||||
break;
|
||||
case 3:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-down"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-danger')
|
||||
break;
|
||||
default:
|
||||
$('#' + id + 'percentageOfSalesGrowth').append('<i class="fas fa-caret-left"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id + 'percentageOfSalesGrowth').addClass('text-warning')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function changeDataFromCalculateChart(id, percentageOfSalesGrowth, statusCalculation) {
|
||||
// pembulatan 2 angka di belakang koma
|
||||
percentageOfSalesGrowth = percentageOfSalesGrowth.toFixed(2);
|
||||
switch (statusCalculation) {
|
||||
case 1:
|
||||
$('#' + id).append('<i class="fas fa-arrow-left"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id).addClass('text-warning')
|
||||
break;
|
||||
case 2:
|
||||
$('#' + id).append('<i class="fas fa-arrow-up"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id).addClass('text-success')
|
||||
break;
|
||||
case 3:
|
||||
$('#' + id).append('<i class="fas fa-arrow-down"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id).addClass('text-danger')
|
||||
break;
|
||||
default:
|
||||
$('#' + id).append('<i class="fas fa-arrow-left"></i> ' +
|
||||
percentageOfSalesGrowth + '%')
|
||||
$('#' + id).addClass('text-warning')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function converRp(params) {
|
||||
return ('Rp. ' + params.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.') ?? 0);
|
||||
}
|
||||
</script>
|
||||
@endpush
|
|
@ -135,7 +135,6 @@
|
|||
<th>Faktur</th>
|
||||
<th>Kebutuhan</th>
|
||||
<th>Jenis Transaksi</th>
|
||||
<th>Jenis Transaksi</th>
|
||||
<th>Tanggal Transaksi</th>
|
||||
<th>User</th>
|
||||
<th>Nominal</th>
|
||||
|
@ -159,7 +158,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('pages.admin.pengeluaran.js')
|
||||
@include('pages.admin.pengeluaran.style')
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
],
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
|
||||
ajax: {
|
||||
url: '{{ route('pengeluaran.getDataPengeluaran') }}',
|
||||
data: function(d) {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
@push('styles')
|
||||
<!-- Toastr -->
|
||||
<style>
|
||||
@media only screen and (max-width : 991px) {
|
||||
/* Styles */
|
||||
}
|
||||
|
||||
@media only screen and (max-width : 768px) {
|
||||
/* Styles */
|
||||
}
|
||||
|
||||
@media only screen and (max-width : 414px) {
|
||||
/* Styles */
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ asset('assets/plugins/toastr/toastr.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('assets/datatables/datatables.min.css') }}">
|
||||
@endpush
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Admins\DashboardController;
|
||||
use App\Http\Controllers\Admins\Dashboard\CalculationController;
|
||||
use App\Http\Controllers\Admins\Dashboard\ChartPengeluaranController;
|
||||
use App\Http\Controllers\Admins\Dashboard\ChartPenjualanController;
|
||||
use App\Http\Controllers\Admins\Dashboard\DashboardController;
|
||||
use App\Http\Controllers\Admins\Pengeluaran\PengeluaranController;
|
||||
use App\Http\Controllers\Admins\Users\RoleController;
|
||||
use App\Http\Controllers\Admins\Users\UserController;
|
||||
|
@ -64,8 +67,12 @@ Route::group(['middleware' => ['auth', 'permission']], function () {
|
|||
Route::group(['prefix' => 'dashboard'], function () {
|
||||
Route::get('/', [DashboardController::class, 'index'])->name('dashboard.index')->comment('Halaman Dashboard');
|
||||
Route::get('/menuTerlaris', [DashboardController::class, 'menuTerlaris'])->name('dashboard.menuTerlaris')->comment("Ambil data Menu Terlaris");
|
||||
Route::get('/getCalculationPendapatan', [DashboardController::class, 'getCalculationPendapatan'])->name('dashboard.getCalculationPendapatan')->comment("Ambil data Total Penjualan");
|
||||
Route::get('/getChart', [DashboardController::class, 'getChart'])->name('dashboard.getChart')->comment("Ambil data Total Penjualan");
|
||||
Route::get('/minumanTerlaris', [DashboardController::class, 'minumanTerlaris'])->name('dashboard.minumanTerlaris')->comment("Ambil data Minuman Terlaris");
|
||||
Route::get('/getCalculationPendapatan', [CalculationController::class, 'getCalculationPendapatan'])->name('dashboard.getCalculationPendapatan')->comment("Ambil data Total Penjualan");
|
||||
Route::get('/getChartWeek', [ChartPenjualanController::class, 'getChartWeek'])->name('dashboard.getChartWeek')->comment("Ambil data Total Penjualan per Minggu");
|
||||
Route::get('/getChartMonth', [ChartPenjualanController::class, 'getChartMonth'])->name('dashboard.getChartMonth')->comment("Ambil data Total Penjualan per Bulan");
|
||||
Route::get('/getChartYear', [ChartPenjualanController::class, 'getChartYear'])->name('dashboard.getChartYear')->comment("Ambil data Total Penjualan per Tahun");
|
||||
Route::get('/getChartPengeluaran', [ChartPengeluaranController::class, 'getChartPengeluaran'])->name('dashboard.getChartPengeluaran')->comment("Ambil data Total Pengeluaran");
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue