Browse Source

Indentation + commentaires modèle Developpement / DeveloppementPriorite

refactoring
Guillaume Bourgeois 6 years ago
parent
commit
9ccfa40174
2 changed files with 50 additions and 14 deletions
  1. +22
    -7
      common/models/Developpement.php
  2. +28
    -7
      common/models/DeveloppementPriorite.php

+ 22
- 7
common/models/Developpement.php View File

* @property string $statut * @property string $statut
* @property double $estimation_temps * @property double $estimation_temps
*/ */
class Developpement extends \yii\db\ActiveRecord {
class Developpement extends \yii\db\ActiveRecord
{


const STATUT_OPEN = 'open'; const STATUT_OPEN = 'open';
const STATUT_CLOSED = 'closed'; const STATUT_CLOSED = 'closed';
/** /**
* @inheritdoc * @inheritdoc
*/ */
public static function tableName() {
public static function tableName()
{
return 'developpement'; return 'developpement';
} }


/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
[['objet', 'date'], 'required'], [['objet', 'date'], 'required'],
[['id', 'avancement'], 'integer'], [['id', 'avancement'], 'integer'],
]; ];
} }


public function getDeveloppementPriorite() {
/*
* Relations
*/
public function getDeveloppementPriorite()
{
return $this->hasMany(DeveloppementPriorite::className(), ['id_developpement' => 'id'])->with('etablissement'); return $this->hasMany(DeveloppementPriorite::className(), ['id_developpement' => 'id'])->with('etablissement');
} }


public function getDeveloppementPrioriteCurrentEtablissement() {
public function getDeveloppementPrioriteCurrentEtablissement()
{
return $this->hasOne(DeveloppementPriorite::className(), ['id_developpement' => 'id'])->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement])->with('etablissement'); return $this->hasOne(DeveloppementPriorite::className(), ['id_developpement' => 'id'])->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement])->with('etablissement');
} }


/** /**
* @inheritdoc * @inheritdoc
*/ */
public function attributeLabels() {
public function attributeLabels()
{
return [ return [
'id' => 'ID', 'id' => 'ID',
'objet' => 'Sujet', 'objet' => 'Sujet',
'date_livraison' => 'Date de livraison' 'date_livraison' => 'Date de livraison'
]; ];
} }

/**
* Définit une date de livraison.
*
* @param string $date
*/
public function setDateLivraison($date = '') { public function setDateLivraison($date = '') {


if (strlen($date)) if (strlen($date))

+ 28
- 7
common/models/DeveloppementPriorite.php View File

* @property integer $id_user * @property integer $id_user
* @property integer $id_developpement * @property integer $id_developpement
*/ */
class DeveloppementPriorite extends \yii\db\ActiveRecord {
class DeveloppementPriorite extends \yii\db\ActiveRecord
{


const PRIORITE_HAUTE = 'haute'; const PRIORITE_HAUTE = 'haute';
const PRIORITE_NORMALE = 'normale'; const PRIORITE_NORMALE = 'normale';
/** /**
* @inheritdoc * @inheritdoc
*/ */
public static function tableName() {
public static function tableName()
{
return 'developpement_priorite'; return 'developpement_priorite';
} }


/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
[['id_etablissement', 'id_developpement'], 'required'], [['id_etablissement', 'id_developpement'], 'required'],
[['id_etablissement', 'id_developpement'], 'integer'], [['id_etablissement', 'id_developpement'], 'integer'],
[['priorite'], 'string'], [['priorite'], 'string'],
]; ];
} }
/*
* Relations
*/


public function getEtablissement() {
public function getEtablissement()
{
return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']); return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']);
} }


/** /**
* @inheritdoc * @inheritdoc
*/ */
public function attributeLabels() {
public function attributeLabels()
{
return [ return [
'id_etablissement' => 'Établissement', 'id_etablissement' => 'Établissement',
'id_developpement' => 'Développement', 'id_developpement' => 'Développement',
]; ];
} }


public function getStrPriorite() {
/**
* Retourne la priorité.
*
* @return string
*/
public function getStrPriorite()
{
switch ($this->priorite) { switch ($this->priorite) {
case self::PRIORITE_BASSE : return 'Basse'; case self::PRIORITE_BASSE : return 'Basse';
break; break;
} }
} }


public function getClassCssStyleBouton() {
/**
* Retourne la classe CSS du bouton servant à définir la priorité.
*
* @return string
*/
public function getClassCssStyleBouton()
{
$style_bouton = 'default'; $style_bouton = 'default';
if ($this->priorite == DeveloppementPriorite::PRIORITE_BASSE) if ($this->priorite == DeveloppementPriorite::PRIORITE_BASSE)
$style_bouton = 'info'; $style_bouton = 'info';

Loading…
Cancel
Save