@extends('layout')
@section('title','Accueil ')
@section('description','Accueil')
@section('content')
<!-- Main Content -->
<br/>
            @php
    		$rr = DB::table('caisse_depense')->where('magasin_id', session('user')->magasin_id)->get()->count();
    		$mag = DB::table('magasin')->get();
    		$produit1=DB::table('produit_vendable')->where('categorie_id', 1)->get();
    		$tp10 = DB::table('ligne_vente')->where('categorie_id', 1)->sum('montligne');
    		$tp11 = DB::table('ligne_vente_client')->where('categorie_id', 1)->sum('montligne');
    		$tp1 = $tp10 + $tp11;
    		$sii = DB::table('versement_caisier')->where('cloture_id',0)->sum('montant');
    		
		
			//ACHATS FOURNISSEURS
				
				$approfini = DB::table('ligne_appro_vendable')->where('etat', 'Validée')->sum('montligne');
				$appromatiere = DB::table('ligne_appro_matiere')->where('etat', 'Validée')->sum('montligne');
				$retourappromatiere = DB::table('ligneretourappromatiere')->where('etat', 'Validée')->sum('montligne');
				$totmatiere = $appromatiere - $retourappromatiere;
				$approemballage = DB::table('ligne_appro_emballage')->where('etat', 'Validée')->sum('montligne');
				$retourapproemballage = DB::table('ligneretourapproemballage')->where('etat', 'Validée')->sum('montligne');
				$totemballage = $approemballage - $retourapproemballage;
				$totachatfou = $totmatiere + $totemballage + $approfini;
    		@endphp
		  @if (session('user')->roles == "Admin")
		  
          <div class="row" style="font-size:10px;">
            <div class="col-xl-12 col-lg-12">
					
					
            </div>
			
			 @foreach($mag as $mags)
			 
			  @php
			  
		    $tv = DB::table('vente')->where('etat','Validée')->where('magasin_id', $mags->id)->get()->count();
			   
			$remb = DB::table('remboursement')->where('etat1','Validée')->where('magasin_id', $mags->id)->where('vente_client_id', NULL)->get()->sum('montant');
            $mv = DB::table('vente')->where('etat','Validée')->where('magasin_id', $mags->id)->get()->sum('montant');  
            $mv1 = $mv - $remb;
            $mv1 =  number_format($mv1, 0, ' ', ' ');    
			   
			   $vf = DB::table('versement_caisier')->where('magasin_id', $mags->id)->get()->count();
			   
			   $tvers = DB::table('versement_caisier')->where('magasin_id', $mags->id)->get()->sum('mont_verse');
			   
			   $tvers1 =  number_format($tvers, 0, ' ', ' ');

               $ct = DB::table('solde')->where('magasin_id', $mags->id)->get()->count();
			   
				/*if ($ct>0){
					
				$solde = DB::table('solde')->where('magasin_id', $mags->id)->get()->last()->solde;
				$solde1 = DB::table('solde')->where('magasin_id', $mags->id)->get()->sum('montant');
				
				} else {
					
					$solde = 0;
					$solde1 = DB::table('solde')->where('magasin_id', $mags->id)->get()->sum('montant');
					
				}*/
				
				$cd = DB::table('caisse_depense')->where('magasin_id', $mags->id)->get()->count();
				
				/*if ($cd>0){
					
				$solded = DB::table('caisse_depense')->where('magasin_id', $mags->id)->get()->last()->solde_final;
				
				} else {
					
					$solded = 0;
					
				}   */
				$paiefou = DB::table('paiement_fou')->where('etat', 'Validée')->where('magasin_id', $mags->id)->get()->sum('montant');
				$soldeddd = DB::table('caisse_depense')->where('typeoperation', 'Débit')->where('nature','!=','Versement banque')->where('etat', 'Validée')->where('magasin_id', $mags->id)->get()->sum('montant');
				$solded = $paiefou + $soldeddd;
				$solde1 = DB::table('caisse_depense')->where('typeoperation', 'Crédit')->where('etat', 'Validée')->where('magasin_id', $mags->id)->get()->sum('montant');
				$caisserecette1 = DB::table('cloture')->where('magasin_id', $mags->id)->get()->sum('montant');
				$caisserecette = $caisserecette1;
				$restecaisse = ($solde1 + $caisserecette) - $soldeddd;
				$paiecli = DB::table('paiement_client')->where('magasin_id', $mags->id)->get()->sum('montant');
				$pc = DB::table('paiement_client')->where('magasin_id', $mags->id)->get()->sum('montant');
				$tt = date('Y-m-d');
                $tf = date_parse($tt);
        		$y = $tf['year'];
				 $si = DB::table('soldepaiment')
		                ->whereYear('date', '=', $y)
		                ->where('etat', 'Validée')
		                ->get()->count();
		         if ($si>0){
		         $sd = DB::table('soldepaiment')
		                ->whereYear('date', '=', $y)
		                ->where('etat', 'Validée')
		                ->sum('montant');
		         }else{
		            $sd = 0;
		         }
		         //$ta1 = DB::table('vente_client')->where('magasin_id', $mags->id)->where('etat','Validée')->get()->sum('montant');
		         $ta1 = DB::table('vente_client')->where('etat','Validée')->get()->sum('montant');
		         //$tr = DB::table('retourcommandeclient')->where('magasin_id', $mags->id)->where('etat','Validée')->get()->sum('montant');
		         $tr = DB::table('retourcommandeclient')->where('magasin_id', $mags->id)->where('etat','Validée')->get()->sum('montant');
		         $ta = ($ta1 + $sd) - $tr;
				$reste = $ta - $pc;
				
				
				
            @endphp
            <div class="col-xl-4 col-lg-4">
              <div class="card">
                <div class="card-body card-type-3">
                  <div class="row">
                    <div class="col">
                      <h6 class="text-muted mb-0"> <font color="red">{{ $mags->nom }} (Comptant)</font></h6>
					   <h6 class="text-muted mt-2 mb-0">Total ventes : <div class="badge badge-info badge-shadow">{{ $mv1 }} FCFA </div></h6>
					   <h6 class="text-muted mt-2 mb-0">Nombre de versement: <div class="badge badge-warning badge-shadow">{{ $vf }} </div></h6>
					   <h6 class="text-muted mt-2 mb-0">Total versement : <div class="badge badge-success badge-shadow">{{ $tvers1 }} FCFA </div></h6>
                    </div>
                  </div>
				   
                </div>
              </div>
            </div>
			<div class="col-xl-4 col-lg-4">
              <div class="card">
                <div class="card-body card-type-3">
                  <div class="row">
                    <div class="col">
                     <h6 class="text-muted mb-0"><font color="green">Ventes & Paiements crédits</font></h6>
                     <h6 class="text-muted mt-2 mb-0">Solde initial <div class="badge badge-info badge-shadow">{{ number_format($sd, 0, ' ', ' ') }} FCFA</div></h6>
                      <h6 class="text-muted mt-2 mb-0">Total à payer <div class="badge badge-info badge-shadow">{{ number_format($ta, 0, ' ', ' ') }} FCFA</div></h6>
					   <h6 class="text-muted mt-2 mb-0">Total paiement <div class="badge badge-success badge-shadow">{{ number_format($pc, 0, ' ', ' ') }} FCFA</div></h6>
					   <h6 class="text-muted mt-2 mb-0">Reste à payer <div class="badge badge-warning badge-shadow">{{ number_format($reste, 0, ' ', ' ') }} FCFA</div></h6>
                      <span class="font-weight-bold mb-0"></span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-xl-4 col-lg-6">
              <div class="card">
                <div class="card-body card-type-3">
                  <div class="row">
                    <div class="col">
					  <h6 class="text-muted mt-1 mb-0"> <font color="blue">Recettes & Dépenses </font></h6>
					  <h6 class="text-muted mt-1 mb-0">Entrée/Appro caisse <span class="text-nowrap"><div class="badge badge-info badge-shadow"> {{ number_format($solde1, 0, ' ', ' ') }}</div></span></h6>
					  <h6 class="text-muted mt-1 mb-0">Total recette<div class="badge badge-primary badge-shadow"> {{ number_format($caisserecette1, 0, ' ', ' ') }}</div></span></h6>
					
					  <h6 class="text-muted mt-1 mb-0">Solde restant<div class="badge badge-info badge-shadow"> {{ number_format($caisserecette, 0, ' ', ' ') }}</div></span></h6>
					  <h6 class="text-muted mt-1 mb-0">Total dépenses <span class="text-nowrap"><div class="badge badge-danger badge-shadow"> {{ number_format($soldeddd, 0, ' ', ' ') }}</div></span></h6>
					  <h6 class="text-muted mt-1 mb-0" hidden>Achats fourn. <span class="text-nowrap"><div class="badge badge-danger badge-shadow"> {{ number_format($totachatfou, 0, ' ', ' ') }}</div></span></h6>
					  <h6 class="text-muted mt-1 mb-0" hidden>Paiement fourn. <span class="text-nowrap"><div class="badge badge-info badge-shadow"> {{ number_format($paiefou, 0, ' ', ' ') }}</div></span></h6>
                      
                      <h6 class="text-muted mt-1 mb-0">Solde caisse dépense<div class="badge badge-success badge-shadow"> {{ number_format($restecaisse, 0, ' ', ' ') }}</div></span></h6>
                      <span class="font-weight-bold mb-0"></span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
			<div class="col-xl-4 col-lg-6" hidden>
              <div class="card">
                <div class="card-body card-type-3">
                  <div class="row">
                    <div class="col">
                      <h6 class="text-muted mb-0"> <font color="red">Achats fournisseurs</font></h6>
					   <h6 class="text-muted mt-3 mb-0">Produit fini : <div class="badge badge-primary badge-shadow">{{ number_format($approfini, 0, ' ', ' ') }} </div></h6>
					   <h6 class="text-muted mt-3 mb-0">Matière première : <div class="badge badge-info badge-shadow">{{ number_format($totmatiere, 0, ' ', ' ') }}  </div></h6>
					   <h6 class="text-muted mt-3 mb-0">Emballage : <div class="badge badge-warning badge-shadow">{{ number_format($totemballage, 0, ' ', ' ') }} </div></h6>
					   <h6 class="text-muted mt-3 mb-0">Total achats : <div class="badge badge-success badge-shadow">{{ number_format($totachatfou, 0, ' ', ' ') }}  </div></h6>
					   
                      <span class="font-weight-bold mb-0"></span>
                    </div>
                    
                  </div>
				   
                </div>
              </div>
            </div>
			@endforeach
			</div>
				@php
				$b1 = DB::table('ligne_vente')->where('etat','Validée')->sum('benef');
				$b2 = DB::table('ligne_vente_client')->where('etat','Validée')->sum('benef');
				$r1 = DB::table('ligneretourcommande')->where('etat','Validée')->sum('benef');
				$r2 = DB::table('ligneretourcommandeclient')->where('etat','Validée')->sum('benef');
				$remiz1 = DB::table('vente')->where('etat','Validée')->sum('remise');
				$remiz2 = DB::table('vente_client')->where('etat','Validée')->sum('remise');
				$mois_annee = date('Y-m');

				$mois_moins_un=  (new \Carbon\Carbon(date('Y-m-d')))->subMonth();
				$mois_moins_un=  date('Y-m', strtotime($mois_moins_un));
				
				$b11 = DB::table('ligne_vente')->where('date', 'like',  $mois_moins_un.'%')->where('etat','Validée')->sum('benef');
				$b22 = DB::table('ligne_vente_client')->where('date', 'like',  $mois_moins_un.'%')->where('etat','Validée')->sum('benef');
				$r11 = DB::table('ligneretourcommande')->where('date', 'like',  $mois_moins_un.'%')->where('etat','Validée')->sum('benef');
				$r22 = DB::table('ligneretourcommandeclient')->where('date', 'like',  $mois_moins_un.'%')->where('etat','Validée')->sum('benef');
				$remiz11 = DB::table('vente')->where('date', 'like',  $mois_moins_un.'%')->where('etat','Validée')->sum('remise');
				$remiz22 = DB::table('vente_client')->where('date', 'like',  $mois_moins_un.'%')->where('etat','Validée')->sum('remise');
				$c = ($b11 + $b22) - ($r11 + $r22 + $remiz11 + $remiz22);
				
				$c11 = DB::table('ligne_vente')->where('date', 'like',  $mois_annee.'%')->where('etat','Validée')->sum('benef');
				$c22 = DB::table('ligne_vente_client')->where('date', 'like',  $mois_annee.'%')->where('etat','Validée')->sum('benef');
				$r111 = DB::table('ligneretourcommande')->where('date', 'like',  $mois_annee.'%')->where('etat','Validée')->sum('benef');
				$r222 = DB::table('ligneretourcommandeclient')->where('date', 'like',  $mois_annee.'%')->where('etat','Validée')->sum('benef');
				$remiz111 = DB::table('vente')->where('date', 'like',  $mois_annee.'%')->where('etat','Validée')->sum('remise');
				$remiz222 = DB::table('vente_client')->where('date', 'like',  $mois_annee.'%')->where('etat','Validée')->sum('remise');
				
				
				
				$d = ($c11 + $c22) - ($r111 + $r222 + $remiz111 + $remiz222);
				//PRODUITS LES PLUS VENDDUS
				$pro = DB::table('produit_vendable')->where('totvendu','>',0)->orderBydesc('totvendu')->take(10)->get();
				$promax = DB::table('produit_vendable')->orderBydesc('totvendu')->take(10)->sum('totvendu');
				
				//PRODUITS MOINS VENDUS
				$pro2 = DB::table('produit_vendable')->where('totvendu','>', 0)->orderBy('totvendu','asc')->take(10)->get();
				$promax2 = DB::table('produit_vendable')->orderBy('totvendu','asc')->take(10)->get();
				
				//PRODUITS JAMAIS VENDUS
				$pro3 = DB::table('produit_vendable')->where('totvendu', 0)->take(10)->get();
				$promax3 = DB::table('produit_vendable')->where('totvendu',0)->take(10)->get();
				
				$b = ($b1 + $b2) - ($r1 + $r2 + $remiz1 + $remiz2);
			  @endphp
			<div class="row" style="font-size:10px;">
			<div class="col-lg-7 col-md-7 col-sm-12 col-xs-12 col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Statistiques mens.
					</h4>
					<p style="margin-top:15px;font-size:14px;"> Bénéfice mois en cours : <font color="red">{{number_format($d, 0, ' ', ' ')}}</font> / 
					Bénéfice mois dernier : <font color="red">{{number_format($c, 0, ' ', ' ')}}</font></p>
                  </div>
                  <div class="card-body">
                    <div class="recent-report__chart">
                      <div id="chart1"></div>
                    </div>
                  </div>
                </div>
            </div>
			<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Statistiques globales</h4>
					<p style="margin-top:15px;font-size:14px;"> <b>Total revenue réalisé : <font color="red">{{number_format($b, 0, ' ', ' ')}}</font></b></p>
                  </div>
                  <div class="card-body">
                    <div class="recent-report__chart">
                      <div id="chart22"></div>
                    </div>
                    </div>
					
                  </div>
                </div>
            </div>
         
			<div class="row" style="font-size:10px;">
			<div class="col-lg-4 col-md-4 col-12 col-sm-12">
              <div class="card">
			  
                <div class="card-header">
                  <h4 style="color:green;text-align:center">Les plus vendus</h4>
                </div>
				
                <div class="card-body">
                  <h5 class="card-title" style="text-align:center"> 10 derniers </h5>
                  @foreach($pro as $pros)
				  @php
				  $maxc = DB::table('stock_magasin')->where('produit_id', $pros->id)->get()->count();
				  if ($maxc == 0){
					  $max = 0;
				  } else {
						$max = DB::table('stock_magasin')->where('produit_id', $pros->id)->orderBydesc('id')->take(1)->first()->apres;
				  }
				  if ($pros->stock_mini >= $max){
					$tx = "red";
				  } else {
					$tx = "#6c757d";
				  }
				  @endphp
				  <div class="m-b-20">
                    <div class="text-small float-right font-weight-bold text-muted">{{$pros->totvendu}}</div>
                    <div class="font-weight-bold" style="color:{{$tx}}">{{$pros->designation}}</div>
                    <div class="progress" data-height="5">
                      <div class="progress-bar l-bg-green" role="progressbar" data-width="{{$pros->totvendu}}%" aria-valuenow="{{$pros->totvendu}}"
                        aria-valuemin="0" aria-valuemax="{{$promax}}"></div>
                    </div>
                  </div>
				  @endforeach
                </div>
              </div>
            </div>
            <div class="col-lg-4 col-md-4 col-12 col-sm-12">
			<div class="card">
			<div class="card-header">
                  <h4 style="color:blue;text-align:center">Produits moins vendus</h4>
                </div>
				<div class="card-body">
				<h5 class="card-title" style="text-align:center"> 10 derniers </h5>
                  @foreach($pro2 as $pro2s)
				  <div class="m-b-20">
                    <div class="text-small float-right font-weight-bold text-muted">{{$pro2s->totvendu}}</div>
                    <div class="font-weight-bold">{{$pro2s->designation}}</div>
                    <div class="progress" data-height="5">
                      <div class="progress-bar l-bg-red" role="progressbar" data-width="{{$pro2s->totvendu}}%" aria-valuenow="{{$pro2s->totvendu}}"
                        aria-valuemin="0" aria-valuemax="{{$promax2}}"></div>
                    </div>
                  </div>
				  @endforeach
            </div>
            </div>
            </div>
			<div class="col-lg-4 col-md-4 col-12 col-sm-12">
			<div class="card">
			<div class="card-header">
                  <h4 style="color:red;text-align:center">Produits jamais vendus</h4>
                </div>
				<div class="card-body">
				<h5 class="card-title" style="text-align:center"> 10 derniers </h5>
                  @foreach($pro3 as $pro3s)
				  <div class="m-b-20">
                    <div class="text-small float-right font-weight-bold text-muted">{{$pro3s->totvendu}}</div>
                    <div class="font-weight-bold">{{$pro3s->designation}}</div>
                    <div class="progress" data-height="5">
                      <div class="progress-bar l-bg-red" role="progressbar" data-width="{{$pro3s->totvendu}}%" aria-valuenow="{{$pro3s->totvendu}}"
                        aria-valuemin="0" aria-valuemax="{{$promax3}}"></div>
                    </div>
                  </div>
				  @endforeach
            </div>
            </div>
            </div>
            </div>
           
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			
		@elseif (session('user')->roles == "Gérant")

		  
		@else
			
		<div class="row" style="font-size:10px;">
            <div class="col-xl-12 col-lg-12">
					@php
					$rr = DB::table('caisse_depense')->where('magasin_id', session('user')->magasin_id)->get()->count();
					@endphp
					@if($rr==0)
					<div class='alert alert-danger' role='alert' style='font-size:18px;text-align:center;opacity:0.5' hidden>
						<i class='ti-na'></i><a href="{{route('caisse')}}">La caisse dépense est vide, veuillez approvisionner avant toutes opérations s'il vous plaît !</a>
					</div>
					@endif
					
            </div>
		
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
			<br/>
          </div>
			
	    @endif
		@push('scripts')
	<script>
	$(function () {
    chart1();
	});

