<?php namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use DB;
use App\Http\Controllers\Logs;


class Indicateurs  {

	//getNB Etablissements
	static public function getNbCotisants() {
		$nb=Employeur::where('id','<>','0')->where('statut','=', "ACT")->count();
		return $nb;
	}

	//getNB Employés
	static public function getNbEmployes($annee) {
		//SELECT count(*) FROM salaire Where annee='2023' and date_sor is null; 
		$nb=DB::table('salaire')->where('annee','=',$annee)->WhereNotNull('date_sor')->count();
		return $nb;
	}

	//getNB Ecritures
	static public function getEcritures($annee) {
		//SELECT count(*) FROM salaire Where annee='2023' and date_sor is null; 
		$nb=DB::table('grand_livre')->where('date_doc','like',$annee."%")->count();
		return $nb;
	}


	//getNB Transferts en attente
	static public function getTransferts() {
		$date_deb="2023-08-01";
        $obj_cotisations = Cotisation::where(function($query) {
                $query->where('releve_ref', '=', '')->orwhereNull('releve_ref');
            });
        $obj_cotisations = $obj_cotisations->where('encais_date','>',$date_deb);
        $nb = $obj_cotisations->count();
		return $nb;
	}



}