VaKeR CYBER ARMY
Logo of a company Server : Apache
System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User : vapecompany ( 2719)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Backend/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Backend/Dashboard.php
<?php

namespace App\Http\Controllers;
use App\Models\Requisition;
use App\Models\Chalan;
use App\Models\ChalanDetails;
use App\Models\Product;
use App\Models\Division;
use App\Models\Category;
use App\Models\SalesTarget;
use Illuminate\Http\Request;
use DB;
use Carbon\Carbon;

class Dashboard extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
       
    }
    public function index(){
        $lastDayOfMonth=Carbon::now('Asia/dhaka')->endOfMonth()->day;
        //$lastDayOfWeek=Carbon::now()->subDays(7)->day;
        $start_date_week=Carbon::now('Asia/dhaka')->subDays(7)->format('Y-m-d');
        $end_date_week=Carbon::now('Asia/dhaka')->format('Y-m-d');
        $start_date_month=Carbon::now('Asia/dhaka')->firstOfMonth()->format('Y-m-d');
        $end_date_month=Carbon::now('Asia/dhaka')->endOfMonth()->format('Y-m-d');
        if(auth()->user()->employee->user_type == 3){
            $month=Carbon::now('Asia/dhaka')->year*100+Carbon::now('Asia/dhaka')->month;
            $sales_target = SalesTarget::Where('month',$month)->where('employee_id',auth()->user()->employee->employee_id)->first();
            $requsitions = Requisition::where('sales_by',auth()->user()->user_id)->whereBetween('requisition_date', [$start_date_month, $end_date_month])->get();
            return view('saleman_dashboard',['sales'=>$sales_target,'requisitions'=>$requsitions]);

        }  
        

        //dd(Carbon::now('Asia/dhaka')->subDays(29)->format('Y-m-d'));
       // dd($lastDayOfWeek);
       // dd(auth()->user());
         $total_pending=Requisition::where('requistion_status',1)->whereBetween('requisition_date', [$start_date_month, $end_date_month])->count();
        $total_requisition=Requisition::whereBetween('requisition_date', [$start_date_month, $end_date_month])->where('requistion_status','!=',0)->count();
        $total_chalan=Requisition::where('requistion_status',4)->whereBetween('requisition_date', [$start_date_month, $end_date_month])->count();

        $selldetailsmonth=ChalanDetails::select(DB::raw('SUM(product_quantity) as total_sales'),'product_id')->whereBetween('chalan_date', [$start_date_month, $end_date_month])->groupBy('product_id')->get();

        $selldetailsweek=ChalanDetails::select(DB::raw('SUM(product_quantity) as total_sales'),'product_id')->whereBetween('chalan_date', [$start_date_week, $end_date_week])->groupBy('product_id')->get();
        $selldetailsmonthly=ChalanDetails::select(DB::raw('SUM(product_quantity) as total_sales'),'product_id')->whereBetween('chalan_date', [date('Y-m-d'),date('Y-m-d')])->groupBy('product_id')->get(); 
        //dd($selldetailsmonthly);
    
        
        $divchalan=DB::table('divisions')
        ->select(DB::raw('sum(chalans.total_quantity) as quantity, divisions.division_name'))
        ->leftJoin('customers', 'divisions.division_id', '=', 'customers.division_id')
        ->leftJoin('chalans', 'chalans.customer_id', '=', 'customers.customer_id')
        ->whereBetween('chalan_date', [$start_date_month, $end_date_month])
       ->groupBy('divisions.division_name')
        ->get();
        $products =Product::get();
        $divisions = Division::where('status',1)->get();
        $categories = Category::where('status',1)->get();
        $month=Carbon::now('Asia/dhaka')->year*100+Carbon::now('Asia/dhaka')->month;
        $salestarget =SalesTarget::Where('month',$month)->get();
      
        

        // foreach(auth()->user()->getrole()->module_event->where('module_id',1)->where('status','!=',0) as $roleevent)
        // {
        //     print_r($roleevent->event->menu_position);
        // }
        
        //     dd(auth()->user()->getrole()->module_event->where('module_id',1)->where('status','!=',0));
        //   dd(auth()->user()->getrole()->module->where('status','!=',0));
        return view('dashboard',['total_requisition'=>$total_requisition,'total_chalan'=>$total_chalan,'divchalan'=>$divchalan,'total_pending'=>$total_pending,'products'=>$products,'selldetailsmonth'=>$selldetailsmonth,'selldetailsweek'=>$selldetailsweek,'lastDayOfMonth'=>$lastDayOfMonth,'selldetailsmonthly'=>$selldetailsmonthly,'start_date_month'=>$start_date_month,'end_date_month'=>$end_date_month,'salestarget'=>$salestarget,'divisions'=>$divisions,'categories'=>$categories]);
        
        
    }
    public function test(){
        return view('testview');
    }
}

VaKeR 2022