function chart1(){
	 var options = {
			@php
		$today = date('Y-m-d');
		$df = date_parse($today);
		$annee = $df['year'];
		$a= $annee;
		//LES VENTES
		$v1 = DB::table('vente')->where('date', 'like',  '%'.$a."-01".'%')->where('etat','Validée')->sum('montant');
		$v2 = DB::table('vente')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('montant');
		$v3 = DB::table('vente')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('montant');
		$v4 = DB::table('vente')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('montant');
		$v5 = DB::table('vente')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('montant');
		$v6 = DB::table('vente')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('montant');
		$v7 = DB::table('vente')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('montant');
		$v8 = DB::table('vente')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('montant');
		$v9 = DB::table('vente')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('montant');
		$v10 = DB::table('vente')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('montant');
		$v11 = DB::table('vente')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('montant');
		$v12 = DB::table('vente')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('montant');
		
		//REMB SUR VENTE COMPTANT
		$remb1 = DB::table('retourcommande')->where('date', 'like', '%'.$a."-01".'%')->where('etat','Validée')->get()->sum('montant');
		$remb2 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->get()->sum('montant');
		$remb3 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->get()->sum('montant');
		$remb4 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->get()->sum('montant');
		$remb5 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->get()->sum('montant');
		$remb6 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->get()->sum('montant');
		$remb7 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->get()->sum('montant');
		$remb8 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->get()->sum('montant');
		$remb9 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->get()->sum('montant');
		$remb10 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->get()->sum('montant');
		$remb11 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->get()->sum('montant');
		$remb12 = DB::table('retourcommande')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->get()->sum('montant');

		
		$v001 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-01".'%')->where('etat','Validée')->sum('montant');
		$v22 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('montant');
		$v33 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('montant');
		$v44 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('montant');
		$v55 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('montant');
		$v66 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('montant');
		$v77 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('montant');
		$v88 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('montant');
		$v99 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('montant');
		$v100 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('montant');
		$v111 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('montant');
		$v112 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('montant');
		
		$tr1 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-01".'%')->where('etat','Validée')->sum('montant');
		$tr2 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('montant');
		$tr3 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('montant');
		$tr4 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('montant');
		$tr5 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('montant');
		$tr6 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('montant');
		$tr7 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('montant');
		$tr8 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('montant');
		$tr9 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('montant');
		$tr10 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('montant');
		$tr11 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('montant');
		$tr12 = DB::table('retourcommandeclient')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('montant');
		
		$v01 = ($v1 + $v001) - ($remb1 + $tr1); $v02 = ($v2 + $v22) - ($remb2 + $tr2); $v03 = ($v3 + $v33) - ($remb3 + $tr3); $v04 = ($v4 + $v44) - ($remb4 + $tr4); $v05 = ($v5 + $v55) - ($remb5 + $tr5); $v06 = ($v6 + $v66) - ($remb6 + $tr6);
		$v07 = ($v7 + $v77) - ($remb7 + $tr7); $v08 = ($v8 + $v88) - ($remb8 + $tr8); $v09 = ($v9 + $v99) - ($remb9 + $tr9); $v010 = ($v10 + $v100) - ($remb10 + $tr10); 
		$v011 = ($v11 + $v111) - ($remb11 + $tr11); $v012 = ($v12 + $v112) - ($remb12 + $tr12); 
		
		//LES BENEF AU COMPTANT
		$b1 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-01".'%')->where('etat','Validée')->sum('benef');
		$b2 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('benef');
		$b3 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('benef');
		$b4 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('benef');
		$b5 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('benef');
		$b6 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('benef');
		$b7 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('benef');
		$b8 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('benef');
		$b9 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('benef');
		$b10 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('benef');
		$b11 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('benef');
		$b12 = DB::table('ligne_vente')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('benef');
		
		//REMISES COMPTANT
		$r1 = DB::table('vente')->where('date', 'like',  '%'.$a."-01".'%')->where('etat','Validée')->sum('montant_remise');
		$r2 = DB::table('vente')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('montant_remise');
		$r3 = DB::table('vente')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('montant_remise');
		$r4 = DB::table('vente')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('montant_remise');
		$r5 = DB::table('vente')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('montant_remise');
		$r6 = DB::table('vente')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('montant_remise');
		$r7 = DB::table('vente')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('montant_remise');
		$r8 = DB::table('vente')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('montant_remise');
		$r9 = DB::table('vente')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('montant_remise');
		$r10 = DB::table('vente')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('montant_remise');
		$r11 = DB::table('vente')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('montant_remise');
		$r12 = DB::table('vente')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('montant_remise');
		
		
		$b001 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-01".'%')->where('etat','Validée')->sum('benef');
		$b22 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('benef');
		$b33 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('benef');
		$b44 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('benef');
		$b55 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('benef');
		$b66 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('benef');
		$b77 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('benef');
		$b88 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('benef');
		$b99 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('benef');
		$b100 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('benef');
		$b111 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('benef');
		$b112 = DB::table('ligne_vente_client')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('benef');
		//REMISES CREDIT
		$r0011 = DB::table('vente_client')->where('date', 'like', '%'.$a."-01".'%')->where('etat','Validée')->sum('montant_remise');
		$r22 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('montant_remise');
		$r33 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('montant_remise');
		$r44 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('montant_remise');
		$r55 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('montant_remise');
		$r66 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('montant_remise');
		$r77 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('montant_remise');
		$r88 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('montant_remise');
		$r99 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('montant_remise');
		$r100 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('montant_remise');
		$r111 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('montant_remise');
		$r122 = DB::table('vente_client')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('montant_remise');
		
		//BENEF RETOUR
		$bb1 = DB::table('ligneretourcommande')->where('date', 'like', '%'.$a."-01".'%')->where('etat','Validée')->get()->sum('benef');
		$bb2 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->get()->sum('benef');
		$bb3 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->get()->sum('benef');
		$bb4 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->get()->sum('benef');
		$bb5 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->get()->sum('benef');
		$bb6 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->get()->sum('benef');
		$bb7 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->get()->sum('benef');
		$bb8 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->get()->sum('benef');
		$bb9 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->get()->sum('benef');
		$bb10 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->get()->sum('benef');
		$bb11 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->get()->sum('benef');
		$bb12 = DB::table('ligneretourcommande')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->get()->sum('benef');
		//BENEF RETOUR BL
		$bbb1 = DB::table('ligneretourcommandeclient')->where('date', 'like', '%'.$a."-01".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb2 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb3 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb4 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb5 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb6 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb7 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb8 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb9 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb10 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb11 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->get()->sum('benef');
		$bbb12 = DB::table('ligneretourcommandeclient')->where('date', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->get()->sum('benef');
		
		
		//$b01 = $b1 + $b11; $b02 = $b2 + $b22; $b03 = $b3 + $b33; $b04 = $b4 + $b44; $b05 = $b5 + $b55; $b06 = $b6 + $b66; $b07 = $b7 + $b77; $b08 = $b8 + $b88; $b09 = $b9 + $b99; $b010 = $b10 + $b100; $b011 = $b11 + $b111; $b012 = $b12 + $b112; 
		$b01 = ($b001 + $b1) - ($r1 + $r0011 + $bb1 + $bbb1); $b02 = ($b2 + $b22) - ($r2 + $r22 + $bb2 + $bbb2); $b03 = ($b3 + $b33) - ($r3 + $r33 + $bb3 + $bbb3); 
		$b04 = ($b4 + $b44) - ($r4 + $r44+ $bb4 + $bbb4); $b05 = ($b5 + $b55) - ($r5 + $r55 + $bb5 + $bbb5); 
		$b06 = ($b6 + $b66) - ($r6 + $r66 + $bb6 + $bbb6); $b07 = ($b7 + $b77) - ($r7 + $r77 + $bb7 + $bbb7); $b08 = ($b8 + $b88) - ($r8 + $r88 + $bb8 + $bbb8);
		$b09 = ($b9 + $b99) - ($r9 + $r99 + $bb9 + $bbb9); $b010 = ($b10 + $b100) - ($r10 + $r100 + $bb10 + $bbb10); 
		$b011 = ($b11 + $b111) - ($r11 + $r111 + $bb11 + $bbb11); $b012 = ($b12 + $b112) - ($r12 + $r122 + $bb12 + $bbb12); 
		//LES DEPENSES
		
		$d1 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-01".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d2 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-02".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d3 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-03".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d4 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-04".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d5 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-05".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d6 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-06".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d7 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-07".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d8 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-08".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d9 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-09".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d10 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-10".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d11 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-11".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$d12 = DB::table('caisse_depense')->where('date', 'like',  '%'.$a."-12".'%')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		
		//LES ACHATS
	
		$a1 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-01".'%')->where('etat','Validée')->sum('montant');
		$a2 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-02".'%')->where('etat','Validée')->sum('montant');
		$a3 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-03".'%')->where('etat','Validée')->sum('montant');
		$a4 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-04".'%')->where('etat','Validée')->sum('montant');
		$a5 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-05".'%')->where('etat','Validée')->sum('montant');
		$a6 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-06".'%')->where('etat','Validée')->sum('montant');
		$a7 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-07".'%')->where('etat','Validée')->sum('montant');
		$a8 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-08".'%')->where('etat','Validée')->sum('montant');
		$a9 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-09".'%')->where('etat','Validée')->sum('montant');
		$a10 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-10".'%')->where('etat','Validée')->sum('montant');
		$a11 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-11".'%')->where('etat','Validée')->sum('montant');
		$a12 = DB::table('appro_vendable')->where('date_appro', 'like',  '%'.$a."-12".'%')->where('etat','Validée')->sum('montant');
		
		@endphp
            chart: {
                height: 350,
                type: 'bar',
            },
            plotOptions: {
                bar: {
                    horizontal: false,
                    endingShape: 'rounded',
                    columnWidth: '55%',
                },
            },
            dataLabels: {
                enabled: false
            },
            stroke: {
                show: true,
                width: 2,
                colors: ['transparent']
            },
            series: [{
                name: 'Total vente',
                data: [{{$v01}}, {{$v02}}, {{$v03}}, {{$v04}}, {{$v05}}, {{$v06}}, {{$v07}}, {{$v08}}, {{$v09}}, {{$v010}}, {{$v011}}, {{$v012}}]
            }, {
                name: 'Bénéfice réalisé',
                data: [{{$b01}}, {{$b02}}, {{$b03}}, {{$b04}}, {{$b05}}, {{$b06}}, {{$b07}}, {{$b08}}, {{$b09}}, {{$b010}}, {{$b011}}, {{$b012}}]
            }, {
                name: 'Autres dépenses',
                data: [{{$d1}}, {{$d2}}, {{$d3}}, {{$d4}}, {{$d5}}, {{$d6}}, {{$d7}}, {{$d8}}, {{$d9}}, {{$d10}}, {{$d11}}, {{$d12}}]
            },
            {
                name: 'Total achats',
                data: [{{$a1}}, {{$a2}}, {{$a3}}, {{$a4}}, {{$a5}}, {{$a6}}, {{$a7}}, {{$a8}}, {{$a9}}, {{$a10}}, {{$a11}}, {{$a12}}]
            }],
            xaxis: {
                categories: ['Jan','Fev', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Aou', 'Sept', 'Oct', 'Nov', 'Déc'],
            },
            yaxis: {
                title: {
                    text: 'Montant'
                }
            },
            fill: {
                opacity: 1

            },
            tooltip: {
                y: {
                    formatter: function (val) {
                        return " " + val + " F"
                    }
                }
            }
        }

        var chart = new ApexCharts(
            document.querySelector("#chart1"),
            options
        );

        chart.render();
       

}
</script>
<script>
	
	var options2 = {
		@php
		
		//ACHATS FOURNISSEURS ET SALAIRES
		//$solded = DB::table('caisse_depense')->where('typeoperation', 'Débit')->where('etat', 'Validée')->get()->sum('montant');
		$sal1 = DB::table('salaires')->get()->sum('avance');
		$sal2 = DB::table('salaires')->get()->sum('net_a_payer');
		$sal3 = DB::table('salaires')->get()->sum('apayer');
		$tsalaire = $sal1 + $sal2 + $sal3;
		
		//FIN
		
		
		$totvente1 = DB::table('vente')->where('etat','Validée')->sum('montant');
		$totvente2 = DB::table('vente_client')->where('etat','Validée')->sum('montant');
		$ttr1 = DB::table('retourcommande')->where('etat','Validée')->sum('montant');
		$ttr2 = DB::table('retourcommandeclient')->where('etat','Validée')->sum('montant');
		$rbr = DB::table('remboursement')->where('etat1','Validée')->sum('montant');
		$totvente = ($totvente1 + $totvente2) - ($ttr1 + $ttr2);
		//$totvente = number_format($totvente, 0, ' ', ' ');
		$paiecli = DB::table('paiement_client')->sum('montant');
		$encaisse = ($totvente1 + $paiecli) - $rbr;
		$depense = DB::table('caisse_depense')->where('typeoperation','Débit')->where('nature','!=','Versement banque')->where('etat','Validée')->sum('montant');
		$benef_o = $encaisse - ($depense + $totachatfou);
		
		$benefice1 = DB::table('ligne_vente')->where('etat','Validée')->sum('benef');
		$benefice2 = DB::table('ligne_vente_client')->where('etat','Validée')->sum('benef');
		$benefice11 = DB::table('ligneretourcommande')->where('etat','Validée')->sum('benef');
		$benefice22 = DB::table('ligneretourcommandeclient')->where('etat','Validée')->sum('benef');
		$rmz1 = DB::table('vente')->where('etat','Validée')->sum('remise');
		$rmz2 = DB::table('vente_client')->where('etat','Validée')->sum('remise');
		$benefice = ($benefice1 + $benefice2) - ($benefice11 + $benefice22 + $rmz1 + $rmz2);
		
		$benef_1 = $benefice - ($depense + $totachatfou);
		
		$v1 = DB::table('ligne_vente')->where('etat','Validée')->sum('montligne');
		$v2 = DB::table('ligne_vente_client')->where('etat','Validée')->sum('montligne');
		$v = $v1 + $v2;
		@endphp
            chart: {
                width: 360,
                type: 'pie',
            },
            labels: ['Chiffre d\'affaire', 'Marge Nette', ' Total encaissé', 'Total dépense', 'Marge Brute'],
            series: [{{$totvente}}, {{$benef_1}}, {{$encaisse}}, {{$depense}}, {{$benefice}}],
            responsive: [{
                breakpoint: 480,
                options: {
                    chart: {
                        width: 300
                    },
                    legend: {
                        position: 'bottom',
						horizontalAlign: 'right',
						floating: true,
						offsetY: 55,
						offsetX: -5
                    }
                }
            }]
        }

        var chart = new ApexCharts(
            document.querySelector("#chart22"),
            options2
        );

        chart.render();

</script>
@endpush
@endsection