選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

79 行
2.0KB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use common\models\Etablissement;
  5. /**
  6. * This is the model class for table "developpement_priorite".
  7. *
  8. * @property integer $id_user
  9. * @property integer $id_developpement
  10. */
  11. class DeveloppementPriorite extends \yii\db\ActiveRecord {
  12. const PRIORITE_HAUTE = 'haute';
  13. const PRIORITE_NORMALE = 'normale';
  14. const PRIORITE_BASSE = 'basse';
  15. /**
  16. * @inheritdoc
  17. */
  18. public static function tableName() {
  19. return 'developpement_priorite';
  20. }
  21. /**
  22. * @inheritdoc
  23. */
  24. public function rules() {
  25. return [
  26. [['id_etablissement', 'id_developpement'], 'required'],
  27. [['id_etablissement', 'id_developpement'], 'integer'],
  28. [['priorite'], 'string'],
  29. ];
  30. }
  31. public function getEtablissement() {
  32. return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']);
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function attributeLabels() {
  38. return [
  39. 'id_etablissement' => 'Établissement',
  40. 'id_developpement' => 'Développement',
  41. 'priorite' => 'Priorité'
  42. ];
  43. }
  44. public function getStrPriorite() {
  45. switch ($this->priorite) {
  46. case self::PRIORITE_BASSE : return 'Basse';
  47. break;
  48. case self::PRIORITE_NORMALE : return 'Normale';
  49. break;
  50. case self::PRIORITE_HAUTE : return 'Haute';
  51. break;
  52. default: return 'Non définie';
  53. break;
  54. }
  55. }
  56. public function getClassCssStyleBouton() {
  57. $style_bouton = 'default';
  58. if ($this->priorite == DeveloppementPriorite::PRIORITE_BASSE)
  59. $style_bouton = 'info';
  60. elseif ($this->priorite == DeveloppementPriorite::PRIORITE_NORMALE)
  61. $style_bouton = 'warning';
  62. elseif ($this->priorite == DeveloppementPriorite::PRIORITE_HAUTE)
  63. $style_bouton = 'danger';
  64. return $style_bouton;
  65. }
  66. }