<?php namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

class reportdimnature extends Sximo  {
	
	protected $table = 'sm_sinisters_disease2';
	protected $primaryKey = '';

	public function __construct() {
		parent::__construct();
		
	}

	public static function querySelect(  ){
		
		return " SELECT 
sm_sinisters_disease2.id_account AS 'Id Compte'
,sc_accounts.name AS 'Compte'
,sm_sinisters_disease2.disease_nature AS 'Nature'
,COUNT(*) AS 'NombreDossiers'
FROM sm_sinisters_disease2
LEFT OUTER JOIN sc_accounts ON sc_accounts.id = sm_sinisters_disease2.id_account ";
	}	

	public static function queryWhere(  ){
		
		if(session('gid') == 4)
		    return " WHERE sm_sinisters_disease2.id IS NOT NULL AND sm_sinisters_disease2.id_account ='".session('aid')."'";
		else
		    return " WHERE sm_sinisters_disease2.id IS NOT NULL ";
	}
	
	public static function queryGroup(){
		return " GROUP BY sm_sinisters_disease2.id_account, sm_sinisters_disease2.disease_nature ";
	}
	

}
