403Webshell
Server IP : 139.59.63.204  /  Your IP : 216.73.217.62
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu-s-1vcpu-1gb-blr1-01 6.8.0-110-generic #110-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 15:09:20 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/app/Http/Controllers/ReportController.php
<?php

namespace App\Http\Controllers;

use App\Exports\InvoiceReportExport;
use App\Exports\ProductReportExport;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Http\Request;
use App\Models\Invoice;
use App\Models\Product;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use Auth;
use DataTables;

class ReportController extends Controller
{
    public function invoicesList(Request $request)
    {  
        $cust_ids = Arr::flatten(Auth::user()->customer->toArray());
        $today = Carbon::now()->format('Y-m-d');
        $date  = $today.' - '.$today;
        //\DB::enableQueryLog();
        $query = Invoice::query();
        $query->whereIn('customer_id',$cust_ids)->where('type',1);

         if (!empty($request->date)) {             
         $brokenDate = explode(' - ', $request->date);
         $startDate = $brokenDate[0];
         $endDate = $brokenDate[1];
         $date = $request->date;
        
         if($startDate == $endDate){
             $invoices =  $query->whereDate('created_at', $startDate);
         }
         else{
             $invoices =  $query->whereDate('created_at','>=', $startDate)->whereDate('created_at','<=',$endDate);
         }
        
        // return view('report.invoice',compact('invoices','date'));
         }
         else if($request->data =="last")
         {
          
             $start = Carbon::now()->startOfMonth()->subMonthsNoOverflow()->toDateString();
 
             $end = Carbon::now()->subMonthsNoOverflow()->endOfMonth()->toDateString();
             $date = $start.' - '.$end;
             $invoices =  $query->whereDate('created_at','>=', $start)->whereDate('created_at','<=', $end);
       
            
         }
         else if($request->data =="current")
         {
          
             $start = Carbon::now()->startOfMonth()->toDateString();;
             $end = Carbon::now()->toDateString();;
             $date = $start.' - '.$end;
             $invoices =  $query->whereDate('created_at','>=', $start)->whereDate('created_at','<=', $end); 
           
            }
        else{
         
         $invoices =  $query->whereDate('created_at', $today);
        }
      
       
        if ($request->ajax()) {    
           // return response()->json(['msg'=> $request->data ]);
            return DataTables::of($invoices)
            ->addIndexColumn()
            ->addColumn('customer_name', function ($invoice) {
               return  (!empty($invoice->customers->firstname))?$invoice->customers->firstname.' '.$invoice->customers->lastname :'-';
                
            })
            ->addColumn('p_name', function ($invoice) {
                $arr =[];
                if(!empty($invoice->lineItem)){
                foreach($invoice->lineItem as $item)
                {
                    $arr[] =!empty( $item->product->name)?$item->product->name:'-';
                }
               return implode(', ', $arr);
                 }
                 return "-";
            })
            ->addColumn('date', function($invoice){
                return $invoice->created_at->format('M d Y');
            })
            ->make(true);
            
          }
       
       
       // \DB::enableQueryLog();
     
        
       
            return view('report.invoice',compact('date'));  
    }
    public function export($date) 
    {
        return Excel::download(new InvoiceReportExport($date), 'invoices.xlsx');
    }

    public function lowInventoryProd(Request $request)
    {
       
        if ($request->ajax()) {    
            $products = Product::where(['status'=>1,'posted_by'=> auth()->id()])->where('qty','>=',0)->where('qty','<=',5)->orderBy('id','desc');

             return DataTables::of($products)
             ->addIndexColumn()
             ->addColumn('date', function($product){
                 return $product->created_at->format('M d Y');
             })
             ->make(true);
             
           }
        return view('report.low_inventory');
    }
    public function exportProduct() 
    {
        return Excel::download(new ProductReportExport, 'lowInventoryProducts.xlsx');
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit