|  | @@ -17,6 +17,16 @@ class DashboardWidget extends Entity{
 | 
	
		
			
				|  |  |  	public $height = 1; //Hauteur (Nombre Entier)
 | 
	
		
			
				|  |  |  	public $dashboard; //Tableau de bord (Nombre Entier)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	public $icon;
 | 
	
		
			
				|  |  | +	public $headerBackground;
 | 
	
		
			
				|  |  | +	public $description;
 | 
	
		
			
				|  |  | +	public $label;
 | 
	
		
			
				|  |  | +	public $content;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	public const MODEL_NEW = 'new';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	protected $TABLE_NAME = 'dashboard_widget';
 | 
	
		
			
				|  |  |  	public $entityLabel = 'Bloc de tableau de bord';
 | 
	
		
			
				|  |  |  	public $fields = array(
 | 
	
	
		
			
				|  | @@ -34,6 +44,32 @@ class DashboardWidget extends Entity{
 | 
	
		
			
				|  |  |  	//Colonnes indexées
 | 
	
		
			
				|  |  |  	public $indexes = array();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	public function __construct(){
 | 
	
		
			
				|  |  | +		$this->model = self::MODEL_NEW;
 | 
	
		
			
				|  |  | +		parent::__construct();
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	public function toArray($decoded=false){
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		return array_merge(array(
 | 
	
		
			
				|  |  | +			'icon' => $this->icon,
 | 
	
		
			
				|  |  | +			'headerBackground' => $this->headerBackground,
 | 
	
		
			
				|  |  | +			'description' => $this->description,
 | 
	
		
			
				|  |  | +			'label' => $this->label,
 | 
	
		
			
				|  |  | +			'content' => $this->content
 | 
	
		
			
				|  |  | +		),parent::toArray($decoded));
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	function toData(){
 | 
	
		
			
				|  |  | +		$row = $this->toArray();
 | 
	
		
			
				|  |  | +		$model = DashboardWidget::model($this->model);
 | 
	
		
			
				|  |  | +		$finalRow = $model->toArray();
 | 
	
		
			
				|  |  | +		foreach($row as $attribute=>$value){
 | 
	
		
			
				|  |  | +			if(isset($value)) $finalRow[$attribute] = $value;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return $finalRow;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	//liste des Type possibles
 | 
	
		
			
				|  |  |  	public static function types($key=null){
 | 
	
		
			
				|  |  |  		$items = array(
 | 
	
	
		
			
				|  | @@ -47,35 +83,45 @@ class DashboardWidget extends Entity{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	public static function model($slug = null){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		/*$model = array();
 | 
	
		
			
				|  |  | +		$model = array();
 | 
	
		
			
				|  |  |  		Plugin::callHook('widget',array(&$models));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		foreach($models as $model)
 | 
	
		
			
				|  |  | -			$models[$model->model] = $model;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		if(!isset($modelUid)) return $models;*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		//todo
 | 
	
		
			
				|  |  | +		$clock = new DashboardWidget();
 | 
	
		
			
				|  |  | +		$clock->icon = 'far fa-user';
 | 
	
		
			
				|  |  | +		$clock->headerBackground = 'rgb(0, 123, 255)';
 | 
	
		
			
				|  |  | +		$clock->description = 'Une Horloge toute couillone';
 | 
	
		
			
				|  |  | +		$clock->label = 'Horloge';
 | 
	
		
			
				|  |  | +		$clock->content = '<div class="text-center m-auto">13:37</div>';
 | 
	
		
			
				|  |  | +		$clock->width = 3;
 | 
	
		
			
				|  |  | +		$clock->height = 3;
 | 
	
		
			
				|  |  | +		$models['clock'] = $clock;
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$newModel = new DashboardWidget();
 | 
	
		
			
				|  |  | +		$newModel->icon = 'far fa-user';
 | 
	
		
			
				|  |  | +		$newModel->headerBackground = 'rgb(0, 123, 255)';
 | 
	
		
			
				|  |  | +		$newModel->description = 'Type de widget non définit';
 | 
	
		
			
				|  |  | +		$newModel->label = 'Nouveau widget';
 | 
	
		
			
				|  |  | +		$newModel->content = '<div class="text-center m-auto">Cliquez sur l\'icone <i class="fas fa-ellipsis-v text-muted mx-1"></i> en haut à droite pour configurer votre widget</div>';
 | 
	
		
			
				|  |  | +		$newModel->width = 3;
 | 
	
		
			
				|  |  | +		$newModel->height = 2;
 | 
	
		
			
				|  |  | +		$models[self::MODEL_NEW] = $newModel;
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		// $row = array(
 | 
	
		
			
				|  |  | -		// 	'id' => 'clock',
 | 
	
		
			
				|  |  | -		// 	'label' => "Horloge",
 | 
	
		
			
				|  |  | -		// 	'icon' => "fa-regular fa-clock",
 | 
	
		
			
				|  |  | -		// 	'description' => "Une Horloge toute couillone"
 | 
	
		
			
				|  |  | -		// );
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		//todo
 | 
	
		
			
				|  |  | -		$model = array(
 | 
	
		
			
				|  |  | -			'icon' => 'far fa-user',
 | 
	
		
			
				|  |  | -			'headerBackground' => 'rgb(0, 123, 255)',
 | 
	
		
			
				|  |  | -			'label' => 'Nouveau widget',
 | 
	
		
			
				|  |  | -			'content' => '<div class="text-center m-auto">Cliquez sur l\'icone <i class="fas fa-ellipsis-v text-muted mx-1"></i> en haut à droite pour configurer votre widget</div>',
 | 
	
		
			
				|  |  | -			'width' => 3,
 | 
	
		
			
				|  |  | -			'height' => 2
 | 
	
		
			
				|  |  | -		);
 | 
	
		
			
				|  |  | -		/*return isset($models[$modelUid]) ? $models[$modelUid] : $model;*/
 | 
	
		
			
				|  |  | +		foreach($models as $model){
 | 
	
		
			
				|  |  | +			if(!isset($model->model)) continue;
 | 
	
		
			
				|  |  | +			$models[$model->model] = $model;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if(!isset($slug)) return $models;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		return $model;
 | 
	
		
			
				|  |  | +		return isset($models[$slug]) ? $models[$slug] : $model;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ?>
 |