Procházet zdrojové kódy

Indentation + commentaires modèle Developpement / DeveloppementPriorite

refactoring
Guillaume Bourgeois před 6 roky
rodič
revize
9ccfa40174
2 změnil soubory, kde provedl 50 přidání a 14 odebrání
  1. +22
    -7
      common/models/Developpement.php
  2. +28
    -7
      common/models/DeveloppementPriorite.php

+ 22
- 7
common/models/Developpement.php Zobrazit soubor

@@ -52,7 +52,8 @@ use common\models\DeveloppementPriorite;
* @property string $statut
* @property double $estimation_temps
*/
class Developpement extends \yii\db\ActiveRecord {
class Developpement extends \yii\db\ActiveRecord
{

const STATUT_OPEN = 'open';
const STATUT_CLOSED = 'closed';
@@ -62,14 +63,16 @@ class Developpement extends \yii\db\ActiveRecord {
/**
* @inheritdoc
*/
public static function tableName() {
public static function tableName()
{
return 'developpement';
}

/**
* @inheritdoc
*/
public function rules() {
public function rules()
{
return [
[['objet', 'date'], 'required'],
[['id', 'avancement'], 'integer'],
@@ -80,18 +83,25 @@ class Developpement extends \yii\db\ActiveRecord {
];
}

public function getDeveloppementPriorite() {
/*
* Relations
*/
public function getDeveloppementPriorite()
{
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');
}

/**
* @inheritdoc
*/
public function attributeLabels() {
public function attributeLabels()
{
return [
'id' => 'ID',
'objet' => 'Sujet',
@@ -104,7 +114,12 @@ class Developpement extends \yii\db\ActiveRecord {
'date_livraison' => 'Date de livraison'
];
}

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

if (strlen($date))

+ 28
- 7
common/models/DeveloppementPriorite.php Zobrazit soubor

@@ -47,7 +47,8 @@ use common\models\Etablissement;
* @property integer $id_user
* @property integer $id_developpement
*/
class DeveloppementPriorite extends \yii\db\ActiveRecord {
class DeveloppementPriorite extends \yii\db\ActiveRecord
{

const PRIORITE_HAUTE = 'haute';
const PRIORITE_NORMALE = 'normale';
@@ -56,29 +57,37 @@ class DeveloppementPriorite extends \yii\db\ActiveRecord {
/**
* @inheritdoc
*/
public static function tableName() {
public static function tableName()
{
return 'developpement_priorite';
}

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

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

/**
* @inheritdoc
*/
public function attributeLabels() {
public function attributeLabels()
{
return [
'id_etablissement' => 'Établissement',
'id_developpement' => 'Développement',
@@ -86,7 +95,13 @@ class DeveloppementPriorite extends \yii\db\ActiveRecord {
];
}

public function getStrPriorite() {
/**
* Retourne la priorité.
*
* @return string
*/
public function getStrPriorite()
{
switch ($this->priorite) {
case self::PRIORITE_BASSE : return 'Basse';
break;
@@ -99,7 +114,13 @@ class DeveloppementPriorite extends \yii\db\ActiveRecord {
}
}

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

Načítá se…
Zrušit
Uložit